• 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/integrations/third-party/wpml-wpseo-notification.php
1
<?php
2

3
namespace Yoast\WP\SEO\Integrations\Third_Party;
4

5
use Yoast\WP\SEO\Conditionals\Third_Party\WPML_Conditional;
6
use Yoast\WP\SEO\Conditionals\Third_Party\WPML_WPSEO_Conditional;
7
use Yoast\WP\SEO\Helpers\Short_Link_Helper;
8
use Yoast\WP\SEO\Integrations\Integration_Interface;
9
use Yoast_Notification;
10
use Yoast_Notification_Center;
11

12
/**
13
 * Adds a notification to the dashboard if the WPML plugin is installed,
14
 * but the Yoast SEO Multilingual plugin (a glue plugin to make Yoast SEO and WPML work nicely together)
15
 * is not.
16
 */
17
class WPML_WPSEO_Notification implements Integration_Interface {
18

19
        /**
20
         * The notification ID.
21
         *
22
         * @internal
23
         */
24
        const NOTIFICATION_ID = 'wpml-wpseo-not-installed';
25

26
        /**
27
         * The short link helper.
28
         *
29
         * @var Short_Link_Helper
30
         */
31
        protected $short_link_helper;
32

33
        /**
34
         * The notification center.
35
         *
36
         * @var Yoast_Notification_Center
37
         */
38
        protected $notification_center;
39

40
        /**
41
         * The WPML WPSEO conditional.
42
         *
43
         * @var WPML_WPSEO_Conditional
44
         */
45
        protected $wpml_wpseo_conditional;
46

47
        /**
48
         * WPML WPSEO notification constructor.
49
         *
50
         * @param Short_Link_Helper         $short_link_helper      The short link helper.
51
         * @param Yoast_Notification_Center $notification_center    The notification center.
52
         * @param WPML_WPSEO_Conditional    $wpml_wpseo_conditional The WPML WPSEO conditional.
53
         */
54
        public function __construct(
55
                Short_Link_Helper $short_link_helper,
56
                Yoast_Notification_Center $notification_center,
57
                WPML_WPSEO_Conditional $wpml_wpseo_conditional
58
        ) {
59
                $this->short_link_helper      = $short_link_helper;
×
60
                $this->notification_center    = $notification_center;
×
61
                $this->wpml_wpseo_conditional = $wpml_wpseo_conditional;
×
62
        }
63

64
        /**
65
         * Initializes the integration.
66
         *
67
         * @return void
68
         */
69
        public function register_hooks() {
70
                \add_action( 'admin_notices', [ $this, 'notify_not_installed' ] );
×
71
        }
72

73
        /**
74
         * Returns the conditionals based in which this loadable should be active.
75
         *
76
         * This integration should only be active when WPML is installed and activated.
77
         *
78
         * @return array The conditionals.
79
         */
80
        public static function get_conditionals() {
81
                return [ WPML_Conditional::class ];
×
82
        }
83

84
        /**
85
         * Notify the user that the Yoast SEO Multilingual plugin is not installed
86
         * (when the WPML plugin is installed).
87
         *
88
         * Remove the notification again when it is installed.
89
         *
90
         * @return void
91
         */
92
        public function notify_not_installed() {
93
                if ( ! $this->wpml_wpseo_conditional->is_met() ) {
×
94
                        $this->notification_center->add_notification( $this->get_notification() );
×
95
                        return;
×
96
                }
97
                $this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID );
×
98
        }
99

100
        /**
101
         * Generates the notification to show to the user when WPML is installed,
102
         * but the Yoast SEO Multilingual plugin is not.
103
         *
104
         * @return Yoast_Notification The notification.
105
         */
106
        protected function get_notification() {
107
                return new Yoast_Notification(
×
108
                        \sprintf(
×
109
                                /* translators: %1$s expands to an opening anchor tag, %2$s expands to an closing anchor tag. */
110
                                \__( 'We notice that you have installed WPML. To make sure your canonical URLs are set correctly, %1$sinstall and activate the Yoast SEO Multilingual add-on%2$s as well!', 'wordpress-seo' ),
×
111
                                '<a href="' . \esc_url( $this->short_link_helper->get( 'https://yoa.st/wpml-yoast-seo' ) ) . '" target="_blank">',
×
112
                                '</a>'
×
113
                        ),
×
114
                        [
×
115
                                'id'   => self::NOTIFICATION_ID,
×
116
                                'type' => Yoast_Notification::WARNING,
×
117
                        ]
×
118
                );
×
119
        }
120
}
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