From 2eb9875b607391c5b9e8ab23058c6a827223106f Mon Sep 17 00:00:00 2001 From: aristath Date: Fri, 9 Nov 2018 20:10:08 +0200 Subject: [PATCH] see #2009 --- modules/css/class-kirki-modules-css.php | 4 ++++ modules/css/class-kirki-output.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+) 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 ); } }