wp/wp-admin/includes/deprecated.php
changeset 16 a86126ab1dd4
parent 7 cf61fcea0001
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   157  *
   157  *
   158  * @since 2.7.0
   158  * @since 2.7.0
   159  * @deprecated 3.0.0 Use register_setting()
   159  * @deprecated 3.0.0 Use register_setting()
   160  * @see register_setting()
   160  * @see register_setting()
   161  *
   161  *
   162  * @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
   162  * @param string $option_group A settings group name. Should correspond to an allowed option key name.
   163  * 	Default whitelisted option key names include "general," "discussion," and "reading," among others.
   163  *                             Default allowed option key names include 'general', 'discussion', 'media',
       
   164  *                             'reading', 'writing', 'misc', 'options', and 'privacy'.
   164  * @param string $option_name The name of an option to sanitize and save.
   165  * @param string $option_name The name of an option to sanitize and save.
   165  * @param callable $sanitize_callback A callback function that sanitizes the option's value.
   166  * @param callable $sanitize_callback A callback function that sanitizes the option's value.
   166  */
   167  */
   167 function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
   168 function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
   168 	_deprecated_function( __FUNCTION__, '3.0.0', 'register_setting()' );
   169 	_deprecated_function( __FUNCTION__, '3.0.0', 'register_setting()' );
   231 
   232 
   232 	global $wpdb;
   233 	global $wpdb;
   233 	if ( !is_multisite() )
   234 	if ( !is_multisite() )
   234 		$level_key = $wpdb->get_blog_prefix() . 'user_level';
   235 		$level_key = $wpdb->get_blog_prefix() . 'user_level';
   235 	else
   236 	else
   236 		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
   237 		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
   237 
   238 
   238 	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
   239 	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
   239 }
   240 }
   240 
   241 
   241 /**
   242 /**
   293 	}
   294 	}
   294 
   295 
   295 	if ( !is_multisite() )
   296 	if ( !is_multisite() )
   296 		$level_key = $wpdb->get_blog_prefix() . 'user_level';
   297 		$level_key = $wpdb->get_blog_prefix() . 'user_level';
   297 	else
   298 	else
   298 		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
   299 		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
   299 
   300 
   300 	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
   301 	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
   301 	if ( $exclude_zeros )
   302 	if ( $exclude_zeros )
   302 		$query .= " AND meta_value != '0'";
   303 		$query .= " AND meta_value != '0'";
   303 
   304 
   317 	global $wpdb;
   318 	global $wpdb;
   318 
   319 
   319 	if ( !is_multisite() )
   320 	if ( !is_multisite() )
   320 		$level_key = $wpdb->get_blog_prefix() . 'user_level';
   321 		$level_key = $wpdb->get_blog_prefix() . 'user_level';
   321 	else
   322 	else
   322 		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
   323 		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
   323 
   324 
   324 	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
   325 	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
   325 }
   326 }
   326 
   327 
   327 if ( ! class_exists( 'WP_User_Search', false ) ) :
   328 if ( ! class_exists( 'WP_User_Search', false ) ) :
   542 
   543 
   543 		if ( $this->role ) {
   544 		if ( $this->role ) {
   544 			$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
   545 			$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
   545 			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
   546 			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
   546 		} elseif ( is_multisite() ) {
   547 		} elseif ( is_multisite() ) {
   547 			$level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
   548 			$level_key = $wpdb->prefix . 'capabilities'; // WPMU site admins don't have user_levels.
   548 			$this->query_from .= ", $wpdb->usermeta";
   549 			$this->query_from .= ", $wpdb->usermeta";
   549 			$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
   550 			$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
   550 		}
   551 		}
   551 
   552 
   552 		do_action_ref_array( 'pre_user_search', array( &$this ) );
   553 		do_action_ref_array( 'pre_user_search', array( &$this ) );
   562 		global $wpdb;
   563 		global $wpdb;
   563 
   564 
   564 		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
   565 		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
   565 
   566 
   566 		if ( $this->results )
   567 		if ( $this->results )
   567 			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
   568 			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // No limit.
   568 		else
   569 		else
   569 			$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
   570 			$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
   570 	}
   571 	}
   571 
   572 
   572 	/**
   573 	/**
   582 	 *
   583 	 *
   583 	 * @since 2.1.0
   584 	 * @since 2.1.0
   584 	 * @access public
   585 	 * @access public
   585 	 */
   586 	 */
   586 	public function do_paging() {
   587 	public function do_paging() {
   587 		if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
   588 		if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results.
   588 			$args = array();
   589 			$args = array();
   589 			if ( ! empty($this->search_term) )
   590 			if ( ! empty($this->search_term) )
   590 				$args['usersearch'] = urlencode($this->search_term);
   591 				$args['usersearch'] = urlencode($this->search_term);
   591 			if ( ! empty($this->role) )
   592 			if ( ! empty($this->role) )
   592 				$args['role'] = urlencode($this->role);
   593 				$args['role'] = urlencode($this->role);
   597 				'base' => 'users.php?%_%',
   598 				'base' => 'users.php?%_%',
   598 				'format' => 'userspage=%#%',
   599 				'format' => 'userspage=%#%',
   599 				'add_args' => $args
   600 				'add_args' => $args
   600 			) );
   601 			) );
   601 			if ( $this->paging_text ) {
   602 			if ( $this->paging_text ) {
   602 				$this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
   603 				$this->paging_text = sprintf(
       
   604 					/* translators: 1: Starting number of users on the current page, 2: Ending number of users, 3: Total number of users. */
       
   605 					'<span class="displaying-num">' . __( 'Displaying %1$s&#8211;%2$s of %3$s' ) . '</span>%s',
   603 					number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
   606 					number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
   604 					number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
   607 					number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
   605 					number_format_i18n( $this->total_users_for_query ),
   608 					number_format_i18n( $this->total_users_for_query ),
   606 					$this->paging_text
   609 					$this->paging_text
   607 				);
   610 				);
   749  * Outputs the TinyMCE editor.
   752  * Outputs the TinyMCE editor.
   750  *
   753  *
   751  * @since 2.7.0
   754  * @since 2.7.0
   752  * @deprecated 3.3.0 Use wp_editor()
   755  * @deprecated 3.3.0 Use wp_editor()
   753  * @see wp_editor()
   756  * @see wp_editor()
   754  *
       
   755  * @staticvar int $num
       
   756  */
   757  */
   757 function wp_tiny_mce( $teeny = false, $settings = false ) {
   758 function wp_tiny_mce( $teeny = false, $settings = false ) {
   758 	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
   759 	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
   759 
   760 
   760 	static $num = 1;
   761 	static $num = 1;
   761 
   762 
   762 	if ( ! class_exists( '_WP_Editors', false ) )
   763 	if ( ! class_exists( '_WP_Editors', false ) )
   763 		require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
   764 		require_once ABSPATH . WPINC . '/class-wp-editor.php';
   764 
   765 
   765 	$editor_id = 'content' . $num++;
   766 	$editor_id = 'content' . $num++;
   766 
   767 
   767 	$set = array(
   768 	$set = array(
   768 		'teeny' => $teeny,
   769 		'teeny' => $teeny,
   997  *
   998  *
   998  * @since 3.0.0
   999  * @since 3.0.0
   999  * @deprecated 3.4.0 Use wp_get_themes()
  1000  * @deprecated 3.4.0 Use wp_get_themes()
  1000  * @see wp_get_themes()
  1001  * @see wp_get_themes()
  1001  *
  1002  *
  1002  * @return array $themes Array of allowed themes.
  1003  * @return WP_Theme[] Array of WP_Theme objects keyed by their name.
  1003  */
  1004  */
  1004 function get_allowed_themes() {
  1005 function get_allowed_themes() {
  1005 	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )" );
  1006 	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )" );
  1006 
  1007 
  1007 	$themes = wp_get_themes( array( 'allowed' => true ) );
  1008 	$themes = wp_get_themes( array( 'allowed' => true ) );
  1114  *
  1115  *
  1115  * @since 1.2.0
  1116  * @since 1.2.0
  1116  * @deprecated 3.5.0 Use image_resize()
  1117  * @deprecated 3.5.0 Use image_resize()
  1117  * @see image_resize()
  1118  * @see image_resize()
  1118  *
  1119  *
  1119  * @param mixed $file Filename of the original image, Or attachment id.
  1120  * @param mixed $file Filename of the original image, Or attachment ID.
  1120  * @param int $max_side Maximum length of a single side for the thumbnail.
  1121  * @param int $max_side Maximum length of a single side for the thumbnail.
  1121  * @param mixed $deprecated Never used.
  1122  * @param mixed $deprecated Never used.
  1122  * @return string Thumbnail path on success, Error string on failure.
  1123  * @return string Thumbnail path on success, Error string on failure.
  1123  */
  1124  */
  1124 function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
  1125 function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
  1152 	_deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' );
  1153 	_deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' );
  1153 
  1154 
  1154 	if ( !empty($feedback) )
  1155 	if ( !empty($feedback) )
  1155 		add_filter('update_feedback', $feedback);
  1156 		add_filter('update_feedback', $feedback);
  1156 
  1157 
  1157 	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
  1158 	require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
  1158 	$upgrader = new Core_Upgrader();
  1159 	$upgrader = new Core_Upgrader();
  1159 	return $upgrader->upgrade($current);
  1160 	return $upgrader->upgrade($current);
  1160 
  1161 
  1161 }
  1162 }
  1162 
  1163 
  1175 	_deprecated_function( __FUNCTION__, '3.7.0', 'new Plugin_Upgrader();' );
  1176 	_deprecated_function( __FUNCTION__, '3.7.0', 'new Plugin_Upgrader();' );
  1176 
  1177 
  1177 	if ( !empty($feedback) )
  1178 	if ( !empty($feedback) )
  1178 		add_filter('update_feedback', $feedback);
  1179 		add_filter('update_feedback', $feedback);
  1179 
  1180 
  1180 	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
  1181 	require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
  1181 	$upgrader = new Plugin_Upgrader();
  1182 	$upgrader = new Plugin_Upgrader();
  1182 	return $upgrader->upgrade($plugin);
  1183 	return $upgrader->upgrade($plugin);
  1183 }
  1184 }
  1184 
  1185 
  1185 /**
  1186 /**
  1197 	_deprecated_function( __FUNCTION__, '3.7.0', 'new Theme_Upgrader();' );
  1198 	_deprecated_function( __FUNCTION__, '3.7.0', 'new Theme_Upgrader();' );
  1198 
  1199 
  1199 	if ( !empty($feedback) )
  1200 	if ( !empty($feedback) )
  1200 		add_filter('update_feedback', $feedback);
  1201 		add_filter('update_feedback', $feedback);
  1201 
  1202 
  1202 	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
  1203 	require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
  1203 	$upgrader = new Theme_Upgrader();
  1204 	$upgrader = new Theme_Upgrader();
  1204 	return $upgrader->upgrade($theme);
  1205 	return $upgrader->upgrade($theme);
  1205 }
  1206 }
  1206 
  1207 
  1207 /**
  1208 /**
  1315  * @param array  $args Array of arguments for this RSS feed.
  1316  * @param array  $args Array of arguments for this RSS feed.
  1316  */
  1317  */
  1317 function wp_dashboard_plugins_output( $rss, $args = array() ) {
  1318 function wp_dashboard_plugins_output( $rss, $args = array() ) {
  1318 	_deprecated_function( __FUNCTION__, '4.8.0' );
  1319 	_deprecated_function( __FUNCTION__, '4.8.0' );
  1319 
  1320 
  1320 	// Plugin feeds plus link to install them
  1321 	// Plugin feeds plus link to install them.
  1321 	$popular = fetch_feed( $args['url']['popular'] );
  1322 	$popular = fetch_feed( $args['url']['popular'] );
  1322 
  1323 
  1323 	if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
  1324 	if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
  1324 		$plugin_slugs = array_keys( get_plugins() );
  1325 		$plugin_slugs = array_keys( get_plugins() );
  1325 		set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
  1326 		set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
  1331 		if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() )
  1332 		if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() )
  1332 			continue;
  1333 			continue;
  1333 
  1334 
  1334 		$items = $feed->get_items(0, 5);
  1335 		$items = $feed->get_items(0, 5);
  1335 
  1336 
  1336 		// Pick a random, non-installed plugin
  1337 		// Pick a random, non-installed plugin.
  1337 		while ( true ) {
  1338 		while ( true ) {
  1338 			// Abort this foreach loop iteration if there's no plugins left of this type
  1339 			// Abort this foreach loop iteration if there's no plugins left of this type.
  1339 			if ( 0 == count($items) )
  1340 			if ( 0 === count($items) )
  1340 				continue 2;
  1341 				continue 2;
  1341 
  1342 
  1342 			$item_key = array_rand($items);
  1343 			$item_key = array_rand($items);
  1343 			$item = $items[$item_key];
  1344 			$item = $items[$item_key];
  1344 
  1345 
  1363 
  1364 
  1364 			// If we get to this point, then the random plugin isn't installed and we can stop the while().
  1365 			// If we get to this point, then the random plugin isn't installed and we can stop the while().
  1365 			break;
  1366 			break;
  1366 		}
  1367 		}
  1367 
  1368 
  1368 		// Eliminate some common badly formed plugin descriptions
  1369 		// Eliminate some common badly formed plugin descriptions.
  1369 		while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
  1370 		while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
  1370 			unset($items[$item_key]);
  1371 			unset($items[$item_key]);
  1371 
  1372 
  1372 		if ( !isset($items[$item_key]) )
  1373 		if ( !isset($items[$item_key]) )
  1373 			continue;
  1374 			continue;
  1375 		$raw_title = $item->get_title();
  1376 		$raw_title = $item->get_title();
  1376 
  1377 
  1377 		$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&amp;TB_iframe=true&amp;width=600&amp;height=800';
  1378 		$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&amp;TB_iframe=true&amp;width=600&amp;height=800';
  1378 		echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) .
  1379 		echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) .
  1379 			'&nbsp;<a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' .
  1380 			'&nbsp;<a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' .
  1380 			/* translators: %s: plugin name */
  1381 			/* translators: %s: Plugin name. */
  1381 			esc_attr( sprintf( __( 'Install %s' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>';
  1382 			esc_attr( sprintf( _x( 'Install %s', 'plugin' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>';
  1382 
  1383 
  1383 		$feed->__destruct();
  1384 		$feed->__destruct();
  1384 		unset( $feed );
  1385 		unset( $feed );
  1385 	}
  1386 	}
  1386 
  1387 
  1512 			});
  1513 			});
  1513 		});
  1514 		});
  1514 	</script>
  1515 	</script>
  1515 	<?php
  1516 	<?php
  1516 }
  1517 }
       
  1518 
       
  1519 /**
       
  1520  * Previous class for list table for privacy data export requests.
       
  1521  *
       
  1522  * @since 4.9.6
       
  1523  * @deprecated 5.3.0
       
  1524  */
       
  1525 class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Data_Export_Requests_List_Table {
       
  1526 	function __construct( $args ) {
       
  1527 		_deprecated_function( __CLASS__, '5.3.0', 'WP_Privacy_Data_Export_Requests_List_Table' );
       
  1528 
       
  1529 		if ( ! isset( $args['screen'] ) || $args['screen'] === 'export_personal_data' ) {
       
  1530 			$args['screen'] = 'export-personal-data';
       
  1531 		}
       
  1532 
       
  1533 		parent::__construct( $args );
       
  1534 	}
       
  1535 }
       
  1536 
       
  1537 /**
       
  1538  * Previous class for list table for privacy data erasure requests.
       
  1539  *
       
  1540  * @since 4.9.6
       
  1541  * @deprecated 5.3.0
       
  1542  */
       
  1543 class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Data_Removal_Requests_List_Table {
       
  1544 	function __construct( $args ) {
       
  1545 		_deprecated_function( __CLASS__, '5.3.0', 'WP_Privacy_Data_Removal_Requests_List_Table' );
       
  1546 
       
  1547 		if ( ! isset( $args['screen'] ) || $args['screen'] === 'remove_personal_data' ) {
       
  1548 			$args['screen'] = 'erase-personal-data';
       
  1549 		}
       
  1550 
       
  1551 		parent::__construct( $args );
       
  1552 	}
       
  1553 }
       
  1554 
       
  1555 /**
       
  1556  * Was used to add options for the privacy requests screens before they were separate files.
       
  1557  *
       
  1558  * @since 4.9.8
       
  1559  * @access private
       
  1560  * @deprecated 5.3.0
       
  1561  */
       
  1562 function _wp_privacy_requests_screen_options() {
       
  1563 	_deprecated_function( __FUNCTION__, '5.3.0' );
       
  1564 }