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.

Built from https://develop.svn.wordpress.org/trunk@38307


git-svn-id: http://core.svn.wordpress.org/trunk@38248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Drew Jaynes 2016-08-22 18:25:31 +00:00
parent 02939c03e5
commit 22adda2aa0
22 changed files with 64 additions and 64 deletions

View File

@ -83,7 +83,7 @@ do_action( 'admin_footer', '' );
*
* @param string $hook_suffix The current admin page.
*/
do_action( "admin_print_footer_scripts-$hook_suffix" );
do_action( "admin_print_footer_scripts-{$hook_suffix}" );
/**
* Prints any scripts and data queued for the footer.
@ -103,7 +103,7 @@ do_action( 'admin_print_footer_scripts' );
* @global string $hook_suffix
* @param string $hook_suffix The current admin page.
*/
do_action( "admin_footer-$hook_suffix" );
do_action( "admin_footer-{$hook_suffix}" );
// get_site_option() won't exist when auto upgrading from <= 2.7
if ( function_exists('get_site_option') ) {

View File

@ -96,7 +96,7 @@ do_action( 'admin_enqueue_scripts', $hook_suffix );
*
* @since 2.6.0
*/
do_action( "admin_print_styles-$hook_suffix" );
do_action( "admin_print_styles-{$hook_suffix}" );
/**
* Fires when styles are printed for all admin pages.
@ -110,7 +110,7 @@ do_action( 'admin_print_styles' );
*
* @since 2.1.0
*/
do_action( "admin_print_scripts-$hook_suffix" );
do_action( "admin_print_scripts-{$hook_suffix}" );
/**
* Fires when scripts are printed for all admin pages.
@ -127,7 +127,7 @@ do_action( 'admin_print_scripts' );
*
* @since 2.1.0
*/
do_action( "admin_head-$hook_suffix" );
do_action( "admin_head-{$hook_suffix}" );
/**
* Fires in head section for all admin pages.

View File

@ -209,7 +209,7 @@ if ( isset($plugin_page) ) {
*
* @since 2.1.0
*/
do_action( 'load-' . $page_hook );
do_action( "load-{$page_hook}" );
if (! isset($_GET['noheader']))
require_once(ABSPATH . 'wp-admin/admin-header.php');
@ -239,7 +239,7 @@ if ( isset($plugin_page) ) {
*
* @since 1.5.0
*/
do_action( 'load-' . $plugin_page );
do_action( "load-{$plugin_page}" );
if ( !isset($_GET['noheader']))
require_once(ABSPATH . 'wp-admin/admin-header.php');
@ -278,7 +278,7 @@ if ( isset($plugin_page) ) {
*
* @since 3.5.0
*/
do_action( 'load-importer-' . $importer );
do_action( "load-importer-{$importer}" );
$parent_file = 'tools.php';
$submenu_file = 'import.php';
@ -326,7 +326,7 @@ if ( isset($plugin_page) ) {
*
* @since 2.1.0
*/
do_action( 'load-' . $pagenow );
do_action( "load-{$pagenow}" );
/*
* The following hooks are fired to ensure backward compatibility.

View File

@ -331,7 +331,7 @@ do_action( 'add_meta_boxes', $post_type, $post );
*
* @param WP_Post $post Post object.
*/
do_action( 'add_meta_boxes_' . $post_type, $post );
do_action( "add_meta_boxes_{$post_type}", $post );
/**
* Fires after meta boxes have been added.

View File

@ -176,7 +176,7 @@ class WP_Automatic_Updater {
* @param bool $update Whether to update.
* @param object $item The update offer.
*/
$update = apply_filters( 'auto_update_' . $type, $update, $item );
$update = apply_filters( "auto_update_{$type}", $update, $item );
if ( ! $update ) {
if ( 'core' == $type )

View File

@ -518,7 +518,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
* @param WP_Theme $theme The current WP_Theme object.
* @param string $context Status of the theme.
*/
$actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context );
$actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context );
echo $this->row_actions( $actions, true );
}
@ -726,6 +726,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
* @param WP_Theme $theme Current WP_Theme object.
* @param string $status Status of the theme.
*/
do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status );
do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status );
}
}

