123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?php
- /**
- * WPSEO plugin file.
- *
- * @package WPSEO\Admin\Tracking
- */
- /**
- * Collects anonymized settings data.
- */
- class WPSEO_Tracking_Settings_Data implements WPSEO_Collection {
- /**
- * @var array $anonymous_settings contains all of the option_names which need to be
- * anonimized before they can be sent elsewhere.
- */
- private $anonymous_settings = [
- 'baiduverify',
- 'googleverify',
- 'msverify',
- 'yandexverify',
- 'myyoast-oauth',
- 'website_name',
- 'alternate_website_name',
- 'company_logo',
- 'company_name',
- 'person_name',
- 'person_logo',
- 'person_logo_id',
- 'company_logo_id',
- 'facebook_site',
- 'instagram_url',
- 'linkedin_url',
- 'myspace_url',
- 'og_default_image',
- 'og_default_image_id',
- 'og_frontpage_title',
- 'og_frontpage_desc',
- 'og_frontpage_image',
- 'og_frontpage_image_id',
- 'pinterest_url',
- 'pinterestverify',
- 'twitter_site',
- 'youtube_url',
- 'wikipedia_url',
- 'fbadminapp',
- ];
- /**
- * @var array $include_list contains the option_names for the options we want to track.
- */
- private $include_list = [
- 'ms_defaults_set',
- 'version',
- 'disableadvanced_meta',
- 'onpage_indexability',
- 'baiduverify',
- 'googleverify',
- 'msverify',
- 'yandexverify',
- 'site_type',
- 'has_multiple_authors',
- 'environment_type',
- 'content_analysis_active',
- 'keyword_analysis_active',
- 'enable_admin_bar_menu',
- 'enable_cornerstone_content',
- 'enable_xml_sitemap',
- 'enable_text_link_counter',
- 'show_onboarding_notice',
- 'first_activated_on',
- 'myyoast-oauth',
- 'website_name',
- 'alternate_website_name',
- 'company_logo',
- 'company_name',
- 'company_or_person',
- 'person_name',
- 'title_test',
- 'forcerewritetitle',
- 'separator',
- 'title-home-wpseo',
- 'title-author-wpseo',
- 'title-archive-wpseo',
- 'title-search-wpseo',
- 'title-404-wpseo',
- 'metadesc-home-wpseo',
- 'metadesc-author-wpseo',
- 'metadesc-archive-wpseo',
- 'rssbefore',
- 'rssafter',
- 'noindex-author-wpseo',
- 'noindex-author-noposts-wpseo',
- 'noindex-archive-wpseo',
- 'disable-author',
- 'disable-date',
- 'disable-post_format',
- 'disable-attachment',
- 'is-media-purge-relevant',
- 'breadcrumbs-404crumb',
- 'breadcrumbs-display-blog-page',
- 'breadcrumbs-boldlast',
- 'breadcrumbs-archiveprefix',
- 'breadcrumbs-enable',
- 'breadcrumbs-home',
- 'breadcrumbs-prefix',
- 'breadcrumbs-searchprefix',
- 'breadcrumbs-sep',
- 'person_logo',
- 'person_logo_id',
- 'company_logo_id',
- 'company_or_person_user_id',
- 'stripcategorybase',
- 'noindex-post',
- 'showdate-post',
- 'display-metabox-pt-post',
- 'noindex-page',
- 'showdate-page',
- 'display-metabox-pt-page',
- 'noindex-attachment',
- 'showdate-attachment',
- 'display-metabox-pt-attachment',
- 'display-metabox-tax-category',
- 'noindex-tax-category',
- 'display-metabox-tax-post_tag',
- 'noindex-tax-post_tag',
- 'display-metabox-tax-post_format',
- 'noindex-tax-post_format',
- 'taxonomy-category-ptparent',
- 'taxonomy-post_tag-ptparent',
- 'taxonomy-post_format-ptparent',
- 'breadcrumbs-blog-remove',
- 'hideeditbox-post',
- 'hideeditbox-page',
- 'hideeditbox-attachment',
- 'hideeditbox-tax-category',
- 'hideeditbox-tax-post_tag',
- 'hideeditbox-tax-post_format',
- 'facebook_site',
- 'instagram_url',
- 'linkedin_url',
- 'myspace_url',
- 'og_default_image',
- 'og_default_image_id',
- 'og_frontpage_title',
- 'og_frontpage_desc',
- 'og_frontpage_image',
- 'og_frontpage_image_id',
- 'opengraph',
- 'pinterest_url',
- 'pinterestverify',
- 'twitter',
- 'twitter_site',
- 'twitter_card_type',
- 'youtube_url',
- 'wikipedia_url',
- 'fbadminapp',
- ];
- /**
- * Returns the collection data.
- *
- * @return array The collection data.
- */
- public function get() {
- /**
- * Filter: 'wpseo_tracking_settings_include_list' - Allow filtering the settings included in tracking.
- *
- * @api string $include_list the list with included setting names.
- */
- $this->include_list = apply_filters( 'wpseo_tracking_settings_include_list', $this->include_list );
- $options = WPSEO_Options::get_all();
- // Returns the settings of which the keys intersect with the values of the include list.
- $options = array_intersect_key( $options, array_flip( $this->include_list ) );
- return [
- 'settings' => $this->anonymize_settings( $options ),
- ];
- }
- /**
- * Anonimizes the WPSEO_Options array by replacing all $anonymous_settings values to 'used'.
- *
- * @param array $settings The settings.
- * @return array The anonymized settings.
- */
- private function anonymize_settings( $settings ) {
- foreach ( $this->anonymous_settings as $setting ) {
- if ( ! empty( $settings[ $setting ] ) ) {
- $settings[ $setting ] = 'used';
- }
- }
- return $settings;
- }
- }
|