Yoast SEO - Version 12.5

Version Description

Download this release

Release Info

Developer Yoast
Plugin Icon 128x128 Yoast SEO
Version 12.5
Comparing to
See all releases

Code changes from version 12.4 to 12.5

Files changed (113) hide show
  1. admin/ajax.php +0 -3
  2. admin/class-admin-init.php +17 -108
  3. admin/class-admin.php +1 -2
  4. admin/class-export.php +4 -2
  5. admin/class-gutenberg-compatibility.php +2 -2
  6. admin/class-premium-upsell-admin-block.php +2 -52
  7. admin/class-yoast-notification-center.php +1 -1
  8. admin/config-ui/class-configuration-components.php +0 -1
  9. admin/config-ui/class-configuration-page.php +1 -5
  10. admin/config-ui/class-configuration-storage.php +0 -1
  11. admin/config-ui/class-configuration-structure.php +7 -19
  12. admin/config-ui/components/class-component-connect-google-search-console.php +0 -165
  13. admin/google_search_console/class-gsc-ajax.php +0 -110
  14. admin/google_search_console/class-gsc-bulk-action.php +0 -98
  15. admin/google_search_console/class-gsc-category-filters.php +0 -263
  16. admin/google_search_console/class-gsc-config.php +0 -26
  17. admin/google_search_console/class-gsc-count.php +0 -235
  18. admin/google_search_console/class-gsc-issue.php +0 -99
  19. admin/google_search_console/class-gsc-issues.php +0 -180
  20. admin/google_search_console/class-gsc-mapper.php +0 -121
  21. admin/google_search_console/class-gsc-marker.php +0 -155
  22. admin/google_search_console/class-gsc-platform-tabs.php +0 -99
  23. admin/google_search_console/class-gsc-service.php +0 -199
  24. admin/google_search_console/class-gsc-settings.php +0 -104
  25. admin/google_search_console/class-gsc-table.php +0 -411
  26. admin/google_search_console/class-gsc.php +36 -261
  27. admin/google_search_console/views/gsc-display.php +2 -147
  28. admin/menu/class-admin-menu.php +4 -8
  29. admin/metabox/class-metabox.php +1 -1
  30. admin/taxonomy/class-taxonomy.php +4 -0
  31. admin/views/licenses.php +16 -16
  32. admin/views/sidebar.php +65 -78
  33. admin/views/tabs/tool/wpseo-import.php +8 -7
  34. admin/views/tool-file-editor.php +4 -4
  35. css/dist/admin-global-1240-rtl.min.css +0 -1
  36. css/dist/admin-global-1240.min.css +0 -1
  37. css/dist/admin-global-1250-rtl.min.css +1 -0
  38. css/dist/admin-global-1250.min.css +1 -0
  39. css/dist/{adminbar-1240-rtl.min.css → adminbar-1250-rtl.min.css} +0 -0
  40. css/dist/{adminbar-1240.min.css → adminbar-1250.min.css} +0 -0
  41. css/dist/{alerts-1240-rtl.min.css → alerts-1250-rtl.min.css} +0 -0
  42. css/dist/{alerts-1240.min.css → alerts-1250.min.css} +0 -0
  43. css/dist/{dashboard-1240-rtl.min.css → dashboard-1250-rtl.min.css} +0 -0
  44. css/dist/{dashboard-1240.min.css → dashboard-1250.min.css} +0 -0
  45. css/dist/{edit-page-1240-rtl.min.css → edit-page-1250-rtl.min.css} +0 -0
  46. css/dist/{edit-page-1240.min.css → edit-page-1250.min.css} +0 -0
  47. css/dist/{featured-image-1240-rtl.min.css → featured-image-1250-rtl.min.css} +0 -0
  48. css/dist/{featured-image-1240.min.css → featured-image-1250.min.css} +0 -0
  49. css/dist/{filter-explanation-1240-rtl.min.css → filter-explanation-1250-rtl.min.css} +0 -0
  50. css/dist/{filter-explanation-1240.min.css → filter-explanation-1250.min.css} +0 -0
  51. css/dist/{inside-editor-1240-rtl.min.css → inside-editor-1250-rtl.min.css} +0 -0
  52. css/dist/{inside-editor-1240.min.css → inside-editor-1250.min.css} +0 -0
  53. css/dist/{metabox-1240-rtl.min.css → metabox-1250-rtl.min.css} +0 -0
  54. css/dist/{metabox-1240.min.css → metabox-1250.min.css} +0 -0
  55. css/dist/{metabox-primary-category-1240-rtl.min.css → metabox-primary-category-1250-rtl.min.css} +0 -0
  56. css/dist/{metabox-primary-category-1240.min.css → metabox-primary-category-1250.min.css} +0 -0
  57. css/dist/{search-appearance-1240-rtl.min.css → search-appearance-1250-rtl.min.css} +0 -0
  58. css/dist/{search-appearance-1240.min.css → search-appearance-1250.min.css} +0 -0
  59. css/dist/{structured-data-blocks-1240-rtl.min.css → structured-data-blocks-1250-rtl.min.css} +0 -0
  60. css/dist/{structured-data-blocks-1240.min.css → structured-data-blocks-1250.min.css} +0 -0
  61. css/dist/{toggle-switch-1240-rtl.min.css → toggle-switch-1250-rtl.min.css} +0 -0
  62. css/dist/{toggle-switch-1240.min.css → toggle-switch-1250.min.css} +0 -0
  63. css/dist/{wpseo-dismissible-1240-rtl.min.css → wpseo-dismissible-1250-rtl.min.css} +0 -0
  64. css/dist/{wpseo-dismissible-1240.min.css → wpseo-dismissible-1250.min.css} +0 -0
  65. css/dist/{yoast-components-1240-rtl.min.css → yoast-components-1250-rtl.min.css} +1 -1
  66. css/dist/{yoast-components-1240.min.css → yoast-components-1250.min.css} +1 -1
  67. css/dist/yoast-extensions-1240-rtl.min.css +0 -1
  68. css/dist/yoast-extensions-1240.min.css +0 -1
  69. css/dist/yoast-extensions-1250-rtl.min.css +1 -0
  70. css/dist/yoast-extensions-1250.min.css +1 -0
  71. css/dist/yst_plugin_tools-1240-rtl.min.css +0 -1
  72. css/dist/yst_plugin_tools-1240.min.css +0 -1
  73. css/dist/yst_plugin_tools-1250-rtl.min.css +1 -0
  74. css/dist/yst_plugin_tools-1250.min.css +1 -0
  75. css/dist/{yst_seo_score-1240-rtl.min.css → yst_seo_score-1250-rtl.min.css} +0 -0
  76. css/dist/{yst_seo_score-1240.min.css → yst_seo_score-1250.min.css} +0 -0
  77. deprecated/admin/config-ui/components/class-component-connect-google-search-console.php +119 -0
  78. {admin → deprecated/admin}/config-ui/fields/class-field-connect-google-search-console.php +17 -4
  79. {admin → deprecated/admin}/config-ui/fields/class-field-google-search-console-intro.php +10 -0
  80. deprecated/admin/google-search-console/class-gsc-ajax.php +112 -0
  81. deprecated/admin/google-search-console/class-gsc-bulk-action.php +27 -0
  82. deprecated/admin/google-search-console/class-gsc-category-filters.php +66 -0
  83. deprecated/admin/google-search-console/class-gsc-config.php +33 -0
  84. deprecated/admin/google-search-console/class-gsc-count.php +133 -0
  85. deprecated/admin/google-search-console/class-gsc-issue.php +47 -0
  86. deprecated/admin/google-search-console/class-gsc-issues.php +63 -0
  87. deprecated/admin/google-search-console/class-gsc-mapper.php +97 -0
  88. deprecated/admin/google-search-console/class-gsc-marker.php +46 -0
  89. {admin/google_search_console → deprecated/admin/google-search-console}/class-gsc-modal.php +19 -31
  90. deprecated/admin/google-search-console/class-gsc-platform-tabs.php +46 -0
  91. deprecated/admin/google-search-console/class-gsc-service.php +122 -0
  92. deprecated/admin/google-search-console/class-gsc-settings.php +79 -0
  93. deprecated/admin/google-search-console/class-gsc-table.php +85 -0
  94. images/Local_SEO_Icon.svg +0 -1
  95. images/News_SEO_Icon.svg +0 -1
  96. images/SEO_for_beginners.svg +0 -1
  97. images/Video_SEO_Icon.svg +0 -1
  98. images/Woo_SEO_Icon.svg +0 -1
  99. images/all-round-SEO.svg +0 -1
  100. images/extensions-local.png +0 -0
  101. images/extensions-news.png +0 -0
  102. images/extensions-premium-ribbon.png +0 -0
  103. images/extensions-video.png +0 -0
  104. images/extensions-woo.png +0 -0
  105. images/local_plugin_assistant.svg +1 -0
  106. images/news_plugin_assistant.svg +1 -0
  107. images/video_plugin_assistant.svg +1 -0
  108. images/woo_plugin_assistant.svg +1 -0
  109. images/yoast_seo_for_wp_2.svg +0 -1
  110. inc/class-upgrade.php +26 -0
  111. inc/options/class-wpseo-option.php +9 -0
  112. inc/options/class-wpseo-options.php +55 -14
  113. js/dist/analysis-1240.min.js +0 -14
