Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:CharlesClarkson/Global Variables

This article is a ROUGH DRAFT. The author is still working on this document, so please do not edit this without the author's permission. The content within this article may not yet be verified or valid. This information is subject to change.

Introduction

Global variables are used throughout the WordPress source code for several reasons. One reason is to easily allow the use of Singletons. Some of them are historical and are needed to maintain backward compatibility with previous versions of WordPress and of PHP. Others are rarely used or will soon be deprecated.

This is a jumping off point for a short and a long description of each global variable used in WordPress source code. It probably is not an exhaustive or authoritative list, though one day that may change.

This page is really meant to be an aid in simplifying the WordPress source code Inline_Documentation. Instead of littering the source code Inline_Documentation with many (sometimes erroneous) definitions of each global variable this page will act as one easily updated central location. Think of it as a Glossary for source code global variables.

Global variables are discussed in detail in the PHP Manual. In the WordPress source code most global variables should be considered read-only, but that is not an enforced rule. As a general rule, you should try to avoid changing the value of a global variable without a darn good reason to do so.

How to Use this Page

Global variables are listed here by some loosely defined category. It helps to explain some global variables in a context of some others. If you are looking for a particular variable, do a search for that variable in your browser. If you cannot find a global listed, place it in the Undefined Variables section and some nice person may get to defining it.

The form of each full definition should be as follows:

$GLOBAL_VARIABLE_NAME
(data type) Description.

Data Types

Some global variables can have different data types depending on how some functions change the variable. For example, the $wpdb->rows() method may return an object, an associative array, or a numerical array depending on what the programmer requests.

In this documentation there is no distinction between an associative array, or a numerical array. In PHP they are both classified as the array data type. If more than one data type can be returned it may be listed as (object|array) or as (mixed). The former is preferred over the latter.

To access a global variable in your code, you first need to globalize the variable with global $variable;

Formatting Variables

Smilies

$wp_similiesreplace
(array)
$wp_smiliessearch
(array)

WordPress Database Related Global Variables

$wpdb
(object) The WordPress Database Object.
$wp_query
(object) The Query Object.
$EZSQL_ERROR
(array) Stores error information of query and error string.
$userdata
(array | object) Used by various functions to update user data.
$query
(string) Holds the query string that was passed to the $wp_query object by wp-blog-header.php.
$query_vars
(array) An associative array of query variable names and their respective values.

Uncategorized Global Variables

The following variables are global in scope and have definition, but have not been categorized. You can help by writing a detailed section about one or more of these or by adding a new category for one or more of them.

$day
(string) Holds the date of the day of the current post during The_Loop.
$previousday
(string) May hold the date of the day of the previous post (if any) during The_Loop.
$wp_version
(string) Holds the installed WordPress version number.
$wp_locale
(object) Handles the date and time locales.
$wp_broken_themes
(array) Holds broken themes list.
$wp_themes
(array) Holds working themes list.
$wp_did_header
(boolean) Returns true if the WordPress header was already loaded. See the /wp-blog-header.php file for details.
$cache_lastpostdate
(array) Stores the date the last post was published in various date formats.
$cache_lastpostmodified
(array) Stores the date the last post was last modified in various date formats.
$cache_lastcommentmodified
(array) Stores the date the last comment was last modified in various date formats.
$blog_id
(integer) The Blog ID.

Undefined Global Variables

The following variables are global in scope, but do not have a definition here yet. You can help by adding a definition for these global variables.

$admin_page_hooks
(unknown)
$ajax_results
(unknown)
$all_links
(unknown)
$allowedposttags
(unknown)
$allowedtags
(unknown)
$authordata
(unknown)
$bgcolor
(unknown)
$cache_categories
(unknown)
$cache_userdata
(unknown)
$category_cache
(unknown)
$class
(unknown)
$comment
(unknown)
$comment_cache
(unknown)
$comment_count_cache
(unknown)
$commentdata
(unknown)
$current_user
(unknown)
$debug
(unknown)
$descriptions
(unknown)
$error
(unknown)
$feeds
(unknown)
$id
(unknown)
$is_apache
(unknown)
$is_IIS
(unknown)
$is_macIE
(unknown)
$is_winIE
(unknown)
$l10n
(unknown)
$locale
(unknown)
$link
(unknown)
$m
(unknown)
$map
(unknown)
$max_num_pages
(unknown)
$menu
(array) Holds an array of all of the admin menus (see wp-admin/menu.php).
$mode
(unknown)
$month
(unknown)
$month_abbrev
(unknown)
$monthnum
(unknown)
$more
(unknown)
$multipage
(unknown)
$names
(unknown)
$newday
(unknown)
$numpages
(unknown)
$page
(unknown)
$page_cache
(unknown)
$paged
(unknown)
$pagenow
(unknown)
$pages
(unknown)
$parent_file
(unknown)
$preview
(unknown)
$previousweekday
(unknown)
$plugin_page
(unknown)
$post
(object)
$post_cache
(unknown)
$post_default_category
(string)
$post_default_title
(string)
$post_meta_cache
(unknown)
$postc
(unknown)
$postdata
(unknown)
$posts
(unknown)
$posts_per_page
(unknown)
$previousday
(unknown)
$request
(unknown)
$result
(unknown)
$richedit
(unknown)
$single
(unknown)
$submenu
(unknown)
$table_prefix
(unknown)
$targets
(unknown)
$timedifference
(unknown)
$timestart
(unknown)
$timeend
(unknown)
$updated_timestamp
(unknown)
$urls
(unknown)
$user_ID
(unknown) USER ID of currently logged-in user.
$user_email
(unknown)
$user_identity
(string) NICKNAME of the user logged-in.
$user_level
(unknown)
$user_login
(string) ACCOUNT NAME of the user logged-in.
$user_pass_md5
(unknown)
$user_url
(unknown)
$weekday
(unknown)
$weekday_abbrev
(unknown)
$weekday_initial
(unknown)
$withcomments
(unknown)
$wp
(unknown)
$wp_broken_themes
(unknown)
$wp_db_version
(unknown)
$wp_did_header
(unknown)
$wp_did_template_redirect
(unknown)
$wp_file_description
(unknown)
$wp_filter
(unknown)
$wp_importers
(unknown)
$wp_plugins
(unknown)
$wp_themes
(unknown)
$wp_object_cache
(unknown)
$wp_queries
(unknown)
$wp_rewrite
(unknown)
$wp_roles
(unknown)
$wpcommentspopupfile
(unknown)
$wpcommentsjavascript
(unknown)