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


PHP ms_upload_constants函数代码示例

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


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

示例1: setUp

 function setUp()
 {
     global $wpdb;
     parent::setUp();
     $this->suppress = $wpdb->suppress_errors();
     update_site_option('ms_files_rewriting', 1);
     ms_upload_constants();
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:8,代码来源:ms-files-rewriting.php

示例2: test_switch_upload_dir

	function test_switch_upload_dir() {
		$this->assertTrue( is_main_site() );

		$site = get_current_site();

		$info = wp_upload_dir();
		$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
		$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
		$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
		$this->assertEquals( '', $info['error'] );

		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
		$blog_id = $this->factory->blog->create( array( 'user_id' => $user_id ) );

		switch_to_blog( $blog_id );
		$info = wp_upload_dir();
		$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] );
		$this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['path'] );
		$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
		$this->assertEquals( '', $info['error'] );
		restore_current_blog();

		$info = wp_upload_dir();
		$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
		$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
		$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
		$this->assertEquals( '', $info['error'] );

		update_site_option( 'ms_files_rewriting', 1 );
		ms_upload_constants();

		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
		$blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) );
		$info = wp_upload_dir();
		$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
		$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
		$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
		$this->assertEquals( '', $info['error'] );

		switch_to_blog( $blog_id2 );
		$info2 = wp_upload_dir();
		$this->assertNotEquals( $info, $info2 );
		$this->assertEquals( get_option( 'siteurl' )  . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['url'] );
		$this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['path'] );
		$this->assertEquals( gmstrftime('/%Y/%m'), $info2['subdir'] );
		$this->assertEquals( '', $info2['error'] );
		restore_current_blog();
		update_site_option( 'ms_files_rewriting', 0 );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:49,代码来源:ms.php

示例3: header

        header('Location: ' . $bootstrap_result);
        exit;
    }
    unset($bootstrap_result);
    $blog_id = $current_blog->blog_id;
    $public = $current_blog->public;
    if (empty($current_blog->site_id)) {
        // This dates to [MU134] and shouldn't be relevant anymore,
        // but it could be possible for arguments passed to insert_blog() etc.
        $current_blog->site_id = 1;
    }
    $site_id = $current_blog->site_id;
    wp_load_core_site_options($site_id);
}
$wpdb->set_prefix($table_prefix, false);
// $table_prefix can be set in sunrise.php
$wpdb->set_blog_id($current_blog->blog_id, $current_blog->site_id);
$table_prefix = $wpdb->get_blog_prefix();
$_wp_switched_stack = array();
$switched = false;
// need to init cache again after blog_id is set
wp_start_object_cache();
if (!$current_site instanceof WP_Network) {
    $current_site = new WP_Network($current_site);
}
if (!$current_blog instanceof WP_Site) {
    $current_blog = new WP_Site($current_blog);
}
// Define upload directory constants
ms_upload_constants();
开发者ID:pbearne,项目名称:contrib2core,代码行数:30,代码来源:ms-settings.php

