当我有define( 'SCRIPT_DEBUG', true );
In mywp-config.php
时,我通过调用这个钩子接收到正确的对象:editor.BlockListBlock
。当我有define( 'SCRIPT_DEBUG', false );
或没有定义时,我收到了错误的对象。
const { createHigherOrderComponent } = wp.compose;
const withClientIdClassName = createHigherOrderComponent( ( BlockListBlock ) => {
// BlockListBlock returns as "WithSelect" with debug off
// and returns as the correct component with debug on
console.log(BlockListBlock);
return ( props ) => {
const {attributes, name} = props;
if(name === 'project/block-name'){
return <BlockListBlock { ...props } className={'classes-i-want-on-this'} />;
} else {
return <BlockListBlock { ...props } />;
}
};
}, 'withClientIdClassName' );
wp.hooks.addFilter( 'editor.BlockListBlock', 'classNames-for-cells', withClientIdClassName );
未定义 SCRIPT_DEBUG 或为 false
使用 SCRIPT_DEBUG 为真