PluginProbe ʕ •ᴥ•ʔ
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.5
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 19.1 19.10 19.11 19.12 19.13 19.14 19.2 19.3 19.4 19.5 19.5.1 19.6 19.6.1 19.7 19.7.1 19.7.2 19.8 19.9 20.0 20.1 20.10 20.11 20.12 20.13 20.2 20.2.1 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.8.1 21.9 21.9.1 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.8.1 24.9 25.0 25.1 25.2 25.3 25.3.1 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.1.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.1.1 27.2 27.3 27.4
wordpress-seo / admin / tracking / class-tracking-addon-data.php
wordpress-seo / admin / tracking Last commit date
class-tracking-addon-data.php 2 years ago class-tracking-default-data.php 3 years ago class-tracking-plugin-data.php 2 years ago class-tracking-server-data.php 3 years ago class-tracking-settings-data.php 3 months ago class-tracking-theme-data.php 4 years ago class-tracking.php 1 year ago
class-tracking-addon-data.php
127 lines
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin\Tracking
6 */
7
8 use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
9
10 /**
11 * Represents the addon option data.
12 */
13 class WPSEO_Tracking_Addon_Data implements WPSEO_Collection {
14
15 /**
16 * The local options we want to track.
17 *
18 * @var string[] The option_names for the options we want to track.
19 */
20 private $local_include_list = [
21 'use_multiple_locations',
22 'multiple_locations_same_organization',
23 'business_type',
24 'woocommerce_local_pickup_setting',
25 ];
26
27 /**
28 * The woo options we want to track.
29 *
30 * @var string[] The option_names for the options we want to track.
31 */
32 private $woo_include_list = [];
33
34 /**
35 * The news options we want to track.
36 *
37 * @var string[] The option_names for the options we want to track.
38 */
39 private $news_include_list = [];
40
41 /**
42 * The video options we want to track.
43 *
44 * @var string[] The option_names for the options we want to track.
45 */
46 private $video_include_list = [];
47
48 /**
49 * Returns the collection data.
50 *
51 * @return array The collection data.
52 */
53 public function get() {
54
55 $addon_settings = [];
56 $addon_manager = new WPSEO_Addon_Manager();
57
58 if ( $addon_manager->is_installed( WPSEO_Addon_Manager::LOCAL_SLUG ) ) {
59 $addon_settings = $this->get_local_addon_settings( $addon_settings, 'wpseo_local', WPSEO_Addon_Manager::LOCAL_SLUG, $this->local_include_list );
60 }
61
62 if ( $addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ) ) {
63 $addon_settings = $this->get_addon_settings( $addon_settings, 'wpseo_woo', WPSEO_Addon_Manager::WOOCOMMERCE_SLUG, $this->woo_include_list );
64 }
65
66 if ( $addon_manager->is_installed( WPSEO_Addon_Manager::NEWS_SLUG ) ) {
67 $addon_settings = $this->get_addon_settings( $addon_settings, 'wpseo_news', WPSEO_Addon_Manager::NEWS_SLUG, $this->news_include_list );
68 }
69
70 if ( $addon_manager->is_installed( WPSEO_Addon_Manager::VIDEO_SLUG ) ) {
71 $addon_settings = $this->get_addon_settings( $addon_settings, 'wpseo_video', WPSEO_Addon_Manager::VIDEO_SLUG, $this->video_include_list );
72 }
73
74 return $addon_settings;
75 }
76
77 /**
78 * Gets the tracked options from the addon
79 *
80 * @param array $addon_settings The current list of addon settings.
81 * @param string $source_name The option key of the addon.
82 * @param string $slug The addon slug.
83 * @param array $option_include_list All the options to be included in tracking.
84 *
85 * @return array
86 */
87 public function get_addon_settings( array $addon_settings, $source_name, $slug, $option_include_list ) {
88 $source_options = get_option( $source_name, [] );
89 if ( ! is_array( $source_options ) || empty( $source_options ) ) {
90 return $addon_settings;
91 }
92 $addon_settings[ $slug ] = array_intersect_key( $source_options, array_flip( $option_include_list ) );
93
94 return $addon_settings;
95 }
96
97 /**
98 * Filter business_type in local addon settings.
99 *
100 * Remove the business_type setting when 'multiple_locations_shared_business_info' setting is turned off.
101 *
102 * @param array $addon_settings The current list of addon settings.
103 * @param string $source_name The option key of the addon.
104 * @param string $slug The addon slug.
105 * @param array $option_include_list All the options to be included in tracking.
106 *
107 * @return array
108 */
109 public function get_local_addon_settings( array $addon_settings, $source_name, $slug, $option_include_list ) {
110 $source_options = get_option( $source_name, [] );
111 if ( ! is_array( $source_options ) || empty( $source_options ) ) {
112 return $addon_settings;
113 }
114 $addon_settings[ $slug ] = array_intersect_key( $source_options, array_flip( $option_include_list ) );
115
116 if ( array_key_exists( 'use_multiple_locations', $source_options ) && array_key_exists( 'business_type', $addon_settings[ $slug ] ) && $source_options['use_multiple_locations'] === 'on' && $source_options['multiple_locations_shared_business_info'] === 'off' ) {
117 $addon_settings[ $slug ]['business_type'] = 'multiple_locations';
118 }
119
120 if ( ! ( new WooCommerce_Conditional() )->is_met() ) {
121 unset( $addon_settings[ $slug ]['woocommerce_local_pickup_setting'] );
122 }
123
124 return $addon_settings;
125 }
126 }
127