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 = stripslashes( $search_term );
476 $this->raw_page = ( '' == $page ) ? false : (int) $page;
477 $this->page = (int) ( '' == $page ) ? 1 : $page;
480 $this->prepare_query();
482 $this->prepare_vars_for_template_usage();
487 * {@internal Missing Short Description}}
489 * {@internal Missing Long Description}}
494 function prepare_query() {
496 $this->first_user = ($this->page - 1) * $this->users_per_page;
498 $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
499 $this->query_orderby = ' ORDER BY user_login';
502 if ( $this->search_term ) {
504 $search_sql = 'AND (';
505 foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
506 $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
507 $search_sql .= implode(' OR ', $searches);
511 $this->query_from = " FROM $wpdb->users";
512 $this->query_where = " WHERE 1=1 $search_sql";
515 $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
516 $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
517 } elseif ( is_multisite() ) {
518 $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
519 $this->query_from .= ", $wpdb->usermeta";
520 $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
523 do_action_ref_array( 'pre_user_search', array( &$this ) );
527 * {@internal Missing Short Description}}
529 * {@internal Missing Long Description}}
537 $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
539 if ( $this->results )
540 $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
542 $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
546 * {@internal Missing Short Description}}
548 * {@internal Missing Long Description}}
553 function prepare_vars_for_template_usage() {
554 $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
558 * {@internal Missing Short Description}}
560 * {@internal Missing Long Description}}
565 function do_paging() {
566 if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
568 if( ! empty($this->search_term) )
569 $args['usersearch'] = urlencode($this->search_term);
570 if( ! empty($this->role) )
571 $args['role'] = urlencode($this->role);
573 $this->paging_text = paginate_links( array(
574 'total' => ceil($this->total_users_for_query / $this->users_per_page),
575 'current' => $this->page,
576 'base' => 'users.php?%_%',
577 'format' => 'userspage=%#%',
580 if ( $this->paging_text ) {
581 $this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
582 number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
583 number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
584 number_format_i18n( $this->total_users_for_query ),
592 * {@internal Missing Short Description}}
594 * {@internal Missing Long Description}}
601 function get_results() {
602 return (array) $this->results;
606 * Displaying paging text.
608 * @see do_paging() Builds paging text.
613 function page_links() {
614 echo $this->paging_text;
618 * Whether paging is enabled.
620 * @see do_paging() Builds paging text.
627 function results_are_paged() {
628 if ( $this->paging_text )
634 * Whether there are search terms.
641 function is_search() {
642 if ( $this->search_term )
650 * Retrieve editable posts from other users.
654 * @param int $user_id User ID to not retrieve posts from.
655 * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
656 * @return array List of posts from others.
658 function get_others_unpublished_posts($user_id, $type='any') {
659 _deprecated_function( __FUNCTION__, '3.1' );
663 $editable = get_editable_user_ids( $user_id );
665 if ( in_array($type, array('draft', 'pending')) )
666 $type_sql = " post_status = '$type' ";
668 $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
670 $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
675 $editable = join(',', $editable);
676 $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) );
679 return apply_filters('get_others_drafts', $other_unpubs);
683 * Retrieve drafts from other users.
687 * @param int $user_id User ID.
688 * @return array List of drafts from other users.
690 function get_others_drafts($user_id) {
691 _deprecated_function( __FUNCTION__, '3.1' );
693 return get_others_unpublished_posts($user_id, 'draft');
697 * Retrieve pending review posts from other users.
701 * @param int $user_id User ID.
702 * @return array List of posts with pending review post type from other users.
704 function get_others_pending($user_id) {
705 _deprecated_function( __FUNCTION__, '3.1' );
707 return get_others_unpublished_posts($user_id, 'pending');
711 * Output the QuickPress dashboard widget.
715 * @deprecated Use wp_dashboard_quick_press()
716 * @see wp_dashboard_quick_press()
718 function wp_dashboard_quick_press_output() {
719 _deprecated_function( __FUNCTION__, '3.2', 'wp_dashboard_quick_press()' );
720 wp_dashboard_quick_press();
726 * @deprecated Use wp_editor()
729 function wp_tiny_mce( $teeny = false, $settings = false ) {
730 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
734 if ( ! class_exists('_WP_Editors' ) )
735 require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
737 $editor_id = 'content' . $num++;
741 'tinymce' => $settings ? $settings : true,
745 $set = _WP_Editors::parse_settings($editor_id, $set);
746 _WP_Editors::editor_settings($editor_id, $set);
751 * @deprecated Use wp_editor()
754 function wp_preload_dialogs() {
755 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
760 * @deprecated Use wp_editor()
763 function wp_print_editor_js() {
764 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
769 * @deprecated Use wp_editor()
772 function wp_quicktags() {
773 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
777 * Returns the screen layout options.
781 * @deprecated Use $current_screen->render_screen_layout()
782 * @see WP_Screen::render_screen_layout()
784 function screen_layout( $screen ) {
785 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_screen_layout()' );
787 $current_screen = get_current_screen();
789 if ( ! $current_screen )
793 $current_screen->render_screen_layout();
794 return ob_get_clean();
798 * Returns the screen's per-page options.
802 * @deprecated Use $current_screen->render_per_page_options()
803 * @see WP_Screen::render_per_page_options()
805 function screen_options( $screen ) {
806 _deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_per_page_options()' );
808 $current_screen = get_current_screen();
810 if ( ! $current_screen )
814 $current_screen->render_per_page_options();
815 return ob_get_clean();
819 * Renders the screen's help.
823 * @deprecated Use $current_screen->render_screen_meta()
824 * @see WP_Screen::render_screen_meta()
826 function screen_meta( $screen ) {
827 $current_screen = get_current_screen();
828 $current_screen->render_screen_meta();
832 * Favorite actions were deprecated in version 3.2. Use the admin bar instead.
837 function favorite_actions() {
838 _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' );
841 function media_upload_image() {
842 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
843 return wp_media_upload_handler();
846 function media_upload_audio() {
847 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
848 return wp_media_upload_handler();
851 function media_upload_video() {
852 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
853 return wp_media_upload_handler();
856 function media_upload_file() {
857 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
858 return wp_media_upload_handler();
861 function type_url_form_image() {
862 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('image')" );
863 return wp_media_insert_url_form( 'image' );
866 function type_url_form_audio() {
867 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('audio')" );
868 return wp_media_insert_url_form( 'audio' );
871 function type_url_form_video() {
872 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('video')" );
873 return wp_media_insert_url_form( 'video' );
876 function type_url_form_file() {
877 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" );
878 return wp_media_insert_url_form( 'file' );
882 * Add contextual help text for a page.
884 * Creates an 'Overview' help tab.
888 * @deprecated Use get_current_screen()->add_help_tab()
891 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
892 * @param string $help The content of an 'Overview' help tab.
894 function add_contextual_help( $screen, $help ) {
895 _deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' );
897 if ( is_string( $screen ) )
898 $screen = convert_to_screen( $screen );
900 WP_Screen::add_old_compat_help( $screen, $help );
904 * Get the allowed themes for the current blog.
908 * @deprecated Use wp_get_themes()
909 * @see wp_get_themes()
911 * @return array $themes Array of allowed themes.
913 function get_allowed_themes() {
914 _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'allowed' => true ) )" );
916 $themes = wp_get_themes( array( 'allowed' => true ) );
918 $wp_themes = array();
919 foreach ( $themes as $theme ) {
920 $wp_themes[ $theme->get('Name') ] = $theme;
927 * {@internal Missing Short Description}}
933 function get_broken_themes() {
934 _deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'errors' => true )" );
936 $themes = wp_get_themes( array( 'errors' => true ) );
938 foreach ( $themes as $theme ) {
939 $name = $theme->get('Name');
940 $broken[ $name ] = array(
943 'Description' => $theme->errors()->get_error_message(),
950 * {@internal Missing Short Description}}
956 function current_theme_info() {
957 _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
959 return wp_get_theme();
963 * This was once used to display an 'Insert into Post' button. Now it is deprecated and stubbed.
967 function _insert_into_post_button( $type ) {
968 _deprecated_function( __FUNCTION__, '3.5' );
972 * This was once used to display a media button. Now it is deprecated and stubbed.
976 function _media_button($title, $icon, $type, $id) {
977 _deprecated_function( __FUNCTION__, '3.5' );
981 * Get an existing post and format it for editing.
989 function get_post_to_edit( $id ) {
990 _deprecated_function( __FUNCTION__, '3.5', 'get_post()' );
992 return get_post( $id, OBJECT, 'edit' );
996 * Get the default page information to use.
1000 * @deprecated Use get_default_post_to_edit()
1002 * @return WP_Post Post object containing all the default post data as attributes
1004 function get_default_page_to_edit() {
1005 _deprecated_function( __FUNCTION__, '3.5', "get_default_post_to_edit( 'page' )" );
1007 $page = get_default_post_to_edit();
1008 $page->post_type = 'page';
1013 * This was once used to create a thumbnail from an Image given a maximum side size.
1017 * @deprecated Use image_resize()
1018 * @see image_resize()
1020 * @param mixed $file Filename of the original image, Or attachment id.
1021 * @param int $max_side Maximum length of a single side for the thumbnail.
1022 * @param mixed $deprecated Never used.
1023 * @return string Thumbnail path on success, Error string on failure.
1025 function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
1026 _deprecated_function( __FUNCTION__, '3.5', 'image_resize' );
1027 return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) );