Ver3.0 ๐จ Gutenberg ๋ธ๋ก ์๋ํฐ ๋ง์คํฐํ๊ธฐ

๐จ Gutenberg ๋ธ๋ก ์๋ํฐ ๋ง์คํฐํ๊ธฐ
๐ ๊ตฌํ ๋ฒ ๋ฅดํฌ, ๋ ๋๊ตฌ๋?
์๋ํ๋ ์ค๋ฅผ ์ฌ์ฉํ๋ค ๋ณด๋ฉด "๊ตฌํ
๋ฒ ๋ฅดํฌ"๋ผ๋ ์ด๋ฆ์ ํ ๋ฒ์ฏค์ ๋ค์ด๋ดค์ ๊ฑฐ์ผ. 2018๋
์๋ํ๋ ์ค 5.0 ๋ฒ์ ๊ณผ ํจ๊ป ๋ฑ์ฅํ ์ด ๋
์์ ๊ธฐ์กด์ ํด๋์ ์๋ํฐ๋ฅผ ์์ ํ ๋ค์ง์ด๋์ ํ๋ช
์ ์ธ ๋ณํ์์ด. ๐
๊ตฌํ
๋ฒ ๋ฅดํฌ๋ ๋
์ผ์ ์ธ์์ ๋ฐ๋ช
๊ฐ ์ํ๋ค์ค ๊ตฌํ
๋ฒ ๋ฅดํฌ์ ์ด๋ฆ์์ ๋ฐ์จ ๊ฑด๋ฐ, ๊ทธ๋งํผ "์ฝํ
์ธ ์ ์์ ํ๋ช
"์ ์๋ฏธํ๋ค๊ณ ๋ณผ ์ ์์ง. ๊ธฐ์กด์๋ ํ
์คํธ ์๋ํฐ์์ HTML ์ฝ๋๋ฅผ ์ง์ ๋ง์ง๊ฑฐ๋ ๋ณต์กํ ์์ฝ๋๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค๋ฉด, ์ด์ ๋ ๋ธ๋ก ๋จ์๋ก ๋๋๊ทธ ์ค ๋๋กญํ๋ฉด์ ์ง๊ด์ ์ผ๋ก ํ์ด์ง๋ฅผ ๋ง๋ค ์ ์๊ฒ ๋์ด.
๋ธ๋ก ์๋ํฐ์ ํต์ฌ ์ฒ ํ์ ๊ฐ๋จํด. "๋ชจ๋ ๊ฒ์ ๋ธ๋ก์ด๋ค(Everything is a Block)". ๋ฌธ๋จ๋ ๋ธ๋ก, ์ด๋ฏธ์ง๋ ๋ธ๋ก, ๋ฒํผ๋ ๋ธ๋ก, ์ฌ์ง์ด ์ ์ฒด ๋ ์ด์์๊น์ง๋ ๋ธ๋ก์ผ๋ก ๊ตฌ์ฑ๋ผ. ๋ ๊ณ ๋ธ๋ก ์กฐ๋ฆฝํ๋ฏ์ด ์นํ์ด์ง๋ฅผ ๋ง๋ค ์ ์๋ค๋ ๊ฑฐ์ง! ๐งฑ
๐ ๏ธ ๊ฐ๋ฐ ํ๊ฒฝ ์ธํ ํ๊ธฐ
์ปค์คํ
๋ธ๋ก ๊ฐ๋ฐ์ ์์ํ๊ธฐ ์ ์ ๋จผ์ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ ๋๋ก ๊ฐ์ถฐ์ผ ํด. ์๋ฆฌ๋ฅผ ํ๋ ค๋ฉด ์ฃผ๋ฐฉ ๋๊ตฌ๊ฐ ํ์ํ๋ฏ์ด ๋ง์ด์ผ! ๐ณ
๊ตฌํ
๋ฒ ๋ฅดํฌ ๋ธ๋ก์ ๊ธฐ๋ณธ์ ์ผ๋ก React์ JavaScript(ES6+)๋ฅผ ์ฌ์ฉํด์ ๋ง๋ค์ด์ ธ. ๊ทธ๋์ ๋ชจ๋ JavaScript ๊ฐ๋ฐ ํ๊ฒฝ์ด ํ์์ผ. ๊ฑฑ์ ํ์ง ๋ง, ์๋ํ๋ ์ค ํ์ด ์ด๋ฏธ ํ๋ฅญํ ๋๊ตฌ๋ค์ ์ค๋นํด๋๊ฑฐ๋ !
Node.js์ npm ์ค์น
Node.js๋ JavaScript ๋ฐํ์ ํ๊ฒฝ์ด๊ณ , npm์ ํจํค์ง ๋งค๋์ ์ผ. ์ด ๋์ ๋ชจ๋ ์น ๊ฐ๋ฐ์ ํ์ ๋๊ตฌ์ง.
๊ณต์ ์ฌ์ดํธ(nodejs.org)์์ LTS ๋ฒ์ ์ ๋ค์ด๋ก๋ํด์ ์ค์นํ๋ฉด ๋ผ. ์ค์น๊ฐ ์๋ฃ๋๋ฉด ํฐ๋ฏธ๋์์ ๋ฒ์ ์ ํ์ธํด๋ณด์:
node --version
npm --version
๋ฒ์ ๋ฒํธ๊ฐ ์ ๋๋ก ๋์ค๋ฉด ์ฑ๊ณต! ๐
@wordpress/create-block ์ค์น
์๋ํ๋ ์ค ํ์ด ๋ง๋ ๊ณต์ ๋ธ๋ก ์์ฑ ๋๊ตฌ์ผ. ์ด ๋
์์ ์ฌ์ฉํ๋ฉด ๋ณต์กํ ์ค์ ์์ด ๋ฐ๋ก ๋ธ๋ก ๊ฐ๋ฐ์ ์์ํ ์ ์์ด.
์ ์ญ์ผ๋ก ์ค์นํ ํ์ ์์ด npx๋ฅผ ์ฌ์ฉํด์ ๋ฐ๋ก ์คํํ ์ ์์ด:
npx @wordpress/create-block my-first-block
์ด ๋ช ๋ น์ด๋ฅผ ์คํํ๋ฉด my-first-block์ด๋ผ๋ ํด๋๊ฐ ์์ฑ๋๊ณ , ๊ทธ ์์ ๋ธ๋ก ๊ฐ๋ฐ์ ํ์ํ ๋ชจ๋ ํ์ผ๊ณผ ์ค์ ์ด ์๋์ผ๋ก ๋ง๋ค์ด์ ธ. ์ ๋ง ํธ๋ฆฌํ์ง? ๐
๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ถ
์๋ํ๋ ์ค๋ฅผ ๋ก์ปฌ์์ ์คํํ ์ ์๋ ํ๊ฒฝ์ด ํ์ํด. ์ฌ๋ฌ ์ต์
์ด ์๋๋ฐ, ๊ฐ์ฅ ์ธ๊ธฐ ์๋ ๊ฒ๋ค์:
โข Local by Flywheel: ๊ฐ์ฅ ์ฝ๊ณ ์ง๊ด์ ์ธ GUI ๊ธฐ๋ฐ ๋๊ตฌ
โข XAMPP/MAMP: ์ ํต์ ์ธ ๋ฐฉ์์ ๋ก์ปฌ ์๋ฒ
โข Docker: ์ปจํ
์ด๋ ๊ธฐ๋ฐ์ผ๋ก ๋ ์ ์ฐํ ํ๊ฒฝ ๊ตฌ์ฑ
โข @wordpress/env: ์๋ํ๋ ์ค ๊ณต์ Docker ๊ธฐ๋ฐ ๊ฐ๋ฐ ํ๊ฒฝ
๊ฐ์ธ์ ์ผ๋ก๋ @wordpress/env๋ฅผ ์ถ์ฒํด. ์ค์ ์ด ๊ฐ๋จํ๊ณ ์๋ํ๋ ์ค ์ฝ์ด ๊ฐ๋ฐํ์ด ์ง์ ๊ด๋ฆฌํ๊ฑฐ๋ .
npm -g install @wordpress/env
wp-env start
๐ฆ ๋ธ๋ก์ ๊ตฌ์กฐ ์ดํดํ๊ธฐ
์ปค์คํ
๋ธ๋ก์ ๋ง๋ค๊ธฐ ์ ์ ๋ธ๋ก์ด ์ด๋ป๊ฒ ๊ตฌ์ฑ๋๋์ง ์ดํดํ๋ ๊ฒ ์ค์ํด. ๋ธ๋ก์ ํฌ๊ฒ ์ธ ๊ฐ์ง ์ฃผ์ ๋ถ๋ถ์ผ๋ก ๋๋์ด:
1. ๋ธ๋ก ๋ฑ๋ก (Registration)
2. ํธ์ง ์ธํฐํ์ด์ค (Edit)
3. ์ ์ฅ๋ ์ฝํ
์ธ (Save)
โข description: ๋ธ๋ก์ ๋ํ ๊ฐ๋จํ ์ค๋ช
โข category: ๋ธ๋ก์ด ์ํ ์นดํ ๊ณ ๋ฆฌ (text, media, design, widgets, theme, embed)
โข icon: ๋ธ๋ก์ ๋ํ๋ด๋ ์์ด์ฝ
โข attributes: ๋ธ๋ก์ด ์ ์ฅํ ๋ฐ์ดํฐ์ ๊ตฌ์กฐ
โข supports: ๋ธ๋ก์ด ์ง์ํ๋ ๊ธฐ๋ฅ๋ค (์ ๋ ฌ, ์์, ํ์ดํฌ๊ทธ๋ํผ ๋ฑ)
โข edit: ์๋ํฐ์์ ๋ณด์ฌ์ง ์ปดํฌ๋ํธ
โข save: ํ๋ก ํธ์๋์ ์ ์ฅ๋ HTML ๊ตฌ์กฐ
๊ธฐ๋ณธ ๋ธ๋ก ์ฝ๋ ๊ตฌ์กฐ
๊ฐ์ฅ ๊ฐ๋จํ ํํ์ ๋ธ๋ก ์ฝ๋๋ฅผ ์ดํด๋ณด์. ์ด๊ฑด "Hello World" ์์ค์ ๋ธ๋ก์ด์ผ:
import { registerBlockType } from '@wordpress/blocks';
import { useBlockProps } from '@wordpress/block-editor';
registerBlockType('my-plugin/hello-block', {
title: '์๋
๋ธ๋ก',
description: '๊ฐ๋จํ ์ธ์ฌ๋ง ๋ธ๋ก์
๋๋ค',
category: 'text',
icon: 'smiley',
attributes: {
message: {
type: 'string',
default: '์๋
ํ์ธ์!'
}
},
edit: (props) => {
const blockProps = useBlockProps();
const { attributes, setAttributes } = props;
return (
<div {...blockProps}>
<input
type="text"
value={attributes.message}
onChange={(e) => setAttributes({ message: e.target.value })}
/>
</div>
);
},
save: (props) => {
const blockProps = useBlockProps.save();
return (
<div {...blockProps}>
<p>{props.attributes.message}</p>
</div>
);
}
});
์ด ์ฝ๋๋ฅผ ๋ณด๋ฉด ๋ธ๋ก์ ๊ธฐ๋ณธ ๊ตฌ์กฐ๊ฐ ํ๋์ ๋ค์ด์ค์ง? ๐
edit ํจ์๋ ์๋ํฐ ํ๋ฉด์์ ์คํ๋๊ณ , save ํจ์๋ ์ค์ ์น์ฌ์ดํธ์ ํ์๋ HTML์ ์์ฑํด. attributes๋ ๋ธ๋ก์ด ์ ์ฅํ ๋ฐ์ดํฐ๋ฅผ ์ ์ํ๋ ๊ฑฐ๊ณ !
๐จ ๊ณ ๊ธ ๋ธ๋ก ๊ธฐ๋ฅ ๊ตฌํํ๊ธฐ
๊ธฐ๋ณธ ๋ธ๋ก์ ๋ง๋ค ์ ์๊ฒ ๋๋ค๋ฉด, ์ด์ ์ข ๋ ๋ฉ์ง ๊ธฐ๋ฅ๋ค์ ์ถ๊ฐํด๋ณผ ์ฐจ๋ก์ผ! ๊ตฌํ ๋ฒ ๋ฅดํฌ๋ ์ ๋ง ๋ค์ํ ์ปดํฌ๋ํธ์ API๋ฅผ ์ ๊ณตํ๊ฑฐ๋ . ๐
1. InspectorControls - ์ฌ์ด๋๋ฐ ์ค์ ํจ๋
๋ธ๋ก์ ์ ํํ์ ๋ ์ค๋ฅธ์ชฝ์ ๋ํ๋๋ ์ค์ ํจ๋์ ๋ณธ ์ ์์ง? ๋ฐ๋ก InspectorControls๋ฅผ ์ฌ์ฉํด์ ๋ง๋๋ ๊ฑฐ์ผ. ์ฌ๊ธฐ์ ์์ ์ ํ, ํฌ๊ธฐ ์กฐ์ , ์คํ์ผ ์ต์ ๋ฑ์ ๋ฃ์ ์ ์์ด.
import { InspectorControls } from '@wordpress/block-editor';
import { PanelBody, RangeControl, ColorPalette } from '@wordpress/components';
edit: (props) => {
const { attributes, setAttributes } = props;
const blockProps = useBlockProps();
return (
<>
<InspectorControls>
<PanelBody title="์คํ์ผ ์ค์ ">
<RangeControl
label="๊ธ์ ํฌ๊ธฐ"
value={attributes.fontSize}
onChange={(value) => setAttributes({ fontSize: value })}
min={12}
max={72}
/>
<ColorPalette
label="ํ
์คํธ ์์"
value={attributes.textColor}
onChange={(color) => setAttributes({ textColor: color })}
/>
</PanelBody>
</InspectorControls>
<div {...blockProps}>
{/* ๋ธ๋ก ์ฝํ
์ธ */}
</div>
</>
);
}
2. RichText - ํ๋ถํ ํ ์คํธ ํธ์ง
์ผ๋ฐ input์ด๋ textarea ๋์ RichText ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ๋ฉด ๋ณผ๋, ์ดํค๋ฆญ, ๋งํฌ ๋ฑ์ ์์์ ์ง์ํ๋ ํ ์คํธ ํธ์ง๊ธฐ๋ฅผ ๋ง๋ค ์ ์์ด. ์๋ํ๋ ์ค์ ๊ธฐ๋ณธ ๋ฌธ๋จ ๋ธ๋ก๋ ์ด๊ฑธ ์ฌ์ฉํ์ง.
import { RichText } from '@wordpress/block-editor';
edit: (props) => {
const { attributes, setAttributes } = props;
const blockProps = useBlockProps();
return (
<div {...blockProps}>
<RichText
tagName="h2"
value={attributes.heading}
onChange={(value) => setAttributes({ heading: value })}
placeholder="์ ๋ชฉ์ ์
๋ ฅํ์ธ์..."
allowedFormats={['core/bold', 'core/italic', 'core/link']}
/>
</div>
);
},
save: (props) => {
const blockProps = useBlockProps.save();
return (
<div {...blockProps}>
<RichText.Content
tagName="h2"
value={props.attributes.heading}
/>
</div>
);
}
allowedFormats ์์ฑ์ผ๋ก ํ์ฉํ ์์์ ์ ํํ ์ ์์ด. ์ฌ์ฉ์๊ฐ ๋๋ฌด ๋ณต์กํ ์์์ ์ฌ์ฉํ์ง ๋ชปํ๊ฒ ๋ง๊ณ ์ถ์ ๋ ์ ์ฉํ์ง! ๐ฏ
3. MediaUpload - ์ด๋ฏธ์ง/๋ฏธ๋์ด ์ ํ
์ด๋ฏธ์ง๋ ๋์์์ ๋ธ๋ก์ ์ถ๊ฐํ๊ณ ์ถ๋ค๋ฉด? MediaUpload ์ปดํฌ๋ํธ๊ฐ ๋ต์ด์ผ!
import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
import { Button } from '@wordpress/components';
edit: (props) => {
const { attributes, setAttributes } = props;
const blockProps = useBlockProps();
return (
<div {...blockProps}>
<MediaUploadCheck>
<MediaUpload
onSelect={(media) => setAttributes({
imageUrl: media.url,
imageId: media.id
})}
allowedTypes={['image']}
value={attributes.imageId}
render={({ open }) => (
<Button onClick={open} variant="primary">
{attributes.imageUrl ? '์ด๋ฏธ์ง ๋ณ๊ฒฝ' : '์ด๋ฏธ์ง ์ ํ'}
</Button>
)}
/>
</MediaUploadCheck>
{attributes.imageUrl && (
<img src={attributes.imageUrl} alt="" />
)}
</div>
);
}
4. InnerBlocks - ์ค์ฒฉ ๋ธ๋ก ์ง์
๋ธ๋ก ์์ ๋ค๋ฅธ ๋ธ๋ก์ ๋ฃ์ ์ ์๊ฒ ํ๊ณ ์ถ๋ค๋ฉด? InnerBlocks๋ฅผ ์ฌ์ฉํ๋ฉด ๋ผ! ์ปจํ ์ด๋ ๋ธ๋ก์ด๋ ๋ ์ด์์ ๋ธ๋ก์ ๋ง๋ค ๋ ํ์์ ์ด์ผ.
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
const ALLOWED_BLOCKS = ['core/paragraph', 'core/heading', 'core/image'];
const TEMPLATE = [
['core/heading', { placeholder: '์ ๋ชฉ์ ์
๋ ฅํ์ธ์...' }],
['core/paragraph', { placeholder: '๋ด์ฉ์ ์
๋ ฅํ์ธ์...' }]
];
edit: () => {
const blockProps = useBlockProps();
return (
<div {...blockProps}>
<InnerBlocks
allowedBlocks={ALLOWED_BLOCKS}
template={TEMPLATE}
templateLock={false}
/>
</div>
);
},
save: () => {
const blockProps = useBlockProps.save();
return (
<div {...blockProps}>
<InnerBlocks.Content />
</div>
);
}
allowedBlocks๋ก ํ์ฉํ ๋ธ๋ก์ ์ ํํ๊ณ , template๋ก ์ด๊ธฐ ๊ตฌ์กฐ๋ฅผ ์ ์ํ ์ ์์ด. templateLock์ true๋ก ์ค์ ํ๋ฉด ์ฌ์ฉ์๊ฐ ๋ธ๋ก์ ์ถ๊ฐํ๊ฑฐ๋ ์ ๊ฑฐํ ์ ์๊ฒ ๋ง๋ค ์๋ ์์ง! ๐
โก ๋์ ๋ธ๋ก vs ์ ์ ๋ธ๋ก
๋ธ๋ก์ ๋ง๋ค ๋ ์ค์ํ ์ ํ์ด ํ๋ ์์ด. ๋ฐ๋ก "์ ์ ์ผ๋ก ์ ์ฅํ ๊ฒ์ธ๊ฐ, ๋์ ์ผ๋ก ๋ ๋๋งํ ๊ฒ์ธ๊ฐ"์ผ. ๊ฐ๊ฐ ์ฅ๋จ์ ์ด ์๊ฑฐ๋ ! ๐ค
| ๊ตฌ๋ถ | ์ ์ ๋ธ๋ก (Static) | ๋์ ๋ธ๋ก (Dynamic) |
|---|---|---|
| ์ ์ฅ ๋ฐฉ์ | HTML์ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์ฅ | ์์ฑ๋ง ์ ์ฅ, ๋ ๋๋ง์ PHP๋ก |
| ์ฑ๋ฅ | ๋น ๋ฆ (๋ฏธ๋ฆฌ ์์ฑ๋ HTML) | ์ฝ๊ฐ ๋๋ฆผ (๋งค๋ฒ ์์ฑ) |
| ์ ์ฐ์ฑ | ๋ฎ์ (์ ์ฅ๋ HTML ๊ณ ์ ) | ๋์ (์ค์๊ฐ ๋ฐ์ดํฐ ๋ฐ์) |
| ์ ๋ฐ์ดํธ | ์ด๋ ค์ (๋ชจ๋ ๋ธ๋ก ์ฌ์ ์ฅ ํ์) | ์ฌ์ (PHP ์ฝ๋๋ง ์์ ) |
| ์ฌ์ฉ ์์ | ๋จ์ ์ฝํ ์ธ , ๊ณ ์ ๋ ์ด์์ | ์ต์ ๊ธ ๋ชฉ๋ก, ์ฌ์ฉ์ ์ ๋ณด |
๋์ ๋ธ๋ก ๋ง๋ค๊ธฐ
๋์ ๋ธ๋ก์ ๋ง๋ค๋ ค๋ฉด save ํจ์๋ฅผ null๋ก ์ค์ ํ๊ณ , PHP์์ ๋ ๋๋ง ์ฝ๋ฐฑ์ ๋ฑ๋กํด์ผ ํด.
// JavaScript (block.js)
registerBlockType('my-plugin/dynamic-block', {
title: '๋์ ๋ธ๋ก',
category: 'widgets',
attributes: {
numberOfPosts: {
type: 'number',
default: 5
}
},
edit: (props) => {
// ์๋ํฐ UI
},
save: () => {
return null; // ๋์ ๋ธ๋ก์ save๋ฅผ null๋ก!
}
});
// PHP (block.php)
function render_dynamic_block($attributes) {
$posts = get_posts([
'numberposts' => $attributes['numberOfPosts']
]);
$output = '<div class="dynamic-block">';
foreach ($posts as $post) {
$output .= '<h3>' . esc_html($post->post_title) . '</h3>';
}
$output .= '</div>';
return $output;
}
register_block_type('my-plugin/dynamic-block', [
'render_callback' => 'render_dynamic_block'
]);
โข ์ฌ์ฉ์๋ณ๋ก ๋ค๋ฅธ ์ฝํ ์ธ ๋ฅผ ๋ณด์ฌ์ค ๋: ๋ก๊ทธ์ธ ์ํ, ๊ถํ์ ๋ฐ๋ฅธ ํ์
โข ์ธ๋ถ API ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ฌ ๋: ๋ ์จ, ์ฃผ์, ์์ ๋ฏธ๋์ด ํผ๋ ๋ฑ
โข ์ค์๊ฐ ์ ๋ณด๊ฐ ํ์ํ ๋: ํ์ฌ ์๊ฐ, ์นด์ดํธ๋ค์ด, ์ฌ๊ณ ์๋ ๋ฑ
๋ฐ๋๋ก ๋จ์ํ ์คํ์ผ๋ง๋ ์ฝํ ์ธ ๋ฅผ ๋ณด์ฌ์ฃผ๋ ๊ฑฐ๋ผ๋ฉด ์ ์ ๋ธ๋ก์ด ๋ ํจ์จ์ ์ด์ผ!
๐ญ ๋ธ๋ก ์คํ์ผ๊ณผ ๋ณํ(Variations)
๊ฐ์ ๋ธ๋ก์ด์ง๋ง ๋ค์ํ ์คํ์ผ์ด๋ ๋ ์ด์์์ ์ ๊ณตํ๊ณ ์ถ์ ๋๊ฐ ์์ง? ๋ธ๋ก ์คํ์ผ๊ณผ ๋ณํ ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ฉด ๋ผ! ๐จ
๋ธ๋ก ์คํ์ผ (Block Styles)
๋ธ๋ก ์คํ์ผ์ ๊ฐ์ ๋ธ๋ก์ ๋ค๋ฅธ CSS ํด๋์ค๋ฅผ ์ ์ฉํด์ ๋ค์ํ ๋ชจ์ต์ ๋ง๋๋ ๊ฑฐ์ผ. ์๋ฅผ ๋ค์ด ๋ฒํผ ๋ธ๋ก์ "๋ฅ๊ทผ ๋ฒํผ", "๊ฐ์ง ๋ฒํผ", "๊ทธ๋ฆผ์ ๋ฒํผ" ๊ฐ์ ์คํ์ผ์ ์ ๊ณตํ ์ ์์ง.
// ๋ธ๋ก ์คํ์ผ ๋ฑ๋ก
wp.blocks.registerBlockStyle('core/button', {
name: 'rounded-button',
label: '๋ฅ๊ทผ ๋ฒํผ',
isDefault: false
});
wp.blocks.registerBlockStyle('core/button', {
name: 'shadow-button',
label: '๊ทธ๋ฆผ์ ๋ฒํผ'
});
// CSS์์ ์คํ์ผ ์ ์
.wp-block-button.is-style-rounded-button .wp-block-button__link {
border-radius: 50px;
padding: 15px 40px;
}
.wp-block-button.is-style-shadow-button .wp-block-button__link {
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}
๋ธ๋ก ๋ณํ (Block Variations)
๋ณํ์ ์คํ์ผ๋ณด๋ค ๋ ๊ฐ๋ ฅํด. ์์ฑ๊ฐ์ด ๋ค๋ฅธ ์ฌ๋ฌ ๋ฒ์ ์ ๋ธ๋ก์ ๋ฏธ๋ฆฌ ์ ์ํ ์ ์๊ฑฐ๋ . ์๋ฅผ ๋ค์ด "2๋จ ๋ ์ด์์", "3๋จ ๋ ์ด์์", "์ฌ์ด๋๋ฐ ๋ ์ด์์" ๊ฐ์ ๊ฑธ ๋ง๋ค ์ ์์ด.
wp.blocks.registerBlockVariation('core/columns', {
name: 'three-columns-equal',
title: '3๋จ ๊ท ๋ฑ ๋ ์ด์์',
description: '๋์ผํ ๋๋น์ 3๊ฐ ์ปฌ๋ผ',
icon: 'columns',
attributes: {
columns: 3
},
innerBlocks: [
['core/column'],
['core/column'],
['core/column']
],
scope: ['block']
});
๋ณํ์ ์ฌ์ฉํ๋ฉด ์ฌ์ฉ์๊ฐ ๋ธ๋ก์ ์ฝ์ ํ ๋ ์ฌ๋ฌ ์ต์ ์ค์์ ์ ํํ ์ ์๊ฒ ๋ผ. ํจ์ฌ ํธ๋ฆฌํ์ง! ๐
๐ง ๋ธ๋ก ๊ฐ๋ฐ ๋ฒ ์คํธ ํ๋ํฐ์ค
์ด์ ๋ธ๋ก์ ๋ง๋ค ์ ์๊ฒ ๋๋ค๋ฉด, ๋ ๋์ ๋ธ๋ก์ ๋ง๋ค๊ธฐ ์ํ ํ๋ค์ ์์๋ณด์! ์ค์ ์์ ์ ๋ง ์ ์ฉํ ๊ฒ๋ค์ด์ผ. ๐ช
1. ์์ฑ(Attributes) ์ค๊ณ ์์น
โข ๊ธฐ๋ณธ๊ฐ ์ ๊ณต: default ๊ฐ์ ํญ์ ์ค์ ํด์ undefined ์๋ฌ ๋ฐฉ์ง
โข ์๋ฏธ ์๋ ์ด๋ฆ: imageUrl๋ณด๋ค๋ featuredImageUrl์ฒ๋ผ ๊ตฌ์ฒด์ ์ผ๋ก
โข ์ค์ฒฉ ์ต์ํ: ๋๋ฌด ๊น์ ๊ฐ์ฒด ๊ตฌ์กฐ๋ ํผํ๊ธฐ
โข ๋ฒ์ ๊ด๋ฆฌ: ์์ฑ ๊ตฌ์กฐ๊ฐ ๋ฐ๋ ๋๋ฅผ ๋๋นํ ๋ง์ด๊ทธ๋ ์ด์ ๊ณํ
// ๋์ ์ โ
attributes: {
data: {
type: 'object'
}
}
// ์ข์ ์ โ
attributes: {
title: {
type: 'string',
default: ''
},
imageUrl: {
type: 'string',
default: ''
},
imageId: {
type: 'number',
default: 0
},
showCaption: {
type: 'boolean',
default: true
}
}
2. ์ฑ๋ฅ ์ต์ ํ
๋ธ๋ก์ด ๋ง์์ง๋ฉด ์๋ํฐ๊ฐ ๋๋ ค์ง ์ ์์ด. ์ฑ๋ฅ์ ๊ณ ๋ คํ ๊ฐ๋ฐ์ด ์ค์ํ์ง! โก
โข ๋ฌด๊ฑฐ์ด ์ฐ์ฐ์ useMemo๋ก: ๋ถํ์ํ ์ฌ๊ณ์ฐ ๋ฐฉ์ง
โข ๋๋ฐ์ด์ฑ ํ์ฉ: ์ฌ์ฉ์ ์ ๋ ฅ์ ์ฆ์ ๋ฐ์ํ์ง ๋ง๊ณ ์ฝ๊ฐ์ ์ง์ฐ ์ถ๊ฐ
โข ์ด๋ฏธ์ง ์ต์ ํ: ์ธ๋ค์ผ ์ฌ์ฉ, lazy loading ์ ์ฉ
โข ์กฐ๊ฑด๋ถ ๋ ๋๋ง: ํ์ํ ๋๋ง ์ปดํฌ๋ํธ ๋ ๋๋ง
import { useMemo } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { debounce } from '@wordpress/compose';
edit: (props) => {
const { attributes, setAttributes } = props;
// ๋ฌด๊ฑฐ์ด ๊ณ์ฐ์ useMemo๋ก
const processedData = useMemo(() => {
return expensiveCalculation(attributes.data);
}, [attributes.data]);
// ๋๋ฐ์ด์ฑ๋ ์
๋ฐ์ดํธ ํจ์
const debouncedUpdate = useMemo(
() => debounce((value) => {
setAttributes({ searchTerm: value });
}, 500),
[]
);
// ํ์ํ ๋ฐ์ดํฐ๋ง ์ ํ
const posts = useSelect((select) => {
return select('core').getEntityRecords('postType', 'post', {
per_page: 5,
_fields: ['id', 'title', 'excerpt'] // ํ์ํ ํ๋๋ง
});
}, []);
return (
// JSX
);
}
3. ์ ๊ทผ์ฑ(Accessibility) ๊ณ ๋ ค
๋ชจ๋ ์ฌ์ฉ์๊ฐ ๋ธ๋ก์ ์ฌ์ฉํ ์ ์์ด์ผ ํด. ์ ๊ทผ์ฑ์ ์ ํ์ด ์๋๋ผ ํ์์ผ! โฟ
// ์๋งจํฑ HTML ์ฌ์ฉ
<nav aria-label="๋ฉ์ธ ๋ค๋น๊ฒ์ด์
">
<ul>
<li><a href="#">ํ</a></li>
</ul>
</nav>
// ํค๋ณด๋ ๋ค๋น๊ฒ์ด์
์ง์
<button
onClick={handleClick}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
handleClick();
}
}}
aria-label="์ด๋ฏธ์ง ์
๋ก๋"
>
์
๋ก๋
</button>
// ์คํฌ๋ฆฐ ๋ฆฌ๋๋ฅผ ์ํ ์ค๋ช
<img
src={imageUrl}
alt={imageAlt || '์ฅ์์ฉ ์ด๋ฏธ์ง'}
role={imageAlt ? 'img' : 'presentation'}
/>
4. ์๋ฌ ์ฒ๋ฆฌ์ ํด๋ฐฑ
๋ญ๊ฐ ์๋ชป๋์ ๋๋ฅผ ๋๋นํ ์์ ์ฅ์น๊ฐ ํ์ํด. ์ฌ์ฉ์์๊ฒ ์น์ ํ ์๋ฌ ๋ฉ์์ง๋ฅผ ๋ณด์ฌ์ฃผ์! ๐ก๏ธ
import { Placeholder, Spinner } from '@wordpress/components';
edit: (props) => {
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
fetchData()
.then(data => {
setAttributes({ data });
setIsLoading(false);
})
.catch(err => {
setError(err.message);
setIsLoading(false);
});
}, []);
if (isLoading) {
return (
<Placeholder>
<Spinner />
<p>๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค๋ ์ค...</p>
</Placeholder>
);
}
if (error) {
return (
<Placeholder icon="warning">
<p>์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {error}</p>
<Button onClick={retry}>๋ค์ ์๋</Button>
</Placeholder>
);
}
return (
// ์ ์ ๋ ๋๋ง
);
}
5. ๋ธ๋ก ๊ฒ์ฆ(Validation)
๋ธ๋ก์ HTML ๊ตฌ์กฐ๊ฐ ๋ณ๊ฒฝ๋๋ฉด ์๋ํ๋ ์ค๊ฐ "์ด ๋ธ๋ก์ ์์์น ๋ชปํ ๋๋ ์๋ชป๋ ์ฝํ ์ธ ๊ฐ ํฌํจ๋์ด ์์ต๋๋ค"๋ผ๋ ๊ฒฝ๊ณ ๋ฅผ ๋ณด์ฌ์ค. ์ด๊ฑธ ๋ฐฉ์งํ๋ ค๋ฉด ์ ์ ํ ๊ฒ์ฆ ์ ๋ต์ด ํ์ํด.
// deprecated ์์ฑ์ผ๋ก ์ด์ ๋ฒ์ ์ง์
deprecated: [
{
attributes: {
// ์ด์ ๋ฒ์ ์ ์์ฑ
},
save: (props) => {
// ์ด์ ๋ฒ์ ์ save ํจ์
},
migrate: (attributes) => {
// ์ ๋ฒ์ ์ผ๋ก ๋ง์ด๊ทธ๋ ์ด์
return {
...attributes,
newAttribute: attributes.oldAttribute
};
}
}
]
๐ ์ค์ ํ๋ก์ ํธ: ๊ณ ๊ธ ์นด๋ ๋ธ๋ก ๋ง๋ค๊ธฐ
์ด๋ก ์ ์ถฉ๋ถํ ๋ฐฐ์ ์ผ๋, ์ด์ ์ค์ ํ๋ก์ ํธ๋ฅผ ํด๋ณด์! ์ด๋ฏธ์ง, ์ ๋ชฉ, ์ค๋ช , ๋ฒํผ์ด ์๋ ๋ฉ์ง ์นด๋ ๋ธ๋ก์ ๋ง๋ค์ด๋ณผ ๊ฑฐ์ผ. ์ค๋ฌด์์ ์ ๋ง ์์ฃผ ์ฌ์ฉํ๋ ํจํด์ด๊ฑฐ๋ ! ๐ฏ
ํ๋ก์ ํธ ์๊ตฌ์ฌํญ
โข ์ ๋ชฉ๊ณผ ์ค๋ช ํ ์คํธ (RichText)
โข ๋ฒํผ ํ ์คํธ์ ๋งํฌ
โข ์นด๋ ์ ๋ ฌ ์ต์ (์ผ์ชฝ, ๊ฐ์ด๋ฐ, ์ค๋ฅธ์ชฝ)
โข ๋ฐฐ๊ฒฝ์๊ณผ ํ ์คํธ ์์ ์ปค์คํฐ๋ง์ด์ง
โข ๊ทธ๋ฆผ์ ํจ๊ณผ on/off
โข ๋ฐ์ํ ๋์์ธ
์์ฑ๋ ์ฝ๋
import { registerBlockType } from '@wordpress/blocks';
import {
useBlockProps,
RichText,
MediaUpload,
InspectorControls,
BlockControls,
AlignmentToolbar
} from '@wordpress/block-editor';
import {
PanelBody,
Button,
ToggleControl,
ColorPalette
} from '@wordpress/components';
registerBlockType('my-plugin/advanced-card', {
title: '๊ณ ๊ธ ์นด๋',
description: '์ด๋ฏธ์ง, ํ
์คํธ, ๋ฒํผ์ด ์๋ ์นด๋ ๋ธ๋ก',
category: 'design',
icon: 'id-alt',
attributes: {
imageUrl: { type: 'string', default: '' },
imageId: { type: 'number', default: 0 },
title: { type: 'string', default: '' },
description: { type: 'string', default: '' },
buttonText: { type: 'string', default: '๋ ์์๋ณด๊ธฐ' },
buttonUrl: { type: 'string', default: '#' },
alignment: { type: 'string', default: 'left' },
backgroundColor: { type: 'string', default: '#ffffff' },
textColor: { type: 'string', default: '#333333' },
hasShadow: { type: 'boolean', default: true }
},
edit: (props) => {
const { attributes, setAttributes } = props;
const blockProps = useBlockProps({
style: {
backgroundColor: attributes.backgroundColor,
color: attributes.textColor,
boxShadow: attributes.hasShadow ?
'0 4px 6px rgba(0,0,0,0.1)' : 'none',
textAlign: attributes.alignment
}
});
return (
<>
<InspectorControls>
<PanelBody title="์คํ์ผ ์ค์ ">
<p><strong>๋ฐฐ๊ฒฝ์</strong></p>
<ColorPalette
value={attributes.backgroundColor}
onChange={(color) =>
setAttributes({ backgroundColor: color })
}
/>
<p><strong>ํ
์คํธ ์์</strong></p>
<ColorPalette
value={attributes.textColor}
onChange={(color) =>
setAttributes({ textColor: color })
}
/>
<ToggleControl
label="๊ทธ๋ฆผ์ ํจ๊ณผ"
checked={attributes.hasShadow}
onChange={(value) =>
setAttributes({ hasShadow: value })
}
/>
</PanelBody>
<PanelBody title="๋ฒํผ ์ค์ ">
<input
type="text"
placeholder="๋ฒํผ URL"
value={attributes.buttonUrl}
onChange={(e) =>
setAttributes({ buttonUrl: e.target.value })
}
/>
</PanelBody>
</InspectorControls>
<BlockControls>
<AlignmentToolbar
value={attributes.alignment}
onChange={(alignment) =>
setAttributes({ alignment })
}
/>
</BlockControls>
<div {...blockProps}>
<MediaUpload
onSelect={(media) => setAttributes({
imageUrl: media.url,
imageId: media.id
})}
allowedTypes={['image']}
value={attributes.imageId}
render={({ open }) => (
attributes.imageUrl ? (
<img
src={attributes.imageUrl}
alt=""
onClick={open}
style={{ cursor: 'pointer' }}
/>
) : (
<Button onClick={open} variant="primary">
์ด๋ฏธ์ง ์ ํ
</Button>
)
)}
/>
<RichText
tagName="h3"
value={attributes.title}
onChange={(value) => setAttributes({ title: value })}
placeholder="์นด๋ ์ ๋ชฉ..."
/>
<RichText
tagName="p"
value={attributes.description}
onChange={(value) =>
setAttributes({ description: value })
}
placeholder="์นด๋ ์ค๋ช
..."
/>
<RichText
tagName="a"
value={attributes.buttonText}
onChange={(value) =>
setAttributes({ buttonText: value })
}
placeholder="๋ฒํผ ํ
์คํธ..."
className="card-button"
/>
</div>
</>
);
},
save: (props) => {
const { attributes } = props;
const blockProps = useBlockProps.save({
style: {
backgroundColor: attributes.backgroundColor,
color: attributes.textColor,
boxShadow: attributes.hasShadow ?
'0 4px 6px rgba(0,0,0,0.1)' : 'none',
textAlign: attributes.alignment
}
});
return (
<div {...blockProps}>
{attributes.imageUrl && (
<img src={attributes.imageUrl} alt="" />
)}
<RichText.Content
tagName="h3"
value={attributes.title}
/>
<RichText.Content
tagName="p"
value={attributes.description}
/>
<a
href={attributes.buttonUrl}
className="card-button"
>
{attributes.buttonText}
</a>
</div>
);
}
});
์ด ์ฝ๋๋ ์ค๋ฌด์์ ๋ฐ๋ก ์ฌ์ฉํ ์ ์๋ ์์ค์ด์ผ! InspectorControls๋ก ์ธ๋ฐํ ์ค์ ์ ์ ๊ณตํ๊ณ , BlockControls๋ก ๋น ๋ฅธ ์ ๋ ฌ ๋ณ๊ฒฝ์ ์ง์ํ๋ฉฐ, ๋ชจ๋ ์ฝํ ์ธ ๊ฐ RichText๋ก ํธ์ง ๊ฐ๋ฅํ์ง. ๐
โข ํธ๋ฒ ํจ๊ณผ ์ถ๊ฐ: ๋ง์ฐ์ค๋ฅผ ์ฌ๋ ธ์ ๋ ์ ๋๋ฉ์ด์
โข ๋ ์ด์์ ๋ณํ: ์ด๋ฏธ์ง ์์น ๋ณ๊ฒฝ (์, ์ผ์ชฝ, ์ค๋ฅธ์ชฝ)
โข ์์ด์ฝ ์ง์: ์ ๋ชฉ ์์ ์์ด์ฝ ์ถ๊ฐ
โข ๋ค์ค ๋ฒํผ: ์ฌ๋ฌ ๊ฐ์ ๋ฒํผ ์ง์
โข ์ ๋๋ฉ์ด์ ํจ๊ณผ: ์คํฌ๋กค ์ ๋ํ๋๋ ํจ๊ณผ
๐ ๋ธ๋ก ๋ฐฐํฌ์ ๊ณต์
๋ฉ์ง ๋ธ๋ก์ ๋ง๋ค์๋ค๋ฉด ์ด์ ๋ค๋ฅธ ์ฌ๋๋ค๊ณผ ๊ณต์ ํ ์ฐจ๋ก์ผ! ์ฌ๋ฌ ๊ฐ์ง ๋ฐฉ๋ฒ์ด ์์ด. ๐
1. ํ๋ฌ๊ทธ์ธ์ผ๋ก ํจํค์ง
๊ฐ์ฅ ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ์ ์๋ํ๋ ์ค ํ๋ฌ๊ทธ์ธ์ผ๋ก ๋ง๋๋ ๊ฑฐ์ผ. ๊ธฐ๋ณธ ๊ตฌ์กฐ๋ ์ด๋ ๊ฒ ์๊ฒผ์ด:
my-blocks-plugin/
โโโ my-blocks-plugin.php (๋ฉ์ธ ํ๋ฌ๊ทธ์ธ ํ์ผ)
โโโ build/
โ โโโ index.js (๋น๋๋ JavaScript)
โ โโโ index.css (๋น๋๋ CSS)
โโโ src/
โ โโโ index.js (์์ค JavaScript)
โ โโโ style.scss (์์ค SCSS)
โโโ package.json
๋ฉ์ธ ํ๋ฌ๊ทธ์ธ ํ์ผ์์ ๋ธ๋ก์ ๋ฑ๋กํ๊ณ ์์ ์ ๋ก๋ํด:
<?php
/**
* Plugin Name: My Custom Blocks
* Description: ์ปค์คํ
๊ตฌํ
๋ฒ ๋ฅดํฌ ๋ธ๋ก ๋ชจ์
* Version: 1.0.0
* Author: Your Name
*/
function my_blocks_register() {
register_block_type(__DIR__ . '/build');
}
add_action('init', 'my_blocks_register');
2. WordPress.org์ ๋ฑ๋ก
๊ณต์ ์๋ํ๋ ์ค ํ๋ฌ๊ทธ์ธ ๋๋ ํ ๋ฆฌ์ ๋ฑ๋กํ๋ฉด ์ ์ธ๊ณ ์ฌ์ฉ์๋ค์ด ์ฝ๊ฒ ์ค์นํ ์ ์์ด. ๋ฌด๋ฃ๋ก ํธ์คํ ๋ ์ ๊ณตํ๊ณ ! ๐
2๋จ๊ณ: ํ๋ฌ๊ทธ์ธ ์ ์ถ ์์ ์์ฑ
3๋จ๊ณ: ์ฝ๋ ๋ฆฌ๋ทฐ ๋๊ธฐ (๋ณดํต 2์ฃผ ์ ๋)
4๋จ๊ณ: SVN ์ ์ฅ์์ ์ฝ๋ ์ ๋ก๋
5๋จ๊ณ: ์น์ธ ํ ๊ณต๊ฐ! ๐
์ฃผ์์ฌํญ: ์ฝ๋ ํ์ง ๊ธฐ์ค์ด ์๊ฒฉํด. ๋ณด์, ์ฑ๋ฅ, ์ ๊ทผ์ฑ์ ๋ชจ๋ ๊ณ ๋ คํด์ผ ํด!
3. GitHub์์ ๊ณต์
์คํ์์ค๋ก ๊ณต์ ํ๊ณ ์ถ๋ค๋ฉด GitHub์ด ์ต๊ณ ์ผ. ๋ค๋ฅธ ๊ฐ๋ฐ์๋ค์ด ๊ธฐ์ฌํ ์๋ ์๊ณ , ์ด์ ํธ๋ํน๋ ํธ๋ฆฌํ์ง.
# README.md ์์
# ๐จ My Custom Blocks
์๋ํ๋ ์ค ๊ตฌํ
๋ฒ ๋ฅดํฌ์ฉ ์ปค์คํ
๋ธ๋ก ๋ชจ์์
๋๋ค.
## ์ค์น ๋ฐฉ๋ฒ
1. ์ด ์ ์ฅ์๋ฅผ ํด๋ก ํฉ๋๋ค
2. `npm install` ์คํ
3. `npm run build` ์คํ
4. ํ๋ฌ๊ทธ์ธ ํด๋๋ฅผ ์๋ํ๋ ์ค์ ์
๋ก๋
## ํฌํจ๋ ๋ธ๋ก
- ๊ณ ๊ธ ์นด๋ ๋ธ๋ก
- ํ์๋ผ์ธ ๋ธ๋ก
- ๊ฐ๊ฒฉํ ๋ธ๋ก
## ๋ผ์ด์ ์ค
GPL v2 or later
4. ์ฌ๋ฅ๋ท์์ ํ๋งคํ๊ธฐ
์์
์ ์ผ๋ก ํ๋งคํ๊ณ ์ถ๋ค๋ฉด? ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์ ํ์ฉํ ์ ์์ด! ์ปค์คํ
๋ธ๋ก ๊ฐ๋ฐ ์๋น์ค๋ฅผ ๋ฑ๋กํ๊ฑฐ๋, ํ๋ฆฌ๋ฏธ์ ๋ธ๋ก ํจํค์ง๋ฅผ ํ๋งคํ๋ ๊ฑฐ์ง. ๐ฐ
ํนํ ํน์ ์ฐ์
์ด๋ ๋์น ๋ง์ผ์ ์ํ ์ ๋ฌธ ๋ธ๋ก์ ๋์ ๊ฐ์น๋ฅผ ์ธ์ ๋ฐ์ ์ ์์ด. ์๋ฅผ ๋ค์ด ๋ถ๋์ฐ ์ฌ์ดํธ์ฉ ๋งค๋ฌผ ์นด๋ ๋ธ๋ก, ๋ ์คํ ๋์ฉ ๋ฉ๋ด ๋ธ๋ก, ์ด๋ฒคํธ ์ฌ์ดํธ์ฉ ์ผ์ ๋ธ๋ก ๊ฐ์ ๊ฑฐ ๋ง์ด์ผ!
๐ฎ ๊ตฌํ ๋ฒ ๋ฅดํฌ์ ๋ฏธ๋
๊ตฌํ ๋ฒ ๋ฅดํฌ๋ ๊ณ์ ์งํํ๊ณ ์์ด. ์์ผ๋ก ์ด๋ค ๋ณํ๊ฐ ์ฌ์ง ์ดํด๋ณด์! ๐
ํ ์ฌ์ดํธ ์๋ํ (Full Site Editing)
์ด๋ฏธ ์์๋ ๋ณํ์ผ. ์ด์ ๋ธ๋ก์ผ๋ก ํค๋, ํธํฐ, ์ฌ์ด๋๋ฐ๊น์ง ๋ชจ๋ ํธ์งํ ์ ์์ด. ํ
๋ง ํ์ผ์ ์ง์ ์์ ํ ํ์๊ฐ ์์ด์ง๋ ๊ฑฐ์ง!
๋ธ๋ก ํ
๋ง(Block Theme)๊ฐ ํ์ค์ด ๋๋ฉด์, ๊ฐ๋ฐ์๋ค์ PHP ํ
ํ๋ฆฟ ๋์ HTML ๋ธ๋ก ํ
ํ๋ฆฟ์ ๋ง๋ค๊ฒ ๋ ๊ฑฐ์ผ. ์ด๋ฏธ Twenty Twenty-Two, Twenty Twenty-Three ๊ฐ์ ๊ณต์ ํ
๋ง๋ค์ด ์ด ๋ฐฉ์์ ์ฌ์ฉํ๊ณ ์์ด.
๋ธ๋ก ๋ฐ์ธ๋ฉ (Block Bindings)
๋ธ๋ก์ ์ปค์คํ ํ๋๋ ์ธ๋ถ ๋ฐ์ดํฐ ์์ค์ ์ฐ๊ฒฐํ๋ ๊ธฐ๋ฅ์ด์ผ. ์๋ฅผ ๋ค์ด ์ ํ ๊ฐ๊ฒฉ ๋ธ๋ก์ WooCommerce ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ง์ ์ฐ๊ฒฐํ ์ ์๊ฒ ๋๋ ๊ฑฐ์ง. ๐
ํ์ ๊ธฐ๋ฅ ๊ฐํ
์ค์๊ฐ ํ์ ํธ์ง, ๋ฒ์ ๊ด๋ฆฌ, ๋๊ธ ๊ธฐ๋ฅ ๋ฑ์ด ์ถ๊ฐ๋ ์์ ์ด์ผ. Google Docs์ฒ๋ผ ์ฌ๋ฌ ์ฌ๋์ด ๋์์ ํธ์งํ ์ ์๊ฒ ๋๋ ๊ฑฐ์ง!
AI ํตํฉ
AI๊ฐ ๋ธ๋ก ์ฝํ ์ธ ๋ฅผ ์๋ ์์ฑํ๊ฑฐ๋, ๋์์ธ์ ์ ์ํ๊ฑฐ๋, ์ด๋ฏธ์ง๋ฅผ ์ต์ ํํ๋ ๊ธฐ๋ฅ๋ค์ด ์ถ๊ฐ๋ ๊ฑฐ์ผ. ์ด๋ฏธ ์ผ๋ถ ํ๋ฌ๊ทธ์ธ๋ค์ด ์ด๋ฐ ๊ธฐ๋ฅ์ ์ ๊ณตํ๊ณ ์์ด. ๐ค
โข WordPress Data Store ์ดํด: Redux ๊ธฐ๋ฐ์ ๋ฐ์ดํฐ ๊ด๋ฆฌ
โข REST API ํ์ฉ: ์ธ๋ถ ๋ฐ์ดํฐ ํตํฉ
โข ์ ๊ทผ์ฑ ํ์ค ์ค์: WCAG ๊ฐ์ด๋๋ผ์ธ
โข ์ฑ๋ฅ ์ต์ ํ ๊ธฐ์ : ์ฝ๋ ์คํ๋ฆฌํ , ๋ ์ด์ง ๋ก๋ฉ
โข ํ ์คํธ ์์ฑ: Jest, Testing Library
๐ฌ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์! ์ฌ๊ธฐ๊น์ง ์ฝ์๋ค๋ฉด ์ ๋ง ๋๋จํด! ๐
๊ตฌํ
๋ฒ ๋ฅดํฌ ๋ธ๋ก ๊ฐ๋ฐ์ ์ฒ์์ ๋ณต์กํด ๋ณด์ด์ง๋ง, ๊ธฐ๋ณธ ๊ฐ๋
์ ์ดํดํ๊ณ ๋๋ฉด ์ ๋ง ๊ฐ๋ ฅํ ๋๊ตฌ์ผ. React ๊ธฐ๋ฐ์ด๋ผ ๋ชจ๋ ์น ๊ฐ๋ฐ ํธ๋ ๋์๋ ์ ๋ง๊ณ , ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค ์ ์์ด์ ์์ฐ์ฑ์ด ์์ฒญ๋๊ฒ ๋์์ง๊ฑฐ๋ .
๊ธฐ์ตํด์ผ ํ ํต์ฌ ํฌ์ธํธ๋ค์ ์ ๋ฆฌํด๋ณผ๊ฒ:
2. ์์ฑ ์ค๊ณ: ๋ช ํํ ํ์ , ๊ธฐ๋ณธ๊ฐ, ์๋ฏธ ์๋ ์ด๋ฆ
3. ์ปดํฌ๋ํธ ํ์ฉ: InspectorControls, RichText, MediaUpload, InnerBlocks
4. ๋์ vs ์ ์ : ์ํฉ์ ๋ง๋ ๋ ๋๋ง ๋ฐฉ์ ์ ํ
5. ์ฑ๋ฅ ์ต์ ํ: useMemo, useSelect, ๋๋ฐ์ด์ฑ
6. ์ ๊ทผ์ฑ: ์๋งจํฑ HTML, ARIA ์์ฑ, ํค๋ณด๋ ๋ค๋น๊ฒ์ด์
7. ์๋ฌ ์ฒ๋ฆฌ: ํด๋ฐฑ UI, ์น์ ํ ๋ฉ์์ง
8. ๋ฒ์ ๊ด๋ฆฌ: deprecated ์์ฑ์ผ๋ก ํ์ ํธํ์ฑ ์ ์ง
๋ธ๋ก ๊ฐ๋ฐ์ ๋จ์ํ ์ฝ๋๋ฅผ ์์ฑํ๋ ๊ฒ ์ด์์ด์ผ. ์ฌ์ฉ์ ๊ฒฝํ์ ๋์์ธํ๊ณ , ์ฝํ
์ธ ์ ์์์ ์ํฌํ๋ก์ฐ๋ฅผ ๊ฐ์ ํ๋ฉฐ, ์น์ฌ์ดํธ์ ์ผ๊ด์ฑ์ ์ ์งํ๋ ๊ฑฐ์ง. ๐จ
์ฒ์์ ์์ ๋ธ๋ก๋ถํฐ ์์ํด๋ด. ๊ฐ๋จํ ํ
์คํธ ๋ธ๋ก, ์ด๋ฏธ์ง ๋ธ๋ก์ ๋ง๋ค์ด๋ณด๊ณ , ์ ์ ๋ณต์กํ ๊ธฐ๋ฅ์ ์ถ๊ฐํด๊ฐ๋ ๊ฑฐ์ผ. ์ค์๋ฅผ ๋๋ ค์ํ์ง ๋ง! ์๋ฌ ๋ฉ์์ง๋ฅผ ์ ์ฝ๊ณ , ๊ณต์ ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ๊ณ , ์ปค๋ฎค๋ํฐ์ ์ง๋ฌธํ๋ฉด์ ๋ฐฐ์๊ฐ๋ฉด ๋ผ.
๊ทธ๋ฆฌ๊ณ ๋ง๋ ๋ธ๋ก์ ๊ผญ ๋ค๋ฅธ ์ฌ๋๋ค๊ณผ ๊ณต์ ํด๋ด. GitHub์ ์คํ์์ค๋ก ์ฌ๋ฆฌ๊ฑฐ๋, WordPress.org์ ๋ฑ๋กํ๊ฑฐ๋, ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ ํ๋งคํ ์๋ ์์ด. ๋ค๋ฅธ ๊ฐ๋ฐ์๋ค์ ํผ๋๋ฐฑ์ ๋ฐ์ผ๋ฉด์ ์ฑ์ฅํ๋ ๊ฒ ๊ฐ์ฅ ๋น ๋ฅธ ํ์ต ๋ฐฉ๋ฒ์ด๊ฑฐ๋ ! ๐
๊ตฌํ
๋ฒ ๋ฅดํฌ๋ ๊ณ์ ์งํํ๊ณ ์์ด. ์๋ก์ด API๊ฐ ์ถ๊ฐ๋๊ณ , ๋ ๊ฐ๋ ฅํ ๊ธฐ๋ฅ๋ค์ด ๋์ค๊ณ ์์ง. ๊ณต์ ๋ธ๋ก๊ทธ(make.wordpress.org/core)๋ฅผ ๊ตฌ๋
ํ๊ณ , ์
๋ฐ์ดํธ๋ฅผ ๋์น์ง ์๋ ๊ฒ ์ค์ํด.
๋ง์ง๋ง์ผ๋ก, ๋ธ๋ก ๊ฐ๋ฐ์ ์ฐฝ์์ฑ์ ๋ฐํํ ์ ์๋ ๋ฉ์ง ๋ถ์ผ์ผ. ๋น์ ๋ง์ ๋
ํนํ ์์ด๋์ด๋ก ์ฌ์ฉ์๋ค์๊ฒ ์๋ก์ด ๊ฒฝํ์ ์ ์ฌํด๋ด. ๋๊ฐ ์์? ๋น์ ์ด ๋ง๋ ๋ธ๋ก์ด ๋ค์ "ํ์ ํ๋ฌ๊ทธ์ธ"์ด ๋ ์๋ ์์์! ๐
์, ์ด์ ์๋ํฐ๋ฅผ ์ด๊ณ ์ฒซ ๋ฒ์งธ ๋ธ๋ก์ ๋ง๋ค์ด๋ณผ ์๊ฐ์ด์ผ. ํ์ด์ ๋น์ด! ๐
โข GitHub ์ ์ฅ์: github.com/WordPress/gutenberg
โข ๋ธ๋ก ์์ : github.com/WordPress/block-development-examples
โข ์ปค๋ฎค๋ํฐ: wordpress.org/support/forum/gutenberg
โข ํ๊ตญ ์ปค๋ฎค๋ํฐ: wordpress.org/support/forum/ko
โข YouTube ํํ ๋ฆฌ์ผ: "Gutenberg Block Development" ๊ฒ์
โข ์จ๋ผ์ธ ๊ฐ์: Udemy, Coursera ๋ฑ์์ ์ ๊ณต
๐ Happy Coding!
๊ตฌํ
๋ฒ ๋ฅดํฌ ๋ธ๋ก ๊ฐ๋ฐ์ ์ธ๊ณ์ ์ค์ ๊ฒ์ ํ์ํฉ๋๋ค!
๋น์ ์ ์ฐฝ์์ ์ธ ๋ธ๋ก์ด ์ธ์์ ๋ ์๋ฆ๋ต๊ฒ ๋ง๋ค ๊ฑฐ์์. ๐ซ
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.