WordPress.org

Make WordPress Core

Ticket #12913: 12913_wp_deprecated_filter_check.diff

File 12913_wp_deprecated_filter_check.diff, 4.2 KB (added by strider72, 4 years ago)
  • wp-login.php

     
    165165        $user_login = $user_data->user_login; 
    166166        $user_email = $user_data->user_email; 
    167167 
    168         do_action('retreive_password', $user_login);  // Misspelled and deprecated 
     168        do_action('retreive_password', $user_login, array( '0.0', 'retrieve_password') );  // Misspelled and deprecated 
    169169        do_action('retrieve_password', $user_login); 
    170170 
    171171        $allow = apply_filters('allow_password_reset', true, $user_data->ID); 
  • wp-includes/plugin.php

     
    346346 * @global array $wp_actions Increments the amount of times action was triggered. 
    347347 * 
    348348 * @param string $tag The name of the action to be executed. 
    349  * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. 
     349 * @param mixed $arg,... Optional additional arguments which are passed on to the 
     350 * functions hooked to the action. 
     351 * @param array $deprecated Optional: If the tag is deprecated, this should be an 
     352 * array containing ($since_version, $replacement) 
    350353 * @return null Will return null if $tag does not exist in $wp_filter array 
    351354 */ 
    352 function do_action($tag, $arg = '') { 
     355function do_action($tag, $arg = '', $deprecated = false) { 
    353356        global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 
    354357 
    355358        if ( ! isset($wp_actions) ) 
     
    390393        reset( $wp_filter[ $tag ] ); 
    391394 
    392395        do { 
    393                 foreach ( (array) current($wp_filter[$tag]) as $the_ ) 
     396                foreach ( (array) current($wp_filter[$tag]) as $the_ ) { 
     397                        // If $tag is deprecated, report its use 
     398                        if( $deprecated && is_array( $deprecated ) ) { 
     399                                _deprecated_action( $tag, $deprecated[0], $deprecated[1] ); 
     400                        } 
     401 
    394402                        if ( !is_null($the_['function']) ) 
    395403                                call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 
     404                } 
    396405 
    397406        } while ( next($wp_filter[$tag]) !== false ); 
    398407 
     
    433442 * 
    434443 * @param string $tag The name of the action to be executed. 
    435444 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt> 
     445 * @param array $deprecated Optional: If the tag is deprecated, this should be an 
     446 * array containing ($since_version, $replacement) 
    436447 * @return null Will return null if $tag does not exist in $wp_filter array 
    437448 */ 
    438 function do_action_ref_array($tag, $args) { 
     449function do_action_ref_array($tag, $args, $deprecated = false) { 
    439450        global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 
    440451 
    441452        if ( ! isset($wp_actions) ) 
     
    469480 
    470481        do { 
    471482                foreach( (array) current($wp_filter[$tag]) as $the_ ) 
     483                        // If $tag is deprecated, report its use 
     484                        if( $deprecated && is_array( $deprecated ) ) { 
     485                                _deprecated_action( $tag, $deprecated[0], $deprecated[1] ); 
     486                        } 
    472487                        if ( !is_null($the_['function']) ) 
    473488                                call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 
    474489 
  • wp-includes/functions.php

     
    32103210        } 
    32113211} 
    32123212 
     3213function _deprecated_action( $tag, $version, $replacement ) { 
     3214        _deprecated_filter( $tag, $version, $replacement, 'action '); 
     3215} 
     3216 
     3217function _deprecated_filter( $tag, $version, $replacement, $type='filter' ) { 
     3218        error_log('deprecated filter called!'); 
     3219        do_action( 'deprecated_filter_run', $tag, $replacement, $version, $type ); 
     3220 
     3221        // Allow plugin to filter the output error trigger 
     3222        if ( WP_DEBUG && apply_filters( 'deprecated_filter_trigger_error', true ) ) { 
     3223                if ( ! is_null( $replacement ) ) 
     3224                        trigger_error( sprintf( __( 'The %1$s "%2$s" is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ), $type, $tag, $version, $replacement ) ); 
     3225                else 
     3226                        trigger_error( sprintf( __( 'The %1$s "%2$s" is <strong>deprecated</strong> since version %3$s with no alternative available.' ), $type, $tag, $version ) ); 
     3227        } 
     3228} 
     3229 
     3230 
    32133231/** 
    32143232 * Is the server running earlier than 1.5.0 version of lighttpd 
    32153233 *