wordpress - editor.BlockListBlock 过滤器未将 BlockListBlock 传递给 Function
问题描述
当我有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 为真
解决方案
推荐阅读
- safari - AppleScript 访问系统正在播放,无需 iTunes
- owncloud - Owncloud 社区共享:读/写权限
- reactjs - 在 React.js 中渲染一个表格,其中每个单元格对应一个带有 material-ui 的元素
- c# - 将项目插入到 SortableBindingList
- php - 在父类中,我是否应该将类属性设为私有,强制继承者使用 getter/setter?
- javascript - 在 Google Apps 脚本中 - 是否可以在当前 Google 表格用户之外的其他帐户上使用高级日历服务?
- python - 如何在 QTreeWidget 整数/浮点数中创建特定列,以便用户不能输入任何字母或符号而不是整数/浮点数?
- c++ - 为什么建议从矩阵中获取最大值的函数->无法将'int(*)[C]'转换为'int(*)[0]
- java - 使用 compareTo() 按字母顺序对名称数组进行排序
- python - 如何在 Python 类中继承错误处理