Skip to content

Commit

Permalink
Merge pull request #2018 from aristath/try/2009
Browse files Browse the repository at this point in the history
Gutenberg support
  • Loading branch information
aristath authored Nov 9, 2018
2 parents 87ee00e + 3755f25 commit da56423
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/css/class-kirki-modules-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 );
}

/**
Expand Down
14 changes: 14 additions & 0 deletions modules/css/class-kirki-output.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Expand Down
3 changes: 3 additions & 0 deletions modules/postmessage/class-kirki-modules-postmessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down
4 changes: 4 additions & 0 deletions modules/webfonts/class-kirki-modules-webfonts-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
1 change: 1 addition & 0 deletions modules/webfonts/class-kirki-modules-webfonts-local.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}

/**
Expand Down

0 comments on commit da56423

Please sign in to comment.