WordPress.org

Make WordPress Core

Changeset 6514


Ignore:
Timestamp:
12/28/2007 09:17:42 PM (11 years ago)
Author:
westi
Message:

Mark functions and files as deprecated. Fixes #4361 props docwhat and darkdragon

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/deprecated.php

    r6370 r6514  
    8787 */
    8888function get_postdata($postid) {
     89    _deprecated_function(__FUNCTION__, '0.0', 'get_post()');
     90
    8991    $post = &get_post($postid);
    9092
     
    119121    global $wp_query, $post;
    120122
     123    _deprecated_function(__FUNCTION__, '1.5', __('new WordPress Loop') );
     124
    121125    // Since the old style loop is being used, advance the query iterator here.
    122126    $wp_query->next_post();
     
    136140 */
    137141function the_category_ID($echo = true) {
     142    _deprecated_function(__FUNCTION__, '0.0', 'get_the_category()');
     143
    138144    // Grab the first cat in the list.
    139145    $categories = get_the_category();
     
    158164function the_category_head($before='', $after='') {
    159165    global $currentcat, $previouscat;
     166
     167    _deprecated_function(__FUNCTION__, '0.0', 'get_the_category_by_ID()');
     168
    160169    // Grab the first cat in the list.
    161170    $categories = get_the_category();
     
    185194function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
    186195
     196    _deprecated_function(__FUNCTION__, '0.0', 'previous_post_link()');
     197
    187198    if ( empty($in_same_cat) || 'no' == $in_same_cat )
    188199        $in_same_cat = false;
     
    218229 */
    219230function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
     231    _deprecated_function(__FUNCTION__, '0.0', 'next_post_link()');
    220232
    221233    if ( empty($in_same_cat) || 'no' == $in_same_cat )
     
    250262 */
    251263function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
     264    _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()');
     265
    252266    $author_data = get_userdata($user_id);
    253267    return ($author_data->user_level > 1);
     
    267281 */
    268282function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
     283    _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()');
     284
    269285    $author_data = get_userdata($user_id);
    270286    return ($author_data->user_level >= 1);
     
    284300 */
    285301function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
     302    _deprecated_function(__FUNCTION__, '0', 'current_user_can()');
     303
    286304    $author_data = get_userdata($user_id);
    287305    $post = get_post($post_id);
     
    310328 */
    311329function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
     330    _deprecated_function(__FUNCTION__, '0.0', '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);
     
    327347 */
    328348function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
     349    _deprecated_function(__FUNCTION__, '0.0', '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));
     
    345367 */
    346368function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
     369    _deprecated_function(__FUNCTION__, '0.0', '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));
     
    363387 */
    364388function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
     389    _deprecated_function(__FUNCTION__, '0.0', '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);
     
    381407 */
    382408function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
     409    _deprecated_function(__FUNCTION__, '0.0', '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);
     
    397425 */
    398426function user_can_edit_user($user_id, $other_user) {
     427    _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()');
     428
    399429    $user  = get_userdata($user_id);
    400430    $other = get_userdata($other_user);
     
    428458                         $show_description = true, $show_rating = false,
    429459                         $limit = -1, $show_updated = 0) {
     460    _deprecated_function(__FUNCTION__, '0.0', 'get_links()');
     461
    430462    $cat_id = -1;
    431463    $cat = get_term_by('name', $cat_name, 'link_category');
     
    448480 */
    449481function wp_get_linksbyname($category, $args = '') {
     482    _deprecated_function(__FUNCTION__, '0.0', 'wp_get_links()');
     483
    450484    $cat = get_term_by('name', $category, 'link_category');
    451485    if ( !$cat )
     
    479513 */
    480514function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
     515    _deprecated_function(__FUNCTION__, '0.0', 'get_linkobjects()');
     516
    481517    $cat_id = -1;
    482518    $cat = get_term_by('name', $cat_name, 'link_category');
     
    530566 */
    531567function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) {
     568    _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()');
     569
    532570    $links = get_bookmarks("category=$category&orderby=$orderby&limit=$limit");
    533571
     
    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    _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()');
    563602
    564603    get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
     
    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    _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()');
    589629
    590630    get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
     
    601641 */
    602642function get_autotoggle($id = 0) {
     643    _deprecated_function(__FUNCTION__, '0.0' );
    603644    return 0;
    604645}
     
    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    _deprecated_function(__FUNCTION__, '0.0', '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');
     
    646689 */
    647690function wp_list_cats($args = '') {
     691    _deprecated_function(__FUNCTION__, '0.0', 'wp_list_categories()');
     692
    648693    $r = wp_parse_args( $args );
    649694
     
    686731        $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false,
    687732        $selected = 0, $exclude = 0) {
     733    _deprecated_function(__FUNCTION__, '0.0', 'wp_dropdown_categories()');
    688734
    689735    $show_option_all = '';
     
    708754 */
    709755function tinymce_include() {
     756    _deprecated_function(__FUNCTION__, '0.0', 'wp_print_scripts()/WP_Scripts');
     757
    710758    wp_print_script('wp_tiny_mce');
    711759}
     
    725773 */
    726774function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
     775    _deprecated_function(__FUNCTION__, '0.0', 'wp_list_authors()');
     776
    727777    $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
    728778    return wp_list_authors($args);
     
    739789 */
    740790function wp_get_post_cats($blogid = '1', $post_ID = 0) {
     791    _deprecated_function(__FUNCTION__, '0.0', 'wp_get_post_categories()');
    741792    return wp_get_post_categories($post_ID);
    742793}
     
    755806 */
    756807function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
     808    _deprecated_function(__FUNCTION__, '0.0', 'wp_set_post_categories()');
    757809    return wp_set_post_categories($post_ID, $post_categories);
    758810}
     
    772824 */
    773825function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
     826    _deprecated_function(__FUNCTION__, '0.0', 'wp_get_archives()');
    774827    $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
    775828    return wp_get_archives($args);
     
    789842 */
    790843function get_author_link($echo = false, $author_id, $author_nicename = '') {
     844    _deprecated_function(__FUNCTION__, '0.0', 'get_author_posts_url()');
     845
    791846    $link = get_author_posts_url($author_id, $author_nicename);
    792847
     
    814869function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page',
    815870                    $pagelink='%', $more_file='') {
     871    _deprecated_function(__FUNCTION__, '0.0', 'wp_link_pages()');
     872
    816873    $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
    817874    return wp_link_pages($args);
     
    829886 */
    830887function get_settings($option) {
     888    _deprecated_function(__FUNCTION__, '0.0', 'get_option()');
     889
    831890    return get_option($option);
    832891}
     
    840899 */
    841900function permalink_link() {
     901    _deprecated_function(__FUNCTION__, '0.0', 'the_permalink()');
    842902    the_permalink();
    843903}
     
    853913 */
    854914function permalink_single_rss($file = '') {
     915    _deprecated_function(__FUNCTION__, '0.0', 'the_permalink_rss()');
    855916    the_permalink_rss();
    856917}
     
    868929 */
    869930function wp_get_links($args = '') {
     931    _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()');
     932
    870933    if ( strpos( $args, '=' ) === false ) {
    871934        $cat_id = $args;
     
    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    _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()');
    916980
    917981    $order = 'ASC';
     
    10081072 */
    10091073function get_links_list($order = 'name', $deprecated = '') {
     1074    _deprecated_function(__FUNCTION__, '0.0', 'get_categories()');
     1075
    10101076    $order = strtolower($order);
    10111077
     
    10541120 */
    10551121function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
     1122    _deprecated_function(__FUNCTION__, '0.0' );
     1123
    10561124    if ( $count )
    10571125        $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links");
     
    10761144 */
    10771145function get_linkrating($link) {
     1146    _deprecated_function(__FUNCTION__, '0.0', 'sanitize_bookmark_field()');
    10781147    return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display');
    10791148}
     
    10901159 */
    10911160function get_linkcatname($id = 0) {
     1161    _deprecated_function(__FUNCTION__, '0.0', 'get_category()');
     1162
    10921163    $id = (int) $id;
    10931164
     
    11171188 */
    11181189function comments_rss_link($link_text = 'Comments RSS', $deprecated = '') {
     1190    _deprecated_function(__FUNCTION__, '0.0', 'post_comments_feed_link()');
    11191191    post_comments_feed_link($link_text);
    11201192}
     
    11331205 */
    11341206function get_category_rss_link($echo = false, $cat_ID = 1, $deprecated = '') {
     1207    _deprecated_function(__FUNCTION__, '0.0', 'get_category_feed_link()');
     1208
    11351209    $link = get_category_feed_link($cat_ID, $feed = 'rss2');
    11361210
     
    11531227 */
    11541228function get_author_rss_link($echo = false, $author_id = 1, $deprecated = '') {
     1229    _deprecated_function(__FUNCTION__, '0.0', 'get_author_feed_link()');
     1230
    11551231    $link = get_author_feed_link($author_id);
    11561232    if ( $echo )
  • trunk/wp-includes/functions.php

    r6447 r6514  
    16061606}
    16071607
     1608/**
     1609 * _deprecated_function() - Marks a function as deprecated and informs when it has been used.
     1610 *
     1611 * There is a hook deprecated_function_run that will be called that can be used to get the backtrace
     1612 * up to what file and function called the deprecated function.
     1613 *
     1614 * The current behavior is to trigger an user error if WP_DEBUG is defined and is true.
     1615 *
     1616 * This function is to be used in every function in depreceated.php
     1617 *
     1618 * @package WordPress
     1619 * @package Debug
     1620 * @since 2.4
     1621 * @access private
     1622 *
     1623 * @uses do_action() Calls 'deprecated_function_run' and passes the function name and what to use instead.
     1624 * @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
     1625 *
     1626 * @param string $function The function that was called
     1627 * @param string $version The version of WordPress that depreceated the function
     1628 * @param string $replacement Optional. The function that should have been called
     1629 */
     1630function _deprecated_function($function, $version, $replacement=null) {
     1631
     1632    do_action('deprecated_function_run', $function, $replacement);
     1633
     1634    // Allow plugin to filter the output error trigger
     1635    if( defined('WP_DEBUG') && ( true === WP_DEBUG ) && apply_filters( 'deprecated_function_trigger_error', true )) {
     1636        if( !is_null($replacement) )
     1637            trigger_error( printf( __("%s is <strong>deprecated</strong> since version %s! Use %s instead."), $function, $version, $replacement ) );
     1638        else
     1639            trigger_error( printf( __("%s is <strong>deprecated</strong since version %s with no alternative available."), $function, $version ) );
     1640    }
     1641}
     1642
     1643/**
     1644 * _deprecated_file() - Marks a file as deprecated and informs when it has been used.
     1645 *
     1646 * There is a hook deprecated_file_included that will be called that can be used to get the backtrace
     1647 * up to what file and function included the deprecated file.
     1648 *
     1649 * The current behavior is to trigger an user error if WP_DEBUG is defined and is true.
     1650 *
     1651 * This function is to be used in every file that is depreceated
     1652 *
     1653 * @package WordPress
     1654 * @package Debug
     1655 * @since 2.4
     1656 * @access private
     1657 *
     1658 * @uses do_action() Calls 'deprecated_file_included' and passes the file name and what to use instead.
     1659 * @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
     1660 *
     1661 * @param string $file The file that was included
     1662 * @param string $version The version of WordPress that depreceated the function
     1663 * @param string $replacement Optional. The function that should have been called
     1664 */
     1665function _deprecated_file($file, $version, $replacement=null) {
     1666
     1667    do_action('deprecated_file_included', $file, $replacement);
     1668
     1669    // Allow plugin to filter the output error trigger
     1670    if( defined('WP_DEBUG') && ( true === WP_DEBUG ) && apply_filters( 'deprecated_file_trigger_error', true )) {
     1671        if( !is_null($replacement) )
     1672            trigger_error( printf( __("%s is <strong>deprecated</strong> since version %s! Use %s instead."), $file, $version, $replacement ) );
     1673        else
     1674            trigger_error( printf( __("%s is <strong>deprecated</strong since version %s with no alternative available."), $file, $version ) );
     1675    }
     1676}
    16081677?>
  • trunk/wp-includes/registration-functions.php

    r5390 r6514  
    11<?php
    22// Deprecated.  Use registration.php.
     3_deprecated_file( basename(__FILE__), '0.0', 'registration.php' );
    34require_once(ABSPATH . WPINC .  '/registration.php');
    45?>
  • trunk/wp-includes/rss-functions.php

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

    r6447 r6514  
    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
Note: See TracChangeset for help on using the changeset viewer.