[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> ms-deprecated.php (source)

   1  <?php
   2  /**
   3   * Deprecated functions from WordPress MU and the multisite feature. You shouldn't
   4   * use these functions and look for the alternatives instead. The functions will be
   5   * removed in a later version.
   6   *
   7   * @package WordPress
   8   * @subpackage Deprecated
   9   * @since 3.0.0
  10   */
  11  
  12  /*
  13   * Deprecated functions come here to die.
  14   */
  15  
  16  /**
  17   * Get the "dashboard blog", the blog where users without a blog edit their profile data.
  18   * Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin.
  19   *
  20   * @since MU (3.0.0)
  21   * @deprecated 3.1.0 Use get_site()
  22   * @see get_site()
  23   *
  24   * @return WP_Site Current site object.
  25   */
  26  function get_dashboard_blog() {
  27      _deprecated_function( __FUNCTION__, '3.1.0', 'get_site()' );
  28      if ( $blog = get_site_option( 'dashboard_blog' ) ) {
  29          return get_site( $blog );
  30      }
  31  
  32      return get_site( get_network()->site_id );
  33  }
  34  
  35  /**
  36   * Generates a random password.
  37   *
  38   * @since MU (3.0.0)
  39   * @deprecated 3.0.0 Use wp_generate_password()
  40   * @see wp_generate_password()
  41   *
  42   * @param int $len Optional. The length of password to generate. Default 8.
  43   */
  44  function generate_random_password( $len = 8 ) {
  45      _deprecated_function( __FUNCTION__, '3.0.0', 'wp_generate_password()' );
  46      return wp_generate_password( $len );
  47  }
  48  
  49  /**
  50   * Determine if user is a site admin.
  51   *
  52   * Plugins should use is_multisite() instead of checking if this function exists
  53   * to determine if multisite is enabled.
  54   *
  55   * This function must reside in a file included only if is_multisite() due to
  56   * legacy function_exists() checks to determine if multisite is enabled.
  57   *
  58   * @since MU (3.0.0)
  59   * @deprecated 3.0.0 Use is_super_admin()
  60   * @see is_super_admin()
  61   *
  62   * @param string $user_login Optional. Username for the user to check. Default empty.
  63   */
  64  function is_site_admin( $user_login = '' ) {
  65      _deprecated_function( __FUNCTION__, '3.0.0', 'is_super_admin()' );
  66  
  67      if ( empty( $user_login ) ) {
  68          $user_id = get_current_user_id();
  69          if ( !$user_id )
  70              return false;
  71      } else {
  72          $user = get_user_by( 'login', $user_login );
  73          if ( ! $user->exists() )
  74              return false;
  75          $user_id = $user->ID;
  76      }
  77  
  78      return is_super_admin( $user_id );
  79  }
  80  
  81  if ( !function_exists( 'graceful_fail' ) ) :
  82  /**
  83   * Deprecated functionality to gracefully fail.
  84   *
  85   * @since MU (3.0.0)
  86   * @deprecated 3.0.0 Use wp_die()
  87   * @see wp_die()
  88   */
  89  function graceful_fail( $message ) {
  90      _deprecated_function( __FUNCTION__, '3.0.0', 'wp_die()' );
  91      $message = apply_filters( 'graceful_fail', $message );
  92      $message_template = apply_filters( 'graceful_fail_template',
  93  '<!DOCTYPE html>
  94  <html xmlns="http://www.w3.org/1999/xhtml"><head>
  95  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  96  <title>Error!</title>
  97  <style type="text/css">
  98  img {
  99      border: 0;
 100  }
 101  body {
 102  line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto;
 103  text-align: center;
 104  }
 105  .message {
 106      font-size: 22px;
 107      width: 350px;
 108      margin: auto;
 109  }
 110  </style>
 111  </head>
 112  <body>
 113  <p class="message">%s</p>
 114  </body>
 115  </html>' );
 116      die( sprintf( $message_template, $message ) );
 117  }
 118  endif;
 119  
 120  /**
 121   * Deprecated functionality to retrieve user information.
 122   *
 123   * @since MU (3.0.0)
 124   * @deprecated 3.0.0 Use get_user_by()
 125   * @see get_user_by()
 126   *
 127   * @param string $username Username.
 128   */
 129  function get_user_details( $username ) {
 130      _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_by()' );
 131      return get_user_by('login', $username);
 132  }
 133  
 134  /**
 135   * Deprecated functionality to clear the global post cache.
 136   *
 137   * @since MU (3.0.0)
 138   * @deprecated 3.0.0 Use clean_post_cache()
 139   * @see clean_post_cache()
 140   *
 141   * @param int $post_id Post ID.
 142   */
 143  function clear_global_post_cache( $post_id ) {
 144      _deprecated_function( __FUNCTION__, '3.0.0', 'clean_post_cache()' );
 145  }
 146  
 147  /**
 148   * Deprecated functionality to determin if the current site is the main site.
 149   *
 150   * @since MU (3.0.0)
 151   * @deprecated 3.0.0 Use is_main_site()
 152   * @see is_main_site()
 153   */
 154  function is_main_blog() {
 155      _deprecated_function( __FUNCTION__, '3.0.0', 'is_main_site()' );
 156      return is_main_site();
 157  }
 158  
 159  /**
 160   * Deprecated functionality to validate an email address.
 161   *
 162   * @since MU (3.0.0)
 163   * @deprecated 3.0.0 Use is_email()
 164   * @see is_email()
 165   *
 166   * @param string $email        Email address to verify.
 167   * @param bool   $check_domain Deprecated.
 168   * @return string|bool Either false or the valid email address.
 169   */
 170  function validate_email( $email, $check_domain = true) {
 171      _deprecated_function( __FUNCTION__, '3.0.0', 'is_email()' );
 172      return is_email( $email, $check_domain );
 173  }
 174  
 175  /**
 176   * Deprecated functionality to retrieve a list of all sites.
 177   *
 178   * @since MU (3.0.0)
 179   * @deprecated 3.0.0 Use wp_get_sites()
 180   * @see wp_get_sites()
 181   *
 182   * @param int    $start      Optional. Offset for retrieving the blog list. Default 0.
 183   * @param int    $num        Optional. Number of blogs to list. Default 10.
 184   * @param string $deprecated Unused.
 185   */
 186  function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
 187      _deprecated_function( __FUNCTION__, '3.0.0', 'wp_get_sites()' );
 188  
 189      global $wpdb;
 190      $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", get_current_network_id() ), ARRAY_A );
 191  
 192      $blog_list = array();
 193      foreach ( (array) $blogs as $details ) {
 194          $blog_list[ $details['blog_id'] ] = $details;
 195          $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
 196      }
 197  
 198      if ( ! $blog_list ) {
 199          return array();
 200      }
 201  
 202      if ( $num == 'all' ) {
 203          return array_slice( $blog_list, $start, count( $blog_list ) );
 204      } else {
 205          return array_slice( $blog_list, $start, $num );
 206      }
 207  }
 208  
 209  /**
 210   * Deprecated functionality to retrieve a list of the most active sites.
 211   *
 212   * @since MU (3.0.0)
 213   * @deprecated 3.0.0
 214   *
 215   * @param int  $num     Optional. Number of activate blogs to retrieve. Default 10.
 216   * @param bool $display Optional. Whether or not to display the most active blogs list. Default true.
 217   * @return array List of "most active" sites.
 218   */
 219  function get_most_active_blogs( $num = 10, $display = true ) {
 220      _deprecated_function( __FUNCTION__, '3.0.0' );
 221  
 222      $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
 223      if ( is_array( $blogs ) ) {
 224          reset( $blogs );
 225          $most_active = array();
 226          $blog_list = array();
 227          foreach ( (array) $blogs as $key => $details ) {
 228              $most_active[ $details['blog_id'] ] = $details['postcount'];
 229              $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
 230          }
 231          arsort( $most_active );
 232          reset( $most_active );
 233          $t = array();
 234          foreach ( (array) $most_active as $key => $details ) {
 235              $t[ $key ] = $blog_list[ $key ];
 236          }
 237          unset( $most_active );
 238          $most_active = $t;
 239      }
 240  
 241      if ( $display ) {
 242          if ( is_array( $most_active ) ) {
 243              reset( $most_active );
 244              foreach ( (array) $most_active as $key => $details ) {
 245                  $url = esc_url('http://' . $details['domain'] . $details['path']);
 246                  echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
 247              }
 248          }
 249      }
 250      return array_slice( $most_active, 0, $num );
 251  }
 252  
 253  /**
 254   * Redirect a user based on $_GET or $_POST arguments.
 255   *
 256   * The function looks for redirect arguments in the following order:
 257   * 1) $_GET['ref']
 258   * 2) $_POST['ref']
 259   * 3) $_SERVER['HTTP_REFERER']
 260   * 4) $_GET['redirect']
 261   * 5) $_POST['redirect']
 262   * 6) $url
 263   *
 264   * @since MU (3.0.0)
 265   * @deprecated 3.3.0 Use wp_redirect()
 266   * @see wp_redirect()
 267   *
 268   * @param string $url Optional. Redirect URL. Default empty.
 269   */
 270  function wpmu_admin_do_redirect( $url = '' ) {
 271      _deprecated_function( __FUNCTION__, '3.3.0', 'wp_redirect()' );
 272  
 273      $ref = '';
 274      if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
 275          wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
 276      } elseif ( isset( $_POST['ref'] ) ) {
 277          $ref = $_POST[ 'ref' ];
 278      } elseif ( isset( $_GET['ref'] ) ) {
 279          $ref = $_GET[ 'ref' ];
 280      }
 281  
 282      if ( $ref ) {
 283          $ref = wpmu_admin_redirect_add_updated_param( $ref );
 284          wp_redirect( $ref );
 285          exit();
 286      }
 287      if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
 288          wp_redirect( $_SERVER['HTTP_REFERER'] );
 289          exit();
 290      }
 291  
 292      $url = wpmu_admin_redirect_add_updated_param( $url );
 293      if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) {
 294          wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
 295      } elseif ( isset( $_GET['redirect'] ) ) {
 296          if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
 297              $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
 298      } elseif ( isset( $_POST['redirect'] ) ) {
 299          $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
 300      }
 301      wp_redirect( $url );
 302      exit();
 303  }
 304  
 305  /**
 306   * Adds an 'updated=true' argument to a URL.
 307   *
 308   * @since MU (3.0.0)
 309   * @deprecated 3.3.0 Use add_query_arg()
 310   * @see add_query_arg()
 311   *
 312   * @param string $url Optional. Redirect URL. Default empty.
 313   * @return string
 314   */
 315  function wpmu_admin_redirect_add_updated_param( $url = '' ) {
 316      _deprecated_function( __FUNCTION__, '3.3.0', 'add_query_arg()' );
 317  
 318      if ( strpos( $url, 'updated=true' ) === false ) {
 319          if ( strpos( $url, '?' ) === false )
 320              return $url . '?updated=true';
 321          else
 322              return $url . '&updated=true';
 323      }
 324      return $url;
 325  }
 326  
 327  /**
 328   * Get a numeric user ID from either an email address or a login.
 329   *
 330   * A numeric string is considered to be an existing user ID
 331   * and is simply returned as such.
 332   *
 333   * @since MU (3.0.0)
 334   * @deprecated 3.6.0 Use get_user_by()
 335   * @see get_user_by()
 336   *
 337   * @param string $string Either an email address or a login.
 338   * @return int
 339   */
 340  function get_user_id_from_string( $string ) {
 341      _deprecated_function( __FUNCTION__, '3.6.0', 'get_user_by()' );
 342  
 343      if ( is_email( $string ) )
 344          $user = get_user_by( 'email', $string );
 345      elseif ( is_numeric( $string ) )
 346          return $string;
 347      else
 348          $user = get_user_by( 'login', $string );
 349  
 350      if ( $user )
 351          return $user->ID;
 352      return 0;
 353  }
 354  
 355  /**
 356   * Get a full blog URL, given a domain and a path.
 357   *
 358   * @since MU (3.0.0)
 359   * @deprecated 3.7.0
 360   *
 361   * @param string $domain
 362   * @param string $path
 363   * @return string
 364   */
 365  function get_blogaddress_by_domain( $domain, $path ) {
 366      _deprecated_function( __FUNCTION__, '3.7.0' );
 367  
 368      if ( is_subdomain_install() ) {
 369          $url = "http://" . $domain.$path;
 370      } else {
 371          if ( $domain != $_SERVER['HTTP_HOST'] ) {
 372              $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
 373              $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
 374              // we're not installing the main blog
 375              if ( $blogname != 'www.' )
 376                  $url .= $blogname . '/';
 377          } else { // main blog
 378              $url = 'http://' . $domain . $path;
 379          }
 380      }
 381      return esc_url_raw( $url );
 382  }
 383  
 384  /**
 385   * Create an empty blog.
 386   *
 387   * @since MU (3.0.0)
 388   * @deprecated 4.4.0
 389   *
 390   * @param string $domain       The new blog's domain.
 391   * @param string $path         The new blog's path.
 392   * @param string $weblog_title The new blog's title.
 393   * @param int    $site_id      Optional. Defaults to 1.
 394   * @return string|int The ID of the newly created blog
 395   */
 396  function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
 397      _deprecated_function( __FUNCTION__, '4.4.0' );
 398  
 399      if ( empty($path) )
 400          $path = '/';
 401  
 402      // Check if the domain has been used already. We should return an error message.
 403      if ( domain_exists($domain, $path, $site_id) )
 404          return __( '<strong>ERROR</strong>: Site URL already taken.' );
 405  
 406      // Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
 407      // Need to get blog_id from wp_blogs, and create new table names.
 408      // Must restore table names at the end of function.
 409  
 410      if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
 411          return __( '<strong>ERROR</strong>: problem creating site entry.' );
 412  
 413      switch_to_blog($blog_id);
 414      install_blog($blog_id);
 415      restore_current_blog();
 416  
 417      return $blog_id;
 418  }
 419  
 420  /**
 421   * Get the admin for a domain/path combination.
 422   *
 423   * @since MU (3.0.0)
 424   * @deprecated 4.4.0
 425   *
 426   * @global wpdb $wpdb WordPress database abstraction object.
 427   *
 428   * @param string $domain Optional. Network domain.
 429   * @param string $path   Optional. Network path.
 430   * @return array|false The network admins.
 431   */
 432  function get_admin_users_for_domain( $domain = '', $path = '' ) {
 433      _deprecated_function( __FUNCTION__, '4.4.0' );
 434  
 435      global $wpdb;
 436  
 437      if ( ! $domain ) {
 438          $network_id = get_current_network_id();
 439      } else {
 440          $_networks  = get_networks( array(
 441              'fields' => 'ids',
 442              'number' => 1,
 443              'domain' => $domain,
 444              'path'   => $path,
 445          ) );
 446          $network_id = ! empty( $_networks ) ? array_shift( $_networks ) : 0;
 447      }
 448  
 449      if ( $network_id )
 450          return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $network_id ), ARRAY_A );
 451  
 452      return false;
 453  }
 454  
 455  /**
 456   * Return an array of sites for a network or networks.
 457   *
 458   * @since 3.7.0
 459   * @deprecated 4.6.0 Use get_sites()
 460   * @see get_sites()
 461   *
 462   * @param array $args {
 463   *     Array of default arguments. Optional.
 464   *
 465   *     @type int|array $network_id A network ID or array of network IDs. Set to null to retrieve sites
 466   *                                 from all networks. Defaults to current network ID.
 467   *     @type int       $public     Retrieve public or non-public sites. Default null, for any.
 468   *     @type int       $archived   Retrieve archived or non-archived sites. Default null, for any.
 469   *     @type int       $mature     Retrieve mature or non-mature sites. Default null, for any.
 470   *     @type int       $spam       Retrieve spam or non-spam sites. Default null, for any.
 471   *     @type int       $deleted    Retrieve deleted or non-deleted sites. Default null, for any.
 472   *     @type int       $limit      Number of sites to limit the query to. Default 100.
 473   *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
 474   * }
 475   * @return array An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise,
 476   *               an associative array of site data arrays, each containing the site (network) ID, blog ID,
 477   *               site domain and path, dates registered and modified, and the language ID. Also, boolean
 478   *               values for whether the site is public, archived, mature, spam, and/or deleted.
 479   */
 480  function wp_get_sites( $args = array() ) {
 481      _deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' );
 482  
 483      if ( wp_is_large_network() )
 484          return array();
 485  
 486      $defaults = array(
 487          'network_id' => get_current_network_id(),
 488          'public'     => null,
 489          'archived'   => null,
 490          'mature'     => null,
 491          'spam'       => null,
 492          'deleted'    => null,
 493          'limit'      => 100,
 494          'offset'     => 0,
 495      );
 496  
 497      $args = wp_parse_args( $args, $defaults );
 498  
 499      // Backwards compatibility
 500      if( is_array( $args['network_id'] ) ){
 501          $args['network__in'] = $args['network_id'];
 502          $args['network_id'] = null;
 503      }
 504  
 505      if( is_numeric( $args['limit'] ) ){
 506          $args['number'] = $args['limit'];
 507          $args['limit'] = null;
 508      } elseif ( ! $args['limit'] ) {
 509          $args['number'] = 0;
 510          $args['limit'] = null;
 511      }
 512  
 513      // Make sure count is disabled.
 514      $args['count'] = false;
 515  
 516      $_sites  = get_sites( $args );
 517  
 518      $results = array();
 519  
 520      foreach ( $_sites as $_site ) {
 521          $_site = get_site( $_site );
 522          $results[] = $_site->to_array();
 523      }
 524  
 525      return $results;
 526  }
 527  
 528  /**
 529   * Check whether a usermeta key has to do with the current blog.
 530   *
 531   * @since MU (3.0.0)
 532   * @deprecated 4.9.0
 533   *
 534   * @global wpdb $wpdb WordPress database abstraction object.
 535   *
 536   * @param string $key
 537   * @param int    $user_id Optional. Defaults to current user.
 538   * @param int    $blog_id Optional. Defaults to current blog.
 539   * @return bool
 540   */
 541  function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
 542      global $wpdb;
 543  
 544      _deprecated_function( __FUNCTION__, '4.9.0' );
 545  
 546      $current_user = wp_get_current_user();
 547      if ( $blog_id == 0 ) {
 548          $blog_id = get_current_blog_id();
 549      }
 550      $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
 551  
 552      return isset( $current_user->$local_key );
 553  }
 554  
 555  /**
 556   * Store basic site info in the blogs table.
 557   *
 558   * This function creates a row in the wp_blogs table and returns
 559   * the new blog's ID. It is the first step in creating a new blog.
 560   *
 561   * @since MU (3.0.0)
 562   * @deprecated 5.1.0 Use `wp_insert_site()`
 563   * @see wp_insert_site()
 564   *
 565   * @param string $domain  The domain of the new site.
 566   * @param string $path    The path of the new site.
 567   * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 568   * @return int|false The ID of the new row
 569   */
 570  function insert_blog($domain, $path, $site_id) {
 571      _deprecated_function( __FUNCTION__, '5.1.0', 'wp_insert_site()' );
 572  
 573      $data = array(
 574          'domain'  => $domain,
 575          'path'    => $path,
 576          'site_id' => $site_id,
 577      );
 578  
 579      $site_id = wp_insert_site( $data );
 580      if ( is_wp_error( $site_id ) ) {
 581          return false;
 582      }
 583  
 584      clean_blog_cache( $site_id );
 585  
 586      return $site_id;
 587  }
 588  
 589  /**
 590   * Install an empty blog.
 591   *
 592   * Creates the new blog tables and options. If calling this function
 593   * directly, be sure to use switch_to_blog() first, so that $wpdb
 594   * points to the new blog.
 595   *
 596   * @since MU (3.0.0)
 597   * @deprecated 5.1.0
 598   *
 599   * @global wpdb     $wpdb     WordPress database abstraction object.
 600   * @global WP_Roles $wp_roles WordPress role management object.
 601   *
 602   * @param int    $blog_id    The value returned by wp_insert_site().
 603   * @param string $blog_title The title of the new site.
 604   */
 605  function install_blog( $blog_id, $blog_title = '' ) {
 606      global $wpdb, $wp_roles;
 607  
 608      _deprecated_function( __FUNCTION__, '5.1.0' );
 609  
 610      // Cast for security
 611      $blog_id = (int) $blog_id;
 612  
 613      require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 614  
 615      $suppress = $wpdb->suppress_errors();
 616      if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
 617          die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
 618      }
 619      $wpdb->suppress_errors( $suppress );
 620  
 621      $url = get_blogaddress_by_id( $blog_id );
 622  
 623      // Set everything up
 624      make_db_current_silent( 'blog' );
 625      populate_options();
 626      populate_roles();
 627  
 628      // populate_roles() clears previous role definitions so we start over.
 629      $wp_roles = new WP_Roles();
 630  
 631      $siteurl = $home = untrailingslashit( $url );
 632  
 633      if ( ! is_subdomain_install() ) {
 634  
 635          if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
 636              $siteurl = set_url_scheme( $siteurl, 'https' );
 637          }
 638          if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
 639              $home = set_url_scheme( $home, 'https' );
 640          }
 641      }
 642  
 643      update_option( 'siteurl', $siteurl );
 644      update_option( 'home', $home );
 645  
 646      if ( get_site_option( 'ms_files_rewriting' ) ) {
 647          update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
 648      } else {
 649          update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
 650      }
 651  
 652      update_option( 'blogname', wp_unslash( $blog_title ) );
 653      update_option( 'admin_email', '' );
 654  
 655      // remove all perms
 656      $table_prefix = $wpdb->get_blog_prefix();
 657      delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
 658      delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
 659  }
 660  
 661  /**
 662   * Set blog defaults.
 663   *
 664   * This function creates a row in the wp_blogs table.
 665   *
 666   * @since MU (3.0.0)
 667   * @deprecated MU
 668   * @deprecated Use wp_install_defaults()
 669   *
 670   * @global wpdb $wpdb WordPress database abstraction object.
 671   *
 672   * @param int $blog_id Ignored in this function.
 673   * @param int $user_id
 674   */
 675  function install_blog_defaults( $blog_id, $user_id ) {
 676      global $wpdb;
 677  
 678      _deprecated_function( __FUNCTION__, 'MU' );
 679  
 680      require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 681  
 682      $suppress = $wpdb->suppress_errors();
 683  
 684      wp_install_defaults( $user_id );
 685  
 686      $wpdb->suppress_errors( $suppress );
 687  }
 688  
 689  /**
 690   * Update the status of a user in the database.
 691   *
 692   * Previously used in core to mark a user as spam or "ham" (not spam) in Multisite.
 693   *
 694   * @since 3.0.0
 695   * @deprecated 5.3.0 Use wp_update_user()
 696   * @see wp_update_user()
 697   *
 698   * @global wpdb $wpdb WordPress database abstraction object.
 699   *
 700   * @param int    $id         The user ID.
 701   * @param string $pref       The column in the wp_users table to update the user's status
 702   *                           in (presumably user_status, spam, or deleted).
 703   * @param int    $value      The new status for the user.
 704   * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
 705   * @return int   The initially passed $value.
 706   */
 707  function update_user_status( $id, $pref, $value, $deprecated = null ) {
 708      global $wpdb;
 709  
 710      _deprecated_function( __FUNCTION__, '5.3.0', 'wp_update_user()' );
 711  
 712      if ( null !== $deprecated ) {
 713          _deprecated_argument( __FUNCTION__, '3.0.2' );
 714      }
 715  
 716      $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
 717  
 718      $user = new WP_User( $id );
 719      clean_user_cache( $user );
 720  
 721      if ( $pref == 'spam' ) {
 722          if ( $value == 1 ) {
 723              /** This filter is documented in wp-includes/user.php */
 724              do_action( 'make_spam_user', $id );
 725          } else {
 726              /** This filter is documented in wp-includes/user.php */
 727              do_action( 'make_ham_user', $id );
 728          }
 729      }
 730  
 731      return $value;
 732  }


Generated: Sat Sep 21 01:00:03 2019 Cross-referenced by PHPXref 0.7.1