Make WordPress Core

Ticket #17559: do_deprecated_action.diff

File do_deprecated_action.diff, 12.8 KB (added by nacin, 13 years ago)
  • wp-signup.php

     
    210210        }
    211211
    212212        $public = (int) $_POST['blog_public'];
    213         $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // deprecated
     213        $meta = apply_deprecated_filters( 'signup_create_blog_meta', '0.0', 'add_signup_meta', array( array( 'lang_id' => 1, 'public' => $public ) ) );
    214214        $meta = apply_filters( 'add_signup_meta', $meta );
    215215
    216216        wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
  • wp-login.php

     
    194194        $user_login = $user_data->user_login;
    195195        $user_email = $user_data->user_email;
    196196
    197         do_action('retreive_password', $user_login);  // Misspelled and deprecated
     197        do_deprecated_action('retreive_password', '0.0', 'retrieve_password', array( $user_login ) ); // Misspelled
    198198        do_action('retrieve_password', $user_login);
    199199
    200200        $allow = apply_filters('allow_password_reset', true, $user_data->ID);
  • wp-includes/plugin.php

     
    785785        }
    786786}
    787787
     788/**
     789 * Fire a deprecated filter. Wraps apply_filters().
     790 *
     791 * @since 3.2.0
     792 *
     793 * @param string $tag The name of the filter hook.
     794 * @param array $args Array of additional function arguments to be passed to apply_filters().
     795 * @param string $version The version of WordPress that deprecated the hook
     796 * @param string $replacement Optional. The hook that should have been used
     797 * @param string $message Optional. A message regarding the change
     798 */
     799function apply_deprecated_filters( $tag, $args, $version, $replacement = false, $message = null ) {
     800        if ( ! has_filter( $tag ) )
     801                return;
     802        _deprecated_hook( $tag, $version, $replacement, $message );
     803        array_unshift( $args, $tag );
     804        return call_user_func_array( 'apply_filters', $args );
     805}
     806
     807/**
     808 * Fire a deprecated action. Wraps do_action().
     809 *
     810 * @since 3.2.0
     811 *
     812 * @param string $tag The name of the filter hook.
     813 * @param array $args Array of additional function arguments to be passed to do_action().
     814 * @param string $version The version of WordPress that deprecated the hook
     815 * @param string $replacement Optional. The hook that should have been used
     816 * @param string $message Optional. A message regarding the change
     817 */
     818function do_deprecated_action( $tag, $args, $version, $replacement = false, $message = null ) {
     819        if ( ! has_action( $tag ) )
     820                return;
     821        _deprecated_hook( $tag, $version, $replacement, $message );
     822        array_unshift( $args, $tag );
     823        call_user_func_array( 'do_action', $args );
     824}
     825
     826/**
     827 * Marks a hook as deprecated and informs when it has been used.
     828 *
     829 * There is a hook deprecated_hook_used that will be called that can be used
     830 * to get the backtrace up to what file and function was used for the callback.
     831 *
     832 * The current behavior is to trigger a user error if WP_DEBUG is true.
     833 *
     834 * This function is to be used for every hook that is deprecated, when any callback is
     835 * attacked to the hook, as determined by has_action() or has_filter(), and shall be
     836 * called before the hook is fired.
     837 *
     838 * @package WordPress
     839 * @subpackage Debug
     840 * @since 3.2.0
     841 * @access private
     842 *
     843 * @uses do_action() Calls 'deprecated_hook_used' and passes the hook name, what to use instead,
     844 *   the version in which the file was deprecated, and any message regarding the change.
     845 * @uses apply_filters() Calls 'deprecated_hook_trigger_error' and expects boolean value of true to do
     846 *   trigger or false to not trigger error.
     847 *
     848 * @param string $hook The hook that was used
     849 * @param string $version The version of WordPress that deprecated the hook
     850 * @param string $replacement Optional. The hook that should have been used
     851 * @param string $message Optional. A message regarding the change
     852 */
     853function _deprecated_hook( $hook, $version, $replacement = null, $message = null ) {
     854        // Allow plugin to filter the output error trigger
     855        if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) {
     856                $message = empty( $message ) ? '' : ' ' . $message;
     857                if ( ! is_null( $replacement ) )
     858                        trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $hook, $version, $replacement ) . $message );
     859                else
     860                        trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $hook, $version ) . $message );
     861        }
     862}
     863
    788864?>
  • wp-includes/post.php

     
    41044104                return ' 1 = 0 ';
    41054105
    41064106        // This hook is deprecated. Why you'd want to use it, I dunno.
    4107         if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) )
     4107        if ( ! $cap = apply_deprecated_filters( 'pub_priv_sql_capability', '3.2', false, array( '' ) ) )
    41084108                $cap = $post_type_obj->cap->read_private_posts;
    41094109
    41104110        if ( $full ) {
     
    44514451 * @since 2.3.0
    44524452 * @access private
    44534453 * @uses $wpdb
    4454  * @uses do_action() Calls 'private_to_published' on post ID if this is a 'private_to_published' call.
    44554454 * @uses wp_clear_scheduled_hook() with 'publish_future_post' and post ID.
    44564455 *
    44574456 * @param string $new_status New post status
     
    44654464                // Reset GUID if transitioning to publish and it is empty
    44664465                if ( '' == get_the_guid($post->ID) )
    44674466                        $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
    4468                 do_action('private_to_published', $post->ID);  // Deprecated, use private_to_publish
     4467                do_deprecated_action( 'private_to_published', '0.0', 'private_to_publish', array( $post->ID ) );
    44694468        }
    44704469
    44714470        // If published posts changed clear the lastpostmodified cache
  • wp-includes/functions.php

     
    34323432                        trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
    34333433        }
    34343434}
     3435
    34353436/**
    34363437 * Marks a function argument as deprecated and informs when it has been used.
    34373438 *
  • wp-includes/rewrite.php

     
    16711671
    16721672                $rules .= "</IfModule>\n";
    16731673
    1674                 $rules = apply_filters('mod_rewrite_rules', $rules);
    1675                 $rules = apply_filters('rewrite_rules', $rules);  // Deprecated
     1674                $rules = apply_filters( 'mod_rewrite_rules', $rules );
     1675                $rules = apply_deprecated_filters( 'rewrite_rules', array( $rules ), '0.0', 'mod_rewrite_rules' );
    16761676
    16771677                return $rules;
    16781678        }
  • wp-includes/class-wp.php

     
    397397
    398398                // query_string filter deprecated.  Use request filter instead.
    399399                if ( has_filter('query_string') ) {  // Don't bother filtering and parsing if no plugins are hooked in.
    400                         $this->query_string = apply_filters('query_string', $this->query_string);
     400                        $this->query_string = apply_deprecated_filters( 'query_string', array( $this->query_string ), '3.2', 'request' );
    401401                        parse_str($this->query_string, $this->query_vars);
    402402                }
    403403        }
  • wp-admin/includes/post.php

     
    16371637        $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING'])
    16381638                && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
    16391639
    1640         /**
     1640        /*
    16411641         * Deprecated
    16421642         *
    16431643         * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
    16441644         * These plugins can be refreshed by appending query string to the URL passed to mce_external_plugins filter.
    16451645         * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
    16461646         */
    1647         $version = apply_filters('tiny_mce_version', '');
     1647        $version = apply_deprecated_filters( 'tiny_mce_version', array( '' ), '0.0', 'mce_external_plugins' );
    16481648        $version = 'ver=' . $tinymce_version . $version;
    16491649
    16501650        if ( 'en' != $language )
  • wp-admin/edit-tags.php

     
    312312if ( current_user_can($tax->cap->edit_terms) ) {
    313313        // Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form
    314314        if ( 'category' == $taxonomy )
    315                 do_action('add_category_form_pre', (object)array('parent' => 0) );
     315                do_deprecated_action( 'add_category_form_pre', array( (object)array('parent' => 0) ), '3.0', 'category_pre_add_form' );
    316316        elseif ( 'link_category' == $taxonomy )
    317                 do_action('add_link_category_form_pre', (object)array('parent' => 0) );
     317                do_deprecated_action( 'add_link_category_form_pre', array( (object)array('parent' => 0) ), '3.1', 'link_category_pre_add_form' );
    318318        else
    319                 do_action('add_tag_form_pre', $taxonomy);
     319                do_deprecated_action( 'add_tag_form_pre', array( $taxonomy ), '3.0', '{$taxonomy}_pre_add_form' ); // [sic]
    320320
    321         do_action($taxonomy . '_pre_add_form', $taxonomy);
     321        do_action( $taxonomy . '_pre_add_form', $taxonomy );
    322322?>
    323323
    324324<div class="form-wrap">
     
    366366
    367367// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form
    368368if ( 'category' == $taxonomy )
    369         do_action('edit_category_form', (object)array('parent' => 0) );
     369        do_deprecated_action( 'edit_category_form', array( (object)array('parent' => 0) ), '3.0', 'category_add_form' );
    370370elseif ( 'link_category' == $taxonomy )
    371         do_action('edit_link_category_form', (object)array('parent' => 0) );
     371        do_deprecated_action( 'edit_link_category_form', array( (object)array('parent' => 0) ), '3.1', 'link_category_add_form' );
    372372else
    373         do_action('add_tag_form', $taxonomy);
     373        do_action( 'add_tag_form', array( $taxonomy ), '3.0', '{$taxonomy}_add_form' ); // [sic]
    374374
    375 do_action($taxonomy . '_add_form', $taxonomy);
     375do_action( $taxonomy . '_add_form', $taxonomy );
    376376?>
    377377</form></div>
    378378<?php } ?>
  • wp-admin/edit-tag-form.php

     
    1818
    1919// Back compat hooks
    2020if ( 'category' == $taxonomy )
    21         do_action('edit_category_form_pre', $tag );
     21        do_deprecated_action( 'edit_category_form_pre', array( $tag ), '3.0', 'category_pre_edit_form' );
    2222elseif ( 'link_category' == $taxonomy )
    23         do_action('edit_link_category_form_pre', $tag );
     23        do_deprecated_action( 'edit_link_category_form_pre', array( $tag ), '3.1', 'link_category_pre_edit_form' );
    2424else
    25         do_action('edit_tag_form_pre', $tag);
     25        do_deprecated_action( 'edit_tag_form_pre', array( $tag ), '3.0', '{$taxonomy}_pre_edit_form' ); // [sic]
    2626
    27 do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy);  ?>
     27do_action( $taxonomy . '_pre_edit_form', $tag, $taxonomy );  ?>
    2828
    2929<div class="wrap">
    3030<?php screen_icon(); ?>
     
    6767                <?php
    6868                // Back compat hooks
    6969                if ( 'category' == $taxonomy )
    70                         do_action('edit_category_form_fields', $tag);
     70                        do_deprecated_action( 'edit_category_form_fields', array( $tag ), '3.0', 'category_edit_form_fields' );
    7171                elseif ( 'link_category' == $taxonomy )
    72                         do_action('edit_link_category_form_fields', $tag);
     72                        do_deprecated_action( 'edit_link_category_form_fields', array( $tag ), '3.1', 'link_category_edit_form_fields' );
    7373                else
    74                         do_action('edit_tag_form_fields', $tag);
     74                        do_deprecated_action( 'edit_tag_form_fields', array( $tag ), '3.0', '{$taxonomy}_edit_form_fields' ); // [sic]
    7575
    76                 do_action($taxonomy . '_edit_form_fields', $tag, $taxonomy);
     76                do_action( $taxonomy . '_edit_form_fields', $tag, $taxonomy );
    7777                ?>
    7878        </table>
    7979<?php
    8080// Back compat hooks
    8181if ( 'category' == $taxonomy )
    82         do_action('edit_category_form', $tag);
     82        do_deprecated_action( 'edit_category_form', array( $tag ), '3.0', 'category_edit_form' );
    8383elseif ( 'link_category' == $taxonomy )
    84         do_action('edit_link_category_form', $tag);
     84        do_deprecated_action( 'edit_link_category_form', array( $tag ), '3.1', 'link_category_edit_form' );
    8585else
    86         do_action('edit_tag_form', $tag);
     86        do_deprecated_action( 'edit_tag_form', array( $tag ), '3.0', '{$taxonomy}_edit_form' ); // [sic]
    8787
    88 do_action($taxonomy . '_edit_form', $tag, $taxonomy);
     88do_action( $taxonomy . '_edit_form', $tag, $taxonomy );
    8989
    9090submit_button( __('Update') );
    9191?>