View File

@ -200,7 +200,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
*
* @param array|bool $args Plugin Install API arguments.
*/
$args = apply_filters( "install_plugins_table_api_args_$tab", $args );
$args = apply_filters( "install_plugins_table_api_args_{$tab}", $args );
if ( !$args )
return;

View File

@ -864,7 +864,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
* 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
* 'Drop-ins', 'Search'.
*/
do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );
do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status );
}
/**

View File

@ -134,7 +134,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
*
* @param array $args An array of themes API arguments.
*/
$args = apply_filters( 'install_themes_table_api_args_' . $tab, $args );
$args = apply_filters( "install_themes_table_api_args_{$tab}", $args );
if ( ! $args )
return;

View File

@ -618,7 +618,7 @@ function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
*
* @param string $upload_iframe_src The upload iframe source URL by type.
*/
$upload_iframe_src = apply_filters( $type . '_upload_iframe_src', $upload_iframe_src );
$upload_iframe_src = apply_filters( "{$type}_upload_iframe_src", $upload_iframe_src );
return add_query_arg('TB_iframe', true, $upload_iframe_src);
}
@ -786,7 +786,7 @@ function wp_media_upload_handler() {
* @param string $src Media source URL.
* @param string $title Media title.
*/
$html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title );
$html = apply_filters( "{$type}_send_to_editor_url", $html, esc_url_raw( $src ), $title );
} else {
$align = '';
$alt = esc_attr( wp_unslash( $_POST['alt'] ) );

View File

@ -588,7 +588,7 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
* @param bool $network_wide Whether to enable the plugin for all sites in the network
* or just the current site. Multisite only. Default is false.
*/
do_action( 'activate_' . $plugin, $network_wide );
do_action( "activate_{$plugin}", $network_wide );
}
if ( $network_wide ) {
@ -701,7 +701,7 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
* @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
* or just the current site. Multisite only. Default is false.
*/
do_action( 'deactivate_' . $plugin, $network_deactivating );
do_action( "deactivate_{$plugin}", $network_deactivating );
/**
* Fires after a plugin is deactivated.

View File

@ -70,10 +70,10 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
* @param string null The context of whether the current revision is the old
* or the new one. Values are 'to' or 'from'.
*/
$content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : '';
$content_from = $compare_from ? apply_filters( "_wp_post_revision_field_{$field}", $compare_from->$field, $field, $compare_from, 'from' ) : '';
/** This filter is documented in wp-admin/includes/revision.php */
$content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' );
$content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' );
$args = array(
'show_split_view' => true

View File

@ -95,7 +95,7 @@ if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_up
*
* @since 2.5.0
*/
do_action( "media_upload_$type" );
do_action( "media_upload_{$type}" );
} else {
/**
* Fires inside limited and specific upload-tab views in the legacy
@ -107,6 +107,6 @@ if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_up
*
* @since 2.5.0
*/
do_action( "media_upload_$tab" );
do_action( "media_upload_{$tab}" );
}

View File

@ -64,7 +64,7 @@ wp_enqueue_script( 'updates' );
*
* @since 2.7.0
*/
do_action( "install_plugins_pre_$tab" );
do_action( "install_plugins_pre_{$tab}" );
/*
* Call the pre upload action on every non-upload plugin install screen
@ -155,7 +155,7 @@ if ( $tab !== 'upload' ) {
*
* @param int $paged The current page number of the plugins list table.
*/
do_action( "install_plugins_$tab", $paged ); ?>
do_action( "install_plugins_{$tab}", $paged ); ?>
<span class="spinner"></span>
</div>

View File

@ -1259,7 +1259,7 @@ function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = ''
*
* @param array $links An array of term links.
*/
$term_links = apply_filters( "term_links-$taxonomy", $links );
$term_links = apply_filters( "term_links-{$taxonomy}", $links );
return $before . join( $sep, $term_links ) . $after;
}

