admin管理员组文章数量:1023108
I'm trying to render a block from PHP with ServerSideRender as follows:
js file:
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { ServerSideRender } = wpponents;
/**
* Internal dependencies
*/
import icons from './../../utils/icons';
registerBlockType( 'name/blockname', {
title: __( 'blockname' ),
description: __( 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.' ),
keywords: [ __( 'recent post' ) ],
icon: icons.block,
category: 'xyz',
edit: ( props ) => {
const {
className,
attributes,
} = props;
return (
<ServerSideRender
block="name/blockname"
attributes={ attributes }
className={ className }
/>
);
},
save: () => {
return null;
},
} );
php file:
register_block_type( '.../blockname', array(
'attributes' => array(
'className' => array(
'type' => 'string',
),
),
'render_callback' => 'render_block',
) );
function render_block( $attr, $content ) {
return 'txt';
}
Render:
<div>txt</div>
Expected:
<div class="wp-block-name-blockname">txt</div>
Everything seems to work correctly but the div with the class name is not being rendered.
Any suggestion to fix this? thank you in advance.
Anybody have any idea about this?
I'm trying to render a block from PHP with ServerSideRender as follows:
js file:
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { ServerSideRender } = wpponents;
/**
* Internal dependencies
*/
import icons from './../../utils/icons';
registerBlockType( 'name/blockname', {
title: __( 'blockname' ),
description: __( 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.' ),
keywords: [ __( 'recent post' ) ],
icon: icons.block,
category: 'xyz',
edit: ( props ) => {
const {
className,
attributes,
} = props;
return (
<ServerSideRender
block="name/blockname"
attributes={ attributes }
className={ className }
/>
);
},
save: () => {
return null;
},
} );
php file:
register_block_type( '.../blockname', array(
'attributes' => array(
'className' => array(
'type' => 'string',
),
),
'render_callback' => 'render_block',
) );
function render_block( $attr, $content ) {
return 'txt';
}
Render:
<div>txt</div>
Expected:
<div class="wp-block-name-blockname">txt</div>
Everything seems to work correctly but the div with the class name is not being rendered.
Any suggestion to fix this? thank you in advance.
Anybody have any idea about this?
本文标签: pluginsI am not receiving className in a ServerSideRender component
版权声明:本文标题:plugins - I am not receiving className in a ServerSideRender component 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745548884a2155525.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论