Skip to content

Commit

Permalink
Adding option to re-enable customizer and menu items when FSE is enab…
Browse files Browse the repository at this point in the history
…led.
  • Loading branch information
ronaldhuereca committed Feb 7, 2024
1 parent 7333e11 commit b53ea58
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/dlx-pw-preview.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-i18n', 'wp-plugins'), 'version' => '16a2bbd70a4a05074098');
<?php return array('dependencies' => array('react', 'wp-i18n', 'wp-plugins'), 'version' => 'c30059576042eea38880');
2 changes: 1 addition & 1 deletion build/dlx-pw-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ var PatternPreviewButton = function PatternPreviewButton() {
// Create the button.
var button = document.createElement('a');
button.className = 'dlx-button-preview components-button has-icon';
button.ariaLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Preview', 'futuris-demo-importer');
button.ariaLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Preview', 'dlx-pattern-wrangler');
button.href = dlxPatternWranglerPreview.previewUrl;
button.target = '_blank';
button.rel = 'noopener noreferrer';
Expand Down
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-i18n', 'wp-plugins'), 'version' => 'c12991944f7fcbcff0d1');
<?php return array('dependencies' => array('react', 'wp-i18n', 'wp-plugins'), 'version' => '9165383a9b85136eb360');
2 changes: 1 addition & 1 deletion build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var PatternPreviewButton = function PatternPreviewButton() {
// Create the button.
var button = document.createElement('a');
button.className = 'dlx-button-preview components-button has-icon';
button.ariaLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Preview', 'futuris-demo-importer');
button.ariaLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Preview', 'dlx-pattern-wrangler');
button.href = dlxPatternWranglerPreview.previewUrl;
button.target = '_blank';
button.rel = 'noopener noreferrer';
Expand Down
2 changes: 2 additions & 0 deletions php/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public static function get_defaults() {
'categories' => array(),
'allowFrontendPatternPreview' => true,
'hideUncategorizedPatterns' => false,
'showCustomizerUI' => true,
'showMenusUI' => true,
'loadCustomizerCSSBlockEditor' => false,
'loadCustomizerCSSFrontend' => true,
'licenseValid' => false,
Expand Down
19 changes: 19 additions & 0 deletions php/Patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ public function run() {
// Add a featured image to the wp_block post type column.
add_action( 'manage_wp_block_posts_custom_column', array( $this, 'add_featured_image_column_content' ), 10, 2 );

// Show the customizer UI if enabled.
$show_customizer_ui = (bool) $options['showCustomizerUI'];
if ( $show_customizer_ui ) {
add_action( 'customize_register', '__return_true' );
}

// Show the menu UI if enabled.
$show_menu_ui = (bool) $options['showMenusUI'];
if ( $show_menu_ui ) {
add_action( 'after_setup_theme', array( $this, 'enable_menus_ui' ), 100 );
}

$hide_all_patterns = (bool) $options['hideAllPatterns'];
if ( $hide_all_patterns ) {
add_action( 'init', array( $this, 'remove_core_patterns' ), 9 );
Expand All @@ -71,6 +83,13 @@ public function run() {
}
}

/**
* Enable menus UI.
*/
public function enable_menus_ui() {
add_theme_support( 'menus' );
}

/**
* Add featured image to wp_block post type column.
*
Expand Down
34 changes: 34 additions & 0 deletions src/js/react/views/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ const Interface = ( props ) => {
disablePatternImporterBlock: data.disablePatternImporterBlock,
allowFrontendPatternPreview: data.allowFrontendPatternPreview,
hideUncategorizedPatterns: data.hideUncategorizedPatterns,
showCustomizerUI: data.showCustomizerUI,
loadCustomizerCSSBlockEditor: data.loadCustomizerCSSBlockEditor,
loadCustomizerCSSFrontend: data.loadCustomizerCSSFrontend,
showMenusUI: data.showMenusUI,
categories: data.categories ?? [],
saveNonce: dlxPatternWranglerAdmin.saveNonce,
resetNonce: dlxPatternWranglerAdmin.resetNonce,
Expand Down Expand Up @@ -386,6 +388,22 @@ const Interface = ( props ) => {
{ __( 'Customizer', 'dlx-pattern-wrangler' ) }
</th>
<td>
<div className="dlx-admin__row">
<Controller
name="showCustomizerUI"
control={ control }
render={ ( { field: { onChange, value } } ) => (
<ToggleControl
label={ __( 'Show Customizer UI', 'dlx-pattern-wrangler' ) }
checked={ value }
onChange={ ( boolValue ) => {
onChange( boolValue );
} }
help={ __( 'This will show the customizer UI in the Appearance menu if enabled.', 'dlx-pattern-wrangler' ) }
/>
) }
/>
</div>
<div className="dlx-admin__row">
<Controller
name="loadCustomizerCSSBlockEditor"
Expand Down Expand Up @@ -425,6 +443,22 @@ const Interface = ( props ) => {
{ __( 'Miscellaneous', 'dlx-pattern-wrangler' ) }
</th>
<td>
<div className="dlx-admin__row">
<Controller
name="showMenusUI"
control={ control }
render={ ( { field: { onChange, value } } ) => (
<ToggleControl
label={ __( 'Show Menus UI', 'dlx-pattern-wrangler' ) }
checked={ value }
onChange={ ( boolValue ) => {
onChange( boolValue );
} }
help={ __( 'This will show the menus UI in the Appearance menu if enabled.', 'dlx-pattern-wrangler' ) }
/>
) }
/>
</div>
<div className="dlx-admin__row">
<Controller
name="disablePatternImporterBlock"
Expand Down

0 comments on commit b53ea58

Please sign in to comment.