当前位置: 首页>>代码示例>>PHP>>正文


PHP is_subdomain_install函数代码示例

本文整理汇总了PHP中is_subdomain_install函数的典型用法代码示例。如果您正苦于以下问题:PHP is_subdomain_install函数的具体用法?PHP is_subdomain_install怎么用?PHP is_subdomain_install使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_subdomain_install函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: category_rewrite_rules

 /**
  * This function taken and only slightly adapted from WP No Category Base plugin by Saurabh Gupta
  */
 function category_rewrite_rules($rewrite)
 {
     global $wp_rewrite;
     $category_rewrite = array();
     $categories = get_categories(array('hide_empty' => false));
     $blog_prefix = '';
     if (function_exists('is_multisite') && is_multisite() && !is_subdomain_install() && is_main_site()) {
         $blog_prefix = 'blog/';
     }
     foreach ($categories as $category) {
         $category_nicename = $category->slug;
         if ($category->parent == $category->cat_ID) {
             // recursive recursion
             $category->parent = 0;
         } elseif ($category->parent != 0) {
             $category_nicename = get_category_parents($category->parent, false, '/', true) . $category_nicename;
         }
         $category_rewrite[$blog_prefix . '(' . $category_nicename . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
         $category_rewrite[$blog_prefix . '(' . $category_nicename . ')/page/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
         $category_rewrite[$blog_prefix . '(' . $category_nicename . ')/?$'] = 'index.php?category_name=$matches[1]';
     }
     // Redirect support from Old Category Base
     $old_base = $wp_rewrite->get_category_permastruct();
     $old_base = str_replace('%category%', '(.+)', $old_base);
     $old_base = trim($old_base, '/');
     $category_rewrite[$old_base . '$'] = 'index.php?wpseo_category_redirect=$matches[1]';
     return $category_rewrite;
 }
开发者ID:kitfrench,项目名称:Futurestep,代码行数:31,代码来源:class-rewrite.php

示例2: render

    function render()
    {
        $this->open_section_box($this->id, __("Create New Site", "ns-cloner"), false, __("Create Site", "ns-cloner"));
        ?>
		<label for="target_title"><?php 
        _e("Give the Target site a Title", "ns-cloner");
        ?>
</label>
		<input type="text" name="target_title" placeholder="New Site H1"/>
		<label for="target_name"><?php 
        _e("Give the Target site a URL (or \"Name\" in WP terminology)", "ns-cloner");
        ?>
</label>
		<?php 
        if (is_subdomain_install()) {
            ?>
			<input type="text" name="target_name" />.<?php 
            echo preg_replace('|^www\\.|', '', get_current_site()->domain);
            ?>
		<?php 
        } else {
            ?>
			<?php 
            echo get_current_site()->domain . get_current_site()->path;
            ?>
<input type="text" name="target_name" />
		<?php 
        }
        ?>
	
		<?php 
        $this->close_section_box();
    }
开发者ID:alpual,项目名称:Caitlin-Sabo,代码行数:33,代码来源:ns-cloner-section-create-target.php

示例3: wdfb_get_registration_fields_array

/**
 * Helper function for generating the registration fields array.
 */
function wdfb_get_registration_fields_array()
{
    global $current_site;
    $data = Wdfb_OptionsRegistry::get_instance();
    $wp_grant_blog = false;
    if (is_multisite()) {
        $reg = get_site_option('registration');
        if ('all' == $reg) {
            $wp_grant_blog = true;
        } else {
            if ('user' != $reg) {
                return array();
            }
        }
    } else {
        if (!(int) get_option('users_can_register')) {
            return array();
        }
    }
    $fields = array(array("name" => "name"), array("name" => "email"), array("name" => "first_name"), array("name" => "last_name"), array("name" => "gender"), array("name" => "location"), array("name" => "birthday"));
    if ($wp_grant_blog) {
        $fields[] = array('name' => 'blog_title', 'description' => __('Your blog title', 'wdfb'), 'type' => 'text');
        $newdomain = is_subdomain_install() ? 'youraddress.' . preg_replace('|^www\\.|', '', $current_site->domain) : $current_site->domain . $current_site->path . 'youraddress';
        $fields[] = array('name' => 'blog_domain', 'description' => sprintf(__('Your blog address (%s)', 'wdfb'), $newdomain), 'type' => 'text');
    }
    if (!$data->get_option('wdfb_connect', 'no_captcha')) {
        $fields[] = array("name" => "captcha");
    }
    return apply_filters('wdfb-registration_fields_array', $fields);
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:33,代码来源:wdfb_utilities.php

示例4: add_rewrite_rules

 public static function add_rewrite_rules($rules)
 {
     //Get taxonomies
     $taxonomies = get_taxonomies();
     $blog_prefix = '';
     $endpoint = Slash_Edit::get_instance()->get_endpoint();
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         /* stolen from /wp-admin/options-permalink.php */
         $blog_prefix = 'blog/';
     }
     $exclude = array('category', 'post_tag', 'nav_menu', 'link_category', 'post_format');
     foreach ($taxonomies as $key => $taxonomy) {
         if (in_array($key, $exclude)) {
             continue;
         }
         $rules["{$blog_prefix}{$key}/([^/]+)/{$endpoint}(/(.*))?/?\$"] = 'index.php?' . $key . '=$matches[1]&' . $endpoint . '=$matches[3]';
     }
     //Add home_url/edit to rewrites
     $add_frontpage_edit_rules = false;
     if (!get_page_by_path($endpoint)) {
         $add_frontpage_edit_rules = true;
     } else {
         $page = get_page_by_path($endpoint);
         if (is_a($page, 'WP_Post') && $page->post_status != 'publish') {
             $add_frontpage_edit_rules = true;
         }
     }
     if ($add_frontpage_edit_rules) {
         $edit_array_rule = array("{$endpoint}/?\$" => 'index.php?' . $endpoint . '=frontpage');
         $rules = $edit_array_rule + $rules;
     }
     return $rules;
 }
开发者ID:sebjon-bytbil,项目名称:BytBil-Hemsida,代码行数:33,代码来源:slash-edit.php

示例5: is_subdomain_replaces_on

 /**
  * Determine whether to apply a subdomain replace over each value in the database.
  *
  * @return bool
  */
 function is_subdomain_replaces_on()
 {
     if (!isset($this->subdomain_replaces_on)) {
         $this->subdomain_replaces_on = is_multisite() && is_subdomain_install() && !$this->has_same_base_domain() && apply_filters('wpmdb_subdomain_replace', true);
     }
     return $this->subdomain_replaces_on;
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:12,代码来源:wpmdb-replace.php

示例6: get_blog_prefix

function get_blog_prefix()
{
    $blog_prefix = '';
    if (is_multisite() && !is_subdomain_install() && is_main_site()) {
        $blog_prefix = '/blog';
    }
    return $blog_prefix;
}
开发者ID:noplanman,项目名称:podlove-publisher,代码行数:8,代码来源:helper.php

示例7: structure

 /**
  * Update the permalink structure.
  *
  * ## DESCRIPTION
  *
  * Updates the post permalink structure.
  *
  * To regenerate a .htaccess file with WP-CLI, you'll need to add the mod_rewrite module
  * to your wp-cli.yml or config.yml. For example:
  *
  * apache_modules:
  *   - mod_rewrite
  *
  * ## OPTIONS
  *
  * <permastruct>
  * : The new permalink structure to apply.
  *
  * [--category-base=<base>]
  * : Set the base for category permalinks, i.e. '/category/'.
  *
  * [--tag-base=<base>]
  * : Set the base for tag permalinks, i.e. '/tag/'.
  *
  * [--hard]
  * : Perform a hard flush - update `.htaccess` rules as well as rewrite rules in database.
  *
  * ## EXAMPLES
  *
  *     wp rewrite structure '/%year%/%monthnum%/%postname%'
  */
 public function structure($args, $assoc_args)
 {
     global $wp_rewrite;
     // copypasta from /wp-admin/options-permalink.php
     $home_path = get_home_path();
     $iis7_permalinks = iis7_supports_permalinks();
     $prefix = $blog_prefix = '';
     if (!got_mod_rewrite() && !$iis7_permalinks) {
         $prefix = '/index.php';
     }
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         $blog_prefix = '/blog';
     }
     $permalink_structure = $args[0] == 'default' ? '' : $args[0];
     if (!empty($permalink_structure)) {
         $permalink_structure = preg_replace('#/+#', '/', '/' . str_replace('#', '', $permalink_structure));
         if ($prefix && $blog_prefix) {
             $permalink_structure = $prefix . preg_replace('#^/?index\\.php#', '', $permalink_structure);
         } else {
             $permalink_structure = $blog_prefix . $permalink_structure;
         }
     }
     $wp_rewrite->set_permalink_structure($permalink_structure);
     // Update category or tag bases
     if (isset($assoc_args['category-base'])) {
         $category_base = $assoc_args['category-base'];
         if (!empty($category_base)) {
             $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $category_base));
         }
         $wp_rewrite->set_category_base($category_base);
     }
     if (isset($assoc_args['tag-base'])) {
         $tag_base = $assoc_args['tag-base'];
         if (!empty($tag_base)) {
             $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $tag_base));
         }
         $wp_rewrite->set_tag_base($tag_base);
     }
     // make sure we detect mod_rewrite if configured in apache_modules in config
     self::apache_modules();
     // Launch a new process to flush rewrites because core expects flush
     // to happen after rewrites are set
     $new_assoc_args = array();
     if (\WP_CLI\Utils\get_flag_value($assoc_args, 'hard')) {
         $new_assoc_args['hard'] = true;
         if (!in_array('mod_rewrite', (array) WP_CLI::get_config('apache_modules'))) {
             WP_CLI::warning("Regenerating a .htaccess file requires special configuration. See usage docs.");
         }
     }
     $process_run = WP_CLI::launch_self('rewrite flush', array(), $new_assoc_args, true, true, array('apache_modules', WP_CLI::get_config('apache_modules')));
     if (!empty($process_run->stderr)) {
         // Strip "Warning: "
         WP_CLI::warning(substr($process_run->stderr, 9));
     }
     WP_CLI::success("Rewrite structure set.");
 }
