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.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Admin / Features / Features.php
woocommerce / src / Admin / Features Last commit date
AsyncProductEditorCategoryField 3 years ago Blueprint 11 months ago Fulfillments 4 weeks ago MarketingRecommendations 3 months ago Navigation 1 year ago OnboardingTasks 4 weeks ago PaymentGatewaySuggestions 1 year ago ProductBlockEditor 4 weeks ago ProductDataViews 4 weeks ago ShippingPartnerSuggestions 1 month ago Features.php 4 weeks ago LaunchYourStore.php 4 weeks ago Onboarding.php 1 year ago ProductVariationsClassicRedesign.php 4 weeks ago TransientNotices.php 3 years ago
Features.php
354 lines
1 <?php
2 /**
3 * Features loader for features developed in WooCommerce Admin.
4 */
5
6 namespace Automattic\WooCommerce\Admin\Features;
7
8 use Automattic\WooCommerce\Admin\PageController;
9 use Automattic\WooCommerce\Internal\Admin\Loader;
10 use Automattic\WooCommerce\Internal\Admin\WCAdminAssets;
11 use Automattic\WooCommerce\Utilities\FeaturesUtil;
12
13 /**
14 * Features Class.
15 */
16 class Features {
17 /**
18 * Class instance.
19 *
20 * @var Loader instance
21 */
22 protected static $instance = null;
23
24 /**
25 * Optional features
26 *
27 * @var array
28 */
29 protected static $optional_features = array(
30 'analytics' => array( 'default' => 'yes' ),
31 'remote-inbox-notifications' => array( 'default' => 'yes' ),
32 );
33
34 /**
35 * Get class instance.
36 */
37 public static function get_instance() {
38 if ( ! self::$instance ) {
39 self::$instance = new self();
40 }
41 return self::$instance;
42 }
43
44 /**
45 * Constructor.
46 */
47 public function __construct() {
48
49 $this->register_internal_class_aliases();
50
51 if ( ! self::should_load_features() ) {
52 return;
53 }
54
55 // Load feature before WooCommerce update hooks.
56 add_action( 'init', array( __CLASS__, 'load_features' ), 4 );
57 add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_scripts' ), 15 );
58 add_filter( 'admin_body_class', array( __CLASS__, 'add_admin_body_classes' ) );
59 }
60
61 /**
62 * Gets a build configured array of enabled WooCommerce Admin features/sections, but does not respect optionally disabled features.
63 *
64 * @return array Enabled Woocommerce Admin features/sections.
65 */
66 public static function get_features() {
67 return apply_filters( 'woocommerce_admin_features', array() );
68 }
69
70 /**
71 * Gets the optional feature options as an associative array that can be toggled on or off.
72 *
73 * @return array
74 */
75 public static function get_optional_feature_options() {
76 $features = array();
77
78 foreach ( array_keys( self::$optional_features ) as $optional_feature_key ) {
79 $feature_class = self::get_feature_class( $optional_feature_key );
80
81 if ( $feature_class ) {
82 $features[ $optional_feature_key ] = $feature_class::TOGGLE_OPTION_NAME;
83 }
84 }
85 return $features;
86 }
87
88 /**
89 * Returns if a specific wc-admin feature exists in the current environment.
90 *
91 * @param string $feature Feature slug.
92 * @return bool Returns true if the feature exists.
93 */
94 public static function exists( $feature ) {
95 $features = self::get_features();
96 return in_array( $feature, $features, true );
97 }
98
99 /**
100 * Get the feature class as a string.
101 *
102 * @param string $feature Feature name.
103 * @return string|null
104 */
105 public static function get_feature_class( $feature ) {
106 $feature = str_replace( '-', '', ucwords( strtolower( $feature ), '-' ) );
107 $feature_class = 'Automattic\\WooCommerce\\Admin\\Features\\' . $feature;
108
109 $should_autoload_class = self::should_load_features();
110
111 if ( class_exists( $feature_class, $should_autoload_class ) ) {
112 return $feature_class;
113 }
114
115 // Handle features contained in subdirectory.
116 if ( class_exists( $feature_class . '\\Init', $should_autoload_class ) ) {
117 return $feature_class . '\\Init';
118 }
119
120 return null;
121 }
122
123 /**
124 * Class loader for enabled WooCommerce Admin features/sections.
125 */
126 public static function load_features() {
127 if ( ! self::should_load_features() ) {
128 return;
129 }
130
131 $features = self::get_features();
132 foreach ( $features as $feature ) {
133 $feature_class = self::get_feature_class( $feature );
134
135 if ( $feature_class ) {
136 new $feature_class();
137 }
138 }
139
140 if ( FeaturesUtil::feature_is_enabled( 'blueprint' ) ) {
141 new \Automattic\WooCommerce\Admin\Features\Blueprint\Init();
142 }
143
144 if ( FeaturesUtil::feature_is_enabled( 'order-detail-redesign' ) ) {
145 new \Automattic\WooCommerce\Internal\Features\OrderDetailRedesign\Init();
146 }
147 }
148
149 /**
150 * Gets a build configured array of enabled WooCommerce Admin respecting optionally disabled features.
151 *
152 * @return array Enabled Woocommerce Admin features/sections.
153 */
154 public static function get_available_features() {
155 $features = self::get_features();
156 $optional_feature_keys = array_keys( self::$optional_features );
157 $optional_features_unavailable = array();
158
159 /**
160 * Filter allowing WooCommerce Admin optional features to be disabled.
161 *
162 * @param bool $disabled False.
163 */
164 if ( apply_filters( 'woocommerce_admin_disabled', false ) ) {
165 return array_values( array_diff( $features, $optional_feature_keys ) );
166 }
167
168 foreach ( $optional_feature_keys as $optional_feature_key ) {
169 $feature_class = self::get_feature_class( $optional_feature_key );
170
171 if ( $feature_class ) {
172 $default = isset( self::$optional_features[ $optional_feature_key ]['default'] ) ?
173 self::$optional_features[ $optional_feature_key ]['default'] :
174 'no';
175
176 // Check if the feature is currently being enabled, if it is continue.
177 /* phpcs:disable WordPress.Security.NonceVerification */
178 $feature_option = $feature_class::TOGGLE_OPTION_NAME;
179 if ( isset( $_POST[ $feature_option ] ) && '1' === $_POST[ $feature_option ] ) {
180 continue;
181 }
182
183 if ( 'yes' !== get_option( $feature_class::TOGGLE_OPTION_NAME, $default ) ) {
184 $optional_features_unavailable[] = $optional_feature_key;
185 }
186 }
187 }
188
189 return array_values( array_diff( $features, $optional_features_unavailable ) );
190 }
191
192 /**
193 * Check if a feature is enabled.
194 *
195 * @param string $feature Feature slug.
196 * @return bool
197 */
198 public static function is_enabled( $feature ) {
199 $available_features = self::get_available_features();
200 return in_array( $feature, $available_features, true );
201 }
202
203 /**
204 * Enable a toggleable optional feature.
205 *
206 * @param string $feature Feature name.
207 * @return bool
208 */
209 public static function enable( $feature ) {
210 $features = self::get_optional_feature_options();
211
212 if ( isset( $features[ $feature ] ) ) {
213 update_option( $features[ $feature ], 'yes' );
214 return true;
215 }
216
217 return false;
218 }
219
220 /**
221 * Disable a toggleable optional feature.
222 *
223 * @param string $feature Feature name.
224 * @return bool
225 */
226 public static function disable( $feature ) {
227 $features = self::get_optional_feature_options();
228
229 if ( isset( $features[ $feature ] ) ) {
230 update_option( $features[ $feature ], 'no' );
231 return true;
232 }
233
234 return false;
235 }
236
237 /**
238 * Adds the Features section to the advanced tab of WooCommerce Settings
239 *
240 * @deprecated 7.0 The WooCommerce Admin features are now handled by the WooCommerce features engine (see the FeaturesController class).
241 *
242 * @param array $sections Sections.
243 * @return array
244 */
245 public static function add_features_section( $sections ) {
246 return $sections;
247 }
248
249 /**
250 * Adds the Features settings.
251 *
252 * @deprecated 7.0 The WooCommerce Admin features are now handled by the WooCommerce features engine (see the FeaturesController class).
253 *
254 * @param array $settings Settings.
255 * @param string $current_section Current section slug.
256 * @return array
257 */
258 public static function add_features_settings( $settings, $current_section ) {
259 return $settings;
260 }
261
262 /**
263 * Loads the required scripts on the correct pages.
264 */
265 public static function load_scripts() {
266 if ( ! PageController::is_admin_or_embed_page() ) {
267 return;
268 }
269
270 $features = self::get_features();
271 $enabled_features = array();
272 foreach ( $features as $key ) {
273 $enabled_features[ $key ] = self::is_enabled( $key );
274 }
275 wp_add_inline_script( WC_ADMIN_APP, 'window.wcAdminFeatures = ' . wp_json_encode( $enabled_features, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 'before' );
276 }
277
278
279 /**
280 * Adds body classes to the main wp-admin wrapper, allowing us to better target elements in specific scenarios.
281 *
282 * @param string $admin_body_class Body class to add.
283 */
284 public static function add_admin_body_classes( $admin_body_class = '' ) {
285 if ( ! PageController::is_admin_or_embed_page() ) {
286 return $admin_body_class;
287 }
288
289 $classes = explode( ' ', trim( $admin_body_class ) );
290
291 $features = self::get_features();
292 foreach ( $features as $feature_key ) {
293 $classes[] = sanitize_html_class( 'woocommerce-feature-enabled-' . $feature_key );
294 }
295
296 $admin_body_class = implode( ' ', array_unique( $classes ) );
297 return " $admin_body_class ";
298 }
299
300 /**
301 * Alias internal features classes to make them backward compatible.
302 * We've moved our feature classes to src-internal as part of merging this
303 * repository with WooCommerce Core to form a monorepo.
304 * See https://wp.me/p90Yrv-2HY for details.
305 */
306 private function register_internal_class_aliases() {
307 $aliases = array(
308 // new class => original class (this will be aliased).
309 'Automattic\WooCommerce\Internal\Admin\WCPayPromotion\Init' => 'Automattic\WooCommerce\Admin\Features\WcPayPromotion\Init',
310 'Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions\Init' => 'Automattic\WooCommerce\Admin\Features\RemoteFreeExtensions\Init',
311 'Automattic\WooCommerce\Internal\Admin\ActivityPanels' => 'Automattic\WooCommerce\Admin\Features\ActivityPanels',
312 'Automattic\WooCommerce\Internal\Admin\Analytics' => 'Automattic\WooCommerce\Admin\Features\Analytics',
313 'Automattic\WooCommerce\Internal\Admin\Coupons' => 'Automattic\WooCommerce\Admin\Features\Coupons',
314 'Automattic\WooCommerce\Internal\Admin\CouponsMovedTrait' => 'Automattic\WooCommerce\Admin\Features\CouponsMovedTrait',
315 'Automattic\WooCommerce\Internal\Admin\CustomerEffortScoreTracks' => 'Automattic\WooCommerce\Admin\Features\CustomerEffortScoreTracks',
316 'Automattic\WooCommerce\Internal\Admin\Homescreen' => 'Automattic\WooCommerce\Admin\Features\Homescreen',
317 'Automattic\WooCommerce\Internal\Admin\Marketing' => 'Automattic\WooCommerce\Admin\Features\Marketing',
318 'Automattic\WooCommerce\Internal\Admin\MobileAppBanner' => 'Automattic\WooCommerce\Admin\Features\MobileAppBanner',
319 'Automattic\WooCommerce\Internal\Admin\RemoteInboxNotifications' => 'Automattic\WooCommerce\Admin\Features\RemoteInboxNotifications',
320 'Automattic\WooCommerce\Internal\Admin\ShippingLabelBanner' => 'Automattic\WooCommerce\Admin\Features\ShippingLabelBanner',
321 'Automattic\WooCommerce\Internal\Admin\ShippingLabelBannerDisplayRules' => 'Automattic\WooCommerce\Admin\Features\ShippingLabelBannerDisplayRules',
322 'Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage' => 'Automattic\WooCommerce\Admin\Features\WcPayWelcomePage',
323 );
324 foreach ( $aliases as $new_class => $orig_class ) {
325 class_alias( $new_class, $orig_class );
326 }
327 }
328
329 /**
330 * Check if we're in an admin context where features should be loaded.
331 *
332 * @return boolean
333 */
334 private static function should_load_features() {
335 $should_load = (
336 is_admin() ||
337 wp_doing_ajax() ||
338 wp_doing_cron() ||
339 ( defined( 'WP_CLI' ) && WP_CLI ) ||
340 ( WC()->is_rest_api_request() && ! WC()->is_store_api_request() ) ||
341 // Allow features to be loaded in frontend for admin users. This is needed for the use case such as the coming soon footer banner.
342 current_user_can( 'manage_woocommerce' )
343 );
344
345 /**
346 * Filter to determine if admin features should be loaded.
347 *
348 * @since 9.6.0
349 * @param boolean $should_load Whether admin features should be loaded. It defaults to true when the current request is in an admin context.
350 */
351 return apply_filters( 'woocommerce_admin_should_load_features', $should_load );
352 }
353 }
354