View File

@ -383,7 +383,7 @@ class WP_Customize_Control {
*
* @param WP_Customize_Control $this WP_Customize_Control instance.
*/
do_action( 'customize_render_control_' . $this->id, $this );
do_action( "customize_render_control_{$this->id}", $this );
$this->render();
}

View File

@ -1413,7 +1413,7 @@ class WP_Rewrite {
*
* @param array $rules The rewrite rules generated for the current permastruct.
*/
$rules = apply_filters( $permastructname . '_rewrite_rules', $rules );
$rules = apply_filters( "{$permastructname}_rewrite_rules", $rules );
if ( 'post_tag' == $permastructname ) {
/**

View File

@ -49,7 +49,7 @@ function get_option( $option, $default = false ) {
* Default false to skip it.
* @param string $option Option name.
*/
$pre = apply_filters( 'pre_option_' . $option, false, $option );
$pre = apply_filters( "pre_option_{$option}", false, $option );
if ( false !== $pre )
return $pre;
@ -72,7 +72,7 @@ function get_option( $option, $default = false ) {
* in the database.
* @param string $option Option name.
*/
return apply_filters( 'default_option_' . $option, $default, $option );
return apply_filters( "default_option_{$option}", $default, $option );
}
$alloptions = wp_load_alloptions();
@ -133,7 +133,7 @@ function get_option( $option, $default = false ) {
* unserialized prior to being returned.
* @param string $option Option name.
*/
return apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option );
return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
}
/**
@ -277,7 +277,7 @@ function update_option( $option, $value, $autoload = null ) {
* @param mixed $old_value The old option value.
* @param string $option Option name.
*/
$value = apply_filters( 'pre_update_option_' . $option, $value, $old_value, $option );
$value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option );
/**
* Filters an option before its value is (maybe) serialized and updated.
@ -534,7 +534,7 @@ function delete_option( $option ) {
*
* @param string $option Name of the deleted option.
*/
do_action( "delete_option_$option", $option );
do_action( "delete_option_{$option}", $option );
/**
* Fires after an option has been deleted.
@ -568,7 +568,7 @@ function delete_transient( $transient ) {
*
* @param string $transient Transient name.
*/
do_action( 'delete_transient_' . $transient, $transient );
do_action( "delete_transient_{$transient}", $transient );
if ( wp_using_ext_object_cache() ) {
$result = wp_cache_delete( $transient, 'transient' );
@ -624,7 +624,7 @@ function get_transient( $transient ) {
* of the transient, and return the returned value.
* @param string $transient Transient name.
*/
$pre = apply_filters( 'pre_transient_' . $transient, false, $transient );
$pre = apply_filters( "pre_transient_{$transient}", false, $transient );
if ( false !== $pre )
return $pre;
@ -661,7 +661,7 @@ function get_transient( $transient ) {
* @param mixed $value Value of transient.
* @param string $transient Transient name.
*/
return apply_filters( 'transient_' . $transient, $value, $transient );
return apply_filters( "transient_{$transient}", $value, $transient );
}
/**
@ -696,7 +696,7 @@ function set_transient( $transient, $value, $expiration = 0 ) {
* @param int $expiration Time until expiration in seconds.
* @param string $transient Transient name.
*/
$value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration, $transient );
$value = apply_filters( "pre_set_transient_{$transient}", $value, $expiration, $transient );
/**
* Filters the expiration for a transient before its value is set.
@ -709,7 +709,7 @@ function set_transient( $transient, $value, $expiration = 0 ) {
* @param mixed $value New value of transient.
* @param string $transient Transient name.
*/
$expiration = apply_filters( 'expiration_of_transient_' . $transient, $expiration, $value, $transient );
$expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient );
if ( wp_using_ext_object_cache() ) {
$result = wp_cache_set( $transient, $value, 'transient', $expiration );
@ -758,7 +758,7 @@ function set_transient( $transient, $value, $expiration = 0 ) {
* @param int $expiration Time until expiration in seconds.
* @param string $transient The name of the transient.
*/
do_action( 'set_transient_' . $transient, $value, $expiration, $transient );
do_action( "set_transient_{$transient}", $value, $expiration, $transient );
/**
* Fires after the value for a transient has been set.
@ -1106,7 +1106,7 @@ function get_network_option( $network_id, $option, $default = false ) {
* @param mixed $pre_option The default value to return if the option does not exist.
* @param string $option Option name.
*/
$pre = apply_filters( 'pre_site_option_' . $option, false, $option );
$pre = apply_filters( "pre_site_option_{$option}", false, $option );
if ( false !== $pre ) {
return $pre;
@ -1130,7 +1130,7 @@ function get_network_option( $network_id, $option, $default = false ) {
* in the database.
* @param string $option Option name.
*/
return apply_filters( 'default_site_option_' . $option, $default, $option );
return apply_filters( "default_site_option_{$option}", $default, $option );
}
if ( ! is_multisite() ) {
@ -1174,7 +1174,7 @@ function get_network_option( $network_id, $option, $default = false ) {
* @param mixed $value Value of network option.
* @param string $option Option name.
*/
return apply_filters( 'site_option_' . $option, $value, $option );
return apply_filters( "site_option_{$option}", $value, $option );
}
/**
@ -1222,7 +1222,7 @@ function add_network_option( $network_id, $option, $value ) {
* @param mixed $value Value of network option.
* @param string $option Option name.
*/
$value = apply_filters( 'pre_add_site_option_' . $option, $value, $option );
$value = apply_filters( "pre_add_site_option_{$option}", $value, $option );
$notoptions_key = "$network_id:notoptions";
@ -1271,7 +1271,7 @@ function add_network_option( $network_id, $option, $value ) {
* @param string $option Name of the network option.
* @param mixed $value Value of the network option.
*/
do_action( 'add_site_option_' . $option, $option, $value );
do_action( "add_site_option_{$option}", $option, $value );
/**
* Fires after a network option has been successfully added.
@ -1327,7 +1327,7 @@ function delete_network_option( $network_id, $option ) {
*
* @param string $option Option name.
*/
do_action( 'pre_delete_site_option_' . $option, $option );
do_action( "pre_delete_site_option_{$option}", $option );
if ( ! is_multisite() ) {
$result = delete_option( $option );
@ -1354,7 +1354,7 @@ function delete_network_option( $network_id, $option ) {
*
* @param string $option Name of the network option.
*/
do_action( 'delete_site_option_' . $option, $option );
do_action( "delete_site_option_{$option}", $option );
/**
* Fires after a network option has been deleted.
@ -1417,7 +1417,7 @@ function update_network_option( $network_id, $option, $value ) {
* @param mixed $old_value Old value of the network option.
* @param string $option Option name.
*/
$value = apply_filters( 'pre_update_site_option_' . $option, $value, $old_value, $option );
$value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option );
if ( $value === $old_value ) {
return false;
@ -1462,7 +1462,7 @@ function update_network_option( $network_id, $option, $value ) {
* @param mixed $value Current value of the network option.
* @param mixed $old_value Old value of the network option.
*/
do_action( 'update_site_option_' . $option, $option, $value, $old_value );
do_action( "update_site_option_{$option}", $option, $value, $old_value );
/**
* Fires after the value of a network option has been successfully updated.
@ -1500,7 +1500,7 @@ function delete_site_transient( $transient ) {
*
* @param string $transient Transient name.
*/
do_action( 'delete_site_transient_' . $transient, $transient );
do_action( "delete_site_transient_{$transient}", $transient );
if ( wp_using_ext_object_cache() ) {
$result = wp_cache_delete( $transient, 'site-transient' );
@ -1557,7 +1557,7 @@ function get_site_transient( $transient ) {
* of the transient, and return the returned value.
* @param string $transient Transient name.
*/
$pre = apply_filters( 'pre_site_transient_' . $transient, false, $transient );
$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
if ( false !== $pre )
return $pre;
@ -1593,7 +1593,7 @@ function get_site_transient( $transient ) {
* @param mixed $value Value of site transient.
* @param string $transient Transient name.
*/
return apply_filters( 'site_transient_' . $transient, $value, $transient );
return apply_filters( "site_transient_{$transient}", $value, $transient );
}
/**
@ -1625,7 +1625,7 @@ function set_site_transient( $transient, $value, $expiration = 0 ) {
* @param mixed $value New value of site transient.
* @param string $transient Transient name.
*/
$value = apply_filters( 'pre_set_site_transient_' . $transient, $value, $transient );
$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );
$expiration = (int) $expiration;
@ -1640,7 +1640,7 @@ function set_site_transient( $transient, $value, $expiration = 0 ) {
* @param mixed $value New value of site transient.
* @param string $transient Transient name.
*/
$expiration = apply_filters( 'expiration_of_site_transient_' . $transient, $expiration, $value, $transient );
$expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
if ( wp_using_ext_object_cache() ) {
$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
@ -1671,7 +1671,7 @@ function set_site_transient( $transient, $value, $expiration = 0 ) {
* @param int $expiration Time until expiration in seconds.
* @param string $transient Transient name.
*/
do_action( 'set_site_transient_' . $transient, $value, $expiration, $transient );
do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );
/**
* Fires after the value for a site transient has been set.

View File

@ -871,7 +871,7 @@ function get_term( $term, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) {
* @param int|WP_Term $_term Term object or ID.
* @param string $taxonomy The taxonomy slug.
*/
$_term = apply_filters( "get_$taxonomy", $_term, $taxonomy );
$_term = apply_filters( "get_{$taxonomy}", $_term, $taxonomy );
// Bail if a filter callback has changed the type of the `$_term` object.
if ( ! ( $_term instanceof WP_Term ) ) {
@ -1915,7 +1915,7 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
* by the parent function. WP_Error otherwise.
* @param array $object_ids List of term object IDs.
*/
do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids );
do_action( "delete_{$taxonomy}", $term, $tt_id, $deleted_term, $object_ids );
return true;
}
@ -2406,7 +2406,7 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
* @param int $term_id Term ID.
* @param int $tt_id Term taxonomy ID.
*/
do_action( "create_$taxonomy", $term_id, $tt_id );
do_action( "create_{$taxonomy}", $term_id, $tt_id );
/**
* Filters the term ID after a new term is created.
@ -2442,7 +2442,7 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
* @param int $term_id Term ID.
* @param int $tt_id Term taxonomy ID.
*/
do_action( "created_$taxonomy", $term_id, $tt_id );
do_action( "created_{$taxonomy}", $term_id, $tt_id );
return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
}
@ -2987,7 +2987,7 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
* @param int $term_id Term ID.
* @param int $tt_id Term taxonomy ID.
*/
do_action( "edit_$taxonomy", $term_id, $tt_id );
do_action( "edit_{$taxonomy}", $term_id, $tt_id );
/** This filter is documented in wp-includes/taxonomy.php */
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
@ -3016,7 +3016,7 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
* @param int $term_id Term ID.
* @param int $tt_id Term taxonomy ID.
*/
do_action( "edited_$taxonomy", $term_id, $tt_id );
do_action( "edited_{$taxonomy}", $term_id, $tt_id );
return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
}

View File

@ -902,7 +902,7 @@ function set_theme_mod( $name, $value ) {
* @param string $value The new value of the theme mod.
* @param string $old_value The current value of the theme mod.
*/
$mods[ $name ] = apply_filters( "pre_set_theme_mod_$name", $value, $old_value );
$mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
$theme = get_option( 'stylesheet' );
update_option( "theme_mods_$theme", $mods );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38306';
$wp_version = '4.7-alpha-38307';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -426,7 +426,7 @@ do_action( 'login_init' );
*
* @since 2.8.0
*/
do_action( 'login_form_' . $action );
do_action( "login_form_{$action}" );
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
$interim_login = isset($_REQUEST['interim-login']);