开发者ID:rjagadishsingh,项目名称:wp-cli,代码行数:87,代码来源:rewrite.php

示例8: show_blog_form

function show_blog_form($blogname = '', $blog_title = '', $errors = '') {
	global $current_site;
	// Blog name
	if ( !is_subdomain_install() )
		echo '<label for="blogname">' . __('Site Name:') . '</label>';
	else
		echo '<label for="blogname">' . __('Site Domain:') . '</label>';

	if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
		<p class="error"><?php echo $errmsg ?></p>
	<?php }

	if ( !is_subdomain_install() )
		echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
	else
		echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';

	if ( !is_user_logged_in() ) {
		print '(<strong>' . __( 'Your address will be ' );
		if ( !is_subdomain_install() )
			print $current_site->domain . $current_site->path . __( 'sitename' );
		else
			print __( 'domain.' ) . $site_domain . $current_site->path;
		echo '.</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
	}

	// Blog Title
	?>
	<label for="blog_title"><?php _e('Site Title:') ?></label>
	<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
		<p class="error"><?php echo $errmsg ?></p>
	<?php }
	echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
	?>

	<div id="privacy">
        <p class="privacy-intro">
            <label for="blog_public_on"><?php _e('Privacy:') ?></label>
            <?php _e('Allow my site to appear in search engines like Google, Technorati, and in public listings around this network.'); ?>
            <br style="clear:both" />
            <label class="checkbox" for="blog_public_on">
                <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
                <strong><?php _e( 'Yes' ); ?></strong>
            </label>
            <label class="checkbox" for="blog_public_off">
                <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
                <strong><?php _e( 'No' ); ?></strong>
            </label>
        </p>
	</div>

	<?php
	do_action('signup_blogform', $errors);
}
开发者ID:realfluid,项目名称:umbaugh,代码行数:54,代码来源:wp-signup.php

