ms-deprecated.php 21 KB

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