* add feature flag

* hydrate options on embedded screens

* is_feature_enabled

* feature class

* feedback

* better name

* fix
This commit is contained in:
Paul Sealock 2020-10-13 13:05:06 +13:00 committed by GitHub
parent 61c189f456
commit c089b49b38
5 changed files with 67 additions and 15 deletions

View File

@ -222,15 +222,19 @@ export const PageLayout = compose(
: identity
)( _PageLayout );
export class EmbedLayout extends Component {
render() {
return (
<Layout
page={ {
breadcrumbs: getSetting( 'embedBreadcrumbs', [] ),
} }
isEmbedded
/>
);
}
}
const _EmbedLayout = () => (
<Layout
page={ {
breadcrumbs: getSetting( 'embedBreadcrumbs', [] ),
} }
isEmbedded
/>
);
export const EmbedLayout = compose(
window.wcSettings.preloadOptions
? withOptionsHydration( {
...window.wcSettings.preloadOptions,
} )
: identity
)( _EmbedLayout );

View File

@ -13,6 +13,7 @@
"store-alerts": true,
"minified-js": false,
"wcpay": true,
"mobile-app-banner": true
"mobile-app-banner": true,
"navigation": false
}
}

View File

@ -13,6 +13,7 @@
"store-alerts": true,
"minified-js": true,
"wcpay": true,
"mobile-app-banner": true
"mobile-app-banner": true,
"navigation": true
}
}

View File

@ -13,6 +13,7 @@
"store-alerts": true,
"minified-js": true,
"wcpay": true,
"mobile-app-banner": true
"mobile-app-banner": true,
"navigation": false
}
}

View File

@ -0,0 +1,45 @@
<?php
/**
* Navigation Experience
*
* @package Woocommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Features;
/**
* Contains logic for the Navigation
*/
class Navigation {
/**
* Hook into WooCommerce.
*/
public function __construct() {
add_filter( 'woocommerce_admin_preload_options', array( $this, 'preload_options' ) );
add_filter( 'woocommerce_admin_features', array( $this, 'maybe_remove_nav_feature' ), 0 );
}
/**
* Overwrites the allowed features array using a local `feature-config.php` file.
*
* @param array $features Array of feature slugs.
*/
public function maybe_remove_nav_feature( $features ) {
if ( in_array( 'navigation', $features, true ) && 'yes' !== get_option( 'woocommerce_navigation_enabled', 'no' ) ) {
$features = array_diff( $features, array( 'navigation' ) );
}
return $features;
}
/**
* Preload options to prime state of the application.
*
* @param array $options Array of options to preload.
* @return array
*/
public function preload_options( $options ) {
$options[] = 'woocommerce_navigation_enabled';
return $options;
}
}