WordPress.org

Make WordPress Core

Ticket #4361: deprecated.api.#4361.2.2.patch

File deprecated.api.#4361.2.2.patch, 21.7 KB (added by darkdragon, 12 years ago)

Fixed two errors, based off of docwhat suggestions

  • wp-includes/author-template.php

     
    2424/**
    2525 * the_author() - Echo the name of the author of the current post in the Loop.
    2626 *
     27 * The behavior of this function is based off of old functionality predating get_the_author().
     28 * This function is not deprecated, but is designed to echo the value from get_the_author()
     29 * and as an result of any old theme that might still use the old behavior will also
     30 * pass the value from get_the_author().
     31 *
     32 * The normal, expected behavior of this function is to echo the author and not return it.
     33 * However, backwards compatiability has to be maintained.
     34 *
    2735 * @since 0.71
    2836 * @see get_the_author()
    29  * @deprecated Use get_the_author()
    3037 *
    3138 * @param string $deprecated Deprecated.
    3239 * @param string $deprecated_echo Echo the string or return it. Deprecated, use get_the_author().
  • wp-includes/bookmark.php

     
    3737
    3838// Deprecate
    3939function get_link($bookmark_id, $output = OBJECT) {
     40        wp_mark_deprecated(__FUNCTION__, 'get_bookmark()');
    4041        return get_bookmark($bookmark_id, $output);
    4142}
    4243
  • wp-includes/deprecated.php

     
    8686 * @return array
    8787 */
    8888function get_postdata($postid) {
     89        wp_mark_deprecated(__FUNCTION__, 'get_post()');
     90
    8991        $post = &get_post($postid);
    9092
    9193        $postdata = array (
     
    118120function start_wp() {
    119121        global $wp_query, $post;
    120122
     123        wp_mark_deprecated(__FUNCTION__, __('new WordPress Loop') );
     124
    121125        // Since the old style loop is being used, advance the query iterator here.
    122126        $wp_query->next_post();
    123127
     
    135139 * @return null|int
    136140 */
    137141function the_category_ID($echo = true) {
     142        wp_mark_deprecated(__FUNCTION__, 'get_the_category()');
     143
    138144        // Grab the first cat in the list.
    139145        $categories = get_the_category();
    140146        $cat = $categories[0]->term_id;
     
    157163 */
    158164function the_category_head($before='', $after='') {
    159165        global $currentcat, $previouscat;
     166
     167        wp_mark_deprecated(__FUNCTION__, 'get_the_category_by_ID()');
     168
    160169        // Grab the first cat in the list.
    161170        $categories = get_the_category();
    162171        $currentcat = $categories[0]->category_id;
     
    184193 */
    185194function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
    186195
     196        wp_mark_deprecated(__FUNCTION__, 'previous_post_link()');
     197
    187198        if ( empty($in_same_cat) || 'no' == $in_same_cat )
    188199                $in_same_cat = false;
    189200        else
     
    217228 * @param string $excluded_categories
    218229 */
    219230function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
     231        wp_mark_deprecated(__FUNCTION__, 'next_post_link()');
    220232
    221233        if ( empty($in_same_cat) || 'no' == $in_same_cat )
    222234                $in_same_cat = false;
     
    249261 * @return bool
    250262 */
    251263function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
     264        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     265
    252266        $author_data = get_userdata($user_id);
    253267        return ($author_data->user_level > 1);
    254268}
     
    266280 * @return bool
    267281 */
    268282function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
     283        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     284
    269285        $author_data = get_userdata($user_id);
    270286        return ($author_data->user_level >= 1);
    271287}
     
    283299 * @return bool
    284300 */
    285301function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
     302        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     303
    286304        $author_data = get_userdata($user_id);
    287305        $post = get_post($post_id);
    288306        $post_author_data = get_userdata($post->post_author);
     
    309327 * @return bool
    310328 */
    311329function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
     330        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     331
    312332        // right now if one can edit, one can delete
    313333        return user_can_edit_post($user_id, $post_id, $blog_id);
    314334}
     
    326346 * @return bool
    327347 */
    328348function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
     349        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     350
    329351        $author_data = get_userdata($user_id);
    330352        return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
    331353}
     
    344366 * @return bool
    345367 */
    346368function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
     369        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     370
    347371        $author_data = get_userdata($user_id);
    348372        return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
    349373}
     
    362386 * @return bool
    363387 */
    364388function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
     389        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     390
    365391        // right now if one can edit a post, one can edit comments made on it
    366392        return user_can_edit_post($user_id, $post_id, $blog_id);
    367393}
     
    380406 * @return bool
    381407 */
    382408function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
     409        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     410
    383411        // right now if one can edit comments, one can delete comments
    384412        return user_can_edit_post_comments($user_id, $post_id, $blog_id);
    385413}
     
    396424 * @return bool
    397425 */
    398426function user_can_edit_user($user_id, $other_user) {
     427        wp_mark_deprecated(__FUNCTION__, 'current_user_can()');
     428
    399429        $user  = get_userdata($user_id);
    400430        $other = get_userdata($other_user);
    401431        if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
     
    427457function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
    428458                                                 $show_description = true, $show_rating = false,
    429459                                                 $limit = -1, $show_updated = 0) {
     460        wp_mark_deprecated(__FUNCTION__, 'get_links()');
     461
    430462        $cat_id = -1;
    431463        $cat = get_term_by('name', $cat_name, 'link_category');
    432464        if ( $cat )
     
    447479 * @return bool|null
    448480 */
    449481function wp_get_linksbyname($category, $args = '') {
     482        wp_mark_deprecated(__FUNCTION__, 'wp_get_links()');
     483
    450484        $cat = get_term_by('name', $category, 'link_category');
    451485        if ( !$cat )
    452486                return false;
     
    478512 * @return unknown
    479513 */
    480514function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
     515        wp_mark_deprecated(__FUNCTION__, 'get_linkobjects()');
     516
    481517        $cat_id = -1;
    482518        $cat = get_term_by('name', $cat_name, 'link_category');
    483519        if ( $cat )
     
    529565 * @return unknown
    530566 */
    531567function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) {
     568        wp_mark_deprecated(__FUNCTION__, 'get_bookmarks()');
     569
    532570        $links = get_bookmarks("category=$category&orderby=$orderby&limit=$limit");
    533571
    534572        $links_array = array();
     
    560598 */
    561599function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ",
    562600                                                                        $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
     601        wp_mark_deprecated(__FUNCTION__, 'get_bookmarks()');
    563602
    564603        get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
    565604}
     
    586625 */
    587626function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true,
    588627                                                          $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
     628        wp_mark_deprecated(__FUNCTION__, 'get_bookmarks()');
    589629
    590630        get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
    591631}
     
    600640 * @return int Only returns 0.
    601641 */
    602642function get_autotoggle($id = 0) {
     643        wp_mark_deprecated( __FUNCTION__ );
    603644        return 0;
    604645}
    605646
     
    631672function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0,
    632673                                   $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0,
    633674                                   $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) {
     675        wp_mark_deprecated(__FUNCTION__, 'wp_list_categories()');
     676
    634677        $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children',
    635678                'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical');
    636679        return wp_list_cats($query);
     
    645688 * @return unknown
    646689 */
    647690function wp_list_cats($args = '') {
     691        wp_mark_deprecated(__FUNCTION__, 'wp_list_categories()');
     692
    648693        $r = wp_parse_args( $args );
    649694
    650695        // Map to new names.
     
    685730function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
    686731                $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false,
    687732                $selected = 0, $exclude = 0) {
     733        wp_mark_deprecated(__FUNCTION__, 'wp_dropdown_categories()');
    688734
    689735        $show_option_all = '';
    690736        if ( $optionall )
     
    707753 * @see WP_Scripts
    708754 */
    709755function tinymce_include() {
     756        wp_mark_deprecated(__FUNCTION__, 'wp_print_scripts()/WP_Scripts');
     757
    710758        wp_print_script('wp_tiny_mce');
    711759}
    712760
     
    724772 * @return unknown
    725773 */
    726774function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
     775        wp_mark_deprecated(__FUNCTION__, 'wp_list_authors()');
     776
    727777        $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
    728778        return wp_list_authors($args);
    729779}
     
    738788 * @return unknown
    739789 */
    740790function wp_get_post_cats($blogid = '1', $post_ID = 0) {
     791        wp_mark_deprecated(__FUNCTION__, 'wp_get_post_categories()');
    741792        return wp_get_post_categories($post_ID);
    742793}
    743794
     
    754805 * @return unknown
    755806 */
    756807function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
     808        wp_mark_deprecated(__FUNCTION__, 'wp_set_post_categories()');
    757809        return wp_set_post_categories($post_ID, $post_categories);
    758810}
    759811
     
    771823 * @return unknown
    772824 */
    773825function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
     826        wp_mark_deprecated(__FUNCTION__, 'wp_get_archives()');
    774827        $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
    775828        return wp_get_archives($args);
    776829}
     
    788841 * @return string|null
    789842 */
    790843function get_author_link($echo = false, $author_id, $author_nicename = '') {
     844        wp_mark_deprecated(__FUNCTION__, 'get_author_posts_url()');
     845
    791846        $link = get_author_posts_url($author_id, $author_nicename);
    792847
    793848        if ( $echo )
     
    813868 */
    814869function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page',
    815870                                        $pagelink='%', $more_file='') {
     871        wp_mark_deprecated(__FUNCTION__, 'wp_link_pages()');
     872
    816873        $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
    817874        return wp_link_pages($args);
    818875}
     
    828885 * @return string
    829886 */
    830887function get_settings($option) {
     888        wp_mark_deprecated(__FUNCTION__, 'get_option()');
     889
    831890        return get_option($option);
    832891}
    833892
     
    839898 * @see the_permalink()
    840899 */
    841900function permalink_link() {
     901        wp_mark_deprecated(__FUNCTION__, 'the_permalink()');
    842902        the_permalink();
    843903}
    844904
     
    852912 * @param string $file
    853913 */
    854914function permalink_single_rss($file = '') {
     915        wp_mark_deprecated(__FUNCTION__, 'the_permalink_rss()');
    855916        the_permalink_rss();
    856917}
    857918
     
    867928 * @return null|string
    868929 */
    869930function wp_get_links($args = '') {
     931        wp_mark_deprecated(__FUNCTION__, 'get_bookmarks()');
     932
    870933        if ( strpos( $args, '=' ) === false ) {
    871934                $cat_id = $args;
    872935                $args = add_query_arg( 'category', $cat_id, $args );
     
    913976 */
    914977function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name',
    915978                        $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) {
     979        wp_mark_deprecated(__FUNCTION__, 'get_bookmarks()');
    916980
    917981        $order = 'ASC';
    918982        if ( substr($orderby, 0, 1) == '_' ) {
     
    10071071 * @param string $$deprecated Not Used
    10081072 */
    10091073function get_links_list($order = 'name', $deprecated = '') {
     1074        wp_mark_deprecated(__FUNCTION__, 'get_categories()');
     1075
    10101076        $order = strtolower($order);
    10111077
    10121078        // Handle link category sorting
     
    10531119 * @param bool $count the number of links in the db
    10541120 */
    10551121function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
     1122        wp_mark_deprecated( __FUNCTION__ );
     1123
    10561124        if ( $count )
    10571125                $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links");
    10581126
     
    10751143 * @return unknown
    10761144 */
    10771145function get_linkrating($link) {
     1146        wp_mark_deprecated(__FUNCTION__, 'sanitize_bookmark_field()');
    10781147        return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display');
    10791148}
    10801149
     
    10891158 * @return string
    10901159 */
    10911160function get_linkcatname($id = 0) {
     1161        wp_mark_deprecated(__FUNCTION__, 'get_category()');
     1162
    10921163        $id = (int) $id;
    10931164
    10941165        if ( empty($id) )
     
    11161187 * @param string $deprecated Not used
    11171188 */
    11181189function comments_rss_link($link_text = 'Comments RSS', $deprecated = '') {
     1190        wp_mark_deprecated(__FUNCTION__, 'post_comments_feed_link()');
    11191191        post_comments_feed_link($link_text);
    11201192}
    11211193
     
    11321204 * @return string|null
    11331205 */
    11341206function get_category_rss_link($echo = false, $cat_ID = 1, $deprecated = '') {
     1207        wp_mark_deprecated(__FUNCTION__, 'get_category_feed_link()');
     1208
    11351209        $link = get_category_feed_link($cat_ID, $feed = 'rss2');
    11361210
    11371211        if ( $echo )
     
    11521226 * @return string|null
    11531227 */
    11541228function get_author_rss_link($echo = false, $author_id = 1, $deprecated = '') {
     1229        wp_mark_deprecated(__FUNCTION__, 'get_author_feed_link()');
     1230
    11551231        $link = get_author_feed_link($author_id);
    11561232        if ( $echo )
    11571233                echo $link;
  • wp-includes/feed.php

     
    9898}
    9999
    100100function comments_rss($deprecated = '') {
     101        wp_mark_deprecated(__FUNCTION__, 'get_post_comments_feed_link()');
    101102        return get_post_comments_feed_link();
    102103}
    103104
     
    178179}
    179180
    180181/**
    181  * prep_atom_text_construct() - determine if given string of data is
    182  * type text, html, or xhtml, per RFC 4287 section 3.1.
     182 * prep_atom_text_construct() - Determine the type of a given string of data
    183183 *
     184 * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1.
     185 *
    184186 * In the case of WordPress, text is defined as containing no markup,
    185187 * xhtml is defined as "well formed", and html as tag soup (i.e., the rest).
    186188 *
    187189 * Container div tags are added to xhtml values, per section 3.1.1.3.
    188190 *
     191 * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
     192 *
    189193 * @package WordPress
    190194 * @subpackage Feed
    191195 * @since 2.4
    192196 *
    193197 * @param string $data input string
    194198 * @return array $result array(type, value)
    195  * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
    196199 */
    197200function prep_atom_text_construct($data) {
    198201        if (strpos($data, '<') === false && strpos($data, '&') === false) {
     
    205208        xml_parser_free($parser);
    206209
    207210        if (!$code) {
    208                        if (strpos($data, '<') === false) {
    209                                return array('text', $data);
    210                        } else {
    211                                $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
    212                                return array('xhtml', $data);
    213                        }
     211                if (strpos($data, '<') === false) {
     212                        return array('text', $data);
     213                } else {
     214                        $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
     215                        return array('xhtml', $data);
     216                }
    214217        }
    215218
    216219        if (strpos($data, ']]>') == false) {
  • wp-includes/functions.php

     
    485485                fclose( $fp );
    486486}
    487487
     488/**
     489 * wp_mark_deprecated() - Marks a function as deprecated and informs when it has been used.
     490 *
     491 * There is a hook that will be called that can be used to get the backtrace up to what file
     492 * and function called the deprecated function. That behavior is not defined here, because of
     493 * preformance.
     494 *
     495 * The current behavior is to trigger an user error if WP_DEBUG is defined and is true. In later
     496 * versions, this behavior could be changed to a more reasonable and less drastic approach of
     497 * letting the user know that deprecated functions were used. However, normal usage will NOT
     498 * trigger these errors, so only those that purposefully enable WP_DEBUG will see them.
     499 *
     500 * This function could be used in every place, including hooks that allows for calling the function.
     501 * The common use will be for functions but can be for hooks, parameters, etc that is deprecated.
     502 *
     503 * @link http://trac.wordpress.org/ticket/4361 History of this function
     504 *
     505 * @package WordPress
     506 * @package Debug
     507 * @since 2.4
     508 *
     509 * @uses do_action() Calls 'deprecated_function_run' and passes the function name and what to use instead.
     510 * @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
     511 *
     512 * @param string $used The function that was called
     513 * @param string $seeinstead Optional. The function that should have been called
     514 */
     515function wp_mark_deprecated($used, $seeinstead=null) {
     516        // Allow plugin to overwrite the error => forward thinking
     517        $outputError = true;
     518
     519        // We can't know if another function will trigger this function before plugins.php is included.
     520        // Test anyway. Small performance lost is okay since this function should not be called at all.
     521        if( function_exists('do_action') ) {
     522                do_action('deprecated_function_run', $function, $seeinstead);
     523
     524                // Allow plugin to filter the output error trigger
     525                $outputError = apply_filters( 'deprecated_function_trigger_error', $outputError );
     526        }
     527
     528        if( $outputError && defined('WP_DEBUG') && true === WP_DEBUG ) {
     529                if( !is_null($seeinstead) )
     530                        trigger_error( printf( __("%s is <strong>deprecated</strong>! Use %s instead."), $used, $seeinstead ) );
     531                else
     532                        trigger_error( printf( __("%s is <strong>deprecated</strong with no alternative available."), $used ) );
     533        }
     534}
     535
    488536function do_enclose( $content, $post_ID ) {
    489537        global $wpdb;
    490538        include_once( ABSPATH . WPINC . '/class-IXR.php' );
  • wp-includes/pluggable.php

     
    788788// Deprecated. Use wp_set_auth_cookie()
    789789if ( !function_exists('wp_setcookie') ) :
    790790function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
     791        wp_mark_deprecated( __FUNCTION__ );
    791792        $user = get_userdatabylogin($username);
    792793        wp_set_auth_cookie($user->ID, $remember);
    793794}
     
    796797// Deprecated. Use wp_clear_auth_cookie()
    797798if ( !function_exists('wp_clearcookie') ) :
    798799function wp_clearcookie() {
     800        wp_mark_deprecated( __FUNCTION__ );
    799801        wp_clear_auth_cookie();
    800802}
    801803endif;
     
    803805// Deprecated.  No alternative.
    804806if ( !function_exists('wp_get_cookie_login') ):
    805807function wp_get_cookie_login() {
     808        wp_mark_deprecated( __FUNCTION__ );
    806809        return false;
    807810}
    808811endif;
  • wp-includes/registration-functions.php

     
    11<?php
    22// Deprecated.  Use registration.php.
     3wp_mark_deprecated( basename(__FILE__), 'registration.php' );
    34require_once(ABSPATH . WPINC .  '/registration.php');
    45?>
  • wp-includes/registration.php

     
    177177
    178178/**
    179179 * A simpler way of inserting an user into the database.
    180  * See also: wp_insert_user().
     180 * @see wp_insert_user().
    181181 * @global object $wpdb WordPress database layer.
    182182 * @param string $username The user's username.
    183183 * @param string $password The user's password.
     
    201201 * @param string $password The user's password.
    202202 * @param string $email The user's email (optional).
    203203 * @return int The new user's ID.
    204  * @deprecated
     204 * @deprecated Use wp_create_user()
     205 * @see wp_create_user()
    205206 */
    206207function create_user($username, $password, $email) {
     208        wp_mark_deprecated( __FUNCTION__, 'wp_create_user()' );
    207209        return wp_create_user($username, $password, $email);
    208210}
    209211
  • wp-includes/rss-functions.php

     
    11<?php
    22// Deprecated.  Use rss.php instead.
     3
     4wp_mark_deprecated( basename(__FILE__), 'rss.php' );
    35require_once (ABSPATH . WPINC . '/rss.php');
    46?>
  • wp-settings.php

     
    156156if (defined('WP_DEBUG') and WP_DEBUG == true) {
    157157   error_reporting(E_ALL);
    158158} else {
    159    error_reporting(E_ALL ^ E_NOTICE);
     159   error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);
    160160}
    161161
    162162// For an advanced caching plugin to use, static because you would only want one