PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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
← All changes | src/integrations/watchers/option-wpseo-watcher.php +24 -0 19.0 → trunk View file →
@@ -23,8 +23,9 @@
23 23 */
24 24 public function register_hooks() {
25 25 \add_action( 'update_option_wpseo', [ $this, 'check_semrush_option_disabled' ], 10, 2 );
26 26 \add_action( 'update_option_wpseo', [ $this, 'check_wincher_option_disabled' ], 10, 2 );
27 + \add_action( 'update_option_wpseo', [ $this, 'check_toggle_usage_tracking' ], 10, 2 );
27 28 }
28 29
29 30 /**
30 31 * Checks if the SEMrush integration is disabled; if so, deletes the tokens.
@@ -57,12 +58,33 @@
57 58 $disabled = $this->check_token_option_disabled( 'wincher_integration_active', 'wincher_tokens', $new_value );
58 59 if ( $disabled ) {
59 60 \YoastSEO()->helpers->options->set( 'wincher_website_id', '' );
60 61 }
62 +
61 63 return $disabled;
62 64 }
63 65
64 66 /**
67 + * Checks if the usage tracking feature is toggled; if so, set an option to stop us from messing with it.
68 + *
69 + * @param array $old_value The old value of the option.
70 + * @param array $new_value The new value of the option.
71 + *
72 + * @return bool Whether the option is set.
73 + */
74 + public function check_toggle_usage_tracking( $old_value, $new_value ) {
75 + $option_name = 'tracking';
76 +
77 + if ( \array_key_exists( $option_name, $old_value ) && \array_key_exists( $option_name, $new_value ) && $old_value[ $option_name ] !== $new_value[ $option_name ] && $old_value['toggled_tracking'] === false ) {
78 + \YoastSEO()->helpers->options->set( 'toggled_tracking', true );
79 +
80 + return true;
81 + }
82 +
83 + return false;
84 + }
85 +
86 + /**
65 87 * Checks if the passed integration is disabled; if so, deletes the tokens.
66 88 *
67 89 * We delete the tokens if the integration is disabled, no matter if
68 90 * the value has actually changed or not.
@@ -75,9 +97,11 @@
75 97 */
76 98 protected function check_token_option_disabled( $integration_option, $target_option, $new_value ) {
77 99 if ( \array_key_exists( $integration_option, $new_value ) && $new_value[ $integration_option ] === false ) {
78 100 \YoastSEO()->helpers->options->set( $target_option, [] );
101 +
79 102 return true;
80 103 }
104 +
81 105 return false;
82 106 }
83 107 }