示例9: dpa_get_user_avatar_link

/**
 * Return the avatar link of a user
 *
 * @param array $args This function supports these arguments:
 *  - int $size If we're showing an avatar, set it to this size
 *  - string $type What type of link to return; either "avatar", "name", or "both", or "url".
 *  - int $user_id The ID for the user.
 * @return string
 * @since Achievements (3.0)
 */
function dpa_get_user_avatar_link($args = array())
{
    $defaults = array('size' => 50, 'type' => 'both', 'user_id' => 0);
    $r = dpa_parse_args($args, $defaults, 'get_user_avatar_link');
    extract($r);
    // Default to current user
    if (empty($user_id) && is_user_logged_in()) {
        $user_id = get_current_user_id();
    }
    // Assemble some link bits
    $user_link = array();
    // BuddyPress
    if (dpa_integrate_into_buddypress()) {
        $user_url = user_trailingslashit(bp_core_get_user_domain($user_id) . dpa_get_authors_endpoint());
        // WordPress
    } else {
        $user_url = user_trailingslashit(trailingslashit(get_author_posts_url($user_id)) . dpa_get_authors_endpoint());
        /**
         * Multisite, running network-wide.
         *
         * When this function is used by the "unlocked achievement" popup, if multisite + running network-wide + and not subdomains,
         * we'll have already done switch_to_blog( DPA_ROOT_BLOG ) by the time that this function is called. This makes inspecting
         * the current site ID, and is_main_site(), both useless as the globals will have already been changed.
         *
         * We need to find out if the user is likely to be on the "main site" in this situation. so we can modify our link.
         * The main site's author URLs are prefixed with "/blog". We do this by inspecting the _wp_switched_stack global.
         *
         * I think this solution might result in a wrong link in multi-network configuration, or if the main site has been set
         * to something non-default, but these are edge-cases for now.
         */
        if (is_multisite() && !is_subdomain_install() && dpa_is_running_networkwide() && DPA_DATA_STORE === 1 && !empty($GLOBALS['_wp_switched_stack'])) {
            $last_element = count($GLOBALS['_wp_switched_stack']) - 1;
            if (isset($GLOBALS['_wp_switched_stack'][$last_element]) && $GLOBALS['_wp_switched_stack'][$last_element] != 1) {
                $user_url = str_replace(home_url(), home_url() . '/blog', $user_url);
            }
        }
    }
    // Get avatar
    if ('avatar' === $type || 'both' === $type) {
        $user_link[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($user_url), get_avatar($user_id, $size));
    }
    // Get display name
    if ('avatar' !== $type) {
        $user_link[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($user_url), get_the_author_meta('display_name', $user_id));
    }
    // Maybe return user URL only
    if ('url' === $type) {
        $user_link = $user_url;
        // Otherwise piece together the link parts and return
    } else {
        $user_link = join('&nbsp;', $user_link);
    }
    return apply_filters('dpa_get_user_avatar_link', $user_link, $args);
}
开发者ID:rlybbert,项目名称:achievements,代码行数:64,代码来源:template.php

