WordPress.org

Make WordPress Core

Ticket #11386: 11386.6.diff

File 11386.6.diff, 15.1 KB (added by nacin, 8 years ago)

Simplified _deprecated_argument()

  • wp-admin/includes/image.php

     
    1717 *
    1818 * @param mixed $file Filename of the original image, Or attachment id.
    1919 * @param int $max_side Maximum length of a single side for the thumbnail.
     20 * @param mixed $deprecated Not used.
    2021 * @return string Thumbnail path on success, Error string on failure.
    2122 */
    2223function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
     24        if ( !empty( $deprecated ) )
     25                _deprecated_argument( __FUNCTION__, '0.0' );
    2326        $thumbpath = image_resize( $file, $max_side, $max_side );
    2427        return apply_filters( 'wp_create_thumbnail', $thumbpath );
    2528}
  • wp-admin/includes/meta-boxes.php

     
    639639function xfn_check($class, $value = '', $deprecated = '') {
    640640        global $link;
    641641
     642        if ( !empty( $deprecated ) )
     643                _deprecated_argument( __FUNCTION__, '0.0' );
     644
    642645        $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
    643646        $rels = preg_split('/\s+/', $link_rel);
    644647
  • wp-admin/includes/upgrade.php

     
    3333 * @param null $deprecated Optional. Not used.
    3434 * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
    3535 */
    36 function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
     36function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '' ) {
    3737        global $wp_rewrite;
    3838
     39        if ( !empty( $deprecated ) )
     40                _deprecated_argument( __FUNCTION__, '2.6' );
     41
    3942        wp_check_mysql_version();
    4043        wp_cache_flush();
    4144        make_db_current_silent();
  • wp-app.php

     
    884884         *
    885885         * @since 2.2.0
    886886         *
    887          * @param mixed $deprecated Optional, not used.
     887         * @param mixed $deprecated Not used.
    888888         * @return string
    889889         */
    890890        function get_categories_url($deprecated = '') {
     891                if ( !empty( $deprecated ) )
     892                        _deprecated_argument( __FUNCTION__, '2.5' );
    891893                return $this->app_base . $this->CATEGORIES_PATH;
    892894        }
    893895
  • wp-includes/author-template.php

     
    2222 */
    2323function get_the_author($deprecated = '') {
    2424        global $authordata;
     25
     26        if ( !empty( $deprecated )
     27                _deprecated_argument( __FUNCTION__, '0.0' );
     28
    2529        return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null);
    2630}
    2731
     
    4448 * @param string $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it.
    4549 * @return string The author's display name, from get_the_author().
    4650 */
    47 function the_author($deprecated = '', $deprecated_echo = true) {
    48         if ( !empty($deprecated) )
    49                 _deprecated_argument(__FUNCTION__, 'deprecated', '1.5');
    50         if ( $deprecated_echo !== true )
    51                 _deprecated_argument(__FUNCTION__, 'deprecated_echo', '1.5', __('Use get_the_author() instead if you do not want the value echoed.'));
     51function the_author( $deprecated = '', $deprecated_echo = true ) {
     52        if ( !empty( $deprecated ) || $deprecated_echo !== true )
     53                _deprecated_argument( __FUNCTION__, '1.5', $deprecated_echo !== true ? __('Use get_the_author() instead if you do not want the value echoed.') : null );
    5254        if ( $deprecated_echo )
    5355                echo get_the_author();
    5456        return get_the_author();
     
    182184 */
    183185function the_author_posts_link($deprecated = '') {
    184186        if ( !empty( $deprecated ) )
    185                 _deprecated_argument(__FUNCTION__, 'deprecated', '0.0');
     187                _deprecated_argument( __FUNCTION__, '0.0' );
    186188
    187189        global $authordata;
    188190        $link = sprintf(
  • wp-includes/comment-template.php

     
    507507 * @param bool $deprecated_2 Not Used
    508508 */
    509509function comments_link( $deprecated_1 = '', $deprecated_2 = '' ) {
    510         if ( !empty( $deprecated_1 ) )
    511                 _deprecated_argument(__FUNCTION__, 'deprecated_1', '0.0');
    512         if ( !empty( $deprecated_2 ) )
    513                 _deprecated_argument(__FUNCTION__, 'deprecated_2', '0.0');
    514 
     510        if ( !empty( $deprecated_1 ) || empty( $deprecated_2 ) )
     511                _deprecated_argument( __FUNCTION__, '0.0' );
    515512        echo get_comments_link();
    516513}
    517514
     
    554551 */
    555552function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
    556553        global $id;
     554
     555        if ( !empty( $deprecated )
     556                _deprecated_argument( __FUNCTION__, '0.0' );
     557
    557558        $number = get_comments_number($id);
    558559
    559560        if ( $number > 1 )
     
    696697 * @since 0.71
    697698 * @uses get_trackback_url() Gets the trackback url for the current post
    698699 *
    699  * @param bool $deprecated Remove backwards compat in 2.5
     700 * @param bool $deprecated_echo Remove backwards compat in 2.5
    700701 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead.
    701702 */
    702 function trackback_url($deprecated = true) {
    703         if ($deprecated) echo get_trackback_url();
    704         else return get_trackback_url();
     703function trackback_url( $deprecated_echo = true ) {
     704        if ( $deprecated_echo !== true )
     705                _deprecated_argument( __FUNCTION__, '2.5', __('Use get_trackback_url() instead if you do not want the value echoed.') );
     706        if ( $deprecated_echo )
     707                echo get_trackback_url();
     708        else
     709                return get_trackback_url();
    705710}
    706711
    707712/**
     
    712717 * @param int $deprecated Not used (Was $timezone = 0)
    713718 */
    714719function trackback_rdf($deprecated = '') {
     720        if ( !empty( $deprecated ) )
     721                _deprecated_argument( __FUNCTION__, '2.5' );
     722
    715723        if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) {
    716724                echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    717725                                xmlns:dc="http://purl.org/dc/elements/1.1/"
  • wp-includes/comment.php

     
    15111511 * @param int $deprecated Not Used.
    15121512 * @return bool|string False on failure, string containing URI on success.
    15131513 */
    1514 function discover_pingback_server_uri($url, $deprecated = '') {
    1515         if ( !empty($deprecated) )
    1516                 _deprecated_argument(__FUNCTION__, 'deprecated', '0.0');
     1514function discover_pingback_server_uri( $url, $deprecated = '' ) {
     1515        if ( !empty( $deprecated ) )
     1516                _deprecated_argument( __FUNCTION__, '0.0' );
    15171517
    15181518        $pingback_str_dquote = 'rel="pingback"';
    15191519        $pingback_str_squote = 'rel=\'pingback\'';
  • wp-includes/cron.php

     
    136136        // Backward compatibility
    137137        // Previously this function took the arguments as discrete vars rather than an array like the rest of the API
    138138        if ( !is_array($args) ) {
    139                 _deprecated_argument(__FUNCTION__, 'args', '3.0.0', __('This argument has changed to an array so as to match with the behaviour of all the other cron functions.') );
     139                _deprecated_argument( __FUNCTION__, '3.0.0', __('This argument has changed to an array to match the behavior of the other cron functions.') );
    140140                $args = array_slice( func_get_args(), 1 );
    141141        }
    142142
  • wp-includes/formatting.php

     
    866866 * @return string Converted string.
    867867 */
    868868function convert_chars($content, $deprecated = '') {
     869        if ( !empty( $deprecated ) )
     870                _deprecated_argument( __FUNCTION__, '0.0' );
     871
    869872        // Translation of invalid Unicode references range to valid range
    870873        $wp_htmltranswinuni = array(
    871874        '&#128;' => '&#8364;', // the Euro sign
  • wp-includes/functions.php

     
    570570 * @return null returns when finished.
    571571 */
    572572function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {
     573        if ( !empty( $deprecated ) )
     574                _deprecated_argument( __FUNCTION__, '2.3' );
     575
    573576        global $wpdb;
    574577
    575578        wp_protect_special_option( $name );
     
    11881191 * @return bool|string False on failure and string of headers if HEAD request.
    11891192 */
    11901193function wp_get_http( $url, $file_path = false, $deprecated = false ) {
     1194        if ( !empty( $deprecated ) )
     1195                _deprecated_argument( __FUNCTION__, '0.0' );
     1196
    11911197        @set_time_limit( 60 );
    11921198
    11931199        $options = array();
     
    12301236 * @return bool|string False on failure, headers on success.
    12311237 */
    12321238function wp_get_http_headers( $url, $deprecated = false ) {
     1239        if ( !empty( $deprecated ) )
     1240                _deprecated_argument( __FUNCTION__, '0.0' );
     1241
    12331242        $response = wp_remote_head( $url );
    12341243
    12351244        if ( is_wp_error( $response ) )
     
    21722181 * @return array
    21732182 */
    21742183function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
     2184        if ( !empty( $deprecated ) )
     2185                _deprecated_argument( __FUNCTION__, '0.0' );
     2186
    21752187        if ( empty( $name ) )
    21762188                return array( 'error' => __( 'Empty filename' ) );
    21772189
     
    30173029 * For example:
    30183030 * <code>
    30193031 * if ( !empty($deprecated) )
    3020  *      _deprecated_argument( __FUNCTION__, 'deprecated', '0.0' );
     3032 *      _deprecated_argument( __FUNCTION__, '0.0' );
    30213033 * </code>
    30223034 *
    30233035 * There is a hook deprecated_argument_run that will be called that can be used
     
    30313043 * @since 3.0.0
    30323044 * @access private
    30333045 *
    3034  * @uses do_action() Calls 'deprecated_argument_run' and passes the function and argument names and what to use instead.
     3046 * @uses do_action() Calls 'deprecated_argument_run' and passes the function name and what to use instead.
    30353047 * @uses apply_filters() Calls 'deprecated_argument_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
    30363048 *
    30373049 * @param string $function The function that was called
    3038  * @param string $argument The name of the deprecated argument that was used
    3039  * @param string $version The version of WordPress that deprecated the function
     3050 * @param string $version The version of WordPress that deprecated the argument used
    30403051 * @param string $message Optional. A message regarding the change.
    30413052 */
    3042 function _deprecated_argument($function, $argument, $version, $message = null) {
     3053function _deprecated_argument($function, $version, $message = null) {
    30433054
    3044         do_action('deprecated_argument_run', $function, $argument, $message);
     3055        do_action('deprecated_argument_run', $function, $message);
    30453056
    30463057        // Allow plugin to filter the output error trigger
    30473058        if( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
    30483059                if( !is_null($message) )
    3049                         trigger_error( sprintf( __('The %1$s argument of %2$s is <strong>deprecated</strong> since version %3$s! %4$s'), $function, $argument, $version, $message ) );
     3060                        trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
    30503061                else
    3051                         trigger_error( sprintf( __('The %1$s argument of %2$s is <strong>deprecated</strong> since version %3$s with no alternative available.'), $function, $argument, $version ) );
     3062                        trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $argument, $version ) );
    30523063        }
    30533064}
    30543065
  • wp-includes/kses.php

     
    11971197add_action('set_current_user', 'kses_init');
    11981198
    11991199function safecss_filter_attr( $css, $deprecated = '' ) {
     1200        if ( !empty( $deprecated ) )
     1201                _deprecated_argument( __FUNCTION__, '0.0' );
     1202
    12001203        $css = wp_kses_no_null($css);
    12011204        $css = str_replace(array("\n","\r","\t"), '', $css);
    12021205
  • wp-includes/link-template.php

     
    168168 * @param mixed $deprecated Not used.
    169169 * @return string
    170170 */
    171 function post_permalink($post_id = 0, $deprecated = '') {
     171function post_permalink( $post_id = 0, $deprecated = '' ) {
     172        if ( !empty( $deprecated ) )
     173                _deprecated_argument( __FUNCTION__, '0.0' );
     174
    172175        return get_permalink($post_id);
    173176}
    174177
  • wp-includes/post-template.php

     
    245245 * @param mixed $deprecated Not used.
    246246 * @return string
    247247 */
    248 function get_the_excerpt($deprecated = '') {
     248function get_the_excerpt( $deprecated = '' ) {
    249249        if ( !empty( $deprecated ) )
    250                 _deprecated_argument(__FUNCTION__, 'deprecated', '2.3');
     250                _deprecated_argument( __FUNCTION__, '2.3' );
    251251
    252252        global $post;
    253253        $output = $post->post_excerpt;
     
    900900 * @param bool $deprecated Deprecated. Not used.
    901901 * @param bool $permalink Optional, default is false. Whether to include permalink.
    902902 */
    903 function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $permalink = false) {
     903function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
     904        if ( !empty( $deprecated ) )
     905                _deprecated_argument( __FUNCTION__, '0.0' );
     906
    904907        if ( $fullsize )
    905908                echo wp_get_attachment_link($id, 'full', $permalink);
    906909        else
  • wp-includes/post.php

     
    35383538 * @param int $deprecated Not Used. Can be set to null.
    35393539 * @param object $post Object type containing the post information
    35403540 */
    3541 function _future_post_hook($deprecated = '', $post) {
     3541function _future_post_hook( $deprecated = '', $post ) {
     3542        if ( !empty( $deprecated ) )
     3543                _deprecated_argument( __FUNCTION__, '0.0' );
    35423544        wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) );
    3543         wp_schedule_single_event(strtotime($post->post_date_gmt. ' GMT'), 'publish_future_post', array($post->ID));
     3545        wp_schedule_single_event( strtotime( $post->post_date_gmt. ' GMT' ), 'publish_future_post', array( $post->ID ) );
    35443546}
    35453547
    35463548/**
  • wp-includes/widgets.php

     
    985985 */
    986986function wp_get_sidebars_widgets($deprecated = true) {
    987987        if ( $deprecated !== true )
    988                 _deprecated_argument(__FUNCTION__, 'deprecated', '0.0');
     988                _deprecated_argument( __FUNCTION__, '0.0' );
    989989
    990990        global $wp_registered_widgets, $wp_registered_sidebars, $_wp_sidebars_widgets;
    991991