3 * Deprecated functions from past WordPress versions. You shouldn't use these
4 * functions and look for the alternatives instead. The functions will be
5 * removed in a later version.
8 * @subpackage Deprecated
12 * Deprecated functions come here to die.
16 * Retrieves all post data for a given post.
19 * @deprecated 1.5.1 Use get_post()
22 * @param int $postid Post ID.
23 * @return array Post data.
25 function get_postdata($postid) {
26 _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
28 $post = get_post($postid);
32 'Author_ID' => $post->post_author,
33 'Date' => $post->post_date,
34 'Content' => $post->post_content,
35 'Excerpt' => $post->post_excerpt,
36 'Title' => $post->post_title,
37 'Category' => $post->post_category,
38 'post_status' => $post->post_status,
39 'comment_status' => $post->comment_status,
40 'ping_status' => $post->ping_status,
41 'post_password' => $post->post_password,
42 'to_ping' => $post->to_ping,
43 'pinged' => $post->pinged,
44 'post_type' => $post->post_type,
45 'post_name' => $post->post_name
52 * Sets up the WordPress Loop.
54 * Use The Loop instead.
56 * @link https://codex.wordpress.org/The_Loop
64 _deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') );
66 // Since the old style loop is being used, advance the query iterator here.
67 $wp_query->next_post();
69 setup_postdata( get_post() );
73 * Returns or prints a category ID.
76 * @deprecated 0.71 Use get_the_category()
77 * @see get_the_category()
79 * @param bool $echo Optional. Whether to echo the output. Default true.
80 * @return int Category ID.
82 function the_category_ID($echo = true) {
83 _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );
85 // Grab the first cat in the list.
86 $categories = get_the_category();
87 $cat = $categories[0]->term_id;
96 * Prints a category with optional text before and after.
99 * @deprecated 0.71 Use get_the_category_by_ID()
100 * @see get_the_category_by_ID()
102 * @param string $before Optional. Text to display before the category. Default empty.
103 * @param string $after Optional. Text to display after the category. Default empty.
105 function the_category_head( $before = '', $after = '' ) {
106 global $currentcat, $previouscat;
108 _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' );
110 // Grab the first cat in the list.
111 $categories = get_the_category();
112 $currentcat = $categories[0]->category_id;
113 if ( $currentcat != $previouscat ) {
115 echo get_the_category_by_ID($currentcat);
117 $previouscat = $currentcat;
122 * Prints a link to the previous post.
125 * @deprecated 2.0.0 Use previous_post_link()
126 * @see previous_post_link()
128 * @param string $format
129 * @param string $previous
130 * @param string $title
131 * @param string $in_same_cat
132 * @param int $limitprev
133 * @param string $excluded_categories
135 function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
137 _deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' );
139 if ( empty($in_same_cat) || 'no' == $in_same_cat )
140 $in_same_cat = false;
144 $post = get_previous_post($in_same_cat, $excluded_categories);
149 $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
150 if ( 'yes' == $title )
151 $string .= apply_filters('the_title', $post->post_title, $post->ID);
153 $format = str_replace('%', $string, $format);
158 * Prints link to the next post.
161 * @deprecated 2.0.0 Use next_post_link()
162 * @see next_post_link()
164 * @param string $format
165 * @param string $next
166 * @param string $title
167 * @param string $in_same_cat
168 * @param int $limitnext
169 * @param string $excluded_categories
171 function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
172 _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' );
174 if ( empty($in_same_cat) || 'no' == $in_same_cat )
175 $in_same_cat = false;
179 $post = get_next_post($in_same_cat, $excluded_categories);
184 $string = '<a href="'.get_permalink($post->ID).'">'.$next;
185 if ( 'yes' == $title )
186 $string .= apply_filters('the_title', $post->post_title, $post->ID);
188 $format = str_replace('%', $string, $format);
193 * Whether user can create a post.
196 * @deprecated 2.0.0 Use current_user_can()
197 * @see current_user_can()
199 * @param int $user_id
200 * @param int $blog_id Not Used
201 * @param int $category_id Not Used
204 function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
205 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
207 $author_data = get_userdata($user_id);
208 return ($author_data->user_level > 1);
212 * Whether user can create a post.
215 * @deprecated 2.0.0 Use current_user_can()
216 * @see current_user_can()
218 * @param int $user_id
219 * @param int $blog_id Not Used
220 * @param int $category_id Not Used
223 function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
224 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
226 $author_data = get_userdata($user_id);
227 return ($author_data->user_level >= 1);
231 * Whether user can edit a post.
234 * @deprecated 2.0.0 Use current_user_can()
235 * @see current_user_can()
237 * @param int $user_id
238 * @param int $post_id
239 * @param int $blog_id Not Used
242 function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
243 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
245 $author_data = get_userdata($user_id);
246 $post = get_post($post_id);
247 $post_author_data = get_userdata($post->post_author);
249 if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
250 || ($author_data->user_level > $post_author_data->user_level)
251 || ($author_data->user_level >= 10) ) {
259 * Whether user can delete a post.
262 * @deprecated 2.0.0 Use current_user_can()
263 * @see current_user_can()
265 * @param int $user_id
266 * @param int $post_id
267 * @param int $blog_id Not Used
270 function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
271 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
273 // right now if one can edit, one can delete
274 return user_can_edit_post($user_id, $post_id, $blog_id);
278 * Whether user can set new posts' dates.
281 * @deprecated 2.0.0 Use current_user_can()
282 * @see current_user_can()
284 * @param int $user_id
285 * @param int $blog_id Not Used
286 * @param int $category_id Not Used
289 function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
290 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
292 $author_data = get_userdata($user_id);
293 return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
297 * Whether user can delete a post.
300 * @deprecated 2.0.0 Use current_user_can()
301 * @see current_user_can()
303 * @param int $user_id
304 * @param int $post_id
305 * @param int $blog_id Not Used
306 * @return bool returns true if $user_id can edit $post_id's date
308 function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
309 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
311 $author_data = get_userdata($user_id);
312 return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
316 * Whether user can delete a post.
319 * @deprecated 2.0.0 Use current_user_can()
320 * @see current_user_can()
322 * @param int $user_id
323 * @param int $post_id
324 * @param int $blog_id Not Used
325 * @return bool returns true if $user_id can edit $post_id's comments
327 function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
328 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
330 // right now if one can edit a post, one can edit comments made on it
331 return user_can_edit_post($user_id, $post_id, $blog_id);
335 * Whether user can delete a post.
338 * @deprecated 2.0.0 Use current_user_can()
339 * @see current_user_can()
341 * @param int $user_id
342 * @param int $post_id
343 * @param int $blog_id Not Used
344 * @return bool returns true if $user_id can delete $post_id's comments
346 function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
347 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
349 // right now if one can edit comments, one can delete comments
350 return user_can_edit_post_comments($user_id, $post_id, $blog_id);
354 * Can user can edit other user.
357 * @deprecated 2.0.0 Use current_user_can()
358 * @see current_user_can()
360 * @param int $user_id
361 * @param int $other_user
364 function user_can_edit_user($user_id, $other_user) {
365 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
367 $user = get_userdata($user_id);
368 $other = get_userdata($other_user);
369 if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
376 * Gets the links associated with category $cat_name.
379 * @deprecated 2.1.0 Use get_bookmarks()
380 * @see get_bookmarks()
382 * @param string $cat_name Optional. The category name to use. If no match is found uses all.
383 * @param string $before Optional. The html to output before the link.
384 * @param string $after Optional. The html to output after the link.
385 * @param string $between Optional. The html to output between the link/image and its description. Not used if no image or $show_images is true.
386 * @param bool $show_images Optional. Whether to show images (if defined).
387 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner.
388 * If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a
390 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
391 * @param bool $show_rating Optional. Show rating stars/chars.
392 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
393 * @param int $show_updated Optional. Whether to show last updated timestamp
395 function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
396 $show_description = true, $show_rating = false,
397 $limit = -1, $show_updated = 0) {
398 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
401 $cat = get_term_by('name', $cat_name, 'link_category');
403 $cat_id = $cat->term_id;
405 get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated);
409 * Gets the links associated with the named category.
412 * @deprecated 2.1.0 Use wp_list_bookmarks()
413 * @see wp_list_bookmarks()
415 * @param string $category The category to use.
416 * @param string $args
417 * @return string|null
419 function wp_get_linksbyname($category, $args = '') {
420 _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()');
426 'category_after' => '',
427 'category_before' => '',
428 'category_name' => $category,
429 'show_description' => 1,
433 $r = wp_parse_args( $args, $defaults );
435 return wp_list_bookmarks($r);
439 * Gets an array of link objects associated with category $cat_name.
441 * $links = get_linkobjectsbyname( 'fred' );
442 * foreach ( $links as $link ) {
443 * echo '<li>' . $link->link_name . '</li>';
447 * @deprecated 2.1.0 Use get_bookmarks()
448 * @see get_bookmarks()
450 * @param string $cat_name The category name to use. If no match is found uses all.
451 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'.
452 * Or maybe owner. If you start the name with an underscore the order will be reversed. You can also
453 * specify 'rand' as the order which will return links in a random order.
454 * @param int $limit Limit to X entries. If not specified, all entries are shown.
457 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
458 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
461 $cat = get_term_by('name', $cat_name, 'link_category');
463 $cat_id = $cat->term_id;
465 return get_linkobjects($cat_id, $orderby, $limit);
469 * Gets an array of link objects associated with category n.
473 * $links = get_linkobjects(1);
475 * foreach ($links as $link) {
476 * echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
497 * @deprecated 2.1.0 Use get_bookmarks()
498 * @see get_bookmarks()
500 * @param int $category The category to use. If no category supplied uses all
501 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
502 * 'description', or 'rating'. Or maybe owner. If you start the name with an
503 * underscore the order will be reversed. You can also specify 'rand' as the
504 * order which will return links in a random order.
505 * @param int $limit Limit to X entries. If not specified, all entries are shown.
508 function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) {
509 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
511 $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ;
513 $links_array = array();
514 foreach ($links as $link)
515 $links_array[] = $link;
521 * Gets the links associated with category 'cat_name' and display rating stars/chars.
524 * @deprecated 2.1.0 Use get_bookmarks()
525 * @see get_bookmarks()
527 * @param string $cat_name The category name to use. If no match is found uses all
528 * @param string $before The html to output before the link
529 * @param string $after The html to output after the link
530 * @param string $between The html to output between the link/image and its description. Not used if no image or show_images is true
531 * @param bool $show_images Whether to show images (if defined).
532 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
533 * 'description', or 'rating'. Or maybe owner. If you start the name with an
534 * underscore the order will be reversed. You can also specify 'rand' as the
535 * order which will return links in a random order.
536 * @param bool $show_description Whether to show the description if show_images=false/not defined
537 * @param int $limit Limit to X entries. If not specified, all entries are shown.
538 * @param int $show_updated Whether to show last updated timestamp
540 function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ",
541 $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
542 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
544 get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
548 * Gets the links associated with category n and display rating stars/chars.
551 * @deprecated 2.1.0 Use get_bookmarks()
552 * @see get_bookmarks()
554 * @param int $category The category to use. If no category supplied uses all
555 * @param string $before The html to output before the link
556 * @param string $after The html to output after the link
557 * @param string $between The html to output between the link/image and its description. Not used if no image or show_images == true
558 * @param bool $show_images Whether to show images (if defined).
559 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url',
560 * 'description', or 'rating'. Or maybe owner. If you start the name with an
561 * underscore the order will be reversed. You can also specify 'rand' as the
562 * order which will return links in a random order.
563 * @param bool $show_description Whether to show the description if show_images=false/not defined.
564 * @param int $limit Limit to X entries. If not specified, all entries are shown.
565 * @param int $show_updated Whether to show last updated timestamp
567 function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true,
568 $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
569 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
571 get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
575 * Gets the auto_toggle setting.
580 * @param int $id The category to get. If no category supplied uses 0
581 * @return int Only returns 0.
583 function get_autotoggle($id = 0) {
584 _deprecated_function( __FUNCTION__, '2.1.0' );
592 * @deprecated 2.1.0 Use wp_list_categories()
593 * @see wp_list_categories()
595 * @param int $optionall
597 * @param string $sort_column
598 * @param string $sort_order
599 * @param string $file
601 * @param int $optiondates
602 * @param int $optioncount
603 * @param int $hide_empty
604 * @param int $use_desc_for_title
605 * @param bool $children
606 * @param int $child_of
607 * @param int $categories
608 * @param int $recurse
609 * @param string $feed
610 * @param string $feed_image
611 * @param string $exclude
612 * @param bool $hierarchical
615 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0,
616 $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0,
617 $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) {
618 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' );
620 $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children',
621 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical');
622 return wp_list_cats($query);
629 * @deprecated 2.1.0 Use wp_list_categories()
630 * @see wp_list_categories()
632 * @param string|array $args
633 * @return false|null|string
635 function wp_list_cats($args = '') {
636 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' );
638 $r = wp_parse_args( $args );
641 if ( isset($r['optionall']) && isset($r['all']))
642 $r['show_option_all'] = $r['all'];
643 if ( isset($r['sort_column']) )
644 $r['orderby'] = $r['sort_column'];
645 if ( isset($r['sort_order']) )
646 $r['order'] = $r['sort_order'];
647 if ( isset($r['optiondates']) )
648 $r['show_last_update'] = $r['optiondates'];
649 if ( isset($r['optioncount']) )
650 $r['show_count'] = $r['optioncount'];
651 if ( isset($r['list']) )
652 $r['style'] = $r['list'] ? 'list' : 'break';
655 return wp_list_categories($r);
659 * Deprecated method for generating a drop-down of categories.
662 * @deprecated 2.1.0 Use wp_dropdown_categories()
663 * @see wp_dropdown_categories()
665 * @param int $optionall
667 * @param string $orderby
668 * @param string $order
669 * @param int $show_last_update
670 * @param int $show_count
671 * @param int $hide_empty
672 * @param bool $optionnone
673 * @param int $selected
674 * @param int $exclude
677 function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
678 $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false,
679 $selected = 0, $exclude = 0) {
680 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' );
682 $show_option_all = '';
684 $show_option_all = $all;
686 $show_option_none = '';
688 $show_option_none = __('None');
690 $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
691 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
692 $query = add_query_arg($vars, '');
693 return wp_dropdown_categories($query);
700 * @deprecated 2.1.0 Use wp_list_authors()
701 * @see wp_list_authors()
703 * @param bool $optioncount
704 * @param bool $exclude_admin
705 * @param bool $show_fullname
706 * @param bool $hide_empty
707 * @param string $feed
708 * @param string $feed_image
709 * @return null|string
711 function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
712 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_authors()' );
714 $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
715 return wp_list_authors($args);
719 * Retrieves a list of post categories.
722 * @deprecated 2.1.0 Use wp_get_post_categories()
723 * @see wp_get_post_categories()
725 * @param int $blogid Not Used
726 * @param int $post_ID
729 function wp_get_post_cats($blogid = '1', $post_ID = 0) {
730 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' );
731 return wp_get_post_categories($post_ID);
735 * Sets the categories that the post id belongs to.
739 * @deprecated Use wp_set_post_categories()
740 * @see wp_set_post_categories()
742 * @param int $blogid Not used
743 * @param int $post_ID
744 * @param array $post_categories
747 function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
748 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' );
749 return wp_set_post_categories($post_ID, $post_categories);
753 * Retrieves a list of archives.
756 * @deprecated 2.1.0 Use wp_get_archives()
757 * @see wp_get_archives()
759 * @param string $type
760 * @param string $limit
761 * @param string $format
762 * @param string $before
763 * @param string $after
764 * @param bool $show_post_count
765 * @return string|null
767 function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
768 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' );
769 $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
770 return wp_get_archives($args);
774 * Returns or Prints link to the author's posts.
777 * @deprecated 2.1.0 Use get_author_posts_url()
778 * @see get_author_posts_url()
781 * @param int $author_id
782 * @param string $author_nicename Optional.
783 * @return string|null
785 function get_author_link($echo, $author_id, $author_nicename = '') {
786 _deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' );
788 $link = get_author_posts_url($author_id, $author_nicename);
796 * Print list of pages based on arguments.
799 * @deprecated 2.1.0 Use wp_link_pages()
800 * @see wp_link_pages()
802 * @param string $before
803 * @param string $after
804 * @param string $next_or_number
805 * @param string $nextpagelink
806 * @param string $previouspagelink
807 * @param string $pagelink
808 * @param string $more_file
811 function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page',
812 $pagelink='%', $more_file='') {
813 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_link_pages()' );
815 $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
816 return wp_link_pages($args);
820 * Get value based on option.
823 * @deprecated 2.1.0 Use get_option()
826 * @param string $option
829 function get_settings($option) {
830 _deprecated_function( __FUNCTION__, '2.1.0', 'get_option()' );
832 return get_option($option);
836 * Print the permalink of the current post in the loop.
839 * @deprecated 1.2.0 Use the_permalink()
840 * @see the_permalink()
842 function permalink_link() {
843 _deprecated_function( __FUNCTION__, '1.2.0', 'the_permalink()' );
848 * Print the permalink to the RSS feed.
851 * @deprecated 2.3.0 Use the_permalink_rss()
852 * @see the_permalink_rss()
854 * @param string $deprecated
856 function permalink_single_rss($deprecated = '') {
857 _deprecated_function( __FUNCTION__, '2.3.0', 'the_permalink_rss()' );
862 * Gets the links associated with category.
865 * @deprecated 2.1.0 Use wp_list_bookmarks()
866 * @see wp_list_bookmarks()
868 * @param string $args a query string
869 * @return null|string
871 function wp_get_links($args = '') {
872 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' );
874 if ( strpos( $args, '=' ) === false ) {
876 $args = add_query_arg( 'category', $cat_id, $args );
888 'show_description' => true,
889 'show_images' => true,
890 'show_rating' => false,
891 'show_updated' => true,
895 $r = wp_parse_args( $args, $defaults );
897 return wp_list_bookmarks($r);
901 * Gets the links associated with category by id.
904 * @deprecated 2.1.0 Use get_bookmarks()
905 * @see get_bookmarks()
907 * @param int $category The category to use. If no category supplied uses all
908 * @param string $before the html to output before the link
909 * @param string $after the html to output after the link
910 * @param string $between the html to output between the link/image and its description.
911 * Not used if no image or show_images == true
912 * @param bool $show_images whether to show images (if defined).
913 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
914 * 'description', or 'rating'. Or maybe owner. If you start the name with an
915 * underscore the order will be reversed. You can also specify 'rand' as the order
916 * which will return links in a random order.
917 * @param bool $show_description whether to show the description if show_images=false/not defined.
918 * @param bool $show_rating show rating stars/chars
919 * @param int $limit Limit to X entries. If not specified, all entries are shown.
920 * @param int $show_updated whether to show last updated timestamp
921 * @param bool $echo whether to echo the results, or return them instead
922 * @return null|string
924 function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name',
925 $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) {
926 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
929 if ( substr($orderby, 0, 1) == '_' ) {
931 $orderby = substr($orderby, 1);
934 if ( $category == -1 ) //get_bookmarks uses '' to signify all categories
937 $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit));
944 foreach ( (array) $results as $row ) {
945 if ( !isset($row->recently_updated) )
946 $row->recently_updated = false;
948 if ( $show_updated && $row->recently_updated )
949 $output .= get_option('links_recently_updated_prepend');
951 if ( !empty($row->link_url) )
952 $the_link = esc_url($row->link_url);
953 $rel = $row->link_rel;
955 $rel = ' rel="' . $rel . '"';
957 $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display'));
958 $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display'));
962 if (substr($row->link_updated_f, 0, 2) != '00')
963 $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';
966 $title = ' title="' . $title . '"';
968 $alt = ' alt="' . $name . '"';
970 $target = $row->link_target;
972 $target = ' target="' . $target . '"';
974 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
976 if ( $row->link_image != null && $show_images ) {
977 if ( strpos($row->link_image, 'http') !== false )
978 $output .= "<img src=\"$row->link_image\" $alt $title />";
979 else // If it's a relative path
980 $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />";
987 if ( $show_updated && $row->recently_updated )
988 $output .= get_option('links_recently_updated_append');
990 if ( $show_description && '' != $desc )
991 $output .= $between . $desc;
994 $output .= $between . get_linkrating($row);
997 $output .= "$after\n";
1006 * Output entire list of links by category.
1008 * Output a list of all links, listed by category, using the settings in
1009 * $wpdb->linkcategories and output it as a nested HTML unordered list.
1012 * @deprecated 2.1.0 Use wp_list_bookmarks()
1013 * @see wp_list_bookmarks()
1015 * @param string $order Sort link categories by 'name' or 'id'
1017 function get_links_list($order = 'name') {
1018 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' );
1020 $order = strtolower($order);
1022 // Handle link category sorting
1024 if ( '_' == substr($order,0,1) ) {
1025 $direction = 'DESC';
1026 $order = substr($order,1);
1029 if ( !isset($direction) )
1032 $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0));
1034 // Display each category
1036 foreach ( (array) $cats as $cat ) {
1037 // Handle each category.
1039 // Display the category name
1040 echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";
1041 // Call get_links() with all the appropriate params
1042 get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);
1044 // Close the last category
1045 echo "\n\t</ul>\n</li>\n";
1051 * Show the link to the links popup and the number of links.
1056 * @param string $text the text of the link
1057 * @param int $width the width of the popup window
1058 * @param int $height the height of the popup window
1059 * @param string $file the page to open in the popup window
1060 * @param bool $count the number of links in the db
1062 function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
1063 _deprecated_function( __FUNCTION__, '2.1.0' );
1067 * Legacy function that retrieved the value of a link's link_rating field.
1070 * @deprecated 2.1.0 Use sanitize_bookmark_field()
1071 * @see sanitize_bookmark_field()
1073 * @param object $link Link object.
1074 * @return mixed Value of the 'link_rating' field, false otherwise.
1076 function get_linkrating( $link ) {
1077 _deprecated_function( __FUNCTION__, '2.1.0', 'sanitize_bookmark_field()' );
1078 return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display');
1082 * Gets the name of category by id.
1085 * @deprecated 2.1.0 Use get_category()
1086 * @see get_category()
1088 * @param int $id The category to get. If no category supplied uses 0
1091 function get_linkcatname($id = 0) {
1092 _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' );
1099 $cats = wp_get_link_cats($id);
1101 if ( empty($cats) || ! is_array($cats) )
1104 $cat_id = (int) $cats[0]; // Take the first cat.
1106 $cat = get_category($cat_id);
1111 * Print RSS comment feed link.
1114 * @deprecated 2.5.0 Use post_comments_feed_link()
1115 * @see post_comments_feed_link()
1117 * @param string $link_text
1119 function comments_rss_link($link_text = 'Comments RSS') {
1120 _deprecated_function( __FUNCTION__, '2.5.0', 'post_comments_feed_link()' );
1121 post_comments_feed_link($link_text);
1125 * Print/Return link to category RSS2 feed.
1128 * @deprecated 2.5.0 Use get_category_feed_link()
1129 * @see get_category_feed_link()
1132 * @param int $cat_ID
1135 function get_category_rss_link($echo = false, $cat_ID = 1) {
1136 _deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' );
1138 $link = get_category_feed_link($cat_ID, 'rss2');
1146 * Print/Return link to author RSS feed.
1149 * @deprecated 2.5.0 Use get_author_feed_link()
1150 * @see get_author_feed_link()
1153 * @param int $author_id
1156 function get_author_rss_link($echo = false, $author_id = 1) {
1157 _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' );
1159 $link = get_author_feed_link($author_id);
1166 * Return link to the post RSS feed.
1169 * @deprecated 2.2.0 Use get_post_comments_feed_link()
1170 * @see get_post_comments_feed_link()
1174 function comments_rss() {
1175 _deprecated_function( __FUNCTION__, '2.2.0', 'get_post_comments_feed_link()' );
1176 return esc_url( get_post_comments_feed_link() );
1180 * An alias of wp_create_user().
1183 * @deprecated 2.0.0 Use wp_create_user()
1184 * @see wp_create_user()
1186 * @param string $username The user's username.
1187 * @param string $password The user's password.
1188 * @param string $email The user's email.
1189 * @return int The new user's ID.
1191 function create_user($username, $password, $email) {
1192 _deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' );
1193 return wp_create_user($username, $password, $email);
1201 function gzip_compression() {
1202 _deprecated_function( __FUNCTION__, '2.5.0' );
1207 * Retrieve an array of comment data about comment $comment_ID.
1210 * @deprecated 2.7.0 Use get_comment()
1211 * @see get_comment()
1213 * @param int $comment_ID The ID of the comment
1214 * @param int $no_cache Whether to use the cache (cast to bool)
1215 * @param bool $include_unapproved Whether to include unapproved comments
1216 * @return array The comment data
1218 function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
1219 _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' );
1220 return get_comment($comment_ID, ARRAY_A);
1224 * Retrieve the category name by the category ID.
1227 * @deprecated 2.8.0 Use get_cat_name()
1228 * @see get_cat_name()
1230 * @param int $cat_ID Category ID
1231 * @return string category name
1233 function get_catname( $cat_ID ) {
1234 _deprecated_function( __FUNCTION__, '2.8.0', 'get_cat_name()' );
1235 return get_cat_name( $cat_ID );
1239 * Retrieve category children list separated before and after the term IDs.
1242 * @deprecated 2.8.0 Use get_term_children()
1243 * @see get_term_children()
1245 * @param int $id Category ID to retrieve children.
1246 * @param string $before Optional. Prepend before category term ID.
1247 * @param string $after Optional, default is empty string. Append after category term ID.
1248 * @param array $visited Optional. Category Term IDs that have already been added.
1251 function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
1252 _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' );
1257 /** TODO: consult hierarchy */
1258 $cat_ids = get_all_category_ids();
1259 foreach ( (array) $cat_ids as $cat_id ) {
1260 if ( $cat_id == $id )
1263 $category = get_category( $cat_id );
1264 if ( is_wp_error( $category ) )
1266 if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
1267 $visited[] = $category->term_id;
1268 $chain .= $before.$category->term_id.$after;
1269 $chain .= get_category_children( $category->term_id, $before, $after );
1276 * Retrieves all category IDs.
1279 * @deprecated 4.0.0 Use get_terms()
1282 * @link https://codex.wordpress.org/Function_Reference/get_all_category_ids
1284 * @return object List of all of the category IDs.
1286 function get_all_category_ids() {
1287 _deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' );
1289 if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) {
1290 $cat_ids = get_terms( 'category', array('fields' => 'ids', 'get' => 'all') );
1291 wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
1298 * Retrieve the description of the author of the current post.
1301 * @deprecated 2.8.0 Use get_the_author_meta()
1302 * @see get_the_author_meta()
1304 * @return string The author's description.
1306 function get_the_author_description() {
1307 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' );
1308 return get_the_author_meta('description');
1312 * Display the description of the author of the current post.
1315 * @deprecated 2.8.0 Use the_author_meta()
1316 * @see the_author_meta()
1318 function the_author_description() {
1319 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' );
1320 the_author_meta('description');
1324 * Retrieve the login name of the author of the current post.
1327 * @deprecated 2.8.0 Use get_the_author_meta()
1328 * @see get_the_author_meta()
1330 * @return string The author's login name (username).
1332 function get_the_author_login() {
1333 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' );
1334 return get_the_author_meta('login');
1338 * Display the login name of the author of the current post.
1341 * @deprecated 2.8.0 Use the_author_meta()
1342 * @see the_author_meta()
1344 function the_author_login() {
1345 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' );
1346 the_author_meta('login');
1350 * Retrieve the first name of the author of the current post.
1353 * @deprecated 2.8.0 Use get_the_author_meta()
1354 * @see get_the_author_meta()
1356 * @return string The author's first name.
1358 function get_the_author_firstname() {
1359 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' );
1360 return get_the_author_meta('first_name');
1364 * Display the first name of the author of the current post.
1367 * @deprecated 2.8.0 Use the_author_meta()
1368 * @see the_author_meta()
1370 function the_author_firstname() {
1371 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' );
1372 the_author_meta('first_name');
1376 * Retrieve the last name of the author of the current post.
1379 * @deprecated 2.8.0 Use get_the_author_meta()
1380 * @see get_the_author_meta()
1382 * @return string The author's last name.
1384 function get_the_author_lastname() {
1385 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' );
1386 return get_the_author_meta('last_name');
1390 * Display the last name of the author of the current post.
1393 * @deprecated 2.8.0 Use the_author_meta()
1394 * @see the_author_meta()
1396 function the_author_lastname() {
1397 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' );
1398 the_author_meta('last_name');
1402 * Retrieve the nickname of the author of the current post.
1405 * @deprecated 2.8.0 Use get_the_author_meta()
1406 * @see get_the_author_meta()
1408 * @return string The author's nickname.
1410 function get_the_author_nickname() {
1411 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' );
1412 return get_the_author_meta('nickname');
1416 * Display the nickname of the author of the current post.
1419 * @deprecated 2.8.0 Use the_author_meta()
1420 * @see the_author_meta()
1422 function the_author_nickname() {
1423 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' );
1424 the_author_meta('nickname');
1428 * Retrieve the email of the author of the current post.
1431 * @deprecated 2.8.0 Use get_the_author_meta()
1432 * @see get_the_author_meta()
1434 * @return string The author's username.
1436 function get_the_author_email() {
1437 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' );
1438 return get_the_author_meta('email');
1442 * Display the email of the author of the current post.
1445 * @deprecated 2.8.0 Use the_author_meta()
1446 * @see the_author_meta()
1448 function the_author_email() {
1449 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' );
1450 the_author_meta('email');
1454 * Retrieve the ICQ number of the author of the current post.
1457 * @deprecated 2.8.0 Use get_the_author_meta()
1458 * @see get_the_author_meta()
1460 * @return string The author's ICQ number.
1462 function get_the_author_icq() {
1463 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' );
1464 return get_the_author_meta('icq');
1468 * Display the ICQ number of the author of the current post.
1471 * @deprecated 2.8.0 Use the_author_meta()
1472 * @see the_author_meta()
1474 function the_author_icq() {
1475 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' );
1476 the_author_meta('icq');
1480 * Retrieve the Yahoo! IM name of the author of the current post.
1483 * @deprecated 2.8.0 Use get_the_author_meta()
1484 * @see get_the_author_meta()
1486 * @return string The author's Yahoo! IM name.
1488 function get_the_author_yim() {
1489 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' );
1490 return get_the_author_meta('yim');
1494 * Display the Yahoo! IM name of the author of the current post.
1497 * @deprecated 2.8.0 Use the_author_meta()
1498 * @see the_author_meta()
1500 function the_author_yim() {
1501 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' );
1502 the_author_meta('yim');
1506 * Retrieve the MSN address of the author of the current post.
1509 * @deprecated 2.8.0 Use get_the_author_meta()
1510 * @see get_the_author_meta()
1512 * @return string The author's MSN address.
1514 function get_the_author_msn() {
1515 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' );
1516 return get_the_author_meta('msn');
1520 * Display the MSN address of the author of the current post.
1523 * @deprecated 2.8.0 Use the_author_meta()
1524 * @see the_author_meta()
1526 function the_author_msn() {
1527 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' );
1528 the_author_meta('msn');
1532 * Retrieve the AIM address of the author of the current post.
1535 * @deprecated 2.8.0 Use get_the_author_meta()
1536 * @see get_the_author_meta()
1538 * @return string The author's AIM address.
1540 function get_the_author_aim() {
1541 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' );
1542 return get_the_author_meta('aim');
1546 * Display the AIM address of the author of the current post.
1549 * @deprecated 2.8.0 Use the_author_meta('aim')
1550 * @see the_author_meta()
1552 function the_author_aim() {
1553 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' );
1554 the_author_meta('aim');
1558 * Retrieve the specified author's preferred display name.
1561 * @deprecated 2.8.0 Use get_the_author_meta()
1562 * @see get_the_author_meta()
1564 * @param int $auth_id The ID of the author.
1565 * @return string The author's display name.
1567 function get_author_name( $auth_id = false ) {
1568 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' );
1569 return get_the_author_meta('display_name', $auth_id);
1573 * Retrieve the URL to the home page of the author of the current post.
1576 * @deprecated 2.8.0 Use get_the_author_meta()
1577 * @see get_the_author_meta()
1579 * @return string The URL to the author's page.
1581 function get_the_author_url() {
1582 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' );
1583 return get_the_author_meta('url');
1587 * Display the URL to the home page of the author of the current post.
1590 * @deprecated 2.8.0 Use the_author_meta()
1591 * @see the_author_meta()
1593 function the_author_url() {
1594 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' );
1595 the_author_meta('url');
1599 * Retrieve the ID of the author of the current post.
1602 * @deprecated 2.8.0 Use get_the_author_meta()
1603 * @see get_the_author_meta()
1605 * @return string|int The author's ID.
1607 function get_the_author_ID() {
1608 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' );
1609 return get_the_author_meta('ID');
1613 * Display the ID of the author of the current post.
1616 * @deprecated 2.8.0 Use the_author_meta()
1617 * @see the_author_meta()
1619 function the_author_ID() {
1620 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' );
1621 the_author_meta('ID');
1625 * Display the post content for the feed.
1627 * For encoding the html or the $encode_html parameter, there are three possible
1628 * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
1629 * encode special characters and automatically display all of the content. The
1630 * value of '2' will strip all HTML tags from the content.
1632 * Also note that you cannot set the amount of words and not set the html
1633 * encoding. If that is the case, then the html encoding will default to 2,
1634 * which will strip all HTML tags.
1636 * To restrict the amount of words of the content, you can use the cut
1637 * parameter. If the content is less than the amount, then there won't be any
1638 * dots added to the end. If there is content left over, then dots will be added
1639 * and the rest of the content will be removed.
1643 * @deprecated 2.9.0 Use the_content_feed()
1644 * @see the_content_feed()
1646 * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
1647 * @param int $stripteaser Optional. Default is 0.
1648 * @param string $more_file Optional.
1649 * @param int $cut Optional. Amount of words to keep for the content.
1650 * @param int $encode_html Optional. How to encode the content.
1652 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
1653 _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed' );
1654 $content = get_the_content($more_link_text, $stripteaser);
1655 $content = apply_filters('the_content_rss', $content);
1656 if ( $cut && !$encode_html )
1658 if ( 1== $encode_html ) {
1659 $content = esc_html($content);
1661 } elseif ( 0 == $encode_html ) {
1662 $content = make_url_footnote($content);
1663 } elseif ( 2 == $encode_html ) {
1664 $content = strip_tags($content);
1667 $blah = explode(' ', $content);
1668 if ( count($blah) > $cut ) {
1676 /** @todo Check performance, might be faster to use array slice instead. */
1677 for ( $i=0; $i<$k; $i++ )
1678 $excerpt .= $blah[$i].' ';
1679 $excerpt .= ($use_dotdotdot) ? '...' : '';
1680 $content = $excerpt;
1682 $content = str_replace(']]>', ']]>', $content);
1687 * Strip HTML and put links at the bottom of stripped content.
1689 * Searches for all of the links, strips them out of the content, and places
1690 * them at the bottom of the content with numbers.
1695 * @param string $content Content to get links
1696 * @return string HTML stripped out of content with links at the bottom.
1698 function make_url_footnote( $content ) {
1699 _deprecated_function( __FUNCTION__, '2.9.0', '' );
1700 preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches );
1701 $links_summary = "\n";
1702 for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) {
1703 $link_match = $matches[0][$i];
1704 $link_number = '['.($i+1).']';
1705 $link_url = $matches[2][$i];
1706 $link_text = $matches[4][$i];
1707 $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content );
1708 $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url;
1709 $links_summary .= "\n" . $link_number . ' ' . $link_url;
1711 $content = strip_tags( $content );
1712 $content .= $links_summary;
1717 * Retrieve translated string with vertical bar context
1719 * Quite a few times, there will be collisions with similar translatable text
1720 * found in more than two places but with different translated context.
1722 * In order to use the separate contexts, the _c() function is used and the
1723 * translatable string uses a pipe ('|') which has the context the string is in.
1725 * When the translated string is returned, it is everything before the pipe, not
1726 * including the pipe character. If there is no pipe in the translated text then
1727 * everything is returned.
1730 * @deprecated 2.9.0 Use _x()
1733 * @param string $text Text to translate
1734 * @param string $domain Optional. Domain to retrieve the translated text
1735 * @return string Translated context string without pipe
1737 function _c( $text, $domain = 'default' ) {
1738 _deprecated_function( __FUNCTION__, '2.9.0', '_x()' );
1739 return before_last_bar( translate( $text, $domain ) );
1743 * Translates $text like translate(), but assumes that the text
1744 * contains a context after its last vertical bar.
1747 * @deprecated 3.0.0 Use _x()
1750 * @param string $text Text to translate
1751 * @param string $domain Domain to retrieve the translated text
1752 * @return string Translated text
1754 function translate_with_context( $text, $domain = 'default' ) {
1755 _deprecated_function( __FUNCTION__, '2.9.0', '_x()' );
1756 return before_last_bar( translate( $text, $domain ) );
1760 * Legacy version of _n(), which supports contexts.
1762 * Strips everything from the translation after the last bar.
1765 * @deprecated 3.0.0 Use _nx()
1768 * @param string $single The text to be used if the number is singular.
1769 * @param string $plural The text to be used if the number is plural.
1770 * @param int $number The number to compare against to use either the singular or plural form.
1771 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
1772 * Default 'default'.
1773 * @return string The translated singular or plural form.
1775 function _nc( $single, $plural, $number, $domain = 'default' ) {
1776 _deprecated_function( __FUNCTION__, '2.9.0', '_nx()' );
1777 return before_last_bar( _n( $single, $plural, $number, $domain ) );
1781 * Retrieve the plural or single form based on the amount.
1784 * @deprecated 2.8.0 Use _n()
1787 function __ngettext() {
1788 _deprecated_function( __FUNCTION__, '2.8.0', '_n()' );
1789 $args = func_get_args();
1790 return call_user_func_array('_n', $args);
1794 * Register plural strings in POT file, but don't translate them.
1797 * @deprecated 2.8.0 Use _n_noop()
1800 function __ngettext_noop() {
1801 _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' );
1802 $args = func_get_args();
1803 return call_user_func_array('_n_noop', $args);
1808 * Retrieve all autoload options, or all options if no autoloaded ones exist.
1811 * @deprecated 3.0.0 Use wp_load_alloptions())
1812 * @see wp_load_alloptions()
1814 * @return array List of all options.
1816 function get_alloptions() {
1817 _deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' );
1818 return wp_load_alloptions();
1822 * Retrieve HTML content of attachment image with link.
1825 * @deprecated 2.5.0 Use wp_get_attachment_link()
1826 * @see wp_get_attachment_link()
1828 * @param int $id Optional. Post ID.
1829 * @param bool $fullsize Optional, default is false. Whether to use full size image.
1830 * @param array $max_dims Optional. Max image dimensions.
1831 * @param bool $permalink Optional, default is false. Whether to include permalink to image.
1834 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
1835 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' );
1837 $_post = get_post($id);
1839 if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
1840 return __('Missing Attachment');
1843 $url = get_attachment_link($_post->ID);
1845 $post_title = esc_attr($_post->post_title);
1847 $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
1848 return "<a href='$url' title='$post_title'>$innerHTML</a>";
1852 * Retrieve icon URL and Path.
1855 * @deprecated 2.5.0 Use wp_get_attachment_image_src()
1856 * @see wp_get_attachment_image_src()
1858 * @param int $id Optional. Post ID.
1859 * @param bool $fullsize Optional, default to false. Whether to have full image.
1860 * @return array Icon URL and full path to file, respectively.
1862 function get_attachment_icon_src( $id = 0, $fullsize = false ) {
1863 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' );
1865 if ( !$post = get_post($id) )
1868 $file = get_attached_file( $post->ID );
1870 if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
1871 // We have a thumbnail desired, specified and existing
1873 $src_file = basename($src);
1874 } elseif ( wp_attachment_is_image( $post->ID ) ) {
1875 // We have an image without a thumbnail
1877 $src = wp_get_attachment_url( $post->ID );
1878 $src_file = & $file;
1879 } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
1880 // No thumb, no image. We'll look for a mime-related icon instead.
1882 $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
1883 $src_file = $icon_dir . '/' . basename($src);
1886 if ( !isset($src) || !$src )
1889 return array($src, $src_file);
1893 * Retrieve HTML content of icon attachment image element.
1896 * @deprecated 2.5.0 Use wp_get_attachment_image()
1897 * @see wp_get_attachment_image()
1899 * @param int $id Optional. Post ID.
1900 * @param bool $fullsize Optional, default to false. Whether to have full size image.
1901 * @param array $max_dims Optional. Dimensions of image.
1902 * @return false|string HTML content.
1904 function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
1905 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' );
1907 if ( !$post = get_post($id) )
1910 if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
1913 list($src, $src_file) = $src;
1915 // Do we need to constrain the image?
1916 if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
1918 $imagesize = getimagesize($src_file);
1920 if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
1921 $actual_aspect = $imagesize[0] / $imagesize[1];
1922 $desired_aspect = $max_dims[0] / $max_dims[1];
1924 if ( $actual_aspect >= $desired_aspect ) {
1925 $height = $actual_aspect * $max_dims[0];
1926 $constraint = "width='{$max_dims[0]}' ";
1927 $post->iconsize = array($max_dims[0], $height);
1929 $width = $max_dims[1] / $actual_aspect;
1930 $constraint = "height='{$max_dims[1]}' ";
1931 $post->iconsize = array($width, $max_dims[1]);
1934 $post->iconsize = array($imagesize[0], $imagesize[1]);
1941 $post_title = esc_attr($post->post_title);
1943 $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
1945 return apply_filters( 'attachment_icon', $icon, $post->ID );
1949 * Retrieve HTML content of image element.
1952 * @deprecated 2.5.0 Use wp_get_attachment_image()
1953 * @see wp_get_attachment_image()
1955 * @param int $id Optional. Post ID.
1956 * @param bool $fullsize Optional, default to false. Whether to have full size image.
1957 * @param array $max_dims Optional. Dimensions of image.
1958 * @return false|string
1960 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
1961 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' );
1963 if ( !$post = get_post($id) )
1966 if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
1969 $innerHTML = esc_attr($post->post_title);
1971 return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
1975 * Retrieves bookmark data based on ID.
1978 * @deprecated 2.1.0 Use get_bookmark()
1979 * @see get_bookmark()
1981 * @param int $bookmark_id ID of link
1982 * @param string $output Optional. Type of output. Accepts OBJECT, ARRAY_N, or ARRAY_A.
1984 * @param string $filter Optional. How to filter the link for output. Accepts 'raw', 'edit',
1985 * 'attribute', 'js', 'db', or 'display'. Default 'raw'.
1986 * @return object|array Bookmark object or array, depending on the type specified by `$output`.
1988 function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) {
1989 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' );
1990 return get_bookmark($bookmark_id, $output, $filter);
1994 * Performs esc_url() for database or redirect usage.
1997 * @deprecated 2.8.0 Use esc_url_raw()
1998 * @see esc_url_raw()
2000 * @param string $url The URL to be cleaned.
2001 * @param array $protocols An array of acceptable protocols.
2002 * @return string The cleaned URL.
2004 function sanitize_url( $url, $protocols = null ) {
2005 _deprecated_function( __FUNCTION__, '2.8.0', 'esc_url_raw()' );
2006 return esc_url_raw( $url, $protocols );
2010 * Checks and cleans a URL.
2012 * A number of characters are removed from the URL. If the URL is for displaying
2013 * (the default behaviour) ampersands are also replaced. The 'clean_url' filter
2014 * is applied to the returned cleaned URL.
2017 * @deprecated 3.0.0 Use esc_url()
2020 * @param string $url The URL to be cleaned.
2021 * @param array $protocols Optional. An array of acceptable protocols.
2022 * @param string $context Optional. How the URL will be used. Default is 'display'.
2023 * @return string The cleaned $url after the {@see 'clean_url'} filter is applied.
2025 function clean_url( $url, $protocols = null, $context = 'display' ) {
2026 if ( $context == 'db' )
2027 _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()' );
2029 _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' );
2030 return esc_url( $url, $protocols, $context );
2034 * Escape single quotes, specialchar double quotes, and fix line endings.
2036 * The filter {@see 'js_escape'} is also applied by esc_js().
2039 * @deprecated 2.8.0 Use esc_js()
2042 * @param string $text The text to be escaped.
2043 * @return string Escaped text.
2045 function js_escape( $text ) {
2046 _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' );
2047 return esc_js( $text );
2051 * Legacy escaping for HTML blocks.
2053 * @deprecated 2.8.0 Use esc_html()
2056 * @param string $string String to escape.
2057 * @param string $quote_style Unused.
2058 * @param false|string $charset Unused.
2059 * @param false $double_encode Whether to double encode. Unused.
2060 * @return string Escaped `$string`.
2062 function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
2063 _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' );
2064 if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments.
2065 $args = func_get_args();
2066 return call_user_func_array( '_wp_specialchars', $args );
2068 return esc_html( $string );
2073 * Escaping for HTML attributes.
2076 * @deprecated 2.8.0 Use esc_attr()
2079 * @param string $text
2082 function attribute_escape( $text ) {
2083 _deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' );
2084 return esc_attr( $text );
2088 * Register widget for sidebar with backward compatibility.
2090 * Allows $name to be an array that accepts either three elements to grab the
2091 * first element and the third for the name or just uses the first element of
2092 * the array for the name.
2094 * Passes to wp_register_sidebar_widget() after argument list and backward
2095 * compatibility is complete.
2098 * @deprecated 2.8.0 Use wp_register_sidebar_widget()
2099 * @see wp_register_sidebar_widget()
2101 * @param string|int $name Widget ID.
2102 * @param callable $output_callback Run when widget is called.
2103 * @param string $classname Optional. Classname widget option. Default empty.
2104 * @param mixed $params ,... Widget parameters.
2106 function register_sidebar_widget($name, $output_callback, $classname = '') {
2107 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' );
2109 if ( is_array($name) ) {
2110 if ( count($name) == 3 )
2111 $name = sprintf($name[0], $name[2]);
2116 $id = sanitize_title($name);
2118 if ( !empty($classname) && is_string($classname) )
2119 $options['classname'] = $classname;
2120 $params = array_slice(func_get_args(), 2);
2121 $args = array($id, $name, $output_callback, $options);
2122 if ( !empty($params) )
2123 $args = array_merge($args, $params);
2125 call_user_func_array('wp_register_sidebar_widget', $args);
2129 * Serves as an alias of wp_unregister_sidebar_widget().
2132 * @deprecated 2.8.0 Use wp_unregister_sidebar_widget()
2133 * @see wp_unregister_sidebar_widget()
2135 * @param int|string $id Widget ID.
2137 function unregister_sidebar_widget($id) {
2138 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' );
2139 return wp_unregister_sidebar_widget($id);
2143 * Registers widget control callback for customizing options.
2145 * Allows $name to be an array that accepts either three elements to grab the
2146 * first element and the third for the name or just uses the first element of
2147 * the array for the name.
2149 * Passes to wp_register_widget_control() after the argument list has
2153 * @deprecated 2.8.0 Use wp_register_widget_control()
2154 * @see wp_register_widget_control()
2156 * @param int|string $name Sidebar ID.
2157 * @param callable $control_callback Widget control callback to display and process form.
2158 * @param int $width Widget width.
2159 * @param int $height Widget height.
2161 function register_widget_control($name, $control_callback, $width = '', $height = '') {
2162 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' );
2164 if ( is_array($name) ) {
2165 if ( count($name) == 3 )
2166 $name = sprintf($name[0], $name[2]);
2171 $id = sanitize_title($name);
2173 if ( !empty($width) )
2174 $options['width'] = $width;
2175 if ( !empty($height) )
2176 $options['height'] = $height;
2177 $params = array_slice(func_get_args(), 4);
2178 $args = array($id, $name, $control_callback, $options);
2179 if ( !empty($params) )
2180 $args = array_merge($args, $params);
2182 call_user_func_array('wp_register_widget_control', $args);
2186 * Alias of wp_unregister_widget_control().
2189 * @deprecated 2.8.0 Use wp_unregister_widget_control()
2190 * @see wp_unregister_widget_control()
2192 * @param int|string $id Widget ID.
2194 function unregister_widget_control($id) {
2195 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' );
2196 return wp_unregister_widget_control($id);
2200 * Remove user meta data.
2203 * @deprecated 3.0.0 Use delete_user_meta()
2204 * @see delete_user_meta()
2206 * @param int $user_id User ID.
2207 * @param string $meta_key Metadata key.
2208 * @param mixed $meta_value Metadata value.
2209 * @return bool True deletion completed and false if user_id is not a number.
2211 function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
2212 _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' );
2214 if ( !is_numeric( $user_id ) )
2216 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2218 if ( is_array($meta_value) || is_object($meta_value) )
2219 $meta_value = serialize($meta_value);
2220 $meta_value = trim( $meta_value );
2222 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2224 if ( $cur && $cur->umeta_id )
2225 do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2227 if ( ! empty($meta_value) )
2228 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) );
2230 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2232 clean_user_cache( $user_id );
2233 wp_cache_delete( $user_id, 'user_meta' );
2235 if ( $cur && $cur->umeta_id )
2236 do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2242 * Retrieve user metadata.
2244 * If $user_id is not a number, then the function will fail over with a 'false'
2245 * boolean return value. Other returned values depend on whether there is only
2246 * one item to be returned, which be that single item type. If there is more
2247 * than one metadata value, then it will be list of metadata values.
2250 * @deprecated 3.0.0 Use get_user_meta()
2251 * @see get_user_meta()
2253 * @param int $user_id User ID
2254 * @param string $meta_key Optional. Metadata key.
2257 function get_usermeta( $user_id, $meta_key = '' ) {
2258 _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' );
2260 $user_id = (int) $user_id;
2265 if ( !empty($meta_key) ) {
2266 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2267 $user = wp_cache_get($user_id, 'users');
2268 // Check the cached user object
2269 if ( false !== $user && isset($user->$meta_key) )
2270 $metas = array($user->$meta_key);
2272 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2274 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) );
2277 if ( empty($metas) ) {
2278 if ( empty($meta_key) )
2284 $metas = array_map('maybe_unserialize', $metas);
2286 if ( count($metas) == 1 )
2293 * Update metadata of user.
2295 * There is no need to serialize values, they will be serialized if it is
2296 * needed. The metadata key can only be a string with underscores. All else will
2299 * Will remove the metadata, if the meta value is empty.
2302 * @deprecated 3.0.0 Use update_user_meta()
2303 * @see update_user_meta()
2305 * @param int $user_id User ID
2306 * @param string $meta_key Metadata key.
2307 * @param mixed $meta_value Metadata value.
2308 * @return bool True on successful update, false on failure.
2310 function update_usermeta( $user_id, $meta_key, $meta_value ) {
2311 _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' );
2313 if ( !is_numeric( $user_id ) )
2315 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2317 /** @todo Might need fix because usermeta data is assumed to be already escaped */
2318 if ( is_string($meta_value) )
2319 $meta_value = stripslashes($meta_value);
2320 $meta_value = maybe_serialize($meta_value);
2322 if (empty($meta_value)) {
2323 return delete_usermeta($user_id, $meta_key);
2326 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2329 do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2332 $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') );
2333 elseif ( $cur->meta_value != $meta_value )
2334 $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') );
2338 clean_user_cache( $user_id );
2339 wp_cache_delete( $user_id, 'user_meta' );
2342 do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value );
2344 do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2350 * Get users for the site.
2352 * For setups that use the multisite feature. Can be used outside of the
2353 * multisite feature.
2356 * @deprecated 3.1.0 Use get_users()
2359 * @global wpdb $wpdb WordPress database abstraction object.
2361 * @param int $id Site ID.
2362 * @return array List of users that are part of that site ID
2364 function get_users_of_blog( $id = '' ) {
2365 _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
2368 if ( empty( $id ) ) {
2369 $id = get_current_blog_id();
2371 $blog_prefix = $wpdb->get_blog_prefix($id);
2372 $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
2377 * Enable/disable automatic general feed link outputting.
2380 * @deprecated 3.0.0 Use add_theme_support()
2381 * @see add_theme_support()
2383 * @param bool $add Optional, default is true. Add or remove links. Defaults to true.
2385 function automatic_feed_links( $add = true ) {
2386 _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" );
2389 add_theme_support( 'automatic-feed-links' );
2391 remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+
2395 * Retrieve user data based on field.
2398 * @deprecated 3.0.0 Use get_the_author_meta()
2399 * @see get_the_author_meta()
2401 * @param string $field User meta field.
2402 * @param false|int $user Optional. User ID to retrieve the field for. Default false (current user).
2403 * @return string The author's field from the current author's DB object.
2405 function get_profile( $field, $user = false ) {
2406 _deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' );
2408 $user = get_user_by( 'login', $user );
2411 return get_the_author_meta( $field, $user );
2415 * Retrieves the number of posts a user has written.
2418 * @deprecated 3.0.0 Use count_user_posts()
2419 * @see count_user_posts()
2421 * @param int $userid User to count posts for.
2422 * @return int Number of posts the given user has written.
2424 function get_usernumposts( $userid ) {
2425 _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' );
2426 return count_user_posts( $userid );
2430 * Callback used to change %uXXXX to &#YYY; syntax
2436 * @param array $matches Single Match
2437 * @return string An HTML entity
2439 function funky_javascript_callback($matches) {
2440 return "&#".base_convert($matches[1],16,10).";";
2444 * Fixes JavaScript bugs in browsers.
2446 * Converts unicode characters to HTML numbered entities.
2454 * @param string $text Text to be made safe.
2455 * @return string Fixed text.
2457 function funky_javascript_fix($text) {
2458 _deprecated_function( __FUNCTION__, '3.0.0' );
2459 // Fixes for browsers' JavaScript bugs.
2460 global $is_macIE, $is_winIE;
2462 if ( $is_winIE || $is_macIE )
2463 $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/",
2464 "funky_javascript_callback",
2471 * Checks that the taxonomy name exists.
2474 * @deprecated 3.0.0 Use taxonomy_exists()
2475 * @see taxonomy_exists()
2477 * @param string $taxonomy Name of taxonomy object
2478 * @return bool Whether the taxonomy exists.
2480 function is_taxonomy( $taxonomy ) {
2481 _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' );
2482 return taxonomy_exists( $taxonomy );
2486 * Check if Term exists.
2489 * @deprecated 3.0.0 Use term_exists()
2490 * @see term_exists()
2492 * @param int|string $term The term to check
2493 * @param string $taxonomy The taxonomy name to use
2494 * @param int $parent ID of parent term under which to confine the exists search.
2495 * @return mixed Get the term id or Term Object, if exists.
2497 function is_term( $term, $taxonomy = '', $parent = 0 ) {
2498 _deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' );
2499 return term_exists( $term, $taxonomy, $parent );
2503 * Is the current admin page generated by a plugin?
2505 * Use global $plugin_page and/or get_plugin_page_hookname() hooks.
2510 * @global $plugin_page
2514 function is_plugin_page() {
2515 _deprecated_function( __FUNCTION__, '3.1.0' );
2517 global $plugin_page;
2519 if ( isset($plugin_page) )
2526 * Update the categories cache.
2528 * This function does not appear to be used anymore or does not appear to be
2529 * needed. It might be a legacy function left over from when there was a need
2530 * for updating the category cache.
2535 * @return bool Always return True
2537 function update_category_cache() {
2538 _deprecated_function( __FUNCTION__, '3.1.0' );
2544 * Check for PHP timezone support
2551 function wp_timezone_supported() {
2552 _deprecated_function( __FUNCTION__, '3.2.0' );
2558 * Displays an editor: TinyMCE, HTML, or both.
2561 * @deprecated 3.3.0 Use wp_editor()
2564 * @param string $content Textarea content.
2565 * @param string $id Optional. HTML ID attribute value. Default 'content'.
2566 * @param string $prev_id Optional. Unused.
2567 * @param bool $media_buttons Optional. Whether to display media buttons. Default true.
2568 * @param int $tab_index Optional. Unused.
2569 * @param bool $extended Optional. Unused.
2571 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
2572 _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
2574 wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
2578 * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
2583 * @param array $ids User ID numbers list.
2584 * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
2586 function get_user_metavalues($ids) {
2587 _deprecated_function( __FUNCTION__, '3.3.0' );
2591 $ids = array_map('intval', $ids);
2592 foreach ( $ids as $id )
2593 $objects[$id] = array();
2595 $metas = update_meta_cache('user', $ids);
2597 foreach ( $metas as $id => $meta ) {
2598 foreach ( $meta as $key => $metavalues ) {
2599 foreach ( $metavalues as $value ) {
2600 $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
2609 * Sanitize every user field.
2611 * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
2616 * @param object|array $user The User Object or Array
2617 * @param string $context Optional, default is 'display'. How to sanitize user fields.
2618 * @return object|array The now sanitized User Object or Array (will be the same type as $user)
2620 function sanitize_user_object($user, $context = 'display') {
2621 _deprecated_function( __FUNCTION__, '3.3.0' );
2623 if ( is_object($user) ) {
2624 if ( !isset($user->ID) )
2626 if ( ! ( $user instanceof WP_User ) ) {
2627 $vars = get_object_vars($user);
2628 foreach ( array_keys($vars) as $field ) {
2629 if ( is_string($user->$field) || is_numeric($user->$field) )
2630 $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
2633 $user->filter = $context;
2635 if ( !isset($user['ID']) )
2637 foreach ( array_keys($user) as $field )
2638 $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
2639 $user['filter'] = $context;
2646 * Get boundary post relational link.
2648 * Can either be start or end post relational link.
2653 * @param string $title Optional. Link title format.
2654 * @param bool $in_same_cat Optional. Whether link should be in a same category.
2655 * @param string $excluded_categories Optional. Excluded categories IDs.
2656 * @param bool $start Optional, default is true. Whether to display link to first or last post.
2659 function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
2660 _deprecated_function( __FUNCTION__, '3.3.0' );
2662 $posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
2663 // If there is no post stop.
2664 if ( empty($posts) )
2667 // Even though we limited get_posts to return only 1 item it still returns an array of objects.
2670 if ( empty($post->post_title) )
2671 $post->post_title = $start ? __('First Post') : __('Last Post');
2673 $date = mysql2date(get_option('date_format'), $post->post_date);
2675 $title = str_replace('%title', $post->post_title, $title);
2676 $title = str_replace('%date', $date, $title);
2677 $title = apply_filters('the_title', $title, $post->ID);
2679 $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
2680 $link .= esc_attr($title);
2681 $link .= "' href='" . get_permalink($post) . "' />\n";
2683 $boundary = $start ? 'start' : 'end';
2684 return apply_filters( "{$boundary}_post_rel_link", $link );
2688 * Display relational link for the first post.
2693 * @param string $title Optional. Link title format.
2694 * @param bool $in_same_cat Optional. Whether link should be in a same category.
2695 * @param string $excluded_categories Optional. Excluded categories IDs.
2697 function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
2698 _deprecated_function( __FUNCTION__, '3.3.0' );
2700 echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);
2704 * Get site index relational link.
2711 function get_index_rel_link() {
2712 _deprecated_function( __FUNCTION__, '3.3.0' );
2714 $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n";
2715 return apply_filters( "index_rel_link", $link );
2719 * Display relational link for the site index.
2724 function index_rel_link() {
2725 _deprecated_function( __FUNCTION__, '3.3.0' );
2727 echo get_index_rel_link();
2731 * Get parent post relational link.
2736 * @param string $title Optional. Link title format. Default '%title'.
2739 function get_parent_post_rel_link( $title = '%title' ) {
2740 _deprecated_function( __FUNCTION__, '3.3.0' );
2742 if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
2743 $post = get_post($GLOBALS['post']->post_parent);
2748 $date = mysql2date(get_option('date_format'), $post->post_date);
2750 $title = str_replace('%title', $post->post_title, $title);
2751 $title = str_replace('%date', $date, $title);
2752 $title = apply_filters('the_title', $title, $post->ID);
2754 $link = "<link rel='up' title='";
2755 $link .= esc_attr( $title );
2756 $link .= "' href='" . get_permalink($post) . "' />\n";
2758 return apply_filters( "parent_post_rel_link", $link );
2762 * Display relational link for parent item
2767 * @param string $title Optional. Link title format. Default '%title'.
2769 function parent_post_rel_link( $title = '%title' ) {
2770 _deprecated_function( __FUNCTION__, '3.3.0' );
2772 echo get_parent_post_rel_link($title);
2776 * Add the "Dashboard"/"Visit Site" menu.
2781 * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
2783 function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
2784 _deprecated_function( __FUNCTION__, '3.3.0' );
2786 $user_id = get_current_user_id();
2788 if ( 0 != $user_id ) {
2790 $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) );
2791 elseif ( is_multisite() )
2792 $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );
2794 $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
2799 * Checks if the current user belong to a given site.
2802 * @deprecated 3.3.0 Use is_user_member_of_blog()
2803 * @see is_user_member_of_blog()
2805 * @param int $blog_id Site ID
2806 * @return bool True if the current users belong to $blog_id, false if not.
2808 function is_blog_user( $blog_id = 0 ) {
2809 _deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' );
2811 return is_user_member_of_blog( get_current_user_id(), $blog_id );
2815 * Open the file handle for debugging.
2818 * @deprecated 3.4.0 Use error_log()
2821 * @link https://secure.php.net/manual/en/function.error-log.php
2823 * @param string $filename File name.
2824 * @param string $mode Type of access you required to the stream.
2825 * @return false Always false.
2827 function debug_fopen( $filename, $mode ) {
2828 _deprecated_function( __FUNCTION__, 'error_log()' );
2833 * Write contents to the file used for debugging.
2836 * @deprecated 3.4.0 Use error_log()
2839 * @link https://secure.php.net/manual/en/function.error-log.php
2841 * @param mixed $fp Unused.
2842 * @param string $string Message to log.
2844 function debug_fwrite( $fp, $string ) {
2845 _deprecated_function( __FUNCTION__, 'error_log()' );
2846 if ( ! empty( $GLOBALS['debug'] ) )
2847 error_log( $string );
2851 * Close the debugging file handle.
2854 * @deprecated 3.4.0 Use error_log()
2857 * @link https://secure.php.net/manual/en/function.error-log.php
2859 * @param mixed $fp Unused.
2861 function debug_fclose( $fp ) {
2862 _deprecated_function( __FUNCTION__, 'error_log()' );
2866 * Retrieve list of themes with theme data in theme directory.
2868 * The theme is broken, if it doesn't have a parent theme and is missing either
2869 * style.css and, or index.php. If the theme has a parent theme then it is
2870 * broken, if it is missing style.css; index.php is optional.
2873 * @deprecated 3.4.0 Use wp_get_themes()
2874 * @see wp_get_themes()
2876 * @return array Theme list with theme data.
2878 function get_themes() {
2879 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' );
2882 if ( isset( $wp_themes ) )
2885 $themes = wp_get_themes();
2886 $wp_themes = array();
2888 foreach ( $themes as $theme ) {
2889 $name = $theme->get('Name');
2890 if ( isset( $wp_themes[ $name ] ) )
2891 $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme;
2893 $wp_themes[ $name ] = $theme;
2900 * Retrieve theme data.
2903 * @deprecated 3.4.0 Use wp_get_theme()
2904 * @see wp_get_theme()
2906 * @param string $theme Theme name.
2907 * @return array|null Null, if theme name does not exist. Theme data, if exists.
2909 function get_theme( $theme ) {
2910 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' );
2912 $themes = get_themes();
2913 if ( is_array( $themes ) && array_key_exists( $theme, $themes ) )
2914 return $themes[ $theme ];
2919 * Retrieve current theme name.
2922 * @deprecated 3.4.0 Use wp_get_theme()
2923 * @see wp_get_theme()
2927 function get_current_theme() {
2928 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
2930 if ( $theme = get_option( 'current_theme' ) )
2933 return wp_get_theme()->get('Name');
2937 * Accepts matches array from preg_replace_callback in wpautop() or a string.
2939 * Ensures that the contents of a `<pre>...</pre>` HTML block are not
2940 * converted into paragraphs or line-breaks.
2945 * @param array|string $matches The array or string
2946 * @return string The pre block without paragraph/line-break conversion.
2948 function clean_pre($matches) {
2949 _deprecated_function( __FUNCTION__, '3.4.0' );
2951 if ( is_array($matches) )
2952 $text = $matches[1] . $matches[2] . "</pre>";
2956 $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
2957 $text = str_replace('<p>', "\n", $text);
2958 $text = str_replace('</p>', '', $text);
2965 * Add callbacks for image header display.
2968 * @deprecated 3.4.0 Use add_theme_support()
2969 * @see add_theme_support()
2971 * @param callable $wp_head_callback Call on the {@see 'wp_head'} action.
2972 * @param callable $admin_head_callback Call on custom header administration screen.
2973 * @param callable $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional.
2975 function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) {
2976 _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' );
2978 'wp-head-callback' => $wp_head_callback,
2979 'admin-head-callback' => $admin_head_callback,
2981 if ( $admin_preview_callback )
2982 $args['admin-preview-callback'] = $admin_preview_callback;
2983 return add_theme_support( 'custom-header', $args );
2987 * Remove image header support.
2990 * @deprecated 3.4.0 Use remove_theme_support()
2991 * @see remove_theme_support()
2993 * @return null|bool Whether support was removed.
2995 function remove_custom_image_header() {
2996 _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' );
2997 return remove_theme_support( 'custom-header' );
3001 * Add callbacks for background image display.
3004 * @deprecated 3.4.0 Use add_theme_support()
3005 * @see add_theme_support()
3007 * @param callable $wp_head_callback Call on the {@see 'wp_head'} action.
3008 * @param callable $admin_head_callback Call on custom background administration screen.
3009 * @param callable $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional.
3011 function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) {
3012 _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' );
3014 if ( $wp_head_callback )
3015 $args['wp-head-callback'] = $wp_head_callback;
3016 if ( $admin_head_callback )
3017 $args['admin-head-callback'] = $admin_head_callback;
3018 if ( $admin_preview_callback )
3019 $args['admin-preview-callback'] = $admin_preview_callback;
3020 return add_theme_support( 'custom-background', $args );
3024 * Remove custom background support.
3027 * @deprecated 3.4.0 Use add_custom_background()
3028 * @see add_custom_background()
3030 * @return null|bool Whether support was removed.
3032 function remove_custom_background() {
3033 _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' );
3034 return remove_theme_support( 'custom-background' );
3038 * Retrieve theme data from parsed theme file.
3041 * @deprecated 3.4.0 Use wp_get_theme()
3042 * @see wp_get_theme()
3044 * @param string $theme_file Theme file path.
3045 * @return array Theme data.
3047 function get_theme_data( $theme_file ) {
3048 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
3049 $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
3051 $theme_data = array(
3052 'Name' => $theme->get('Name'),
3053 'URI' => $theme->display('ThemeURI', true, false),
3054 'Description' => $theme->display('Description', true, false),
3055 'Author' => $theme->display('Author', true, false),
3056 'AuthorURI' => $theme->display('AuthorURI', true, false),
3057 'Version' => $theme->get('Version'),
3058 'Template' => $theme->get('Template'),
3059 'Status' => $theme->get('Status'),
3060 'Tags' => $theme->get('Tags'),
3061 'Title' => $theme->get('Name'),
3062 'AuthorName' => $theme->get('Author'),
3065 foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) {
3066 if ( ! isset( $theme_data[ $extra_header ] ) )
3067 $theme_data[ $extra_header ] = $theme->get( $extra_header );
3074 * Alias of update_post_cache().
3076 * @see update_post_cache() Posts and pages are the same, alias is intentional
3079 * @deprecated 3.4.0 Use update_post_cache()
3080 * @see update_post_cache()
3082 * @param array $pages list of page objects
3084 function update_page_cache( &$pages ) {
3085 _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' );
3087 update_post_cache( $pages );
3091 * Will clean the page in the cache.
3093 * Clean (read: delete) page from cache that matches $id. Will also clean cache
3094 * associated with 'all_page_ids' and 'get_pages'.
3097 * @deprecated 3.4.0 Use clean_post_cache
3098 * @see clean_post_cache()
3100 * @param int $id Page ID to clean
3102 function clean_page_cache( $id ) {
3103 _deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' );
3105 clean_post_cache( $id );
3109 * Retrieve nonce action "Are you sure" message.
3111 * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3.
3114 * @deprecated 3.4.1 Use wp_nonce_ays()
3115 * @see wp_nonce_ays()
3117 * @param string $action Nonce action.
3118 * @return string Are you sure message.
3120 function wp_explain_nonce( $action ) {
3121 _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' );
3122 return __( 'Are you sure you want to do this?' );
3126 * Display "sticky" CSS class, if a post is sticky.
3129 * @deprecated 3.5.0 Use post_class()
3132 * @param int $post_id An optional post ID.
3134 function sticky_class( $post_id = null ) {
3135 _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' );
3136 if ( is_sticky( $post_id ) )
3141 * Retrieve post ancestors.
3143 * This is no longer needed as WP_Post lazy-loads the ancestors
3144 * property with get_post_ancestors().
3147 * @deprecated 3.5.0 Use get_post_ancestors()
3148 * @see get_post_ancestors()
3150 * @param WP_Post &$post Post object, passed by reference (unused).
3152 function _get_post_ancestors( &$post ) {
3153 _deprecated_function( __FUNCTION__, '3.5.0' );
3157 * Load an image from a string, if PHP supports it.
3160 * @deprecated 3.5.0 Use wp_get_image_editor()
3161 * @see wp_get_image_editor()
3163 * @param string $file Filename of the image to load.
3164 * @return resource The resulting image resource on success, Error string on failure.
3166 function wp_load_image( $file ) {
3167 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
3169 if ( is_numeric( $file ) )
3170 $file = get_attached_file( $file );
3172 if ( ! is_file( $file ) ) {
3173 /* translators: %s: file name */
3174 return sprintf( __( 'File “%s” doesn’t exist?' ), $file );
3177 if ( ! function_exists('imagecreatefromstring') )
3178 return __('The GD image library is not installed.');
3180 // Set artificially high because GD uses uncompressed images in memory.
3181 wp_raise_memory_limit( 'image' );
3183 $image = imagecreatefromstring( file_get_contents( $file ) );
3185 if ( ! is_resource( $image ) ) {
3186 /* translators: %s: file name */
3187 return sprintf( __( 'File “%s” is not an image.' ), $file );
3194 * Scale down an image to fit a particular size and save a new copy of the image.
3196 * The PNG transparency will be preserved using the function, as well as the
3197 * image type. If the file going in is PNG, then the resized image is going to
3198 * be PNG. The only supported image types are PNG, GIF, and JPEG.
3200 * Some functionality requires API to exist, so some PHP version may lose out
3201 * support. This is not the fault of WordPress (where functionality is
3202 * downgraded, not actual defects), but of your PHP version.
3205 * @deprecated 3.5.0 Use wp_get_image_editor()
3206 * @see wp_get_image_editor()
3208 * @param string $file Image file path.
3209 * @param int $max_w Maximum width to resize to.
3210 * @param int $max_h Maximum height to resize to.
3211 * @param bool $crop Optional. Whether to crop image or resize.
3212 * @param string $suffix Optional. File suffix.
3213 * @param string $dest_path Optional. New image file path.
3214 * @param int $jpeg_quality Optional, default is 90. Image quality percentage.
3215 * @return mixed WP_Error on failure. String with new destination path.
3217 function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
3218 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
3220 $editor = wp_get_image_editor( $file );
3221 if ( is_wp_error( $editor ) )
3223 $editor->set_quality( $jpeg_quality );
3225 $resized = $editor->resize( $max_w, $max_h, $crop );
3226 if ( is_wp_error( $resized ) )
3229 $dest_file = $editor->generate_filename( $suffix, $dest_path );
3230 $saved = $editor->save( $dest_file );
3232 if ( is_wp_error( $saved ) )
3239 * Retrieve a single post, based on post ID.
3241 * Has categories in 'post_category' property or key. Has tags in 'tags_input'
3245 * @deprecated 3.5.0 Use get_post()
3248 * @param int $postid Post ID.
3249 * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
3250 * @return WP_Post|null Post object or array holding post contents and information
3252 function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
3253 _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
3254 return get_post( $postid, $mode );
3258 * Check that the user login name and password is correct.
3261 * @deprecated 3.5.0 Use wp_authenticate()
3262 * @see wp_authenticate()
3264 * @param string $user_login User name.
3265 * @param string $user_pass User password.
3266 * @return bool False if does not authenticate, true if username and password authenticates.
3268 function user_pass_ok($user_login, $user_pass) {
3269 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' );
3270 $user = wp_authenticate( $user_login, $user_pass );
3271 if ( is_wp_error( $user ) )
3278 * Callback formerly fired on the save_post hook. No longer needed.
3283 function _save_post_hook() {}
3286 * Check if the installed version of GD supports particular image type
3289 * @deprecated 3.5.0 Use wp_image_editor_supports()
3290 * @see wp_image_editor_supports()
3292 * @param string $mime_type
3295 function gd_edit_image_support($mime_type) {
3296 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' );
3298 if ( function_exists('imagetypes') ) {
3299 switch( $mime_type ) {
3301 return (imagetypes() & IMG_JPG) != 0;
3303 return (imagetypes() & IMG_PNG) != 0;
3305 return (imagetypes() & IMG_GIF) != 0;
3308 switch( $mime_type ) {
3310 return function_exists('imagecreatefromjpeg');
3312 return function_exists('imagecreatefrompng');
3314 return function_exists('imagecreatefromgif');
3321 * Converts an integer byte value to a shorthand byte value.
3324 * @deprecated 3.6.0 Use size_format()
3325 * @see size_format()
3327 * @param int $bytes An integer byte value.
3328 * @return string A shorthand byte value.
3330 function wp_convert_bytes_to_hr( $bytes ) {
3331 _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' );
3333 $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' );
3334 $log = log( $bytes, KB_IN_BYTES );
3335 $power = (int) $log;
3336 $size = pow( KB_IN_BYTES, $log - $power );
3338 if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) {
3339 $unit = $units[ $power ];
3345 return $size . $unit;
3349 * Formerly used internally to tidy up the search terms.
3355 * @param string $t Search terms to "tidy", e.g. trim.
3356 * @return string Trimmed search terms.
3358 function _search_terms_tidy( $t ) {
3359 _deprecated_function( __FUNCTION__, '3.7.0' );
3360 return trim( $t, "\"'\n\r " );
3364 * Determine if TinyMCE is available.
3366 * Checks to see if the user has deleted the tinymce files to slim down
3367 * their WordPress install.
3372 * @return bool Whether TinyMCE exists.
3374 function rich_edit_exists() {
3375 global $wp_rich_edit_exists;
3376 _deprecated_function( __FUNCTION__, '3.9.0' );
3378 if ( ! isset( $wp_rich_edit_exists ) )
3379 $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' );
3381 return $wp_rich_edit_exists;
3385 * Old callback for tag link tooltips.
3391 * @param int $count Number of topics.
3392 * @return int Number of topics.
3394 function default_topic_count_text( $count ) {
3399 * Formerly used to escape strings before inserting into the DB.
3401 * Has not performed this function for many, many years. Use wpdb::prepare() instead.
3406 * @param string $content The text to format.
3407 * @return string The very same text.
3409 function format_to_post( $content ) {
3410 _deprecated_function( __FUNCTION__, '3.9.0' );
3415 * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
3418 * @deprecated 4.0.0 Use wpdb::esc_like()
3419 * @see wpdb::esc_like()
3421 * @param string $text The text to be escaped.
3422 * @return string text, safe for inclusion in LIKE query.
3424 function like_escape($text) {
3425 _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' );
3426 return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text );
3430 * Determines if the URL can be accessed over SSL.
3432 * Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access
3433 * the URL using https as the scheme.
3438 * @param string $url The URL to test.
3439 * @return bool Whether SSL access is available.
3441 function url_is_accessable_via_ssl( $url ) {
3442 _deprecated_function( __FUNCTION__, '4.0.0' );
3444 $response = wp_remote_get( set_url_scheme( $url, 'https' ) );
3446 if ( !is_wp_error( $response ) ) {
3447 $status = wp_remote_retrieve_response_code( $response );
3448 if ( 200 == $status || 401 == $status ) {
3457 * Start preview theme output buffer.
3459 * Will only perform task if the user has permissions and template and preview
3460 * query variables exist.
3465 function preview_theme() {
3466 _deprecated_function( __FUNCTION__, '4.3.0' );
3470 * Private function to modify the current template when previewing a theme
3478 function _preview_theme_template_filter() {
3479 _deprecated_function( __FUNCTION__, '4.3.0' );
3484 * Private function to modify the current stylesheet when previewing a theme
3492 function _preview_theme_stylesheet_filter() {
3493 _deprecated_function( __FUNCTION__, '4.3.0' );
3498 * Callback function for ob_start() to capture all links in the theme.
3504 * @param string $content
3507 function preview_theme_ob_filter( $content ) {
3508 _deprecated_function( __FUNCTION__, '4.3.0' );
3513 * Manipulates preview theme links in order to control and maintain location.
3515 * Callback function for preg_replace_callback() to accept and filter matches.
3521 * @param array $matches
3524 function preview_theme_ob_filter_callback( $matches ) {
3525 _deprecated_function( __FUNCTION__, '4.3.0' );
3530 * Formats text for the rich text editor.
3532 * The {@see 'richedit_pre'} filter is applied here. If $text is empty the filter will
3533 * be applied to an empty string.
3538 * @param string $text The text to be formatted.
3539 * @return string The formatted text after filter is applied.
3541 function wp_richedit_pre($text) {
3542 _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
3544 if ( empty( $text ) ) {
3546 * Filters text returned for the rich text editor.
3548 * This filter is first evaluated, and the value returned, if an empty string
3549 * is passed to wp_richedit_pre(). If an empty string is passed, it results
3550 * in a break tag and line feed.
3552 * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
3553 * return after being formatted.
3558 * @param string $output Text for the rich text editor.
3560 return apply_filters( 'richedit_pre', '' );
3563 $output = convert_chars($text);
3564 $output = wpautop($output);
3565 $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );
3567 /** This filter is documented in wp-includes/deprecated.php */
3568 return apply_filters( 'richedit_pre', $output );
3572 * Formats text for the HTML editor.
3574 * Unless $output is empty it will pass through htmlspecialchars before the
3575 * {@see 'htmledit_pre'} filter is applied.
3578 * @deprecated 4.3.0 Use format_for_editor()
3579 * @see format_for_editor()
3581 * @param string $output The text to be formatted.
3582 * @return string Formatted text after filter applied.
3584 function wp_htmledit_pre($output) {
3585 _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
3587 if ( !empty($output) )
3588 $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > &
3591 * Filters the text before it is formatted for the HTML editor.
3596 * @param string $output The HTML-formatted text.
3598 return apply_filters( 'htmledit_pre', $output );
3602 * Retrieve permalink from post ID.
3605 * @deprecated 4.4.0 Use get_permalink()
3606 * @see get_permalink()
3608 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
3609 * @return string|false
3611 function post_permalink( $post_id = 0 ) {
3612 _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' );
3614 return get_permalink( $post_id );
3618 * Perform a HTTP HEAD or GET request.
3620 * If $file_path is a writable filename, this will do a GET request and write
3621 * the file to that path.
3624 * @deprecated 4.4.0 Use WP_Http
3627 * @param string $url URL to fetch.
3628 * @param string|bool $file_path Optional. File path to write request to. Default false.
3629 * @param int $red Optional. The number of Redirects followed, Upon 5 being hit,
3630 * returns false. Default 1.
3631 * @return bool|string False on failure and string of headers if HEAD request.
3633 function wp_get_http( $url, $file_path = false, $red = 1 ) {
3634 _deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' );
3636 @set_time_limit( 60 );
3642 $options['redirection'] = 5;
3644 if ( false == $file_path )
3645 $options['method'] = 'HEAD';
3647 $options['method'] = 'GET';
3649 $response = wp_safe_remote_request( $url, $options );
3651 if ( is_wp_error( $response ) )
3654 $headers = wp_remote_retrieve_headers( $response );
3655 $headers['response'] = wp_remote_retrieve_response_code( $response );
3657 // WP_HTTP no longer follows redirects for HEAD requests.
3658 if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
3659 return wp_get_http( $headers['location'], $file_path, ++$red );
3662 if ( false == $file_path )
3665 // GET request - write it to the supplied filename
3666 $out_fp = fopen($file_path, 'w');
3670 fwrite( $out_fp, wp_remote_retrieve_body( $response ) );
3678 * Whether SSL login should be forced.
3681 * @deprecated 4.4.0 Use force_ssl_admin()
3682 * @see force_ssl_admin()
3684 * @param string|bool $force Optional Whether to force SSL login. Default null.
3685 * @return bool True if forced, false if not forced.
3687 function force_ssl_login( $force = null ) {
3688 _deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' );
3689 return force_ssl_admin( $force );
3693 * Retrieve path of comment popup template in current or parent template.
3698 * @return string Full path to comments popup template file.
3700 function get_comments_popup_template() {
3701 _deprecated_function( __FUNCTION__, '4.5.0' );
3707 * Whether the current URL is within the comments popup window.
3714 function is_comments_popup() {
3715 _deprecated_function( __FUNCTION__, '4.5.0' );
3721 * Display the JS popup script to show a comment.
3726 function comments_popup_script() {
3727 _deprecated_function( __FUNCTION__, '4.5.0' );
3731 * Adds element attributes to open links in new windows.
3736 * @param string $text Content to replace links to open in a new window.
3737 * @return string Content that has filtered links.
3739 function popuplinks( $text ) {
3740 _deprecated_function( __FUNCTION__, '4.5.0' );
3741 $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
3746 * The Google Video embed handler callback.
3748 * Deprecated function that previously assisted in turning Google Video URLs
3749 * into embeds but that service has since been shut down.
3754 * @return string An empty string.
3756 function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
3757 _deprecated_function( __FUNCTION__, '4.6.0' );
3763 * Retrieve path of paged template in current or parent template.
3766 * @deprecated 4.7.0 The paged.php template is no longer part of the theme template hierarchy.
3768 * @return string Full path to paged template file.
3770 function get_paged_template() {
3771 _deprecated_function( __FUNCTION__, '4.7.0' );
3773 return get_query_template( 'paged' );
3777 * Removes the HTML JavaScript entities found in early versions of Netscape 4.
3779 * Previously, this function was pulled in from the original
3780 * import of kses and removed a specific vulnerability only
3781 * existent in early version of Netscape 4. However, this
3782 * vulnerability never affected any other browsers and can
3783 * be considered safe for the modern web.
3785 * The regular expression which sanitized this vulnerability
3786 * has been removed in consideration of the performance and
3787 * energy demands it placed, now merely passing through its
3788 * input to the return.
3791 * @deprecated deprecated since 4.7
3793 * @param string $string
3796 function wp_kses_js_entities( $string ) {
3797 _deprecated_function( __FUNCTION__, '4.7.0' );
3799 return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $string );
3803 * Sort categories by ID.
3805 * Used by usort() as a callback, should not be used directly. Can actually be
3806 * used to sort any term object.
3809 * @deprecated 4.7.0 Use wp_list_sort()
3816 function _usort_terms_by_ID( $a, $b ) {
3817 _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' );
3819 if ( $a->term_id > $b->term_id )
3821 elseif ( $a->term_id < $b->term_id )
3828 * Sort categories by name.
3830 * Used by usort() as a callback, should not be used directly. Can actually be
3831 * used to sort any term object.
3834 * @deprecated 4.7.0 Use wp_list_sort()
3841 function _usort_terms_by_name( $a, $b ) {
3842 _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' );
3844 return strcmp( $a->name, $b->name );
3848 * Sort menu items by the desired key.
3851 * @deprecated 4.7.0 Use wp_list_sort()
3854 * @global string $_menu_item_sort_prop
3856 * @param object $a The first object to compare
3857 * @param object $b The second object to compare
3858 * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.
3860 function _sort_nav_menu_items( $a, $b ) {
3861 global $_menu_item_sort_prop;
3863 _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' );
3865 if ( empty( $_menu_item_sort_prop ) )
3868 if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) )
3871 $_a = (int) $a->$_menu_item_sort_prop;
3872 $_b = (int) $b->$_menu_item_sort_prop;
3874 if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop )
3876 elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop )
3877 return $_a < $_b ? -1 : 1;
3879 return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );