From 4548b08236fa2fdc8d9443ed70e8b53f7057a151 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 14 Dec 2016 04:18:42 +0000 Subject: [PATCH] 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 Built from https://develop.svn.wordpress.org/trunk@39600 git-svn-id: http://core.svn.wordpress.org/trunk@39540 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-comments.php | 6 +++++- wp-admin/includes/ajax-actions.php | 2 +- wp-admin/includes/class-wp-list-table.php | 2 +- wp-admin/includes/class-wp-screen.php | 2 +- wp-admin/includes/plugin.php | 4 ++-- wp-admin/network/site-themes.php | 8 ++++++-- wp-includes/author-template.php | 4 ++-- wp-includes/bookmark.php | 6 +++--- wp-includes/class-wp-customize-setting.php | 6 ++++-- wp-includes/option.php | 8 ++++---- wp-includes/post.php | 2 +- wp-includes/user.php | 2 +- wp-includes/version.php | 2 +- 13 files changed, 32 insertions(+), 22 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 51afd71cb8..47244f025e 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -83,19 +83,23 @@ if ( $doaction ) { } if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) { + $screen = get_current_screen()->id; + /** * Fires when a custom bulk action should be handled. * * The redirect link should be modified with success or failure feedback * from the action to be used to display feedback to the user. * + * The dynamic portion of the hook name, `$screen`, refers to the current screen ID. + * * @since 4.7.0 * * @param string $redirect_url The redirect URL. * @param string $doaction The action being taken. * @param array $items The items to take the action on. */ - $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $comment_ids ); + $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids ); } wp_defer_comment_counting( false ); diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index ef89a6b816..660d3739f4 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -2702,7 +2702,7 @@ function wp_ajax_send_link_to_editor() { $type = $ext_type; /** This filter is documented in wp-admin/includes/media.php */ - $html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text ); + $html = apply_filters( "{$type}_send_to_editor_url", $html, $src, $link_text ); wp_send_json_success( $html ); } diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index bf642acb25..dedfec9340 100644 --- a/wp-admin/includes/class-wp-list-table.php +++ b/wp-admin/includes/class-wp-list-table.php @@ -732,7 +732,7 @@ class WP_List_Table { * * @param int $per_page Number of items to be displayed. Default 20. */ - return (int) apply_filters( $option, $per_page ); + return (int) apply_filters( "{$option}", $per_page ); } /** diff --git a/wp-admin/includes/class-wp-screen.php b/wp-admin/includes/class-wp-screen.php index a7d9a1a5c3..79d6c1e0ef 100644 --- a/wp-admin/includes/class-wp-screen.php +++ b/wp-admin/includes/class-wp-screen.php @@ -1162,7 +1162,7 @@ final class WP_Screen { $per_page = apply_filters( 'edit_categories_per_page', $per_page ); } else { /** This filter is documented in wp-admin/includes/class-wp-list-table.php */ - $per_page = apply_filters( $option, $per_page ); + $per_page = apply_filters( "{$option}", $per_page ); } // Back compat diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 9a4d0cb29b..f60489064a 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -1025,7 +1025,7 @@ function uninstall_plugin($plugin) { wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); include( WP_PLUGIN_DIR . '/' . $file ); - add_action( 'uninstall_' . $file, $callable ); + add_action( "uninstall_{$file}", $callable ); /** * Fires in uninstall_plugin() once the plugin has been uninstalled. @@ -1035,7 +1035,7 @@ function uninstall_plugin($plugin) { * * @since 2.7.0 */ - do_action( 'uninstall_' . $file ); + do_action( "uninstall_{$file}" ); } } diff --git a/wp-admin/network/site-themes.php b/wp-admin/network/site-themes.php index a500c5333f..b7b422d487 100644 --- a/wp-admin/network/site-themes.php +++ b/wp-admin/network/site-themes.php @@ -124,20 +124,24 @@ if ( $action ) { check_admin_referer( 'bulk-themes' ); $themes = (array) $_POST['checked']; $n = count( $themes ); + $screen = get_current_screen()->id; + /** * Fires when a custom bulk action should be handled. * * The redirect link should be modified with success or failure feedback * from the action to be used to display feedback to the user. * + * The dynamic portion of the hook name, `$screen`, refers to the current screen ID. + * * @since 4.7.0 * * @param string $redirect_url The redirect URL. * @param string $action The action being taken. * @param array $items The items to take the action on. - * @param int $site_id The site id. + * @param int $site_id The site ID. */ - $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes, $id ); + $referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id ); } else { $action = 'error'; $n = 'none'; diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index b2b6ea3159..5dc618b7a5 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -148,7 +148,7 @@ function get_the_author_meta( $field = '', $user_id = false ) { * @param int $user_id The user ID for the value. * @param int|bool $original_user_id The original user ID, as passed to the function. */ - return apply_filters( 'get_the_author_' . $field, $value, $user_id, $original_user_id ); + return apply_filters( "get_the_author_{$field}", $value, $user_id, $original_user_id ); } /** @@ -174,7 +174,7 @@ function the_author_meta( $field = '', $user_id = false ) { * @param string $author_meta The value of the metadata. * @param int $user_id The user ID. */ - echo apply_filters( 'the_author_' . $field, $author_meta, $user_id ); + echo apply_filters( "the_author_{$field}", $author_meta, $user_id ); } /** diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index 718760be98..cb1bee7ca3 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -383,7 +383,7 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { if ( 'edit' == $context ) { /** This filter is documented in wp-includes/post.php */ - $value = apply_filters( "edit_$field", $value, $bookmark_id ); + $value = apply_filters( "edit_{$field}", $value, $bookmark_id ); if ( 'link_notes' == $field ) { $value = esc_html( $value ); // textarea_escaped @@ -392,10 +392,10 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { } } elseif ( 'db' == $context ) { /** This filter is documented in wp-includes/post.php */ - $value = apply_filters( "pre_$field", $value ); + $value = apply_filters( "pre_{$field}", $value ); } else { /** This filter is documented in wp-includes/post.php */ - $value = apply_filters( $field, $value, $bookmark_id, $context ); + $value = apply_filters( "{$field}", $value, $bookmark_id, $context ); if ( 'attribute' == $context ) { $value = esc_attr( $value ); diff --git a/wp-includes/class-wp-customize-setting.php b/wp-includes/class-wp-customize-setting.php index 7f1f98ac3b..f89797425c 100644 --- a/wp-includes/class-wp-customize-setting.php +++ b/wp-includes/class-wp-customize-setting.php @@ -480,17 +480,19 @@ class WP_Customize_Setting { return false; } + $id_base = $this->id_data['base']; + /** * Fires when the WP_Customize_Setting::save() method is called. * - * The dynamic portion of the hook name, `$this->id_data['base']` refers to + * The dynamic portion of the hook name, `$id_base` refers to * the base slug of the setting name. * * @since 3.4.0 * * @param WP_Customize_Setting $this WP_Customize_Setting instance. */ - do_action( 'customize_save_' . $this->id_data['base'], $this ); + do_action( "customize_save_{$id_base}", $this ); $this->update( $value ); } diff --git a/wp-includes/option.php b/wp-includes/option.php index 66fb6e4fd1..fa935cec85 100644 --- a/wp-includes/option.php +++ b/wp-includes/option.php @@ -102,7 +102,7 @@ function get_option( $option, $default = false ) { wp_cache_set( 'notoptions', $notoptions, 'options' ); /** This filter is documented in wp-includes/option.php */ - return apply_filters( 'default_option_' . $option, $default, $option, $passed_default ); + return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); } } } @@ -114,7 +114,7 @@ function get_option( $option, $default = false ) { $value = $row->option_value; } else { /** This filter is documented in wp-includes/option.php */ - return apply_filters( 'default_option_' . $option, $default, $option, $passed_default ); + return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); } } @@ -309,7 +309,7 @@ function update_option( $option, $value, $autoload = null ) { } /** This filter is documented in wp-includes/option.php */ - if ( apply_filters( 'default_option_' . $option, false, $option, false ) === $old_value ) { + if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) { // Default setting for new options is 'yes'. if ( null === $autoload ) { $autoload = 'yes'; @@ -430,7 +430,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) /** This filter is documented in wp-includes/option.php */ - if ( apply_filters( 'default_option_' . $option, false, $option, false ) !== get_option( $option ) ) + if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) return false; $serialized_value = maybe_serialize( $value ); diff --git a/wp-includes/post.php b/wp-includes/post.php index d9c64f5bfe..e4d09e5a83 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2061,7 +2061,7 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { * values include 'raw', 'edit', 'db', 'display', * 'attribute' and 'js'. */ - $value = apply_filters( $field, $value, $post_id, $context ); + $value = apply_filters( "{$field}", $value, $post_id, $context ); } else { $value = apply_filters( "post_{$field}", $value, $post_id, $context ); } diff --git a/wp-includes/user.php b/wp-includes/user.php index 6f5dae67f9..3067278363 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1208,7 +1208,7 @@ function sanitize_user_field($field, $value, $user_id, $context) { if ( $prefixed ) { /** This filter is documented in wp-includes/post.php */ - $value = apply_filters( $field, $value, $user_id, $context ); + $value = apply_filters( "{$field}", $value, $user_id, $context ); } else { /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 41e8fc2a18..32bd426898 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-39599'; +$wp_version = '4.8-alpha-39600'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.