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

Yoast / wordpress-seo / 6987097851

25 Nov 2023 04:49AM UTC coverage: 49.206% (-0.1%) from 49.302%
6987097851

push

github

web-flow
Merge pull request #20878 from Yoast/JRF/ghactions-minor-tweak

GH Actions: update a few links in inline comments

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

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

0.0
/admin/views/class-yoast-feature-toggle.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin
6
 */
7

8
/**
9
 * Class representing a feature toggle.
10
 */
11
class Yoast_Feature_Toggle {
12

13
        /**
14
         * Feature toggle identifier.
15
         *
16
         * @var string
17
         */
18
        protected $name = '';
19

20
        /**
21
         * Name of the setting the feature toggle is associated with.
22
         *
23
         * @var string
24
         */
25
        protected $setting = '';
26

27
        /**
28
         * Whether the feature is premium or not.
29
         *
30
         * @var bool
31
         */
32
        protected $premium = false;
33

34
        /**
35
         * Whether the feature is in beta or not.
36
         *
37
         * @var bool
38
         */
39
        protected $in_beta = false;
40

41
        /**
42
         * The Premium version in which this feature has been added.
43
         *
44
         * @var string
45
         */
46
        protected $premium_version = '';
47

48
        /**
49
         * The languages in which this feature is supported.
50
         * E.g. for language specific analysis support.
51
         *
52
         * If empty, the feature is considered to have support in all languages.
53
         *
54
         * @var string[]
55
         */
56
        protected $supported_languages = [];
57

58
        /**
59
         * Feature toggle label.
60
         *
61
         * @var string
62
         */
63
        protected $label = '';
64

65
        /**
66
         * URL to learn more about the feature.
67
         *
68
         * @var string
69
         */
70
        protected $read_more_url = '';
71

72
        /**
73
         * URL to learn more about the premium feature.
74
         *
75
         * @var string
76
         */
77
        protected $premium_url = '';
78

79
        /**
80
         * URL to buy premium.
81
         *
82
         * @var string
83
         */
84
        protected $premium_upsell_url = '';
85

86
        /**
87
         * Label for the learn more link.
88
         *
89
         * @var string
90
         */
91
        protected $read_more_label = '';
92

93
        /**
94
         * Additional help content for the feature.
95
         *
96
         * @var string
97
         */
98
        protected $extra = '';
99

100
        /**
101
         * Additional content to be rendered after the toggle.
102
         *
103
         * @var string
104
         */
105
        protected $after = '';
106

107
        /**
108
         * Value to specify the feature toggle order.
109
         *
110
         * @var string
111
         */
112
        protected $order = 100;
113

114
        /**
115
         * Disable the integration toggle.
116
         *
117
         * @var bool
118
         */
119
        protected $disabled = false;
120

121
        /**
122
         * Whether the feature is new or not.
123
         *
124
         * @var bool
125
         */
126
        protected $new = false;
127

128
        /**
129
         * Constructor.
130
         *
131
         * Sets the feature toggle arguments.
132
         *
133
         * @param array $args {
134
         *     Feature toggle arguments.
135
         *
136
         *     @type string $name                Required. Feature toggle identifier.
137
         *     @type string $setting             Required. Name of the setting the feature toggle is associated with.
138
         *     @type string $disabled            Whether the feature is premium or not.
139
         *     @type string $label               Feature toggle label.
140
         *     @type string $read_more_url       URL to learn more about the feature. Default empty string.
141
         *     @type string $premium_upsell_url  URL to buy premium. Default empty string.
142
         *     @type string $read_more_label     Label for the learn more link. Default empty string.
143
         *     @type string $extra               Additional help content for the feature. Default empty string.
144
         *     @type int    $order               Value to specify the feature toggle order. A lower value indicates
145
         *                                       a higher priority. Default 100.
146
         *     @type bool   $disabled            Disable the integration toggle. Default false.
147
         *     @type string $new                 Whether the feature is new or not.
148
         *     @type bool   $in_beta             Whether the feature is in beta or not.
149
         *     @type array  $supported_languages The languages that this feature supports.
150
         *     @type string $premium_version     The Premium version in which this feature was added.
151
         * }
152
         *
153
         * @throws InvalidArgumentException Thrown when a required argument is missing.
154
         */
155
        public function __construct( array $args ) {
×
156
                $required_keys = [ 'name', 'setting' ];
×
157

158
                foreach ( $required_keys as $key ) {
×
159
                        if ( empty( $args[ $key ] ) ) {
×
160
                                /* translators: %s: argument name */
161
                                throw new InvalidArgumentException( sprintf( __( '%s is a required feature toggle argument.', 'wordpress-seo' ), $key ) );
×
162
                        }
163
                }
164

165
                foreach ( $args as $key => $value ) {
×
166
                        if ( property_exists( $this, $key ) ) {
×
167
                                $this->$key = $value;
×
168
                        }
169
                }
170
        }
171

172
        /**
173
         * Magic isset-er.
174
         *
175
         * @param string $key Key to check whether a value for it is set.
176
         *
177
         * @return bool True if set, false otherwise.
178
         */
179
        public function __isset( $key ) {
×
180
                return isset( $this->$key );
×
181
        }
182

183
        /**
184
         * Magic getter.
185
         *
186
         * @param string $key Key to get the value for.
187
         *
188
         * @return mixed Value for the key, or null if not set.
189
         */
190
        public function __get( $key ) {
×
191
                if ( isset( $this->$key ) ) {
×
192
                        return $this->$key;
×
193
                }
194

195
                return null;
×
196
        }
197

198
        /**
199
         * Checks whether the feature for this toggle is enabled.
200
         *
201
         * @return bool True if the feature is enabled, false otherwise.
202
         */
203
        public function is_enabled() {
×
204
                return (bool) WPSEO_Options::get( $this->setting );
×
205
        }
206
}
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