WordPress.org

Make WordPress Core

Ticket #48255: 48255-deprecated-hooks-use-the-correct-function.patch

File 48255-deprecated-hooks-use-the-correct-function.patch, 18.1 KB (added by jrf, 2 years ago)

Use the correct function for deprecated hooks

  • src/wp-admin/edit-tag-form.php

    From 2c6bed050e85deede35c183b09cc1f15660c4529 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Tue, 8 Oct 2019 03:26:47 +0200
    Subject: [PATCH] Use the correct function for deprecated hooks
    
    ---
     src/wp-admin/edit-tag-form.php                | 18 ++++++++--------
     src/wp-admin/edit-tags.php                    | 12 +++++------
     src/wp-admin/includes/class-wp-screen.php     | 21 ++++++++++++++++---
     .../includes/class-wp-terms-list-table.php    |  4 ++--
     src/wp-admin/includes/image-edit.php          |  8 +++----
     src/wp-admin/includes/media.php               |  2 +-
     src/wp-admin/includes/meta-boxes.php          |  2 +-
     src/wp-includes/class-wp-rewrite.php          |  4 ++--
     src/wp-includes/class-wp-xmlrpc-server.php    |  4 ++--
     src/wp-includes/class-wp.php                  |  7 ++++++-
     src/wp-includes/post.php                      |  4 ++--
     src/wp-includes/taxonomy.php                  |  4 ++--
     src/wp-includes/user.php                      |  2 +-
     src/wp-signup.php                             |  2 +-
     14 files changed, 57 insertions(+), 37 deletions(-)
    
    diff --git a/src/wp-admin/edit-tag-form.php b/src/wp-admin/edit-tag-form.php
    index 006c70774d..cf5c80ffa2 100644
    a b if ( 'category' == $taxonomy ) { 
    2121         *
    2222         * @param WP_Term $tag Current category term object.
    2323         */
    24         do_action( 'edit_category_form_pre', $tag );
     24        do_action_deprecated( 'edit_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
    2525} elseif ( 'link_category' == $taxonomy ) {
    2626        /**
    2727         * Fires before the Edit Link Category form.
    if ( 'category' == $taxonomy ) { 
    3131         *
    3232         * @param WP_Term $tag Current link category term object.
    3333         */
    34         do_action( 'edit_link_category_form_pre', $tag );
     34        do_action_deprecated( 'edit_link_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
    3535} else {
    3636        /**
    3737         * Fires before the Edit Tag form.
    if ( 'category' == $taxonomy ) { 
    4141         *
    4242         * @param WP_Term $tag Current tag term object.
    4343         */
    44         do_action( 'edit_tag_form_pre', $tag );
     44        do_action_deprecated( 'edit_tag_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
    4545}
    4646
    4747/**
    if ( isset( $tag->name ) ) { 
    201201                         *
    202202                         * @param WP_Term $tag Current category term object.
    203203                         */
    204                         do_action( 'edit_category_form_fields', $tag );
     204                        do_action_deprecated( 'edit_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
    205205                } elseif ( 'link_category' == $taxonomy ) {
    206206                        /**
    207207                         * Fires after the Edit Link Category form fields are displayed.
    if ( isset( $tag->name ) ) { 
    211211                         *
    212212                         * @param WP_Term $tag Current link category term object.
    213213                         */
    214                         do_action( 'edit_link_category_form_fields', $tag );
     214                        do_action_deprecated( 'edit_link_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
    215215                } else {
    216216                        /**
    217217                         * Fires after the Edit Tag form fields are displayed.
    if ( isset( $tag->name ) ) { 
    221221                         *
    222222                         * @param WP_Term $tag Current tag term object.
    223223                         */
    224                         do_action( 'edit_tag_form_fields', $tag );
     224                        do_action_deprecated( 'edit_tag_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
    225225                }
    226226                /**
    227227                 * Fires after the Edit Term form fields are displayed.
    if ( isset( $tag->name ) ) { 
    241241// Back compat hooks
    242242if ( 'category' == $taxonomy ) {
    243243        /** This action is documented in wp-admin/edit-tags.php */
    244         do_action( 'edit_category_form', $tag );
     244        do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
    245245} elseif ( 'link_category' == $taxonomy ) {
    246246        /** This action is documented in wp-admin/edit-tags.php */
    247         do_action( 'edit_link_category_form', $tag );
     247        do_action_deprecated( 'edit_link_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
    248248} else {
    249249        /**
    250250         * Fires at the end of the Edit Term form.
    if ( 'category' == $taxonomy ) { 
    254254         *
    255255         * @param WP_Term $tag Current taxonomy term object.
    256256         */
    257         do_action( 'edit_tag_form', $tag );
     257        do_action_deprecated( 'edit_tag_form', array( $tag ), '3.0.0', '{$taxonomy}_edit_form' );
    258258}
    259259/**
    260260 * Fires at the end of the Edit Term form for all taxonomies.
  • src/wp-admin/edit-tags.php

    diff --git a/src/wp-admin/edit-tags.php b/src/wp-admin/edit-tags.php
    index 80ab3ffdd8..d2cda2c633 100644
    a b if ( $can_edit_terms ) { 
    378378                 *
    379379                 * @param object $arg Optional arguments cast to an object.
    380380                 */
    381                 do_action( 'add_category_form_pre', (object) array( 'parent' => 0 ) );
     381                do_action_deprecated( 'add_category_form_pre', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_pre_add_form' );
    382382        } elseif ( 'link_category' == $taxonomy ) {
    383383                /**
    384384                 * Fires before the link category form.
    if ( $can_edit_terms ) { 
    388388                 *
    389389                 * @param object $arg Optional arguments cast to an object.
    390390                 */
    391                 do_action( 'add_link_category_form_pre', (object) array( 'parent' => 0 ) );
     391                do_action_deprecated( 'add_link_category_form_pre', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_pre_add_form' );
    392392        } else {
    393393                /**
    394394                 * Fires before the Add Tag form.
    if ( $can_edit_terms ) { 
    398398                 *
    399399                 * @param string $taxonomy The taxonomy slug.
    400400                 */
    401                 do_action( 'add_tag_form_pre', $taxonomy );
     401                do_action_deprecated( 'add_tag_form_pre', array( $taxonomy ), '3.0.0', '{$taxonomy}_pre_add_form' );
    402402        }
    403403
    404404        /**
    if ( $can_edit_terms ) { 
    534534                 *
    535535                 * @param object $arg Optional arguments cast to an object.
    536536                 */
    537                 do_action( 'edit_category_form', (object) array( 'parent' => 0 ) );
     537                do_action_deprecated( 'edit_category_form', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_add_form' );
    538538        } elseif ( 'link_category' == $taxonomy ) {
    539539                /**
    540540                 * Fires at the end of the Edit Link form.
    if ( $can_edit_terms ) { 
    544544                 *
    545545                 * @param object $arg Optional arguments cast to an object.
    546546                 */
    547                 do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) );
     547                do_action_deprecated( 'edit_link_category_form', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_add_form' );
    548548        } else {
    549549                /**
    550550                 * Fires at the end of the Add Tag form.
    if ( $can_edit_terms ) { 
    554554                 *
    555555                 * @param string $taxonomy The taxonomy slug.
    556556                 */
    557                 do_action( 'add_tag_form', $taxonomy );
     557                do_action_deprecated( 'add_tag_form', array( $taxonomy ), '3.0.0', '{$taxonomy}_add_form' );
    558558        }
    559559
    560560        /**
  • src/wp-admin/includes/class-wp-screen.php

    diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php
    index 41b20a1024..8d9a4fa072 100644
    a b final class WP_Screen { 
    775775                 * @param array     $old_compat_help Old contextual help.
    776776                 * @param WP_Screen $this            Current WP_Screen instance.
    777777                 */
    778                 self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this );
     778                self::$_old_compat_help = apply_filters_deprecated(
     779                        'contextual_help_list',
     780                        array( self::$_old_compat_help, $this ),
     781                        '3.3.0',
     782                        'get_current_screen()->add_help_tab() or get_current_screen()->remove_help_tab()'
     783                );
    779784
    780785                $old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
    781786
    final class WP_Screen { 
    790795                 * @param string    $screen_id Screen ID.
    791796                 * @param WP_Screen $this      Current WP_Screen instance.
    792797                 */
    793                 $old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
     798                $old_help = apply_filters_deprecated(
     799                        'contextual_help',
     800                        array( $old_help, $this->id, $this ),
     801                        '3.3.0',
     802                        'get_current_screen()->add_help_tab() or get_current_screen()->remove_help_tab()'
     803                );
    794804
    795805                // Default help only if there is no old-style block of text and no new-style help tabs.
    796806                if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
    final class WP_Screen { 
    804814                         *
    805815                         * @param string $old_help_default Default contextual help text.
    806816                         */
    807                         $default_help = apply_filters( 'default_contextual_help', '' );
     817                        $default_help = apply_filters_deprecated(
     818                                'default_contextual_help',
     819                                array( '' ),
     820                                '3.3.0',
     821                                'get_current_screen()->add_help_tab() or get_current_screen()->remove_help_tab()'
     822                        );
    808823                        if ( $default_help ) {
    809824                                $old_help = '<p>' . $default_help . '</p>';
    810825                        }
  • src/wp-admin/includes/class-wp-terms-list-table.php

    diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php
    index 33ef9fa8d6..a537311d40 100644
    a b class WP_Terms_List_Table extends WP_List_Table { 
    9797                         *
    9898                         * @param int $tags_per_page Number of tags to be displayed. Default 20.
    9999                         */
    100                         $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page );
     100                        $tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' );
    101101                } elseif ( 'category' === $this->screen->taxonomy ) {
    102102                        /**
    103103                         * Filters the number of terms displayed per page for the Categories list table.
    class WP_Terms_List_Table extends WP_List_Table { 
    508508                 *                          'Edit', 'Quick Edit', 'Delete', and 'View'.
    509509                 * @param WP_Term  $tag     Term object.
    510510                 */
    511                 $actions = apply_filters( 'tag_row_actions', $actions, $tag );
     511                $actions = apply_filters_deprecated( 'tag_row_actions', array( $actions, $tag ), '3.0.0', '{$taxonomy}_row_actions' );
    512512
    513513                /**
    514514                 * Filters the action links displayed for each term in the terms list table.
  • src/wp-admin/includes/image-edit.php

    diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php
    index 3d038f8391..519100acc3 100644
    a b function wp_stream_image( $image, $mime_type, $attachment_id ) { 
    292292                 * @param resource $image         Image resource to be streamed.
    293293                 * @param int      $attachment_id The attachment post ID.
    294294                 */
    295                 $image = apply_filters( 'image_save_pre', $image, $attachment_id );
     295                $image = apply_filters_deprecated( 'image_save_pre', array( $image, $attachment_id ), '3.5.0', 'image_editor_save_pre' );
    296296
    297297                switch ( $mime_type ) {
    298298                        case 'image/jpeg':
    function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { 
    353353                _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$image', 'WP_Image_Editor' ) );
    354354
    355355                /** This filter is documented in wp-admin/includes/image-edit.php */
    356                 $image = apply_filters( 'image_save_pre', $image, $post_id );
     356                $image = apply_filters_deprecated( 'image_save_pre', array( $image, $post_id ), '3.5.0', 'image_editor_save_pre' );;
    357357
    358358                /**
    359359                 * Filters whether to skip saving the image file.
    function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { 
    370370                 * @param string          $mime_type Image mime type.
    371371                 * @param int             $post_id   Post ID.
    372372                 */
    373                 $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id );
     373                $saved = apply_filters_deprecated( 'wp_save_image_file', array( null, $filename, $image, $mime_type, $post_id ), '3.5.0', 'wp_save_image_editor_file' );
    374374
    375375                if ( null !== $saved ) {
    376376                        return $saved;
    function image_edit_apply_changes( $image, $changes ) { 
    570570                 * @param resource $image   GD image resource.
    571571                 * @param array    $changes Array of change operations.
    572572                 */
    573                 $image = apply_filters( 'image_edit_before_change', $image, $changes );
     573                $image = apply_filters_deprecated( 'image_edit_before_change', array( $image, $changes ), '3.5.0', 'wp_image_editor_before_change' );
    574574        }
    575575
    576576        foreach ( $changes as $operation ) {
  • src/wp-admin/includes/media.php

    diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
    index b9e9acc99d..9838019ce4 100644
    a b function media_buttons( $editor_id = 'content' ) { 
    652652         *
    653653         * @param string $string Media buttons context. Default empty.
    654654         */
    655         $legacy_filter = apply_filters( 'media_buttons_context', '' );
     655        $legacy_filter = apply_filters_deprecated( 'media_buttons_context', array( '' ), '3.5.0', 'media_buttons' );
    656656
    657657        if ( $legacy_filter ) {
    658658                // #WP22559. Close <a> if a plugin started by closing <a> to open their own <a> tag.
  • src/wp-admin/includes/meta-boxes.php

    diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php
    index 7c5d72570c..4cf7378501 100644
    a b function register_and_do_post_meta_boxes( $post ) { 
    15081508         *
    15091509         * @param WP_Post $post Post object.
    15101510         */
    1511         do_action( 'dbx_post_advanced', $post );
     1511        do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' );
    15121512
    15131513        // Allow the Discussion meta box to show up if the post type supports comments,
    15141514        // or if comments or pings are open.
  • src/wp-includes/class-wp-rewrite.php

    diff --git a/src/wp-includes/class-wp-rewrite.php b/src/wp-includes/class-wp-rewrite.php
    index bc96c083dc..f73617e066 100644
    a b class WP_Rewrite { 
    14111411                                 *
    14121412                                 * @param array $rules The rewrite rules generated for tags.
    14131413                                 */
    1414                                 $rules = apply_filters( 'tag_rewrite_rules', $rules );
     1414                                $rules = apply_filters_deprecated( 'tag_rewrite_rules', array( $rules ), '3.1.0', 'post_tag_rewrite_rules' );
    14151415                        }
    14161416
    14171417                        $this->extra_rules_top = array_merge( $this->extra_rules_top, $rules );
    class WP_Rewrite { 
    15601560                 *
    15611561                 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
    15621562                 */
    1563                 return apply_filters( 'rewrite_rules', $rules );
     1563                return apply_filters_deprecated( 'rewrite_rules', array( $rules ), '1.5.0', 'mod_rewrite_rules' );
    15641564        }
    15651565
    15661566        /**
  • src/wp-includes/class-wp-xmlrpc-server.php

    diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php
    index abef0329ef..377efd0463 100644
    a b class wp_xmlrpc_server extends IXR_Server { 
    235235                 * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc'
    236236                 * option was deprecated in 3.5.0. Use the 'xmlrpc_enabled' hook instead.
    237237                 */
    238                 $enabled = apply_filters( 'pre_option_enable_xmlrpc', false );
     238                $enabled = apply_filters_deprecated( 'pre_option_enable_xmlrpc', array( false ), '3.5.0', 'xmlrpc_enabled' );
    239239                if ( false === $enabled ) {
    240                         $enabled = apply_filters( 'option_enable_xmlrpc', true );
     240                        $enabled = apply_filters_deprecated( 'option_enable_xmlrpc', array( true ), '3.5.0', 'xmlrpc_enabled' );
    241241                }
    242242
    243243                /**
  • src/wp-includes/class-wp.php

    diff --git a/src/wp-includes/class-wp.php b/src/wp-includes/class-wp.php
    index 59f1a90dbb..0772426773 100644
    a b class WP { 
    546546                         *
    547547                         * @param string $query_string The query string to modify.
    548548                         */
    549                         $this->query_string = apply_filters( 'query_string', $this->query_string );
     549                        $this->query_string = apply_filters_deprecated(
     550                                'query_string',
     551                                array( $this->query_string ),
     552                                '2.1.0',
     553                                'query_vars or request'
     554                        );
    550555                        parse_str( $this->query_string, $this->query_vars );
    551556                }
    552557        }
  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index eb98238d5e..2a598fc2fb 100644
    a b function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, 
    63256325                 *
    63266326                 * @param string $cap Capability.
    63276327                 */
    6328                 $cap = apply_filters( 'pub_priv_sql_capability', '' );
     6328                $cap = apply_filters_deprecated( 'pub_priv_sql_capability', array( '' ), '3.2.0' );
    63296329                if ( ! $cap ) {
    63306330                        $cap = current_user_can( $post_type_obj->cap->read_private_posts );
    63316331                }
    function _transition_post_status( $new_status, $old_status, $post ) { 
    67346734                 *
    67356735                 * @param int $post_id Post ID.
    67366736                 */
    6737                 do_action( 'private_to_published', $post->ID );
     6737                do_action_deprecated( 'private_to_published', array( $post->ID ), '2.3.0', 'private_to_publish' );
    67386738        }
    67396739
    67406740        // If published posts changed clear the lastpostmodified cache.
  • src/wp-includes/taxonomy.php

    diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
    index 4631a534dd..e861d921f5 100644
    a b function get_term_link( $term, $taxonomy = '' ) { 
    42494249                 * @param string $termlink Tag link URL.
    42504250                 * @param int    $term_id  Term ID.
    42514251                 */
    4252                 $termlink = apply_filters( 'tag_link', $termlink, $term->term_id );
     4252                $termlink = apply_filters_deprecated( 'tag_link', array( $termlink, $term->term_id ), '2.5.0', 'term_link' );
    42534253        } elseif ( 'category' === $taxonomy ) {
    42544254
    42554255                /**
    function get_term_link( $term, $taxonomy = '' ) { 
    42614261                 * @param string $termlink Category link URL.
    42624262                 * @param int    $term_id  Term ID.
    42634263                 */
    4264                 $termlink = apply_filters( 'category_link', $termlink, $term->term_id );
     4264                $termlink = apply_filters_deprecated( 'category_link', array( $termlink, $term->term_id ), '2.5.0', 'term_link' );
    42654265        }
    42664266
    42674267        /**
  • src/wp-includes/user.php

    diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
    index 505048e57a..6c3a5fe85d 100644
    a b function get_password_reset_key( $user ) { 
    22722272         *
    22732273         * @param string $user_login The user login name.
    22742274         */
    2275         do_action( 'retreive_password', $user->user_login );
     2275        do_action_deprecated( 'retreive_password', array( $user->user_login ), '1.5.1', 'retrieve_password' );
    22762276
    22772277        /**
    22782278         * Fires before a new password is retrieved.
  • src/wp-signup.php

    diff --git a/src/wp-signup.php b/src/wp-signup.php
    index 8457c7059e..fc38eac6c9 100644
    a b function validate_another_blog_signup() { 
    457457         *
    458458         * @param array $blog_meta_defaults An array of default blog meta variables.
    459459         */
    460         $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults );
     460        $meta_defaults = apply_filters_deprecated( 'signup_create_blog_meta', array( $blog_meta_defaults ), '3.0.0', 'add_signup_meta' );
    461461
    462462        /**
    463463         * Filters the new default site meta variables.