register-settings.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <?php
  2. /**
  3. * Registering MonsterInsights Settings
  4. *
  5. * @since 6.0.0
  6. *
  7. * @package MonsterInsights
  8. * @subpackage Settings API
  9. * @author Chris Christoff
  10. */
  11. /**
  12. * Callback for getting all of the settings tabs for MonsterInsights.
  13. *
  14. * @since 6.0.0
  15. * @return array $tabs
  16. */
  17. function monsterinsights_get_settings_tabs() {
  18. // Levels: lite, basic, plus, pro
  19. // coming soon = true (don't count on this)
  20. $tabs = array(
  21. 'engagement' => array(
  22. 'title' => esc_html__( 'Engagement', 'google-analytics-for-wordpress' ),
  23. 'level' => 'lite'
  24. ),
  25. 'demographics' => array(
  26. 'title' => esc_html__( 'Demographics', 'google-analytics-for-wordpress' ),
  27. 'level' => 'lite'
  28. ),
  29. 'links' => array(
  30. 'title' => esc_html__( 'Link Attribution', 'google-analytics-for-wordpress' ),
  31. 'level' => 'lite'
  32. ),
  33. 'files' => array(
  34. 'title' => esc_html__( 'File Downloads', 'google-analytics-for-wordpress' ),
  35. 'level' => 'lite'
  36. ),
  37. 'affiliates' => array(
  38. 'title' => esc_html__( 'Affiliate Links', 'google-analytics-for-wordpress' ),
  39. 'level' => 'lite'
  40. ),
  41. 'social' => array(
  42. 'title' => esc_html__( 'Social', 'google-analytics-for-wordpress' ),
  43. 'level' => 'basic',
  44. 'comingsoon' => true
  45. ),
  46. 'ads' => array(
  47. 'title' => esc_html__( 'Ads', 'google-analytics-for-wordpress' ),
  48. 'level' => 'plus',
  49. ),
  50. 'forms' => array(
  51. 'title' => esc_html__( 'Forms', 'google-analytics-for-wordpress' ),
  52. 'level' => 'pro',
  53. ),
  54. 'ecommerce' => array(
  55. 'title' => esc_html__( 'eCommerce', 'google-analytics-for-wordpress' ),
  56. 'level' => 'pro'
  57. ),
  58. 'media' => array(
  59. 'title' => esc_html__( 'Media', 'google-analytics-for-wordpress' ),
  60. 'level' => 'plus',
  61. 'comingsoon' => true
  62. ),
  63. 'memberships' => array(
  64. 'title' => esc_html__( 'Memberships', 'google-analytics-for-wordpress' ),
  65. 'level' => 'plus',
  66. 'comingsoon' => true
  67. ),
  68. 'dimensions' => array(
  69. 'title' => esc_html__( 'Custom Dimensions', 'google-analytics-for-wordpress' ),
  70. 'level' => 'pro',
  71. ),
  72. 'performance' => array(
  73. 'title' => esc_html__( 'Performance', 'google-analytics-for-wordpress' ),
  74. 'level' => 'plus'
  75. ),
  76. 'amp' => array(
  77. 'title' => esc_html__( 'Google AMP', 'google-analytics-for-wordpress' ),
  78. 'level' => 'plus'
  79. ),
  80. 'goptimize' => array(
  81. 'title' => esc_html__( 'Google Optimize', 'google-analytics-for-wordpress' ),
  82. 'level' => 'pro'
  83. ),
  84. 'fbia' => array(
  85. 'title' => esc_html__( 'FB Instant Articles', 'google-analytics-for-wordpress' ),
  86. 'level' => 'plus'
  87. ),
  88. 'bounce' => array(
  89. 'title' => esc_html__( 'Bounce Reduction', 'google-analytics-for-wordpress' ),
  90. 'level' => 'plus',
  91. 'comingsoon' => true
  92. ),
  93. 'reporting' => array(
  94. 'title' => esc_html__( 'Additional Reporting', 'google-analytics-for-wordpress' ),
  95. 'level' => 'plus',
  96. 'comingsoon' => true
  97. ),
  98. 'notifications' => array(
  99. 'title' => esc_html__( 'Notifications', 'google-analytics-for-wordpress' ),
  100. 'level' => 'basic',
  101. 'comingsoon' => true
  102. ),
  103. 'compatibility' => array(
  104. 'title' => esc_html__( 'Compatibility', 'google-analytics-for-wordpress' ),
  105. 'level' => 'lite'
  106. ),
  107. 'eucompliance' => array(
  108. 'title' => esc_html__( 'EU Compliance', 'google-analytics-for-wordpress' ),
  109. 'level' => 'basic'
  110. ),
  111. 'permissions' => array(
  112. 'title' => esc_html__( 'Permissions', 'google-analytics-for-wordpress' ),
  113. 'level' => 'lite'
  114. ),
  115. );
  116. /**
  117. * Developers Warning: MonsterInsights does not guarantee backwards compatiblity
  118. * of tabs yet. We might add/remove/reorder/edit tabs for the first few major
  119. * versions after 7.0 to ensure we've got the right layout for the long term.
  120. * Changes may be done without advance warning or announcement. You've been warned.
  121. */
  122. return apply_filters( 'monsterinsights_settings_tabs', $tabs );
  123. }
  124. /**
  125. * Retrieve the array of plugin settings
  126. *
  127. * @since 6.0.0
  128. * @return array
  129. */
  130. function monsterinsights_get_registered_settings() {
  131. /**
  132. * 'Whitelisted' MonsterInsights settings, filters are provided for each settings
  133. * section to allow extensions and other plugins to add their own settings
  134. */
  135. /**
  136. * Developers Warning: MonsterInsights does not guarantee backwards compatiblity
  137. * of settings or tabs. We may add/remove settings and/or tabs, or re-arrange the
  138. * settings panel as we need to. We provide these filters here right now for internal use only.
  139. * As such the filters below may be removed or altered at any time, without advance
  140. * warning or announcement. You've been warned.
  141. *
  142. * We will eventually promise backwards compatibility on these filters below but we want to ensure
  143. * for the first few major releases after 7.0 we do that the current settings arrangement won't stifle
  144. * our development progress. Once we're confident we've made the correct decision on settings layout,
  145. * we'll remove this notice, and only at that point should you rely on the filters below.
  146. */
  147. $monsterinsights_settings = array(
  148. /** Engagement Settings */
  149. 'engagement' => apply_filters( 'monsterinsights_settings_engagement',
  150. array(
  151. 'ignore_users' => array(
  152. 'id' => 'ignore_users',
  153. 'name' => __( 'Ignore these user roles from tracking:', 'google-analytics-for-wordpress' ),
  154. 'desc' => __( 'Users that have at least one of these roles will not be tracked into Google Analytics.', 'google-analytics-for-wordpress' ),
  155. 'type' => 'select',
  156. 'options' => monsterinsights_get_roles(),
  157. 'select2' => true,
  158. 'multiple' => true,
  159. 'allowclear' => true,
  160. ),
  161. 'events_mode' => array(
  162. 'id' => 'events_mode',
  163. 'name' => __( 'Enable MonsterInsights events tracking:', 'google-analytics-for-wordpress' ),
  164. 'desc' => __( 'This turns on our Javascript based tracking system which among other things tracks clicks on outbound, affiliate, mail, telephone, hashed and download links.', 'google-analytics-for-wordpress' ),
  165. 'type' => 'radio',
  166. 'std' => 'js',
  167. 'options' => array(
  168. 'js' => __( 'Yes (Recommended)', 'google-analytics-for-wordpress' ),
  169. 'none' => __( 'No', 'google-analytics-for-wordpress' ),
  170. ),
  171. ),
  172. )
  173. ),
  174. /** Demographics Settings */
  175. 'demographics' => apply_filters('monsterinsights_settings_demographics',
  176. array(
  177. 'demographics' => array(
  178. 'id' => 'demographics',
  179. 'name' => __( 'Enable Demographics and Interests Reports for Remarketing and Advertising', 'google-analytics-for-wordpress' ),
  180. 'desc' => sprintf( esc_html__( 'Check this setting to add the Demographics and Remarketing features to your Google Analytics tracking code. Make sure to enable Demographics and Remarketing in your Google Analytics account. We have a guide for how to do that in our %1$sknowledge base%2$s. For more information about Remarketing, we refer you to %3$sGoogle\'s documentation%2$s. Note that usage of this function is affected by privacy and cookie laws around the world. Be sure to follow the laws that affect your target audience.', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'settings-page', 'demographics-setting-doc-link', 'https://www.monsterinsights.com/docs/enable-demographics-and-interests-report-in-google-analytics/' ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">',
  181. '</a>','<a href="https://support.google.com/analytics/answer/2444872?hl=' . get_locale() . '" target="_blank" rel="noopener noreferrer" referrer="no-referrer">'
  182. ),
  183. 'type' => 'checkbox',
  184. ),
  185. 'anonymize_ips' => array(
  186. 'id' => 'anonymize_ips',
  187. 'name' => __( 'Anonymize IP addresses?', 'google-analytics-for-wordpress' ),
  188. 'desc' => sprintf( esc_html__( 'This adds %1$s, telling Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/ip-anonymization" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_anonymizeIp</code></a>' ),
  189. 'type' => 'checkbox',
  190. ),
  191. )
  192. ),
  193. /** Enhanced Link Attribution Settings */
  194. 'links' => apply_filters('monsterinsights_settings_links',
  195. array(
  196. 'enhanced_link_attribution' => array(
  197. 'id' => 'enhanced_link_attribution',
  198. 'name' => __( 'Enable enhanced link attribution?', 'google-analytics-for-wordpress' ),
  199. 'desc' => sprintf( esc_html__( 'Add %1$sEnhanced Link Attribution%2$s to your tracking code.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-link-attribution" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', ' </a>' ),
  200. 'type' => 'checkbox',
  201. ),
  202. 'hash_tracking' => array(
  203. 'id' => 'hash_tracking',
  204. 'name' => __( 'Turn on anchor tracking', 'google-analytics-for-wordpress' ),
  205. 'desc' => esc_html__( 'Many WordPress "1-page" style themes rely on anchor tags for navigation to show virtual pages. The problem is that to Google Analytics, these are all just a single page, and it makes it hard to get meaningful statistics about pages viewed. This feature allows proper tracking in those themes.', 'google-analytics-for-wordpress' ),
  206. 'type' => 'checkbox',
  207. ),
  208. 'allow_anchor' => array(
  209. 'id' => 'allow_anchor',
  210. 'name' => __( 'Turn on allowAnchor', 'google-analytics-for-wordpress' ),
  211. 'desc' => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, and makes RSS link tagging use a %2$s as well.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#allowAnchor" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowAnchor</code></a>', '<code>#</code>' ),
  212. 'type' => 'checkbox',
  213. ),
  214. 'add_allow_linker' => array(
  215. 'id' => 'add_allow_linker',
  216. 'name' => __( 'Turn on allowLinker', 'google-analytics-for-wordpress' ),
  217. 'desc' => sprintf( esc_html__( 'This adds a %1$s call to your tracking code, allowing you to use %2$s and related functions.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/linker#configuring_a_site_to_accept_linker_parameters" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_setAllowLinker</code></a>', ' <code>_link</code>' ),
  218. 'type' => 'checkbox',
  219. ),
  220. 'tag_links_in_rss' => array(
  221. 'id' => 'tag_links_in_rss',
  222. 'name' => __( 'Turn on tag links in RSS', 'google-analytics-for-wordpress' ),
  223. 'desc' => sprintf( esc_html__( 'Do not use this feature if you use FeedBurner, as FeedBurner can do this automatically and better than this plugin can. Check %1$sthis help page%2$s for info on how to enable this feature in FeedBurner.', 'google-analytics-for-wordpress' ), '<a href="https://support.google.com/feedburner/answer/165769?hl=en&amp;ref_topic=13075" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' ),
  224. 'type' => 'checkbox',
  225. ),
  226. )
  227. ),
  228. /** File Download Settings */
  229. 'files' => apply_filters('monsterinsights_settings_files',
  230. array(
  231. 'track_download_as' => array(
  232. 'id' => 'track_download_as',
  233. 'name' => __( 'Track downloads as an:', 'google-analytics-for-wordpress' ),
  234. 'desc' => __( 'Tracking as pageviews is not recommended, as this would skew your statistics, but it does make it possible to track downloads as goals. This feature requires that event tracking be turned on.', 'google-analytics-for-wordpress' ),
  235. 'type' => 'radio',
  236. 'std' => 'event',
  237. 'options' => array(
  238. 'event' => __( 'Event (recommended)', 'google-analytics-for-wordpress' ),
  239. 'pageview' => __( 'Pageview', 'google-analytics-for-wordpress' )
  240. ),
  241. ),
  242. 'extensions_of_files' => array( /* @todo: Select2 extensions of files */
  243. 'id' => 'extensions_of_files',
  244. 'name' => __( 'Extensions of files to track as downloads:', 'google-analytics-for-wordpress' ),
  245. 'desc' => __( 'If you have enabled event tracking, MonsterInsights will send an event/pageview to GA if a link to a file has one of the above extensions.', 'google-analytics-for-wordpress' ),
  246. 'type' => 'text',
  247. ),
  248. )
  249. ),
  250. /** Affiliate Tracking Settings */
  251. 'affiliates' => apply_filters('monsterinsights_settings_affiliates',
  252. array(
  253. 'track_internal_as_outbound' => array(
  254. 'id' => 'track_internal_as_outbound',
  255. 'name' => __( 'Set path for internal links to track as outbound links', 'google-analytics-for-wordpress' ),
  256. 'desc' => sprintf( esc_html__( 'If you want to track all internal links that begin with %1$s, enter %1$s in the box above. If you have multiple prefixes you can separate them with comma\'s: %2$s', 'google-analytics-for-wordpress' ), '<code>/out/</code>', '<code>/out/,/recommends/</code>' ),
  257. 'type' => 'text',
  258. ),
  259. 'track_internal_as_label' => array(
  260. 'id' => 'track_internal_as_label',
  261. 'name' => __( 'Label for those links:', 'google-analytics-for-wordpress' ),
  262. 'desc' => sprintf( esc_html__( 'The label to use for these links, this will be added to where the click came from, so if the label is %s, the label for a click from the content of an article becomes "outbound-link-aff".', 'google-analytics-for-wordpress' ), '"aff"' ),
  263. 'type' => 'text',
  264. ),
  265. )
  266. ),
  267. /** Social Tracking Settings */
  268. 'social' => apply_filters('monsterinsights_settings_social',
  269. array()
  270. ),
  271. /** Ad Tracking Settings */
  272. 'ads' => apply_filters('monsterinsights_settings_ads',
  273. array()
  274. ),
  275. /** Forms Tracking Settings */
  276. 'forms' => apply_filters('monsterinsights_settings_forms',
  277. array()
  278. ),
  279. /** eCommerce Tracking Settings */
  280. 'ecommerce' => apply_filters('monsterinsights_settings_ecommerce',
  281. array()
  282. ),
  283. /** Media Tracking Settings */
  284. 'media' => apply_filters('monsterinsights_settings_media',
  285. array()
  286. ),
  287. /** Members Tracking Settings */
  288. 'memberships' => apply_filters('monsterinsights_settings_memberships',
  289. array()
  290. ),
  291. /** Dimensions Tracking Settings */
  292. 'dimensions' => apply_filters('monsterinsights_settings_dimensions',
  293. array()
  294. ),
  295. /** Performance Tracking Settings */
  296. 'performance' => apply_filters('monsterinsights_settings_performance',
  297. array()
  298. ),
  299. /** AMP Tracking Settings */
  300. 'amp' => apply_filters('monsterinsights_settings_amp',
  301. array()
  302. ),
  303. /** Google Optimize Tracking Settings */
  304. 'goptimize' => apply_filters('monsterinsights_settings_goptimize',
  305. array()
  306. ),
  307. /** Facebook Instant Articles Tracking Settings */
  308. 'fbia' => apply_filters('monsterinsights_settings_fbia',
  309. array()
  310. ),
  311. /** Bounce Reduction Settings */
  312. 'bounce' => apply_filters('monsterinsights_settings_bounce',
  313. array()
  314. ),
  315. /** Reporting Tracking Settings */
  316. 'reporting' => apply_filters('monsterinsights_settings_reporting',
  317. array()
  318. ),
  319. /** Notifications Tracking Settings */
  320. 'notifications' => apply_filters('monsterinsights_settings_notifications',
  321. array()
  322. ),
  323. /** Compatibility Tracking Settings */
  324. 'compatibility' => apply_filters('monsterinsights_settings_compatibility',
  325. array(
  326. 'subdomain_tracking' => array(
  327. 'id' => 'subdomain_tracking',
  328. 'name' => __( 'Domain to track as:', 'google-analytics-for-wordpress' ),
  329. 'desc' => sprintf( esc_html__( 'This allows you to %1$sset the domain%2$s that\'s used for tracking. Only is used if set to a value, else defaults to automatic determination. It is very rare that you would need to use this setting.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/tracking-snippet-reference" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' ,'</a>' ),
  330. 'type' => 'text',
  331. ),
  332. 'custom_code' => array(
  333. 'id' => 'custom_code',
  334. 'name' => __( 'Custom code', 'google-analytics-for-wordpress' ),
  335. 'desc' => sprintf( esc_html__( 'Not for the average user: this allows you to add a line of code, to be added before the %1$s call.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/pages#implementation" target="_blank" rel="noopener noreferrer" referrer="no-referrer"><code>_trackPageview</code></a>' ),
  336. 'type' => 'unfiltered_textarea',
  337. ),
  338. 'debug_mode' => array(
  339. 'id' => 'debug_mode',
  340. 'name' => __( 'Enable Debug Mode', 'google-analytics-for-wordpress' ),
  341. 'desc' => __( 'Turns on debugging in JS events tracking, logging of eCommerce requests and enables debug settings.', 'google-analytics-for-wordpress'),
  342. 'type' => 'checkbox',
  343. ),
  344. )
  345. ),
  346. /** EU Compliance Tracking Settings */
  347. 'eucompliance' => apply_filters('monsterinsights_settings_eucompliance',
  348. array()
  349. ),
  350. /** Permissions Tracking Settings */
  351. 'permissions' => apply_filters('monsterinsights_settings_permissions',
  352. array(
  353. 'view_reports' => array(
  354. 'id' => 'view_reports',
  355. 'name' => __( 'Let these user roles see reports:', 'google-analytics-for-wordpress' ),
  356. 'desc' => sprintf( esc_html( 'Users that have at least one of these roles will be able to view the reports, along with any user with the %s capability.', 'google-analytics-for-wordpress' ), '<code>manage_options</code>'),
  357. 'type' => 'select',
  358. 'options' => monsterinsights_get_roles(),
  359. 'select2' => true,
  360. 'multiple' => true,
  361. 'allowclear' => true
  362. ),
  363. 'save_settings' => array(
  364. 'id' => 'save_settings',
  365. 'name' => __( 'Let these user roles save settings:', 'google-analytics-for-wordpress' ),
  366. 'desc' => sprintf( esc_html__( 'Users that have at least one of these roles will be able to view and save the settings panel, along with any user with the %s capability.', 'google-analytics-for-wordpress'), '<code>manage_options</code>' ),
  367. 'type' => 'select',
  368. 'options' => monsterinsights_get_roles(),
  369. 'select2' => true,
  370. 'multiple' => true,
  371. 'allowclear' => true
  372. ),
  373. 'automatic_updates' => array(
  374. 'id' => 'automatic_updates',
  375. 'name' => __( 'Automatic Updates', 'google-analytics-for-wordpress' ),
  376. 'type' => 'radio',
  377. 'std' => 'none',
  378. 'options' => array(
  379. 'all' => __( 'Yes (Recommended) - Get the latest features, bugfixes, and security updates as they are released.', 'google-analytics-for-wordpress' ),
  380. 'minor' => __( 'Minor Only - Only get bugfixes and security updates, but not major features.', 'google-analytics-for-wordpress' ),
  381. 'none' => __( 'None - Manually update everything.', 'google-analytics-for-wordpress' ),
  382. ),
  383. ),
  384. 'anonymous_data' => array(
  385. 'id' => 'anonymous_data',
  386. 'name' => __( 'Allow Usage Tracking', 'google-analytics-for-wordpress' ),
  387. 'desc' => __( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' ),
  388. 'type' => 'checkbox',
  389. ),
  390. 'hide_am_notices' => array(
  391. 'id' => 'hide_am_notices',
  392. 'name' => __( 'Hide Announcements', 'google-analytics-for-wordpress' ),
  393. 'desc' => __( 'Hides plugin announcements and update details. This includes critical notices we use to inform about deprecations and important required configuration changes.', 'google-analytics-for-wordpress' ),
  394. 'type' => 'checkbox',
  395. ),
  396. )
  397. ),
  398. );
  399. if ( monsterinsights_is_pro_version() ) {
  400. unset( $monsterinsights_settings['permissions']['anonymous_data'] );
  401. }
  402. return apply_filters( 'monsterinsights_registered_settings', $monsterinsights_settings );
  403. }