我一直在关注 Elementor 关于创建自定义小部件的文档。注册控件时,Elementor 编辑器开始崩溃,永远卡在加载状态。
原代码:
<?php
class Custom_Widget extends \Elementor\Widget_Base
{
$this->start_controls_section(
'content_section',
[
'label' => esc_html__( 'Content', 'textdomain' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, //causes the issue.
]
);
}
?>
我一遍又一遍地检查语法,但不明白为什么。在偶然发现这个支持票之后,我注意到OP使用的是SECTION常量而不是TAB_CONTENT或TAB_STYLE。这解决了我的问题,但我无法使用这两个常量注册任何部分而不会使 Elementor 编辑器崩溃。
新代码:
<?php
class Custom_Widget extends \Elementor\Widget_Base
{
$this->start_controls_section(
'content_section',
[
'label' => esc_html__( 'Content', 'textdomain' ),
'tab' => \Elementor\Controls_Manager::SECTION, //Loads the Elementor editor
]
);
}
?>
TAB_CONTENT 和 TAB_STYLE 都是 默认 Elementor Tabs 常量。那么,为什么它们不适合我?另外,由于 SECTION 常量不是默认常量,因此它不应该引起问题吗?