admin/ajax.php CHANGED
@@ -328,9 +328,6 @@ function wpseo_register_ajax_integrations() {
328
 
329
  wpseo_register_ajax_integrations();
330
 
331
- // Crawl Issue Manager AJAX hooks.
332
- new WPSEO_GSC_Ajax();
333
-
334
  // SEO Score Recalculations.
335
  new WPSEO_Recalculate_Scores_Ajax();
336
 
328
 
329
  wpseo_register_ajax_integrations();
330
 
 
 
 
331
  // SEO Score Recalculations.
332
  new WPSEO_Recalculate_Scores_Ajax();
333
 
admin/class-admin-init.php CHANGED
@@ -39,11 +39,9 @@ class WPSEO_Admin_Init {
39
  add_action( 'admin_init', array( $this, 'blog_public_notice' ), 15 );
40
  add_action( 'admin_init', array( $this, 'permalink_notice' ), 15 );
41
  add_action( 'admin_init', array( $this, 'page_comments_notice' ), 15 );
42
- add_action( 'admin_init', array( $this, 'ga_compatibility_notice' ), 15 );
43
  add_action( 'admin_init', array( $this, 'yoast_plugin_suggestions_notification' ), 15 );
44
  add_action( 'admin_init', array( $this, 'recalculate_notice' ), 15 );
45
  add_action( 'admin_init', array( $this, 'unsupported_php_notice' ), 15 );
46
- add_action( 'admin_init', array( $this, 'wordpress_upgrade_notice' ), 15 );
47
  add_action( 'admin_init', array( $this->asset_manager, 'register_assets' ) );
48
  add_action( 'admin_init', array( $this, 'show_hook_deprecation_warnings' ) );
49
  add_action( 'admin_init', array( 'WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts' ) );
@@ -249,41 +247,13 @@ class WPSEO_Admin_Init {
249
  /**
250
  * Shows a notice to the user if they have Google Analytics for WordPress 5.4.3 installed because it causes an error
251
  * on the google search console page.
252
- */
253
- public function ga_compatibility_notice() {
254
-
255
- $notification = $this->get_compatibility_notification();
256
- $notification_center = Yoast_Notification_Center::get();
257
-
258
- if ( defined( 'GAWP_VERSION' ) && '5.4.3' === GAWP_VERSION ) {
259
- $notification_center->add_notification( $notification );
260
- }
261
- else {
262
- $notification_center->remove_notification( $notification );
263
- }
264
- }
265
-
266
- /**
267
- * Build compatibility problem notification.
268
  *
269
- * @return Yoast_Notification
 
 
270
  */
271
- private function get_compatibility_notification() {
272
- $info_message = sprintf(
273
- /* translators: %1$s expands to Yoast SEO, %2$s expands to 5.4.3, %3$s expands to Google Analytics by Yoast */
274
- __( '%1$s detected you are using version %2$s of %3$s, please update to the latest version to prevent compatibility issues.', 'wordpress-seo' ),
275
- 'Yoast SEO',
276
- '5.4.3',
277
- 'Google Analytics by Yoast'
278
- );
279
-
280
- return new Yoast_Notification(
281
- $info_message,
282
- array(
283
- 'id' => 'gawp-compatibility-notice',
284
- 'type' => Yoast_Notification::ERROR,
285
- )
286
- );
287
  }
288
 
289
  /**
@@ -410,79 +380,6 @@ class WPSEO_Admin_Init {
410
  return (float) $wp_version_latest;
411
  }
412
 
413
- /**
414
- * Creates a WordPress upgrade notification in the notification center.
415
- *
416
- * @return void
417
- */
418
- public function wordpress_upgrade_notice() {
419
- global $wp_version;
420
-
421
- $latest_major_wp_version = number_format( $this->get_latest_major_wordpress_version(), 1 );
422
- $next_major_wp_version = number_format( ( $latest_major_wp_version + 0.1 ), 1 );
423
-
424
- $wp_less_than_50 = version_compare( $wp_version, '5.0', '<' );
425
- $wp_less_than_latest_version = version_compare( $wp_version, $latest_major_wp_version, '<' );
426
-
427
- $notification_center = Yoast_Notification_Center::get();
428
-
429
- $message = sprintf(
430
- /* translators: %1$s expands to an opening strong tag, %2$s expands to a closing strong tag, %3$s expands to a html break, %4$s expands to Yoast, %5$s expands to Yoast SEO, %6$s expands to the latest major released WP version, %7$s expands to the next major WP release version */
431
- __(
432
- '%1$sUpgrade WordPress to the most recent version%2$s%3$sWe’ve noticed that you’re not on the latest WordPress version, which might cause an issue soon. %4$s (for reasons of security and stability) only supports the current and previous version of WordPress. When the next version of WordPress comes out, that means that we will support WordPress %6$s and %7$s. This means you will not get any updates to %5$s until you update your WordPress, so please make sure to upgrade to the latest WordPress version soon!%3$s%3$s',
433
- 'wordpress-seo'
434
- ),
435
- '<strong>',
436
- '</strong>',
437
- '<br/>',
438
- 'Yoast',
439
- 'Yoast SEO',
440
- $latest_major_wp_version,
441
- $next_major_wp_version
442
- );
443
- if ( $wp_less_than_50 ) {
444
- $message .= sprintf(
445
- /* translators: %1$s expands to Yoast SEO, %2$s expands to 5.0 */
446
- __(
447
- 'If you’ve held off on updating to %2$s and higher because of the new Gutenberg editor, please install the Classic Editor plugin. It will give you the same editing experience you have now, but also the security of newer versions of WordPress and %1$s.',
448
- 'wordpress-seo'
449
- ),
450
- 'Yoast SEO',
451
- '5.0'
452
- );
453
- }
454
- $message .= '<br/><br/>';
455
- $message .= sprintf(
456
- /* translators: %1$s expands to an opening anchor tag, %2$s expands to a closing anchor tag */
457
- __(
458
- 'Read %1$sthis post for more information about why we’re not supporting older versions.%2$s',
459
- 'wordpress-seo'
460
- ),
461
- '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/old-wp-support' ) . '" target="_blank" rel="nofollow">',
462
- WPSEO_Admin_Utils::get_new_tab_message() . '</a>'
463
- );
464
-
465
- $notification = new Yoast_Notification(
466
- $message,
467
- array(
468
- 'type' => Yoast_Notification::ERROR,
469
- 'id' => 'wpseo-dismiss-wordpress-upgrade',
470
- )
471
- );
472
-
473
- if ( $wp_less_than_latest_version ) {
474
- // If the latest WordPress version is not known, do not initiate the WordPress upgrade notice.
475
- if ( $this->get_latest_major_wordpress_version() === 0 ) {
476
- $notification_center->remove_notification( $notification );
477
- return;
478
- }
479
-
480
- $notification_center->add_notification( $notification );
481
- return;
482
- }
483
- $notification_center->remove_notification( $notification );
484
- }
485
-
486
  /**
487
  * Check if the user has dismissed the given notice (by $notice_name).
488
  *
@@ -728,4 +625,16 @@ class WPSEO_Admin_Init {
728
  public function yoast_plugin_compatibility_notification() {
729
  _deprecated_function( __METHOD__, 'WPSEO 12.3' );
730
  }
 
 
 
 
 
 
 
 
 
 
 
 
731
  }
39
  add_action( 'admin_init', array( $this, 'blog_public_notice' ), 15 );
40
  add_action( 'admin_init', array( $this, 'permalink_notice' ), 15 );
41
  add_action( 'admin_init', array( $this, 'page_comments_notice' ), 15 );
 
42
  add_action( 'admin_init', array( $this, 'yoast_plugin_suggestions_notification' ), 15 );
43
  add_action( 'admin_init', array( $this, 'recalculate_notice' ), 15 );
44
  add_action( 'admin_init', array( $this, 'unsupported_php_notice' ), 15 );
 
45
  add_action( 'admin_init', array( $this->asset_manager, 'register_assets' ) );
46
  add_action( 'admin_init', array( $this, 'show_hook_deprecation_warnings' ) );
47
  add_action( 'admin_init', array( 'WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts' ) );
247
  /**
248
  * Shows a notice to the user if they have Google Analytics for WordPress 5.4.3 installed because it causes an error
249
  * on the google search console page.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  *
251
+ * @deprecated 12.5
252
+ *
253
+ * @codeCoverageIgnore
254
  */
255
+ public function ga_compatibility_notice() {
256
+ _deprecated_function( __METHOD__, 'WPSEO 12.5' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
 
259
  /**
380
  return (float) $wp_version_latest;
381
  }
382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  /**
384
  * Check if the user has dismissed the given notice (by $notice_name).
385
  *
625
  public function yoast_plugin_compatibility_notification() {
626
  _deprecated_function( __METHOD__, 'WPSEO 12.3' );
627
  }
628
+
629
+ /**
630
+ * Creates a WordPress upgrade notification in the notification center.
631
+ *
632
+ * @deprecated 12.5
633
+ * @codeCoverageIgnore
634
+ *
635
+ * @return void
636
+ */
637
+ public function wordpress_upgrade_notice() {
638
+ _deprecated_function( __METHOD__, 'WPSEO 12.5' );
639
+ }
640
  }
admin/class-admin.php CHANGED
@@ -93,8 +93,7 @@ class WPSEO_Admin {
93
  }
94
 
95
  $this->admin_features = array(
96
- 'google_search_console' => new WPSEO_GSC(),
97
- 'dashboard_widget' => new Yoast_Dashboard_Widget(),
98
  );
99
 
100
  if ( WPSEO_Metabox::is_post_overview( $pagenow ) || WPSEO_Metabox::is_post_edit( $pagenow ) ) {
93
  }
94
 
95
  $this->admin_features = array(
96
+ 'dashboard_widget' => new Yoast_Dashboard_Widget(),
 
97
  );
98
 
99
  if ( WPSEO_Metabox::is_post_overview( $pagenow ) || WPSEO_Metabox::is_post_edit( $pagenow ) ) {
admin/class-export.php CHANGED
@@ -51,7 +51,7 @@ class WPSEO_Export {
51
  return;
52
  }
53
 
54
- echo '<p>';
55
  printf(
56
  /* translators: %1$s expands to Import settings */
57
  esc_html__(
@@ -64,7 +64,9 @@ class WPSEO_Export {
64
  )
65
  );
66
  echo '</p>';
67
- echo '<textarea id="wpseo-export" rows="20" cols="100">' . esc_textarea( $this->export ) . '</textarea>';
 
 
68
  }
69
 
70
  /**
51
  return;
52
  }
53
 
54
+ echo '<p id="wpseo-settings-export-desc">';
55
  printf(
56
  /* translators: %1$s expands to Import settings */
57
  esc_html__(
64
  )
65
  );
66
  echo '</p>';
67
+ /* translators: %1$s expands to Yoast SEO */
68
+ echo '<label for="wpseo-settings-export" class="yoast-inline-label">' . sprintf( __( 'Your %1$s settings:', 'wordpress-seo' ), 'Yoast SEO' ) . '</label><br />';
69
+ echo '<textarea id="wpseo-settings-export" rows="20" cols="100" aria-describedby="wpseo-settings-export-desc">' . esc_textarea( $this->export ) . '</textarea>';
70
  }
71
 
72
  /**
admin/class-gutenberg-compatibility.php CHANGED
@@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility {
15
  *
16
  * @var string
17
  */
18
- const CURRENT_RELEASE = '6.7.0';
19
 
20
  /**
21
  * The minimally supported version of Gutenberg by the plugin.
22
  *
23
  * @var string
24
  */
25
- const MINIMUM_SUPPORTED = '6.7.0';
26
 
27
  /**
28
  * Holds the current version.
15
  *
16
  * @var string
17
  */
18
+ const CURRENT_RELEASE = '6.8.0';
19
 
20
  /**
21
  * The minimally supported version of Gutenberg by the plugin.
22
  *
23
  * @var string
24
  */
25
+ const MINIMUM_SUPPORTED = '6.8.0';
26
 
27
  /**
28
  * Holds the current version.
admin/class-premium-upsell-admin-block.php CHANGED
@@ -22,7 +22,7 @@ class WPSEO_Premium_Upsell_Admin_Block {
22
  *
23
  * @var string
24
  */
25
- protected $identifier = 'premium_upsell_admin_block';
26
 
27
  /**
28
  * Registers which hook the block will be displayed on.
@@ -39,9 +39,7 @@ class WPSEO_Premium_Upsell_Admin_Block {
39
  * @return void
40
  */
41
  public function register_hooks() {
42
- if ( ! $this->is_hidden() ) {
43
- add_action( $this->hook, array( $this, 'render' ) );
44
- }
45
  }
46
 
47
  /**
@@ -65,9 +63,6 @@ class WPSEO_Premium_Upsell_Admin_Block {
65
 
66
  $class = $this->get_html_class();
67
 
68
- /* translators: %s expands to "Yoast SEO Premium". */
69
- $dismiss_msg = sprintf( __( 'Dismiss %s upgrade notice', 'wordpress-seo' ), 'Yoast SEO Premium' );
70
-
71
  /* translators: %s expands to Yoast SEO Premium */
72
  $button_text = esc_html( sprintf( __( 'Get %s', 'wordpress-seo' ), 'Yoast SEO Premium' ) );
73
  $button_text .= '<span class="screen-reader-text">' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>' .
@@ -81,12 +76,6 @@ class WPSEO_Premium_Upsell_Admin_Block {
81
  );
82
 
83
  echo '<div class="' . esc_attr( $class ) . '">';
84
- printf(
85
- '<a href="%1$s" style="" class="alignright button %2$s" aria-label="%3$s"><span class="dashicons dashicons-no-alt"></span></a>',
86
- esc_url( add_query_arg( array( $this->get_query_variable_name() => 1 ) ) ),
87
- esc_attr( $class . '--close' ),
88
- esc_attr( $dismiss_msg )
89
- );
90
 
91
  echo '<div>';
92
  echo '<h2 class="' . esc_attr( $class . '--header' ) . '">' .
@@ -122,45 +111,6 @@ class WPSEO_Premium_Upsell_Admin_Block {
122
  );
123
  }
124
 
125
- /**
126
- * Checks if the block is hidden by the user.
127
- *
128
- * @return bool False when it should be shown, True if it should be hidden.
129
- */
130
- protected function is_hidden() {
131
- $transient_name = $this->get_option_name();
132
-
133
- $hide = (bool) get_user_option( $transient_name );
134
- if ( ! $hide ) {
135
- $query_variable_name = $this->get_query_variable_name();
136
- if ( filter_input( INPUT_GET, $query_variable_name, FILTER_VALIDATE_INT ) === 1 ) {
137
- // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.
138
- update_user_option( get_current_user_id(), $transient_name, true );
139
- $hide = true;
140
- }
141
- }
142
-
143
- return $hide;
144
- }
145
-
146
- /**
147
- * Retrieves the option name to use.
148
- *
149
- * @return string The name of the option to save the data in.
150
- */
151
- protected function get_option_name() {
152
- return 'yoast_promo_hide_' . $this->identifier;
153
- }
154
-
155
- /**
156
- * Retrieves the query variable to use for dismissing the block.
157
- *
158
- * @return string The name of the query variable to use.
159
- */
160
- protected function get_query_variable_name() {
161
- return 'yoast_promo_hide_' . $this->identifier;
162
- }
163
-
164
  /**
165
  * Returns the HTML base class to use.
166
  *
22
  *
23
  * @var string
24
  */
25
+ protected $identifier = 'premium_upsell';
26
 
27
  /**
28
  * Registers which hook the block will be displayed on.
39
  * @return void
40
  */
41
  public function register_hooks() {
42
+ add_action( $this->hook, array( $this, 'render' ) );
 
 
43
  }
44
 
45
  /**
63
 
64
  $class = $this->get_html_class();
65
 
 
 
 
66
  /* translators: %s expands to Yoast SEO Premium */
67
  $button_text = esc_html( sprintf( __( 'Get %s', 'wordpress-seo' ), 'Yoast SEO Premium' ) );
68
  $button_text .= '<span class="screen-reader-text">' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>' .
76
  );
