From 12a079e69b17540ad386dd50d7d73f60bc317451 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 13 Nov 2022 13:49:16 +0000 Subject: [PATCH] Docs: Document the usage of globals in some functions. This affects: * `the_block_editor_meta_boxes()` * `wp_generate_block_templates_export_file()` * `WP_oEmbed_Controller::get_proxy_item()` Follow-up to [44131], [48135], [51151], [53129]. Props krunal265. Fixes #57082. git-svn-id: https://develop.svn.wordpress.org/trunk@54831 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/post.php | 4 ++++ src/wp-includes/block-template-utils.php | 5 ++++- src/wp-includes/class-wp-oembed-controller.php | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 8db8861c42..65b36c4836 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -2210,6 +2210,10 @@ function get_block_editor_server_block_settings() { * Renders the meta boxes forms. * * @since 5.0.0 + * + * @global WP_Post $post Global post object. + * @global WP_Screen $current_screen WordPress current screen object. + * @global array $wp_meta_boxes */ function the_block_editor_meta_boxes() { global $post, $current_screen, $wp_meta_boxes; diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 8ecb9dfe55..b1a3172fbb 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -1200,9 +1200,13 @@ function wp_is_theme_directory_ignored( $path ) { * @since 5.9.0 * @since 6.0.0 Adds the whole theme to the export archive. * + * @global string $wp_version The WordPress version string. + * * @return WP_Error|string Path of the ZIP file or error on failure. */ function wp_generate_block_templates_export_file() { + global $wp_version; + if ( ! class_exists( 'ZipArchive' ) ) { return new WP_Error( 'missing_zip_package', __( 'Zip Export not supported.' ) ); } @@ -1270,7 +1274,6 @@ function wp_generate_block_templates_export_file() { $theme_json_raw = $tree->get_data(); // If a version is defined, add a schema. if ( $theme_json_raw['version'] ) { - global $wp_version; $theme_json_version = 'wp/' . substr( $wp_version, 0, 3 ); $schema = array( '$schema' => 'https://schemas.wp.org/' . $theme_json_version . '/theme.json' ); $theme_json_raw = array_merge( $schema, $theme_json_raw ); diff --git a/src/wp-includes/class-wp-oembed-controller.php b/src/wp-includes/class-wp-oembed-controller.php index 22fceb54a9..a36fff987d 100644 --- a/src/wp-includes/class-wp-oembed-controller.php +++ b/src/wp-includes/class-wp-oembed-controller.php @@ -160,13 +160,14 @@ final class WP_oEmbed_Controller { * @since 4.8.0 * * @see WP_oEmbed::get_html() - * @global WP_Embed $wp_embed + * @global WP_Embed $wp_embed + * @global WP_Scripts $wp_scripts * * @param WP_REST_Request $request Full data about the request. * @return object|WP_Error oEmbed response data or WP_Error on failure. */ public function get_proxy_item( $request ) { - global $wp_embed; + global $wp_embed, $wp_scripts; $args = $request->get_params(); @@ -204,7 +205,6 @@ final class WP_oEmbed_Controller { $html = $wp_embed->get_embed_handler_html( $args, $url ); if ( $html ) { - global $wp_scripts; // Check if any scripts were enqueued by the shortcode, and include them in the response. $enqueued_scripts = array();