PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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
← All changes | admin/class-premium-upsell-admin-block.php +126 -26 18.8 → trunk View file →
@@ -4,8 +4,11 @@
4 4 *
5 5 * @package WPSEO\Admin
6 6 */
7 7
8 +use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
9 +use Yoast\WP\SEO\Promotions\Application\Promotion_Manager;
10 +
8 11 /**
9 12 * Class WPSEO_Premium_Upsell_Admin_Block
10 13 */
11 14 class WPSEO_Premium_Upsell_Admin_Block {
@@ -47,51 +50,66 @@
47 50 *
48 51 * @return void
49 52 */
50 53 public function render() {
51 - $url = WPSEO_Shortlinker::get( 'https://yoa.st/17h' );
52 54
53 - $arguments = [
54 - '<strong>' . esc_html__( 'Multiple keyphrases', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Increase your SEO reach', 'wordpress-seo' ),
55 - '<strong>' . esc_html__( 'No more dead links', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Easy redirect manager', 'wordpress-seo' ),
56 - '<strong>' . esc_html__( 'Superfast internal linking suggestions', 'wordpress-seo' ) . '</strong>',
57 - '<strong>' . esc_html__( 'Social media preview', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Facebook & Twitter', 'wordpress-seo' ),
58 - '<strong>' . esc_html__( '24/7 email support', 'wordpress-seo' ) . '</strong>',
59 - '<strong>' . esc_html__( 'No ads!', 'wordpress-seo' ) . '</strong>',
60 - ];
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' );
61 57
58 + [ $header_text, $header_icon ] = $this->get_header( $is_woocommerce_active );
59 +
60 + $arguments = $this->get_arguments( $is_woocommerce_active );
61 +
62 + $now_including = [ 'Local SEO', 'News SEO', 'Video SEO', __( 'Google Docs add-on (1 seat)', 'wordpress-seo' ) ];
63 + if ( $is_woocommerce_active ) {
64 + array_unshift( $now_including, 'Yoast SEO Premium' );
65 + }
66 +
67 + $header_class = ( $is_woocommerce_active ) ? 'woo-header' : '';
62 68 $arguments_html = implode( '', array_map( [ $this, 'get_argument_html' ], $arguments ) );
69 + $badge_class = ( $is_woocommerce_active ) ? 'woo-badge' : '';
63 70
64 71 $class = $this->get_html_class();
65 72
66 73 /* translators: %s expands to Yoast SEO Premium */
67 - $button_text = sprintf( esc_html__( '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>' .
69 - '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
74 + $button_text = $this->get_button_text( $is_woocommerce_active );
75 + /* translators: Hidden accessibility text. */
76 + $button_text .= '<span class="screen-reader-text">' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>'
77 + . '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
70 78
71 79 $upgrade_button = sprintf(
72 - '<a id="%1$s" class="yoast-button-upsell" href="%2$s" target="_blank">%3$s</a>',
80 + '<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>',
73 81 esc_attr( 'wpseo-' . $this->identifier . '-popup-button' ),
74 82 esc_url( $url ),
75 - $button_text
83 + $button_text,
76 84 );
77 85
78 86 echo '<div class="' . esc_attr( $class ) . '">';
79 87
80 - echo '<div>';
81 - echo '<h2 class="' . esc_attr( $class . '--header' ) . '">' .
82 - sprintf(
83 - /* translators: %s expands to Yoast SEO Premium */
84 - esc_html__( 'Upgrade to %s', 'wordpress-seo' ),
85 - 'Yoast SEO Premium'
86 - ) .
87 - '</h2>';
88 + if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-promotion' ) ) {
89 + $bf_label = esc_html__( 'BLACK FRIDAY', 'wordpress-seo' );
90 + $sale_label = esc_html__( '30% OFF', 'wordpress-seo' );
91 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped above.
92 + echo "<div class='black-friday-container'><span>$sale_label</span> <span style='margin-left: auto;'>$bf_label</span> </div>";
93 + }
88 94
95 + echo '<div class="' . esc_attr( $class . '--container' ) . '">';
96 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in get_header() method.
97 + echo '<h2 class="' . esc_attr( $class . '--header' ) . ' ' . esc_attr( $header_class ) . ' ">' . $header_text . $header_icon . '</h2>';
98 +
99 + echo '<div class="' . esc_attr( $class . '--subheader' ) . '">';
100 + echo '<span style="margin-right: 8px">' . esc_html__( 'Now includes:', 'wordpress-seo' ) . '</span>';
101 + echo '<div style="display: inline-block;">';
102 + foreach ( $now_including as $value ) {
103 + echo '<span class="yoast-badge ' . esc_attr( $class . '--badge' ) . ' ' . esc_attr( $badge_class ) . '">' . esc_html( $value ) . '</span>';
104 + }
105 + echo '</div>';
106 + echo '</div>';
89 107 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $this->get_argument_html() method.
90 108 echo '<ul class="' . esc_attr( $class . '--motivation' ) . '">' . $arguments_html . '</ul>';
91 109
92 110 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $upgrade_button and $button_text above.
93 - echo '<p>' . $upgrade_button . '</p>';
111 + echo '<p style="max-width: inherit; margin-top: 24px; margin-bottom: 0;">' . $upgrade_button . '</p>';
94 112 echo '</div>';
95 113
96 114 echo '</div>';
97 115 }
@@ -103,14 +121,16 @@
103 121 *
104 122 * @return string Formatted argument in HTML.
105 123 */
106 124 protected function get_argument_html( $argument ) {
107 - $class = $this->get_html_class();
125 + $assets_uri = trailingslashit( plugin_dir_url( WPSEO_FILE ) );
126 + $class = $this->get_html_class();
108 127
109 128 return sprintf(
110 - '<li><div class="%1$s">%2$s</div></li>',
129 + '<li style="line-height: 19.5px"><img src="%1$s" alt="" width="19.5" height="19.5"><div class="%2$s">%3$s</div></li>',
130 + esc_url( $assets_uri . 'packages/js/images/icon-check-circle-green.svg' ),
111 131 esc_attr( $class . '--argument' ),
112 - $argument
132 + $argument,
113 133 );
114 134 }
115 135
116 136 /**
@@ -119,6 +139,86 @@
119 139 * @return string The HTML base class.
120 140 */
121 141 protected function get_html_class() {
122 142 return 'yoast_' . $this->identifier;
143 + }
144 +
145 + /**
146 + * Returns the arguments based on whether WooCommerce is active.
147 + *
148 + * @param bool $is_woocommerce_active Whether WooCommerce is active.
149 + *
150 + * @return array<string> The arguments list.
151 + */
152 + private function get_arguments( bool $is_woocommerce_active ) {
153 + $arguments = [
154 + esc_html__( 'Generate SEO optimized metadata in seconds with AI', 'wordpress-seo' ),
155 + esc_html__( 'Make your articles visible, be seen in Google News', 'wordpress-seo' ),
156 + esc_html__( 'Built to get found by search, AI, and real users', 'wordpress-seo' ),
157 + esc_html__( 'Easy Local SEO. Show up in Google Maps results', 'wordpress-seo' ),
158 + esc_html__( 'Internal links and redirect management, easy', 'wordpress-seo' ),
159 + esc_html__( 'Access to friendly help when you need it, day or night', 'wordpress-seo' ),
160 + ];
161 +
162 + if ( $is_woocommerce_active ) {
163 + $arguments[1] = esc_html__( 'Boost visibility for your products, from 10 or 10,000+', 'wordpress-seo' );
164 + }
165 +
166 + return $arguments;
167 + }
168 +
169 + /**
170 + * Returns the header text and icon based on whether WooCommerce is active.
171 + *
172 + * @param bool $is_woocommerce_active Whether WooCommerce is active.
173 + *
174 + * @return array<string, string> The header text and icon.
175 + */
176 + private function get_header( bool $is_woocommerce_active ) {
177 + $assets_uri = trailingslashit( plugin_dir_url( WPSEO_FILE ) );
178 + if ( $is_woocommerce_active ) {
179 + $header_text = sprintf(
180 + /* translators: %s expands to Yoast WooCommerce SEO */
181 + esc_html__( 'Upgrade to %s', 'wordpress-seo' ),
182 + 'Yoast WooCommerce SEO',
183 + );
184 + $header_icon = sprintf(
185 + '<img src="%s" alt="" width="14" height="14" style="margin-inline-start: 8px;">',
186 + esc_url( $assets_uri . 'packages/js/images/icon-trolley.svg' ),
187 + );
188 + }
189 + else {
190 + $header_text = sprintf(
191 + /* translators: %s expands to Yoast SEO Premium*/
192 + esc_html__( 'Upgrade to %s', 'wordpress-seo' ),
193 + 'Yoast SEO Premium',
194 + );
195 +
196 + $header_icon = sprintf(
197 + '<img src="%s" alt="" width="14" height="14" style="margin-inline-start: 8px;">',
198 + esc_url( $assets_uri . 'packages/js/images/icon-crown.svg' ),
199 + );
200 + }
201 + return [ $header_text, $header_icon ];
202 + }
203 +
204 + /**
205 + * Returns the button text based on whether WooCommerce is active.
206 + *
207 + * @param bool $is_woocommerce_active Whether WooCommerce is active.
208 + *
209 + * @return string The button text.
210 + */
211 + private function get_button_text( bool $is_woocommerce_active ): string {
212 + if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-promotion' ) ) {
213 + return esc_html__( 'Get 30% off now!', 'wordpress-seo' );
214 + }
215 + else {
216 + // phpcs:disable Squiz.ControlStructures.InlineIfDeclaration.NotSingleLine -- needed to add translators comments.
217 + return $is_woocommerce_active
218 + /* translators: %s expands to Yoast WooCommerce SEO */
219 + ? sprintf( esc_html__( 'Explore %s now!', 'wordpress-seo' ), 'Yoast WooCommerce SEO' )
220 + /* translators: %s expands to Yoast SEO Premium */
221 + : sprintf( esc_html__( 'Explore %s now!', 'wordpress-seo' ), 'Yoast SEO Premium' );
222 + }
123 223 }
124 224 }