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

Yoast / wordpress-seo / 07ede00b851a4d772f8c4dea47e6335593a19b03

12 Aug 2025 12:16PM UTC coverage: 52.835% (-0.07%) from 52.906%
07ede00b851a4d772f8c4dea47e6335593a19b03

Pull #22489

github

web-flow
Merge 9a1e897e1 into c0dcdb8c1
Pull Request #22489: Stops showing the introduction modals in the FTC

8340 of 15135 branches covered (55.1%)

Branch coverage included in aggregate %.

2 of 13 new or added lines in 2 files covered. (15.38%)

139 existing lines in 13 files now uncovered.

31240 of 59778 relevant lines covered (52.26%)

39942.25 hits per line

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

0.0
/admin/class-premium-upsell-admin-block.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin
6
 */
7

8
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
9
use Yoast\WP\SEO\Promotions\Application\Promotion_Manager;
10

11
/**
12
 * Class WPSEO_Premium_Upsell_Admin_Block
13
 */
14
class WPSEO_Premium_Upsell_Admin_Block {
15

16
        /**
17
         * Hook to display the block on.
18
         *
19
         * @var string
20
         */
21
        protected $hook;
22

23
        /**
24
         * Identifier to use in the dismissal functionality.
25
         *
26
         * @var string
27
         */
28
        protected $identifier = 'premium_upsell';
29

30
        /**
31
         * Registers which hook the block will be displayed on.
32
         *
33
         * @param string $hook Hook to display the block on.
34
         */
35
        public function __construct( $hook ) {
×
UNCOV
36
                $this->hook = $hook;
×
37
        }
38

39
        /**
40
         * Registers WordPress hooks.
41
         *
42
         * @return void
43
         */
44
        public function register_hooks() {
×
UNCOV
45
                add_action( $this->hook, [ $this, 'render' ] );
×
46
        }
47

48
        /**
49
         * Renders the upsell block.
50
         *
51
         * @return void
52
         */
53
        public function render() {
×
54

55
                $is_woocommerce_active = ( new WooCommerce_Conditional() )->is_met();
×
56
                $url                   = ( $is_woocommerce_active ) ? WPSEO_Shortlinker::get( 'https://yoa.st/admin-footer-upsell-woocommerce' ) : WPSEO_Shortlinker::get( 'https://yoa.st/17h' );
×
57

58
                [ $header_text, $header_icon ] = $this->get_header( $is_woocommerce_active );
×
59

60
                $arguments = $this->get_arguments( $is_woocommerce_active );
×
61

62
                $arguments_html = implode( '', array_map( [ $this, 'get_argument_html' ], $arguments ) );
×
63

64
                $class = $this->get_html_class();
×
65

66
                /* translators: %s expands to Yoast SEO Premium */
67
                $button_text = $this->get_button_text( $is_woocommerce_active );
×
68
                /* translators: Hidden accessibility text. */
UNCOV
69
                $button_text .= '<span class="screen-reader-text">' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>'
×
70
                        . '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
×
71

72
                $upgrade_button = sprintf(
×
73
                        '<a id="%1$s" class="yoast-button-upsell" data-action="load-nfd-ctb" data-ctb-id="f6a84663-465f-4cb5-8ba5-f7a6d72224b2" href="%2$s" target="_blank">%3$s</a>',
×
74
                        esc_attr( 'wpseo-' . $this->identifier . '-popup-button' ),
×
UNCOV
75
                        esc_url( $url ),
×
76
                        $button_text
×
77
                );
×
78

79
                echo '<div class="' . esc_attr( $class ) . '">';
×
80

UNCOV
81
                if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-2024-promotion' ) ) {
×
82
                        $bf_label   = esc_html__( 'BLACK FRIDAY', 'wordpress-seo' );
×
83
                        $sale_label = esc_html__( '30% OFF', 'wordpress-seo' );
×
84
                        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped above.
85
                        echo "<div class='black-friday-container'><span>$sale_label</span> <span style='margin-left: auto;'>$bf_label</span> </div>";
×
86
                }
87

88
                echo '<div class="' . esc_attr( $class . '--container' ) . '">';
×
89
                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in get_header() method.
90
                echo '<h2 class="' . esc_attr( $class . '--header' ) . '">' . $header_text . $header_icon . '</h2>';
×
91

92
                echo '<span class="' . esc_attr( $class . '--subheader' ) . '">'
×
93
                        . esc_html__( 'Now includes Local, News & Video SEO + 1 Google Docs seat!', 'wordpress-seo' )
×
UNCOV
94
                . '</span>';
×
95
                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $this->get_argument_html() method.
UNCOV
96
                echo '<ul class="' . esc_attr( $class . '--motivation' ) . '">' . $arguments_html . '</ul>';
×
97

98
                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $upgrade_button and $button_text above.
UNCOV
99
                echo '<p style="max-width: inherit;">' . $upgrade_button . '</p>';
×
100
                echo '</div>';
×
101

102
                echo '</div>';
×
103
        }
104

105
        /**
106
         * Formats the argument to a HTML list item.
107
         *
108
         * @param string $argument The argument to format.
109
         *
110
         * @return string Formatted argument in HTML.
111
         */
