/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. * Represents the classifier for determine the type of the currently opened page.
  9. */
  10. class WPSEO_Frontend_Page_Type {
  11. /**
  12. * Checks if the currently opened page is a simple page.
  13. *
  14. * @return bool Whether the currently opened page is a simple page.
  15. */
  16. public function is_simple_page() {
  17. return $this->get_simple_page_id() > 0;
  18. }
  19. /**
  20. * Returns the id of the currently opened page.
  21. *
  22. * @return int The id of the currently opened page.
  23. */
  24. public function get_simple_page_id() {
  25. if ( is_singular() ) {
  26. return get_the_ID();
  27. }
  28. if ( is_home() && 'page' === get_option( 'show_on_front' ) ) {
  29. return get_option( 'page_for_posts' );
  30. }
  31. /**
  32. * Filter: Allow changing the default page id.
  33. *
  34. * @api int $page_id The default page id.
  35. */
  36. return apply_filters( 'wpseo_frontend_page_type_simple_page_id', 0 );
  37. }
  38. }