Skip to content

Commit ff75298

Browse files
committed
Update from vk-blocks-pro
1 parent cea643b commit ff75298

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+6805
-7674
lines changed

editor-css/_editor_before_tab.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
margin-bottom:0;
1414
}
1515
}
16-
.block-list-appender{
16+
// .vk_tab_bodys_body と隣接する .block-list-appender だけを対象にする
17+
.vk_tab_bodys_body.block-editor-block-list__block + .block-list-appender {
1718
position: absolute;
1819
top: calc( 1rem * -6 );
1920
right: calc( 1rem * 0 );

inc/vk-blocks/load-vk-components.php

+42-11
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,58 @@
88
use VektorInc\VK_Component\VK_Component_Posts;
99

1010
/**
11-
* Boostrapの読み込み
11+
* VK Components(Bootstrap) を読み込むべきか判定
1212
*
13-
* @param string $hook_suffix hook suffix.
13+
* @return bool 読み込む場合 true、読み込まない場合 false
1414
*/
15-
function vk_blocks_load_vk_components( $hook_suffix ) {
15+
function vk_blocks_should_load_vk_components() {
1616
$template = wp_get_theme()->Template;
17-
// lightning 系(ベクトル)の場合 vk-components はテーマなどで読み込むので必要ない
18-
if ( 'lightning' === $template || 'lightning-pro' === $template || 'katawara' === $template ) {
19-
return;
20-
}
17+
// lightning 系(ベクトル)の場合 vk-components はテーマなどで読み込むので適用しない
18+
$should_load = ! in_array( $template, array( 'lightning', 'lightning-pro', 'katawara' ), true );
19+
20+
return apply_filters( 'vk_blocks_should_load_vk_components', $should_load );
21+
}
22+
23+
// 条件に合わなければここで return することで、以降の処理を実行しない
24+
if ( ! vk_blocks_should_load_vk_components() ) {
25+
return;
26+
}
2127

28+
/**
29+
* VK Components(Bootstrap) の登録 & 読み込み
30+
*/
31+
function vk_blocks_register_vk_components_style() {
2232
VK_Component_Posts::register_style( 'vk-components-style' );
33+
}
34+
add_action( 'init', 'vk_blocks_register_vk_components_style' );
2335

24-
// 管理画面
36+
/**
37+
* VK Components(Bootstrap) を管理画面とフロントに適用
38+
*
39+
* @param string $hook_suffix hook suffix.
40+
*/
41+
function vk_blocks_enqueue_vk_components_style( $hook_suffix = '' ) {
2542
if ( is_admin() ) {
26-
if ( 'post.php' === $hook_suffix || 'post-new.php' === $hook_suffix ) {
43+
if ( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ), true ) ) {
2744
wp_enqueue_style( 'vk-components-style' );
2845
}
2946
} else {
3047
wp_enqueue_style( 'vk-components-style' );
3148
}
3249
}
33-
add_action( 'admin_enqueue_scripts', 'vk_blocks_load_vk_components' );
34-
add_action( 'wp_enqueue_scripts', 'vk_blocks_load_vk_components' );
50+
add_action( 'admin_enqueue_scripts', 'vk_blocks_enqueue_vk_components_style' );
51+
add_action( 'wp_enqueue_scripts', 'vk_blocks_enqueue_vk_components_style' );
52+
53+
/**
54+
* エディター用の VK Components(Bootstrap) を適用
55+
*/
56+
function vk_blocks_enqueue_vk_components_editor_style() {
57+
// スタイルが登録されていない場合は登録
58+
if ( ! wp_style_is( 'vk-components-style', 'registered' ) ) {
59+
VK_Component_Posts::register_style( 'vk-components-style' );
60+
}
61+
62+
// スタイルを適用
63+
wp_enqueue_style( 'vk-components-style' );
64+
}
65+
add_action( 'enqueue_block_assets', 'vk_blocks_enqueue_vk_components_editor_style' );

0 commit comments

Comments
 (0)