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()
45 * @see wp_constrain_dimensions()
47 * @param int $width Current width of the image
48 * @param int $height Current height of the image
49 * @param int $wmax Maximum wanted width
50 * @param int $hmax Maximum wanted height
51 * @return array Shrunk dimensions (width, height).
53 function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
54 _deprecated_function( __FUNCTION__, '3.0', 'wp_constrain_dimensions()' );
55 return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
59 * Calculated the new dimensions for a downsampled image.
63 * @deprecated Use wp_constrain_dimensions()
64 * @see wp_constrain_dimensions()
66 * @param int $width Current width of the image
67 * @param int $height Current height of the image
68 * @return array Shrunk dimensions (width, height).
70 function get_udims( $width, $height ) {
71 _deprecated_function( __FUNCTION__, '3.5', 'wp_constrain_dimensions()' );
72 return wp_constrain_dimensions( $width, $height, 128, 96 );
76 * {@internal Missing Short Description}}
80 * @deprecated Use wp_category_checklist()
81 * @see wp_category_checklist()
83 * @param unknown_type $default
84 * @param unknown_type $parent
85 * @param unknown_type $popular_ids
87 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
88 _deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' );
90 wp_category_checklist( $post_ID );
94 * {@internal Missing Short Description}}
98 * @deprecated Use wp_link_category_checklist()
99 * @see wp_link_category_checklist()
101 * @param unknown_type $default
103 function dropdown_link_categories( $default = 0 ) {
104 _deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );
106 wp_link_category_checklist( $link_id );
110 * {@internal Missing Short Description}}
114 * @deprecated Use wp_dropdown_categories()
115 * @see wp_dropdown_categories()
117 * @param unknown_type $currentcat
118 * @param unknown_type $currentparent
119 * @param unknown_type $parent
120 * @param unknown_type $level
121 * @param unknown_type $categories
124 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
125 _deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
127 $categories = get_categories( array('hide_empty' => 0) );
130 foreach ( $categories as $category ) {
131 if ( $currentcat != $category->term_id && $parent == $category->parent) {
132 $pad = str_repeat( '– ', $level );
133 $category->name = esc_html( $category->name );
134 echo "\n\t<option value='$category->term_id'";
135 if ( $currentparent == $category->term_id )
136 echo " selected='selected'";
137 echo ">$pad$category->name</option>";
138 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
147 * Register a setting and its sanitization callback
151 * @deprecated Use register_setting()
152 * @see register_setting()
154 * @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
155 * Default whitelisted option key names include "general," "discussion," and "reading," among others.
156 * @param string $option_name The name of an option to sanitize and save.
157 * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
160 function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
161 _deprecated_function( __FUNCTION__, '3.0', 'register_setting()' );
162 return register_setting( $option_group, $option_name, $sanitize_callback );
166 * Unregister a setting
170 * @deprecated Use unregister_setting()
171 * @see unregister_setting()
173 * @param unknown_type $option_group
174 * @param unknown_type $option_name
175 * @param unknown_type $sanitize_callback
178 function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
179 _deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' );
180 return unregister_setting( $option_group, $option_name, $sanitize_callback );
184 * Determines the language to use for CodePress syntax highlighting.
189 * @param string $filename
191 function codepress_get_lang( $filename ) {
192 _deprecated_function( __FUNCTION__, '3.0' );
197 * Adds Javascript required to make CodePress work on the theme/plugin editors.
202 function codepress_footer_js() {
203 _deprecated_function( __FUNCTION__, '3.0' );
208 * Determine whether to use CodePress.
213 function use_codepress() {
214 _deprecated_function( __FUNCTION__, '3.0' );
221 * @return array List of user IDs.
223 function get_author_user_ids() {
224 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
227 if ( !is_multisite() )
228 $level_key = $wpdb->get_blog_prefix() . 'user_level';
230 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
232 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
238 * @param int $user_id User ID.
239 * @return array|bool List of editable authors. False if no editable users.
241 function get_editable_authors( $user_id ) {
242 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
246 $editable = get_editable_user_ids( $user_id );
251 $editable = join(',', $editable);
252 $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
255 return apply_filters('get_editable_authors', $authors);
261 * @param int $user_id User ID.
262 * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
265 function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
266 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
270 if ( ! $user = get_userdata( $user_id ) )
272 $post_type_obj = get_post_type_object($post_type);
274 if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
275 if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
276 return array($user->ID);
281 if ( !is_multisite() )
282 $level_key = $wpdb->get_blog_prefix() . 'user_level';
284 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
286 $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
287 if ( $exclude_zeros )
288 $query .= " AND meta_value != '0'";
290 return $wpdb->get_col( $query );
296 function get_nonauthor_user_ids() {
297 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
301 if ( !is_multisite() )
302 $level_key = $wpdb->get_blog_prefix() . 'user_level';
304 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
306 return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
309 if ( !class_exists('WP_User_Search') ) :
311 * WordPress User Search class.
316 class WP_User_Search {
319 * {@internal Missing Description}}
328 * {@internal Missing Description}}
346 * Role name that users have.
364 * Amount of users to display per page.
370 var $users_per_page = 50;
373 * {@internal Missing Description}}
382 * {@internal Missing Description}}
391 * {@internal Missing Description}}
400 * {@internal Missing Description}}
409 * {@internal Missing Description}}
418 * {@internal Missing Description}}
427 * {@internal Missing Description}}
433 var $total_users_for_query = 0;
436 * {@internal Missing Description}}
442 var $too_many_total_users = false;
445 * {@internal Missing Description}}
454 * {@internal Missing Description}}
463 * PHP4 Constructor - Sets up the object properties.
467 * @param string $search_term Search terms string.
468 * @param int $page Optional. Page ID.
469 * @param string $role Role name.
470 * @return WP_User_Search
472 function WP_User_Search ($search_term = '', $page = '', $role = '') {
473 _deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' );
475 $this->search_term = wp_unslash( $search_term );
476 $this->raw_page = ( '' == $page ) ? false : (int) $page;
477 $this->page = (int) ( '' == $page ) ? 1 : $page;
480 $this->prepare_query();
486 * {@internal Missing Short Description}}
488 * {@internal Missing Long Description}}
493 function prepare_query() {
495 $this->first_user = ($this->page - 1) * $this->users_per_page;
497 $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
498 $this->query_orderby = ' ORDER BY user_login';
501 if ( $this->search_term ) {
503 $search_sql = 'AND (';
504 foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
505 $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
506 $search_sql .= implode(' OR ', $searches);
510 $this->query_from = " FROM $wpdb->users";
511 $this->query_where = " WHERE 1=1 $search_sql";
514 $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
515 $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
516 } elseif ( is_multisite() ) {
517 $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
518 $this->query_from .= ", $wpdb->usermeta";
519 $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
522 do_action_ref_array( 'pre_user_search', array( &$this ) );
526 * {@internal Missing Short Description}}
528 * {@internal Missing Long Description}}
536 $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
538 if ( $this->results )
539 $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
541 $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
545 * {@internal Missing Short Description}}
547 * {@internal Missing Long Description}}
552 function prepare_vars_for_template_usage() {}
555 * {@internal Missing Short Description}}
557 * {@internal Missing Long Description}}
562 function do_paging() {
563 if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
565 if( ! empty($this->search_term) )
566 $args['usersearch'] = urlencode($this->search_term);
567 if( ! empty($this->role) )
568 $args['role'] = urlencode($this->role);
570 $this->paging_text = paginate_links( array(
571 'total' => ceil($this->total_users_for_query / $this->users_per_page),
572 'current' => $this->page,
573 'base' => 'users.php?%_%',
574 'format' => 'userspage=%#%',
577 if ( $this->paging_text ) {
578 $this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
579 number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
580 number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
581 number_format_i18n( $this->total_users_for_query ),
589 * {@internal Missing Short Description}}
591 * {@internal Missing Long Description}}
598 function get_results() {
599 return (array) $this->results;
603 * Displaying paging text.
605 * @see do_paging() Builds paging text.
610 function page_links() {
611 echo $this->paging_text;
615 * Whether paging is enabled.
617 * @see do_paging() Builds paging text.
624 function results_are_paged() {
625 if ( $this->paging_text )
631 * Whether there are search terms.
638 function is_search() {
639 if ( $this->search_term )
647 * Retrieve editable posts from other users.
651 * @param int $user_id User ID to not retrieve posts from.
652 * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
653 * @return array List of posts from others.
655 function get_others_unpublished_posts($user_id, $type='any') {
656 _deprecated_function( __FUNCTION__, '3.1' );
660 $editable = get_editable_user_ids( $user_id );
662 if ( in_array($type, array('draft', 'pending')) )
663 $type_sql = " post_status = '$type' ";
665 $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
667 $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
672 $editable = join(',', $editable);
673 $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) );
676 return apply_filters('get_others_drafts', $other_unpubs);
680 * Retrieve drafts from other users.
684 * @param int $user_id User ID.
685 * @return array List of drafts from other users.
687 function get_others_drafts($user_id) {
688 _deprecated_function( __FUNCTION__, '3.1' );
690 return get_others_unpublished_posts($user_id, 'draft');
694 * Retrieve pending review posts from other users.
698 * @param int $user_id User ID.
699 * @return array List of posts with pending review post type from other users.
701 function get_others_pending($user_id) {
702 _deprecated_function( __FUNCTION__, '3.1' );
704 return get_others_unpublished_posts($user_id, 'pending');
708 * Output the QuickPress dashboard widget.
712 * @deprecated Use wp_dashboard_quick_press()
713 * @see wp_dashboard_quick_press()
715 function wp_dashboard_quick_press_output() {
716 _deprecated_function( __FUNCTION__, '3.2', 'wp_dashboard_quick_press()' );
717 wp_dashboard_quick_press();
723 * @deprecated Use wp_editor()
726 function wp_tiny_mce( $teeny = false, $settings = false ) {
727 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
731 if ( ! class_exists('_WP_Editors' ) )
732 require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
734 $editor_id = 'content' . $num++;
738 'tinymce' => $settings ? $settings : true,
742 $set = _WP_Editors::parse_settings($editor_id, $set);
743 _WP_Editors::editor_settings($editor_id, $set);
748 * @deprecated Use wp_editor()
751 function wp_preload_dialogs() {
752 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
757 * @deprecated Use wp_editor()
760 function wp_print_editor_js() {
761 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
766 * @deprecated Use wp_editor()
769 function wp_quicktags() {
770 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
774 * Returns the screen layout options.
778 * @deprecated Use $current_screen->render_screen_layout()
779 * @see WP_Screen::render_screen_layout()
781 function screen_layout( $screen ) {
782 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_screen_layout()' );
784 $current_screen = get_current_screen();
786 if ( ! $current_screen )
790 $current_screen->render_screen_layout();
791 return ob_get_clean();
795 * Returns the screen's per-page options.
799 * @deprecated Use $current_screen->render_per_page_options()
800 * @see WP_Screen::render_per_page_options()
802 function screen_options( $screen ) {
803 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_per_page_options()' );
805 $current_screen = get_current_screen();
807 if ( ! $current_screen )
811 $current_screen->render_per_page_options();
812 return ob_get_clean();
816 * Renders the screen's help.
820 * @deprecated Use $current_screen->render_screen_meta()
821 * @see WP_Screen::render_screen_meta()
823 function screen_meta( $screen ) {
824 $current_screen = get_current_screen();
825 $current_screen->render_screen_meta();
829 * Favorite actions were deprecated in version 3.2. Use the admin bar instead.
834 function favorite_actions() {
835 _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' );
838 function media_upload_image() {
839 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
840 return wp_media_upload_handler();
843 function media_upload_audio() {
844 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
845 return wp_media_upload_handler();
848 function media_upload_video() {
849 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
850 return wp_media_upload_handler();
853 function media_upload_file() {
854 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
855 return wp_media_upload_handler();
858 function type_url_form_image() {
859 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('image')" );
860 return wp_media_insert_url_form( 'image' );
863 function type_url_form_audio() {
864 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('audio')" );
865 return wp_media_insert_url_form( 'audio' );
868 function type_url_form_video() {
869 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('video')" );
870 return wp_media_insert_url_form( 'video' );
873 function type_url_form_file() {
874 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" );
875 return wp_media_insert_url_form( 'file' );
879 * Add contextual help text for a page.
881 * Creates an 'Overview' help tab.
885 * @deprecated Use get_current_screen()->add_help_tab()
888 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
889 * @param string $help The content of an 'Overview' help tab.
891 function add_contextual_help( $screen, $help ) {
892 _deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' );
894 if ( is_string( $screen ) )
895 $screen = convert_to_screen( $screen );
897 WP_Screen::add_old_compat_help( $screen, $help );
901 * Get the allowed themes for the current blog.
905 * @deprecated Use wp_get_themes()
906 * @see wp_get_themes()
908 * @return array $themes Array of allowed themes.
910 function get_allowed_themes() {
911 _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'allowed' => true ) )" );
913 $themes = wp_get_themes( array( 'allowed' => true ) );
915 $wp_themes = array();
916 foreach ( $themes as $theme ) {
917 $wp_themes[ $theme->get('Name') ] = $theme;
924 * {@internal Missing Short Description}}
930 function get_broken_themes() {
931 _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'errors' => true )" );
933 $themes = wp_get_themes( array( 'errors' => true ) );
935 foreach ( $themes as $theme ) {
936 $name = $theme->get('Name');
937 $broken[ $name ] = array(
940 'Description' => $theme->errors()->get_error_message(),
947 * {@internal Missing Short Description}}
953 function current_theme_info() {
954 _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
956 return wp_get_theme();
960 * This was once used to display an 'Insert into Post' button. Now it is deprecated and stubbed.
964 function _insert_into_post_button( $type ) {
965 _deprecated_function( __FUNCTION__, '3.5' );
969 * This was once used to display a media button. Now it is deprecated and stubbed.
973 function _media_button($title, $icon, $type, $id) {
974 _deprecated_function( __FUNCTION__, '3.5' );
978 * Get an existing post and format it for editing.
986 function get_post_to_edit( $id ) {
987 _deprecated_function( __FUNCTION__, '3.5', 'get_post()' );
989 return get_post( $id, OBJECT, 'edit' );
993 * Get the default page information to use.
997 * @deprecated Use get_default_post_to_edit()
999 * @return WP_Post Post object containing all the default post data as attributes
1001 function get_default_page_to_edit() {
1002 _deprecated_function( __FUNCTION__, '3.5', "get_default_post_to_edit( 'page' )" );
1004 $page = get_default_post_to_edit();
1005 $page->post_type = 'page';
1010 * This was once used to create a thumbnail from an Image given a maximum side size.
1014 * @deprecated Use image_resize()
1015 * @see image_resize()
1017 * @param mixed $file Filename of the original image, Or attachment id.
1018 * @param int $max_side Maximum length of a single side for the thumbnail.
1019 * @param mixed $deprecated Never used.
1020 * @return string Thumbnail path on success, Error string on failure.
1022 function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
1023 _deprecated_function( __FUNCTION__, '3.5', 'image_resize()' );
1024 return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) );