From 362dd8172aae17e96faeed1176b80815bf9e04be Mon Sep 17 00:00:00 2001 From: noruzzamanrubel Date: Wed, 4 Feb 2026 20:59:56 +0600 Subject: [PATCH 1/7] Docs: Systematically add missing @global annotations for global variables **Trac Ticket:** https://core.trac.wordpress.org/ticket/64224 **Why this change?** This change adds missing @global documentation tags to functions in - src/wp-admin/includes/misc.php - src/wp-admin/includes/template.php - src/wp-admin/includes/schema.php - src/wp-admin/install.php This aligns the codebase with the WordPress PHP Documentation Standards, ensuring that global variables used within functions are properly documented for better static analysis and code clarity. Files Changed: - src/wp-admin/includes/misc.php - src/wp-admin/includes/template.php - src/wp-admin/includes/schema.php - src/wp-admin/install.php --- src/wp-admin/includes/misc.php | 3 +++ src/wp-admin/includes/schema.php | 4 ++-- src/wp-admin/includes/template.php | 2 ++ src/wp-admin/install.php | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 6c00a0ffb1951..d5a861638a2e7 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -492,6 +492,9 @@ function wp_make_plugin_file_tree( $plugin_editable_files ) { * @since 4.9.0 * @access private * + * @global string $file Path to the file being edited. + * @global string $plugin Path to the plugin file relative to the plugins directory. + * * @param array|string $tree List of file/folder paths, or filename. * @param string $label Name of file or folder to print. * @param int $level The aria-level for the current iteration. diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 9ef4078f89054..7c762991b03bf 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -12,8 +12,8 @@ * Declare these as global in case schema.php is included from a function. * * @global wpdb $wpdb WordPress database abstraction object. - * @global array $wp_queries - * @global string $charset_collate + * @global array $wp_queries Global database queries array. + * @global string $charset_collate Database charset and collation. */ global $wpdb, $wp_queries, $charset_collate; diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index b50ebc8c76678..1f8e3a6edbddd 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1628,6 +1628,8 @@ function do_accordion_sections( $screen, $context, $data_object ) { * @type string $after_section HTML content to append to the section's HTML output. Default empty. * @type string $section_class The class name to use for the section. Default empty. * } + * + * @global array $wp_settings_sections Global settings sections array. */ function add_settings_section( $id, $title, $callback, $page, $args = array() ) { global $wp_settings_sections; diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php index 7fcacab9bd6c9..8083e55fc115c 100644 --- a/src/wp-admin/install.php +++ b/src/wp-admin/install.php @@ -342,6 +342,7 @@ function display_setup_form( $error = null ) { /** * @global string $wp_local_package Locale code of the package. * @global WP_Locale $wp_locale WordPress date and time locale object. + * @global wpdb $wpdb WordPress database abstraction object. */ $language = ''; if ( ! empty( $_REQUEST['language'] ) ) { From 607af7b63f0a315f063ed98b575307ee11aad728 Mon Sep 17 00:00:00 2001 From: noruzzamanrubel Date: Wed, 4 Feb 2026 21:09:26 +0600 Subject: [PATCH 2/7] Docs: Add missing @global annotations in Twenty Eleven theme and core --- src/wp-content/themes/twentyeleven/content-featured.php | 3 +++ src/wp-content/themes/twentyeleven/functions.php | 4 ++++ src/wp-content/themes/twentyeleven/header.php | 4 ++++ src/wp-content/themes/twentyeleven/showcase.php | 3 +++ src/wp-includes/abilities.php | 2 ++ 5 files changed, 16 insertions(+) diff --git a/src/wp-content/themes/twentyeleven/content-featured.php b/src/wp-content/themes/twentyeleven/content-featured.php index b49f680454902..b1355706dfacf 100644 --- a/src/wp-content/themes/twentyeleven/content-featured.php +++ b/src/wp-content/themes/twentyeleven/content-featured.php @@ -7,6 +7,9 @@ * @since Twenty Eleven 1.0 */ +/** + * @global string $feature_class CSS classes for the article element. + */ global $feature_class; ?>
> diff --git a/src/wp-content/themes/twentyeleven/functions.php b/src/wp-content/themes/twentyeleven/functions.php index 900c1f2cf23c0..8bd2b24127368 100644 --- a/src/wp-content/themes/twentyeleven/functions.php +++ b/src/wp-content/themes/twentyeleven/functions.php @@ -636,6 +636,8 @@ function twentyeleven_widgets_init() { * * @since Twenty Eleven 1.0 * + * @global WP_Query $wp_query WordPress query object. + * * @param string $html_id The HTML id attribute. */ function twentyeleven_content_nav( $html_id ) { @@ -756,6 +758,8 @@ function twentyeleven_footer_sidebar_class() { * @param WP_Comment $comment The comment object. * @param array $args An array of comment arguments. @see get_comment_reply_link() * @param int $depth The depth of the comment. + * + * @global WP_Comment $comment Global comment object. */ function twentyeleven_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; diff --git a/src/wp-content/themes/twentyeleven/header.php b/src/wp-content/themes/twentyeleven/header.php index c93d34d014182..f507cce011726 100644 --- a/src/wp-content/themes/twentyeleven/header.php +++ b/src/wp-content/themes/twentyeleven/header.php @@ -16,6 +16,10 @@ <?php // Print the <title> tag based on what is being viewed. + /** + * @global int $page The current page number for multi-paged posts. + * @global int $paged The current page number for the archive. + */ global $page, $paged; wp_title( '|', true, 'right' ); diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php index a46fed329cd69..cf1757234c6d1 100644 --- a/src/wp-content/themes/twentyeleven/showcase.php +++ b/src/wp-content/themes/twentyeleven/showcase.php @@ -209,6 +209,9 @@ $recent->the_post(); // Set $more to 0 in order to only get the first part of the post. + /** + * @global int $more Whether to display the full post or just the teaser. + */ global $more; $more = 0; diff --git a/src/wp-includes/abilities.php b/src/wp-includes/abilities.php index 0320df3b9f38a..af88f6fe85b5b 100644 --- a/src/wp-includes/abilities.php +++ b/src/wp-includes/abilities.php @@ -39,6 +39,8 @@ function wp_register_core_ability_categories(): void { * * @since 6.9.0 * + * @global wpdb $wpdb WordPress database abstraction object. + * * @return void */ function wp_register_core_abilities(): void { From 2424d656e49b0a699a6af9e4c8765d4cd6804d59 Mon Sep 17 00:00:00 2001 From: noruzzamanrubel <noruzzamanrubel@gmail.com> Date: Wed, 4 Feb 2026 21:12:34 +0600 Subject: [PATCH 3/7] Docs: Merge comments into @global DocBlocks for Twenty Eleven --- src/wp-content/themes/twentyeleven/header.php | 3 ++- src/wp-content/themes/twentyeleven/showcase.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-content/themes/twentyeleven/header.php b/src/wp-content/themes/twentyeleven/header.php index f507cce011726..a9d6c7cc3494e 100644 --- a/src/wp-content/themes/twentyeleven/header.php +++ b/src/wp-content/themes/twentyeleven/header.php @@ -15,8 +15,9 @@ <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title> <?php - // Print the <title> tag based on what is being viewed. /** + * Print the <title> tag based on what is being viewed. + * * @global int $page The current page number for multi-paged posts. * @global int $paged The current page number for the archive. */ diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php index cf1757234c6d1..5cee2ebf414f3 100644 --- a/src/wp-content/themes/twentyeleven/showcase.php +++ b/src/wp-content/themes/twentyeleven/showcase.php @@ -208,8 +208,9 @@ if ( $recent->have_posts() ) : $recent->the_post(); - // Set $more to 0 in order to only get the first part of the post. /** + * Set $more to 0 in order to only get the first part of the post. + * * @global int $more Whether to display the full post or just the teaser. */ global $more; From 6b8e7616f7f700ff00176b3de47d83f566bb4332 Mon Sep 17 00:00:00 2001 From: noruzzamanrubel <noruzzamanrubel@gmail.com> Date: Wed, 4 Feb 2026 21:18:44 +0600 Subject: [PATCH 4/7] Docs: Add missing @global annotations for wp_version and post in Twenty Eleven --- src/wp-content/themes/twentyeleven/functions.php | 2 ++ src/wp-content/themes/twentyeleven/header.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-content/themes/twentyeleven/functions.php b/src/wp-content/themes/twentyeleven/functions.php index 8bd2b24127368..87b751db7603d 100644 --- a/src/wp-content/themes/twentyeleven/functions.php +++ b/src/wp-content/themes/twentyeleven/functions.php @@ -83,6 +83,8 @@ function twentyeleven_setup() { * Manual loading of text domain is not required after the introduction of * just in time translation loading in WordPress version 4.6. * + * @global string $wp_version The WordPress version. + * * @ticket 58318 */ if ( version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ) { diff --git a/src/wp-content/themes/twentyeleven/header.php b/src/wp-content/themes/twentyeleven/header.php index a9d6c7cc3494e..76be6be585dc4 100644 --- a/src/wp-content/themes/twentyeleven/header.php +++ b/src/wp-content/themes/twentyeleven/header.php @@ -103,9 +103,11 @@ ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>> <?php - /* + /** * The header image. - * Check if this is a post or page, if it has a thumbnail, and if it's a big one + * Check if this is a post or page, if it has a thumbnail, and if it's a big one. + * + * @global WP_Post $post Global post object. */ $image = false; if ( is_singular() && has_post_thumbnail( $post->ID ) ) { From 36b116c2ca267eeffe2aa04c0475e1d1de992cf7 Mon Sep 17 00:00:00 2001 From: noruzzamanrubel <noruzzamanrubel@gmail.com> Date: Wed, 4 Feb 2026 21:22:01 +0600 Subject: [PATCH 5/7] Docs: Correct DocBlock tag order (@global before @param) --- src/wp-admin/includes/template.php | 2 -- src/wp-content/themes/twentyeleven/functions.php | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 1f8e3a6edbddd..b50ebc8c76678 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1628,8 +1628,6 @@ function do_accordion_sections( $screen, $context, $data_object ) { * @type string $after_section HTML content to append to the section's HTML output. Default empty. * @type string $section_class The class name to use for the section. Default empty. * } - * - * @global array $wp_settings_sections Global settings sections array. */ function add_settings_section( $id, $title, $callback, $page, $args = array() ) { global $wp_settings_sections; diff --git a/src/wp-content/themes/twentyeleven/functions.php b/src/wp-content/themes/twentyeleven/functions.php index 87b751db7603d..d605e951a7de3 100644 --- a/src/wp-content/themes/twentyeleven/functions.php +++ b/src/wp-content/themes/twentyeleven/functions.php @@ -757,11 +757,11 @@ function twentyeleven_footer_sidebar_class() { * * @since Twenty Eleven 1.0 * + * @global WP_Comment $comment Global comment object. + * * @param WP_Comment $comment The comment object. * @param array $args An array of comment arguments. @see get_comment_reply_link() * @param int $depth The depth of the comment. - * - * @global WP_Comment $comment Global comment object. */ function twentyeleven_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; From 6186f8e6f015af701faf034fed50595c3d62e10a Mon Sep 17 00:00:00 2001 From: noruzzamanrubel <noruzzamanrubel@gmail.com> Date: Wed, 4 Feb 2026 21:56:04 +0600 Subject: [PATCH 6/7] Docs: Add missing @global annotations for content_width and wp_version in Twenty Fifteen functions.php --- src/wp-content/themes/twentyfifteen/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-content/themes/twentyfifteen/functions.php b/src/wp-content/themes/twentyfifteen/functions.php index 7ac78506bbef3..a0bdb17ac70c6 100644 --- a/src/wp-content/themes/twentyfifteen/functions.php +++ b/src/wp-content/themes/twentyfifteen/functions.php @@ -29,6 +29,8 @@ * Set the content width based on the theme's design and stylesheet. * * @since Twenty Fifteen 1.0 + * + * @global int $content_width The content width. */ if ( ! isset( $content_width ) ) { $content_width = 660; @@ -62,6 +64,8 @@ function twentyfifteen_setup() { * Manual loading of text domain is not required after the introduction of * just in time translation loading in WordPress version 4.6. * + * @global string $wp_version The WordPress version. + * * @ticket 58318 */ @@ -499,6 +503,8 @@ function twentyfifteen_block_editor_styles() { * @since Twenty Fifteen 1.7 * @deprecated Twenty Fifteen 3.4 Disabled filter because, by default, fonts are self-hosted. * + * @global string $wp_version The WordPress version. + * * @param array $urls URLs to print for resource hints. * @param string $relation_type The relation type the URLs are printed. * @return array URLs to print for resource hints. From 240a9faa5a2663b9dfd6e287726aea3c781a9b54 Mon Sep 17 00:00:00 2001 From: noruzzamanrubel <noruzzamanrubel@gmail.com> Date: Wed, 4 Feb 2026 21:57:34 +0600 Subject: [PATCH 7/7] Docs: Add missing @global annotations for wp_version in Twenty Fifteen back-compat.php --- src/wp-content/themes/twentyfifteen/inc/back-compat.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-content/themes/twentyfifteen/inc/back-compat.php b/src/wp-content/themes/twentyfifteen/inc/back-compat.php index 6a628ae8df0c7..ac510d98b418d 100644 --- a/src/wp-content/themes/twentyfifteen/inc/back-compat.php +++ b/src/wp-content/themes/twentyfifteen/inc/back-compat.php @@ -32,6 +32,8 @@ function twentyfifteen_switch_theme() { * Twenty Fifteen on WordPress versions prior to 4.1. * * @since Twenty Fifteen 1.0 + * + * @global string $wp_version The WordPress version. */ function twentyfifteen_upgrade_notice() { printf( @@ -48,6 +50,8 @@ function twentyfifteen_upgrade_notice() { * Prevents the Customizer from being loaded on WordPress versions prior to 4.1. * * @since Twenty Fifteen 1.0 + * + * @global string $wp_version The WordPress version. */ function twentyfifteen_customize() { wp_die( @@ -68,6 +72,8 @@ function twentyfifteen_customize() { * Prevents the Theme Preview from being loaded on WordPress versions prior to 4.1. * * @since Twenty Fifteen 1.0 + * + * @global string $wp_version The WordPress version. */ function twentyfifteen_preview() { if ( isset( $_GET['preview'] ) ) {