• 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/wordproof-integration-toggle.php
1
<?php
2

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

5
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
6
use Yoast\WP\SEO\Helpers\Wordproof_Helper;
7
use Yoast\WP\SEO\Integrations\Integration_Interface;
8
use Yoast_Feature_Toggle;
9

10
/**
11
 * Class WordProofIntegrationToggle.
12
 *
13
 * @package Yoast\WP\SEO\Integrations\Third_Party
14
 */
15
class Wordproof_Integration_Toggle implements Integration_Interface {
16

17
        /**
18
         * The WordProof helper instance.
19
         *
20
         * @var Wordproof_Helper
21
         */
22
        protected $wordproof;
23

24
        /**
25
         * The WordProof integration toggle constructor.
26
         *
27
         * @param Wordproof_Helper $wordproof The WordProof helper instance.
28
         */
29
        public function __construct( Wordproof_Helper $wordproof ) {
30
                $this->wordproof = $wordproof;
×
31
        }
32

33
        /**
34
         * Returns the conditionals based in which this loadable should be active.
35
         *
36
         * @return array
37
         */
38
        public static function get_conditionals() {
39
                return [ Admin_Conditional::class ];
×
40
        }
41

42
        /**
43
         * Initializes the integration.
44
         *
45
         * This is the place to register hooks and filters.
46
         *
47
         * @return void
48
         */
49
        public function register_hooks() {
50
                /**
51
                 * Called by Yoast_Integration_Toggles to add extra toggles to the ones defined there.
52
                 */
53
                \add_filter( 'wpseo_integration_toggles', [ $this, 'add_integration_toggle' ] );
×
54

55
                /**
56
                 * Update the default wordproof_integration_active depending if the integration is disabled or not.
57
                 */
58
                \add_filter( 'wpseo_option_wpseo_defaults', [ $this, 'default_values' ] );
×
59

60
                /**
61
                 * Add extra text after the network integration toggle if the toggle is disabled.
62
                 */
63
                \add_action( 'Yoast\WP\SEO\admin_network_integration_after', [ $this, 'after_network_integration_toggle' ] );
×
64
        }
65

66
        /**
67
         * Adds the WordProof integration toggle to the array.
68
         *
69
         * @param array $integration_toggles The integration toggles array.
70
         *
71
         * @return array The updated integration toggles array.
72
         */
73
        public function add_integration_toggle( $integration_toggles ) {
74
                if ( \is_array( $integration_toggles ) ) {
×
75
                        $integration_toggles[] = (object) [
×
76
                                /* translators: %s expands to WordProof */
77
                                'name'            => \sprintf( \__( '%s integration', 'wordpress-seo' ), 'WordProof' ),
×
78
                                'setting'         => 'wordproof_integration_active',
×
79
                                'label'           => \sprintf(
×
80
                                /* translators: %s expands to WordProof */
81
                                        \__( '%1$s can be used to timestamp your privacy page.', 'wordpress-seo' ),
×
82
                                        'WordProof'
×
83
                                ),
×
84
                                /* translators: %s expands to WordProof */
85
                                'read_more_label' => \sprintf( \__( 'Read more about how %s works.', 'wordpress-seo' ), 'WordProof ' ),
×
86
                                'read_more_url'   => 'https://yoa.st/wordproof-integration',
×
87
                                'order'           => 16,
×
88
                                'disabled'        => $this->wordproof->integration_is_disabled(),
×
89
                                'new'             => true,
×
90
                        ];
×
91
                }
92

93
                return $integration_toggles;
×
94
        }
95

96
        /**
97
         * Set the default WordProof integration option value depending if the integration is disabled or not.
98
         *
99
         * @param array $defaults Array containing default wpseo options.
100
         *
101
         * @return array
102
         */
103
        public function default_values( $defaults ) {
104
                if ( $this->wordproof->integration_is_disabled() ) {
×
105
                        $defaults['wordproof_integration_active'] = false;
×
106
                }
107

108
                return $defaults;
×
109
        }
110

111
        /**
112
         * Add an explainer when the integration toggle is disabled.
113
         *
114
         * @deprecated 20.3
115
         * @codeCoverageIgnore
116
         *
117
         * @param Yoast_Feature_Toggle $integration The integration toggle class.
118
         */
119
        public function after_integration_toggle( $integration ) {
120
                \_deprecated_function( __METHOD__, 'Yoast SEO 20.3' );
121
                if ( $integration->setting === 'wordproof_integration_active' ) {
122
                        if ( $integration->disabled ) {
123

124
                                $conditional = $this->wordproof->integration_is_disabled( true );
125

126
                                if ( $conditional === 'Non_Multisite_Conditional' ) {
127
                                        echo '<p>' . \sprintf(
128
                                                /* translators: %s expands to WordProof */
129
                                                \esc_html__( 'Currently, the %s integration is not available for multisites.', 'wordpress-seo' ),
130
                                                'WordProof'
131
                                        ) . '</p>';
132
                                }
133

134
                                if ( $conditional === 'Wordproof_Plugin_Inactive_Conditional' ) {
135
                                        echo '<p>' . \esc_html__( 'The WordProof Timestamp plugin needs to be disabled before you can activate this integration.', 'wordpress-seo' ) . '</p>';
136
                                }
137
                        }
138
                }
139
        }
140

141
        /**
142
         * Add an explainer when the network integration toggle is disabled.
143
         *
144
         * @param Yoast_Feature_Toggle $integration The integration toggle class.
145
         */
146
        public function after_network_integration_toggle( $integration ) {
147
                if ( $integration->setting === 'wordproof_integration_active' ) {
×
148
                        if ( $integration->disabled ) {
×
149
                                echo '<p>' . \sprintf(
×
150
                                        /* translators: %s expands to WordProof */
151
                                        \esc_html__( 'Currently, the %s integration is not available for multisites.', 'wordpress-seo' ),
×
152
                                        'WordProof'
×
153
                                ) . '</p>';
×
154
                        }
155
                }
156
        }
157
}
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