77
 
78
  echo '<div class="' . esc_attr( $class ) . '">';
 
 
 
 
 
 
79
 
80
  echo '<div>';
81
  echo '<h2 class="' . esc_attr( $class . '--header' ) . '">' .
111
  );
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  /**
115
  * Returns the HTML base class to use.
116
  *
admin/class-yoast-notification-center.php CHANGED
@@ -145,7 +145,7 @@ class Yoast_Notification_Center {
145
  }
146
 
147
  /**
148
- * Check if the nofitication is being dismissed.
149
  *
150
  * @param string|Yoast_Notification $notification Notification to check dismissal of.
151
  * @param string $meta_value Value to set the meta value to if dismissed.
145
  }
146
 
147
  /**
148
+ * Checks if the notification is being dismissed.
149
  *
150
  * @param string|Yoast_Notification $notification Notification to check dismissal of.
151
  * @param string $meta_value Value to set the meta value to if dismissed.
admin/config-ui/class-configuration-components.php CHANGED
@@ -28,7 +28,6 @@ class WPSEO_Configuration_Components {
28
  * Add default components.
29
  */
30
  public function initialize() {
31
- $this->add_component( new WPSEO_Config_Component_Connect_Google_Search_Console() );
32
  $this->add_component( new WPSEO_Config_Component_Mailchimp_Signup() );
33
  $this->add_component( new WPSEO_Config_Component_Suggestions() );
34
  }
