WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP::register_globals() public WP 2.0.0

Set up the WordPress Globals.

The query_vars property will be extracted to the GLOBALS. So care should be taken when naming global variables that might interfere with the WordPress environment.

Это метод класса: WP{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$WP = new WP();
$WP->register_globals();

Заметки

  • Global. WP_Query. $wp_query WordPress Query object.
  • Global. Строка. $query_string Query string for the loop.
  • Global. Массив. $posts The found posts.
  • Global. WP_Post/null. $post The current post, if available.
  • Global. Строка. $request The SQL statement for the request.
  • Global. Число. $more Only set, if single page or post.
  • Global. Число. $single If single page or post. Only set, if single page or post.
  • Global. WP_User. $authordata Only set, if author archive.

Список изменений

С версии 2.0.0 Введена.

Код WP::register globals: wp-includes/class-wp.php WP 5.5.1

<?php
public function register_globals() {
	global $wp_query;

	// Extract updated query vars back into global namespace.
	foreach ( (array) $wp_query->query_vars as $key => $value ) {
		$GLOBALS[ $key ] = $value;
	}

	$GLOBALS['query_string'] = $this->query_string;
	$GLOBALS['posts']        = & $wp_query->posts;
	$GLOBALS['post']         = isset( $wp_query->post ) ? $wp_query->post : null;
	$GLOBALS['request']      = $wp_query->request;

	if ( $wp_query->is_single() || $wp_query->is_page() ) {
		$GLOBALS['more']   = 1;
		$GLOBALS['single'] = 1;
	}

	if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
		$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
	}
}