【问题标题】:Elementor error when Editing the Page Warning: Undefined array key "pro_widgets" in *\wp-content\plugins\elementor\includes\api.php on line 160编辑页面警告时出现 Elementor 错误:第 160 行 *\wp-content\plugins\elementor\includes\api.php 中的未定义数组键“pro_widgets”
【发布时间】:2022-02-03 10:08:18
【问题描述】:

当我尝试使用 elementor 编辑页面时,我收到此错误并且 pro 小部件未显示(我有免费 elementor 但计划获得 pro)

我更新了 elementor 插件和主题,并尝试卸载一些插件,但仍然无法正常工作

【问题讨论】:

    标签: php wordpress elementor


    【解决方案1】:

    请尝试切换它们并检查。

    可能存在文件冲突问题。 确保您的 WP 设置和插件是最新版本

    【讨论】:

    • 我禁用了所有插件并更新了所有内容,但仍然无法正常工作
    • 请分享截图或网址,以便我详细检查。
    • 正在本地主机上构建网站您想要特定事物的屏幕截图吗?
    【解决方案2】:

    您需要在 api.php 第 160 行 中使用 isset 检查变量是否已设置且不为 NULL。

    get_promotion_widget() 函数内部 改成这样:

    public static function get_promotion_widgets() {
        $data = self::get_info_data();
    
        if ( ! isset( $data['pro_widgets'] ) ) {
            $data['pro_widgets'] = [];
        }
    
        return $data['pro_widgets'];
    }
    

    警告应该消失了。

    【讨论】:

      【解决方案3】:

      我已经通过在函数中添加一行来临时修复它,如下所示。不幸的是,每次更新 Elementor 插件时都需要重新应用这种临时修复,因此这不是一个好的长期解决方案。

      public static function get_promotion_widgets() {
          $data = self::get_info_data();
      
          if ( ! isset( $data['pro_widgets'] ) ) {
              if (!is_array($data)) $data = []; # Added
              $data['pro_widgets'] = [];
          }
      
          return $data['pro_widgets'];
      }
      

      该函数可以在 wp-content/plugins/elementor/includes/api.php 的第 160 行附近找到。

      我已经通过 github 向插件开发者提交了我的修复,所以希望它会成为插件代码。

      【讨论】:

        猜你喜欢
        • 2017-04-08
        • 1970-01-01
        • 1970-01-01
        • 2021-07-19
        • 1970-01-01
        • 2016-07-14
        • 2022-10-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多