ComingSoonAdminBarBadge.php
1 year ago
ComingSoonCacheInvalidator.php
1 year ago
ComingSoonHelper.php
1 year ago
ComingSoonRequestHandler.php
9 months ago
ComingSoonHelper.php
54 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\Internal\ComingSoon; |
| 3 | |
| 4 | use Automattic\WooCommerce\Admin\WCAdminHelper; |
| 5 | |
| 6 | /** |
| 7 | * Provides helper methods for coming soon functionality. |
| 8 | */ |
| 9 | class ComingSoonHelper { |
| 10 | |
| 11 | /** |
| 12 | * Returns true when the entire site is live. |
| 13 | */ |
| 14 | public function is_site_live(): bool { |
| 15 | return 'yes' !== get_option( 'woocommerce_coming_soon' ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Returns true when the entire site is coming soon mode. |
| 20 | */ |
| 21 | public function is_site_coming_soon(): bool { |
| 22 | return 'yes' === get_option( 'woocommerce_coming_soon' ) && 'yes' !== get_option( 'woocommerce_store_pages_only' ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Returns true when only the store pages are in coming soon mode. |
| 27 | */ |
| 28 | public function is_store_coming_soon(): bool { |
| 29 | return 'yes' === get_option( 'woocommerce_coming_soon' ) && 'yes' === get_option( 'woocommerce_store_pages_only' ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Return true if the current page should be shown in coming soon mode. |
| 34 | */ |
| 35 | public function is_current_page_coming_soon(): bool { |
| 36 | // Early exit if coming soon mode not active. |
| 37 | if ( $this->is_site_live() ) { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | if ( $this->is_site_coming_soon() ) { |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | // Check the current page is a store page when in "store coming soon" mode. |
| 46 | if ( $this->is_store_coming_soon() && WCAdminHelper::is_current_page_store_page() ) { |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | // Default to false. |
| 51 | return false; |
| 52 | } |
| 53 | } |
| 54 |