Skip to content

Commit

Permalink
シルクスキンのWordPress5.8ブロックエディター対応
Browse files Browse the repository at this point in the history
  • Loading branch information
yhira committed Jul 22, 2021
1 parent bc5f75b commit 529ed0b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion skins/silk/functions.php
Expand Up @@ -182,6 +182,7 @@ private function __construct() {
add_filter('get_editor_key_color', [$this, 'editor_color']);
add_filter('block_editor_color_palette_colors', [$this, 'palette_colors']);
add_action('get_template_part_tmp/css-custom', [$this, 'css_custom']);
add_action('admin_print_styles', [$this, 'echo_block_css']);
add_action('cocoon_settings_after_save', [$this, 'delete_options']);
add_action('get_header', [$this, 'icon_settings']);
add_filter('menu_description_walker', [$this, 'navi_header']);
Expand Down Expand Up @@ -264,6 +265,16 @@ public function palette_colors($colors) {
return $colors;
}

public function echo_block_css() {
$current_screen = get_current_screen();
if ( ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) || ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) ) {
echo '<style>';
$this->css_custom();
echo '</style>'.PHP_EOL;
}

}

//カスタムCSS
public function css_custom() {
$color = get_site_key_color() ?: self::KEY_COLOR;
Expand Down Expand Up @@ -340,7 +351,7 @@ public function css_custom() {
//カラーパレット追加
$color_palette = get_cocoon_editor_color_palette_colors();
foreach ($color_palette as $editor_color) {
echo '.body .has-'.$editor_color['slug'].'-border-color .label-box-label,
echo 'html .body .has-'.$editor_color['slug'].'-border-color .label-box-label,
.wp-block-cover-image.has-'.$editor_color['slug'].'-background-color.has-background-dim,
.wp-block-cover.has-'.$editor_color['slug'].'-background-color.has-background-dim,
.has-'.$editor_color['slug'].'-background-color hr.is-style-cut-line::after,
Expand Down Expand Up @@ -839,6 +850,7 @@ public function blogcard_height($height) {
return THUMB320HEIGHT;
}


//エディター用JS・CSS
public function editor_assets() {
$file = str_ireplace('style.css', 'gutenberg.js', get_skin_url());
Expand Down Expand Up @@ -1111,3 +1123,4 @@ private function is_highlight() {
}

Skin_Silk_Functions::instance();

0 comments on commit 529ed0b

Please sign in to comment.