Elementor error when Editing the Page Warning: Undefined array key "pro_widgets" in *\wp-content\plugins\elementor\includes\api.php on line 160

Viewed 924

When I try to edit the page with elementor I get this error and the pro widgets isn't showing (I have the free elementor but planning on getting the pro)

I updated the elementor plugin and theme and tried to uninstall some plugins but its still not working

3 Answers

Please try to switch them and check.

There may be a file conflict issue. Make sure your WP setup and plugin are with the latest version

What you need in api.php line 160 is to check whether a variable is set and is not NULL using isset.

Inside the get_promotion_widget() function change it to like this:

public static function get_promotion_widgets() {
    $data = self::get_info_data();

    if ( ! isset( $data['pro_widgets'] ) ) {
        $data['pro_widgets'] = [];
    }

    return $data['pro_widgets'];
}

And the warning should be gone.

I've fixed it temporarily by adding one line to the function, as below. Unfortunately this kind of temporary fix needs to be reapplied each time the Elementor plugin is updated, so it's not a good long term solution.

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'];
}

The function can be found in wp-content/plugins/elementor/includes/api.php at around line 160.

I've submitted my fix to the plugin developers through github, so hopefully it will make it into the plugin code.

Related