[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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><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 determine 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|false Valid email address on success, false on failure.
 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   * @global wpdb $wpdb WordPress database abstraction object.
 183   *
 184   * @param int    $start      Optional. Offset for retrieving the blog list. Default 0.
 185   * @param int    $num        Optional. Number of blogs to list. Default 10.
 186   * @param string $deprecated Unused.
 187   */
 188  function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
 189      _deprecated_function( __FUNCTION__, '3.0.0', 'wp_get_sites()' );
 190  
 191      global $wpdb;
 192      $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 );
 193  
 194      $blog_list = array();
 195      foreach ( (array) $blogs as $details ) {
 196          $blog_list[ $details['blog_id'] ] = $details;
 197          $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'" );
 198      }
 199  
 200      if ( ! $blog_list ) {
 201          return array();
 202      }
 203  
 204      if ( 'all' === $num ) {
 205          return array_slice( $blog_list, $start, count( $blog_list ) );
 206      } else {
 207          return array_slice( $blog_list, $start, $num );
 208      }
 209  }
 210  
 211  /**
 212   * Deprecated functionality to retrieve a list of the most active sites.
 213   *
 214   * @since MU (3.0.0)
 215   * @deprecated 3.0.0
 216   *
 217   * @param int  $num     Optional. Number of activate blogs to retrieve. Default 10.
 218   * @param bool $display Optional. Whether or not to display the most active blogs list. Default true.
 219   * @return array List of "most active" sites.
 220   */
 221  function get_most_active_blogs( $num = 10, $display = true ) {
 222      _deprecated_function( __FUNCTION__, '3.0.0' );
 223  
 224      $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
 225      if ( is_array( $blogs ) ) {
 226          reset( $blogs );
 227          $most_active = array();
 228          $blog_list = array();
 229          foreach ( (array) $blogs as $key => $details ) {
 230              $most_active[ $details['blog_id'] ] = $details['postcount'];
 231              $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!
 232          }
 233          arsort( $most_active );
 234          reset( $most_active );
 235          $t = array();
 236          foreach ( (array) $most_active as $key => $details ) {
 237              $t[ $key ] = $blog_list[ $key ];
 238          }
 239          unset( $most_active );
 240          $most_active = $t;
 241      }
 242  
 243      if ( $display ) {
 244          if ( is_array( $most_active ) ) {
 245              reset( $most_active );
 246              foreach ( (array) $most_active as $key => $details ) {
 247                  $url = esc_url('http://' . $details['domain'] . $details['path']);
 248                  echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
 249              }
 250          }
 251      }
 252      return array_slice( $most_active, 0, $num );
 253  }
 254  
 255  /**
 256   * Redirect a user based on $_GET or $_POST arguments.
 257   *
 258   * The function looks for redirect arguments in the following order:
 259   * 1) $_GET['ref']
 260   * 2) $_POST['ref']
 261   * 3) $_SERVER['HTTP_REFERER']
 262   * 4) $_GET['redirect']
 263   * 5) $_POST['redirect']
 264   * 6) $url
 265   *
 266   * @since MU (3.0.0)
 267   * @deprecated 3.3.0 Use wp_redirect()
 268   * @see wp_redirect()
 269   *
 270   * @param string $url Optional. Redirect URL. Default empty.
 271   */
 272  function wpmu_admin_do_redirect( $url = '' ) {
 273      _deprecated_function( __FUNCTION__, '3.3.0', 'wp_redirect()' );
 274  
 275      $ref = '';
 276      if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
 277          wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
 278      } elseif ( isset( $_POST['ref'] ) ) {
 279          $ref = $_POST['ref'];
 280      } elseif ( isset( $_GET['ref'] ) ) {
 281          $ref = $_GET['ref'];
 282      }
 283  
 284      if ( $ref ) {
 285          $ref = wpmu_admin_redirect_add_updated_param( $ref );
 286          wp_redirect( $ref );
 287          exit;
 288      }
 289      if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
 290          wp_redirect( $_SERVER['HTTP_REFERER'] );
 291          exit;
 292      }
 293  
 294      $url = wpmu_admin_redirect_add_updated_param( $url );
 295      if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) {
 296          wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
 297      } elseif ( isset( $_GET['redirect'] ) ) {
 298          if ( str_starts_with( $_GET['redirect'], 's_' ) )
 299              $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
 300      } elseif ( isset( $_POST['redirect'] ) ) {
 301          $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
 302      }
 303      wp_redirect( $url );
 304      exit;
 305  }
 306  
 307  /**
 308   * Adds an 'updated=true' argument to a URL.
 309   *
 310   * @since MU (3.0.0)
 311   * @deprecated 3.3.0 Use add_query_arg()
 312   * @see add_query_arg()
 313   *
 314   * @param string $url Optional. Redirect URL. Default empty.
 315   * @return string
 316   */
 317  function wpmu_admin_redirect_add_updated_param( $url = '' ) {
 318      _deprecated_function( __FUNCTION__, '3.3.0', 'add_query_arg()' );
 319  
 320      if ( ! str_contains( $url, 'updated=true' ) ) {
 321          if ( ! str_contains( $url, '?' ) )
 322              return $url . '?updated=true';
 323          else
 324              return $url . '&updated=true';
 325      }
 326      return $url;
 327  }
 328  
 329  /**
 330   * Get a numeric user ID from either an email address or a login.
 331   *
 332   * A numeric string is considered to be an existing user ID
 333   * and is simply returned as such.
 334   *
 335   * @since MU (3.0.0)
 336   * @deprecated 3.6.0 Use get_user_by()
 337   * @see get_user_by()
 338   *
 339   * @param string $email_or_login Either an email address or a login.
 340   * @return int
 341   */
 342  function get_user_id_from_string( $email_or_login ) {
 343      _deprecated_function( __FUNCTION__, '3.6.0', 'get_user_by()' );
 344  
 345      if ( is_email( $email_or_login ) )
 346          $user = get_user_by( 'email', $email_or_login );
 347      elseif ( is_numeric( $email_or_login ) )
 348          return $email_or_login;
 349      else
 350          $user = get_user_by( 'login', $email_or_login );
 351  
 352      if ( $user )
 353          return $user->ID;
 354      return 0;
 355  }
 356  
 357  /**
 358   * Get a full site URL, given a domain and a path.
 359   *
 360   * @since MU (3.0.0)
 361   * @deprecated 3.7.0
 362   *
 363   * @param string $domain
 364   * @param string $path
 365   * @return string
 366   */
 367  function get_blogaddress_by_domain( $domain, $path ) {
 368      _deprecated_function( __FUNCTION__, '3.7.0' );
 369  
 370      if ( is_subdomain_install() ) {
 371          $url = "http://" . $domain.$path;
 372      } else {
 373          if ( $domain != $_SERVER['HTTP_HOST'] ) {
 374              $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
 375              $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
 376              // We're not installing the main blog.
 377              if ( 'www.' !== $blogname )
 378                  $url .= $blogname . '/';
 379          } else { // Main blog.
 380              $url = 'http://' . $domain . $path;
 381          }
 382      }
 383      return sanitize_url( $url );
 384  }
 385  
 386  /**
 387   * Create an empty blog.
 388   *
 389   * @since MU (3.0.0)
 390   * @deprecated 4.4.0
 391   *
 392   * @param string $domain       The new blog's domain.
 393   * @param string $path         The new blog's path.
 394   * @param string $weblog_title The new blog's title.
 395   * @param int    $site_id      Optional. Defaults to 1.
 396   * @return string|int The ID of the newly created blog
 397   */
 398  function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
 399      _deprecated_function( __FUNCTION__, '4.4.0' );
 400  
 401      if ( empty($path) )
 402          $path = '/';
 403  
 404      // Check if the domain has been used already. We should return an error message.
 405      if ( domain_exists($domain, $path, $site_id) )
 406          return __( '<strong>Error:</strong> Site URL you&#8217;ve entered is already taken.' );
 407  
 408      /*
 409       * Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
 410       * Need to get blog_id from wp_blogs, and create new table names.
 411       * Must restore table names at the end of function.
 412       */
 413  
 414      if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
 415          return __( '<strong>Error:</strong> There was a problem creating site entry.' );
 416  
 417      switch_to_blog($blog_id);
 418      install_blog($blog_id);
 419      restore_current_blog();
 420  
 421      return $blog_id;
 422  }
 423  
 424  /**
 425   * Get the admin for a domain/path combination.
 426   *
 427   * @since MU (3.0.0)
 428   * @deprecated 4.4.0
 429   *
 430   * @global wpdb $wpdb WordPress database abstraction object.
 431   *
 432   * @param string $domain Optional. Network domain.
 433   * @param string $path   Optional. Network path.
 434   * @return array|false The network admins.
 435   */
 436  function get_admin_users_for_domain( $domain = '', $path = '' ) {
 437      _deprecated_function( __FUNCTION__, '4.4.0' );
 438  
 439      global $wpdb;
 440  
 441      if ( ! $domain ) {
 442          $network_id = get_current_network_id();
 443      } else {
 444          $_networks  = get_networks( array(
 445              'fields' => 'ids',
 446              'number' => 1,
 447              'domain' => $domain,
 448              'path'   => $path,
 449          ) );
 450          $network_id = ! empty( $_networks ) ? array_shift( $_networks ) : 0;
 451      }
 452  
 453      if ( $network_id )
 454          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 );
 455  
 456      return false;
 457  }
 458  
 459  /**
 460   * Return an array of sites for a network or networks.
 461   *
 462   * @since 3.7.0
 463   * @deprecated 4.6.0 Use get_sites()
 464   * @see get_sites()
 465   *
 466   * @param array $args {
 467   *     Array of default arguments. Optional.
 468   *
 469   *     @type int|int[] $network_id A network ID or array of network IDs. Set to null to retrieve sites
 470   *                                 from all networks. Defaults to current network ID.
 471   *     @type int       $public     Retrieve public or non-public sites. Default null, for any.
 472   *     @type int       $archived   Retrieve archived or non-archived sites. Default null, for any.
 473   *     @type int       $mature     Retrieve mature or non-mature sites. Default null, for any.
 474   *     @type int       $spam       Retrieve spam or non-spam sites. Default null, for any.
 475   *     @type int       $deleted    Retrieve deleted or non-deleted sites. Default null, for any.
 476   *     @type int       $limit      Number of sites to limit the query to. Default 100.
 477   *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
 478   * }
 479   * @return array[] An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise,
 480   *                 an associative array of WP_Site data as arrays.
 481   */
 482  function wp_get_sites( $args = array() ) {
 483      _deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' );
 484  
 485      if ( wp_is_large_network() )
 486          return array();
 487  
 488      $defaults = array(
 489          'network_id' => get_current_network_id(),
 490          'public'     => null,
 491          'archived'   => null,
 492          'mature'     => null,
 493          'spam'       => null,
 494          'deleted'    => null,
 495          'limit'      => 100,
 496          'offset'     => 0,
 497      );
 498  
 499      $args = wp_parse_args( $args, $defaults );
 500  
 501      // Backward compatibility.
 502      if( is_array( $args['network_id'] ) ){
 503          $args['network__in'] = $args['network_id'];
 504          $args['network_id'] = null;
 505      }
 506  
 507      if( is_numeric( $args['limit'] ) ){
 508          $args['number'] = $args['limit'];
 509          $args['limit'] = null;
 510      } elseif ( ! $args['limit'] ) {
 511          $args['number'] = 0;
 512          $args['limit'] = null;
 513      }
 514  
 515      // Make sure count is disabled.
 516      $args['count'] = false;
 517  
 518      $_sites  = get_sites( $args );
 519  
 520      $results = array();
 521  
 522      foreach ( $_sites as $_site ) {
 523          $_site = get_site( $_site );
 524          $results[] = $_site->to_array();
 525      }
 526  
 527      return $results;
 528  }
 529  
 530  /**
 531   * Check whether a usermeta key has to do with the current blog.
 532   *
 533   * @since MU (3.0.0)
 534   * @deprecated 4.9.0
 535   *
 536   * @global wpdb $wpdb WordPress database abstraction object.
 537   *
 538   * @param string $key
 539   * @param int    $user_id Optional. Defaults to current user.
 540   * @param int    $blog_id Optional. Defaults to current blog.
 541   * @return bool
 542   */
 543  function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
 544      global $wpdb;
 545  
 546      _deprecated_function( __FUNCTION__, '4.9.0' );
 547  
 548      $current_user = wp_get_current_user();
 549      if ( $blog_id == 0 ) {
 550          $blog_id = get_current_blog_id();
 551      }
 552      $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
 553  
 554      return isset( $current_user->$local_key );
 555  }
 556  
 557  /**
 558   * Store basic site info in the blogs table.
 559   *
 560   * This function creates a row in the wp_blogs table and returns
 561   * the new blog's ID. It is the first step in creating a new blog.
 562   *
 563   * @since MU (3.0.0)
 564   * @deprecated 5.1.0 Use wp_insert_site()
 565   * @see wp_insert_site()
 566   *
 567   * @param string $domain  The domain of the new site.
 568   * @param string $path    The path of the new site.
 569   * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 570   * @return int|false The ID of the new row
 571   */
 572  function insert_blog($domain, $path, $site_id) {
 573      _deprecated_function( __FUNCTION__, '5.1.0', 'wp_insert_site()' );
 574  
 575      $data = array(
 576          'domain'  => $domain,
 577          'path'    => $path,
 578          'site_id' => $site_id,
 579      );
 580  
 581      $site_id = wp_insert_site( $data );
 582      if ( is_wp_error( $site_id ) ) {
 583          return false;
 584      }
 585  
 586      clean_blog_cache( $site_id );
 587  
 588      return $site_id;
 589  }
 590  
 591  /**
 592   * Install an empty blog.
 593   *
 594   * Creates the new blog tables and options. If calling this function
 595   * directly, be sure to use switch_to_blog() first, so that $wpdb
 596   * points to the new blog.
 597   *
 598   * @since MU (3.0.0)
 599   * @deprecated 5.1.0
 600   *
 601   * @global wpdb     $wpdb     WordPress database abstraction object.
 602   * @global WP_Roles $wp_roles WordPress role management object.
 603   *
 604   * @param int    $blog_id    The value returned by wp_insert_site().
 605   * @param string $blog_title The title of the new site.
 606   */
 607  function install_blog( $blog_id, $blog_title = '' ) {
 608      global $wpdb, $wp_roles;
 609  
 610      _deprecated_function( __FUNCTION__, '5.1.0' );
 611  
 612      // Cast for security.
 613      $blog_id = (int) $blog_id;
 614  
 615      require_once  ABSPATH . 'wp-admin/includes/upgrade.php';
 616  
 617      $suppress = $wpdb->suppress_errors();
 618      if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
 619          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>' );
 620      }
 621      $wpdb->suppress_errors( $suppress );
 622  
 623      $url = get_blogaddress_by_id( $blog_id );
 624  
 625      // Set everything up.
 626      make_db_current_silent( 'blog' );
 627      populate_options();
 628      populate_roles();
 629  
 630      // populate_roles() clears previous role definitions so we start over.
 631      $wp_roles = new WP_Roles();
 632  
 633      $siteurl = $home = untrailingslashit( $url );
 634  
 635      if ( ! is_subdomain_install() ) {
 636  
 637          if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
 638              $siteurl = set_url_scheme( $siteurl, 'https' );
 639          }
 640          if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
 641              $home = set_url_scheme( $home, 'https' );
 642          }
 643      }
 644  
 645      update_option( 'siteurl', $siteurl );
 646      update_option( 'home', $home );
 647  
 648      if ( get_site_option( 'ms_files_rewriting' ) ) {
 649          update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
 650      } else {
 651          update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
 652      }
 653  
 654      update_option( 'blogname', wp_unslash( $blog_title ) );
 655      update_option( 'admin_email', '' );
 656  
 657      // Remove all permissions.
 658      $table_prefix = $wpdb->get_blog_prefix();
 659      delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true );   // Delete all.
 660      delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all.
 661  }
 662  
 663  /**
 664   * Set blog defaults.
 665   *
 666   * This function creates a row in the wp_blogs table.
 667   *
 668   * @since MU (3.0.0)
 669   * @deprecated MU
 670   * @deprecated Use wp_install_defaults()
 671   *
 672   * @global wpdb $wpdb WordPress database abstraction object.
 673   *
 674   * @param int $blog_id Ignored in this function.
 675   * @param int $user_id
 676   */
 677  function install_blog_defaults( $blog_id, $user_id ) {
 678      global $wpdb;
 679  
 680      _deprecated_function( __FUNCTION__, 'MU' );
 681  
 682      require_once  ABSPATH . 'wp-admin/includes/upgrade.php';
 683  
 684      $suppress = $wpdb->suppress_errors();
 685  
 686      wp_install_defaults( $user_id );
 687  
 688      $wpdb->suppress_errors( $suppress );
 689  }
 690  
 691  /**
 692   * Update the status of a user in the database.
 693   *
 694   * Previously used in core to mark a user as spam or "ham" (not spam) in Multisite.
 695   *
 696   * @since 3.0.0
 697   * @deprecated 5.3.0 Use wp_update_user()
 698   * @see wp_update_user()
 699   *
 700   * @global wpdb $wpdb WordPress database abstraction object.
 701   *
 702   * @param int    $id         The user ID.
 703   * @param string $pref       The column in the wp_users table to update the user's status
 704   *                           in (presumably user_status, spam, or deleted).
 705   * @param int    $value      The new status for the user.
 706   * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
 707   * @return int   The initially passed $value.
 708   */
 709  function update_user_status( $id, $pref, $value, $deprecated = null ) {
 710      global $wpdb;
 711  
 712      _deprecated_function( __FUNCTION__, '5.3.0', 'wp_update_user()' );
 713  
 714      if ( null !== $deprecated ) {
 715          _deprecated_argument( __FUNCTION__, '3.0.2' );
 716      }
 717  
 718      $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
 719  
 720      $user = new WP_User( $id );
 721      clean_user_cache( $user );
 722  
 723      if ( 'spam' === $pref ) {
 724          if ( $value == 1 ) {
 725              /** This filter is documented in wp-includes/user.php */
 726              do_action( 'make_spam_user', $id );
 727          } else {
 728              /** This filter is documented in wp-includes/user.php */
 729              do_action( 'make_ham_user', $id );
 730          }
 731      }
 732  
 733      return $value;
 734  }
 735  
 736  /**
 737   * Maintains a canonical list of terms by syncing terms created for each blog with the global terms table.
 738   *
 739   * @since 3.0.0
 740   * @since 6.1.0 This function no longer does anything.
 741   * @deprecated 6.1.0
 742   *
 743   * @param int    $term_id    An ID for a term on the current blog.
 744   * @param string $deprecated Not used.
 745   * @return int An ID from the global terms table mapped from $term_id.
 746   */
 747  function global_terms( $term_id, $deprecated = '' ) {
 748      _deprecated_function( __FUNCTION__, '6.1.0' );
 749  
 750      return $term_id;
 751  }


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref