PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.4
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 / wordproof-helper.php

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

110 lines 2.9 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 use Yoast\WP\SEO\Conditionals\Non_Multisite_Conditional;
6 use Yoast\WP\SEO\Conditionals\Third_Party\Wordproof_Plugin_Inactive_Conditional;
7 use Yoast\WP\SEO\Conditionals\User_Can_Publish_Posts_And_Pages_Conditional;
8
9 /**
10 * A helper object for WordProof integration.
11 */
12 class Wordproof_Helper {
13
14 /**
15 * Holds the Current Page helper instance.
16 *
17 * @var Current_Page_Helper
18 */
19 protected $current_page;
20
21 /**
22 * Holds the WooCommerce helper instance.
23 *
24 * @var Woocommerce_Helper
25 */
26 protected $woocommerce;
27
28 /**
29 * Holds the Options Page helper instance.
30 *
31 * @var Options_Helper
32 */
33 protected $options;
34
35 /**
36 * WordProof_Helper constructor.
37 *
38 * @param Current_Page_Helper $current_page The current page helper.
39 * @param Woocommerce_Helper $woocommerce The woocommerce helper.
40 * @param Options_Helper $options The options helper.
41 */
42 public function __construct( Current_Page_Helper $current_page, Woocommerce_Helper $woocommerce, Options_Helper $options ) {
43 $this->current_page = $current_page;
44 $this->woocommerce = $woocommerce;
45 $this->options = $options;
46 }
47
48 /**
49 * Remove site options after disabling the integration.
50 *
51 * @return bool Returns if the options are deleted
52 */
53 public function remove_site_options() {
54 return delete_site_option( 'wordproof_access_token' )
55 && delete_site_option( 'wordproof_source_id' );
56 }
57
58 /**
59 * Returns if conditionals are met. If not, the integration should be disabled.
60 *
61 * @param bool $return_conditional If the conditional class name that was unmet should be returned.
62 *
63 * @return bool|string Returns if the integration should be disabled.
64 */
65 public function integration_is_disabled( $return_conditional = false ) {
66 $conditionals = [ new Wordproof_Plugin_Inactive_Conditional(), new Non_Multisite_Conditional(), new User_Can_Publish_Posts_And_Pages_Conditional() ];
67
68 foreach ( $conditionals as $conditional ) {
69 if ( ! $conditional->is_met() ) {
70
71 if ( $return_conditional === true ) {
72 return ( new \ReflectionClass( $conditional ) )->getShortName();
73 }
74
75 return true;
76 }
77 }
78
79 return false;
80 }
81
82 /**
83 * Returns if the WordProof integration toggle is turned on.
84 *
85 * @return bool Returns if the integration toggle is set to true if conditionals are met.
86 */
87 public function integration_is_active() {
88 if ( $this->integration_is_disabled() ) {
89 return false;
90 }
91
92 return $this->options->get( 'wordproof_integration_active', true );
93 }
94
95 /**
96 * Return if WordProof should be active for this post editor page.
97 *
98 * @return bool Returns if WordProof should be active for this page.
99 */
100 public function is_active() {
101 $is_wordproof_active = $this->integration_is_active();
102
103 if ( ! $is_wordproof_active ) {
104 return false;
105 }
106
107 return ( $this->current_page->current_post_is_privacy_policy() || $this->woocommerce->current_post_is_terms_and_conditions_page() );
108 }
109 }
110