Skip to content

Commit b4fca4a

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38307 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f9491ed commit b4fca4a

21 files changed

Lines changed: 63 additions & 63 deletions

src/wp-admin/admin-footer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
*
8484
* @param string $hook_suffix The current admin page.
8585
*/
86-
do_action( "admin_print_footer_scripts-$hook_suffix" );
86+
do_action( "admin_print_footer_scripts-{$hook_suffix}" );
8787

8888
/**
8989
* Prints any scripts and data queued for the footer.
@@ -103,7 +103,7 @@
103103
* @global string $hook_suffix
104104
* @param string $hook_suffix The current admin page.
105105
*/
106-
do_action( "admin_footer-$hook_suffix" );
106+
do_action( "admin_footer-{$hook_suffix}" );
107107

108108
// get_site_option() won't exist when auto upgrading from <= 2.7
109109
if ( function_exists('get_site_option') ) {

src/wp-admin/admin-header.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
*
9797
* @since 2.6.0
9898
*/
99-
do_action( "admin_print_styles-$hook_suffix" );
99+
do_action( "admin_print_styles-{$hook_suffix}" );
100100

101101
/**
102102
* Fires when styles are printed for all admin pages.
@@ -110,7 +110,7 @@
110110
*
111111
* @since 2.1.0
112112
*/
113-
do_action( "admin_print_scripts-$hook_suffix" );
113+
do_action( "admin_print_scripts-{$hook_suffix}" );
114114

115115
/**
116116
* Fires when scripts are printed for all admin pages.
@@ -127,7 +127,7 @@
127127
*
128128
* @since 2.1.0
129129
*/
130-
do_action( "admin_head-$hook_suffix" );
130+
do_action( "admin_head-{$hook_suffix}" );
131131

132132
/**
133133
* Fires in head section for all admin pages.

src/wp-admin/admin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
*
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');
215215

@@ -239,7 +239,7 @@
239239
*
240240
* @since 1.5.0
241241
*/
242-
do_action( 'load-' . $plugin_page );
242+
do_action( "load-{$plugin_page}" );
243243

244244
if ( !isset($_GET['noheader']))
245245
require_once(ABSPATH . 'wp-admin/admin-header.php');
@@ -278,7 +278,7 @@
278278
*
279279
* @since 3.5.0
280280
*/
281-
do_action( 'load-importer-' . $importer );
281+
do_action( "load-importer-{$importer}" );
282282

283283
$parent_file = 'tools.php';
284284
$submenu_file = 'import.php';
@@ -326,7 +326,7 @@
326326
*
327327
* @since 2.1.0
328328
*/
329-
do_action( 'load-' . $pagenow );
329+
do_action( "load-{$pagenow}" );
330330

331331
/*
332332
* The following hooks are fired to ensure backward compatibility.

src/wp-admin/edit-form-advanced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
*
332332
* @param WP_Post $post Post object.
333333
*/
334-
do_action( 'add_meta_boxes_' . $post_type, $post );
334+
do_action( "add_meta_boxes_{$post_type}", $post );
335335

336336
/**
337337
* Fires after meta boxes have been added.

src/wp-admin/includes/class-wp-automatic-updater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function should_update( $type, $item, $context ) {
176176
* @param bool $update Whether to update.
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 ) {
182182
if ( 'core' == $type )

src/wp-admin/includes/class-wp-ms-themes-list-table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public function column_name( $theme ) {
518518
* @param WP_Theme $theme The current WP_Theme object.
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 );
524524
}
@@ -726,6 +726,6 @@ public function single_row( $theme ) {
726726
* @param WP_Theme $theme Current WP_Theme object.
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
}

src/wp-admin/includes/class-wp-plugin-install-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function prepare_items() {
200200
*
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 )
206206
return;

src/wp-admin/includes/class-wp-plugins-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ public function single_row( $item ) {
864864
* 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
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

870870
/**

src/wp-admin/includes/class-wp-theme-install-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function prepare_items() {
134134
*
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 )
140140
return;

src/wp-admin/includes/media.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
618618
*
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);
624624
}
@@ -786,7 +786,7 @@ function wp_media_upload_handler() {
786786
* @param string $src Media source URL.
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 = '';
792792
$alt = esc_attr( wp_unslash( $_POST['alt'] ) );

0 commit comments

Comments
 (0)