# ai-builder/2.7.6/includes/class-js-handler.php

AI Builder – Generate pages, blocks, images &amp; translate with AI, version 2.7.6. 33 lines.

- Page: https://pluginprobe.com/plugins/ai-builder/2.7.6/code/includes/class-js-handler.php
- Raw: https://pluginprobe.com/plugins/ai-builder/2.7.6/raw/includes/class-js-handler.php
- Modified: 2025-12-26T10:33:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ai-builder/2.7.6/code/includes/class-js-handler.php#L10-L20`.

```php
<?php

if (!defined('ABSPATH'))
    exit; // Exit if accessed directly

class AIBUI_JS_Handler
{
    public function __construct()
    {
        // Ajouter le JS personnalisé sur le frontend
        add_action('wp_footer', array($this, 'add_custom_js'));
    }

    public function add_custom_js()
    {
        // Récupérer l'ID du post actuel
        $post_id = get_the_ID();

        if (!$post_id) {
            return;
        }

        // Récupérer le JS personnalisé depuis les meta du post
        $js_content = get_post_meta($post_id, 'ai_builder_js_content', true);

        if (!empty($js_content)) {
            echo '<script id="ai-builder-frontend-js" type="text/javascript">' . $js_content . '</script>';
        }
    }
}

new AIBUI_JS_Handler();

```