28
  * Add default components.
29
  */
30
  public function initialize() {
 
31
  $this->add_component( new WPSEO_Config_Component_Mailchimp_Signup() );
32
  $this->add_component( new WPSEO_Config_Component_Suggestions() );
33
  }
admin/config-ui/class-configuration-page.php CHANGED
@@ -170,8 +170,7 @@ class WPSEO_Configuration_Page {
170
  * @return array The API endpoint config.
171
  */
172
  public function get_config() {
173
- $service = new WPSEO_GSC_Service();
174
- $config = array(
175
  'namespace' => WPSEO_Configuration_Endpoint::REST_NAMESPACE,
176
  'endpoint_retrieve' => WPSEO_Configuration_Endpoint::ENDPOINT_RETRIEVE,
177
  'endpoint_store' => WPSEO_Configuration_Endpoint::ENDPOINT_STORE,
@@ -179,9 +178,6 @@ class WPSEO_Configuration_Page {
179
  'root' => esc_url_raw( rest_url() ),
180
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
181
  'finishUrl' => admin_url( 'admin.php?page=wpseo_dashboard&configuration=finished' ),
182
- 'gscAuthURL' => $service->get_client()->createAuthUrl(),
183
- 'gscProfiles' => $service->get_sites(),
184
- 'gscNonce' => wp_create_nonce( 'wpseo-gsc-ajax-security' ),
185
  );
186
 
187
  return $config;
170
  * @return array The API endpoint config.
171
  */
172
  public function get_config() {
173
+ $config = array(
 
174
  'namespace' => WPSEO_Configuration_Endpoint::REST_NAMESPACE,
175
  'endpoint_retrieve' => WPSEO_Configuration_Endpoint::ENDPOINT_RETRIEVE,
176
  'endpoint_store' => WPSEO_Configuration_Endpoint::ENDPOINT_STORE,
178
  'root' => esc_url_raw( rest_url() ),
179
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
180
  'finishUrl' => admin_url( 'admin.php?page=wpseo_dashboard&configuration=finished' ),
 
 
 
181
  );
182
 
183
  return $config;
admin/config-ui/class-configuration-storage.php CHANGED
@@ -39,7 +39,6 @@ class WPSEO_Configuration_Storage {
39
  new WPSEO_Config_Field_Title_Intro(),
40
  new WPSEO_Config_Field_Site_Name(),
41
  new WPSEO_Config_Field_Separator(),
42
- new WPSEO_Config_Field_Google_Search_Console_Intro(),
43
  new WPSEO_Config_Field_Profile_URL_Facebook(),
44
  new WPSEO_Config_Field_Profile_URL_Twitter(),
45
  new WPSEO_Config_Field_Profile_URL_Instagram(),
39
  new WPSEO_Config_Field_Title_Intro(),
40
  new WPSEO_Config_Field_Site_Name(),
41
  new WPSEO_Config_Field_Separator(),
 
42
  new WPSEO_Config_Field_Profile_URL_Facebook(),
43
  new WPSEO_Config_Field_Profile_URL_Twitter(),
44
  new WPSEO_Config_Field_Profile_URL_Instagram(),
admin/config-ui/class-configuration-structure.php CHANGED
@@ -26,9 +26,9 @@ class WPSEO_Configuration_Structure {
26
  * @var array
27
  */
28
  private $fields = array(
29
- 'environment_type' => array( 'environment_type' ),
30
- 'siteType' => array( 'siteType' ),
31
- 'publishingEntity' => array(
32
  'publishingEntity',
33
  'publishingEntityType',
34
  'publishingEntityCompanyInfo',
@@ -44,21 +44,17 @@ class WPSEO_Configuration_Structure {
44
  'profileUrlYouTube',
45
  'profileUrlWikipedia',
46
  ),
47
- 'multipleAuthors' => array( 'multipleAuthors' ),
48
- 'connectGoogleSearchConsole' => array(
49
- 'googleSearchConsoleIntro',
50
- 'connectGoogleSearchConsole',
51
- ),
52
- 'titleTemplate' => array(
53
  'titleIntro',
54
  'siteName',
55
  'separator',
56
  ),
57
- 'newsletter' => array(
58
  'mailchimpSignup',
59
  'suggestions',
60
  ),
61
- 'success' => array( 'successMessage' ),
62
  );
63
 
64
  /**
@@ -86,14 +82,6 @@ class WPSEO_Configuration_Structure {
86
  __( 'Multiple authors', 'wordpress-seo' ),
87
  $this->fields['multipleAuthors']
88
  );
89
- // @codingStandardsIgnoreStart -- These lines are commented out temporarily, see next line.
90
- // Commented out since 11.1.1 patch because Google removed their GSC API.
91
- // $this->add_step(
92
- // 'connect-google-search-console',
93
- // __( 'Google Search Console', 'wordpress-seo' ),
94
- // $this->fields['connectGoogleSearchConsole']
95
- // );
96
- // @codingStandardsIgnoreEnd
97
 
98
  $this->add_step( 'title-template', __( 'Title settings', 'wordpress-seo' ), $this->fields['titleTemplate'] );
99
  $this->add_step( 'newsletter', __( 'Continue learning', 'wordpress-seo' ), $this->fields['newsletter'], true, true );
26
  * @var array
27
  */
28
  private $fields = array(
29
+ 'environment_type' => array( 'environment_type' ),
30
+ 'siteType' => array( 'siteType' ),
31
+ 'publishingEntity' => array(
32
  'publishingEntity',
33
  'publishingEntityType',
34
  'publishingEntityCompanyInfo',
44
  'profileUrlYouTube',
45
  'profileUrlWikipedia',
46
  ),
47
+ 'multipleAuthors' => array( 'multipleAuthors' ),
48
+ 'titleTemplate' => array(
 
 
 
 
49
  'titleIntro',
50
  'siteName',
51
  'separator',
52
  ),
53
+ 'newsletter' => array(
54
  'mailchimpSignup',
55
  'suggestions',
56
  ),
57
+ 'success' => array( 'successMessage' ),
58
  );
59
 
60
  /**
82
  __( 'Multiple authors', 'wordpress-seo' ),
83
  $this->fields['multipleAuthors']
84
  );
 
 
 
 
 
 
 
 
85
 
86
  $this->add_step( 'title-template', __( 'Title settings', 'wordpress-seo' ), $this->fields['titleTemplate'] );
87
  $this->add_step( 'newsletter', __( 'Continue learning', 'wordpress-seo' ), $this->fields['newsletter'], true, true );
admin/config-ui/components/class-component-connect-google-search-console.php DELETED
@@ -1,165 +0,0 @@
1
- <?php
2
- /**
3
- * WPSEO plugin file.
4
- *
5
- * @package WPSEO\Admin\ConfigurationUI
6
- */
7
-
8
- /**
9
- * Class WPSEO_Config_Component_Connect_Google_Search_Console.
10
- */
11
- class WPSEO_Config_Component_Connect_Google_Search_Console implements WPSEO_Config_Component {
12
-
13
- /**
14
- * Option identifier where the GSC token is stored.
15
- *
16
- * @var string
17
- */
18
- const OPTION_ACCESS_TOKEN = 'wpseo-gsc-access_token';
19
-
20
- /**
21
- * Option identifier where the GSC refresh token is stored.
22
- *
23
- * @var string
24
- */
25
- const OPTION_REFRESH_TOKEN = 'wpseo-gsc-refresh_token';
26
-
27
- /**
28
- * Service to use.
29
- *
30
- * @var WPSEO_GSC_Service
31
- */
32
- protected $gsc_service;
33
-
34
- /**
35
- * WPSEO_Config_Component_Connect_Google_Search_Console constructor.
36
- */
37
- public function __construct() {
38
- $this->gsc_service = new WPSEO_GSC_Service( $this->get_profile() );
39
- }
40
-
41
- /**
42
- * Set the Google Search Console service.
43
- *
44
- * @param WPSEO_GSC_Service $service Set service to use.
45
- */
46
- public function set_gsc_service( WPSEO_GSC_Service $service ) {
47
- $this->gsc_service = $service;
48
- }
49
-
50
- /**
51
- * Gets the component identifier.
52
- *
53
- * @return string
54
- */
55
- public function get_identifier() {
56
- return 'ConnectGoogleSearchConsole';
57
- }
58
-
59
- /**
60
- * Gets the field.
61
- *
62
- * @return WPSEO_Config_Field
63
- */
64
- public function get_field() {
65
- return new WPSEO_Config_Field_Connect_Google_Search_Console();
66
- }
67
-
68
- /**
69
- * Get the data for the field.
70
- *
71
- * @return mixed
72
- */
73
- public function get_data() {
74
-
75
- $data = array(
76
- 'profileList' => $this->get_profilelist(),
77
- 'profile' => $this->get_profile(),
78
- 'hasAccessToken' => $this->hasAccessToken(),
79
- );
80
-
81
- return $data;
82
- }
83
-
84
- /**
85
- * Save data.
86
- *
87
- * @param array $data Data containing changes.
88
- *
89
- * @return mixed
90
- */
91
- public function set_data( $data ) {
92
-
93
- $current_data = $this->get_data();
94
-
95
- $this->handle_profile_change( $current_data, $data );
96
-
97
- // Save profile.
98
- $has_saved = update_option(
99
- WPSEO_GSC::OPTION_WPSEO_GSC,
100
- array( 'profile' => $data['profile'] )
101
- );
102
-
103
- // Collect results to return to the configurator.
104
- $results = array(
105
- 'profile' => $has_saved,
106
- );
107
-
108
- return $results;
109
- }
110
-
111
- /**
112
- * Remove issues when the profile has changed.
113
- *
114
- * @param array $current_data Saved data before changes.
115
- * @param array $data Data after changes.
116
- */
117
- protected function handle_profile_change( $current_data, $data ) {
118
- // If the profile has been changed, remove issues.
119
- if ( $current_data['profile'] === $data['profile'] ) {
120
- return;
121
- }
122
-
123
- $this->reload_issues();
124
- }
125
-
126
- /**
127
- * Get the current GSC profile.
128
- *
129
- * @return string
130
- */
131
- protected function get_profile() {
132
- return WPSEO_GSC_Settings::get_profile();
133
- }
134
-
135
- /**
136
- * Reload GSC issues.
137
- */
138
- protected function reload_issues() {
139
- WPSEO_GSC_Settings::reload_issues();
140
- }
141
-
142
- /**
143
- * Gets a list with the profiles.
144
- *
145
- * @return array
146
- */
147
- protected function get_profilelist() {
148
- $profiles = array();
149
- $sites = $this->gsc_service->get_sites();
150
- foreach ( $sites as $site_key => $site_value ) {
151
- $profiles[ untrailingslashit( $site_key ) ] = untrailingslashit( $site_value );
152
- }
153
-
154
- return $profiles;
155
- }
156
-
157
- /**
158
- * Checks if there is an access token. If so, there is a connection.
159
- *
160
- * @return bool
161
- */
162
- private function hasAccessToken() {
163
- return ( null !== $this->gsc_service->get_client()->getAccessToken() );
164
- }
165
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/google_search_console/class-gsc-ajax.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
- /**
3
- * WPSEO plugin file.
4
- *
5
- * @package WPSEO\Admin\Google_Search_Console
6
- */
7
-
8
- /**
9
- * Class WPSEO_GSC_Ajax.
10
- */
11
- class WPSEO_GSC_Ajax {
12
-
13
- /**
14
- * Setting the AJAX hooks for GSC.
15
- */
16
- public function __construct() {
17
- add_action( 'wp_ajax_wpseo_mark_fixed_crawl_issue', array( $this, 'ajax_mark_as_fixed' ) );
18
- add_action( 'wp_ajax_wpseo_dismiss_gsc', array( $this, 'dismiss_notice' ) );
19
- add_action( 'wp_ajax_wpseo_save_auth_code', array( $this, 'save_auth_code' ) );
20
- add_action( 'wp_ajax_wpseo_clear_auth_code', array( $this, 'clear_auth_code' ) );
21
- add_action( 'wp_ajax_wpseo_get_profiles', array( $this, 'get_profiles' ) );
22
- }
23
-
24
- /**
25
- * This method will be access by an AJAX request and will mark an issue as fixed.
26
- *
27
- * First it will do a request to the Google API.
28
- */
29
- public function ajax_mark_as_fixed() {
30
- if ( $this->valid_nonce() ) {
31
- $marker = new WPSEO_GSC_Marker( filter_input( INPUT_POST, 'url' ) );
32
-
33
- wp_die( $marker->get_response() );
34
- }
35
-
36
- wp_die( 'false' );
37
- }
38
-
39
- /**
40
- * Handle the AJAX request and dismiss the GSC notice.
41
- */
42
- public function dismiss_notice() {
43
- check_ajax_referer( 'dismiss-gsc-notice' );
44
-
45
- update_user_meta( get_current_user_id(), 'wpseo_dismissed_gsc_notice', true );
46
-
47
- wp_die( 'true' );
48
- }
49
-
50
- /**
51
- * Saves the authorization code.
52
- */
53
- public function save_auth_code() {
54
- if ( ! $this->valid_nonce() ) {
55
- wp_die( '0' );
56
- }
57
-
58
- // Validate the authorization.
59
- $service = $this->get_service();
60
- $authorization_code = filter_input( INPUT_POST, 'authorization' );
61
- $is_authorization_valid = WPSEO_GSC_Settings::validate_authorization( $authorization_code, $service->get_client() );
62
- if ( ! $is_authorization_valid ) {
63
- wp_die( '0' );
64
- }
65
-
66
- $this->get_profiles();
67
- }
68
-
69
- /**
70
- * Clears all authorization data.
71
- */
72
- public function clear_auth_code() {
73
- if ( ! $this->valid_nonce() ) {
74
- wp_die( '0' );
75
- }
76
-
77
- $service = $this->get_service();
78
-
79
- WPSEO_GSC_Settings::clear_data( $service );
80
-
81
- $this->get_profiles();
82
- }
83
-
84
- /**
85
- * Check if posted nonce is valid and return true if it is.
86
- *
87
- * @return mixed
88
- */
89
- private function valid_nonce() {
90
- return wp_verify_nonce( filter_input( INPUT_POST, 'ajax_nonce' ), 'wpseo-gsc-ajax-security' );
91
- }
92
-
93
- /**
94
- * Returns an instance of the Google Search Console service.
95
- *
96
- * @return WPSEO_GSC_Service
97
- */
98
- private function get_service() {
99
- return new WPSEO_GSC_Service();
100
- }
101
-
102
- /**
103
- * Prints a JSON encoded string with the current profile config.
104
- */
105
- private function get_profiles() {
106
- $component = new WPSEO_Config_Component_Connect_Google_Search_Console();
107
-
108
- wp_die( WPSEO_Utils::format_json_encode( $component->get_data() ) );
109
- }
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/google_search_console/class-gsc-bulk-action.php DELETED
@@ -1,98 +0,0 @@
1
- <?php
2
- /**
3
- * WPSEO plugin file.
4
- *
5
- * @package WPSEO\Admin\Google_Search_Console
6
- */
7
-
8
- /**
9
- * Class WPSEO_GSC_Bulk_Action.
10
- */
11
- class WPSEO_GSC_Bulk_Action {
12
-
13
- /**
14
- * Setting the listener on the bulk action post.
15
- */
16
- public function __construct() {
17
- if ( wp_verify_nonce( filter_input( INPUT_POST, 'wpseo_gsc_nonce' ), 'wpseo_gsc_nonce' ) ) {
18
- $this->handle_bulk_action();
19
- }
20
- }
21
-
22
- /**
23
- * Handles the bulk action when there is an action posted.
24
- */
25
- private function handle_bulk_action() {
26
- $bulk_action = $this->determine_bulk_action();
27
- if ( $bulk_action !== false ) {
28
- $this->run_bulk_action( $bulk_action, $this->posted_issues() );
29
-
30
- wp_redirect( filter_input( INPUT_POST, '_wp_http_referer' ) );
31
- exit;
32
- }
33
- }
34
-
35
- /**
36
- * Determine which bulk action is selected and return that value.
37
- *
38
- * @return string|bool
39
- */
40
- private function determine_bulk_action() {
41
- $action_inputs = array(
42
- 'action', // Bulk action select above the table.
43
- 'action2', // Bulk action select below the table.
44
- );
45
-
46
- foreach ( $action_inputs as $action_name ) {
47
- $action = filter_input( INPUT_POST, $action_name );
48
- if ( ! empty( $action ) && $action !== '-1' ) {
49
- return $action;
50
- }
51
- }
52
-
53
- return false;
54
- }
55
-
56
- /**
57
- * Get the posted issues and return them.
58
- *
59
- * @return array
60
- */
61
- private function posted_issues() {
62
- $issues = filter_input( INPUT_POST, 'wpseo_crawl_issues', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
63
- if ( ! empty( $issues ) ) {
64
- return $issues;
65
- }
66
-
67
- // Fallback if issues are empty.
68
- return array();
69
- }
70
-
71
- /**
72
- * Runs the bulk action.
73
- *
74
- * @param string $bulk_action Action type.
75
- * @param array $issues Set of issues to apply to.
76
- */
77
- private function run_bulk_action( $bulk_action, $issues ) {
78
- switch ( $bulk_action ) {
79
- case 'mark_as_fixed':
80
- array_map( array( $this, 'action_mark_as_fixed' ), $issues );
81
-
82
- break;
83
- }
84
- }
85
-
86
- /**
87
- * Marks the issue as fixed.
88
- *
89
- * @param string $issue Issue URL.
90
- *
91
- * @return string
92
- */
93
- private function action_mark_as_fixed( $issue ) {
94
- new WPSEO_GSC_Marker( $issue );
95
-
96
- return $issue;
97
- }
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/google_search_console/class-gsc-category-filters.php DELETED
@@ -1,263 +0,0 @@
1
- <?php
2
- /**
3
- * WPSEO plugin file.
4
- *
5
- * @package WPSEO\Admin\Google_Search_Console
6
- */
7
-
8
- /**
9
- * Class WPSEO_GSC_Category_Filters.
10
- *
11
- * This class will get all category counts from the options and will parse the filter links that are displayed above
12
- * the crawl issue tables.
13
- */
14
- class WPSEO_GSC_Category_Filters {
15
-
16
- /**
17
- * The counts per category.
18
- *
19
- * @var array
20
- */
21
- private $category_counts = array();
22
-
23
- /**
24
- * All the possible filters.
25
- *
26
- * @var array
27
- */
28
- private $filter_values = array();
29
-
30
- /**
31
- * The current category.
32
- *
33
- * @var string
34
- */
35
- private $category;
36
-
37
- /**
38
- * Constructing this object.
39
- *
40
- * Setting the hook to create the issues categories as the links.
41
- *
42
- * @param array $platform_counts Set of issue counts by platform.
43
- */
44
- public function __construct( array $platform_counts ) {
45
- if ( ! empty( $platform_counts ) ) {
46
- $this->set_counts( $platform_counts );
47
- }
48
-
49
- // Setting the filter values.
50
- $this->set_filter_values();
51
-
52
- $this->category = $this->get_current_category();
53
- }
54
-
55
- /**
56
- * Returns the value of the current category.
57
- *
58
- * @return mixed|string
59
- */
60
- public function get_category() {
61
- return $this->category;
62
- }
63
-
64
- /**
65
- * Returns the current filters as an array.
66
- *
67
- * Only return categories with more than 0 issues.
68
- *
69
- * @return array
70
- */
71
- public function as_array() {
72
- $new_views = array();
73
-
74
- foreach ( $this->category_counts as $category_name => $category ) {
75
- $new_views[] = $this->create_view_link( $category_name, $category['count'] );
76
- }
77
-
78
- return $new_views;
79
- }
80
-
81
- /**
82
- * Getting the current view.
83
- */
84
- private function get_current_category() {
85
- $current_category = filter_input( INPUT_GET, 'category' );
86
- if ( ! empty( $current_category ) ) {
87
- return $current_category;
88
- }
89
-
90
- // Just prevent redirect loops.
91
- if ( ! empty( $this->category_counts ) ) {
92
- $current_category = 'not_found';
93
- if ( empty( $this->category_counts[ $current_category ] ) ) {
94
- $current_category = key( $this->category_counts );
95
- }
96
-
97
- // Just redirect to set the category.
98
- wp_redirect( add_query_arg( 'category', $current_category ) );
99
- exit;
100
- }
101
- }
102
-
103
- /**
104
- * Setting the view counts based on the saved data. The info will be used to display the category filters.
105
- *
106
- * @param array $platform_counts Set of counts by platform.
107
- */
108
- private function set_counts( array $platform_counts ) {
109
- $this->category_counts = $this->parse_counts( $platform_counts );
110
- }
111
-
112
- /**
113
- * Setting the values for the filter.
114
- */
115
- private function set_filter_values() {
116
- $this->set_filter_value(
117
- 'access_denied',
118
- __( 'Access denied', 'wordpress-seo' ),
119
- __( 'Server requires authentication or is blocking Googlebot from accessing the site.', 'wordpress-seo' ),
120
- sprintf(
121
- /* translators: %s: category name. N.B.: The category name is translated separately. */
122
- __( 'Show information about errors in category %s', 'wordpress-seo' ),
123
- __( 'Access denied', 'wordpress-seo' )
124
- )
125
- );
126
- $this->set_filter_value( 'faulty_redirects', __( 'Faulty redirects', 'wordpress-seo' ) );
127
- $this->set_filter_value( 'not_followed', __( 'Not followed', 'wordpress-seo' ) );
128
- $this->set_filter_value(
129
- 'not_found',
130
- __( 'Not found', 'wordpress-seo' ),
131
- __( 'URL points to a non-existent page.', 'wordpress-seo' ),
132
- sprintf(
133
- /* translators: %s: category name. N.B.: The category name is translated separately. */
134
- __( 'Show information about errors in category %s', 'wordpress-seo' ),
135
- __( 'Not found', 'wordpress-seo' )
136
- )
137
- );
138
- $this->set_filter_value(
139
- 'other',
140
- __( 'Other', 'wordpress-seo' ),
141
- __( 'Google was unable to crawl this URL due to an undetermined issue.', 'wordpress-seo' ),
142
- sprintf(
143
- /* translators: %s: category name. N.B.: The category name is translated separately. */
144
- __( 'Show information about errors in category %s', 'wordpress-seo' ),
145
- __( 'Other', 'wordpress-seo' )
146
- )
147
- );
148
- $this->set_filter_value(
149
- 'roboted',
150
- __( 'Blocked', 'wordpress-seo' ),
151
- sprintf(
152
- /* translators: %1$s: expands to '<code>robots.txt</code>'. */
153
- __( 'Googlebot could access your site, but certain URLs are blocked for Googlebot in your %1$s file. This block could either be for all Googlebots or even specifically for Googlebot-mobile.', 'wordpress-seo' ),
154
- '<code>robots.txt</code>'
155
- ),
156
- sprintf(
157
- /* translators: %s: category name. N.B.: The category name is translated separately. */
158
- __( 'Show information about errors in category %s', 'wordpress-seo' ),
159
- __( 'Blocked', 'wordpress-seo' )
160
- )
161
- );
162
- $this->set_filter_value(
163
- 'server_error',
164
- __( 'Server Error', 'wordpress-seo' ),
165
- __( 'Request timed out or site is blocking Google.', 'wordpress-seo' ),
166
- sprintf(
167
- /* translators: %s: category name. N.B.: The category name is translated separately. */
168
- __( 'Show information about errors in category %s', 'wordpress-seo' ),
169
- __( 'Server Error', 'wordpress-seo' )
170
- )
171
- );
172
- $this->set_filter_value(
173
- 'soft_404',
174
- __( 'Soft 404', 'wordpress-seo' ),
175
- __( "The target URL doesn't exist, but your server is not returning a 404 (file not found) error.", 'wordpress-seo' ),
176
- sprintf(
177
- /* translators: %s: category name. N.B.: The category name is translated separately. */
178
- __( 'Show information about errors in category %s', 'wordpress-seo' ),
179
- __( 'Soft 404', 'wordpress-seo' )
180
- )
181
- );
182
- }
183
-
184
- /**
185
- * Add new filter value to the filter_values.
186
- *
187
- * @param string $key Filter key.
188
- * @param string $value Filter value.
189
- * @param string $description Optional description string.
190
- * @param string $help_button_text Optional help button text.
191
- */
192
- private function set_filter_value( $key, $value, $description = '', $help_button_text = '' ) {
193
- $this->filter_values[ $key ] = array(
194
- 'value' => $value,
195
- 'description' => $description,
196
- 'help-button' => $help_button_text,
197
- );
198
- }
199
-
200
- /**
201
- * Creates a filter link.
202
- *
203
- * @param string $category Issue type.
204
- * @param integer $count Count for the type.
205
- *
206
- * @return string
207
- */
208
- private function create_view_link( $category, $count ) {
209
- $href = add_query_arg(
210
- array(
211
- 'category' => $category,
212
- 'paged' => 1,
213
- )
214
- );
215
-
216
- $class = 'gsc_category';
217
- $aria_current = '';
218
-
219
- if ( $this->category === $category ) {
220
- $class .= ' current';
221
- $aria_current = ' aria-current="page"';
222
- }
223
-
224
- $help_button = '';
225
- $help_panel = '';
226
- if ( $this->filter_values[ $category ]['description'] !== '' ) {
227
- $help = new WPSEO_Admin_Help_Panel( $category, $this->filter_values[ $category ]['help-button'], $this->filter_values[ $category ]['description'], 'has-wrapper' );
228
- $help_button = $help->get_button_html();
229
- $help_panel = $help->get_panel_html();
230
- }
231
-
232
- return sprintf(
233
- '<a href="%1$s" class="%2$s"%8$s>%3$s</a> (<span id="gsc_count_%4$s">%5$s</span>) %6$s %7$s',
234
- esc_attr( $href ),
235
- $class,
236
- $this->filter_values[ $category ]['value'],
237
- $category,
238
- $count,
239
- $help_button,
240
- $help_panel,
241
- $aria_current
242
- );
243
- }
244
-
245
- /**
246
- * Parsing the category counts.
247
- *
248
- * When there are 0 issues for a specific category, just remove that one from the array.
249
- *
250
- * @param array $category_counts Set of counts for categories.
251
- *
252
- * @return mixed
253
- */
254
- private function parse_counts( $category_counts ) {
255
- foreach ( $category_counts as $category_name => $category ) {
256
- if ( $category['count'] === '0' ) {
257
- unset( $category_counts[ $category_name ] );
258
- }
259
- }
260
-
261
- return $category_counts;
262
- }
263
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/google_search_console/class-gsc-config.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- /**
3
- * WPSEO plugin file.
4
- *
5
- * @package WPSEO\Admin
6
- */
7
-
8
- /**
9
- * Class WPSEO_GSC_Config.
10
- */
11
- class WPSEO_GSC_Config {
12
-
13
- /**
14
- * The Google search console configuration.
15
- *
16
- * @var array
17
- */
18
- public static $gsc = array(
19
- 'application_name' => 'Yoast SEO',
20
- 'client_id' => '395430892738-ushj8aced0cji2j4bkq6bda6felaigb9.apps.googleusercontent.com',
21
- 'client_secret' => 'c2kYgOwMhk1emWxQ3NaA8wOi',
22
- 'redirect_uri' => 'urn:ietf:wg:oauth:2.0:oob',
23
- 'scopes' => array( 'https://www.googleapis.com/auth/webmasters' ),
24
- );
25
-
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/google_search_console/class-gsc-count.php DELETED
@@ -1,235 +0,0 @@
1
- <?php
2
- /**
3
- * WPSEO plugin file.
4
- *
5
- * @package WPSEO\Admin\Google_Search_Console
6
- */
7
-
8
- /**
9
- * Class WPSEO_GSC_Count.
10
- */
11
- class WPSEO_GSC_Count {
12
-
13
- /**
14
- * The name of the option containing the last checked timestamp.
15
- *
16
- * @var string
17
- */
18
- const OPTION_CI_LAST_FETCH = 'wpseo_gsc_last_fetch';
19
-
20
- /**
21
- * The option name where the issues counts are saved.
22
- *
23
- * @var string
24
- */
25
- const OPTION_CI_COUNTS = 'wpseo_gsc_issues_counts';
26
-
27
- /**
28
- * Service that fetches data from GSC API.
29
- *
30
- * @var WPSEO_GSC_Service
31
- */
32
- private $service;
33
-
34
- /**
35
- * Holder for the fetched issues from GSC.
36
- *
37
- * @var array
38
- */
39
- private $issues = array();
40
-
41
- /**
42
- * Fetching the counts
43
- *
44
- * @param WPSEO_GSC_Service $service Service class instance.
45
- */
46
- public function __construct( WPSEO_GSC_Service $service ) {
47
- $this->service = $service;
48
- }
49
-
50
- /**
51
- * Getting the counts for given platform and return them as an array.
52
- *
53
- * @param string $platform Platform (desktop, mobile, feature phone).
54
- *
55
- * @return array
56
- */
57
- public function get_platform_counts( $platform ) {
58
- $counts = $this->get_counts();
59
- if ( array_key_exists( $platform, $counts ) ) {
60
- return $counts[ $platform ];
61
- }
62
-
63
- return array();
64
- }
65
-
66
- /**
67
- * Return the fetched issues.
68
- *
69
- * @return array
70
- */
71
- public function get_issues() {
72
- return $this->issues;
73
- }
74
-
75
- /**
76
- * Listing the issues an gives them back as fetched issues.
77
- *
78
- * @param string $platform Platform (desktop, mobile, feature phone).
79
- * @param string $category Issue category.
80
- */
81
- public function list_issues( $platform, $category ) {
82
- $counts = $this->get_counts();
83
-
84
- if ( array_key_exists( $platform, $counts ) ) {
85
- $counts[ $platform ] = $this->list_category_issues( $counts[ $platform ], $platform, $category );
86
-
87
- // Write the new counts value.
88
- $this->set_counts( $counts );
89
- }
90
- }
91
-
92
- /**
93
- * Getting the counts for given platform and category.
94
- *
95
- * @param string $platform Platform (desktop, mobile, feature phone).
96
- * @param string $category Issue type.
97
- *
98
- * @return integer
99
- */
100
- public function get_issue_count( $platform, $category ) {
101
- $counts = $this->get_counts();
102
-
103
- if ( ! empty( $counts[ $platform ][ $category ]['count'] ) ) {
104
- return $counts[ $platform ][ $category ]['count'];
105
- }
106
-
107
- return 0;
108
- }
109
-
110
- /**
111
- * Update the count of the issues.
112
- *
113
- * @param string $platform Platform (desktop, mobile, feature phone).
114
- * @param string $category Issue type.
115
- * @param integer $new_count Updated count.
116
- */
117
- public function update_issue_count( $platform, $category, $new_count ) {
118
- $counts = $this->get_counts();
119
-
120
- if ( ! empty( $counts[ $platform ][ $category ] ) && is_array( $counts[ $platform ][ $category ] ) ) {
121
- $counts[ $platform ][ $category ]['count'] = $new_count;
122
- }
123
-
124
- $this->set_counts( $counts );
125
- }
126
-
127
- /**
128
- * Fetching the counts from the GSC API.
129
- */
130
- public function fetch_counts() {
131
- if ( WPSEO_GSC_Settings::get_profile() && $this->get_last_fetch() <= strtotime( '-12 hours' ) ) {
132
- // Remove the timestamp.
133
- $this->remove_last_fetch();
134
-
135
- // Getting the counts and parse them.
136
- $counts = $this->parse_counts( $this->service->get_crawl_issue_counts() );
137
-
138
- // Fetching the counts by setting an option.
139
- $this->set_counts( $counts );
140
-
141
- // Saving the current timestamp.
142
- $this->save_last_fetch();
143
- }
144
- }
145
-
146
- /**
147
- * Parsing the received counts from the API and map the keys to plugin friendly values.
148
- *
149
- * @param array $fetched_counts Set of retrieved counts.
150
- *
151
- * @return array
152
- */
153
- private function parse_counts( array $fetched_counts ) {
154
- $counts = array();
155
- foreach ( $fetched_counts as $platform_name => $categories ) {
156
- $new_platform = WPSEO_GSC_Mapper::platform_from_api( $platform_name );
157
-
158
- foreach ( $categories as $category_name => $category ) {
159
- $new_category = WPSEO_GSC_Mapper::category_from_api( $category_name );
160
-
161
- $counts[ $new_platform ][ $new_category ] = $category;
162
- }
163
- }
164
-
165
- return $counts;
166
- }
167
-
168
- /**
169
- * Listing the issues for current category.
170
- *
171
- * @param array $counts Set of counts.
172
- * @param string $platform Platform (desktop, mobile, feature phone).
173
- * @param string $category Issue type.
174
- *
175
- * @return array
176
- */
177
- private function list_category_issues( array $counts, $platform, $category ) {
178
- // When the issues have to be fetched.
179
- if ( array_key_exists( $category, $counts ) && $counts[ $category ]['count'] > 0 && $counts[ $category ]['last_fetch'] <= strtotime( '-12 hours' ) ) {
180
- $issues = $this->service->fetch_category_issues( WPSEO_GSC_Mapper::platform_to_api( $platform ), WPSEO_GSC_Mapper::category_to_api( $category ) );
181
- if ( ! empty( $issues ) ) {
182
- $this->issues = $issues;
183
- }
184
-
185
- // Be sure the total count is correct.
186
- $counts[ $category ]['count'] = count( $this->issues );
187
-
188
- // Set last fetch.
189
- $counts[ $category ]['last_fetch'] = time();
190
- }
191
-
192
- return $counts;
193
- }
194
-
195
- /**
196
- * Getting the counts from the options
197
- *
198
- * @return array
199
- */
200
- private function get_counts() {
201
- return get_option( self::OPTION_CI_COUNTS, array() );
202
- }
203
-
204
- /**
205
- * Fetching the counts from the service and store them in an option
206
- *
207
- * @param array $counts Set of counts.
208
- */
209
- private function set_counts( array $counts ) {
210
- update_option( self::OPTION_CI_COUNTS, $counts );
211
- }
212
-
213
- /**
214
- * Store the timestamp of when crawl errors were saved the last time.
215
- */
216
- private function save_last_fetch() {
217
- add_option( self::OPTION_CI_LAST_FETCH, time(), '', 'no' );
218
- }
219
-
220
- /**
221
- * Remove the last checked option
222
- */
223
- private function remove_last_fetch() {
224
- delete_option( self::OPTION_CI_LAST_FETCH );
225
- }
226
-
227
- /**
228
- * Get the timestamp of when the crawl errors were last saved
229
- *
230
- * @return int
231
- */
232
- private function get_last_fetch() {
233
- return get_option( self::OPTION_CI_LAST_FETCH, 0 );
234
- }
235
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/google_search_console/class-gsc-issue.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
- /**
3
- * WPSEO plugin file.
4
- *
5
- * @package WPSEO\Admin\Google_Search_Console
6
- */
7
-
8
- /**
9
- * Class WPSEO_GSC_Issue.
10
- */
11
- class WPSEO_GSC_Issue {
12
-
13
- /**
14
- * The URL of the Google Search Console issue.
15
- *
16
- * @var string
17
- */