Make WordPress Core

Changeset 39600


Ignore:
Timestamp:
12/14/2016 04:17:38 AM (8 years ago)
Author:
johnbillion
Message:

General: Use interpolation instead of concatenation for all dynamic hook names.

This fixes the rendering of the hook names on developer.wordpress.org.

Props keesiemeijer
Fixes #39148

Location:
trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-comments.php

    r39552 r39600  
    8484
    8585    if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) {
     86        $screen = get_current_screen()->id;
     87
    8688        /**
    8789         * Fires when a custom bulk action should be handled.
     
    8991         * The redirect link should be modified with success or failure feedback
    9092         * from the action to be used to display feedback to the user.
     93         *
     94         * The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
    9195         *
    9296         * @since 4.7.0
     
    96100         * @param array  $items        The items to take the action on.
    97101         */
    98         $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $comment_ids );
     102        $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids );
    99103    }
    100104
  • trunk/src/wp-admin/includes/ajax-actions.php

    r39326 r39600  
    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 );
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r38672 r39600  
    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
  • trunk/src/wp-admin/includes/class-wp-screen.php

    r37488 r39600  
    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
  • trunk/src/wp-admin/includes/plugin.php

    r38687 r39600  
    10261026        include( WP_PLUGIN_DIR . '/' . $file );
    10271027
    1028         add_action( 'uninstall_' . $file, $callable );
     1028        add_action( "uninstall_{$file}", $callable );
    10291029
    10301030        /**
     
    10361036         * @since 2.7.0
    10371037         */
    1038         do_action( 'uninstall_' . $file );
     1038        do_action( "uninstall_{$file}" );
    10391039    }
    10401040}
  • trunk/src/wp-admin/network/site-themes.php

    r38957 r39600  
    125125                $themes = (array) $_POST['checked'];
    126126                $n = count( $themes );
     127                $screen = get_current_screen()->id;
     128
    127129                /**
    128130                 * Fires when a custom bulk action should be handled.
     
    130132                 * The redirect link should be modified with success or failure feedback
    131133                 * from the action to be used to display feedback to the user.
     134                 *
     135                 * The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
    132136                 *
    133137                 * @since 4.7.0
     
    136140                 * @param string $action       The action being taken.
    137141                 * @param array  $items        The items to take the action on.
    138                  * @param int    $site_id      The site id.
     142                 * @param int    $site_id      The site ID.
    139143                 */
    140                 $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes, $id );
     144                $referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id );
    141145            } else {
    142146                $action = 'error';
  • trunk/src/wp-includes/author-template.php

    r38341 r39600  
    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
     
    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
  • trunk/src/wp-includes/bookmark.php

    r39188 r39600  
    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 ) {
     
    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 ) {
  • trunk/src/wp-includes/class-wp-customize-setting.php

    r39318 r39600  
    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         *
     
    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 );
  • trunk/src/wp-includes/option.php

    r39564 r39600  
    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            }
     
    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    }
     
    310310
    311311    /** This filter is documented in wp-includes/option.php */
    312     if ( apply_filters( 'default_option_' . $option, false, $option, false ) === $old_value ) {
     312    if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) {
    313313        // Default setting for new options is 'yes'.
    314314        if ( null === $autoload ) {
     
    431431    if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
    432432        /** This filter is documented in wp-includes/option.php */
    433         if ( apply_filters( 'default_option_' . $option, false, $option, false ) !== get_option( $option ) )
     433        if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) )
    434434            return false;
    435435
  • trunk/src/wp-includes/post.php

    r39598 r39600  
    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 );
  • trunk/src/wp-includes/user.php

    r39486 r39600  
    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
Note: See TracChangeset for help on using the changeset viewer.