PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.4
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / presenters / admin / indexing-failed-notification-presenter.php

indexing-failed-notification-presenter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.4, at src/presenters/admin/indexing-failed-notification-presenter.php

100 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
3
4 namespace Yoast\WP\SEO\Presenters\Admin;
5
6 use WPSEO_Addon_Manager;
7 use Yoast\WP\SEO\Helpers\Product_Helper;
8 use Yoast\WP\SEO\Helpers\Short_Link_Helper;
9 use Yoast\WP\SEO\Presenters\Abstract_Presenter;
10
11 /**
12 * Class Indexing_Failed_Notification_Presenter.
13 *
14 * @package Yoast\WP\SEO\Presenters\Notifications
15 */
16 class Indexing_Failed_Notification_Presenter extends Abstract_Presenter {
17
18 /**
19 * The product helper.
20 *
21 * @var Product_Helper
22 */
23 protected $product_helper;
24
25 /**
26 * The addon manager.
27 *
28 * @var WPSEO_Addon_Manager
29 */
30 protected $class_addon_manager;
31
32 /**
33 * The short link helper.
34 *
35 * @var Short_Link_Helper
36 */
37 protected $short_link_helper;
38
39 /**
40 * Indexing_Failed_Notification_Presenter constructor.
41 *
42 * @param Product_Helper $product_helper The product helper.
43 * @param Short_Link_Helper $short_link_helper The addon manager.
44 * @param WPSEO_Addon_Manager $class_addon_manager The addon manager.
45 */
46 public function __construct( $product_helper, $short_link_helper, $class_addon_manager ) {
47 $this->class_addon_manager = $class_addon_manager;
48 $this->short_link_helper = $short_link_helper;
49 $this->product_helper = $product_helper;
50 }
51
52 /**
53 * Returns the notification as an HTML string.
54 *
55 * @return string The notification in an HTML string representation.
56 */
57 public function present() {
58 $notification_text = \sprintf(
59 /* Translators: %1$s expands to an opening anchor tag for a link leading to the Yoast SEO tools page, %2$s expands to a closing anchor tag. */
60 \esc_html__(
61 'Something has gone wrong and we couldn\'t complete the optimization of your SEO data. Please %1$sre-start the process%2$s.',
62 'wordpress-seo'
63 ),
64 '<a href="' . \get_admin_url( null, 'admin.php?page=wpseo_tools' ) . '">',
65 '</a>'
66 );
67
68 if ( $this->product_helper->is_premium() ) {
69 if ( $this->has_valid_premium_subscription() ) {
70 // Add a support message for premium customers.
71 $notification_text .= ' ';
72 $notification_text .= \esc_html__( 'If the problem persists, please contact support.', 'wordpress-seo' );
73 }
74 else {
75 // Premium plugin with inactive addon; overwrite the entire error message.
76 $notification_text = \sprintf(
77 /* Translators: %1$s expands to an opening anchor tag for a link leading to the Premium installation page, %2$s expands to a closing anchor tag. */
78 \esc_html__(
79 'Oops, something has gone wrong and we couldn\'t complete the optimization of your SEO data. Please make sure to activate your subscription in MyYoast by completing %1$sthese steps%2$s.',
80 'wordpress-seo'
81 ),
82 '<a href="' . \esc_url( $this->short_link_helper->get( 'https://yoa.st/3wv' ) ) . '">',
83 '</a>'
84 );
85 }
86 }
87
88 return '<p>' . $notification_text . '</p>';
89 }
90
91 /**
92 * Determines if the site has a valid Premium subscription.
93 *
94 * @return bool
95 */
96 protected function has_valid_premium_subscription() {
97 return $this->class_addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG );
98 }
99 }
100