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

Yoast / wordpress-seo / 6638054992

25 Oct 2023 08:55AM UTC coverage: 49.106%. First build
6638054992

Pull #20653

github

vraja-pro
Merge remote-tracking branch 'origin/feature/upgrade-react-and-tests' into feature/upgrade-react-and-tests
Pull Request #20653: Feature/upgrade react and tests

64 of 157 new or added lines in 34 files covered. (40.76%)

13135 of 26748 relevant lines covered (49.11%)

3.96 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\Promotions\Application\Promotion_Manager;
9

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

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

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

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

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

47
        /**
48
         * Renders the upsell block.
49
         *
50
         * @return void
51
         */
52
        public function render() {
53
                $url = WPSEO_Shortlinker::get( 'https://yoa.st/17h' );
×
54

55
                $arguments = [
×
56
                        '<strong>' . esc_html__( 'Use AI', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Quickly create titles & meta descriptions', 'wordpress-seo' ),
×
57
                        '<strong>' . esc_html__( 'No more dead links', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Easy redirect manager', 'wordpress-seo' ),
×
58
                        '<strong>' . esc_html__( 'Superfast internal linking suggestions', 'wordpress-seo' ) . '</strong>',
×
59
                        '<strong>' . esc_html__( 'Social media preview', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Facebook & Twitter', 'wordpress-seo' ),
×
60
                        '<strong>' . esc_html__( 'Multiple keyphrases', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Increase your SEO reach', 'wordpress-seo' ),
×
61
                        '<strong>' . esc_html__( 'SEO Workouts', 'wordpress-seo' ) . '</strong>: ' . esc_html__( 'Get guided in routine SEO tasks', 'wordpress-seo' ),
×
62
                        '<strong>' . esc_html__( '24/7 email support', 'wordpress-seo' ) . '</strong>',
×
63
                        '<strong>' . esc_html__( 'No ads!', 'wordpress-seo' ) . '</strong>',
×
64
                ];
×
65

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

68
                $class = $this->get_html_class();
×
69

70
                /* translators: %s expands to Yoast SEO Premium */
NEW
71
                $button_text = YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-2023-promotion' ) ? \esc_html__( 'Claim your 30% off now!', 'wordpress-seo' ) : sprintf( esc_html__( 'Get %s', 'wordpress-seo' ), 'Yoast SEO Premium' );
×
72
                /* translators: Hidden accessibility text. */
73
                $button_text .= '<span class="screen-reader-text">' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>' .
×
74
                        '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
×
75

76
                $upgrade_button = sprintf(
×
77
                        '<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>',
×
78
                        esc_attr( 'wpseo-' . $this->identifier . '-popup-button' ),
×
79
                        esc_url( $url ),
×
80
                        $button_text
×
81
                );
×
82

83
                echo '<div class="' . esc_attr( $class ) . '">';
×
84

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

NEW
92
                echo '<div class="' . esc_attr( $class . '--container' ) . '">';
×
93
                echo '<h2 class="' . esc_attr( $class . '--header' ) . '">' .
×
94
                        sprintf(
×
95
                                /* translators: %s expands to Yoast SEO Premium */
96
                                esc_html__( 'Upgrade to %s', 'wordpress-seo' ),
×
97
                                'Yoast SEO Premium'
×
98
                        ) .
×
99
                '</h2>';
×
100

101
                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $this->get_argument_html() method.
102
                echo '<ul class="' . esc_attr( $class . '--motivation' ) . '">' . $arguments_html . '</ul>';
×
103

104
                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $upgrade_button and $button_text above.
105
                echo '<p>' . $upgrade_button . '</p>';
×
106
                echo '</div>';
×
107

108
                echo '</div>';
×
109
        }
110

111
        /**
112
         * Formats the argument to a HTML list item.
113
         *
114
         * @param string $argument The argument to format.
115
         *
116
         * @return string Formatted argument in HTML.
117
         */
118
        protected function get_argument_html( $argument ) {
119
                $class = $this->get_html_class();
×
120

121
                return sprintf(
×
122
                        '<li><div class="%1$s">%2$s</div></li>',
×
123
                        esc_attr( $class . '--argument' ),
×
124
                        $argument
×
125
                );
×
126
        }
127

128
        /**
129
         * Returns the HTML base class to use.
130
         *
131
         * @return string The HTML base class.
132
         */
133
        protected function get_html_class() {
134
                return 'yoast_' . $this->identifier;
×
135
        }
136
}
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