Site Builder
Editing:
promptinator-shortcode.php
writable 0666
<?php /* Plugin Name: Promptinator Shortcode Description: Loads Promptinator only on posts/pages containing a .Promptinator mount. Version: 1.0.6 Author: RF Safe / John Coates */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Only enqueue our scoped popup CSS and JS when there's a Promptinator on the page. */ add_action( 'wp_enqueue_scripts', function() { if ( ! is_singular() ) { return; } global $post; if ( empty( $post->post_content ) || stripos( $post->post_content, 'class="Promptinator"' ) === false ) { return; } $assets_url = plugins_url( 'assets', __FILE__ ); // Scoped popup CSS (all rules under dialog .popup-body) wp_enqueue_style( 'promptinator-css', $assets_url . '/promptinator.css' ); // Promptinator JS (ES module) wp_enqueue_script( 'promptinator-js', $assets_url . '/promptinator.js', array(), null, true ); }); /** * Append the Promptinator loader script *after* content— * again only on pages with a .Promptinator mount. */ add_filter( 'the_content', function( $content ) { if ( ! is_singular() ) { return $content; } global $post; if ( empty( $post->post_content ) || stripos( $post->post_content, 'class="Promptinator"' ) === false ) { return $content; } $js_url = plugins_url( 'assets/promptinator.js', __FILE__ ); $loader = <<<HTML <script type="module"> import Promptinator from "{$js_url}"; document.querySelectorAll('.Promptinator').forEach(div => { Promptinator.init({ mount: div }); }); </script> HTML; return $content . $loader; });
Save changes
Create folder
writable 0777
Create
Cancel