示例10: baseurl

 /**
  * Returns the correct baseurl path of the current site's uploads folder.
  *
  * @since 3.0.0
  *
  * @return string The correct baseurl path of the current site's uploads folder.
  */
 public function baseurl()
 {
     $uploads = $this->get_uploads_dir();
     $base_url = (string) $uploads['baseurl'];
     if (!is_subdomain_install()) {
         return $base_url;
     }
     $site_url = get_option('siteurl');
     if (0 === strpos($base_url, $site_url)) {
         return $base_url;
     }
     return str_replace(parse_url($base_url, PHP_URL_HOST), parse_url($site_url, PHP_URL_HOST), $base_url);
 }
开发者ID:inpsyde,项目名称:multilingual-press,代码行数:20,代码来源:CachingBasePathAdapter.php

示例11: test_get_id_from_blogname_www

 /**
  * @ticket 34450
  */
 public function test_get_id_from_blogname_www()
 {
     global $current_site;
     $original_network = $current_site;
     $current_site = get_network(self::$network_ids['www.wordpress.net/']);
     if (is_subdomain_install()) {
         $expected = self::$site_ids['foo.wordpress.net/'];
     } else {
         $expected = self::$site_ids['www.wordpress.net/foo/'];
     }
     $result = get_id_from_blogname('foo');
     $current_site = $original_network;
     $this->assertEquals($expected, $result);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:17,代码来源:getIdFromBlogname.php

示例12: structure

 /**
  * Update the permalink structure.
  *
  * ## OPTIONS
  *
  * <permastruct>
  * : The new permalink structure to apply.
  *
  * [--category-base=<base>]
  * : Set the base for category permalinks, i.e. '/category/'.
  *
  * [--tag-base=<base>]
  * : Set the base for tag permalinks, i.e. '/tag/'.
  *
  * [--hard]
  * : Perform a hard flush - update `.htaccess` rules as well as rewrite rules in database.
  *
  * ## EXAMPLES
  *
  *     wp rewrite structure '/%year%/%monthnum%/%postname%'
  */
 public function structure($args, $assoc_args)
 {
     global $wp_rewrite;
     // copypasta from /wp-admin/options-permalink.php
     $home_path = get_home_path();
     $iis7_permalinks = iis7_supports_permalinks();
     $prefix = $blog_prefix = '';
     if (!got_mod_rewrite() && !$iis7_permalinks) {
         $prefix = '/index.php';
     }
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         $blog_prefix = '/blog';
     }
     $permalink_structure = $args[0] == 'default' ? '' : $args[0];
     if (!empty($permalink_structure)) {
         $permalink_structure = preg_replace('#/+#', '/', '/' . str_replace('#', '', $permalink_structure));
         if ($prefix && $blog_prefix) {
             $permalink_structure = $prefix . preg_replace('#^/?index\\.php#', '', $permalink_structure);
         } else {
             $permalink_structure = $blog_prefix . $permalink_structure;
         }
     }
     $wp_rewrite->set_permalink_structure($permalink_structure);
     // Update category or tag bases
     if (isset($assoc_args['category-base'])) {
         $category_base = $assoc_args['category-base'];
         if (!empty($category_base)) {
             $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $category_base));
         }
         $wp_rewrite->set_category_base($category_base);
     }
     if (isset($assoc_args['tag-base'])) {
         $tag_base = $assoc_args['tag-base'];
         if (!empty($tag_base)) {
             $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $tag_base));
         }
         $wp_rewrite->set_tag_base($tag_base);
     }
     // make sure we detect mod_rewrite if configured in apache_modules in config
     self::apache_modules();
     // Launch a new process to flush rewrites because core expects flush
     // to happen after rewrites are set
     $new_assoc_args = array();
     if (isset($assoc_args['hard'])) {
         $new_assoc_args['hard'] = true;
     }
     \WP_CLI::launch_self('rewrite flush', array(), $new_assoc_args);
     WP_CLI::success("Rewrite structure set.");
 }
开发者ID:nb,项目名称:wp-cli,代码行数:70,代码来源:rewrite.php

示例13: structure

 /**
  * Set permalink structure
  *
  * @param array $args
  * @param array $assoc_args
  */
 public function structure($args, $assoc_args)
 {
     if (!count($args) && !count($assoc_args)) {
         WP_CLI::line("usage: wp rewrite structure <new-permalink-structure>");
         exit;
     }
     global $wp_rewrite;
     // copypasta from /wp-admin/options-permalink.php
     $home_path = get_home_path();
     $iis7_permalinks = iis7_supports_permalinks();
     $prefix = $blog_prefix = '';
     if (!got_mod_rewrite() && !$iis7_permalinks) {
         $prefix = '/index.php';
     }
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         $blog_prefix = '/blog';
     }
     // Update base permastruct if argument is provided
     if (isset($args[0])) {
         $permalink_structure = $args[0] == 'default' ? '' : $args[0];
         if (!empty($permalink_structure)) {
             $permalink_structure = preg_replace('#/+#', '/', '/' . str_replace('#', '', $permalink_structure));
             if ($prefix && $blog_prefix) {
                 $permalink_structure = $prefix . preg_replace('#^/?index\\.php#', '', $permalink_structure);
             } else {
                 $permalink_structure = $blog_prefix . $permalink_structure;
             }
         }
         $wp_rewrite->set_permalink_structure($permalink_structure);
     }
     // Update category or tag bases
     if (isset($assoc_args['category-base'])) {
         $category_base = $assoc_args['category-base'];
         if (!empty($category_base)) {
             $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $category_base));
         }
         $wp_rewrite->set_category_base($category_base);
     }
     if (isset($assoc_args['tag-base'])) {
         $tag_base = $assoc_args['tag-base'];
         if (!empty($tag_base)) {
             $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $tag_base));
         }
         $wp_rewrite->set_tag_base($tag_base);
     }
     flush_rewrite_rules($hard);
 }
