Skip to content

Commit ca92da2

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

12 files changed

Lines changed: 31 additions & 21 deletions

src/wp-admin/edit-comments.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,23 @@
8383
}
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.
8890
*
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.
9193
*
94+
* The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
95+
*
9296
* @since 4.7.0
9397
*
9498
* @param string $redirect_url The redirect URL.
9599
* @param string $doaction The action being taken.
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

101105
wp_defer_comment_counting( false );

src/wp-admin/includes/ajax-actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,7 @@ function wp_ajax_send_link_to_editor() {
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ protected function get_items_per_page( $option, $default = 20 ) {
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ public function render_per_page_options() {
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ function uninstall_plugin($plugin) {
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.
@@ -1035,7 +1035,7 @@ function uninstall_plugin($plugin) {
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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,24 @@
124124
check_admin_referer( 'bulk-themes' );
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.
129131
*
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.
132134
*
135+
* The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
136+
*
133137
* @since 4.7.0
134138
*
135139
* @param string $redirect_url The redirect URL.
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';
143147
$n = 'none';

src/wp-includes/author-template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function get_the_author_meta( $field = '', $user_id = false ) {
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
/**
@@ -174,7 +174,7 @@ function the_author_meta( $field = '', $user_id = false ) {
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) {
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
@@ -392,10 +392,10 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) {
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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,17 +480,19 @@ final public function save() {
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function get_option( $option, $default = false ) {
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
}
@@ -114,7 +114,7 @@ function get_option( $option, $default = false ) {
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

@@ -309,7 +309,7 @@ function update_option( $option, $value, $autoload = null ) {
309309
}
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 ) {
315315
$autoload = 'yes';
@@ -430,7 +430,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
430430
$notoptions = wp_cache_get( 'notoptions', 'options' );
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

436436
$serialized_value = maybe_serialize( $value );

0 commit comments

Comments
 (0)