const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
export const el = wp.element.createElement;
const {
RichText
} = wp.blockEditor;
const icon = el('svg', { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 18 18", color: '#0d34be' },
el('path', { d: "M12.5 3a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h5zm0 3a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h5zm.5 3.5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h5a.5.5 0 0 0 .5-.5zm-.5 2.5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h5z" } ),
el('path', { d: "M16 2a2 2 0 0 0-2-2H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2zM4 1v14H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h2zm1 0h9a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H5V1z" } ),
);
registerBlockType('create-block/test-block', {
title: __('Block', 'test-block'),
icon: icon,
category: 'common',
attributes: {
title: { type: 'string' },
},
edit({ className, attributes, setAttributes, isSelected }) {
const {
title ,
} = attributes
return (
<div>
<RichText
tagName="h1"
value={ title }
onChange={ ( value ) => {
setAttributes( { title: value } );
} }
/>
</div>
);
},
save({ attributes }) {
return null;
}
});
function slider_gutenberg_block_cgb_block_assets() {
wp_register_script(
'cgb-script',
plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ),
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ),
filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ),
true
);
wp_register_style(
'cgb-editor-style',
plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' )
);
wp_register_script(
'cgb-swiper-lib-script',
plugins_url( 'src/block/swiper-slider/swiper-bundle.min.js', dirname( __FILE__ ) ),
array( 'wp-blocks', 'wp-element', 'wp-i18n', 'jquery' ),
filemtime( plugin_dir_path( __DIR__ ) . 'src/block/swiper-slider/swiper-bundle.min.js' ),
true
);
wp_register_script(
'cgb-swiper-init-script',
plugins_url( 'src/block/swiper-slider/swiper-init.js', dirname( __FILE__ ) ),
array( 'wp-blocks', 'wp-element', 'wp-i18n', 'jquery', 'cgb-swiper-lib-script' ),
filemtime( plugin_dir_path( __DIR__ ) . 'src/block/swiper-slider/swiper-init.js' ),
true
);
wp_register_style(
'cgb-swiper-style',
plugins_url( 'src/block/swiper-slider/swiper-bundle.min.css', dirname( __FILE__ ) ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __DIR__ ) . 'src/block/swiper-slider/swiper-bundle.min.css' )
);
register_block_type(
'cgb/block-slider-gutenberg-block', array(
'style' => array('cgb-swiper-style'),
'script' => array('cgb-swiper-lib-script', 'cgb-swiper-init-script'),
'editor_style' => array('cgb-editor-style', 'cgb-swiper-style'),
'editor_script' => array('cgb-script', 'cgb-swiper-lib-script', 'cgb-swiper-init-script'),
)
);
}
add_action( 'init', 'slider_gutenberg_block_cgb_block_assets' );
<ul class="menu"> <!-- Начало Уровня 0 -->
<li class="menu-item">
<a href="#">Заголовок 0</a>
<ul class="sub-menu"> <!-- Начало Уровня 1 -->
<li class="menu-item">
<a href="#">Заголовок 1</a>
<ul class="sub-menu"> <!-- Начало Уровня 2 -->
<li class="menu-item">
<a href="#">Заголовок 2</a>
<ul class="sub-menu"> <!-- Начало Уровня 3 -->
<li class="menu-item">
<a href="#">Заголовок 3</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>