Skip to content

Commit

Permalink
Merge branch 'develop' into feature/post-list/sticky-posts
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdkei authored Feb 18, 2025
2 parents f5e4cfd + 05f4feb commit 209b259
Show file tree
Hide file tree
Showing 28 changed files with 627 additions and 215 deletions.
53 changes: 42 additions & 11 deletions inc/vk-blocks/load-vk-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,58 @@
use VektorInc\VK_Component\VK_Component_Posts;

/**
* Boostrapの読み込み
* VK Components(Bootstrap) を読み込むべきか判定
*
* @param string $hook_suffix hook suffix.
* @return bool 読み込む場合 true、読み込まない場合 false
*/
function vk_blocks_load_vk_components( $hook_suffix ) {
function vk_blocks_should_load_vk_components() {
$template = wp_get_theme()->Template;
// lightning 系(ベクトル)の場合 vk-components はテーマなどで読み込むので必要ない
if ( 'lightning' === $template || 'lightning-pro' === $template || 'katawara' === $template ) {
return;
}
// lightning 系(ベクトル)の場合 vk-components はテーマなどで読み込むので適用しない
$should_load = ! in_array( $template, array( 'lightning', 'lightning-pro', 'katawara' ), true );

return apply_filters( 'vk_blocks_should_load_vk_components', $should_load );
}

// 条件に合わなければここで return することで、以降の処理を実行しない
if ( ! vk_blocks_should_load_vk_components() ) {
return;
}

/**
* VK Components(Bootstrap) の登録 & 読み込み
*/
function vk_blocks_register_vk_components_style() {
VK_Component_Posts::register_style( 'vk-components-style' );
}
add_action( 'init', 'vk_blocks_register_vk_components_style' );

// 管理画面
/**
* VK Components(Bootstrap) を管理画面とフロントに適用
*
* @param string $hook_suffix hook suffix.
*/
function vk_blocks_enqueue_vk_components_style( $hook_suffix = '' ) {
if ( is_admin() ) {
if ( 'post.php' === $hook_suffix || 'post-new.php' === $hook_suffix ) {
if ( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ), true ) ) {
wp_enqueue_style( 'vk-components-style' );
}
} else {
wp_enqueue_style( 'vk-components-style' );
}
}
add_action( 'admin_enqueue_scripts', 'vk_blocks_load_vk_components' );
add_action( 'wp_enqueue_scripts', 'vk_blocks_load_vk_components' );
add_action( 'admin_enqueue_scripts', 'vk_blocks_enqueue_vk_components_style' );
add_action( 'wp_enqueue_scripts', 'vk_blocks_enqueue_vk_components_style' );

/**
* エディター用の VK Components(Bootstrap) を適用
*/
function vk_blocks_enqueue_vk_components_editor_style() {
// スタイルが登録されていない場合は登録
if ( ! wp_style_is( 'vk-components-style', 'registered' ) ) {
VK_Component_Posts::register_style( 'vk-components-style' );
}

// スタイルを適用
wp_enqueue_style( 'vk-components-style' );
}
add_action( 'enqueue_block_assets', 'vk_blocks_enqueue_vk_components_editor_style' );
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ e.g.
== Changelog ==

[ Add function ][ Post List (Pro) / Post List Slider (Pro) ] Added the ability to set sticky posts to display.
[ Bug fix ] [ Icon ] Fixed an unwanted bottom margin appearing.
[ Add function ][ Grid Column Card (Pro) ] Added noreferrer and nofollow to the link feature.
[ Add function ][ Animation (Pro) / Fixed Display (Pro) / Outer (Pro) ] Added support for layout.allowJustification: false, allowing full-width/wide alignment in block themes where wrapped blocks previously did not appear as full-width or wide in the editor.
[ Add function ][ group ] Added noreferrer, nofollow, and link description options to the link feature.
[ Add function ][ Icon / Slider ] Added noreferrer, nofollow, and link description options to the link feature.
[ Add function ][ Slider ] Added noreferrer, nofollow, and link description options to the link feature.
[ Bug fix ][ Icon ] Fixed an unwanted bottom margin appearing.
[ Editor Design Bug Fix ] [ Grid Column (Pro) ] Fixed an issue where the 'is-vertical' layout of grid column items was not displayed vertically.
[ Specification change ] Fixed the zoom-out toggle not always displaying in the editor toolbar (updated blocks.json API version from 2 to 3).

