Docs: Explicitly declare some globals for clarity.

This aims to improve developer experience by making it clear that these variables are defined elsewhere.

Props ravipatel, davidbaumwald, hellofromTonya, costdev, SergeyBiryukov.
Fixes #51439.
Built from https://develop.svn.wordpress.org/trunk@53450


git-svn-id: http://core.svn.wordpress.org/trunk@53039 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-05-29 15:35:11 +00:00
parent 9a2a423eb6
commit d842b3b5c3
6 changed files with 38 additions and 4 deletions

View File

@ -25,6 +25,11 @@ if ( $doaction ) {
check_admin_referer( 'bulk-comments' );
if ( 'delete_all' === $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) {
/**
* @global wpdb $wpdb WordPress database abstraction object.
*/
global $wpdb;
$comment_status = wp_unslash( $_REQUEST['comment_status'] );
$delete_time = wp_unslash( $_REQUEST['pagegen_timestamp'] );
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $comment_status, $delete_time ) );
@ -135,6 +140,11 @@ $wp_list_table->prepare_items();
wp_enqueue_script( 'admin-comments' );
enqueue_comment_hotkeys_js();
/**
* @global int $post_id
*/
global $post_id;
if ( $post_id ) {
$comments_count = wp_count_comments( $post_id );
$draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' );

View File

@ -10,6 +10,11 @@
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* @global WP_Comment $comment Global comment object.
*/
global $comment;
?>
<form name="post" action="comment.php" method="post" id="post">
<?php wp_nonce_field( 'update-comment_' . $comment->comment_ID ); ?>
@ -139,7 +144,14 @@ printf( __( 'Submitted on: %s' ), '<b>' . $submitted . '</b>' );
<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a>
<fieldset id='timestampdiv' class='hide-if-js'>
<legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend>
<?php touch_time( ( 'editcomment' === $action ), 0 ); ?>
<?php
/**
* @global string $action
*/
global $action;
touch_time( ( 'editcomment' === $action ), 0 );
?>
</fieldset>
</div>

View File

@ -9,6 +9,11 @@
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
/**
* @global string $typenow The post type of the current screen.
*/
global $typenow;
if ( ! $typenow ) {
wp_die( __( 'Invalid post type.' ) );
}
@ -87,6 +92,11 @@ if ( $doaction ) {
$post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] );
// Validate the post status exists.
if ( get_post_status_object( $post_status ) ) {
/**
* @global wpdb $wpdb WordPress database abstraction object.
*/
global $wpdb;
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
}
$doaction = 'delete';

View File

@ -225,8 +225,9 @@ if ( is_blog_installed() ) {
* @global string $wp_version The WordPress version string.
* @global string $required_php_version The required PHP version string.
* @global string $required_mysql_version The required MySQL version string.
* @global wpdb $wpdb WordPress database abstraction object.
*/
global $wp_version, $required_php_version, $required_mysql_version;
global $wp_version, $required_php_version, $required_mysql_version, $wpdb;
$php_version = PHP_VERSION;
$mysql_version = $wpdb->db_version();

View File

@ -39,8 +39,9 @@ if ( 'upgrade_db' === $step ) {
* @global string $wp_version The WordPress version string.
* @global string $required_php_version The required PHP version string.
* @global string $required_mysql_version The required MySQL version string.
* @global wpdb $wpdb WordPress database abstraction object.
*/
global $wp_version, $required_php_version, $required_mysql_version;
global $wp_version, $required_php_version, $required_mysql_version, $wpdb;
$step = (int) $step;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53449';
$wp_version = '6.1-alpha-53450';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.