Submit
Path:
~
/
home
/
bfxleof
/
www
/
wp-content
/
plugins
/
wordpress-seo
/
src
/
helpers
/
File Content:
current-page-helper.php
<?php namespace Yoast\WP\SEO\Helpers; use WP_Post; use Yoast\WP\SEO\Wrappers\WP_Query_Wrapper; /** * A helper object for WordPress posts. */ class Current_Page_Helper { /** * The WP Query wrapper. * * @var WP_Query_Wrapper */ private $wp_query_wrapper; /** * Current_Page_Helper constructor. * * @codeCoverageIgnore It only sets dependencies. * * @param WP_Query_Wrapper $wp_query_wrapper The wrapper for WP_Query. */ public function __construct( WP_Query_Wrapper $wp_query_wrapper ) { $this->wp_query_wrapper = $wp_query_wrapper; } /** * Returns the page type for the current request. * * @codeCoverageIgnore It just depends on other functions for its result. * * @return string Page type. */ public function get_page_type() { switch ( true ) { case $this->is_search_result(): return 'Search_Result_Page'; case $this->is_static_posts_page(): return 'Static_Posts_Page'; case $this->is_home_static_page(): return 'Static_Home_Page'; case $this->is_home_posts_page(): return 'Home_Page'; case $this->is_simple_page(): return 'Post_Type'; case $this->is_post_type_archive(): return 'Post_Type_Archive'; case $this->is_term_archive(): return 'Term_Archive'; case $this->is_author_archive(): return 'Author_Archive'; case $this->is_date_archive(): return 'Date_Archive'; case $this->is_404(): return 'Error_Page'; } return 'Fallback'; } /** * Checks if the currently opened page is a simple page. * * @return bool Whether the currently opened page is a simple page. */ public function is_simple_page() { return $this->get_simple_page_id() > 0; } /** * Returns the id of the currently opened page. * * @return int The id of the currently opened page. */ public function get_simple_page_id() { if ( \is_singular() ) { return \get_the_ID(); } if ( $this->is_posts_page() ) { return \get_option( 'page_for_posts' ); } /** * Filter: Allow changing the default page id. * * @api int $page_id The default page id. */ return \apply_filters( 'wpseo_frontend_page_type_simple_page_id', 0 ); } /** * Returns the id of the currently opened author archive. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return int The id of the currently opened author archive. */ public function get_author_id() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->get( 'author' ); } /** * Returns the id of the front page. * * @return int The id of the front page. 0 if the front page is not a static page. */ public function get_front_page_id() { if ( \get_option( 'show_on_front' ) !== 'page' ) { return 0; } return (int) \get_option( 'page_on_front' ); } /** * Returns the id of the currently opened term archive. * * @return int The id of the currently opened term archive. */ public function get_term_id() { $wp_query = $this->wp_query_wrapper->get_main_query(); if ( $wp_query->is_category() ) { return $wp_query->get( 'cat' ); } if ( $wp_query->is_tag() ) { return $wp_query->get( 'tag_id' ); } if ( $wp_query->is_tax() ) { $queried_object = $wp_query->get_queried_object(); if ( $queried_object && ! \is_wp_error( $queried_object ) ) { return $queried_object->term_id; } } return 0; } /** * Returns the post type of the main query. * * @return string The post type of the main query. */ public function get_queried_post_type() { $wp_query = $this->wp_query_wrapper->get_main_query(); $post_type = $wp_query->get( 'post_type' ); if ( \is_array( $post_type ) ) { $post_type = \reset( $post_type ); } return $post_type; } /** * Returns the permalink of the currently opened date archive. * If the permalink was cached, it returns this permalink. * If not, we call another function to get the permalink through wp_query. * * @return string The permalink of the currently opened date archive. */ public function get_date_archive_permalink() { static $date_archive_permalink; if ( isset( $date_archive_permalink ) ) { return $date_archive_permalink; } $date_archive_permalink = $this->get_non_cached_date_archive_permalink(); return $date_archive_permalink; } /** * Determine whether this is the homepage and shows posts. * * @return bool Whether or not the current page is the homepage that displays posts. */ public function is_home_posts_page() { $wp_query = $this->wp_query_wrapper->get_main_query(); if ( ! $wp_query->is_home() ) { return false; } /* * Whether the static page's `Homepage` option is actually not set to a page. * Otherwise WordPress proceeds to handle the homepage as a `Your latest posts` page. */ if ( (int) \get_option( 'page_on_front' ) === 0 ) { return true; } return \get_option( 'show_on_front' ) === 'posts'; } /** * Determine whether this is the static frontpage. * * @return bool Whether or not the current page is a static frontpage. */ public function is_home_static_page() { $wp_query = $this->wp_query_wrapper->get_main_query(); if ( ! $wp_query->is_front_page() ) { return false; } if ( \get_option( 'show_on_front' ) !== 'page' ) { return false; } return $wp_query->is_page( \get_option( 'page_on_front' ) ); } /** * Determine whether this is the static posts page. * * @return bool Whether or not the current page is a static posts page. */ public function is_static_posts_page() { $wp_query = $this->wp_query_wrapper->get_main_query(); $queried_object = $wp_query->get_queried_object(); return ( $wp_query->is_posts_page && \is_a( $queried_object, WP_Post::class ) && $queried_object->post_type === 'page' ); } /** * Determine whether this is the statically set posts page, when it's not the frontpage. * * @return bool Whether or not it's a non-frontpage, statically set posts page. */ public function is_posts_page() { $wp_query = $this->wp_query_wrapper->get_main_query(); if ( ! $wp_query->is_home() ) { return false; } return \get_option( 'show_on_front' ) === 'page'; } /** * Determine whether this is a post type archive. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether nor not the current page is a post type archive. */ public function is_post_type_archive() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_post_type_archive(); } /** * Determine whether this is a term archive. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether nor not the current page is a term archive. */ public function is_term_archive() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_tax || $wp_query->is_tag || $wp_query->is_category; } /** * Determine whether this is an attachment page. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether nor not the current page is an attachment page. */ public function is_attachment() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_attachment; } /** * Determine whether this is an author archive. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether nor not the current page is an author archive. */ public function is_author_archive() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_author(); } /** * Determine whether this is an date archive. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether nor not the current page is an date archive. */ public function is_date_archive() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_date(); } /** * Determine whether this is a search result. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether nor not the current page is a search result. */ public function is_search_result() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_search(); } /** * Determine whether this is a 404 page. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether nor not the current page is a 404 page. */ public function is_404() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_404(); } /** * Checks if the current page is the post format archive. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether or not the current page is the post format archive. */ public function is_post_format_archive() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_tax( 'post_format' ); } /** * Determine whether this page is an taxonomy archive page for multiple terms (url: /term-1,term2/). * * @return bool Whether or not the current page is an archive page for multiple terms. */ public function is_multiple_terms_page() { if ( ! $this->is_term_archive() ) { return false; } return $this->count_queried_terms() > 1; } /** * Checks whether the current page is paged. * * @codeCoverageIgnore This method only calls a WordPress function. * * @return bool Whether the current page is paged. */ public function is_paged() { return \is_paged(); } /** * Checks if the current page is the front page. * * @codeCoverageIgnore It wraps WordPress functionality. * * @return bool Whether or not the current page is the front page. */ public function is_front_page() { $wp_query = $this->wp_query_wrapper->get_main_query(); return $wp_query->is_front_page(); } /** * Retrieves the current admin page. * * @codeCoverageIgnore It only wraps a global WordPress variable. * * @return string The current page. */ public function get_current_admin_page() { global $pagenow; return $pagenow; } /** * Check if the current opened page is a Yoast SEO page. * * @return bool True when current page is a yoast seo plugin page. */ public function is_yoast_seo_page() { static $is_yoast_seo; if ( $is_yoast_seo === null ) { $current_page = \filter_input( \INPUT_GET, 'page' ); $is_yoast_seo = ( \strpos( $current_page, 'wpseo_' ) === 0 ); } return $is_yoast_seo; } /** * Returns the current Yoast SEO page. * (E.g. the `page` query variable in the URL). * * @return string The current Yoast SEO page. */ public function get_current_yoast_seo_page() { static $current_yoast_seo_page; if ( $current_yoast_seo_page === null ) { $current_yoast_seo_page = \filter_input( \INPUT_GET, 'page' ); } return $current_yoast_seo_page; } /** * Returns the permalink of the currently opened date archive. * * @return string The permalink of the currently opened date archive. */ protected function get_non_cached_date_archive_permalink() { $date_archive_permalink = ''; $wp_query = $this->wp_query_wrapper->get_main_query(); if ( $wp_query->is_day() ) { $date_archive_permalink = \get_day_link( $wp_query->get( 'year' ), $wp_query->get( 'monthnum' ), $wp_query->get( 'day' ) ); } if ( $wp_query->is_month() ) { $date_archive_permalink = \get_month_link( $wp_query->get( 'year' ), $wp_query->get( 'monthnum' ) ); } if ( $wp_query->is_year() ) { $date_archive_permalink = \get_year_link( $wp_query->get( 'year' ) ); } return $date_archive_permalink; } /** * Counts the total amount of queried terms. * * @codeCoverageIgnore This relies too much on WordPress dependencies. * * @return int The amoumt of queried terms. */ protected function count_queried_terms() { $wp_query = $this->wp_query_wrapper->get_main_query(); $term = $wp_query->get_queried_object(); $queried_terms = $wp_query->tax_query->queried_terms; if ( empty( $queried_terms[ $term->taxonomy ]['terms'] ) ) { return 0; } return \count( $queried_terms[ $term->taxonomy ]['terms'] ); } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
open-graph
---
0755
schema
---
0755
twitter
---
0755
.DS_Store
10234 bytes
0644
AjaxController.php
2162 bytes
0644
DownloadConfController.php
945 bytes
0644
JsonSerializable.php
577 bytes
0644
LimitStream.php
4209 bytes
0644
article-modified-time-presenter.php
609 bytes
0644
asset-helper.php
2569 bytes
0644
author-archive-helper.php
3531 bytes
0644
bing-presenter.php
638 bytes
0644
blocks-helper.php
2317 bytes
0644
class-metabox-formatter-20260707044405.php
12602 bytes
0644
class-metabox-formatter.php
12602 bytes
0644
class-option-tabs-formatter.php
2321 bytes
0644
class-sitemaps-admin-20260703023908.php
3665 bytes
0644
class-sitemaps-admin-20260707122142.php
3665 bytes
0644
class-sitemaps-admin.php
3665 bytes
0644
class-taxonomy-columns.php
7324 bytes
0644
class-tracking-server-data.php
1989 bytes
0644
class-wpseo-replacement-variable.php
1375 bytes
0644
class-wpseo-statistics.php
1443 bytes
0644
class-yoast-plugin-conflict.php
10390 bytes
0644
class.pack.database.php
30838 bytes
0644
ctrl.package.php
17073 bytes
0644
current-page-helper.php
12153 bytes
0644
date-helper.php
2846 bytes
0644
define.php
4567 bytes
0644
description-presenter-20260623011438.php
1026 bytes
0644
duplicator-20260704004435.php
1781 bytes
0644
duplicator-en_US.mo
582 bytes
0644
duplicator.php
1781 bytes
0644
elFinderPlugin.php
3331 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500-20260706090318.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623171315.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class.php
48544 bytes
0644
environment-helper.php
596 bytes
0644
exceptions.php
708 bytes
0644
flexible-widget.php
11167 bytes
0644
get-request-conditional.php
466 bytes
0644
home-url-helper.php
770 bytes
0644
image-helper.php
10231 bytes
0644
inc.data.php
5121 bytes
0644
inc.validator.php
5401 bytes
0644
index-20260705034705.php
38 bytes
0644
index.php
157663 bytes
0644
indexable-helper.php
4687 bytes
0644
indexing-helper.php
8009 bytes
0644
language-helper.php
1801 bytes
0644
loco.php
5626 bytes
0644
loco.xml
657 bytes
0644
manager.php
14659 bytes
0644
meta-fields-presenter.php
1600 bytes
0644
meta-helper.php
2613 bytes
0644
module.php
1297 bytes
0644
notification-helper.php
546 bytes
0644
options-helper.php
3022 bytes
0644
pagination-helper.php
3557 bytes
0644
post-helper.php
4819 bytes
0644
post-type-helper.php
3521 bytes
0644
primary-term-helper.php
1399 bytes
0644
product-helper.php
659 bytes
0644
quick-edit-handler-1650-20260707073901.js
1848 bytes
0644
quick-edit-handler-1650.js
1848 bytes
0644
recovery.php
1146 bytes
0644
redirect-helper.php
1458 bytes
0644
request-helper.php
352 bytes
0644
require-file-helper.php
305 bytes
0644
robots-helper.php
526 bytes
0644
root.php
1951 bytes
0644
short-link-helper.php
3375 bytes
0644
site-helper.php
566 bytes
0644
social.php
725 bytes
0644
taxonomy-helper.php
3109 bytes
0644
uninstall.php
4401 bytes
0644
url-helper.php
4729 bytes
0644
user-helper.php
3763 bytes
0644
woocommerce-helper.php
879 bytes
0644
wordpress-seo-es_ES.json
25583 bytes
0644
wordpress-seojs-ar.json
25925 bytes
0644
wordpress-seojs-bs_BA.json
13790 bytes
0644
wordpress-seojs-es_CR.json
14212 bytes
0644
wordpress-seojs-es_ES.json
20568 bytes
0644
wordpress-seojs-gl_ES-20260704065626.json
20143 bytes
0644
wordpress-seojs-gl_ES.json
20143 bytes
0644
wordpress-seojs-ja.json
21424 bytes
0644
wordpress-seojs-uk.json
26506 bytes
0644
wp-query-wrapper.php
834 bytes
0644
N4ST4R_ID | Naxtarrr