PHP Class The_SEO_Framework\Query

Caches and organizes the WP Query.
Since: 2.7.1
Inheritance: extends Compat
Show file Open project: sybrew/the-seo-framework

Public Methods

Method Description
can_cache_query ( ) : boolean Checks whether $wp_query or $current_screen is set.
check_the_real_ID ( ) : integer | empty Get the real ID from plugins.
get_admin_term_id ( ) : integer Fetches the Term ID on admin pages.
get_query_cache ( string $key, mixed $value_to_set = null ) : mixed Handles object cache for the query class.
get_the_real_ID ( boolean $use_cache = true ) : integer | false Get the real page ID, also from CPT, archives, author, blog, etc.
get_the_real_admin_ID ( ) Fetches post or term ID within the admin.
is_404 ( ) : boolean Detects 404.
is_admin ( ) : boolean Detects admin screen.
is_archive ( ) : boolean Detects archive pages. Also in admin.
is_archive_admin ( ) : boolean Extends default WordPress is_archive() and determines screen in admin.
is_attachment ( mixed $attachment = '' ) : boolean Detects attachment page.
is_author ( mixed $author = '' ) : boolean Detects author archives.
is_blog_page ( integer $id ) : boolean Detect the separated blog page.
is_category ( mixed $category = '' ) : boolean Detects category archives.
is_category_admin ( ) : boolean Extends default WordPress is_category() and determines screen in admin.
is_date ( ) : boolean Detects date archives.
is_day ( ) : boolean Detects day archives.
is_feed ( string | array $feeds = '' ) : boolean Detects feed.
is_front_page ( integer $id ) : boolean Detects front page.
is_home ( ) : boolean Detects home page.
is_menu_page ( string $pagehook = '', string $pageslug = '' ) : boolean Checks the screen base file through global $page_hook or $_GET.
is_month ( ) : boolean Detects month archives.
is_page ( integer | string | array $page = '' ) : boolean Detects pages.
is_page_admin ( ) : boolean Detects pages within the admin area.
is_post_edit ( ) : boolean Detects Post edit screen in WP Admin.
is_preview ( ) : boolean Detects preview.
is_search ( ) : boolean Detects preview.
is_seo_settings_page ( boolean $secure = true ) : boolean Determines whether we're on the SEO settings page.
is_single ( integer | string | array $post = '' ) : boolean Detects posts.
is_single_admin ( ) : boolean Detects posts within the admin area.
is_singular ( string | array $post_types = '' ) : boolean Determines if the current page is singular is holds singular items within the admin screen.
is_singular_admin ( ) : boolean Determines if the page is singular within the admin screen.
is_static_frontpage ( integer $id = '' ) : boolean Detects the static front page.
is_tag ( mixed $tag = '' ) : boolean Detects tag archives.
is_tag_admin ( ) : boolean Determines if the page is a tag within the admin screen.
is_tax ( string | array $taxonomy = '', integer | string | array $term = '' ) : boolean Detects taxonomy archives.
is_term_edit ( ) : boolean Detects Term edit screen in WP Admin.
is_ultimate_member_user_page ( ) : boolean Determines if the page is a Ulimate Member's plugin User page.
is_wc_product ( ) : boolean Determines if the page is the WooCommerce plugin Product page.
is_wc_shop ( ) : boolean Determines if the page is the WooCommerce plugin Shop page.
is_wp_lists_edit ( ) : boolean Detects Post or Archive Lists in Admin.
is_year ( ) : boolean Detects year archives.
page ( ) : integer Fetches the amount of pages on the screen.
paged ( ) : integer Fetches the number of the current page.
set_query_cache ( string $key, mixed $value_to_set ) : boolean Object cache handler for the query class.

Protected Methods

Method Description
__construct ( ) Constructor. Load parent constructor.
is_multipage ( ) : boolean Determines whether the current loop is a multipage.

Method Details

__construct() protected method

Constructor. Load parent constructor.
protected __construct ( )

can_cache_query() public method

Checks whether $wp_query or $current_screen is set.
Since: 2.6.1
public can_cache_query ( ) : boolean
return boolean True when wp_query or current_screen has been initialized.

check_the_real_ID() public method

Only works on front-end as there's no need to check for inconsistent functions for the current ID in the admin.
Since: 2.5.0
public check_the_real_ID ( ) : integer | empty
return integer | empty the ID.

get_admin_term_id() public method

Fetches the Term ID on admin pages.
Since: 2.6.0
Since: 2.6.6 Moved from class The_SEO_Framework_Term_Data.
public get_admin_term_id ( ) : integer
return integer Term ID.

get_query_cache() public method

Handles object cache for the query class.
Since: 2.7.0
public get_query_cache ( string $key, mixed $value_to_set = null ) : mixed
$key string The key to set or get.
$value_to_set mixed The value to set.
return mixed : { mixed The cached value if set and $value_to_set is null. null If the query can't be cached yet, or when no value has been set. If $value_to_set is set : { true If the value is being set for the first time. false If the value has been set and $value_to_set is being overwritten. } }

get_the_real_ID() public method

Get the real page ID, also from CPT, archives, author, blog, etc.
Since: 2.5.0
public get_the_real_ID ( boolean $use_cache = true ) : integer | false
$use_cache boolean Whether to use the cache or not.
return integer | false The ID.

get_the_real_admin_ID() public method

Alters while in the loop. Therefore, this can't be cached and must be called within the loop.
Since: 2.7.0

is_404() public method

Detects 404.
Since: 2.6.0
public is_404 ( ) : boolean
return boolean

is_admin() public method

Detects admin screen.
Since: 2.6.0
public is_admin ( ) : boolean
return boolean

is_archive() public method

Detects archive pages. Also in admin.
Since: 2.6.0
public is_archive ( ) : boolean
return boolean

is_archive_admin() public method

Extends default WordPress is_archive() and determines screen in admin.
Since: 2.6.0
public is_archive_admin ( ) : boolean
return boolean Post Type is archive

is_attachment() public method

Detects attachment page.
Since: 2.6.0
public is_attachment ( mixed $attachment = '' ) : boolean
$attachment mixed Attachment ID, title, slug, or array of such.
return boolean

is_author() public method

Detects author archives.
Since: 2.6.0
public is_author ( mixed $author = '' ) : boolean
$author mixed Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
return boolean

is_blog_page() public method

Detect the separated blog page.
Since: 2.3.4
public is_blog_page ( integer $id ) : boolean
$id integer the Page ID.
return boolean true if is blog page. Always false if blog page is homepage.

is_category() public method

Detects category archives.
Since: 2.6.0
public is_category ( mixed $category = '' ) : boolean
$category mixed Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
return boolean

is_category_admin() public method

Extends default WordPress is_category() and determines screen in admin.
Since: 2.6.0
public is_category_admin ( ) : boolean
return boolean Post Type is category

is_date() public method

Detects date archives.
Since: 2.6.0
public is_date ( ) : boolean
return boolean

is_day() public method

Detects day archives.
Since: 2.6.0
public is_day ( ) : boolean
return boolean

is_feed() public method

Detects feed.
Since: 2.6.0
public is_feed ( string | array $feeds = '' ) : boolean
$feeds string | array Optional feed types to check.
return boolean

is_front_page() public method

Detects front page.
Since: 2.6.0
public is_front_page ( integer $id ) : boolean
$id integer The Page or Post ID.
return boolean

is_home() public method

Detects home page.
Since: 2.6.0
public is_home ( ) : boolean
return boolean

is_menu_page() public method

Checks the screen base file through global $page_hook or $_GET.
Since: 2.2.2
Since: 2.7.0 Added pageslug parameter.
public is_menu_page ( string $pagehook = '', string $pageslug = '' ) : boolean
$pagehook string The menu pagehook to compare to.
$pageslug string The menu page slug to compare to.
return boolean true if screen match.

is_month() public method

Detects month archives.
Since: 2.6.0
public is_month ( ) : boolean
return boolean

is_multipage() protected method

Determines whether the current loop is a multipage.
Since: 2.7.0
protected is_multipage ( ) : boolean
return boolean True if multipage.

is_page() public method

When $page is supplied, it will check against the current object. So it will not work in the admin screens.
Since: 2.6.0
public is_page ( integer | string | array $page = '' ) : boolean
$page integer | string | array Optional. Page ID, title, slug, or array of such. Default empty.
return boolean

is_page_admin() public method

Detects pages within the admin area.
Since: 2.6.0
public is_page_admin ( ) : boolean
return boolean

is_post_edit() public method

Detects Post edit screen in WP Admin.
Since: 2.6.0
public is_post_edit ( ) : boolean
return boolean We're on Post Edit screen.

is_preview() public method

Detects preview.
Since: 2.6.0
public is_preview ( ) : boolean
return boolean

is_seo_settings_page() public method

WARNING: Do not ever use this as a safety check.
Since: 2.6.0
Since: 2.7.0 Added secure parameter.
public is_seo_settings_page ( boolean $secure = true ) : boolean
$secure boolean Whether to ignore the use of the second (insecure) parameter.
return boolean

is_single() public method

When $post is supplied, it will check against the current object. So it will not work in the admin screens.
Since: 2.6.0
public is_single ( integer | string | array $post = '' ) : boolean
$post integer | string | array Optional. Post ID, title, slug, or array of such. Default empty.
return boolean

is_single_admin() public method

Detects posts within the admin area.
See also: The_SEO_Framework_Query::is_single()
Since: 2.6.0
public is_single_admin ( ) : boolean
return boolean

is_singular() public method

Replaces and expands default WordPress is_singular().
Since: 2.5.2
public is_singular ( string | array $post_types = '' ) : boolean
$post_types string | array Optional. Post type or array of post types. Default empty string.
return boolean Post Type is singular

is_singular_admin() public method

Determines if the page is singular within the admin screen.
Since: 2.5.2
public is_singular_admin ( ) : boolean
return boolean Post Type is singular

is_static_frontpage() public method

Detects the static front page.
Since: 2.3.8
public is_static_frontpage ( integer $id = '' ) : boolean
$id integer the Page ID to check. If empty, the current ID will be fetched.
return boolean true if is blog page. Always false if the homepage is a blog.

is_tag() public method

Detects tag archives.
Since: 2.6.0
public is_tag ( mixed $tag = '' ) : boolean
$tag mixed Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs.
return boolean

is_tag_admin() public method

Determines if the page is a tag within the admin screen.
Since: 2.6.0
public is_tag_admin ( ) : boolean
return boolean Post Type is category.

is_tax() public method

Detects taxonomy archives.
Since: 2.6.0
public is_tax ( string | array $taxonomy = '', integer | string | array $term = '' ) : boolean
$taxonomy string | array Optional. Taxonomy slug or slugs.
$term integer | string | array Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
return boolean

is_term_edit() public method

Detects Term edit screen in WP Admin.
Since: 2.6.0
public is_term_edit ( ) : boolean
return boolean We're on Term Edit screen.

is_ultimate_member_user_page() public method

Checks for function availability: um_user, um_is_core_page, um_get_requested_user
Since: 2.5.2
public is_ultimate_member_user_page ( ) : boolean
return boolean Whether we're on a Ultimate Member page.

is_wc_product() public method

Determines if the page is the WooCommerce plugin Product page.
Since: 2.5.2
public is_wc_product ( ) : boolean
return boolean True if on a WooCommerce Product page.

is_wc_shop() public method

Determines if the page is the WooCommerce plugin Shop page.
Since: 2.5.2
public is_wc_shop ( ) : boolean
return boolean True if on the WooCommerce shop page.

is_wp_lists_edit() public method

Detects Post or Archive Lists in Admin.
Since: 2.6.0
public is_wp_lists_edit ( ) : boolean
return boolean We're on the edit screen.

is_year() public method

Detects year archives.
Since: 2.6.0
public is_year ( ) : boolean
return boolean

page() public method

Fetches global $page through Query Var to prevent conflicts.
Since: 2.6.0
public page ( ) : integer
return integer $page Always a positive number.

paged() public method

Fetches global $paged through Query Var to prevent conflicts.
Since: 2.6.0
public paged ( ) : integer
return integer $paged

set_query_cache() public method

Object cache handler for the query class.
See also: The_SEO_Framework_Query::get_query_cache()
Since: 2.7.0
public set_query_cache ( string $key, mixed $value_to_set ) : boolean
$key string The key to set.
$value_to_set mixed If null, no cache will be set.
return boolean : { true If the value is being set for the first time. false If the value has been set and $value_to_set is being overwritten. }