Skip to content

Commit

Permalink
[ Bug fix ] Fixed errors that occur on the site editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurudrive committed Jul 4, 2024
1 parent 0988c02 commit 7ddc514
Show file tree
Hide file tree
Showing 6 changed files with 735 additions and 725 deletions.
37 changes: 22 additions & 15 deletions patterns-data/class-register-patterns-from-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/**
* 生成先のテーマ・プラグインでブロックパターン情報を読み込んで登録
*
* @package VK Block Pattern Plugin Generator
* @package vektor-inc/vk-block-pattern-plugin-generator
* @version 0.8.8
*/

namespace wp_content\plugins\vk_block_patterns\patterns_data;
Expand All @@ -28,7 +29,7 @@ public function __construct() {
* @return string 最小化したCSSファイル
*/
public static function load_inline_css( $filename = 'style.css' ) {
$style_path = wp_normalize_path( dirname( __FILE__ ) . '/' . $filename );
$style_path = wp_normalize_path( __DIR__ . '/' . $filename );
$style_url = str_replace( wp_normalize_path( ABSPATH ), site_url() . '/', $style_path );
$dynamic_css = '';
if ( file_exists( $style_path ) ) {
Expand Down Expand Up @@ -77,7 +78,7 @@ public static function print_pattern_editor_css() {
public static function register_template() {

// これは読み込み側では存在しないクラスなので要対応.
$json_dir_path = wp_normalize_path( dirname( __FILE__ ) . '/' );
$json_dir_path = wp_normalize_path( __DIR__ . '/' );

if ( function_exists( 'register_block_pattern_category' ) && function_exists( 'register_block_pattern' ) ) {

Expand Down Expand Up @@ -168,29 +169,35 @@ public static function register_template() {
if ( in_array( $site_lang, (array) $val['languages'], true ) ) {
// 本来 $val['post_status'] は必ず必ず入ってくる。リリース前のデータ対応なので2021年3月以降削除可.
if ( ! isset( $val['post_status'] ) || 'publish' === $val['post_status'] ) {
$pattern_properties = array(
'title' => $val['title'],
'categories' => $val['categories'],
'content' => $val['content'],
);
if ( ! empty( $val['blockTypes'] ) ) {
$pattern_properties['blockTypes'] = $val['blockTypes'];
}
register_block_pattern(
$val['post_name'],
array(
'title' => $val['title'],
'categories' => $val['categories'],
'content' => $val['content'],
'blockTypes' => $val['blockTypes'],
)
$pattern_properties
);
}
}
} else {
// 英語のパターンのみ登録するモード.
if ( in_array( mb_strtolower( 'en_US' ), (array) $val['languages'], true ) ) {
if ( ! isset( $val['post_status'] ) || 'publish' === $val['post_status'] ) {
$pattern_properties = array(
'title' => $val['title'],
'categories' => $val['categories'],
'content' => $val['content'],
);
if ( ! empty( $val['blockTypes'] ) ) {
$pattern_properties['blockTypes'] = $val['blockTypes'];
}
register_block_pattern(
$val['post_name'],
array(
'title' => $val['title'],
'categories' => $val['categories'],
'content' => $val['content'],
'blockTypes' => $val['blockTypes'],
)
$pattern_properties
);
}
}
Expand Down
466 changes: 233 additions & 233 deletions patterns-data/template-all.json

Large diffs are not rendered by default.

Loading

0 comments on commit 7ddc514

Please sign in to comment.