Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 );
}
}
}