WordPress.org

Make WordPress Core

Changeset 38307


Ignore:
Timestamp:
08/22/2016 06:24:48 PM (3 years ago)
Author:
DrewAPicture
Message:

Hooks: Standardize naming of dynamic hooks to use interpolation vs concatenation.

Benefits gained in discoverability and self-documentation throughout core trump the negligible performance hit in using interpolation in hook names.

Props ramiy.
See #37748.

Location:
trunk/src
Files:
21 edited

Legend:

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

    r38022 r38307  
    8484 * @param string $hook_suffix The current admin page.
    8585 */
    86 do_action( "admin_print_footer_scripts-$hook_suffix" );
     86do_action( "admin_print_footer_scripts-{$hook_suffix}" );
    8787
    8888/**
     
    104104 * @param string $hook_suffix The current admin page.
    105105 */
    106 do_action( "admin_footer-$hook_suffix" );
     106do_action( "admin_footer-{$hook_suffix}" );
    107107
    108108// get_site_option() won't exist when auto upgrading from <= 2.7
  • trunk/src/wp-admin/admin-header.php

    r37560 r38307  
    9797 * @since 2.6.0
    9898 */
    99 do_action( "admin_print_styles-$hook_suffix" );
     99do_action( "admin_print_styles-{$hook_suffix}" );
    100100
    101101/**
     
    111111 * @since 2.1.0
    112112 */
    113 do_action( "admin_print_scripts-$hook_suffix" );
     113do_action( "admin_print_scripts-{$hook_suffix}" );
    114114
    115115/**
     
    128128 * @since 2.1.0
    129129 */
    130 do_action( "admin_head-$hook_suffix" );
     130do_action( "admin_head-{$hook_suffix}" );
    131131
    132132/**
  • trunk/src/wp-admin/admin.php

    r38015 r38307  
    210210         * @since 2.1.0
    211211         */
    212         do_action( 'load-' . $page_hook );
     212        do_action( "load-{$page_hook}" );
    213213        if (! isset($_GET['noheader']))
    214214            require_once(ABSPATH . 'wp-admin/admin-header.php');
     
    240240         * @since 1.5.0
    241241         */
    242         do_action( 'load-' . $plugin_page );
     242        do_action( "load-{$plugin_page}" );
    243243
    244244        if ( !isset($_GET['noheader']))
     
    279279     * @since 3.5.0
    280280     */
    281     do_action( 'load-importer-' . $importer );
     281    do_action( "load-importer-{$importer}" );
    282282
    283283    $parent_file = 'tools.php';
     
    327327     * @since 2.1.0
    328328     */
    329     do_action( 'load-' . $pagenow );
     329    do_action( "load-{$pagenow}" );
    330330
    331331    /*
  • trunk/src/wp-admin/edit-form-advanced.php

    r38029 r38307  
    332332 * @param WP_Post $post Post object.
    333333 */
    334 do_action( 'add_meta_boxes_' . $post_type, $post );
     334do_action( "add_meta_boxes_{$post_type}", $post );
    335335
    336336/**
  • trunk/src/wp-admin/includes/class-wp-automatic-updater.php

    r38242 r38307  
    177177         * @param object $item   The update offer.
    178178         */
    179         $update = apply_filters( 'auto_update_' . $type, $update, $item );
     179        $update = apply_filters( "auto_update_{$type}", $update, $item );
    180180
    181181        if ( ! $update ) {
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r38071 r38307  
    519519         * @param string   $context Status of the theme.
    520520         */
    521         $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context );
     521        $actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context );
    522522
    523523        echo $this->row_actions( $actions, true );
     
    727727         * @param string   $status     Status of the theme.
    728728         */
    729         do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status );
     729        do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status );
    730730    }
    731731}
  • trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php

    r38221 r38307  
    201201         * @param array|bool $args Plugin Install API arguments.
    202202         */
    203         $args = apply_filters( "install_plugins_table_api_args_$tab", $args );
     203        $args = apply_filters( "install_plugins_table_api_args_{$tab}", $args );
    204204
    205205        if ( !$args )
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r38149 r38307  
    865865         *                            'Drop-ins', 'Search'.
    866866         */
    867         do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );
     867        do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status );
    868868    }
    869869
  • trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php

    r37937 r38307  
    135135         * @param array $args An array of themes API arguments.
    136136         */
    137         $args = apply_filters( 'install_themes_table_api_args_' . $tab, $args );
     137        $args = apply_filters( "install_themes_table_api_args_{$tab}", $args );
    138138
    139139        if ( ! $args )
  • trunk/src/wp-admin/includes/media.php

    r38294 r38307  
    619619     * @param string $upload_iframe_src The upload iframe source URL by type.
    620620     */
    621     $upload_iframe_src = apply_filters( $type . '_upload_iframe_src', $upload_iframe_src );
     621    $upload_iframe_src = apply_filters( "{$type}_upload_iframe_src", $upload_iframe_src );
    622622
    623623    return add_query_arg('TB_iframe', true, $upload_iframe_src);
     
    787787             * @param string $title Media title.
    788788             */
    789             $html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title );
     789            $html = apply_filters( "{$type}_send_to_editor_url", $html, esc_url_raw( $src ), $title );
    790790        } else {
    791791            $align = '';
  • trunk/src/wp-admin/includes/plugin.php

    r38167 r38307  
    589589             *                           or just the current site. Multisite only. Default is false.
    590590             */
    591             do_action( 'activate_' . $plugin, $network_wide );
     591            do_action( "activate_{$plugin}", $network_wide );
    592592        }
    593593
     
    702702             *                                   or just the current site. Multisite only. Default is false.
    703703             */
    704             do_action( 'deactivate_' . $plugin, $network_deactivating );
     704            do_action( "deactivate_{$plugin}", $network_deactivating );
    705705
    706706            /**
  • trunk/src/wp-admin/includes/revision.php

    r37488 r38307  
    7171         *                                      or the new one. Values are 'to' or 'from'.
    7272         */
    73         $content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : '';
     73        $content_from = $compare_from ? apply_filters( "_wp_post_revision_field_{$field}", $compare_from->$field, $field, $compare_from, 'from' ) : '';
    7474
    7575        /** This filter is documented in wp-admin/includes/revision.php */
    76         $content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' );
     76        $content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' );
    7777
    7878        $args = array(
  • trunk/src/wp-admin/media-upload.php

    r37914 r38307  
    9696     * @since 2.5.0
    9797     */
    98     do_action( "media_upload_$type" );
     98    do_action( "media_upload_{$type}" );
    9999} else {
    100100    /**
     
    108108     * @since 2.5.0
    109109     */
    110     do_action( "media_upload_$tab" );
     110    do_action( "media_upload_{$tab}" );
    111111}
    112112
  • trunk/src/wp-admin/plugin-install.php

    r38172 r38307  
    6565 * @since 2.7.0
    6666 */
    67 do_action( "install_plugins_pre_$tab" );
     67do_action( "install_plugins_pre_{$tab}" );
    6868
    6969/*
     
    156156 * @param int $paged The current page number of the plugins list table.
    157157 */
    158 do_action( "install_plugins_$tab", $paged ); ?>
     158do_action( "install_plugins_{$tab}", $paged ); ?>
    159159
    160160    <span class="spinner"></span>
  • trunk/src/wp-includes/category-template.php

    r38121 r38307  
    12601260     * @param array $links An array of term links.
    12611261     */
    1262     $term_links = apply_filters( "term_links-$taxonomy", $links );
     1262    $term_links = apply_filters( "term_links-{$taxonomy}", $links );
    12631263
    12641264    return $before . join( $sep, $term_links ) . $after;
  • trunk/src/wp-includes/class-wp-customize-control.php

    r37491 r38307  
    384384         * @param WP_Customize_Control $this WP_Customize_Control instance.
    385385         */
    386         do_action( 'customize_render_control_' . $this->id, $this );
     386        do_action( "customize_render_control_{$this->id}", $this );
    387387
    388388        $this->render();
  • trunk/src/wp-includes/class-wp-rewrite.php

    r37539 r38307  
    14141414             * @param array $rules The rewrite rules generated for the current permastruct.
    14151415             */
    1416             $rules = apply_filters( $permastructname . '_rewrite_rules', $rules );
     1416            $rules = apply_filters( "{$permastructname}_rewrite_rules", $rules );
    14171417            if ( 'post_tag' == $permastructname ) {
    14181418
  • trunk/src/wp-includes/option.php

    r37985 r38307  
    5050     * @param string     $option     Option name.
    5151     */
    52     $pre = apply_filters( 'pre_option_' . $option, false, $option );
     52    $pre = apply_filters( "pre_option_{$option}", false, $option );
    5353    if ( false !== $pre )
    5454        return $pre;
     
    7373             * @param string $option  Option name.
    7474             */
    75             return apply_filters( 'default_option_' . $option, $default, $option );
     75            return apply_filters( "default_option_{$option}", $default, $option );
    7676        }
    7777
     
    134134     * @param string $option Option name.
    135135     */
    136     return apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option );
     136    return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
    137137}
    138138
     
    278278     * @param string $option    Option name.
    279279     */
    280     $value = apply_filters( 'pre_update_option_' . $option, $value, $old_value, $option );
     280    $value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option );
    281281
    282282    /**
     
    535535         * @param string $option Name of the deleted option.
    536536         */
    537         do_action( "delete_option_$option", $option );
     537        do_action( "delete_option_{$option}", $option );
    538538
    539539        /**
     
    569569     * @param string $transient Transient name.
    570570     */
    571     do_action( 'delete_transient_' . $transient, $transient );
     571    do_action( "delete_transient_{$transient}", $transient );
    572572
    573573    if ( wp_using_ext_object_cache() ) {
     
    625625     * @param string $transient     Transient name.
    626626     */
    627     $pre = apply_filters( 'pre_transient_' . $transient, false, $transient );
     627    $pre = apply_filters( "pre_transient_{$transient}", false, $transient );
    628628    if ( false !== $pre )
    629629        return $pre;
     
    662662     * @param string $transient Transient name.
    663663     */
    664     return apply_filters( 'transient_' . $transient, $value, $transient );
     664    return apply_filters( "transient_{$transient}", $value, $transient );
    665665}
    666666
     
    697697     * @param string $transient  Transient name.
    698698     */
    699     $value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration, $transient );
     699    $value = apply_filters( "pre_set_transient_{$transient}", $value, $expiration, $transient );
    700700
    701701    /**
     
    710710     * @param string $transient  Transient name.
    711711     */
    712     $expiration = apply_filters( 'expiration_of_transient_' . $transient, $expiration, $value, $transient );
     712    $expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient );
    713713
    714714    if ( wp_using_ext_object_cache() ) {
     
    759759         * @param string $transient  The name of the transient.
    760760         */
    761         do_action( 'set_transient_' . $transient, $value, $expiration, $transient );
     761        do_action( "set_transient_{$transient}", $value, $expiration, $transient );
    762762
    763763        /**
     
    11071107     * @param string $option     Option name.
    11081108     */
    1109     $pre = apply_filters( 'pre_site_option_' . $option, false, $option );
     1109    $pre = apply_filters( "pre_site_option_{$option}", false, $option );
    11101110
    11111111    if ( false !== $pre ) {
     
    11311131         * @param string $option  Option name.
    11321132         */
    1133         return apply_filters( 'default_site_option_' . $option, $default, $option );
     1133        return apply_filters( "default_site_option_{$option}", $default, $option );
    11341134    }
    11351135
     
    11751175     * @param string $option Option name.
    11761176     */
    1177     return apply_filters( 'site_option_' . $option, $value, $option );
     1177    return apply_filters( "site_option_{$option}", $value, $option );
    11781178}
    11791179
     
    12231223     * @param string $option Option name.
    12241224     */
    1225     $value = apply_filters( 'pre_add_site_option_' . $option, $value, $option );
     1225    $value = apply_filters( "pre_add_site_option_{$option}", $value, $option );
    12261226
    12271227    $notoptions_key = "$network_id:notoptions";
     
    12721272         * @param mixed  $value  Value of the network option.
    12731273         */
    1274         do_action( 'add_site_option_' . $option, $option, $value );
     1274        do_action( "add_site_option_{$option}", $option, $value );
    12751275
    12761276        /**
     
    13281328     * @param string $option Option name.
    13291329     */
    1330     do_action( 'pre_delete_site_option_' . $option, $option );
     1330    do_action( "pre_delete_site_option_{$option}", $option );
    13311331
    13321332    if ( ! is_multisite() ) {
     
    13551355         * @param string $option Name of the network option.
    13561356         */
    1357         do_action( 'delete_site_option_' . $option, $option );
     1357        do_action( "delete_site_option_{$option}", $option );
    13581358
    13591359        /**
     
    14181418     * @param string $option    Option name.
    14191419     */
    1420     $value = apply_filters( 'pre_update_site_option_' . $option, $value, $old_value, $option );
     1420    $value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option );
    14211421
    14221422    if ( $value === $old_value ) {
     
    14631463         * @param mixed  $old_value Old value of the network option.
    14641464         */
    1465         do_action( 'update_site_option_' . $option, $option, $value, $old_value );
     1465        do_action( "update_site_option_{$option}", $option, $value, $old_value );
    14661466
    14671467        /**
     
    15011501     * @param string $transient Transient name.
    15021502     */
    1503     do_action( 'delete_site_transient_' . $transient, $transient );
     1503    do_action( "delete_site_transient_{$transient}", $transient );
    15041504
    15051505    if ( wp_using_ext_object_cache() ) {
     
    15581558     * @param string $transient          Transient name.
    15591559     */
    1560     $pre = apply_filters( 'pre_site_transient_' . $transient, false, $transient );
     1560    $pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
    15611561
    15621562    if ( false !== $pre )
     
    15941594     * @param string $transient Transient name.
    15951595     */
    1596     return apply_filters( 'site_transient_' . $transient, $value, $transient );
     1596    return apply_filters( "site_transient_{$transient}", $value, $transient );
    15971597}
    15981598
     
    16261626     * @param string $transient Transient name.
    16271627     */
    1628     $value = apply_filters( 'pre_set_site_transient_' . $transient, $value, $transient );
     1628    $value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );
    16291629
    16301630    $expiration = (int) $expiration;
     
    16411641     * @param string $transient  Transient name.
    16421642     */
    1643     $expiration = apply_filters( 'expiration_of_site_transient_' . $transient, $expiration, $value, $transient );
     1643    $expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
    16441644
    16451645    if ( wp_using_ext_object_cache() ) {
     
    16721672         * @param string $transient  Transient name.
    16731673         */
    1674         do_action( 'set_site_transient_' . $transient, $value, $expiration, $transient );
     1674        do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );
    16751675
    16761676        /**
  • trunk/src/wp-includes/taxonomy.php

    r38292 r38307  
    872872     * @param string      $taxonomy The taxonomy slug.
    873873     */
    874     $_term = apply_filters( "get_$taxonomy", $_term, $taxonomy );
     874    $_term = apply_filters( "get_{$taxonomy}", $_term, $taxonomy );
    875875
    876876    // Bail if a filter callback has changed the type of the `$_term` object.
     
    19161916     * @param array   $object_ids   List of term object IDs.
    19171917     */
    1918     do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids );
     1918    do_action( "delete_{$taxonomy}", $term, $tt_id, $deleted_term, $object_ids );
    19191919
    19201920    return true;
     
    24072407     * @param int $tt_id   Term taxonomy ID.
    24082408     */
    2409     do_action( "create_$taxonomy", $term_id, $tt_id );
     2409    do_action( "create_{$taxonomy}", $term_id, $tt_id );
    24102410
    24112411    /**
     
    24432443     * @param int $tt_id   Term taxonomy ID.
    24442444     */
    2445     do_action( "created_$taxonomy", $term_id, $tt_id );
     2445    do_action( "created_{$taxonomy}", $term_id, $tt_id );
    24462446
    24472447    return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
     
    29882988     * @param int $tt_id   Term taxonomy ID.
    29892989     */
    2990     do_action( "edit_$taxonomy", $term_id, $tt_id );
     2990    do_action( "edit_{$taxonomy}", $term_id, $tt_id );
    29912991
    29922992    /** This filter is documented in wp-includes/taxonomy.php */
     
    30173017     * @param int $tt_id   Term taxonomy ID.
    30183018     */
    3019     do_action( "edited_$taxonomy", $term_id, $tt_id );
     3019    do_action( "edited_{$taxonomy}", $term_id, $tt_id );
    30203020
    30213021    return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
  • trunk/src/wp-includes/theme.php

    r37985 r38307  
    903903     * @param string $old_value The current value of the theme mod.
    904904     */
    905     $mods[ $name ] = apply_filters( "pre_set_theme_mod_$name", $value, $old_value );
     905    $mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
    906906
    907907    $theme = get_option( 'stylesheet' );
  • trunk/src/wp-login.php

    r38304 r38307  
    427427 * @since 2.8.0
    428428 */
    429 do_action( 'login_form_' . $action );
     429do_action( "login_form_{$action}" );
    430430
    431431$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
Note: See TracChangeset for help on using the changeset viewer.