• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 5066322038

pending completion
5066322038

push

github

GitHub
Merge pull request #20316 from Yoast/JRF/ghactions-run-more-selectively

2550 of 29012 relevant lines covered (8.79%)

0.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/presenters/admin/indexing-error-presenter.php
1
<?php
2

3
namespace Yoast\WP\SEO\Presenters\Admin;
4

5
use WPSEO_Addon_Manager;
6
use Yoast\WP\SEO\Helpers\Product_Helper;
7
use Yoast\WP\SEO\Helpers\Short_Link_Helper;
8
use Yoast\WP\SEO\Presenters\Abstract_Presenter;
9

10
/**
11
 * An error that should be shown when indexation has failed.
12
 */
13
class Indexing_Error_Presenter extends Abstract_Presenter {
14

15
        /**
16
         * The short link helper.
17
         *
18
         * @var Short_Link_Helper
19
         */
20
        protected $short_link_helper;
21

22
        /**
23
         * The product helper
24
         *
25
         * @var Product_Helper
26
         */
27
        protected $product_helper;
28

29
        /**
30
         * The addon manager.
31
         *
32
         * @var WPSEO_Addon_Manager
33
         */
34
        protected $addon_manager;
35

36
        /**
37
         * Indexing_Error_Presenter constructor.
38
         *
39
         * @param Short_Link_Helper   $short_link_helper Represents the short link helper.
40
         * @param Product_Helper      $product_helper    The product helper.
41
         * @param WPSEO_Addon_Manager $addon_manager     The addon manager.
42
         */
43
        public function __construct(
44
                Short_Link_Helper $short_link_helper,
45
                Product_Helper $product_helper,
46
                WPSEO_Addon_Manager $addon_manager
47
        ) {
48
                $this->short_link_helper = $short_link_helper;
×
49
                $this->product_helper    = $product_helper;
×
50
                $this->addon_manager     = $addon_manager;
×
51
        }
52

53
        /**
54
         * Generates the first paragraph of the error message to show when indexing failed.
55
         *
56
         * The contents of the paragraph varies based on whether WordPress SEO Premium has a valid, activated subscription or not.
57
         *
58
         * @param bool $is_premium                     Whether WordPress SEO Premium is currently active.
59
         * @param bool $has_valid_premium_subscription Whether WordPress SEO Premium currently has a valid subscription.
60
         *
61
         * @return string
62
         */
63
        protected function generate_first_paragraph( $is_premium, $has_valid_premium_subscription ) {
64
                $message = \__(
×
65
                        'Oops, something has gone wrong and we couldn\'t complete the optimization of your SEO data. Please click the button again to re-start the process. ',
×
66
                        'wordpress-seo'
×
67
                );
×
68

69
                if ( $is_premium ) {
×
70
                        if ( $has_valid_premium_subscription ) {
×
71
                                $message .= \__( 'If the problem persists, please contact support.', 'wordpress-seo' );
×
72
                        }
73
                        else {
74
                                $message = \sprintf(
×
75
                                        /* 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. */
76
                                        \__(
×
77
                                                '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.',
×
78
                                                'wordpress-seo'
×
79
                                        ),
×
80
                                        '<a href="' . \esc_url( $this->short_link_helper->get( 'https://yoa.st/3wv' ) ) . '">',
×
81
                                        '</a>'
×
82
                                );
×
83
                        }
84
                }
85

86
                return $message;
×
87
        }
88

89
        /**
90
         * Generates the second paragraph of the error message to show when indexing failed.
91
         *
92
         * The error message varies based on whether WordPress SEO Premium has a valid, activated subscription or not.
93
         *
94
         * @param bool $is_premium                     Whether WordPress SEO Premium is currently active.
95
         * @param bool $has_valid_premium_subscription Whether WordPress SEO Premium currently has a valid subscription.
96
         *
97
         * @return string The second paragraph of the error message.
98
         */
99
        protected function generate_second_paragraph( $is_premium, $has_valid_premium_subscription ) {
100
                return \sprintf(
×
101
                        /* 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. */
102
                        \__(
×
103
                                'Below are the technical details for the error. See %1$sthis page%2$s for a more detailed explanation.',
×
104
                                'wordpress-seo'
×
105
                        ),
×
106
                        '<a href="' . \esc_url( $this->short_link_helper->get( 'https://yoa.st/4f3' ) ) . '">',
×
107
                        '</a>'
×
108
                );
×
109
        }
110

111
        /**
112
         * Presents the error message to show if SEO optimization failed.
113
         *
114
         * The error message varies based on whether WordPress SEO Premium has a valid, activated subscription or not.
115
         *
116
         * @return string The error message to show.
117
         */
118
        public function present() {
119
                $is_premium                     = $this->product_helper->is_premium();
×
120
                $has_valid_premium_subscription = $this->addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG );
×
121

122
                $output  = '<p>' . $this->generate_first_paragraph( $is_premium, $has_valid_premium_subscription ) . '</p>';
×
123
                $output .= '<p>' . $this->generate_second_paragraph( $is_premium, $has_valid_premium_subscription ) . '</p>';
×
124

125
                return $output;
×
126
        }
127
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc