Make WordPress Core

Ticket #39148: 39148.patch

File 39148.patch, 10.0 KB (added by keesiemeijer, 8 years ago)

Use interpolation for naming of dynamic hooks

  • src/wp-admin/edit-comments.php

     
    8383        }
    8484
    8585        if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) {
     86                $screen = get_current_screen()->id;
    8687                /**
    8788                 * Fires when a custom bulk action should be handled.
    8889                 *
    8990                 * The redirect link should be modified with success or failure feedback
    9091                 * from the action to be used to display feedback to the user.
    9192                 *
     93                 * The dynamic hook name, `$screen`, refers to the current screen ID.
     94                 *
    9295                 * @since 4.7.0
    9396                 *
    9497                 * @param string $redirect_url The redirect URL.
    9598                 * @param string $doaction     The action being taken.
    9699                 * @param array  $items        The items to take the action on.
    97100                 */
    98                 $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $comment_ids );
     101                $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids );
    99102        }
    100103
    101104        wp_defer_comment_counting( false );
  • src/wp-admin/includes/ajax-actions.php

     
    27022702                        $type = $ext_type;
    27032703
    27042704        /** This filter is documented in wp-admin/includes/media.php */
    2705         $html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text );
     2705        $html = apply_filters( "{$type}_send_to_editor_url", $html, $src, $link_text );
    27062706
    27072707        wp_send_json_success( $html );
    27082708}
  • src/wp-admin/includes/class-wp-list-table.php

     
    732732                 *
    733733                 * @param int $per_page Number of items to be displayed. Default 20.
    734734                 */
    735                 return (int) apply_filters( $option, $per_page );
     735                return (int) apply_filters( "{$option}", $per_page );
    736736        }
    737737
    738738        /**
  • src/wp-admin/includes/class-wp-screen.php

     
    11621162                        $per_page = apply_filters( 'edit_categories_per_page', $per_page );
    11631163                } else {
    11641164                        /** This filter is documented in wp-admin/includes/class-wp-list-table.php */
    1165                         $per_page = apply_filters( $option, $per_page );
     1165                        $per_page = apply_filters( "{$option}", $per_page );
    11661166                }
    11671167
    11681168                // Back compat
  • src/wp-admin/includes/plugin.php

     
    10251025                wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
    10261026                include( WP_PLUGIN_DIR . '/' . $file );
    10271027
    1028                 add_action( 'uninstall_' . $file, $callable );
     1028                add_action( "uninstall_{$file}", $callable );
    10291029
    10301030                /**
    10311031                 * Fires in uninstall_plugin() once the plugin has been uninstalled.
     
    10351035                 *
    10361036                 * @since 2.7.0
    10371037                 */
    1038                 do_action( 'uninstall_' . $file );
     1038                do_action( "uninstall_{$file}" );
    10391039        }
    10401040}
    10411041
  • src/wp-admin/network/site-themes.php

     
    124124                                check_admin_referer( 'bulk-themes' );
    125125                                $themes = (array) $_POST['checked'];
    126126                                $n = count( $themes );
     127                                $screen = get_current_screen()->id;
    127128                                /**
    128129                                 * Fires when a custom bulk action should be handled.
    129130                                 *
    130131                                 * The redirect link should be modified with success or failure feedback
    131132                                 * from the action to be used to display feedback to the user.
    132133                                 *
     134                                 * The dynamic hook name, `$screen`, refers to the current screen ID.
     135                                 *
    133136                                 * @since 4.7.0
    134137                                 *
    135138                                 * @param string $redirect_url The redirect URL.
     
    137140                                 * @param array  $items        The items to take the action on.
    138141                                 * @param int    $site_id      The site id.
    139142                                 */
    140                                 $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes, $id );
     143                                $referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id );
    141144                        } else {
    142145                                $action = 'error';
    143146                                $n = 'none';
  • src/wp-includes/author-template.php

     
    148148         * @param int      $user_id          The user ID for the value.
    149149         * @param int|bool $original_user_id The original user ID, as passed to the function.
    150150         */
    151         return apply_filters( 'get_the_author_' . $field, $value, $user_id, $original_user_id );
     151        return apply_filters( "get_the_author_{$field}", $value, $user_id, $original_user_id );
    152152}
    153153
    154154/**
     
    174174         * @param string $author_meta The value of the metadata.
    175175         * @param int    $user_id     The user ID.
    176176         */
    177         echo apply_filters( 'the_author_' . $field, $author_meta, $user_id );
     177        echo apply_filters( "the_author_{$field}", $author_meta, $user_id );
    178178}
    179179
    180180/**
  • src/wp-includes/bookmark.php

     
    383383
    384384        if ( 'edit' == $context ) {
    385385                /** This filter is documented in wp-includes/post.php */
    386                 $value = apply_filters( "edit_$field", $value, $bookmark_id );
     386                $value = apply_filters( "edit_{$field}", $value, $bookmark_id );
    387387
    388388                if ( 'link_notes' == $field ) {
    389389                        $value = esc_html( $value ); // textarea_escaped
     
    392392                }
    393393        } elseif ( 'db' == $context ) {
    394394                /** This filter is documented in wp-includes/post.php */
    395                 $value = apply_filters( "pre_$field", $value );
     395                $value = apply_filters( "pre_{$field}", $value );
    396396        } else {
    397397                /** This filter is documented in wp-includes/post.php */
    398                 $value = apply_filters( $field, $value, $bookmark_id, $context );
     398                $value = apply_filters( "{$field}", $value, $bookmark_id, $context );
    399399
    400400                if ( 'attribute' == $context ) {
    401401                        $value = esc_attr( $value );
  • src/wp-includes/class-wp-customize-setting.php

     
    480480                        return false;
    481481                }
    482482
     483                $id_base = $this->id_data['base'];
     484
    483485                /**
    484486                 * Fires when the WP_Customize_Setting::save() method is called.
    485487                 *
    486                  * The dynamic portion of the hook name, `$this->id_data['base']` refers to
     488                 * The dynamic portion of the hook name, `$id_base` refers to
    487489                 * the base slug of the setting name.
    488490                 *
    489491                 * @since 3.4.0
    490492                 *
    491493                 * @param WP_Customize_Setting $this WP_Customize_Setting instance.
    492494                 */
    493                 do_action( 'customize_save_' . $this->id_data['base'], $this );
     495                do_action( "customize_save_{$id_base}", $this );
    494496
    495497                $this->update( $value );
    496498        }
  • src/wp-includes/option.php

     
    102102                                        wp_cache_set( 'notoptions', $notoptions, 'options' );
    103103
    104104                                        /** This filter is documented in wp-includes/option.php */
    105                                         return apply_filters( 'default_option_' . $option, $default, $option, $passed_default );
     105                                        return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
    106106                                }
    107107                        }
    108108                }
     
    114114                        $value = $row->option_value;
    115115                } else {
    116116                        /** This filter is documented in wp-includes/option.php */
    117                         return apply_filters( 'default_option_' . $option, $default, $option, $passed_default );
     117                        return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
    118118                }
    119119        }
    120120
     
    300300                return false;
    301301
    302302        /** This filter is documented in wp-includes/option.php */
    303         if ( apply_filters( 'default_option_' . $option, false, $option, false ) === $old_value ) {
     303        if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) {
    304304                // Default setting for new options is 'yes'.
    305305                if ( null === $autoload ) {
    306306                        $autoload = 'yes';
     
    421421        $notoptions = wp_cache_get( 'notoptions', 'options' );
    422422        if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
    423423                /** This filter is documented in wp-includes/option.php */
    424                 if ( apply_filters( 'default_option_' . $option, false, $option, false ) !== get_option( $option ) )
     424                if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) )
    425425                        return false;
    426426
    427427        $serialized_value = maybe_serialize( $value );
  • src/wp-includes/post.php

     
    20612061                         *                        values include 'raw', 'edit', 'db', 'display',
    20622062                         *                        'attribute' and 'js'.
    20632063                         */
    2064                         $value = apply_filters( $field, $value, $post_id, $context );
     2064                        $value = apply_filters( "{$field}", $value, $post_id, $context );
    20652065                } else {
    20662066                        $value = apply_filters( "post_{$field}", $value, $post_id, $context );
    20672067                }
  • src/wp-includes/user.php

     
    12081208                if ( $prefixed ) {
    12091209
    12101210                        /** This filter is documented in wp-includes/post.php */
    1211                         $value = apply_filters( $field, $value, $user_id, $context );
     1211                        $value = apply_filters( "{$field}", $value, $user_id, $context );
    12121212                } else {
    12131213
    12141214                        /**