PluginProbe
AI Builder – Generate pages, blocks, images & translate with AI / 2.7.3
AI Builder – Generate pages, blocks, images & translate with AI v2.7.3
2.7.9 2.7.8 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.10 2.3.11 All 121 releases
ai-builder / includes / class-js-handler.php

class-js-handler.php in AI Builder – Generate pages, blocks, images & translate with AI 2.7.3, at includes/class-js-handler.php

33 lines 770 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH'))
4 exit; // Exit if accessed directly
5
6 class AIBUI_JS_Handler
7 {
8 public function __construct()
9 {
10 // Ajouter le JS personnalisé sur le frontend
11 add_action('wp_footer', array($this, 'add_custom_js'));
12 }
13
14 public function add_custom_js()
15 {
16 // Récupérer l'ID du post actuel
17 $post_id = get_the_ID();
18
19 if (!$post_id) {
20 return;
21 }
22
23 // Récupérer le JS personnalisé depuis les meta du post
24 $js_content = get_post_meta($post_id, 'ai_builder_js_content', true);
25
26 if (!empty($js_content)) {
27 echo '<script id="ai-builder-frontend-js" type="text/javascript">' . $js_content . '</script>';
28 }
29 }
30 }
31
32 new AIBUI_JS_Handler();
33