wordpress - 如何更改 Elementor 弹出位置设置?
问题描述
我在我工作的一个网站上遇到问题,其中 Elementor 弹出窗口的“edit_in_content”位置设置对于所有弹出窗口都设置为 FALSE,并且它阻止管理员进入 Elementor 编辑器。
此问题表现为常见的“the_content not found”错误消息,但是,调试会导致弹出窗口的位置设置成为问题。问题出在\ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager 的builder_wrapper 方法中,该方法位于/elementor-pro/modules/theme-builder/classes/locations-manager.php 中。
public function builder_wrapper( $content ) {
$post_id = get_the_ID();
if ( $post_id ) {
$document = Module::instance()->get_document( $post_id );
if ( $document ) {
$document_location = $document->get_location();
$location_settings = $this->get_location( $document_location );
/**
* Custom Modification Begin
* ------------------------------------
*/
if( $document_location == 'popup' )
return $content;
/**
* Custom Modification End
* ------------------------------------
*/
// If is a `content` document or the theme is not support the document location (header/footer and etc.).
if ( $location_settings && ! $location_settings['edit_in_content'] ) {
$content = '<div class="elementor-theme-builder-content-area">' . __( 'Content Area', 'elementor-pro' ) . '</div>';
}
}
}
return $content;
}
我知道这是一个插件黑客,不推荐,但我没有找到其他方法来处理这个问题。
- 我不确定为什么所有弹出窗口的 edit_in_content 都是 FALSE。
- 我发现无法确保 edit_in_content 为 TRUE,以便管理员可以使用弹出窗口。
公平地说,我应该透露主题是定制的,但相当少。当切换到二十二十时,问题就消失了。测试期间所有插件都已禁用,并且弹出位置设置似乎受到自定义主题的影响。
- 我在 2020 中没有发现任何以任何方式引用 elementor 的内容。
- 我已经阅读了 Elementor 与 the_content 问题相关的文档,但没有任何说明会导致成功。参考:https ://docs.elementor.com/article/56-content-area-not-found
所以,我希望有人能够对这个问题有所了解。我该怎么做才能不必破解插件?
解决方案
我发布答案是因为我发现了一些我可以做的事情来不破解插件,尽管我仍然很好奇为什么需要这样做。我基本上只是添加一个钩子/动作,在它最初注册后重新处理弹出位置。这可以放在主题的 functions.php 文件中:
function fixElementorPopupLocation( $that )
{
$loc = $that->get_location('popup');
if( ! $loc['edit_in_content'] )
{
$args = [
'label' => $loc['label'],
'multiple' => $loc['multiple'],
'public' => $loc['public'],
'edit_in_content' => TRUE,
'hook' => $loc['hook'],
];
$that->register_location('popup', $args);
}
}
add_action(
'elementor/theme/register_locations',
'fixElementorPopupLocation',
93062220
);
如果有人能告诉我为什么我需要这样做,以及为什么我在 220 主题中不需要这样做,我很乐意接受这个作为答案,只要我可以使用这些建议来“修复”我的主题。
推荐阅读
- node.js - UnhandledPromiseRejectionWarning:NodeJS 拉取请求不起作用
- ios - 应用内购买非消耗品与我完美合作,但不适用于苹果查看器
- python - 如何根据熊猫数据框中的过滤器进行分组并计算最大值
- amazon-web-services - AWS::Serverless::HttpApi Cors 配置适用于 POST 但不适用于 OPTIONS
- python - Pyinstaller:运行 .exe 文件时出现“ModuleNotFoundError:没有名为 'pyutil' 的模块”
- python - Project Euler #8:使用 numpy 计算子列表的乘积返回负值
- reactjs - 如何摆脱警告“React Hook useEffect has missing dependencies ...”同时(故意)保留一个空数组作为依赖项?
- typescript - 将对象数组转换为特定键的值数组
- javascript - Jest 无法测试等待的承诺,而是超时
- html - 使用 CSS 的子元素上带有浅黑色背景的不透明度