3 * Deprecated admin functions from past WordPress versions. You shouldn't use these
4 * functions and look for the alternatives instead. The functions will be removed
8 * @subpackage Deprecated
12 * Deprecated functions come here to die.
18 * @deprecated Use wp_editor().
21 function tinymce_include() {
22 _deprecated_function( __FUNCTION__, '2.1', 'wp_editor()' );
28 * Unused Admin function.
34 function documentation_link() {
35 _deprecated_function( __FUNCTION__, '2.5' );
40 * Calculates the new dimensions for a downsampled image.
44 * @deprecated Use wp_constrain_dimensions()
46 * @param int $width Current width of the image
47 * @param int $height Current height of the image
48 * @param int $wmax Maximum wanted width
49 * @param int $hmax Maximum wanted height
50 * @return mixed Array(height,width) of shrunk dimensions.
52 function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
53 _deprecated_function( __FUNCTION__, '3.0', 'wp_constrain_dimensions()' );
54 return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
58 * {@internal Missing Short Description}}
62 * @deprecated Use wp_category_checklist()
63 * @see wp_category_checklist()
65 * @param unknown_type $default
66 * @param unknown_type $parent
67 * @param unknown_type $popular_ids
69 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
70 _deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' );
72 wp_category_checklist( $post_ID );
76 * {@internal Missing Short Description}}
80 * @deprecated Use wp_link_category_checklist()
81 * @see wp_link_category_checklist()
83 * @param unknown_type $default
85 function dropdown_link_categories( $default = 0 ) {
86 _deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );
88 wp_link_category_checklist( $link_id );
92 * {@internal Missing Short Description}}
96 * @deprecated Use wp_dropdown_categories()
97 * @see wp_dropdown_categories()
99 * @param unknown_type $currentcat
100 * @param unknown_type $currentparent
101 * @param unknown_type $parent
102 * @param unknown_type $level
103 * @param unknown_type $categories
106 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
107 _deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
109 $categories = get_categories( array('hide_empty' => 0) );
112 foreach ( $categories as $category ) {
113 if ( $currentcat != $category->term_id && $parent == $category->parent) {
114 $pad = str_repeat( '– ', $level );
115 $category->name = esc_html( $category->name );
116 echo "\n\t<option value='$category->term_id'";
117 if ( $currentparent == $category->term_id )
118 echo " selected='selected'";
119 echo ">$pad$category->name</option>";
120 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
129 * Register a setting and its sanitization callback
133 * @deprecated Use register_setting()
134 * @see register_setting()
136 * @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
137 * Default whitelisted option key names include "general," "discussion," and "reading," among others.
138 * @param string $option_name The name of an option to sanitize and save.
139 * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
142 function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
143 _deprecated_function( __FUNCTION__, '3.0', 'register_setting()' );
144 return register_setting( $option_group, $option_name, $sanitize_callback );
148 * Unregister a setting
152 * @deprecated Use unregister_setting()
153 * @see unregister_setting()
155 * @param unknown_type $option_group
156 * @param unknown_type $option_name
157 * @param unknown_type $sanitize_callback
160 function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
161 _deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' );
162 return unregister_setting( $option_group, $option_name, $sanitize_callback );
166 * Determines the language to use for CodePress syntax highlighting.
171 * @param string $filename
173 function codepress_get_lang( $filename ) {
174 _deprecated_function( __FUNCTION__, '3.0' );
179 * Adds Javascript required to make CodePress work on the theme/plugin editors.
184 function codepress_footer_js() {
185 _deprecated_function( __FUNCTION__, '3.0' );
190 * Determine whether to use CodePress.
195 function use_codepress() {
196 _deprecated_function( __FUNCTION__, '3.0' );
204 * @return array List of user IDs.
206 function get_author_user_ids() {
207 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
210 if ( !is_multisite() )
211 $level_key = $wpdb->get_blog_prefix() . 'user_level';
213 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
215 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
221 * @param int $user_id User ID.
222 * @return array|bool List of editable authors. False if no editable users.
224 function get_editable_authors( $user_id ) {
225 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
229 $editable = get_editable_user_ids( $user_id );
234 $editable = join(',', $editable);
235 $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
238 return apply_filters('get_editable_authors', $authors);
244 * @param int $user_id User ID.
245 * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
248 function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
249 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
253 $user = new WP_User( $user_id );
254 $post_type_obj = get_post_type_object($post_type);
256 if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
257 if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
258 return array($user->ID);
263 if ( !is_multisite() )
264 $level_key = $wpdb->get_blog_prefix() . 'user_level';
266 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
268 $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
269 if ( $exclude_zeros )
270 $query .= " AND meta_value != '0'";
272 return $wpdb->get_col( $query );
278 function get_nonauthor_user_ids() {
279 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
283 if ( !is_multisite() )
284 $level_key = $wpdb->get_blog_prefix() . 'user_level';
286 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
288 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
291 if ( !class_exists('WP_User_Search') ) :
293 * WordPress User Search class.
298 class WP_User_Search {
301 * {@internal Missing Description}}
310 * {@internal Missing Description}}
328 * Role name that users have.
346 * Amount of users to display per page.
352 var $users_per_page = 50;
355 * {@internal Missing Description}}
364 * {@internal Missing Description}}
373 * {@internal Missing Description}}
382 * {@internal Missing Description}}
391 * {@internal Missing Description}}
400 * {@internal Missing Description}}
409 * {@internal Missing Description}}
415 var $total_users_for_query = 0;
418 * {@internal Missing Description}}
424 var $too_many_total_users = false;
427 * {@internal Missing Description}}
436 * {@internal Missing Description}}
445 * PHP4 Constructor - Sets up the object properties.
449 * @param string $search_term Search terms string.
450 * @param int $page Optional. Page ID.
451 * @param string $role Role name.
452 * @return WP_User_Search
454 function WP_User_Search ($search_term = '', $page = '', $role = '') {
455 _deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' );
457 $this->search_term = stripslashes( $search_term );
458 $this->raw_page = ( '' == $page ) ? false : (int) $page;
459 $this->page = (int) ( '' == $page ) ? 1 : $page;
462 $this->prepare_query();
464 $this->prepare_vars_for_template_usage();
469 * {@internal Missing Short Description}}
471 * {@internal Missing Long Description}}
476 function prepare_query() {
478 $this->first_user = ($this->page - 1) * $this->users_per_page;
480 $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
481 $this->query_orderby = ' ORDER BY user_login';
484 if ( $this->search_term ) {
486 $search_sql = 'AND (';
487 foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
488 $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
489 $search_sql .= implode(' OR ', $searches);
493 $this->query_from = " FROM $wpdb->users";
494 $this->query_where = " WHERE 1=1 $search_sql";
497 $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
498 $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
499 } elseif ( is_multisite() ) {
500 $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
501 $this->query_from .= ", $wpdb->usermeta";
502 $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
505 do_action_ref_array( 'pre_user_search', array( &$this ) );
509 * {@internal Missing Short Description}}
511 * {@internal Missing Long Description}}
519 $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
521 if ( $this->results )
522 $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
524 $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
528 * {@internal Missing Short Description}}
530 * {@internal Missing Long Description}}
535 function prepare_vars_for_template_usage() {
536 $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
540 * {@internal Missing Short Description}}
542 * {@internal Missing Long Description}}
547 function do_paging() {
548 if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
550 if( ! empty($this->search_term) )
551 $args['usersearch'] = urlencode($this->search_term);
552 if( ! empty($this->role) )
553 $args['role'] = urlencode($this->role);
555 $this->paging_text = paginate_links( array(
556 'total' => ceil($this->total_users_for_query / $this->users_per_page),
557 'current' => $this->page,
558 'base' => 'users.php?%_%',
559 'format' => 'userspage=%#%',
562 if ( $this->paging_text ) {
563 $this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
564 number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
565 number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
566 number_format_i18n( $this->total_users_for_query ),
574 * {@internal Missing Short Description}}
576 * {@internal Missing Long Description}}
583 function get_results() {
584 return (array) $this->results;
588 * Displaying paging text.
590 * @see do_paging() Builds paging text.
595 function page_links() {
596 echo $this->paging_text;
600 * Whether paging is enabled.
602 * @see do_paging() Builds paging text.
609 function results_are_paged() {
610 if ( $this->paging_text )
616 * Whether there are search terms.
623 function is_search() {
624 if ( $this->search_term )
632 * Retrieve editable posts from other users.
636 * @param int $user_id User ID to not retrieve posts from.
637 * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
638 * @return array List of posts from others.
640 function get_others_unpublished_posts($user_id, $type='any') {
641 _deprecated_function( __FUNCTION__, '3.1' );
645 $editable = get_editable_user_ids( $user_id );
647 if ( in_array($type, array('draft', 'pending')) )
648 $type_sql = " post_status = '$type' ";
650 $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
652 $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
657 $editable = join(',', $editable);
658 $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) );
661 return apply_filters('get_others_drafts', $other_unpubs);
665 * Retrieve drafts from other users.
669 * @param int $user_id User ID.
670 * @return array List of drafts from other users.
672 function get_others_drafts($user_id) {
673 _deprecated_function( __FUNCTION__, '3.1' );
675 return get_others_unpublished_posts($user_id, 'draft');
679 * Retrieve pending review posts from other users.
683 * @param int $user_id User ID.
684 * @return array List of posts with pending review post type from other users.
686 function get_others_pending($user_id) {
687 _deprecated_function( __FUNCTION__, '3.1' );
689 return get_others_unpublished_posts($user_id, 'pending');
693 * Output the QuickPress dashboard widget.
697 * @deprecated Use wp_dashboard_quick_press()
698 * @see wp_dashboard_quick_press()
700 function wp_dashboard_quick_press_output() {
701 _deprecated_function( __FUNCTION__, '3.2', 'wp_dashboard_quick_press()' );
702 wp_dashboard_quick_press();
708 * @deprecated Use wp_editor()
711 function wp_tiny_mce( $teeny = false, $settings = false ) {
712 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
716 if ( ! class_exists('_WP_Editors' ) )
717 require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
719 $editor_id = 'content' . $num++;
723 'tinymce' => $settings ? $settings : true,
727 $set = _WP_Editors::parse_settings($editor_id, $set);
728 _WP_Editors::editor_settings($editor_id, $set);
733 * @deprecated Use wp_editor()
736 function wp_preload_dialogs() {
737 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
742 * @deprecated Use wp_editor()
745 function wp_print_editor_js() {
746 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
751 * @deprecated Use wp_editor()
754 function wp_quicktags() {
755 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
759 * Returns the screen layout options.
763 * @deprecated Use $current_screen->render_screen_layout()
764 * @see WP_Screen::render_screen_layout()
766 function screen_layout( $screen ) {
767 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_screen_layout()' );
769 $current_screen = get_current_screen();
771 if ( ! $current_screen )
775 $current_screen->render_screen_layout();
776 return ob_get_clean();
780 * Returns the screen's per-page options.
784 * @deprecated Use $current_screen->render_per_page_options()
785 * @see WP_Screen::render_per_page_options()
787 function screen_options( $screen ) {
788 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_per_page_options()' );
790 $current_screen = get_current_screen();
792 if ( ! $current_screen )
796 $current_screen->render_per_page_options();
797 return ob_get_clean();
801 * Renders the screen's help.
805 * @deprecated Use $current_screen->render_screen_meta()
806 * @see WP_Screen::render_screen_meta()
808 function screen_meta( $screen ) {
809 $current_screen = get_current_screen();
810 $current_screen->render_screen_meta();
814 * Favorite actions were deprecated in version 3.2. Use the admin bar instead.
819 function favorite_actions() {
820 _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' );
823 function media_upload_image() {
824 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
825 return wp_media_upload_handler();
828 function media_upload_audio() {
829 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
830 return wp_media_upload_handler();
833 function media_upload_video() {
834 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
835 return wp_media_upload_handler();
838 function media_upload_file() {
839 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
840 return wp_media_upload_handler();
843 function type_url_form_image() {
844 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('image')" );
845 return wp_media_insert_url_form( 'image' );
848 function type_url_form_audio() {
849 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('audio')" );
850 return wp_media_insert_url_form( 'audio' );
853 function type_url_form_video() {
854 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('video')" );
855 return wp_media_insert_url_form( 'video' );
858 function type_url_form_file() {
859 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" );
860 return wp_media_insert_url_form( 'file' );
864 * Add contextual help text for a page.
866 * Creates an 'Overview' help tab.
870 * @deprecated Use get_current_screen()->add_help_tab()
873 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
874 * @param string $help The content of an 'Overview' help tab.
876 function add_contextual_help( $screen, $help ) {
877 _deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' );
879 if ( is_string( $screen ) )
880 $screen = convert_to_screen( $screen );
882 WP_Screen::add_old_compat_help( $screen, $help );