| 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 |
'myyoast-oauth', |
| 25 |
'website_name', |
| 26 |
'alternate_website_name', |
| 27 |
'company_logo', |
| 28 |
'company_name', |
| 29 |
'person_name', |
| 30 |
'person_logo', |
| 31 |
'person_logo_id', |
| 32 |
'company_logo_id', |
| 33 |
'facebook_site', |
| 34 |
'instagram_url', |
| 35 |
'linkedin_url', |
| 36 |
'myspace_url', |
| 37 |
'og_default_image', |
| 38 |
'og_default_image_id', |
| 39 |
'og_frontpage_title', |
| 40 |
'og_frontpage_desc', |
| 41 |
'og_frontpage_image', |
| 42 |
'og_frontpage_image_id', |
| 43 |
'open_graph_frontpage_title', |
| 44 |
'open_graph_frontpage_desc', |
| 45 |
'open_graph_frontpage_image', |
| 46 |
'open_graph_frontpage_image_id', |
| 47 |
'pinterest_url', |
| 48 |
'pinterestverify', |
| 49 |
'twitter_site', |
| 50 |
'youtube_url', |
| 51 |
'wikipedia_url', |
| 52 |
'semrush_tokens', |
| 53 |
'zapier_api_key', |
| 54 |
'wincher_tokens', |
| 55 |
'wincher_website_id', |
| 56 |
]; |
| 57 |
|
| 58 |
/** |
| 59 |
* The options we want to track. |
| 60 |
* |
| 61 |
* @var array The option_names for the options we want to track. |
| 62 |
*/ |
| 63 |
private $include_list = [ |
| 64 |
'ms_defaults_set', |
| 65 |
'version', |
| 66 |
'disableadvanced_meta', |
| 67 |
'ryte_indexability', |
| 68 |
'baiduverify', |
| 69 |
'googleverify', |
| 70 |
'msverify', |
| 71 |
'yandexverify', |
| 72 |
'site_type', |
| 73 |
'has_multiple_authors', |
| 74 |
'environment_type', |
| 75 |
'content_analysis_active', |
| 76 |
'keyword_analysis_active', |
| 77 |
'enable_admin_bar_menu', |
| 78 |
'enable_cornerstone_content', |
| 79 |
'enable_xml_sitemap', |
| 80 |
'enable_text_link_counter', |
| 81 |
'show_onboarding_notice', |
| 82 |
'first_activated_on', |
| 83 |
'myyoast-oauth', |
| 84 |
'dynamic_permalinks', |
| 85 |
'website_name', |
| 86 |
'alternate_website_name', |
| 87 |
'company_logo', |
| 88 |
'company_name', |
| 89 |
'company_or_person', |
| 90 |
'person_name', |
| 91 |
'forcerewritetitle', |
| 92 |
'separator', |
| 93 |
'title-home-wpseo', |
| 94 |
'title-author-wpseo', |
| 95 |
'title-archive-wpseo', |
| 96 |
'title-search-wpseo', |
| 97 |
'title-404-wpseo', |
| 98 |
'metadesc-home-wpseo', |
| 99 |
'metadesc-author-wpseo', |
| 100 |
'metadesc-archive-wpseo', |
| 101 |
'rssbefore', |
| 102 |
'rssafter', |
| 103 |
'noindex-author-wpseo', |
| 104 |
'noindex-author-noposts-wpseo', |
| 105 |
'noindex-archive-wpseo', |
| 106 |
'disable-author', |
| 107 |
'disable-date', |
| 108 |
'disable-post_format', |
| 109 |
'disable-attachment', |
| 110 |
'breadcrumbs-404crumb', |
| 111 |
'breadcrumbs-display-blog-page', |
| 112 |
'breadcrumbs-boldlast', |
| 113 |
'breadcrumbs-archiveprefix', |
| 114 |
'breadcrumbs-enable', |
| 115 |
'breadcrumbs-home', |
| 116 |
'breadcrumbs-prefix', |
| 117 |
'breadcrumbs-searchprefix', |
| 118 |
'breadcrumbs-sep', |
| 119 |
'person_logo', |
| 120 |
'person_logo_id', |
| 121 |
'company_logo_id', |
| 122 |
'company_or_person_user_id', |
| 123 |
'stripcategorybase', |
| 124 |
'noindex-post', |
| 125 |
'display-metabox-pt-post', |
| 126 |
'noindex-page', |
| 127 |
'display-metabox-pt-page', |
| 128 |
'noindex-attachment', |
| 129 |
'display-metabox-pt-attachment', |
| 130 |
'display-metabox-tax-category', |
| 131 |
'noindex-tax-category', |
| 132 |
'display-metabox-tax-post_tag', |
| 133 |
'noindex-tax-post_tag', |
| 134 |
'display-metabox-tax-post_format', |
| 135 |
'noindex-tax-post_format', |
| 136 |
'taxonomy-category-ptparent', |
| 137 |
'taxonomy-post_tag-ptparent', |
| 138 |
'taxonomy-post_format-ptparent', |
| 139 |
'breadcrumbs-blog-remove', |
| 140 |
'hideeditbox-post', |
| 141 |
'hideeditbox-page', |
| 142 |
'hideeditbox-attachment', |
| 143 |
'hideeditbox-tax-category', |
| 144 |
'hideeditbox-tax-post_tag', |
| 145 |
'hideeditbox-tax-post_format', |
| 146 |
'facebook_site', |
| 147 |
'instagram_url', |
| 148 |
'linkedin_url', |
| 149 |
'myspace_url', |
| 150 |
'og_default_image', |
| 151 |
'og_default_image_id', |
| 152 |
'og_frontpage_title', |
| 153 |
'og_frontpage_desc', |
| 154 |
'og_frontpage_image', |
| 155 |
'og_frontpage_image_id', |
| 156 |
'open_graph_frontpage_title', |
| 157 |
'open_graph_frontpage_desc', |
| 158 |
'open_graph_frontpage_image', |
| 159 |
'open_graph_frontpage_image_id', |
| 160 |
'opengraph', |
| 161 |
'pinterest_url', |
| 162 |
'pinterestverify', |
| 163 |
'twitter', |
| 164 |
'twitter_site', |
| 165 |
'twitter_card_type', |
| 166 |
'youtube_url', |
| 167 |
'wikipedia_url', |
| 168 |
'indexables_indexing_completed', |
| 169 |
'semrush_integration_active', |
| 170 |
'semrush_tokens', |
| 171 |
'semrush_country_code', |
| 172 |
'enable_enhanced_slack_sharing', |
| 173 |
'zapier_integration_active', |
| 174 |
'zapier_api_key', |
| 175 |
'enable_metabox_insights', |
| 176 |
'enable_link_suggestions', |
| 177 |
'workouts', |
| 178 |
'wincher_integration_active', |
| 179 |
'wincher_tokens', |
| 180 |
'wincher_website_id', |
| 181 |
'wincher_automatically_add_keyphrases', |
| 182 |
'first_time_install', |
| 183 |
]; |
| 184 |
|
| 185 |
/** |
| 186 |
* Returns the collection data. |
| 187 |
* |
| 188 |
* @return array The collection data. |
| 189 |
*/ |
| 190 |
public function get() { |
| 191 |
/** |
| 192 |
* Filter: 'wpseo_tracking_settings_include_list' - Allow filtering the settings included in tracking. |
| 193 |
* |
| 194 |
* @api string $include_list the list with included setting names. |
| 195 |
*/ |
| 196 |
$this->include_list = apply_filters( 'wpseo_tracking_settings_include_list', $this->include_list ); |
| 197 |
|
| 198 |
$options = WPSEO_Options::get_all(); |
| 199 |
// Returns the settings of which the keys intersect with the values of the include list. |
| 200 |
$options = array_intersect_key( $options, array_flip( $this->include_list ) ); |
| 201 |
|
| 202 |
return [ |
| 203 |
'settings' => $this->anonymize_settings( $options ), |
| 204 |
]; |
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* Anonimizes the WPSEO_Options array by replacing all $anonymous_settings values to 'used'. |
| 209 |
* |
| 210 |
* @param array $settings The settings. |
| 211 |
* |
| 212 |
* @return array The anonymized settings. |
| 213 |
*/ |
| 214 |
private function anonymize_settings( $settings ) { |
| 215 |
foreach ( $this->anonymous_settings as $setting ) { |
| 216 |
if ( ! empty( $settings[ $setting ] ) ) { |
| 217 |
$settings[ $setting ] = 'used'; |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
return $settings; |
| 222 |
} |
| 223 |
} |
| 224 |
|