112
        protected function get_argument_html( $argument ) {
×
UNCOV
113
                $class = $this->get_html_class();
×
114

115
                return sprintf(
×
116
                        '<li style="margin-inline-start: 8px;"><span>•</span><div class="%1$s">%2$s</div></li>',
×
UNCOV
117
                        esc_attr( $class . '--argument' ),
×
118
                        $argument
×
UNCOV
119
                );
×
120
        }
121

122
        /**
123
         * Returns the HTML base class to use.
124
         *
125
         * @return string The HTML base class.
126
         */
127
        protected function get_html_class() {
×
128
                return 'yoast_' . $this->identifier;
×
129
        }
130

131
        /**
132
         * Returns the arguments based on whether WooCommerce is active.
133
         *
134
         * @param bool $is_woocommerce_active Whether WooCommerce is active.
135
         *
136
         * @return array<string> The arguments list.
137
         */
UNCOV
138
        private function get_arguments( bool $is_woocommerce_active ) {
×
UNCOV
139
                $arguments = [
×
UNCOV
140
                        esc_html__( 'Generate SEO optimized metadata in seconds with AI', 'wordpress-seo' ),
×
UNCOV
141
                        esc_html__( 'Make your articles visible, be seen in Google News', 'wordpress-seo' ),
×
UNCOV
142
                        esc_html__( 'Built to get found by search, AI, and real users', 'wordpress-seo' ),
×
UNCOV
143
                        esc_html__( 'Easy Local SEO. Show up in Google Maps results', 'wordpress-seo' ),
×
UNCOV
144
                        esc_html__( 'Internal links and redirect management, easy', 'wordpress-seo' ),
×
UNCOV
145
                        esc_html__( 'Access to friendly help when you need it, day or night', 'wordpress-seo' ),
×
UNCOV
146
                ];
×
147

148
                if ( $is_woocommerce_active ) {
×
UNCOV
149
                        $arguments[1] = esc_html__( 'Boost visibility for your products, from 10 or 10,000+', 'wordpress-seo' );
×
150
                }
151

152
                return $arguments;
×
153
        }
154

155
        /**
156
         * Returns the header text and icon based on whether WooCommerce is active.
157
         *
158
         * @param bool $is_woocommerce_active Whether WooCommerce is active.
159
         *
160
         * @return array<string, string> The header text and icon.
161
         */
162
        private function get_header( bool $is_woocommerce_active ) {
×
163
                $assets_uri = trailingslashit( plugin_dir_url( WPSEO_FILE ) );
×
UNCOV
164
                if ( $is_woocommerce_active ) {
×
UNCOV
165
                        $header_text = sprintf(
×
166
                        /* translators: %s expands to Yoast WooCommerce SEO */
UNCOV
167
                                esc_html__( 'Upgrade to %s', 'wordpress-seo' ),
×
UNCOV
168
                                'Yoast WooCommerce SEO'
×
UNCOV
169
                        );
×
UNCOV
170
                        $header_icon = sprintf(
×
UNCOV
171
                                '<img src="%s" alt="%s" width="14" height="14" style="margin-inline-start: 8px;">',
×
UNCOV
172
                                esc_url( $assets_uri . 'packages/js/images/icon-trolley.svg' ),
×
UNCOV
173
                                esc_attr__( 'this is a trolley icon', 'wordpress-seo' )
×
UNCOV
174
                        );
×
175
                }
176
                else {
UNCOV
177
                        $header_text = sprintf(
×
178
                        /* translators: %s expands to Yoast SEO Premium*/
UNCOV
179
                                esc_html__( 'Upgrade to %s', 'wordpress-seo' ),
×
UNCOV
180
                                'Yoast SEO Premium'
×
UNCOV
181
                        );
×
182

UNCOV
183
                        $header_icon = sprintf(
×
UNCOV
184
                                '<img src="%s" alt="%s" width="14" height="14" style="margin-inline-start: 8px;">',
×
UNCOV
185
                                esc_url( $assets_uri . 'packages/js/images/icon-crown.svg' ),
×
UNCOV
186
                                esc_attr__( 'this is a crown icon', 'wordpress-seo' )
×
UNCOV
187
                        );
×
188
                }
UNCOV
189
                return [ $header_text, $header_icon ];
×
190
        }
191

192
        /**
193
         * Returns the button text based on whether WooCommerce is active.
194
         *
195
         * @param bool $is_woocommerce_active Whether WooCommerce is active.
196
         *
197
         * @return string The button text.
198
         */
UNCOV
199
        private function get_button_text( bool $is_woocommerce_active ): string {
×
UNCOV
200
                if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-2024-promotion' ) ) {
×
UNCOV
201
                        return esc_html__( 'Upgrade now', 'wordpress-seo' );
×
202
                }
203
                else {
204
                        // phpcs:disable Squiz.ControlStructures.InlineIfDeclaration.NotSingleLine -- needed to add translators comments.
UNCOV
205
                        return $is_woocommerce_active
×
UNCOV
206
                                /* translators: %s expands to Yoast WooCommerce SEO */
×
UNCOV
207
                                ? sprintf( esc_html__( 'Explore %s now!', 'wordpress-seo' ), 'Yoast WooCommerce SEO' )
×
UNCOV
208
                                /* translators: %s expands to Yoast SEO Premium */
×
UNCOV
209
                                : sprintf( esc_html__( 'Explore %s now!', 'wordpress-seo' ), 'Yoast SEO Premium' );
×
210
                }
211
        }
212
}
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

© 2025 Coveralls, Inc