开发者ID:rpeterson,项目名称:wp-cli,代码行数:53,代码来源:rewrite.php

示例14: bogo_post_rewrite_rules

function bogo_post_rewrite_rules($post_rewrite)
{
    global $wp_rewrite;
    $permastruct = $wp_rewrite->permalink_structure;
    // from wp-admin/includes/misc.php
    $got_rewrite = apply_filters('got_rewrite', apache_mod_loaded('mod_rewrite', true));
    $got_url_rewrite = apply_filters('got_url_rewrite', $got_rewrite || $GLOBALS['is_nginx'] || iis7_supports_permalinks());
    if (!$got_url_rewrite) {
        $permastruct = preg_replace('#^/index\\.php#', '/index.php/%lang%', $permastruct);
    } elseif (is_multisite() && !is_subdomain_install() && is_main_site()) {
        $permastruct = preg_replace('#^/blog#', '/%lang%/blog', $permastruct);
    } else {
        $permastruct = preg_replace('#^/#', '/%lang%/', $permastruct);
    }
    $extra = bogo_generate_rewrite_rules($permastruct, array('ep_mask' => EP_PERMALINK, 'paged' => false));
    return array_merge($extra, $post_rewrite);
}
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:17,代码来源:rewrite.php

示例15: replace_url

 /**
  * @return bool
  */
 public function replace_url()
 {
     ob_start();
     $_SERVER['_REQUEST_URI'] = untrailingslashit($_SERVER['REQUEST_URI']);
     if (false === strpos($_SERVER['_REQUEST_URI'], UPLOADS_STRUCTURE_NAME)) {
         return false;
     }
     // Fix conflict with WProcket
     define('DONOTCACHEPAGE', true);
     // Get extension
     $extension = pathinfo($_SERVER['_REQUEST_URI'], PATHINFO_EXTENSION);
     // Send content type header
     header('Content-Type: ' . $this->get_mime_type_from_file_extension($extension));
     // Test if is local file for MS subfolder installation.
     $request_uri_parts = explode('/', ltrim($_SERVER['_REQUEST_URI'], '/'));
     array_shift($request_uri_parts);
     if (function_exists('is_subdomain_install') && !is_subdomain_install() && is_file(ABSPATH . implode('/', $request_uri_parts))) {
         status_header(200);
         readfile(ABSPATH . implode('/', $request_uri_parts));
         exit;
     }
     // Get remote HTML file
     $response = wp_remote_get(untrailingslashit(PROD_UPLOADS_URL) . $_SERVER['_REQUEST_URI']);
     // Get response code
     $response_code = wp_remote_retrieve_response_code($response);
     ob_end_clean();
     // Check for error and the response code
     if (!is_wp_error($response) && 200 == $response_code) {
         // Parse remote HTML file
         $data = wp_remote_retrieve_body($response);
         // Check for error
         if (!is_wp_error($data)) {
             status_header(200);
             echo $data;
             exit;
         }
     }
     //TODO Improve cache
     header('Pragma: public');
     header('Cache-Control: max-age=86400');
     header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 86400));
     //header( 'Content-Length: 0' );
     exit;
 }
开发者ID:BeAPI,项目名称:prod-images,代码行数:47,代码来源:prod-images.php


注:本文中的is_subdomain_install函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。