fix: elementor widget crash guard - check class_exists before registering

This commit is contained in:
Krystie
2026-06-02 20:23:17 -07:00
parent acef2a0f40
commit 5c6eba625a
+9 -4
View File
@@ -20,11 +20,16 @@ class Beep_Plugin {
update_option('beep_giphy_key', 'xuxYxuIvzPqw5tPB4laa7sQO8dFtSlNS');
}
// Elementor widget
// Elementor widget — only load if Elementor is active
add_action('elementor/widgets/register', function ($widgets_manager) {
require_once BEEP_DIR . 'includes/class-elementor-widget.php';
$widgets_manager->register(new \Elementor\Beep_Elementor_Widget());
});
if (!class_exists('\Elementor\Widget_Base')) return;
$widget_file = BEEP_DIR . 'includes/class-elementor-widget.php';
if (!file_exists($widget_file)) return;
require_once $widget_file;
if (class_exists('\Elementor\Beep_Elementor_Widget')) {
$widgets_manager->register(new \Elementor\Beep_Elementor_Widget());
}
}, 5);
// Admin settings (Giphy API key only — full settings via Beep_Settings)
add_action('admin_menu', [__CLASS__, 'add_admin_menu']);