PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 19.0
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v19.0
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / helpers / woocommerce-helper.php

woocommerce-helper.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 19.0, at src/helpers/woocommerce-helper.php

72 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Helpers;
4
5 /**
6 * Represents helper methods for WooCommerce.
7 */
8 class Woocommerce_Helper {
9
10 /**
11 * Checks if WooCommerce is active.
12 *
13 * @return bool Is WooCommerce active.
14 */
15 public function is_active() {
16 return \class_exists( 'WooCommerce' );
17 }
18
19 /**
20 * Returns the id of the set WooCommerce shop page.
21 *
22 * @return int The ID of the set page.
23 */
24 public function get_shop_page_id() {
25 if ( ! \function_exists( 'wc_get_page_id' ) ) {
26 return -1;
27 }
28
29 return \wc_get_page_id( 'shop' );
30 }
31
32 /**
33 * Checks if the current page is a WooCommerce shop page.
34 *
35 * @return bool True when the page is a shop page.
36 */
37 public function is_shop_page() {
38 if ( ! \function_exists( 'is_shop' ) ) {
39 return false;
40 }
41
42 if ( ! \is_shop() ) {
43 return false;
44 }
45
46 if ( \is_search() ) {
47 return false;
48 }
49
50 return true;
51 }
52
53 /**
54 * Checks if the current page is a WooCommerce shop page.
55 *
56 * @return bool True when the page is a shop page.
57 */
58 public function current_post_is_terms_and_conditions_page() {
59 if ( ! \function_exists( 'wc_terms_and_conditions_page_id' ) ) {
60 return false;
61 }
62
63 global $post;
64
65 if ( ! isset( $post->ID ) ) {
66 return false;
67 }
68
69 return \intval( $post->ID ) === \intval( \wc_terms_and_conditions_page_id() );
70 }
71 }
72