Trouble making a modal box in my plugin

I’m trying to create a modal box on my wordpress, and I’ve followed instructions on this website: https://www.w3schools.com/howto/howto_css_modals.asp

But when I try it, I can’t find the script anywhere in my source code. I’m not using jQuery, mainly because I don’t know it yet. Before I put the code, I’ll explain a few details:

First, the modal box would actually be the footer of my page sliding up to reveal more content, getting focus through a black opaque background-color property.
Second, I triend implementing the code as specified, directly in the PHP-generated HTML, but there was no trace of that in my source code.
Third, I tried cuting the script as is, and pasting it in another file named ‘mq_script.js’ and located in my ‘plugin_name/js/’ folder.
Then, I tried including this script into my plugin, using below code. Plugin is an Object, refering to a widget that displays properly on my frontend through a PHP file. Widget itself is an object. That’s why in my code I declare public functions, and why I refer to my functions as $this->function_name().

Here we go:
In my widget.php file, I declared the ‘add_script’ function as such :

public function add_script(){
wp_register_script(‘mq_script’, plugins_url(‘js/mq_script.js’, __FILE__), array(), ‘1.0’, true);
wp_enqueue_script(‘mq_script’);
}

and in the same file, I added the action in the construct as such :

add_action(‘wp_enqueue_scripts’, array($this, ‘add_script’));

What am I missing?
Should I try to “translate” it to jQuery and do with WP integrated jQuery dependencies?

Thanks, I appreciate the time.

Read more here:: Trouble making a modal box in my plugin

Leave a Reply

Your email address will not be published. Required fields are marked *