Skip to content

Commit

Permalink
First update: added condition if the option is enable or disabled. Ad…
Browse files Browse the repository at this point in the history
…ded add_actions for enqueue (#14)

* First update: added condition if the option is enable or disabled. Added add_actions for enqueue

* Removing the js integration

* Enqueue customize css

* Finalized the enable disable add the customize css

* Eslint fix

* Eslint fix

* Loading customizer in block editor using dummy CSS handle.

* Removing unneeded file.

* Fixing PHPCS.

---------

Co-authored-by: Mike Francis Miguel Abella DLX <[email protected]>
Co-authored-by: Ronald Huereca <[email protected]>
  • Loading branch information
3 people authored Feb 9, 2024
1 parent babbe75 commit 087dab0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/index.js.map

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions php/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Admin {
* Class runner.
*/
public function run() {

$options = Options::get_options();

// Init the admin menu.
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );

Expand Down Expand Up @@ -51,6 +54,10 @@ public function run() {

// Output synced vs. unsynced.
add_action( 'manage_wp_block_posts_custom_column', array( $this, 'output_pattern_sync_column' ), 10, 2 );

if ( (bool) $options['loadCustomizerCSSBlockEditor'] ) {
add_action( 'enqueue_block_assets', array( $this, 'enqueue_customizer_css_block_editor' ), PHP_INT_MAX );
}
}


Expand Down Expand Up @@ -555,4 +562,19 @@ public function admin_page() {
</div>
<?php
}

/**
* Enqueue customizer CSS for the block editor.
*/
public function enqueue_customizer_css_block_editor() {
$custom_css = wp_get_custom_css();
if ( ! empty( $custom_css ) ) {
wp_register_style(
'dlx-pw-customizer-css-block-editor',
false
);
wp_enqueue_style( 'dlx-pw-customizer-css-block-editor' );
wp_add_inline_style( 'dlx-pw-customizer-css-block-editor', $custom_css );
}
}
}

0 comments on commit 087dab0

Please sign in to comment.