diff --git a/modules/css/class-kirki-modules-css.php b/modules/css/class-kirki-modules-css.php index 94c33b5ff..1afb6ab37 100644 --- a/modules/css/class-kirki-modules-css.php +++ b/modules/css/class-kirki-modules-css.php @@ -139,6 +139,7 @@ public function init() { // If we're in the customizer, load inline no matter what. add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority ); + add_action( 'enqueue_block_editor_assets', array( $this, 'inline_dynamic_css' ), $priority ); // If we're using file method, on save write the new styles. if ( 'file' === $method ) { @@ -174,6 +175,9 @@ public function init() { // If we got this far then add styles inline. add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority ); + + // Admin styles, adds Gutenberg compatibility. + add_action( 'admin_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority ); } /** diff --git a/modules/css/class-kirki-output.php b/modules/css/class-kirki-output.php index e97f9bcf2..48fd21423 100644 --- a/modules/css/class-kirki-output.php +++ b/modules/css/class-kirki-output.php @@ -239,6 +239,20 @@ protected function parse_output() { } $value = $this->process_value( $value, $output ); + + // Set the context. + if ( ! isset( $output['context'] ) || empty( $output['context'] ) ) { + $output['context'] = array( 'front' ); + } + + // Check if this is an admin style. + if ( is_admin() && ! is_customize_preview() ) { + if ( ! in_array( 'editor', $output['context'] ) ) { + return; + } + } elseif ( ! in_array( 'front', $output['context'] ) ) { + return; + } $this->process_output( $output, $value ); } } diff --git a/modules/postmessage/class-kirki-modules-postmessage.php b/modules/postmessage/class-kirki-modules-postmessage.php index e58f3693a..9a3162867 100644 --- a/modules/postmessage/class-kirki-modules-postmessage.php +++ b/modules/postmessage/class-kirki-modules-postmessage.php @@ -97,6 +97,9 @@ protected function script( $args ) { if ( ! isset( $js_var['function'] ) || 'html' !== $js_var['function'] ) { $add_css = true; } + if ( isset( $js_var['context'] ) && ! in_array( 'front', $js_var['context'] ) ) { + $add_css = false; + } } if ( $add_css ) { diff --git a/modules/webfont-loader/class-kirki-modules-webfont-loader.php b/modules/webfont-loader/class-kirki-modules-webfont-loader.php index 4ea8183ea..4b227b45e 100644 --- a/modules/webfont-loader/class-kirki-modules-webfont-loader.php +++ b/modules/webfont-loader/class-kirki-modules-webfont-loader.php @@ -49,6 +49,7 @@ class Kirki_Modules_Webfont_Loader { */ protected function __construct() { add_action( 'wp_head', array( $this, 'enqueue_scripts' ), 20 ); + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 20 ); } /** diff --git a/modules/webfonts/class-kirki-modules-webfonts-async.php b/modules/webfonts/class-kirki-modules-webfonts-async.php index 2d077dc9f..ec7f624d7 100644 --- a/modules/webfonts/class-kirki-modules-webfonts-async.php +++ b/modules/webfonts/class-kirki-modules-webfonts-async.php @@ -69,6 +69,10 @@ public function __construct( $config_id, $webfonts, $googlefonts, $args = array( add_action( 'wp_head', array( $this, 'webfont_loader' ) ); add_action( 'wp_head', array( $this, 'webfont_loader_script' ), 30 ); + // Add these in the dashboard to support editor-styles. + add_action( 'admin_enqueue_scripts', array( $this, 'webfont_loader' ) ); + add_action( 'admin_enqueue_scripts', array( $this, 'webfont_loader_script' ), 30 ); + add_filter( 'wp_resource_hints', array( $this, 'resource_hints' ), 10, 2 ); } diff --git a/modules/webfonts/class-kirki-modules-webfonts-local.php b/modules/webfonts/class-kirki-modules-webfonts-local.php index 05a41b521..c7daa8168 100755 --- a/modules/webfonts/class-kirki-modules-webfonts-local.php +++ b/modules/webfonts/class-kirki-modules-webfonts-local.php @@ -65,6 +65,7 @@ public function __construct( $webfonts, $googlefonts ) { $this->googlefonts = $googlefonts; add_action( 'wp_footer', array( $this, 'add_styles' ) ); + add_action( 'admin_footer', array( $this, 'add_styles' ) ); } /**