: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* PHP4 Constructor - Sets up the object properties.
* @param string $search_term Search terms string.
* @param int $page Optional. Page ID.
* @param string $role Role name.
public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
_deprecated_constructor( 'WP_User_Search', '3.1.0', get_class( $this ) );
self::__construct( $search_term, $page, $role );
* Prepares the user search query (legacy).
* @global wpdb $wpdb WordPress database abstraction object.
public function prepare_query() {
$this->first_user = ($this->page - 1) * $this->users_per_page;
$this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
$this->query_orderby = ' ORDER BY user_login';
if ( $this->search_term ) {
foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
$search_sql .= implode(' OR ', $searches);
$this->query_from = " FROM $wpdb->users";
$this->query_where = " WHERE 1=1 $search_sql";
$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
} elseif ( is_multisite() ) {
$level_key = $wpdb->prefix . 'capabilities'; // WPMU site admins don't have user_levels.
$this->query_from .= ", $wpdb->usermeta";
$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
do_action_ref_array( 'pre_user_search', array( &$this ) );
* Executes the user search query.
* @global wpdb $wpdb WordPress database abstraction object.
public function query() {
$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // No limit.
$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
* Prepares variables for use in templates.
function prepare_vars_for_template_usage() {}
* Handles paging for the user search query.
public function do_paging() {
if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results.
if ( ! empty($this->search_term) )
$args['usersearch'] = urlencode($this->search_term);
if ( ! empty($this->role) )
$args['role'] = urlencode($this->role);
$this->paging_text = paginate_links( array(
'total' => ceil($this->total_users_for_query / $this->users_per_page),
'current' => $this->page,
'base' => 'users.php?%_%',
'format' => 'userspage=%#%',
if ( $this->paging_text ) {
$this->paging_text = sprintf(
/* translators: 1: Starting number of users on the current page, 2: Ending number of users, 3: Total number of users. */
'<span class="displaying-num">' . __( 'Displaying %1$s–%2$s of %3$s' ) . '</span>%s',
number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
number_format_i18n( $this->total_users_for_query ),
* Retrieves the user search query results.
public function get_results() {
return (array) $this->results;
* Displaying paging text.
* @see do_paging() Builds paging text.
* Whether paging is enabled.
* @see do_paging() Builds paging text.
function results_are_paged() {
if ( $this->paging_text )
* Whether there are search terms.
if ( $this->search_term )
* Retrieves editable posts from other users.
* @deprecated 3.1.0 Use get_posts()
* @global wpdb $wpdb WordPress database abstraction object.
* @param int $user_id User ID to not retrieve posts from.
* @param string $type Optional. Post type to retrieve. Accepts 'draft', 'pending' or 'any' (all).
* @return array List of posts from others.
function get_others_unpublished_posts( $user_id, $type = 'any' ) {
_deprecated_function( __FUNCTION__, '3.1.0' );
$editable = get_editable_user_ids( $user_id );
if ( in_array($type, array('draft', 'pending')) )
$type_sql = " post_status = '$type' ";
$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
$editable = join(',', $editable);
$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
return apply_filters('get_others_drafts', $other_unpubs);
* Retrieve drafts from other users.
* @deprecated 3.1.0 Use get_posts()
* @param int $user_id User ID.
* @return array List of drafts from other users.
function get_others_drafts($user_id) {
_deprecated_function( __FUNCTION__, '3.1.0' );
return get_others_unpublished_posts($user_id, 'draft');
* Retrieve pending review posts from other users.
* @deprecated 3.1.0 Use get_posts()
* @param int $user_id User ID.
* @return array List of posts with pending review post type from other users.
function get_others_pending($user_id) {
_deprecated_function( __FUNCTION__, '3.1.0' );
return get_others_unpublished_posts($user_id, 'pending');
* Output the QuickPress dashboard widget.
* @deprecated 3.2.0 Use wp_dashboard_quick_press()
* @see wp_dashboard_quick_press()
function wp_dashboard_quick_press_output() {
_deprecated_function( __FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()' );
wp_dashboard_quick_press();
* Outputs the TinyMCE editor.
* @deprecated 3.3.0 Use wp_editor()
function wp_tiny_mce( $teeny = false, $settings = false ) {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
if ( ! class_exists( '_WP_Editors', false ) )
require_once ABSPATH . WPINC . '/class-wp-editor.php';
$editor_id = 'content' . $num++;
'tinymce' => $settings ? $settings : true,
$set = _WP_Editors::parse_settings($editor_id, $set);
_WP_Editors::editor_settings($editor_id, $set);
* Preloads TinyMCE dialogs.
* @deprecated 3.3.0 Use wp_editor()
function wp_preload_dialogs() {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
* Prints TinyMCE editor JS.
* @deprecated 3.3.0 Use wp_editor()
function wp_print_editor_js() {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
* @deprecated 3.3.0 Use wp_editor()
function wp_quicktags() {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
* Returns the screen layout options.
* @deprecated 3.3.0 WP_Screen::render_screen_layout()
* @see WP_Screen::render_screen_layout()
function screen_layout( $screen ) {
_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()' );
$current_screen = get_current_screen();
$current_screen->render_screen_layout();
* Returns the screen's per-page options.
* @deprecated 3.3.0 Use WP_Screen::render_per_page_options()
* @see WP_Screen::render_per_page_options()
function screen_options( $screen ) {
_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()' );
$current_screen = get_current_screen();
$current_screen->render_per_page_options();
* Renders the screen's help.
* @deprecated 3.3.0 Use WP_Screen::render_screen_meta()
* @see WP_Screen::render_screen_meta()
function screen_meta( $screen ) {
$current_screen = get_current_screen();
$current_screen->render_screen_meta();
* Favorite actions were deprecated in version 3.2. Use the admin bar instead.
* @deprecated 3.2.0 Use WP_Admin_Bar
function favorite_actions() {
_deprecated_function( __FUNCTION__, '3.2.0', 'WP_Admin_Bar' );
* Handles uploading an image.
* @deprecated 3.3.0 Use wp_media_upload_handler()
* @see wp_media_upload_handler()
function media_upload_image() {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
* Handles uploading an audio file.
* @deprecated 3.3.0 Use wp_media_upload_handler()
* @see wp_media_upload_handler()
function media_upload_audio() {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
* Handles uploading a video file.
* @deprecated 3.3.0 Use wp_media_upload_handler()
* @see wp_media_upload_handler()
function media_upload_video() {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
* Handles uploading a generic file.
* @deprecated 3.3.0 Use wp_media_upload_handler()
* @see wp_media_upload_handler()
function media_upload_file() {
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
* Handles retrieving the insert-from-URL form for an image.
* @deprecated 3.3.0 Use wp_media_insert_url_form()
* @see wp_media_insert_url_form()
function type_url_form_image() {
_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')" );
return wp_media_insert_url_form( 'image' );
* Handles retrieving the insert-from-URL form for an audio file.
* @deprecated 3.3.0 Use wp_media_insert_url_form()
* @see wp_media_insert_url_form()
function type_url_form_audio() {
_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')" );
return wp_media_insert_url_form( 'audio' );
* Handles retrieving the insert-from-URL form for a video file.
* @deprecated 3.3.0 Use wp_media_insert_url_form()
* @see wp_media_insert_url_form()
function type_url_form_video() {
_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')" );
return wp_media_insert_url_form( 'video' );
* Handles retrieving the insert-from-URL form for a generic file.
* @deprecated 3.3.0 Use wp_media_insert_url_form()
* @see wp_media_insert_url_form()
function type_url_form_file() {
_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')" );
return wp_media_insert_url_form( 'file' );
* Add contextual help text for a page.
* Creates an 'Overview' help tab.
* @deprecated 3.3.0 Use WP_Screen::add_help_tab()
* @see WP_Screen::add_help_tab()
* @param string $screen The handle for the screen to add help to. This is usually
* the hook name returned by the `add_*_page()` functions.
* @param string $help The content of an 'Overview' help tab.
function add_contextual_help( $screen, $help ) {
_deprecated_function( __FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()' );
if ( is_string( $screen ) )