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' );
203 * @return array List of user IDs.
205 function get_author_user_ids() {
206 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
209 if ( !is_multisite() )
210 $level_key = $wpdb->get_blog_prefix() . 'user_level';
212 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
214 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
220 * @param int $user_id User ID.
221 * @return array|bool List of editable authors. False if no editable users.
223 function get_editable_authors( $user_id ) {
224 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
228 $editable = get_editable_user_ids( $user_id );
233 $editable = join(',', $editable);
234 $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
237 return apply_filters('get_editable_authors', $authors);
243 * @param int $user_id User ID.
244 * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
247 function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
248 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
252 $user = new WP_User( $user_id );
253 $post_type_obj = get_post_type_object($post_type);
255 if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
256 if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
257 return array($user->ID);
262 if ( !is_multisite() )
263 $level_key = $wpdb->get_blog_prefix() . 'user_level';
265 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
267 $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
268 if ( $exclude_zeros )
269 $query .= " AND meta_value != '0'";
271 return $wpdb->get_col( $query );
277 function get_nonauthor_user_ids() {
278 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
282 if ( !is_multisite() )
283 $level_key = $wpdb->get_blog_prefix() . 'user_level';
285 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
287 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
290 if ( !class_exists('WP_User_Search') ) :
292 * WordPress User Search class.
297 class WP_User_Search {
300 * {@internal Missing Description}}
309 * {@internal Missing Description}}
327 * Role name that users have.
345 * Amount of users to display per page.
351 var $users_per_page = 50;
354 * {@internal Missing Description}}
363 * {@internal Missing Description}}
372 * {@internal Missing Description}}
381 * {@internal Missing Description}}
390 * {@internal Missing Description}}
399 * {@internal Missing Description}}
408 * {@internal Missing Description}}
414 var $total_users_for_query = 0;
417 * {@internal Missing Description}}
423 var $too_many_total_users = false;
426 * {@internal Missing Description}}
435 * {@internal Missing Description}}
444 * PHP4 Constructor - Sets up the object properties.
448 * @param string $search_term Search terms string.
449 * @param int $page Optional. Page ID.
450 * @param string $role Role name.
451 * @return WP_User_Search
453 function WP_User_Search ($search_term = '', $page = '', $role = '') {
454 _deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' );
456 $this->search_term = stripslashes( $search_term );
457 $this->raw_page = ( '' == $page ) ? false : (int) $page;
458 $this->page = (int) ( '' == $page ) ? 1 : $page;
461 $this->prepare_query();
463 $this->prepare_vars_for_template_usage();
468 * {@internal Missing Short Description}}
470 * {@internal Missing Long Description}}
475 function prepare_query() {
477 $this->first_user = ($this->page - 1) * $this->users_per_page;
479 $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
480 $this->query_orderby = ' ORDER BY user_login';
483 if ( $this->search_term ) {
485 $search_sql = 'AND (';
486 foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
487 $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
488 $search_sql .= implode(' OR ', $searches);
492 $this->query_from = " FROM $wpdb->users";
493 $this->query_where = " WHERE 1=1 $search_sql";
496 $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
497 $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
498 } elseif ( is_multisite() ) {
499 $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
500 $this->query_from .= ", $wpdb->usermeta";
501 $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
504 do_action_ref_array( 'pre_user_search', array( &$this ) );
508 * {@internal Missing Short Description}}
510 * {@internal Missing Long Description}}
518 $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
520 if ( $this->results )
521 $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
523 $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
527 * {@internal Missing Short Description}}
529 * {@internal Missing Long Description}}
534 function prepare_vars_for_template_usage() {
535 $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
539 * {@internal Missing Short Description}}
541 * {@internal Missing Long Description}}
546 function do_paging() {
547 if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
549 if( ! empty($this->search_term) )
550 $args['usersearch'] = urlencode($this->search_term);
551 if( ! empty($this->role) )
552 $args['role'] = urlencode($this->role);
554 $this->paging_text = paginate_links( array(
555 'total' => ceil($this->total_users_for_query / $this->users_per_page),
556 'current' => $this->page,
557 'base' => 'users.php?%_%',
558 'format' => 'userspage=%#%',
561 if ( $this->paging_text ) {
562 $this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
563 number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
564 number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
565 number_format_i18n( $this->total_users_for_query ),
573 * {@internal Missing Short Description}}
575 * {@internal Missing Long Description}}
582 function get_results() {
583 return (array) $this->results;
587 * Displaying paging text.
589 * @see do_paging() Builds paging text.
594 function page_links() {
595 echo $this->paging_text;
599 * Whether paging is enabled.
601 * @see do_paging() Builds paging text.
608 function results_are_paged() {
609 if ( $this->paging_text )
615 * Whether there are search terms.
622 function is_search() {
623 if ( $this->search_term )
631 * Retrieve editable posts from other users.
635 * @param int $user_id User ID to not retrieve posts from.
636 * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
637 * @return array List of posts from others.
639 function get_others_unpublished_posts($user_id, $type='any') {
640 _deprecated_function( __FUNCTION__, '3.1' );
644 $editable = get_editable_user_ids( $user_id );
646 if ( in_array($type, array('draft', 'pending')) )
647 $type_sql = " post_status = '$type' ";
649 $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
651 $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
656 $editable = join(',', $editable);
657 $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) );
660 return apply_filters('get_others_drafts', $other_unpubs);
664 * Retrieve drafts from other users.
668 * @param int $user_id User ID.
669 * @return array List of drafts from other users.
671 function get_others_drafts($user_id) {
672 _deprecated_function( __FUNCTION__, '3.1' );
674 return get_others_unpublished_posts($user_id, 'draft');
678 * Retrieve pending review posts from other users.
682 * @param int $user_id User ID.
683 * @return array List of posts with pending review post type from other users.
685 function get_others_pending($user_id) {
686 _deprecated_function( __FUNCTION__, '3.1' );
688 return get_others_unpublished_posts($user_id, 'pending');
692 * Output the QuickPress dashboard widget.
696 * @deprecated Use wp_dashboard_quick_press()
697 * @see wp_dashboard_quick_press()
699 function wp_dashboard_quick_press_output() {
700 _deprecated_function( __FUNCTION__, '3.2', 'wp_dashboard_quick_press()' );
701 wp_dashboard_quick_press();
707 * @deprecated Use wp_editor()
710 function wp_tiny_mce( $teeny = false, $settings = false ) {
711 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
715 if ( ! class_exists('_WP_Editors' ) )
716 require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
718 $editor_id = 'content' . $num++;
722 'tinymce' => $settings ? $settings : true,
726 $set = _WP_Editors::parse_settings($editor_id, $set);
727 _WP_Editors::editor_settings($editor_id, $set);
732 * @deprecated Use wp_editor()
735 function wp_preload_dialogs() {
736 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
741 * @deprecated Use wp_editor()
744 function wp_print_editor_js() {
745 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
750 * @deprecated Use wp_editor()
753 function wp_quicktags() {
754 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
758 * Returns the screen layout options.
762 * @deprecated Use $current_screen->render_screen_layout()
763 * @see WP_Screen::render_screen_layout()
765 function screen_layout( $screen ) {
766 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_screen_layout()' );
768 $current_screen = get_current_screen();
770 if ( ! $current_screen )
774 $current_screen->render_screen_layout();
775 return ob_get_clean();
779 * Returns the screen's per-page options.
783 * @deprecated Use $current_screen->render_per_page_options()
784 * @see WP_Screen::render_per_page_options()
786 function screen_options( $screen ) {
787 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_per_page_options()' );
789 $current_screen = get_current_screen();
791 if ( ! $current_screen )
795 $current_screen->render_per_page_options();
796 return ob_get_clean();
800 * Renders the screen's help.
804 * @deprecated Use $current_screen->render_screen_meta()
805 * @see WP_Screen::render_screen_meta()
807 function screen_meta( $screen ) {
808 $current_screen = get_current_screen();
809 $current_screen->render_screen_meta();
813 * Favorite actions were deprecated in version 3.2. Use the admin bar instead.
818 function favorite_actions() {
819 _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' );
822 function media_upload_image() {
823 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
824 return wp_media_upload_handler();
827 function media_upload_audio() {
828 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
829 return wp_media_upload_handler();
832 function media_upload_video() {
833 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
834 return wp_media_upload_handler();
837 function media_upload_file() {
838 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
839 return wp_media_upload_handler();
842 function type_url_form_image() {
843 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('image')" );
844 return wp_media_insert_url_form( 'image' );
847 function type_url_form_audio() {
848 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('audio')" );
849 return wp_media_insert_url_form( 'audio' );
852 function type_url_form_video() {
853 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('video')" );
854 return wp_media_insert_url_form( 'video' );
857 function type_url_form_file() {
858 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" );
859 return wp_media_insert_url_form( 'file' );
863 * Add contextual help text for a page.
865 * Creates an 'Overview' help tab.
869 * @deprecated Use get_current_screen()->add_help_tab()
872 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
873 * @param string $help The content of an 'Overview' help tab.
875 function add_contextual_help( $screen, $help ) {
876 _deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' );
878 if ( is_string( $screen ) )
879 $screen = convert_to_screen( $screen );
881 WP_Screen::add_old_compat_help( $screen, $help );
885 * Get the allowed themes for the current blog.
889 * @deprecated Use wp_get_themes()
890 * @see wp_get_themes()
892 * @return array $themes Array of allowed themes.
894 function get_allowed_themes() {
895 _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'allowed' => true ) )" );
897 $themes = wp_get_themes( array( 'allowed' => true ) );
899 $wp_themes = array();
900 foreach ( $themes as $theme ) {
901 $wp_themes[ $theme->get('Name') ] = $theme;
908 * {@internal Missing Short Description}}
914 function get_broken_themes() {
915 _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'errors' => true )" );
917 $themes = wp_get_themes( array( 'errors' => true ) );
919 foreach ( $themes as $theme ) {
920 $name = $theme->get('Name');
921 $broken[ $name ] = array(
924 'Description' => $theme->errors()->get_error_message(),
931 * {@internal Missing Short Description}}
937 function current_theme_info() {
938 _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
940 return wp_get_theme();