= 1.95.0 =
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/_pro/accordion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const settings = {
},
{
name: 'vk_accordion-background-color-rounded',
label: __('Background color / Rounded ', 'vk-blocks-pro'),
label: __('Background color / Rounded', 'vk-blocks-pro'),
},
{
name: 'vk_accordion-background-color-rounded-border',
Expand Down
5 changes: 4 additions & 1 deletion src/blocks/_pro/animation/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"textdomain": "vk-blocks-pro",
"supports": {
"html": false,
"className": true
"className": true,
"layout": {
"allowJustification": false
}
}
}
2 changes: 1 addition & 1 deletion src/blocks/_pro/card-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default function CardItemEdit(props) {
value={excerpt_text} //eslint-disable-line camelcase
onChange={(value) => setAttributes({ excerpt_text: value })}
placeholder={__(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'vk-blocks-pro'
)}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/blocks/_pro/fixed-display/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
"html": false,
"className": true,
"anchor": true,
"layout": {
"allowJustification": false
},
"color": {
"gradients": true,
"link": true,
Expand Down
7 changes: 6 additions & 1 deletion src/blocks/_pro/gridcolcard-item/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@
"type": "string"
},
"url": {
"type": "string"
"type": "string",
"default": ""
},
"urlOpenType": {
"type": "boolean",
"default": false
},
"relAttribute": {
"type": "string",
"default": ""
}
}
}
109 changes: 109 additions & 0 deletions src/blocks/_pro/gridcolcard-item/deprecated/1.95.0/save.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import { isHexColor } from '@vkblocks/utils/is-hex-color';
import { isGradientStyle } from '@vkblocks/utils/is-gradient-style';

import classnames from 'classnames';

export default function save(props) {
const { attributes } = props;
const {
backgroundColor,
textColor,
headerDisplay,
footerDisplay,
containerSpace,
borderRadius,
border,
borderColor,
borderWidth,
backgroundGradient,
url,
urlOpenType,
} = attributes;

// カラーパレットに対応
const containerClasses = classnames('vk_gridcolcard_item', {
[`vk_gridcolcard_item-noHeader`]: headerDisplay === 'delete',
[`vk_gridcolcard_item-noFooter`]: footerDisplay === 'delete',
[`has-background`]: !!backgroundColor,
[`has-border-color`]: !!border,
[`has-${backgroundColor}-background-color`]:
!!backgroundColor && !isHexColor(backgroundColor),
[`has-${backgroundGradient}-gradient-background`]:
!!backgroundGradient && !isGradientStyle(backgroundGradient),
[`has-${borderColor}-border-color`]:
!!border && !!borderColor && !isHexColor(borderColor),
});

const innerClasses = classnames('vk_gridcolcard_item_container', {
[`has-text-color`]: !!textColor,
[`has-${textColor}-color`]: !!textColor && !isHexColor(textColor),
});

const style = {
backgroundColor: null,
border: null,
};
if (borderRadius) {
style.borderRadius = `${borderRadius}`;
}

// 背景色
if (backgroundColor && isHexColor(backgroundColor)) {
// custom color
style.backgroundColor = `${backgroundColor}`;
}

// 背景グラデーション
if (backgroundGradient && isGradientStyle(backgroundGradient)) {
// custom color
style.background = `${backgroundGradient}`;
}

// 線の色と太さ
if (border) {
style.borderWidth = borderWidth;
if (isHexColor(borderColor)) {
// custom color
style.borderColor = `${borderColor}`;
}
}

// 文字色
const textColorCustom =
textColor && isHexColor(textColor) ? textColor : null;

const blockProps = useBlockProps.save({
className: classnames(containerClasses, {
'vk_gridcolcard_item-noHeader': headerDisplay === 'delete',
'vk_gridcolcard_item-noFooter': footerDisplay === 'delete',
[`vk_gridcolcard_item-header-${headerDisplay}`]:
headerDisplay !== 'delete',
[`vk_gridcolcard_item-footer-${footerDisplay}`]:
footerDisplay !== 'delete',
}),
style,
});

const TagName = url ? 'a' : 'div';

return (
<div {...blockProps}>
<TagName
className={innerClasses}
style={{
paddingTop: containerSpace.top,
paddingBottom: containerSpace.bottom,
paddingLeft: containerSpace.left,
paddingRight: containerSpace.right,
color: textColorCustom,
}}
href={url}
target={urlOpenType ? '_blank' : undefined}
rel={urlOpenType ? 'noopener noreferrer' : undefined}
>
<InnerBlocks.Content />
</TagName>
</div>
);
}
38 changes: 36 additions & 2 deletions src/blocks/_pro/gridcolcard-item/deprecated/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import save1_38_0 from './1.38.0/save';
import save1_71_0 from './1.71.0/save';
import save1_87_0 from './1.87.0/save';
import save1_95_0 from './1.95.0/save';

const blockAttributes = {
editLock: {
Expand Down Expand Up @@ -63,12 +64,45 @@ const blockAttributes = {
const blockAttributes2 = {
...blockAttributes,
borderWidth: {
type: 'number',
default: 1,
type: 'string',
default: '1px',
},
};

// 1.87.0 からの変更で追加したもの
const blockAttributes3 = {
...blockAttributes2,
headerDisplay: {
type: 'string',
default: 'display'
},
footerDisplay: {
type: 'string',
default: 'display'
},
};

/* 次回対応おねがいします
const blockAttributes4 = {
...blockAttributes3,
relAttribute: {
"type": "string",
"default": ""
}
};
*/

const deprecated = [
{
attributes: blockAttributes3,
save: save1_95_0,
migrate: (attributes) => {
return {
...attributes,
relAttribute: ''
};
},
},
{
attributes: blockAttributes2,
save: save1_87_0,
Expand Down
Loading

0 comments on commit 209b259

Please sign in to comment.