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.
20 * @deprecated Use get_post()
26 function get_postdata($postid) {
27 _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
29 $post = get_post($postid);
33 'Author_ID' => $post->post_author,
34 'Date' => $post->post_date,
35 'Content' => $post->post_content,
36 'Excerpt' => $post->post_excerpt,
37 'Title' => $post->post_title,
38 'Category' => $post->post_category,
39 'post_status' => $post->post_status,
40 'comment_status' => $post->comment_status,
41 'ping_status' => $post->ping_status,
42 'post_password' => $post->post_password,
43 'to_ping' => $post->to_ping,
44 'pinged' => $post->pinged,
45 'post_type' => $post->post_type,
46 'post_name' => $post->post_name
53 * Sets up the WordPress Loop.
57 * @deprecated Use The Loop - {@link https://codex.wordpress.org/The_Loop Use new WordPress Loop}
62 _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') );
64 // Since the old style loop is being used, advance the query iterator here.
65 $wp_query->next_post();
67 setup_postdata( get_post() );
71 * Return or Print Category ID.
75 * @deprecated use get_the_category()
76 * @see get_the_category()
81 function the_category_ID($echo = true) {
82 _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );
84 // Grab the first cat in the list.
85 $categories = get_the_category();
86 $cat = $categories[0]->term_id;
95 * Print category with optional text before and after.
99 * @deprecated use get_the_category_by_ID()
100 * @see get_the_category_by_ID()
102 * @param string $before
103 * @param string $after
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 link to the previous post.
126 * @deprecated Use previous_post_link()
127 * @see previous_post_link()
129 * @param string $format
130 * @param string $previous
131 * @param string $title
132 * @param string $in_same_cat
133 * @param int $limitprev
134 * @param string $excluded_categories
136 function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
138 _deprecated_function( __FUNCTION__, '2.0', 'previous_post_link()' );
140 if ( empty($in_same_cat) || 'no' == $in_same_cat )
141 $in_same_cat = false;
145 $post = get_previous_post($in_same_cat, $excluded_categories);
150 $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
151 if ( 'yes' == $title )
152 $string .= apply_filters('the_title', $post->post_title, $post->ID);
154 $format = str_replace('%', $string, $format);
159 * Prints link to the next post.
163 * @deprecated Use next_post_link()
164 * @see next_post_link()
166 * @param string $format
167 * @param string $next
168 * @param string $title
169 * @param string $in_same_cat
170 * @param int $limitnext
171 * @param string $excluded_categories
173 function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
174 _deprecated_function( __FUNCTION__, '2.0', 'next_post_link()' );
176 if ( empty($in_same_cat) || 'no' == $in_same_cat )
177 $in_same_cat = false;
181 $post = get_next_post($in_same_cat, $excluded_categories);
186 $string = '<a href="'.get_permalink($post->ID).'">'.$next;
187 if ( 'yes' == $title )
188 $string .= apply_filters('the_title', $post->post_title, $post->ID);
190 $format = str_replace('%', $string, $format);
195 * Whether user can create a post.
199 * @deprecated Use current_user_can()
200 * @see current_user_can()
202 * @param int $user_id
203 * @param int $blog_id Not Used
204 * @param int $category_id Not Used
207 function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
208 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
210 $author_data = get_userdata($user_id);
211 return ($author_data->user_level > 1);
215 * Whether user can create a post.
219 * @deprecated Use current_user_can()
220 * @see current_user_can()
222 * @param int $user_id
223 * @param int $blog_id Not Used
224 * @param int $category_id Not Used
227 function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
228 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
230 $author_data = get_userdata($user_id);
231 return ($author_data->user_level >= 1);
235 * Whether user can edit a post.
239 * @deprecated Use current_user_can()
240 * @see current_user_can()
242 * @param int $user_id
243 * @param int $post_id
244 * @param int $blog_id Not Used
247 function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
248 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
250 $author_data = get_userdata($user_id);
251 $post = get_post($post_id);
252 $post_author_data = get_userdata($post->post_author);
254 if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
255 || ($author_data->user_level > $post_author_data->user_level)
256 || ($author_data->user_level >= 10) ) {
264 * Whether user can delete a post.
268 * @deprecated Use current_user_can()
269 * @see current_user_can()
271 * @param int $user_id
272 * @param int $post_id
273 * @param int $blog_id Not Used
276 function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
277 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
279 // right now if one can edit, one can delete
280 return user_can_edit_post($user_id, $post_id, $blog_id);
284 * Whether user can set new posts' dates.
288 * @deprecated Use current_user_can()
289 * @see current_user_can()
291 * @param int $user_id
292 * @param int $blog_id Not Used
293 * @param int $category_id Not Used
296 function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
297 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
299 $author_data = get_userdata($user_id);
300 return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
304 * Whether user can delete a post.
308 * @deprecated Use current_user_can()
309 * @see current_user_can()
311 * @param int $user_id
312 * @param int $post_id
313 * @param int $blog_id Not Used
314 * @return bool returns true if $user_id can edit $post_id's date
316 function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
317 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
319 $author_data = get_userdata($user_id);
320 return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
324 * Whether user can delete a post.
328 * @deprecated Use current_user_can()
329 * @see current_user_can()
331 * @param int $user_id
332 * @param int $post_id
333 * @param int $blog_id Not Used
334 * @return bool returns true if $user_id can edit $post_id's comments
336 function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
337 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
339 // right now if one can edit a post, one can edit comments made on it
340 return user_can_edit_post($user_id, $post_id, $blog_id);
344 * Whether user can delete a post.
348 * @deprecated Use current_user_can()
349 * @see current_user_can()
351 * @param int $user_id
352 * @param int $post_id
353 * @param int $blog_id Not Used
354 * @return bool returns true if $user_id can delete $post_id's comments
356 function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
357 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
359 // right now if one can edit comments, one can delete comments
360 return user_can_edit_post_comments($user_id, $post_id, $blog_id);
364 * Can user can edit other user.
368 * @deprecated Use current_user_can()
369 * @see current_user_can()
371 * @param int $user_id
372 * @param int $other_user
375 function user_can_edit_user($user_id, $other_user) {
376 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
378 $user = get_userdata($user_id);
379 $other = get_userdata($other_user);
380 if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
387 * Gets the links associated with category $cat_name.
391 * @deprecated Use get_bookmarks()
392 * @see get_bookmarks()
394 * @param string $cat_name Optional. The category name to use. If no match is found uses all.
395 * @param string $before Optional. The html to output before the link.
396 * @param string $after Optional. The html to output after the link.
397 * @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.
398 * @param bool $show_images Optional. Whether to show images (if defined).
399 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner.
400 * 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
402 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
403 * @param bool $show_rating Optional. Show rating stars/chars.
404 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
405 * @param int $show_updated Optional. Whether to show last updated timestamp
407 function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
408 $show_description = true, $show_rating = false,
409 $limit = -1, $show_updated = 0) {
410 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
413 $cat = get_term_by('name', $cat_name, 'link_category');
415 $cat_id = $cat->term_id;
417 get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated);
421 * Gets the links associated with the named category.
425 * @deprecated Use wp_list_bookmarks()
426 * @see wp_list_bookmarks()
428 * @param string $category The category to use.
429 * @param string $args
430 * @return string|null
432 function wp_get_linksbyname($category, $args = '') {
433 _deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()');
439 'category_after' => '',
440 'category_before' => '',
441 'category_name' => $category,
442 'show_description' => 1,
446 $r = wp_parse_args( $args, $defaults );
448 return wp_list_bookmarks($r);
452 * Gets an array of link objects associated with category $cat_name.
454 * $links = get_linkobjectsbyname( 'fred' );
455 * foreach ( $links as $link ) {
456 * echo '<li>' . $link->link_name . '</li>';
461 * @deprecated Use get_bookmarks()
462 * @see get_bookmarks()
464 * @param string $cat_name The category name to use. If no match is found uses all.
465 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'.
466 * Or maybe owner. If you start the name with an underscore the order will be reversed. You can also
467 * specify 'rand' as the order which will return links in a random order.
468 * @param int $limit Limit to X entries. If not specified, all entries are shown.
471 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
472 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
475 $cat = get_term_by('name', $cat_name, 'link_category');
477 $cat_id = $cat->term_id;
479 return get_linkobjects($cat_id, $orderby, $limit);
483 * Gets an array of link objects associated with category n.
487 * $links = get_linkobjects(1);
489 * foreach ($links as $link) {
490 * echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
512 * @deprecated Use get_bookmarks()
513 * @see get_bookmarks()
515 * @param int $category The category to use. If no category supplied uses all
516 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
517 * 'description', or 'rating'. Or maybe owner. If you start the name with an
518 * underscore the order will be reversed. You can also specify 'rand' as the
519 * order which will return links in a random order.
520 * @param int $limit Limit to X entries. If not specified, all entries are shown.
523 function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) {
524 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
526 $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ;
528 $links_array = array();
529 foreach ($links as $link)
530 $links_array[] = $link;
536 * Gets the links associated with category 'cat_name' and display rating stars/chars.
540 * @deprecated Use get_bookmarks()
541 * @see get_bookmarks()
543 * @param string $cat_name The category name to use. If no match is found uses all
544 * @param string $before The html to output before the link
545 * @param string $after The html to output after the link
546 * @param string $between The html to output between the link/image and its description. Not used if no image or show_images is true
547 * @param bool $show_images Whether to show images (if defined).
548 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
549 * 'description', or 'rating'. Or maybe owner. If you start the name with an
550 * underscore the order will be reversed. You can also specify 'rand' as the
551 * order which will return links in a random order.
552 * @param bool $show_description Whether to show the description if show_images=false/not defined
553 * @param int $limit Limit to X entries. If not specified, all entries are shown.
554 * @param int $show_updated Whether to show last updated timestamp
556 function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ",
557 $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
558 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
560 get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
564 * Gets the links associated with category n and display rating stars/chars.
568 * @deprecated Use get_bookmarks()
569 * @see get_bookmarks()
571 * @param int $category The category to use. If no category supplied uses all
572 * @param string $before The html to output before the link
573 * @param string $after The html to output after the link
574 * @param string $between The html to output between the link/image and its description. Not used if no image or show_images == true
575 * @param bool $show_images Whether to show images (if defined).
576 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url',
577 * 'description', or 'rating'. Or maybe owner. If you start the name with an
578 * underscore the order will be reversed. You can also specify 'rand' as the
579 * order which will return links in a random order.
580 * @param bool $show_description Whether to show the description if show_images=false/not defined.
581 * @param int $limit Limit to X entries. If not specified, all entries are shown.
582 * @param int $show_updated Whether to show last updated timestamp
584 function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true,
585 $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
586 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
588 get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
592 * Gets the auto_toggle setting.
596 * @deprecated No alternative function available
598 * @param int $id The category to get. If no category supplied uses 0
599 * @return int Only returns 0.
601 function get_autotoggle($id = 0) {
602 _deprecated_function( __FUNCTION__, '2.1' );
609 * @deprecated Use wp_list_categories()
610 * @see wp_list_categories()
612 * @param int $optionall
614 * @param string $sort_column
615 * @param string $sort_order
616 * @param string $file
618 * @param int $optiondates
619 * @param int $optioncount
620 * @param int $hide_empty
621 * @param int $use_desc_for_title
622 * @param bool $children
623 * @param int $child_of
624 * @param int $categories
625 * @param int $recurse
626 * @param string $feed
627 * @param string $feed_image
628 * @param string $exclude
629 * @param bool $hierarchical
632 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0,
633 $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0,
634 $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) {
635 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' );
637 $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children',
638 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical');
639 return wp_list_cats($query);
645 * @deprecated Use wp_list_categories()
646 * @see wp_list_categories()
648 * @param string|array $args
649 * @return false|null|string
651 function wp_list_cats($args = '') {
652 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' );
654 $r = wp_parse_args( $args );
657 if ( isset($r['optionall']) && isset($r['all']))
658 $r['show_option_all'] = $r['all'];
659 if ( isset($r['sort_column']) )
660 $r['orderby'] = $r['sort_column'];
661 if ( isset($r['sort_order']) )
662 $r['order'] = $r['sort_order'];
663 if ( isset($r['optiondates']) )
664 $r['show_last_update'] = $r['optiondates'];
665 if ( isset($r['optioncount']) )
666 $r['show_count'] = $r['optioncount'];
667 if ( isset($r['list']) )
668 $r['style'] = $r['list'] ? 'list' : 'break';
671 return wp_list_categories($r);
677 * @deprecated Use wp_dropdown_categories()
678 * @see wp_dropdown_categories()
680 * @param int $optionall
682 * @param string $orderby
683 * @param string $order
684 * @param int $show_last_update
685 * @param int $show_count
686 * @param int $hide_empty
687 * @param bool $optionnone
688 * @param int $selected
689 * @param int $exclude
692 function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
693 $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false,
694 $selected = 0, $exclude = 0) {
695 _deprecated_function( __FUNCTION__, '2.1', 'wp_dropdown_categories()' );
697 $show_option_all = '';
699 $show_option_all = $all;
701 $show_option_none = '';
703 $show_option_none = __('None');
705 $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
706 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
707 $query = add_query_arg($vars, '');
708 return wp_dropdown_categories($query);
716 * @deprecated Use wp_list_authors()
717 * @see wp_list_authors()
719 * @param bool $optioncount
720 * @param bool $exclude_admin
721 * @param bool $show_fullname
722 * @param bool $hide_empty
723 * @param string $feed
724 * @param string $feed_image
725 * @return null|string
727 function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
728 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_authors()' );
730 $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
731 return wp_list_authors($args);
737 * @deprecated Use wp_get_post_categories()
738 * @see wp_get_post_categories()
740 * @param int $blogid Not Used
741 * @param int $post_ID
744 function wp_get_post_cats($blogid = '1', $post_ID = 0) {
745 _deprecated_function( __FUNCTION__, '2.1', 'wp_get_post_categories()' );
746 return wp_get_post_categories($post_ID);
750 * Sets the categories that the post id belongs to.
754 * @deprecated Use wp_set_post_categories()
755 * @see wp_set_post_categories()
757 * @param int $blogid Not used
758 * @param int $post_ID
759 * @param array $post_categories
762 function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
763 _deprecated_function( __FUNCTION__, '2.1', 'wp_set_post_categories()' );
764 return wp_set_post_categories($post_ID, $post_categories);
770 * @deprecated Use wp_get_archives()
771 * @see wp_get_archives()
773 * @param string $type
774 * @param string $limit
775 * @param string $format
776 * @param string $before
777 * @param string $after
778 * @param bool $show_post_count
779 * @return string|null
781 function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
782 _deprecated_function( __FUNCTION__, '2.1', 'wp_get_archives()' );
783 $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
784 return wp_get_archives($args);
788 * Returns or Prints link to the author's posts.
792 * @deprecated Use get_author_posts_url()
793 * @see get_author_posts_url()
796 * @param int $author_id
797 * @param string $author_nicename Optional.
798 * @return string|null
800 function get_author_link($echo, $author_id, $author_nicename = '') {
801 _deprecated_function( __FUNCTION__, '2.1', 'get_author_posts_url()' );
803 $link = get_author_posts_url($author_id, $author_nicename);
811 * Print list of pages based on arguments.
815 * @deprecated Use wp_link_pages()
816 * @see wp_link_pages()
818 * @param string $before
819 * @param string $after
820 * @param string $next_or_number
821 * @param string $nextpagelink
822 * @param string $previouspagelink
823 * @param string $pagelink
824 * @param string $more_file
827 function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page',
828 $pagelink='%', $more_file='') {
829 _deprecated_function( __FUNCTION__, '2.1', 'wp_link_pages()' );
831 $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
832 return wp_link_pages($args);
836 * Get value based on option.
840 * @deprecated Use get_option()
843 * @param string $option
846 function get_settings($option) {
847 _deprecated_function( __FUNCTION__, '2.1', 'get_option()' );
849 return get_option($option);
853 * Print the permalink of the current post in the loop.
857 * @deprecated Use the_permalink()
858 * @see the_permalink()
860 function permalink_link() {
861 _deprecated_function( __FUNCTION__, '1.2', 'the_permalink()' );
866 * Print the permalink to the RSS feed.
870 * @deprecated Use the_permalink_rss()
871 * @see the_permalink_rss()
873 * @param string $deprecated
875 function permalink_single_rss($deprecated = '') {
876 _deprecated_function( __FUNCTION__, '2.3', 'the_permalink_rss()' );
881 * Gets the links associated with category.
883 * @see get_links() for argument information that can be used in $args
886 * @deprecated Use wp_list_bookmarks()
887 * @see wp_list_bookmarks()
889 * @param string $args a query string
890 * @return null|string
892 function wp_get_links($args = '') {
893 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' );
895 if ( strpos( $args, '=' ) === false ) {
897 $args = add_query_arg( 'category', $cat_id, $args );
909 'show_description' => true,
910 'show_images' => true,
911 'show_rating' => false,
912 'show_updated' => true,
916 $r = wp_parse_args( $args, $defaults );
918 return wp_list_bookmarks($r);
922 * Gets the links associated with category by id.
926 * @deprecated Use get_bookmarks()
927 * @see get_bookmarks()
929 * @param int $category The category to use. If no category supplied uses all
930 * @param string $before the html to output before the link
931 * @param string $after the html to output after the link
932 * @param string $between the html to output between the link/image and its description.
933 * Not used if no image or show_images == true
934 * @param bool $show_images whether to show images (if defined).
935 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
936 * 'description', or 'rating'. Or maybe owner. If you start the name with an
937 * underscore the order will be reversed. You can also specify 'rand' as the order
938 * which will return links in a random order.
939 * @param bool $show_description whether to show the description if show_images=false/not defined.
940 * @param bool $show_rating show rating stars/chars
941 * @param int $limit Limit to X entries. If not specified, all entries are shown.
942 * @param int $show_updated whether to show last updated timestamp
943 * @param bool $echo whether to echo the results, or return them instead
944 * @return null|string
946 function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name',
947 $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) {
948 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
951 if ( substr($orderby, 0, 1) == '_' ) {
953 $orderby = substr($orderby, 1);
956 if ( $category == -1 ) //get_bookmarks uses '' to signify all categories
959 $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit));
966 foreach ( (array) $results as $row ) {
967 if ( !isset($row->recently_updated) )
968 $row->recently_updated = false;
970 if ( $show_updated && $row->recently_updated )
971 $output .= get_option('links_recently_updated_prepend');
973 if ( !empty($row->link_url) )
974 $the_link = esc_url($row->link_url);
975 $rel = $row->link_rel;
977 $rel = ' rel="' . $rel . '"';
979 $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display'));
980 $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display'));
984 if (substr($row->link_updated_f, 0, 2) != '00')
985 $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';
988 $title = ' title="' . $title . '"';
990 $alt = ' alt="' . $name . '"';
992 $target = $row->link_target;
994 $target = ' target="' . $target . '"';
996 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
998 if ( $row->link_image != null && $show_images ) {
999 if ( strpos($row->link_image, 'http') !== false )
1000 $output .= "<img src=\"$row->link_image\" $alt $title />";
1001 else // If it's a relative path
1002 $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />";
1009 if ( $show_updated && $row->recently_updated )
1010 $output .= get_option('links_recently_updated_append');
1012 if ( $show_description && '' != $desc )
1013 $output .= $between . $desc;
1016 $output .= $between . get_linkrating($row);
1019 $output .= "$after\n";
1028 * Output entire list of links by category.
1030 * Output a list of all links, listed by category, using the settings in
1031 * $wpdb->linkcategories and output it as a nested HTML unordered list.
1035 * @deprecated Use wp_list_bookmarks()
1036 * @see wp_list_bookmarks()
1038 * @param string $order Sort link categories by 'name' or 'id'
1040 function get_links_list($order = 'name') {
1041 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' );
1043 $order = strtolower($order);
1045 // Handle link category sorting
1047 if ( '_' == substr($order,0,1) ) {
1048 $direction = 'DESC';
1049 $order = substr($order,1);
1052 if ( !isset($direction) )
1055 $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0));
1057 // Display each category
1059 foreach ( (array) $cats as $cat ) {
1060 // Handle each category.
1062 // Display the category name
1063 echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";
1064 // Call get_links() with all the appropriate params
1065 get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);
1067 // Close the last category
1068 echo "\n\t</ul>\n</li>\n";
1074 * Show the link to the links popup and the number of links.
1078 * @deprecated {@internal Use function instead is unknown}}
1080 * @param string $text the text of the link
1081 * @param int $width the width of the popup window
1082 * @param int $height the height of the popup window
1083 * @param string $file the page to open in the popup window
1084 * @param bool $count the number of links in the db
1086 function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
1087 _deprecated_function( __FUNCTION__, '2.1' );
1093 * @deprecated Use sanitize_bookmark_field()
1094 * @see sanitize_bookmark_field()
1096 * @param object $link
1099 function get_linkrating($link) {
1100 _deprecated_function( __FUNCTION__, '2.1', 'sanitize_bookmark_field()' );
1101 return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display');
1105 * Gets the name of category by id.
1109 * @deprecated Use get_category()
1110 * @see get_category()
1112 * @param int $id The category to get. If no category supplied uses 0
1115 function get_linkcatname($id = 0) {
1116 _deprecated_function( __FUNCTION__, '2.1', 'get_category()' );
1123 $cats = wp_get_link_cats($id);
1125 if ( empty($cats) || ! is_array($cats) )
1128 $cat_id = (int) $cats[0]; // Take the first cat.
1130 $cat = get_category($cat_id);
1135 * Print RSS comment feed link.
1139 * @deprecated Use post_comments_feed_link()
1140 * @see post_comments_feed_link()
1142 * @param string $link_text
1144 function comments_rss_link($link_text = 'Comments RSS') {
1145 _deprecated_function( __FUNCTION__, '2.5', 'post_comments_feed_link()' );
1146 post_comments_feed_link($link_text);
1150 * Print/Return link to category RSS2 feed.
1154 * @deprecated Use get_category_feed_link()
1155 * @see get_category_feed_link()
1158 * @param int $cat_ID
1161 function get_category_rss_link($echo = false, $cat_ID = 1) {
1162 _deprecated_function( __FUNCTION__, '2.5', 'get_category_feed_link()' );
1164 $link = get_category_feed_link($cat_ID, 'rss2');
1172 * Print/Return link to author RSS feed.
1176 * @deprecated Use get_author_feed_link()
1177 * @see get_author_feed_link()
1180 * @param int $author_id
1183 function get_author_rss_link($echo = false, $author_id = 1) {
1184 _deprecated_function( __FUNCTION__, '2.5', 'get_author_feed_link()' );
1186 $link = get_author_feed_link($author_id);
1193 * Return link to the post RSS feed.
1197 * @deprecated Use get_post_comments_feed_link()
1198 * @see get_post_comments_feed_link()
1202 function comments_rss() {
1203 _deprecated_function( __FUNCTION__, '2.2', 'get_post_comments_feed_link()' );
1204 return esc_url( get_post_comments_feed_link() );
1208 * An alias of wp_create_user().
1212 * @deprecated Use wp_create_user()
1213 * @see wp_create_user()
1215 * @param string $username The user's username.
1216 * @param string $password The user's password.
1217 * @param string $email The user's email.
1218 * @return int The new user's ID.
1220 function create_user($username, $password, $email) {
1221 _deprecated_function( __FUNCTION__, '2.0', 'wp_create_user()' );
1222 return wp_create_user($username, $password, $email);
1230 function gzip_compression() {
1231 _deprecated_function( __FUNCTION__, '2.5' );
1236 * Retrieve an array of comment data about comment $comment_ID.
1240 * @deprecated Use get_comment()
1241 * @see get_comment()
1243 * @param int $comment_ID The ID of the comment
1244 * @param int $no_cache Whether to use the cache (cast to bool)
1245 * @param bool $include_unapproved Whether to include unapproved comments
1246 * @return array The comment data
1248 function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
1249 _deprecated_function( __FUNCTION__, '2.7', 'get_comment()' );
1250 return get_comment($comment_ID, ARRAY_A);
1254 * Retrieve the category name by the category ID.
1258 * @deprecated Use get_cat_name()
1259 * @see get_cat_name()
1261 * @param int $cat_ID Category ID
1262 * @return string category name
1264 function get_catname( $cat_ID ) {
1265 _deprecated_function( __FUNCTION__, '2.8', 'get_cat_name()' );
1266 return get_cat_name( $cat_ID );
1270 * Retrieve category children list separated before and after the term IDs.
1274 * @deprecated Use get_term_children()
1275 * @see get_term_children()
1277 * @param int $id Category ID to retrieve children.
1278 * @param string $before Optional. Prepend before category term ID.
1279 * @param string $after Optional, default is empty string. Append after category term ID.
1280 * @param array $visited Optional. Category Term IDs that have already been added.
1283 function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
1284 _deprecated_function( __FUNCTION__, '2.8', 'get_term_children()' );
1289 /** TODO: consult hierarchy */
1290 $cat_ids = get_all_category_ids();
1291 foreach ( (array) $cat_ids as $cat_id ) {
1292 if ( $cat_id == $id )
1295 $category = get_category( $cat_id );
1296 if ( is_wp_error( $category ) )
1298 if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
1299 $visited[] = $category->term_id;
1300 $chain .= $before.$category->term_id.$after;
1301 $chain .= get_category_children( $category->term_id, $before, $after );
1308 * Retrieves all category IDs.
1311 * @deprecated 4.0.0 Use get_terms() instead.
1313 * @link https://codex.wordpress.org/Function_Reference/get_all_category_ids
1315 * @return object List of all of the category IDs.
1317 function get_all_category_ids() {
1318 _deprecated_function( __FUNCTION__, '4.0', 'get_terms()' );
1320 if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) {
1321 $cat_ids = get_terms( 'category', array('fields' => 'ids', 'get' => 'all') );
1322 wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
1329 * Retrieve the description of the author of the current post.
1333 * @deprecated Use get_the_author_meta('description')
1334 * @see get_the_author_meta()
1336 * @return string The author's description.
1338 function get_the_author_description() {
1339 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'description\')' );
1340 return get_the_author_meta('description');
1344 * Display the description of the author of the current post.
1348 * @deprecated Use the_author_meta('description')
1349 * @see the_author_meta()
1351 function the_author_description() {
1352 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')' );
1353 the_author_meta('description');
1357 * Retrieve the login name of the author of the current post.
1361 * @deprecated Use get_the_author_meta('login')
1362 * @see get_the_author_meta()
1364 * @return string The author's login name (username).
1366 function get_the_author_login() {
1367 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'login\')' );
1368 return get_the_author_meta('login');
1372 * Display the login name of the author of the current post.
1376 * @deprecated Use the_author_meta('login')
1377 * @see the_author_meta()
1379 function the_author_login() {
1380 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')' );
1381 the_author_meta('login');
1385 * Retrieve the first name of the author of the current post.
1389 * @deprecated Use get_the_author_meta('first_name')
1390 * @see get_the_author_meta()
1392 * @return string The author's first name.
1394 function get_the_author_firstname() {
1395 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')' );
1396 return get_the_author_meta('first_name');
1400 * Display the first name of the author of the current post.
1404 * @deprecated Use the_author_meta('first_name')
1405 * @see the_author_meta()
1407 function the_author_firstname() {
1408 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'first_name\')' );
1409 the_author_meta('first_name');
1413 * Retrieve the last name of the author of the current post.
1417 * @deprecated Use get_the_author_meta('last_name')
1418 * @see get_the_author_meta()
1420 * @return string The author's last name.
1422 function get_the_author_lastname() {
1423 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')' );
1424 return get_the_author_meta('last_name');
1428 * Display the last name of the author of the current post.
1432 * @deprecated Use the_author_meta('last_name')
1433 * @see the_author_meta()
1435 function the_author_lastname() {
1436 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'last_name\')' );
1437 the_author_meta('last_name');
1441 * Retrieve the nickname of the author of the current post.
1445 * @deprecated Use get_the_author_meta('nickname')
1446 * @see get_the_author_meta()
1448 * @return string The author's nickname.
1450 function get_the_author_nickname() {
1451 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')' );
1452 return get_the_author_meta('nickname');
1456 * Display the nickname of the author of the current post.
1460 * @deprecated Use the_author_meta('nickname')
1461 * @see the_author_meta()
1463 function the_author_nickname() {
1464 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' );
1465 the_author_meta('nickname');
1469 * Retrieve the email of the author of the current post.
1473 * @deprecated Use get_the_author_meta('email')
1474 * @see get_the_author_meta()
1476 * @return string The author's username.
1478 function get_the_author_email() {
1479 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'email\')' );
1480 return get_the_author_meta('email');
1484 * Display the email of the author of the current post.
1488 * @deprecated Use the_author_meta('email')
1489 * @see the_author_meta()
1491 function the_author_email() {
1492 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')' );
1493 the_author_meta('email');
1497 * Retrieve the ICQ number of the author of the current post.
1501 * @deprecated Use get_the_author_meta('icq')
1502 * @see get_the_author_meta()
1504 * @return string The author's ICQ number.
1506 function get_the_author_icq() {
1507 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')' );
1508 return get_the_author_meta('icq');
1512 * Display the ICQ number of the author of the current post.
1516 * @deprecated Use the_author_meta('icq')
1517 * @see the_author_meta()
1519 function the_author_icq() {
1520 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')' );
1521 the_author_meta('icq');
1525 * Retrieve the Yahoo! IM name of the author of the current post.
1529 * @deprecated Use get_the_author_meta('yim')
1530 * @see get_the_author_meta()
1532 * @return string The author's Yahoo! IM name.
1534 function get_the_author_yim() {
1535 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')' );
1536 return get_the_author_meta('yim');
1540 * Display the Yahoo! IM name of the author of the current post.
1544 * @deprecated Use the_author_meta('yim')
1545 * @see the_author_meta()
1547 function the_author_yim() {
1548 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')' );
1549 the_author_meta('yim');
1553 * Retrieve the MSN address of the author of the current post.
1557 * @deprecated Use get_the_author_meta('msn')
1558 * @see get_the_author_meta()
1560 * @return string The author's MSN address.
1562 function get_the_author_msn() {
1563 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')' );
1564 return get_the_author_meta('msn');
1568 * Display the MSN address of the author of the current post.
1572 * @deprecated Use the_author_meta('msn')
1573 * @see the_author_meta()
1575 function the_author_msn() {
1576 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')' );
1577 the_author_meta('msn');
1581 * Retrieve the AIM address of the author of the current post.
1585 * @deprecated Use get_the_author_meta('aim')
1586 * @see get_the_author_meta()
1588 * @return string The author's AIM address.
1590 function get_the_author_aim() {
1591 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'aim\')' );
1592 return get_the_author_meta('aim');
1596 * Display the AIM address of the author of the current post.
1599 * @see the_author_meta()
1601 * @deprecated Use the_author_meta('aim')
1603 function the_author_aim() {
1604 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')' );
1605 the_author_meta('aim');
1609 * Retrieve the specified author's preferred display name.
1613 * @deprecated Use get_the_author_meta('display_name')
1614 * @see get_the_author_meta()
1616 * @param int $auth_id The ID of the author.
1617 * @return string The author's display name.
1619 function get_author_name( $auth_id = false ) {
1620 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')' );
1621 return get_the_author_meta('display_name', $auth_id);
1625 * Retrieve the URL to the home page of the author of the current post.
1629 * @deprecated Use get_the_author_meta('url')
1630 * @see get_the_author_meta()
1632 * @return string The URL to the author's page.
1634 function get_the_author_url() {
1635 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'url\')' );
1636 return get_the_author_meta('url');
1640 * Display the URL to the home page of the author of the current post.
1644 * @deprecated Use the_author_meta('url')
1645 * @see the_author_meta()
1647 function the_author_url() {
1648 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')' );
1649 the_author_meta('url');
1653 * Retrieve the ID of the author of the current post.
1657 * @deprecated Use get_the_author_meta('ID')
1658 * @see get_the_author_meta()
1660 * @return string|int The author's ID.
1662 function get_the_author_ID() {
1663 _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')' );
1664 return get_the_author_meta('ID');
1668 * Display the ID of the author of the current post.
1672 * @deprecated Use the_author_meta('ID')
1673 * @see the_author_meta()
1675 function the_author_ID() {
1676 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')' );
1677 the_author_meta('ID');
1681 * Display the post content for the feed.
1683 * For encoding the html or the $encode_html parameter, there are three possible
1684 * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
1685 * encode special characters and automatically display all of the content. The
1686 * value of '2' will strip all HTML tags from the content.
1688 * Also note that you cannot set the amount of words and not set the html
1689 * encoding. If that is the case, then the html encoding will default to 2,
1690 * which will strip all HTML tags.
1692 * To restrict the amount of words of the content, you can use the cut
1693 * parameter. If the content is less than the amount, then there won't be any
1694 * dots added to the end. If there is content left over, then dots will be added
1695 * and the rest of the content will be removed.
1700 * @deprecated Use the_content_feed()
1701 * @see the_content_feed()
1703 * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
1704 * @param int $stripteaser Optional. Default is 0.
1705 * @param string $more_file Optional.
1706 * @param int $cut Optional. Amount of words to keep for the content.
1707 * @param int $encode_html Optional. How to encode the content.
1709 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
1710 _deprecated_function( __FUNCTION__, '2.9', 'the_content_feed' );
1711 $content = get_the_content($more_link_text, $stripteaser);
1712 $content = apply_filters('the_content_rss', $content);
1713 if ( $cut && !$encode_html )
1715 if ( 1== $encode_html ) {
1716 $content = esc_html($content);
1718 } elseif ( 0 == $encode_html ) {
1719 $content = make_url_footnote($content);
1720 } elseif ( 2 == $encode_html ) {
1721 $content = strip_tags($content);
1724 $blah = explode(' ', $content);
1725 if ( count($blah) > $cut ) {
1733 /** @todo Check performance, might be faster to use array slice instead. */
1734 for ( $i=0; $i<$k; $i++ )
1735 $excerpt .= $blah[$i].' ';
1736 $excerpt .= ($use_dotdotdot) ? '...' : '';
1737 $content = $excerpt;
1739 $content = str_replace(']]>', ']]>', $content);
1744 * Strip HTML and put links at the bottom of stripped content.
1746 * Searches for all of the links, strips them out of the content, and places
1747 * them at the bottom of the content with numbers.
1752 * @param string $content Content to get links
1753 * @return string HTML stripped out of content with links at the bottom.
1755 function make_url_footnote( $content ) {
1756 _deprecated_function( __FUNCTION__, '2.9', '' );
1757 preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches );
1758 $links_summary = "\n";
1759 for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) {
1760 $link_match = $matches[0][$i];
1761 $link_number = '['.($i+1).']';
1762 $link_url = $matches[2][$i];
1763 $link_text = $matches[4][$i];
1764 $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content );
1765 $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url;
1766 $links_summary .= "\n" . $link_number . ' ' . $link_url;
1768 $content = strip_tags( $content );
1769 $content .= $links_summary;
1774 * Retrieve translated string with vertical bar context
1776 * Quite a few times, there will be collisions with similar translatable text
1777 * found in more than two places but with different translated context.
1779 * In order to use the separate contexts, the _c() function is used and the
1780 * translatable string uses a pipe ('|') which has the context the string is in.
1782 * When the translated string is returned, it is everything before the pipe, not
1783 * including the pipe character. If there is no pipe in the translated text then
1784 * everything is returned.
1788 * @deprecated Use _x()
1791 * @param string $text Text to translate
1792 * @param string $domain Optional. Domain to retrieve the translated text
1793 * @return string Translated context string without pipe
1795 function _c( $text, $domain = 'default' ) {
1796 _deprecated_function( __FUNCTION__, '2.9', '_x()' );
1797 return before_last_bar( translate( $text, $domain ) );
1801 * Translates $text like translate(), but assumes that the text
1802 * contains a context after its last vertical bar.
1806 * @deprecated Use _x()
1809 * @param string $text Text to translate
1810 * @param string $domain Domain to retrieve the translated text
1811 * @return string Translated text
1813 function translate_with_context( $text, $domain = 'default' ) {
1814 _deprecated_function( __FUNCTION__, '2.9', '_x()' );
1815 return before_last_bar( translate( $text, $domain ) );
1819 * A version of _n(), which supports contexts.
1820 * Strips everything from the translation after the last bar.
1824 * @deprecated Use _nx()
1826 * @see _n() For parameters.
1827 * @see _c() For parameters. _c() is deprecated.
1830 function _nc( $single, $plural, $number, $domain = 'default' ) {
1831 _deprecated_function( __FUNCTION__, '2.9', '_nx()' );
1832 return before_last_bar( _n( $single, $plural, $number, $domain ) );
1836 * Retrieve the plural or single form based on the amount.
1840 * @deprecated Use _n()
1843 function __ngettext() {
1844 _deprecated_function( __FUNCTION__, '2.8', '_n()' );
1845 $args = func_get_args();
1846 return call_user_func_array('_n', $args);
1850 * Register plural strings in POT file, but don't translate them.
1854 * @deprecated Use _n_noop()
1857 function __ngettext_noop() {
1858 _deprecated_function( __FUNCTION__, '2.8', '_n_noop()' );
1859 $args = func_get_args();
1860 return call_user_func_array('_n_noop', $args);
1865 * Retrieve all autoload options, or all options if no autoloaded ones exist.
1869 * @deprecated Use wp_load_alloptions())
1870 * @see wp_load_alloptions()
1872 * @return array List of all options.
1874 function get_alloptions() {
1875 _deprecated_function( __FUNCTION__, '3.0', 'wp_load_alloptions()' );
1876 return wp_load_alloptions();
1880 * Retrieve HTML content of attachment image with link.
1884 * @deprecated Use wp_get_attachment_link()
1885 * @see wp_get_attachment_link()
1887 * @param int $id Optional. Post ID.
1888 * @param bool $fullsize Optional, default is false. Whether to use full size image.
1889 * @param array $max_dims Optional. Max image dimensions.
1890 * @param bool $permalink Optional, default is false. Whether to include permalink to image.
1893 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
1894 _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' );
1896 $_post = get_post($id);
1898 if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
1899 return __('Missing Attachment');
1902 $url = get_attachment_link($_post->ID);
1904 $post_title = esc_attr($_post->post_title);
1906 $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
1907 return "<a href='$url' title='$post_title'>$innerHTML</a>";
1911 * Retrieve icon URL and Path.
1915 * @deprecated Use wp_get_attachment_image_src()
1916 * @see wp_get_attachment_image_src()
1918 * @param int $id Optional. Post ID.
1919 * @param bool $fullsize Optional, default to false. Whether to have full image.
1920 * @return array Icon URL and full path to file, respectively.
1922 function get_attachment_icon_src( $id = 0, $fullsize = false ) {
1923 _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' );
1925 if ( !$post = get_post($id) )
1928 $file = get_attached_file( $post->ID );
1930 if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
1931 // We have a thumbnail desired, specified and existing
1933 $src_file = basename($src);
1934 } elseif ( wp_attachment_is_image( $post->ID ) ) {
1935 // We have an image without a thumbnail
1937 $src = wp_get_attachment_url( $post->ID );
1938 $src_file = & $file;
1939 } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
1940 // No thumb, no image. We'll look for a mime-related icon instead.
1942 $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
1943 $src_file = $icon_dir . '/' . basename($src);
1946 if ( !isset($src) || !$src )
1949 return array($src, $src_file);
1953 * Retrieve HTML content of icon attachment image element.
1957 * @deprecated Use wp_get_attachment_image()
1958 * @see wp_get_attachment_image()
1960 * @param int $id Optional. Post ID.
1961 * @param bool $fullsize Optional, default to false. Whether to have full size image.
1962 * @param array $max_dims Optional. Dimensions of image.
1963 * @return false|string HTML content.
1965 function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
1966 _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
1968 if ( !$post = get_post($id) )
1971 if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
1974 list($src, $src_file) = $src;
1976 // Do we need to constrain the image?
1977 if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
1979 $imagesize = getimagesize($src_file);
1981 if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
1982 $actual_aspect = $imagesize[0] / $imagesize[1];
1983 $desired_aspect = $max_dims[0] / $max_dims[1];
1985 if ( $actual_aspect >= $desired_aspect ) {
1986 $height = $actual_aspect * $max_dims[0];
1987 $constraint = "width='{$max_dims[0]}' ";
1988 $post->iconsize = array($max_dims[0], $height);
1990 $width = $max_dims[1] / $actual_aspect;
1991 $constraint = "height='{$max_dims[1]}' ";
1992 $post->iconsize = array($width, $max_dims[1]);
1995 $post->iconsize = array($imagesize[0], $imagesize[1]);
2002 $post_title = esc_attr($post->post_title);
2004 $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
2006 return apply_filters( 'attachment_icon', $icon, $post->ID );
2010 * Retrieve HTML content of image element.
2014 * @deprecated Use wp_get_attachment_image()
2015 * @see wp_get_attachment_image()
2017 * @param int $id Optional. Post ID.
2018 * @param bool $fullsize Optional, default to false. Whether to have full size image.
2019 * @param array $max_dims Optional. Dimensions of image.
2020 * @return false|string
2022 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
2023 _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
2025 if ( !$post = get_post($id) )
2028 if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
2031 $innerHTML = esc_attr($post->post_title);
2033 return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
2037 * Retrieve bookmark data based on ID.
2041 * @deprecated Use get_bookmark()
2042 * @see get_bookmark()
2044 * @param int $bookmark_id ID of link
2045 * @param string $output OBJECT, ARRAY_N, or ARRAY_A
2046 * @return object|array
2048 function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {
2049 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' );
2050 return get_bookmark($bookmark_id, $output, $filter);
2054 * Performs esc_url() for database or redirect usage.
2058 * @deprecated Use esc_url_raw()
2059 * @see esc_url_raw()
2061 * @param string $url The URL to be cleaned.
2062 * @param array $protocols An array of acceptable protocols.
2063 * @return string The cleaned URL.
2065 function sanitize_url( $url, $protocols = null ) {
2066 _deprecated_function( __FUNCTION__, '2.8', 'esc_url_raw()' );
2067 return esc_url_raw( $url, $protocols );
2071 * Checks and cleans a URL.
2073 * A number of characters are removed from the URL. If the URL is for displaying
2074 * (the default behaviour) ampersands are also replaced. The 'clean_url' filter
2075 * is applied to the returned cleaned URL.
2079 * @deprecated Use esc_url()
2080 * @see Alias for esc_url()
2082 * @param string $url The URL to be cleaned.
2083 * @param array $protocols Optional. An array of acceptable protocols.
2084 * @param string $context Optional. How the URL will be used. Default is 'display'.
2085 * @return string The cleaned $url after the 'clean_url' filter is applied.
2087 function clean_url( $url, $protocols = null, $context = 'display' ) {
2088 if ( $context == 'db' )
2089 _deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' );
2091 _deprecated_function( __FUNCTION__, '3.0', 'esc_url()' );
2092 return esc_url( $url, $protocols, $context );
2096 * Escape single quotes, specialchar double quotes, and fix line endings.
2098 * The filter 'js_escape' is also applied by esc_js()
2102 * @deprecated Use esc_js()
2105 * @param string $text The text to be escaped.
2106 * @return string Escaped text.
2108 function js_escape( $text ) {
2109 _deprecated_function( __FUNCTION__, '2.8', 'esc_js()' );
2110 return esc_js( $text );
2114 * Escaping for HTML blocks.
2117 * @deprecated Use esc_html()
2120 function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
2121 _deprecated_function( __FUNCTION__, '2.8', 'esc_html()' );
2122 if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args
2123 $args = func_get_args();
2124 return call_user_func_array( '_wp_specialchars', $args );
2126 return esc_html( $string );
2131 * Escaping for HTML attributes.
2135 * @deprecated Use esc_attr()
2138 * @param string $text
2141 function attribute_escape( $text ) {
2142 _deprecated_function( __FUNCTION__, '2.8', 'esc_attr()' );
2143 return esc_attr( $text );
2147 * Register widget for sidebar with backwards compatibility.
2149 * Allows $name to be an array that accepts either three elements to grab the
2150 * first element and the third for the name or just uses the first element of
2151 * the array for the name.
2153 * Passes to {@link wp_register_sidebar_widget()} after argument list and
2154 * backwards compatibility is complete.
2158 * @deprecated Use wp_register_sidebar_widget()
2159 * @see wp_register_sidebar_widget()
2161 * @param string|int $name Widget ID.
2162 * @param callback $output_callback Run when widget is called.
2163 * @param string $classname Classname widget option.
2164 * @param mixed $params ,... Widget parameters.
2166 function register_sidebar_widget($name, $output_callback, $classname = '') {
2167 _deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' );
2169 if ( is_array($name) ) {
2170 if ( count($name) == 3 )
2171 $name = sprintf($name[0], $name[2]);
2176 $id = sanitize_title($name);
2178 if ( !empty($classname) && is_string($classname) )
2179 $options['classname'] = $classname;
2180 $params = array_slice(func_get_args(), 2);
2181 $args = array($id, $name, $output_callback, $options);
2182 if ( !empty($params) )
2183 $args = array_merge($args, $params);
2185 call_user_func_array('wp_register_sidebar_widget', $args);
2189 * Alias of {@link wp_unregister_sidebar_widget()}.
2193 * @deprecated Use wp_unregister_sidebar_widget()
2194 * @see wp_unregister_sidebar_widget()
2196 * @param int|string $id Widget ID.
2198 function unregister_sidebar_widget($id) {
2199 _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_sidebar_widget()' );
2200 return wp_unregister_sidebar_widget($id);
2204 * Registers widget control callback for customizing options.
2206 * Allows $name to be an array that accepts either three elements to grab the
2207 * first element and the third for the name or just uses the first element of
2208 * the array for the name.
2210 * Passes to {@link wp_register_widget_control()} after the argument list has
2215 * @deprecated Use wp_register_widget_control()
2216 * @see wp_register_widget_control()
2218 * @param int|string $name Sidebar ID.
2219 * @param callback $control_callback Widget control callback to display and process form.
2220 * @param int $width Widget width.
2221 * @param int $height Widget height.
2223 function register_widget_control($name, $control_callback, $width = '', $height = '') {
2224 _deprecated_function( __FUNCTION__, '2.8', 'wp_register_widget_control()' );
2226 if ( is_array($name) ) {
2227 if ( count($name) == 3 )
2228 $name = sprintf($name[0], $name[2]);
2233 $id = sanitize_title($name);
2235 if ( !empty($width) )
2236 $options['width'] = $width;
2237 if ( !empty($height) )
2238 $options['height'] = $height;
2239 $params = array_slice(func_get_args(), 4);
2240 $args = array($id, $name, $control_callback, $options);
2241 if ( !empty($params) )
2242 $args = array_merge($args, $params);
2244 call_user_func_array('wp_register_widget_control', $args);
2248 * Alias of {@link wp_unregister_widget_control()}.
2252 * @deprecated Use wp_unregister_widget_control()
2253 * @see wp_unregister_widget_control()
2255 * @param int|string $id Widget ID.
2257 function unregister_widget_control($id) {
2258 _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_widget_control()' );
2259 return wp_unregister_widget_control($id);
2263 * Remove user meta data.
2267 * @deprecated Use delete_user_meta()
2268 * @see delete_user_meta()
2270 * @param int $user_id User ID.
2271 * @param string $meta_key Metadata key.
2272 * @param mixed $meta_value Metadata value.
2273 * @return bool True deletion completed and false if user_id is not a number.
2275 function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
2276 _deprecated_function( __FUNCTION__, '3.0', 'delete_user_meta()' );
2278 if ( !is_numeric( $user_id ) )
2280 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2282 if ( is_array($meta_value) || is_object($meta_value) )
2283 $meta_value = serialize($meta_value);
2284 $meta_value = trim( $meta_value );
2286 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2288 if ( $cur && $cur->umeta_id )
2289 do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2291 if ( ! empty($meta_value) )
2292 $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) );
2294 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2296 clean_user_cache( $user_id );
2297 wp_cache_delete( $user_id, 'user_meta' );
2299 if ( $cur && $cur->umeta_id )
2300 do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2306 * Retrieve user metadata.
2308 * If $user_id is not a number, then the function will fail over with a 'false'
2309 * boolean return value. Other returned values depend on whether there is only
2310 * one item to be returned, which be that single item type. If there is more
2311 * than one metadata value, then it will be list of metadata values.
2315 * @deprecated Use get_user_meta()
2316 * @see get_user_meta()
2318 * @param int $user_id User ID
2319 * @param string $meta_key Optional. Metadata key.
2322 function get_usermeta( $user_id, $meta_key = '' ) {
2323 _deprecated_function( __FUNCTION__, '3.0', 'get_user_meta()' );
2325 $user_id = (int) $user_id;
2330 if ( !empty($meta_key) ) {
2331 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2332 $user = wp_cache_get($user_id, 'users');
2333 // Check the cached user object
2334 if ( false !== $user && isset($user->$meta_key) )
2335 $metas = array($user->$meta_key);
2337 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2339 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) );
2342 if ( empty($metas) ) {
2343 if ( empty($meta_key) )
2349 $metas = array_map('maybe_unserialize', $metas);
2351 if ( count($metas) == 1 )
2358 * Update metadata of user.
2360 * There is no need to serialize values, they will be serialized if it is
2361 * needed. The metadata key can only be a string with underscores. All else will
2364 * Will remove the metadata, if the meta value is empty.
2368 * @deprecated Use update_user_meta()
2369 * @see update_user_meta()
2371 * @param int $user_id User ID
2372 * @param string $meta_key Metadata key.
2373 * @param mixed $meta_value Metadata value.
2374 * @return bool True on successful update, false on failure.
2376 function update_usermeta( $user_id, $meta_key, $meta_value ) {
2377 _deprecated_function( __FUNCTION__, '3.0', 'update_user_meta()' );
2379 if ( !is_numeric( $user_id ) )
2381 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2383 /** @todo Might need fix because usermeta data is assumed to be already escaped */
2384 if ( is_string($meta_value) )
2385 $meta_value = stripslashes($meta_value);
2386 $meta_value = maybe_serialize($meta_value);
2388 if (empty($meta_value)) {
2389 return delete_usermeta($user_id, $meta_key);
2392 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
2395 do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2398 $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') );
2399 elseif ( $cur->meta_value != $meta_value )
2400 $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') );
2404 clean_user_cache( $user_id );
2405 wp_cache_delete( $user_id, 'user_meta' );
2408 do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value );
2410 do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
2416 * Get users for the blog.
2418 * For setups that use the multi-blog feature. Can be used outside of the
2419 * multi-blog feature.
2424 * @global wpdb $wpdb WordPress database abstraction object.
2425 * @uses $blog_id The Blog id of the blog for those that use more than one blog
2427 * @param int $id Blog ID.
2428 * @return array List of users that are part of that Blog ID
2430 function get_users_of_blog( $id = '' ) {
2431 _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
2433 global $wpdb, $blog_id;
2435 $id = (int) $blog_id;
2436 $blog_prefix = $wpdb->get_blog_prefix($id);
2437 $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" );
2442 * Enable/disable automatic general feed link outputting.
2446 * @deprecated Use add_theme_support( 'automatic-feed-links' )
2448 * @param boolean $add Optional, default is true. Add or remove links. Defaults to true.
2450 function automatic_feed_links( $add = true ) {
2451 _deprecated_function( __FUNCTION__, '3.0', "add_theme_support( 'automatic-feed-links' )" );
2454 add_theme_support( 'automatic-feed-links' );
2456 remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+
2460 * Retrieve user data based on field.
2464 * @deprecated Use get_the_author_meta()
2465 * @see get_the_author_meta()
2467 function get_profile( $field, $user = false ) {
2468 _deprecated_function( __FUNCTION__, '3.0', 'get_the_author_meta()' );
2470 $user = get_user_by( 'login', $user );
2473 return get_the_author_meta( $field, $user );
2477 * Number of posts user has written.
2481 * @deprecated Use count_user_posts()
2482 * @see count_user_posts()
2484 function get_usernumposts( $userid ) {
2485 _deprecated_function( __FUNCTION__, '3.0', 'count_user_posts()' );
2486 return count_user_posts( $userid );
2490 * Callback used to change %uXXXX to &#YYY; syntax
2496 * @param array $matches Single Match
2497 * @return string An HTML entity
2499 function funky_javascript_callback($matches) {
2500 return "&#".base_convert($matches[1],16,10).";";
2504 * Fixes JavaScript bugs in browsers.
2506 * Converts unicode characters to HTML numbered entities.
2513 * @param string $text Text to be made safe.
2514 * @return string Fixed text.
2516 function funky_javascript_fix($text) {
2517 _deprecated_function( __FUNCTION__, '3.0' );
2518 // Fixes for browsers' JavaScript bugs.
2519 global $is_macIE, $is_winIE;
2521 if ( $is_winIE || $is_macIE )
2522 $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/",
2523 "funky_javascript_callback",
2530 * Checks that the taxonomy name exists.
2534 * @deprecated Use taxonomy_exists()
2535 * @see taxonomy_exists()
2537 * @param string $taxonomy Name of taxonomy object
2538 * @return bool Whether the taxonomy exists.
2540 function is_taxonomy( $taxonomy ) {
2541 _deprecated_function( __FUNCTION__, '3.0', 'taxonomy_exists()' );
2542 return taxonomy_exists( $taxonomy );
2546 * Check if Term exists.
2550 * @deprecated Use term_exists()
2551 * @see term_exists()
2553 * @param int|string $term The term to check
2554 * @param string $taxonomy The taxonomy name to use
2555 * @param int $parent ID of parent term under which to confine the exists search.
2556 * @return mixed Get the term id or Term Object, if exists.
2558 function is_term( $term, $taxonomy = '', $parent = 0 ) {
2559 _deprecated_function( __FUNCTION__, '3.0', 'term_exists()' );
2560 return term_exists( $term, $taxonomy, $parent );
2564 * Is the current admin page generated by a plugin?
2568 * @deprecated Use global $plugin_page and/or get_plugin_page_hookname() hooks.
2570 * @global $plugin_page
2574 function is_plugin_page() {
2575 _deprecated_function( __FUNCTION__, '3.1' );
2577 global $plugin_page;
2579 if ( isset($plugin_page) )
2586 * Update the categories cache.
2588 * This function does not appear to be used anymore or does not appear to be
2589 * needed. It might be a legacy function left over from when there was a need
2590 * for updating the category cache.
2595 * @return bool Always return True
2597 function update_category_cache() {
2598 _deprecated_function( __FUNCTION__, '3.1' );
2604 * Check for PHP timezone support
2611 function wp_timezone_supported() {
2612 _deprecated_function( __FUNCTION__, '3.2' );
2618 * Display editor: TinyMCE, HTML, or both.
2622 * @deprecated Use wp_editor()
2625 * @param string $content Textarea content.
2626 * @param string $id Optional, default is 'content'. HTML ID attribute value.
2627 * @param string $prev_id Optional, not used
2628 * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
2629 * @param int $tab_index Optional, not used
2631 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
2632 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
2634 wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
2638 * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
2643 * @param array $ids User ID numbers list.
2644 * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
2646 function get_user_metavalues($ids) {
2647 _deprecated_function( __FUNCTION__, '3.3' );
2651 $ids = array_map('intval', $ids);
2652 foreach ( $ids as $id )
2653 $objects[$id] = array();
2655 $metas = update_meta_cache('user', $ids);
2657 foreach ( $metas as $id => $meta ) {
2658 foreach ( $meta as $key => $metavalues ) {
2659 foreach ( $metavalues as $value ) {
2660 $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
2669 * Sanitize every user field.
2671 * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
2676 * @param object|array $user The User Object or Array
2677 * @param string $context Optional, default is 'display'. How to sanitize user fields.
2678 * @return object|array The now sanitized User Object or Array (will be the same type as $user)
2680 function sanitize_user_object($user, $context = 'display') {
2681 _deprecated_function( __FUNCTION__, '3.3' );
2683 if ( is_object($user) ) {
2684 if ( !isset($user->ID) )
2686 if ( ! ( $user instanceof WP_User ) ) {
2687 $vars = get_object_vars($user);
2688 foreach ( array_keys($vars) as $field ) {
2689 if ( is_string($user->$field) || is_numeric($user->$field) )
2690 $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
2693 $user->filter = $context;
2695 if ( !isset($user['ID']) )
2697 foreach ( array_keys($user) as $field )
2698 $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
2699 $user['filter'] = $context;
2706 * Get boundary post relational link.
2708 * Can either be start or end post relational link.
2713 * @param string $title Optional. Link title format.
2714 * @param bool $in_same_cat Optional. Whether link should be in a same category.
2715 * @param string $excluded_categories Optional. Excluded categories IDs.
2716 * @param bool $start Optional, default is true. Whether to display link to first or last post.
2719 function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
2720 _deprecated_function( __FUNCTION__, '3.3' );
2722 $posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
2723 // If there is no post stop.
2724 if ( empty($posts) )
2727 // Even though we limited get_posts to return only 1 item it still returns an array of objects.
2730 if ( empty($post->post_title) )
2731 $post->post_title = $start ? __('First Post') : __('Last Post');
2733 $date = mysql2date(get_option('date_format'), $post->post_date);
2735 $title = str_replace('%title', $post->post_title, $title);
2736 $title = str_replace('%date', $date, $title);
2737 $title = apply_filters('the_title', $title, $post->ID);
2739 $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
2740 $link .= esc_attr($title);
2741 $link .= "' href='" . get_permalink($post) . "' />\n";
2743 $boundary = $start ? 'start' : 'end';
2744 return apply_filters( "{$boundary}_post_rel_link", $link );
2748 * Display relational link for the first post.
2753 * @param string $title Optional. Link title format.
2754 * @param bool $in_same_cat Optional. Whether link should be in a same category.
2755 * @param string $excluded_categories Optional. Excluded categories IDs.
2757 function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
2758 _deprecated_function( __FUNCTION__, '3.3' );
2760 echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);
2764 * Get site index relational link.
2771 function get_index_rel_link() {
2772 _deprecated_function( __FUNCTION__, '3.3' );
2774 $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n";
2775 return apply_filters( "index_rel_link", $link );
2779 * Display relational link for the site index.
2784 function index_rel_link() {
2785 _deprecated_function( __FUNCTION__, '3.3' );
2787 echo get_index_rel_link();
2791 * Get parent post relational link.
2796 * @param string $title Optional. Link title format.
2799 function get_parent_post_rel_link($title = '%title') {
2800 _deprecated_function( __FUNCTION__, '3.3' );
2802 if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
2803 $post = get_post($GLOBALS['post']->post_parent);
2808 $date = mysql2date(get_option('date_format'), $post->post_date);
2810 $title = str_replace('%title', $post->post_title, $title);
2811 $title = str_replace('%date', $date, $title);
2812 $title = apply_filters('the_title', $title, $post->ID);
2814 $link = "<link rel='up' title='";
2815 $link .= esc_attr( $title );
2816 $link .= "' href='" . get_permalink($post) . "' />\n";
2818 return apply_filters( "parent_post_rel_link", $link );
2822 * Display relational link for parent item
2827 function parent_post_rel_link($title = '%title') {
2828 _deprecated_function( __FUNCTION__, '3.3' );
2830 echo get_parent_post_rel_link($title);
2834 * Add the "Dashboard"/"Visit Site" menu.
2839 function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
2840 _deprecated_function( __FUNCTION__, '3.3' );
2842 $user_id = get_current_user_id();
2844 if ( 0 != $user_id ) {
2846 $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) );
2847 elseif ( is_multisite() )
2848 $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );
2850 $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
2855 * Checks if the current user belong to a given blog.
2859 * @deprecated Use is_user_member_of_blog()
2860 * @see is_user_member_of_blog()
2862 * @param int $blog_id Blog ID
2863 * @return bool True if the current users belong to $blog_id, false if not.
2865 function is_blog_user( $blog_id = 0 ) {
2866 _deprecated_function( __FUNCTION__, '3.3', 'is_user_member_of_blog()' );
2868 return is_user_member_of_blog( get_current_user_id(), $blog_id );
2872 * Open the file handle for debugging.
2875 * @deprecated Use error_log()
2876 * @link http://www.php.net/manual/en/function.error-log.php
2879 function debug_fopen( $filename, $mode ) {
2880 _deprecated_function( __FUNCTION__, 'error_log()' );
2885 * Write contents to the file used for debugging.
2888 * @deprecated Use error_log() instead.
2889 * @link http://www.php.net/manual/en/function.error-log.php
2892 function debug_fwrite( $fp, $string ) {
2893 _deprecated_function( __FUNCTION__, 'error_log()' );
2894 if ( ! empty( $GLOBALS['debug'] ) )
2895 error_log( $string );
2899 * Close the debugging file handle.
2902 * @deprecated Use error_log()
2903 * @link http://www.php.net/manual/en/function.error-log.php
2906 function debug_fclose( $fp ) {
2907 _deprecated_function( __FUNCTION__, 'error_log()' );
2911 * Retrieve list of themes with theme data in theme directory.
2913 * The theme is broken, if it doesn't have a parent theme and is missing either
2914 * style.css and, or index.php. If the theme has a parent theme then it is
2915 * broken, if it is missing style.css; index.php is optional.
2919 * @deprecated Use wp_get_themes()
2920 * @see wp_get_themes()
2922 * @return array Theme list with theme data.
2924 function get_themes() {
2925 _deprecated_function( __FUNCTION__, '3.4', 'wp_get_themes()' );
2928 if ( isset( $wp_themes ) )
2931 $themes = wp_get_themes();
2932 $wp_themes = array();
2934 foreach ( $themes as $theme ) {
2935 $name = $theme->get('Name');
2936 if ( isset( $wp_themes[ $name ] ) )
2937 $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme;
2939 $wp_themes[ $name ] = $theme;
2946 * Retrieve theme data.
2950 * @deprecated Use wp_get_theme()
2951 * @see wp_get_theme()
2953 * @param string $theme Theme name.
2954 * @return array|null Null, if theme name does not exist. Theme data, if exists.
2956 function get_theme( $theme ) {
2957 _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme( $stylesheet )' );
2959 $themes = get_themes();
2960 if ( is_array( $themes ) && array_key_exists( $theme, $themes ) )
2961 return $themes[ $theme ];
2966 * Retrieve current theme name.
2970 * @deprecated Use (string) wp_get_theme()
2971 * @see wp_get_theme()
2975 function get_current_theme() {
2976 _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
2978 if ( $theme = get_option( 'current_theme' ) )
2981 return wp_get_theme()->get('Name');
2985 * Accepts matches array from preg_replace_callback in wpautop() or a string.
2987 * Ensures that the contents of a `<pre>...</pre>` HTML block are not
2988 * converted into paragraphs or line-breaks.
2993 * @param array|string $matches The array or string
2994 * @return string The pre block without paragraph/line-break conversion.
2996 function clean_pre($matches) {
2997 _deprecated_function( __FUNCTION__, '3.4' );
2999 if ( is_array($matches) )
3000 $text = $matches[1] . $matches[2] . "</pre>";
3004 $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
3005 $text = str_replace('<p>', "\n", $text);
3006 $text = str_replace('</p>', '', $text);
3013 * Add callbacks for image header display.
3017 * @deprecated Use add_theme_support('custom-header', $args)
3018 * @see add_theme_support()
3020 * @param callback $wp_head_callback Call on 'wp_head' action.
3021 * @param callback $admin_head_callback Call on custom header administration screen.
3022 * @param callback $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional.
3024 function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) {
3025 _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support( \'custom-header\', $args )' );
3027 'wp-head-callback' => $wp_head_callback,
3028 'admin-head-callback' => $admin_head_callback,
3030 if ( $admin_preview_callback )
3031 $args['admin-preview-callback'] = $admin_preview_callback;
3032 return add_theme_support( 'custom-header', $args );
3036 * Remove image header support.
3040 * @deprecated Use remove_theme_support('custom-header')
3041 * @see remove_theme_support()
3043 * @return null|bool Whether support was removed.
3045 function remove_custom_image_header() {
3046 _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support( \'custom-header\' )' );
3047 return remove_theme_support( 'custom-header' );
3051 * Add callbacks for background image display.
3055 * @deprecated Use add_theme_support('custom-background, $args)
3056 * @see add_theme_support()
3058 * @param callback $wp_head_callback Call on 'wp_head' action.
3059 * @param callback $admin_head_callback Call on custom background administration screen.
3060 * @param callback $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional.
3062 function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) {
3063 _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support( \'custom-background\', $args )' );
3065 if ( $wp_head_callback )
3066 $args['wp-head-callback'] = $wp_head_callback;
3067 if ( $admin_head_callback )
3068 $args['admin-head-callback'] = $admin_head_callback;
3069 if ( $admin_preview_callback )
3070 $args['admin-preview-callback'] = $admin_preview_callback;
3071 return add_theme_support( 'custom-background', $args );
3075 * Remove custom background support.
3078 * @see add_custom_background()
3080 * @return null|bool Whether support was removed.
3082 function remove_custom_background() {
3083 _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support( \'custom-background\' )' );
3084 return remove_theme_support( 'custom-background' );
3088 * Retrieve theme data from parsed theme file.
3092 * @deprecated Use wp_get_theme()
3093 * @see wp_get_theme()
3095 * @param string $theme_file Theme file path.
3096 * @return array Theme data.
3098 function get_theme_data( $theme_file ) {
3099 _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
3100 $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
3102 $theme_data = array(
3103 'Name' => $theme->get('Name'),
3104 'URI' => $theme->display('ThemeURI', true, false),
3105 'Description' => $theme->display('Description', true, false),
3106 'Author' => $theme->display('Author', true, false),
3107 'AuthorURI' => $theme->display('AuthorURI', true, false),
3108 'Version' => $theme->get('Version'),
3109 'Template' => $theme->get('Template'),
3110 'Status' => $theme->get('Status'),
3111 'Tags' => $theme->get('Tags'),
3112 'Title' => $theme->get('Name'),
3113 'AuthorName' => $theme->get('Author'),
3116 foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) {
3117 if ( ! isset( $theme_data[ $extra_header ] ) )
3118 $theme_data[ $extra_header ] = $theme->get( $extra_header );
3125 * Alias of update_post_cache().
3127 * @see update_post_cache() Posts and pages are the same, alias is intentional
3132 * @param array $pages list of page objects
3134 function update_page_cache( &$pages ) {
3135 _deprecated_function( __FUNCTION__, '3.4', 'update_post_cache()' );
3137 update_post_cache( $pages );
3141 * Will clean the page in the cache.
3143 * Clean (read: delete) page from cache that matches $id. Will also clean cache
3144 * associated with 'all_page_ids' and 'get_pages'.
3149 * @param int $id Page ID to clean
3151 function clean_page_cache( $id ) {
3152 _deprecated_function( __FUNCTION__, '3.4', 'clean_post_cache()' );
3154 clean_post_cache( $id );
3158 * Retrieve nonce action "Are you sure" message.
3160 * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3.
3164 * @deprecated Use wp_nonce_ays()
3165 * @see wp_nonce_ays()
3167 * @param string $action Nonce action.
3168 * @return string Are you sure message.
3170 function wp_explain_nonce( $action ) {
3171 _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' );
3172 return __( 'Are you sure you want to do this?' );
3176 * Display "sticky" CSS class, if a post is sticky.
3180 * @deprecated Use post_class()
3183 * @param int $post_id An optional post ID.
3185 function sticky_class( $post_id = null ) {
3186 _deprecated_function( __FUNCTION__, '3.5', 'post_class()' );
3187 if ( is_sticky( $post_id ) )
3192 * Retrieve post ancestors.
3194 * This is no longer needed as WP_Post lazy-loads the ancestors
3195 * property with get_post_ancestors().
3199 * @see get_post_ancestors()
3201 function _get_post_ancestors( &$post ) {
3202 _deprecated_function( __FUNCTION__, '3.5' );
3206 * Load an image from a string, if PHP supports it.
3210 * @see wp_get_image_editor()
3212 * @param string $file Filename of the image to load.
3213 * @return resource The resulting image resource on success, Error string on failure.
3215 function wp_load_image( $file ) {
3216 _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' );
3218 if ( is_numeric( $file ) )
3219 $file = get_attached_file( $file );
3221 if ( ! is_file( $file ) )
3222 return sprintf(__('File “%s” doesn’t exist?'), $file);
3224 if ( ! function_exists('imagecreatefromstring') )
3225 return __('The GD image library is not installed.');
3227 // Set artificially high because GD uses uncompressed images in memory
3228 @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
3229 $image = imagecreatefromstring( file_get_contents( $file ) );
3231 if ( !is_resource( $image ) )
3232 return sprintf(__('File “%s” is not an image.'), $file);
3238 * Scale down an image to fit a particular size and save a new copy of the image.
3240 * The PNG transparency will be preserved using the function, as well as the
3241 * image type. If the file going in is PNG, then the resized image is going to
3242 * be PNG. The only supported image types are PNG, GIF, and JPEG.
3244 * Some functionality requires API to exist, so some PHP version may lose out
3245 * support. This is not the fault of WordPress (where functionality is
3246 * downgraded, not actual defects), but of your PHP version.
3250 * @see wp_get_image_editor()
3252 * @param string $file Image file path.
3253 * @param int $max_w Maximum width to resize to.
3254 * @param int $max_h Maximum height to resize to.
3255 * @param bool $crop Optional. Whether to crop image or resize.
3256 * @param string $suffix Optional. File suffix.
3257 * @param string $dest_path Optional. New image file path.
3258 * @param int $jpeg_quality Optional, default is 90. Image quality percentage.
3259 * @return mixed WP_Error on failure. String with new destination path.
3261 function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
3262 _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' );
3264 $editor = wp_get_image_editor( $file );
3265 if ( is_wp_error( $editor ) )
3267 $editor->set_quality( $jpeg_quality );
3269 $resized = $editor->resize( $max_w, $max_h, $crop );
3270 if ( is_wp_error( $resized ) )
3273 $dest_file = $editor->generate_filename( $suffix, $dest_path );
3274 $saved = $editor->save( $dest_file );
3276 if ( is_wp_error( $saved ) )
3283 * Retrieve a single post, based on post ID.
3285 * Has categories in 'post_category' property or key. Has tags in 'tags_input'
3292 * @param int $postid Post ID.
3293 * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
3294 * @return WP_Post|null Post object or array holding post contents and information
3296 function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
3297 _deprecated_function( __FUNCTION__, '3.5', 'get_post()' );
3298 return get_post( $postid, $mode );
3302 * Check that the user login name and password is correct.
3306 * @deprecated Use wp_authenticate()
3307 * @see wp_authenticate()
3309 * @param string $user_login User name.
3310 * @param string $user_pass User password.
3311 * @return bool False if does not authenticate, true if username and password authenticates.
3313 function user_pass_ok($user_login, $user_pass) {
3314 _deprecated_function( __FUNCTION__, '3.5', 'wp_authenticate()' );
3315 $user = wp_authenticate( $user_login, $user_pass );
3316 if ( is_wp_error( $user ) )
3323 * Callback formerly fired on the save_post hook. No longer needed.
3328 function _save_post_hook() {}
3331 * Check if the installed version of GD supports particular image type
3335 * @see wp_image_editor_supports()
3337 * @param string $mime_type
3340 function gd_edit_image_support($mime_type) {
3341 _deprecated_function( __FUNCTION__, '3.5', 'wp_image_editor_supports()' );
3343 if ( function_exists('imagetypes') ) {
3344 switch( $mime_type ) {
3346 return (imagetypes() & IMG_JPG) != 0;
3348 return (imagetypes() & IMG_PNG) != 0;
3350 return (imagetypes() & IMG_GIF) != 0;
3353 switch( $mime_type ) {
3355 return function_exists('imagecreatefromjpeg');
3357 return function_exists('imagecreatefrompng');
3359 return function_exists('imagecreatefromgif');
3366 * Converts an integer byte value to a shorthand byte value.
3370 * @deprecated Use size_format()
3372 * @param int $bytes An integer byte value.
3373 * @return string A shorthand byte value.
3375 function wp_convert_bytes_to_hr( $bytes ) {
3376 _deprecated_function( __FUNCTION__, '3.6', 'size_format()' );
3378 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB', 4 => 'TB' );
3379 $log = log( $bytes, 1024 );
3380 $power = (int) $log;
3381 $size = pow( 1024, $log - $power );
3383 if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) {
3384 $unit = $units[ $power ];
3390 return $size . $unit;
3394 * Formerly used internally to tidy up the search terms.
3400 function _search_terms_tidy( $t ) {
3401 _deprecated_function( __FUNCTION__, '3.7' );
3402 return trim( $t, "\"'\n\r " );
3406 * Determine if TinyMCE is available.
3408 * Checks to see if the user has deleted the tinymce files to slim down
3409 * their WordPress install.
3414 * @return bool Whether TinyMCE exists.
3416 function rich_edit_exists() {
3417 global $wp_rich_edit_exists;
3418 _deprecated_function( __FUNCTION__, '3.9' );
3420 if ( ! isset( $wp_rich_edit_exists ) )
3421 $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' );
3423 return $wp_rich_edit_exists;
3427 * Old callback for tag link tooltips.
3433 function default_topic_count_text( $count ) {
3438 * Formerly used to escape strings before inserting into the DB.
3440 * Has not performed this function for many, many years. Use wpdb::prepare() instead.
3445 * @param string $content The text to format.
3446 * @return string The very same text.
3448 function format_to_post( $content ) {
3449 _deprecated_function( __FUNCTION__, '3.9' );
3454 * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
3458 * @deprecated Use wpdb::esc_like()
3460 * @param string $text The text to be escaped.
3461 * @return string text, safe for inclusion in LIKE query.
3463 function like_escape($text) {
3464 _deprecated_function( __FUNCTION__, '4.0', 'wpdb::esc_like()' );
3465 return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text );
3469 * Determines if the URL can be accessed over SSL.
3471 * Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access
3472 * the URL using https as the scheme.
3477 * @param string $url The URL to test.
3478 * @return bool Whether SSL access is available.
3480 function url_is_accessable_via_ssl( $url ) {
3481 _deprecated_function( __FUNCTION__, '4.0' );
3483 $response = wp_remote_get( set_url_scheme( $url, 'https' ) );
3485 if ( !is_wp_error( $response ) ) {
3486 $status = wp_remote_retrieve_response_code( $response );
3487 if ( 200 == $status || 401 == $status ) {