PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/wp-content/plugins/wordpress-seo/frontend/class-frontend-page-type.php

https://bitbucket.org/carloskikea/helpet
PHP | 43 lines | 15 code | 5 blank | 23 comment | 3 complexity | c228e3e7f56a7143ca79c3e7f344db21 MD5 | raw file
 1<?php
 2/**
 3 * WPSEO plugin file.
 4 *
 5 * @package WPSEO\Frontend
 6 */
 7
 8/**
 9 * Represents the classifier for determine the type of the currently opened page.
10 */
11class WPSEO_Frontend_Page_Type {
12
13	/**
14	 * Checks if the currently opened page is a simple page.
15	 *
16	 * @return bool Whether the currently opened page is a simple page.
17	 */
18	public function is_simple_page() {
19		return $this->get_simple_page_id() > 0;
20	}
21
22	/**
23	 * Returns the id of the currently opened page.
24	 *
25	 * @return int The id of the currently opened page.
26	 */
27	public function get_simple_page_id() {
28		if ( is_singular() ) {
29			return get_the_ID();
30		}
31
32		if ( is_home() && 'page' === get_option( 'show_on_front' ) ) {
33			return get_option( 'page_for_posts' );
34		}
35
36		/**
37		 * Filter: Allow changing the default page id.
38		 *
39		 * @api int $page_id The default page id.
40		 */
41		return apply_filters( 'wpseo_frontend_page_type_simple_page_id', 0 );
42	}
43}