Amazon_S3_And_CloudFront::get_dynamic_prefix PHP Method

get_dynamic_prefix() public method

Get the prefix path for the files. Ignores WP media library year month subdirectory setting and just uses S3 setting
public get_dynamic_prefix ( string $time = null ) : string
$time string
return string
    function get_dynamic_prefix($time = null)
    {
        $prefix = '';
        $subdir = '';
        // If multisite (and if not the main site in a post-MU network)
        if (is_multisite() && !(is_main_network() && is_main_site() && defined('MULTISITE'))) {
            if (!get_site_option('ms_files_rewriting')) {
                /*
                 * If ms-files rewriting is disabled (networks created post-3.5), it is fairly
                 * straightforward: Append sites/%d if we're not on the main site (for post-MU
                 * networks). (The extra directory prevents a four-digit ID from conflicting with
                 * a year-based directory for the main site. But if a MU-era network has disabled
                 * ms-files rewriting manually, they don't need the extra directory, as they never
                 * had wp-content/uploads for the main site.)
                 */
                if (defined('MULTISITE')) {
                    $prefix = '/sites/' . get_current_blog_id();
                } else {
                    $prefix = '/' . get_current_blog_id();
                }
            } elseif (defined('UPLOADS') && !ms_is_switched()) {
                /*
                 * Handle the old-form ms-files.php rewriting if the network still has that enabled.
                 * When ms-files rewriting is enabled, then we only listen to UPLOADS when:
                 * 1) We are not on the main site in a post-MU network, as wp-content/uploads is used
                 *    there, and
                 * 2) We are not switched, as ms_upload_constants() hardcodes these constants to reflect
                 *    the original blog ID.
                 *
                 * Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute.
                 * (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as
                 * as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
                 * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
                 */
                if (defined('BLOGUPLOADDIR')) {
                    $prefix = untrailingslashit(BLOGUPLOADDIR);
                } else {
                    $prefix = ABSPATH . UPLOADS;
                }
            }
        }
        if ($this->get_setting('use-yearmonth-folders')) {
            $subdir = $this->get_year_month_directory_name($time);
            $prefix .= $subdir;
        }
        // support legacy MS installs (<3.5 since upgraded) for subsites
        if (is_multisite() && !(is_main_network() && is_main_site()) && false === strpos($prefix, 'sites/')) {
            $details = get_blog_details(get_current_blog_id());
            $legacy_ms_prefix = 'sites/' . $details->blog_id . '/';
            $legacy_ms_prefix = apply_filters('as3cf_legacy_ms_subsite_prefix', $legacy_ms_prefix, $details);
            $prefix = '/' . trailingslashit(ltrim($legacy_ms_prefix, '/')) . ltrim($subdir, '/');
        }
        return $prefix;
    }
Amazon_S3_And_CloudFront