Skip to content

Commit

Permalink
Merge pull request #2165 from vektor-inc/develop
Browse files Browse the repository at this point in the history
[ Change version ] 1.81.0.0
  • Loading branch information
kurudrive authored Aug 8, 2024
2 parents 51b2f8d + 133115d commit 2d8daa9
Show file tree
Hide file tree
Showing 30 changed files with 2,722 additions and 5,494 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ module.exports = {
'react-hooks/exhaustive-deps': 'off',
'no-shadow': 'off',
'jsdoc/no-undefined-types': 'off',
'react-hooks/rules-of-hooks': 'off',
},
};
33 changes: 24 additions & 9 deletions editor-css/_editor_before_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,36 @@
.is-layout-constrained .vk_slider_item-background-area {
max-width: 100%; // コアが --wp--style--global--content-size つけてくるので打消し
}
.vk_slider.vk_swiper.alignwide,
.vk_slider.vk_swiper.alignfull {
.vk_slider.vk_swiper{
&.vk_slider_editorMode--default {//編集モードが編集の時
.vk_slider_item {
display: flex;
}
}
.vk_slider_item {
max-width:100%;
box-sizing: border-box;
//デバイス毎の高さに数字を入れ、その高さよりも大きいブロックが入った場合に編集画面ではみ出すので追加
overflow: hidden;
//編集画面ではswiper-slideのクラス名がついていない(クリックすると付与される)ので、swiper-slideと同じプロパティを追加
display: flex;
flex-direction: column;
// Lightning theme.json 有効時など コアが margin-block-start: 24px; つけてくるので打消し
.vk_slider_item-background-area,
.vk_slider_item_container{
margin-block-start: 0; // コアが margin-block-start: 24px; つけてくるので打消し
}
&.vk_slider_item-paddingLR-use,
&.vk_slider_item-paddingLR-zero{
.vk_slider_item_container{
max-width:100%;
.wp-block:where(:not(.is-layout-constrained)){
max-width:100%;
}
&.alignwide,
&.alignfull {
.vk_slider_item {
max-width:100%;
&.vk_slider_item-paddingLR-use,
&.vk_slider_item-paddingLR-zero{
.vk_slider_item_container{
max-width:100%;
.wp-block:where(:not(.is-layout-constrained)){
max-width:100%;
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions inc/vk-blocks/class-vk-blocks-block-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function add_styles() {
// 分割読み込みの場合は register されるファイルが false 指定で何も読み込まれなくなっている.
wp_enqueue_style( 'vk-blocks-build-css' );
wp_enqueue_style( 'vk-blocks-utils-common-css' );
wp_enqueue_style( 'vk-blocks/core-table', VK_BLOCKS_DIR_URL . 'build/extensions/core/table/style.css', array(), VK_BLOCKS_VERSION );
wp_enqueue_style( 'vk-blocks/core-heading', VK_BLOCKS_DIR_URL . 'build/extensions/core/heading/style.css', array(), VK_BLOCKS_VERSION );
wp_enqueue_style( 'vk-blocks/core-image', VK_BLOCKS_DIR_URL . 'build/extensions/core/image/style.css', array(), VK_BLOCKS_VERSION );
}

/**
Expand All @@ -118,6 +121,9 @@ public function register_blocks_assets() {
wp_register_style( 'vk-blocks-build-css', false, array(), VK_BLOCKS_VERSION );
// src/utils内の内の共通cssの読み込み .
wp_register_style( 'vk-blocks-utils-common-css', VK_BLOCKS_DIR_URL . 'build/utils/common.css', array(), VK_BLOCKS_VERSION );
wp_register_style( 'vk-blocks/core-table', VK_BLOCKS_DIR_URL . 'build/extensions/core/table/style.css', array(), VK_BLOCKS_VERSION );
wp_register_style( 'vk-blocks/core-heading', VK_BLOCKS_DIR_URL . 'build/extensions/core/heading/style.css', array(), VK_BLOCKS_VERSION );
wp_register_style( 'vk-blocks/core-image', VK_BLOCKS_DIR_URL . 'build/extensions/core/image/style.css', array(), VK_BLOCKS_VERSION );
} else {
// 一括読み込みの場合 : 結合CSSを登録.
wp_register_style( 'vk-blocks-build-css', VK_BLOCKS_DIR_URL . 'build/block-build.css', array(), VK_BLOCKS_VERSION );
Expand All @@ -133,6 +139,17 @@ public function register_blocks_assets() {
wp_add_inline_style( 'wp-edit-blocks', $dynamic_css );
}

// WordPress 6.5 以下の対策
if ( ! wp_script_is( 'react-jsx-runtime', 'registered' ) ) {
wp_register_script(
'react-jsx-runtime',
$this->assets_build_url . 'react-jsx-runtime.js',
array( 'react' ),
'18.3.1',
true
);
}

// 編集画面のjs登録 : 設定に関わらず結合JSを登録 -> 各ブロックのindex.phpから呼び出される.
wp_register_script(
'vk-blocks-build-js',
Expand Down
4 changes: 4 additions & 0 deletions inc/vk-blocks/class-vk-blocks-global-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ public static function block_style_lists() {
'name' => 'vk-image-rounded',
'label' => __( 'Rounded02', 'vk-blocks-pro' ),
),
array(
'name' => 'vk-image-circle',
'label' => __( 'Circle', 'vk-blocks-pro' ),
),
array(
'name' => 'vk-image-border',
'label' => __( 'Border', 'vk-blocks-pro' ),
Expand Down
1 change: 1 addition & 0 deletions inc/vk-blocks/images/circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 32 additions & 73 deletions inc/vk-blocks/view/class-vk-blocks-postlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class Vk_Blocks_PostList {
* @return string
*/
public static function render_post_list( $attributes, $wp_query, $options_loop ) {

if ( ! empty( $attributes['className'] ) ) {
$options_loop['class_loop_outer'] .= ' ' . $attributes['className'];
$options_loop['class_loop_outer'] .= ' ' . esc_attr( $attributes['className'] );
}

if ( ! isset( $wp_query ) || false === $wp_query || 'false' === $wp_query || empty( $wp_query->posts ) ) {
Expand All @@ -38,7 +39,7 @@ public static function render_post_list( $attributes, $wp_query, $options_loop )
'display_new' => esc_html( $attributes['display_new'] ),
'display_taxonomies' => esc_html( $attributes['display_taxonomies'] ),
'display_btn' => esc_html( $attributes['display_btn'] ),
'image_default_url' => VK_BLOCKS_URL . 'images/no-image.png',
'image_default_url' => esc_url( VK_BLOCKS_URL . 'images/no-image.png' ),
'overlay' => false,
'new_text' => esc_html( $attributes['new_text'] ),
'new_date' => esc_html( $attributes['new_date'] ),
Expand All @@ -54,16 +55,16 @@ public static function render_post_list( $attributes, $wp_query, $options_loop )
'class_title' => '',
'body_prepend' => '',
'body_append' => '',
'vkb_hidden' => isset( $attributes['vkb_hidden'] ) ? $attributes['vkb_hidden'] : '',
'vkb_hidden_xxl' => isset( $attributes['vkb_hidden_xxl'] ) ? $attributes['vkb_hidden_xxl'] : '',
'vkb_hidden_xl' => isset( $attributes['vkb_hidden_xl'] ) ? $attributes['vkb_hidden_xl'] : '',
'vkb_hidden_xl_v2' => isset( $attributes['vkb_hidden_xl_v2'] ) ? $attributes['vkb_hidden_xl_v2'] : '',
'vkb_hidden_lg' => isset( $attributes['vkb_hidden_lg'] ) ? $attributes['vkb_hidden_lg'] : '',
'vkb_hidden_md' => isset( $attributes['vkb_hidden_md'] ) ? $attributes['vkb_hidden_md'] : '',
'vkb_hidden_sm' => isset( $attributes['vkb_hidden_sm'] ) ? $attributes['vkb_hidden_sm'] : '',
'vkb_hidden_xs' => isset( $attributes['vkb_hidden_xs'] ) ? $attributes['vkb_hidden_xs'] : '',
'marginTop' => isset( $attributes['marginTop'] ) ? $attributes['marginTop'] : '',
'marginBottom' => isset( $attributes['marginBottom'] ) ? $attributes['marginBottom'] : '',
'vkb_hidden' => isset( $attributes['vkb_hidden'] ) ? esc_attr( $attributes['vkb_hidden'] ) : '',
'vkb_hidden_xxl' => isset( $attributes['vkb_hidden_xxl'] ) ? esc_attr( $attributes['vkb_hidden_xxl'] ) : '',
'vkb_hidden_xl' => isset( $attributes['vkb_hidden_xl'] ) ? esc_attr( $attributes['vkb_hidden_xl'] ) : '',
'vkb_hidden_xl_v2' => isset( $attributes['vkb_hidden_xl_v2'] ) ? esc_attr( $attributes['vkb_hidden_xl_v2'] ) : '',
'vkb_hidden_lg' => isset( $attributes['vkb_hidden_lg'] ) ? esc_attr( $attributes['vkb_hidden_lg'] ) : '',
'vkb_hidden_md' => isset( $attributes['vkb_hidden_md'] ) ? esc_attr( $attributes['vkb_hidden_md'] ) : '',
'vkb_hidden_sm' => isset( $attributes['vkb_hidden_sm'] ) ? esc_attr( $attributes['vkb_hidden_sm'] ) : '',
'vkb_hidden_xs' => isset( $attributes['vkb_hidden_xs'] ) ? esc_attr( $attributes['vkb_hidden_xs'] ) : '',
'marginTop' => isset( $attributes['marginTop'] ) ? esc_attr( $attributes['marginTop'] ) : '',
'marginBottom' => isset( $attributes['marginBottom'] ) ? esc_attr( $attributes['marginBottom'] ) : '',
);

$elm = VK_Component_Posts::get_loop( $wp_query, $options, $options_loop );
Expand Down Expand Up @@ -128,10 +129,10 @@ private static function format_terms( $tax_query_relation, $is_checked_terms, $p
* @return WP_Query|bool WP_Query object or false.
*/
public static function get_loop_query( $attributes ) {
$is_checked_post_type = json_decode( $attributes['isCheckedPostType'], true );

$is_checked_terms = json_decode( $attributes['isCheckedTerms'], true );
$tax_query_relation = isset( $attributes['taxQueryRelation'] ) ? $attributes['taxQueryRelation'] : 'OR';
$is_checked_post_type = json_decode( $attributes['isCheckedPostType'], true );
$is_checked_terms = json_decode( $attributes['isCheckedTerms'], true );
$tax_query_relation = isset( $attributes['taxQueryRelation'] ) ? $attributes['taxQueryRelation'] : 'OR';

if ( empty( $is_checked_post_type ) ) {
return false;
Expand Down Expand Up @@ -178,7 +179,6 @@ public static function get_loop_query( $attributes ) {
}

global $wp_query;
// とりあえず1を入れつつ2ページ目の情報があったら上書き
$paged = 1;
if ( ! empty( $attributes['pagedlock'] ) ) {
$paged = 1;
Expand All @@ -188,64 +188,23 @@ public static function get_loop_query( $attributes ) {
$paged = $wp_query->query_vars['paged'];
}

$all_posts = array();
$offset_count = 0;

foreach ( $is_checked_post_type as $post_type ) {
$args = array(
'post_type' => $post_type,
'paged' => 1,
'posts_per_page' => -1,
'order' => $attributes['order'],
'orderby' => $attributes['orderby'],
'post__not_in' => $post__not_in,
'date_query' => $date_query,
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'tax_query' => ! empty( $is_checked_terms ) ? self::format_terms( $tax_query_relation, $is_checked_terms, $post_type ) : array(),
);

if ( ! empty( $is_checked_terms ) ) {
$args['tax_query'] = self::format_terms( $tax_query_relation, $is_checked_terms, $post_type );
}

$temp_query = new WP_Query( $args );
$all_posts = array_merge( $all_posts, $temp_query->posts );
}

if ( 'rand' === $attributes['orderby'] ) {
shuffle( $all_posts );
} else {
usort(
$all_posts,
function ( $a, $b ) use ( $attributes ) {
if ( 'date' === $attributes['orderby'] ) {
if ( 'ASC' === $attributes['order'] ) {
return strtotime( $a->post_date ) - strtotime( $b->post_date );
} else {
return strtotime( $b->post_date ) - strtotime( $a->post_date );
}
} elseif ( 'modified' === $attributes['orderby'] ) {
if ( 'ASC' === $attributes['order'] ) {
return strtotime( $a->post_modified ) - strtotime( $b->post_modified );
} else {
return strtotime( $b->post_modified ) - strtotime( $a->post_modified );
}
} elseif ( 'title' === $attributes['orderby'] ) {
return strcmp( $a->post_title, $b->post_title ) * ( 'ASC' === $attributes['order'] ? 1 : -1 );
} else {
return 0;
}
}
);
}

$all_posts = array_slice( $all_posts, $offset, intval( $attributes['numberPosts'] ) );

$wp_query_combined = new WP_Query();
$wp_query_combined->posts = $all_posts;
$wp_query_combined->post_count = count( $all_posts );
$args = array(
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'tax_query' => ! empty( $is_checked_terms ) ? self::format_terms( $tax_query_relation, $is_checked_terms, $is_checked_post_type ) : array(),
'post_type' => $is_checked_post_type,
'paged' => $paged,
'posts_per_page' => intval( $attributes['numberPosts'] ),
'order' => $attributes['order'],
'orderby' => $attributes['orderby'],
'post__not_in' => array_map( 'intval', $post__not_in ),
'date_query' => $date_query,
'update_post_meta_cache' => false,
'no_found_rows' => true,
'offset' => $offset,
);

return $wp_query_combined;
// クエリ実行
return new WP_Query( $args );
}

/**
Expand Down
1 change: 1 addition & 0 deletions inc/vk-blocks/vk-blocks-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function vk_blocks_blocks_assets() {
$dynamic_css = '
:root {
--vk_flow-arrow: url(' . VK_BLOCKS_URL . 'images/arrow_bottom.svg);
--vk_image-mask-circle: url(' . VK_BLOCKS_URL . 'images/circle.svg);
--vk_image-mask-wave01: url(' . VK_BLOCKS_URL . 'images/wave01.svg);
--vk_image-mask-wave02: url(' . VK_BLOCKS_URL . 'images/wave02.svg);
--vk_image-mask-wave03: url(' . VK_BLOCKS_URL . 'images/wave03.svg);
Expand Down
17 changes: 11 additions & 6 deletions inc/vk-components/package/class-vk-component-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,14 @@ public static function get_loop( $wp_query, $options, $loop_options = array() )
$loop_outer_class_post_types = array();
if ( ! isset( $wp_query->query['post_type'] ) ) {
$loop_outer_class_post_types[] = 'vk_posts-postType-post';
} elseif ( is_array( $wp_query->query['post_type'] ) ) {
foreach ( $wp_query->query['post_type'] as $key => $value ) {
$loop_outer_class_post_types[] = 'vk_posts-postType-' . $value;
}
} else {
$loop_outer_class_post_types[] = 'vk_posts-postType-' . $wp_query->query['post_type'];
if ( is_array( $wp_query->query['post_type'] ) ) {
foreach ( $wp_query->query['post_type'] as $key => $value ) {
$loop_outer_class_post_types[] = 'vk_posts-postType-' . $value;
}
} else {
$loop_outer_class_post_types[] = 'vk_posts-postType-' . $wp_query->query['post_type'];
}
}

$loop_outer_class_post_types[] = 'vk_posts-layout-' . $options['layout'];
Expand Down Expand Up @@ -205,7 +207,7 @@ public static function get_loop( $wp_query, $options, $loop_options = array() )
$vk_posts_loop_item_count = 0;

while ( $wp_query->have_posts() ) {
++$vk_posts_loop_item_count;
$vk_posts_loop_item_count++;

$wp_query->the_post();
global $post;
Expand Down Expand Up @@ -719,8 +721,11 @@ public static function get_view_body( $post, $options ) {
} // foreach
$html .= '</div>';
}

}

$html .= apply_filters( 'vk_post_taxonomies_after', '' );

if ( $options['textlink'] ) {
if ( $options['display_btn'] ) {
$button_options = array(
Expand Down
Loading

0 comments on commit 2d8daa9

Please sign in to comment.