v1.7.0: shortcode-only, remove auto-inject
This commit is contained in:
+15
-3
@@ -22,12 +22,12 @@ class Beep_Plugin {
|
||||
|
||||
// Elementor widget — only load if Elementor is active
|
||||
add_action('elementor/widgets/register', function ($widgets_manager) {
|
||||
if (!class_exists('\Elementor\Widget_Base')) return;
|
||||
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());
|
||||
if (class_exists('\\Elementor\\Beep_Elementor_Widget')) {
|
||||
$widgets_manager->register(new \\Elementor\\Beep_Elementor_Widget());
|
||||
}
|
||||
}, 5);
|
||||
|
||||
@@ -35,6 +35,18 @@ class Beep_Plugin {
|
||||
add_action('admin_menu', [__CLASS__, 'add_admin_menu']);
|
||||
add_action('admin_init', [__CLASS__, 'register_settings']);
|
||||
}
|
||||
// Don't inject in feeds, REST, admin, etc.
|
||||
if (is_feed() || is_admin() || (defined('REST_REQUEST') && REST_REQUEST)) {
|
||||
return $content;
|
||||
}
|
||||
// Don't double-inject if content already has a beep feed
|
||||
if (strpos($content, 'data-beep-feed') !== false) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$feed = do_shortcode('[beep_feed limit="10"]');
|
||||
return $feed . $content;
|
||||
}
|
||||
|
||||
public static function add_admin_menu() {
|
||||
add_options_page(
|
||||
|
||||
Reference in New Issue
Block a user