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-settings-data.php
296 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WPSEO plugin file. |
| 4 | * |
| 5 | * @package WPSEO\Admin\Tracking |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Collects anonymized settings data. |
| 10 | */ |
| 11 | class WPSEO_Tracking_Settings_Data implements WPSEO_Collection { |
| 12 | |
| 13 | /** |
| 14 | * The options that need to be anonymized before they can be sent elsewhere. |
| 15 | * |
| 16 | * @var array All of the option_names which need to be |
| 17 | * anonymized before they can be sent elsewhere. |
| 18 | */ |
| 19 | private $anonymous_settings = [ |
| 20 | 'baiduverify', |
| 21 | 'googleverify', |
| 22 | 'msverify', |
| 23 | 'yandexverify', |
| 24 | 'ahrefsverify', |
| 25 | 'myyoast-oauth', |
| 26 | 'website_name', |
| 27 | 'alternate_website_name', |
| 28 | 'company_logo', |
| 29 | 'company_name', |
| 30 | 'company_alternate_name', |
| 31 | 'person_name', |
| 32 | 'person_logo', |
| 33 | 'person_logo_id', |
| 34 | 'company_logo_id', |
| 35 | 'facebook_site', |
| 36 | 'instagram_url', |
| 37 | 'linkedin_url', |
| 38 | 'myspace_url', |
| 39 | 'og_default_image', |
| 40 | 'og_default_image_id', |
| 41 | 'og_frontpage_title', |
| 42 | 'og_frontpage_desc', |
| 43 | 'og_frontpage_image', |
| 44 | 'og_frontpage_image_id', |
| 45 | 'open_graph_frontpage_title', |
| 46 | 'open_graph_frontpage_desc', |
| 47 | 'open_graph_frontpage_image', |
| 48 | 'open_graph_frontpage_image_id', |
| 49 | 'other_social_urls', |
| 50 | 'mastodon_url', |
| 51 | 'pinterest_url', |
| 52 | 'pinterestverify', |
| 53 | 'twitter_site', |
| 54 | 'youtube_url', |
| 55 | 'wikipedia_url', |
| 56 | 'semrush_tokens', |
| 57 | 'wincher_tokens', |
| 58 | 'wincher_website_id', |
| 59 | 'least_readability_ignore_list', |
| 60 | 'least_seo_score_ignore_list', |
| 61 | 'most_linked_ignore_list', |
| 62 | 'least_linked_ignore_list', |
| 63 | 'indexables_page_reading_list', |
| 64 | 'publishing_principles_id', |
| 65 | 'ownership_funding_info_id', |
| 66 | 'actionable_feedback_policy_id', |
| 67 | 'corrections_policy_id', |
| 68 | 'ethics_policy_id', |
| 69 | 'diversity_policy_id', |
| 70 | 'diversity_staffing_report_id', |
| 71 | ]; |
| 72 | |
| 73 | /** |
| 74 | * The options we want to track. |
| 75 | * |
| 76 | * @var array The option_names for the options we want to track. |
| 77 | */ |
| 78 | private $include_list = [ |
| 79 | 'ms_defaults_set', |
| 80 | 'version', |
| 81 | 'disableadvanced_meta', |
| 82 | 'ryte_indexability', |
| 83 | 'baiduverify', |
| 84 | 'googleverify', |
| 85 | 'ahrefsverify', |
| 86 | 'msverify', |
| 87 | 'yandexverify', |
| 88 | 'site_type', |
| 89 | 'has_multiple_authors', |
| 90 | 'environment_type', |
| 91 | 'content_analysis_active', |
| 92 | 'keyword_analysis_active', |
| 93 | 'inclusive_language_analysis_active', |
| 94 | 'enable_admin_bar_menu', |
| 95 | 'enable_cornerstone_content', |
| 96 | 'enable_xml_sitemap', |
| 97 | 'enable_text_link_counter', |
| 98 | 'show_onboarding_notice', |
| 99 | 'first_activated_on', |
| 100 | 'myyoast-oauth', |
| 101 | 'dynamic_permalinks', |
| 102 | 'website_name', |
| 103 | 'alternate_website_name', |
| 104 | 'company_logo', |
| 105 | 'company_name', |
| 106 | 'company_or_person', |
| 107 | 'person_name', |
| 108 | 'forcerewritetitle', |
| 109 | 'separator', |
| 110 | 'title-home-wpseo', |
| 111 | 'title-author-wpseo', |
| 112 | 'title-archive-wpseo', |
| 113 | 'title-search-wpseo', |
| 114 | 'title-404-wpseo', |
| 115 | 'metadesc-home-wpseo', |
| 116 | 'metadesc-author-wpseo', |
| 117 | 'metadesc-archive-wpseo', |
| 118 | 'rssbefore', |
| 119 | 'rssafter', |
| 120 | 'noindex-author-wpseo', |
| 121 | 'noindex-author-noposts-wpseo', |
| 122 | 'noindex-archive-wpseo', |
| 123 | 'disable-author', |
| 124 | 'disable-date', |
| 125 | 'disable-post_format', |
| 126 | 'disable-attachment', |
| 127 | 'breadcrumbs-404crumb', |
| 128 | 'breadcrumbs-display-blog-page', |
| 129 | 'breadcrumbs-boldlast', |
| 130 | 'breadcrumbs-archiveprefix', |
| 131 | 'breadcrumbs-enable', |
| 132 | 'breadcrumbs-home', |
| 133 | 'breadcrumbs-prefix', |
| 134 | 'breadcrumbs-searchprefix', |
| 135 | 'breadcrumbs-sep', |
| 136 | 'person_logo', |
| 137 | 'person_logo_id', |
| 138 | 'company_logo_id', |
| 139 | 'company_or_person_user_id', |
| 140 | 'stripcategorybase', |
| 141 | 'noindex-post', |
| 142 | 'display-metabox-pt-post', |
| 143 | 'noindex-page', |
| 144 | 'display-metabox-pt-page', |
| 145 | 'noindex-attachment', |
| 146 | 'display-metabox-pt-attachment', |
| 147 | 'display-metabox-tax-category', |
| 148 | 'noindex-tax-category', |
| 149 | 'display-metabox-tax-post_tag', |
| 150 | 'noindex-tax-post_tag', |
| 151 | 'display-metabox-tax-post_format', |
| 152 | 'noindex-tax-post_format', |
| 153 | 'taxonomy-category-ptparent', |
| 154 | 'taxonomy-post_tag-ptparent', |
| 155 | 'taxonomy-post_format-ptparent', |
| 156 | 'breadcrumbs-blog-remove', |
| 157 | 'hideeditbox-post', |
| 158 | 'hideeditbox-page', |
| 159 | 'hideeditbox-attachment', |
| 160 | 'hideeditbox-tax-category', |
| 161 | 'hideeditbox-tax-post_tag', |
| 162 | 'hideeditbox-tax-post_format', |
| 163 | 'facebook_site', |
| 164 | 'instagram_url', |
| 165 | 'linkedin_url', |
| 166 | 'myspace_url', |
| 167 | 'og_default_image', |
| 168 | 'og_default_image_id', |
| 169 | 'og_frontpage_title', |
| 170 | 'og_frontpage_desc', |
| 171 | 'og_frontpage_image', |
| 172 | 'og_frontpage_image_id', |
| 173 | 'open_graph_frontpage_title', |
| 174 | 'open_graph_frontpage_desc', |
| 175 | 'open_graph_frontpage_image', |
| 176 | 'open_graph_frontpage_image_id', |
| 177 | 'opengraph', |
| 178 | 'pinterest_url', |
| 179 | 'pinterestverify', |
| 180 | 'twitter', |
| 181 | 'twitter_site', |
| 182 | 'twitter_card_type', |
| 183 | 'youtube_url', |
| 184 | 'wikipedia_url', |
| 185 | 'mastodon_url', |
| 186 | 'indexables_indexing_completed', |
| 187 | 'semrush_integration_active', |
| 188 | 'semrush_tokens', |
| 189 | 'semrush_country_code', |
| 190 | 'enable_enhanced_slack_sharing', |
| 191 | 'enable_metabox_insights', |
| 192 | 'enable_link_suggestions', |
| 193 | 'enable_index_now', |
| 194 | 'enable_ai_generator', |
| 195 | 'workouts', |
| 196 | 'wincher_integration_active', |
| 197 | 'wincher_tokens', |
| 198 | 'wincher_website_id', |
| 199 | 'wincher_automatically_add_keyphrases', |
| 200 | 'first_time_install', |
| 201 | 'other_social_urls', |
| 202 | 'remove_feed_global', |
| 203 | 'remove_feed_global_comments', |
| 204 | 'remove_feed_post_comments', |
| 205 | 'remove_feed_authors', |
| 206 | 'remove_feed_categories', |
| 207 | 'remove_feed_tags', |
| 208 | 'remove_feed_custom_taxonomies', |
| 209 | 'remove_feed_post_types', |
| 210 | 'remove_feed_search', |
| 211 | 'remove_atom_rdf_feeds', |
| 212 | 'remove_shortlinks', |
| 213 | 'remove_rest_api_links', |
| 214 | 'remove_rsd_wlw_links', |
| 215 | 'remove_oembed_links', |
| 216 | 'remove_generator', |
| 217 | 'remove_emoji_scripts', |
| 218 | 'remove_powered_by_header', |
| 219 | 'remove_pingback_header', |
| 220 | 'clean_campaign_tracking_urls', |
| 221 | 'clean_permalinks', |
| 222 | 'clean_permalinks_extra_variables', |
| 223 | 'search_cleanup', |
| 224 | 'search_cleanup_emoji', |
| 225 | 'search_cleanup_patterns', |
| 226 | 'search_character_limit', |
| 227 | 'redirect_search_pretty_urls', |
| 228 | 'indexables_overview_state', |
| 229 | 'deny_search_crawling', |
| 230 | 'deny_wp_json_crawling', |
| 231 | 'deny_adsbot_crawling', |
| 232 | 'deny_ccbot_crawling', |
| 233 | 'deny_google_extended_crawling', |
| 234 | 'deny_gptbot_crawling', |
| 235 | 'last_known_no_unindexed', |
| 236 | 'site_kit_connected', |
| 237 | 'site_kit_tracking_setup_widget_loaded', |
| 238 | 'site_kit_tracking_first_interaction_stage', |
| 239 | 'site_kit_tracking_last_interaction_stage', |
| 240 | 'site_kit_tracking_setup_widget_temporarily_dismissed', |
| 241 | 'site_kit_tracking_setup_widget_permanently_dismissed', |
| 242 | 'google_site_kit_feature_enabled', |
| 243 | 'ai_free_sparks_started_on', |
| 244 | 'enable_llms_txt', |
| 245 | 'llms_txt_selection_mode', |
| 246 | 'configuration_finished_steps', |
| 247 | 'enable_schema_aggregation_endpoint', |
| 248 | 'schema_aggregation_endpoint_enabled_on', |
| 249 | 'enable_task_list', |
| 250 | 'enable_schema', |
| 251 | // No need to add anything from WPSEO_Option_Tracking_Only as they are added automatically below. |
| 252 | ]; |
| 253 | |
| 254 | /** |
| 255 | * Returns the collection data. |
| 256 | * |
| 257 | * @return array The collection data. |
| 258 | */ |
| 259 | public function get() { |
| 260 | /** |
| 261 | * Filter: 'wpseo_tracking_settings_include_list' - Allow filtering the settings included in tracking. |
| 262 | * |
| 263 | * @param string $include_list The list with included setting names. |
| 264 | */ |
| 265 | $this->include_list = apply_filters( 'wpseo_tracking_settings_include_list', $this->include_list ); |
| 266 | |
| 267 | // Always include the tracking only option keys. |
| 268 | $this->include_list = array_merge( $this->include_list, YoastSEO()->helpers->options->get_tracking_only_options() ); |
| 269 | |
| 270 | $options = WPSEO_Options::get_all(); |
| 271 | // Returns the settings of which the keys intersect with the values of the include list. |
| 272 | $options = array_intersect_key( $options, array_flip( $this->include_list ) ); |
| 273 | |
| 274 | return [ |
| 275 | 'settings' => $this->anonymize_settings( $options ), |
| 276 | ]; |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * Anonimizes the WPSEO_Options array by replacing all $anonymous_settings values to 'used'. |
| 281 | * |
| 282 | * @param array $settings The settings. |
| 283 | * |
| 284 | * @return array The anonymized settings. |
| 285 | */ |
| 286 | private function anonymize_settings( $settings ) { |
| 287 | foreach ( $this->anonymous_settings as $setting ) { |
| 288 | if ( ! empty( $settings[ $setting ] ) ) { |
| 289 | $settings[ $setting ] = 'used'; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | return $settings; |
| 294 | } |
| 295 | } |
| 296 |