示例4: add_network

 /**
  * Add a new network
  *
  * @since 1.3
  *
  * @param array $args  {
  *     Array of arguments.
  *     @type string  $domain           Domain name for new network - for VHOST=no,
  *                                     this should be FQDN, otherwise domain only.
  *     @type string  $path             Path to root of network hierarchy - should
  *                                     be '/' unless WP is cohabiting with another
  *                                     product on a domain.
  *     @type string  $site_name        Name of the root blog to be created on
  *                                     the new network.
  *     @type integer $user_id          ID of the user to add as the site owner.
  *                                     Defaults to current user ID.
  *     @type array   $meta             Array of metadata to save to this network.
  *                                     Defaults to array( 'public' => false ).
  *     @type integer $clone_network    ID of network whose networkmeta values are
  *                                     to be copied - default NULL.
  *     @type array   $options_to_clone Override default network meta options to copy
  *                                     when cloning - default NULL.
  * }
  *
  * @return integer ID of newly created network
  */
 function add_network($args = array())
 {
     global $wpdb;
     // Backward compatibility with old method of passing arguments
     if (!is_array($args) || func_num_args() > 1) {
         _deprecated_argument(__METHOD__, '1.7.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'wp-multi-network'), __METHOD__, __FILE__));
         // Juggle function parameters
         $func_args = func_get_args();
         $old_args_keys = array(0 => 'domain', 1 => 'path', 2 => 'site_name', 3 => 'clone_network', 4 => 'options_to_clone');
         // Reset array
         $args = array();
         // Rejig args
         foreach ($old_args_keys as $arg_num => $arg_key) {
             if (isset($func_args[$arg_num])) {
                 $args[$arg_key] = $func_args[$arg_num];
             }
         }
     }
     // Parse args
     $r = wp_parse_args($args, array('domain' => '', 'path' => '/', 'site_name' => __('New Network', 'wp-multi-network'), 'user_id' => get_current_user_id(), 'meta' => array('public' => get_option('blog_public', false)), 'clone_network' => false, 'options_to_clone' => array_keys(network_options_to_copy())));
     // Bail if no user with this ID
     if (empty($r['user_id']) || !get_userdata($r['user_id'])) {
         return new WP_Error('network_user', __('User does not exist.', 'wp-multi-network'));
     }
     // Permissive sanitization for super admin usage
     $r['domain'] = str_replace(' ', '', strtolower($r['domain']));
     $r['path'] = str_replace(' ', '', strtolower($r['path']));
     // Check for existing network
     $networks = get_networks(array('domain' => $r['domain'], 'path' => $r['path'], 'number' => '1'));
     // Bail if network already exists
     if (!empty($networks)) {
         return new WP_Error('network_exists', __('Network already exists.', 'wp-multi-network'));
     }
     // Insert new network
     $wpdb->insert($wpdb->site, array('domain' => $r['domain'], 'path' => $r['path']));
     $new_network_id = $wpdb->insert_id;
     // If network was created, create a blog for it too
     if (!empty($new_network_id)) {
         if (!defined('WP_INSTALLING')) {
             define('WP_INSTALLING', true);
         }
         // Switch to the new network so counts are properly bumped
         switch_to_network($new_network_id);
         // Ensure upload constants are envoked
         ms_upload_constants();
         // Create the site for the root of this network
         $new_blog_id = wpmu_create_blog($r['domain'], $r['path'], $r['site_name'], $r['user_id'], $r['meta'], $new_network_id);
         // Switch back to the current network, to avoid any issues
         restore_current_network();
         // Bail if blog could not be created
         if (is_wp_error($new_blog_id)) {
             return $new_blog_id;
         }
         /**
          * Fix upload_path for main sites on secondary networks
          * This applies only to new installs (WP 3.5+)
          */
         // Switch to network (if set & exists)
         if (defined('SITE_ID_CURRENT_SITE') && get_network(SITE_ID_CURRENT_SITE)) {
             $use_files_rewriting = get_network_option(SITE_ID_CURRENT_SITE, 'ms_files_rewriting');
         } else {
             $use_files_rewriting = get_site_option('ms_files_rewriting');
         }
         global $wp_version;
         // Create the upload_path and upload_url_path values
         if (empty($use_files_rewriting) && version_compare($wp_version, '3.7', '<')) {
             // WP_CONTENT_URL is locked to the current site and can't be overridden,
             //  so we have to replace the hostname the hard way
             $current_siteurl = get_option('siteurl');
             $new_siteurl = untrailingslashit(get_blogaddress_by_id($new_blog_id));
             $upload_url = str_replace($current_siteurl, $new_siteurl, WP_CONTENT_URL);
             $upload_url = $upload_url . '/uploads';
             $upload_dir = WP_CONTENT_DIR;
             if (0 === strpos($upload_dir, ABSPATH)) {
//.........这里部分代码省略.........
开发者ID:stuttter,项目名称:wp-multi-network,代码行数:101,代码来源:functions.php


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