Make WordPress Core

Ticket #17559: deprecated_hook.diff

File deprecated_hook.diff, 9.3 KB (added by nacin, 14 years ago)
  • wp-signup.php

     
    211211
    212212        $public = (int) $_POST['blog_public'];
    213213        $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // deprecated
     214        if ( has_filter( 'signup_create_blog_meta' ) )
     215                _deprecated_hook( 'signup_create_blog_meta', '0.0', 'add_signup_meta' );
    214216        $meta = apply_filters( 'add_signup_meta', $meta );
    215217
    216218        wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
  • wp-login.php

     
    195195        $user_email = $user_data->user_email;
    196196
    197197        do_action('retreive_password', $user_login);  // Misspelled and deprecated
     198        if ( has_action( 'retreive_password' ) )
     199                _deprecated_hook('retreive_password', '0.0', 'retrieve_password');
    198200        do_action('retrieve_password', $user_login);
    199201
    200202        $allow = apply_filters('allow_password_reset', true, $user_data->ID);
  • wp-includes/post.php

     
    41034103        if ( ! $post_type_obj )
    41044104                return ' 1 = 0 ';
    41054105
     4106        if ( has_filter( 'pub_priv_sql_capability' ) )
     4107                _deprecated_hook( 'pub_priv_sql_capability', '3.2' );
     4108
    41064109        // This hook is deprecated. Why you'd want to use it, I dunno.
    41074110        if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) )
    41084111                $cap = $post_type_obj->cap->read_private_posts;
  • 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 *
     
    34783479}
    34793480
    34803481/**
     3482 * Marks a hook as deprecated and informs when it has been used.
     3483 *
     3484 * There is a hook deprecated_hook_used that will be called that can be used
     3485 * to get the backtrace up to what file and function was used for the callback.
     3486 *
     3487 * The current behavior is to trigger a user error if WP_DEBUG is true.
     3488 *
     3489 * This function is to be used for every hook that is deprecated, when any callback is
     3490 * attacked to the hook, as determined by has_action() or has_filter(), and shall be
     3491 * called before the hook is fired.
     3492 *
     3493 * @package WordPress
     3494 * @subpackage Debug
     3495 * @since 2.5.0
     3496 * @access private
     3497 *
     3498 * @uses do_action() Calls 'deprecated_hook_used' and passes the hook name, what to use instead,
     3499 *   the version in which the file was deprecated, and any message regarding the change.
     3500 * @uses apply_filters() Calls 'deprecated_hook_trigger_error' and expects boolean value of true to do
     3501 *   trigger or false to not trigger error.
     3502 *
     3503 * @param string $file The hook that was used
     3504 * @param string $version The version of WordPress that deprecated the hook
     3505 * @param string $replacement Optional. The hook that should have been used
     3506 * @param string $message Optional. A message regarding the change
     3507 */
     3508function _deprecated_hook( $hook, $version, $replacement = null, $message = '' ) {
     3509
     3510        do_action( 'deprecated_hook_used', $hook, $replacement, $version, $message );
     3511
     3512        // Allow plugin to filter the output error trigger
     3513        if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) {
     3514                $message = empty( $message ) ? '' : ' ' . $message;
     3515                if ( ! is_null( $replacement ) )
     3516                        trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );
     3517                else
     3518                        trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
     3519        }
     3520}
     3521
     3522/**
    34813523 * Marks something as being incorrectly called.
    34823524 *
    34833525 * There is a hook doing_it_wrong_run that will be called that can be used
  • 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                        _deprecated_hook( 'query_string', '3.2', 'request' );
    400401                        $this->query_string = apply_filters('query_string', $this->query_string);
    401402                        parse_str($this->query_string, $this->query_vars);
    402403                }
  • wp-admin/edit-tags.php

     
    311311
    312312if ( current_user_can($tax->cap->edit_terms) ) {
    313313        // Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form
    314         if ( 'category' == $taxonomy )
     314        if ( 'category' == $taxonomy && has_action( 'add_category_form_pre' ) ) {
     315                _deprecated_hook( 'add_category_form_pre', '3.0', 'category_pre_add_form' );
    315316                do_action('add_category_form_pre', (object)array('parent' => 0) );
    316         elseif ( 'link_category' == $taxonomy )
     317        } elseif ( 'link_category' == $taxonomy && has_action( 'add_link_category_form_pre' ) ) {
     318                _deprecated_hook( 'add_link_category_form_pre', '3.1', 'link_category_pre_add_form' );
    317319                do_action('add_link_category_form_pre', (object)array('parent' => 0) );
    318         else
     320        } elseif ( has_action( 'add_tag_form_pre' ) ) {
     321                _deprecated_hook( 'add_tag_form_pre', '3.0', '{$taxonomy}_pre_add_form' ); // [sic]
    319322                do_action('add_tag_form_pre', $taxonomy);
     323        }
    320324
    321325        do_action($taxonomy . '_pre_add_form', $taxonomy);
    322326?>
     
    365369submit_button( $tax->labels->add_new_item, 'button' );
    366370
    367371// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form
    368 if ( 'category' == $taxonomy )
     372if ( 'category' == $taxonomy && has_action( 'edit_category_form' ) ) {
     373        _deprecated_hook( 'edit_category_form', '3.0', 'category_add_form' );
    369374        do_action('edit_category_form', (object)array('parent' => 0) );
    370 elseif ( 'link_category' == $taxonomy )
     375} elseif ( 'link_category' == $taxonomy && has_action( 'edit_link_category_form' ) ) {
     376        _deprecated_hook( 'edit_link_category_form', '3.1', 'link_category_add_form' );
    371377        do_action('edit_link_category_form', (object)array('parent' => 0) );
    372 else
     378} elseif ( has_action( 'add_tag_form' ) ) {
     379        _deprecated_hook( 'add_tag_form', '3.0', '{$taxonomy}_add_form' ); // [sic]
    373380        do_action('add_tag_form', $taxonomy);
     381}
    374382
    375383do_action($taxonomy . '_add_form', $taxonomy);
    376384?>
  • wp-admin/edit-tag-form.php

     
    1717}
    1818
    1919// Back compat hooks
    20 if ( 'category' == $taxonomy )
     20if ( 'category' == $taxonomy && has_action( 'edit_category_form_pre' ) ) {
     21        _deprecated_hook( 'edit_category_form_pre', '3.0', 'category_pre_edit_form' );
    2122        do_action('edit_category_form_pre', $tag );
    22 elseif ( 'link_category' == $taxonomy )
     23} elseif ( 'link_category' == $taxonomy && has_action( 'edit_link_category_form_pre' ) ) {
     24        _deprecated_hook( 'edit_link_category_form_pre', '3.1', 'link_category_pre_edit_form' );
    2325        do_action('edit_link_category_form_pre', $tag );
    24 else
     26} elseif ( has_action( 'edit_tag_form_pre' ) ) {
     27        _deprecated_hook( 'edit_tag_form_pre', '3.0', '{$taxonomy}_pre_edit_form' );
    2528        do_action('edit_tag_form_pre', $tag);
     29}
    2630
    2731do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy);  ?>
    2832
     
    6670                </tr>
    6771                <?php
    6872                // Back compat hooks
    69                 if ( 'category' == $taxonomy )
     73                if ( 'category' == $taxonomy && has_action( 'edit_category_form_fields' ) ) {
     74                        _deprecated_hook( 'edit_category_form_fields', '3.0', 'category_edit_form_fields' );
    7075                        do_action('edit_category_form_fields', $tag);
    71                 elseif ( 'link_category' == $taxonomy )
     76                } elseif ( 'link_category' == $taxonomy && has_action( 'edit_link_category_form_fields' ) ) {
     77                        _deprecated_hook( 'edit_link_category_form_fields', '3.1', 'link_category_edit_form_fields' );
    7278                        do_action('edit_link_category_form_fields', $tag);
    73                 else
     79                } elseif ( has_action( 'edit_tag_form_fields' ) ) {
     80                        _deprecated_hook( 'edit_tag_form_fields', '3.0', '{$taxonomy}_edit_form_fields' ); // [sic]
    7481                        do_action('edit_tag_form_fields', $tag);
     82                }
    7583
    7684                do_action($taxonomy . '_edit_form_fields', $tag, $taxonomy);
    7785                ?>
    7886        </table>
    7987<?php
    8088// Back compat hooks
    81 if ( 'category' == $taxonomy )
     89if ( 'category' == $taxonomy && has_action( 'edit_category_form' ) ) {
     90        _deprecated_hook( 'edit_category_form', '3.0', 'category_edit_form' );
    8291        do_action('edit_category_form', $tag);
    83 elseif ( 'link_category' == $taxonomy )
     92} elseif ( 'link_category' == $taxonomy && has_action( 'edit_link_category_form' ) ) {
     93        _deprecated_hook( 'edit_link_category_form', '3.1', 'link_category_edit_form' );
    8494        do_action('edit_link_category_form', $tag);
    85 else
     95} elseif ( has_action( 'edit_tag_form' ) ) {
     96        _deprecated_hook( 'edit_tag_form', '3.0', '{$taxonomy}_edit_form' ); // [sic]
    8697        do_action('edit_tag_form', $tag);
     98}
    8799
    88100do_action($taxonomy . '_edit_form', $tag, $taxonomy);
    89101