• I have the following code in a mu-plugin file that adds a couple of buttons with popup windows next to the add media button, it works great but after doing some reading I think I am supposed to enqueue the jQuery which I have tried to do but I’m not sure how to do it for the following:

    add_action('media_buttons_context', 'add_my_custom_button');
    function add_my_custom_button() {
    ?>
    <script>
      jQuery(document).ready(function($) {
       $('.popup').click(function() {
         var NWin = window.open($(this).prop('href'), '', 'scrollbars=1,height=400,width=400');
         if (window.focus)
         {
           NWin.focus();
         }
         return false;
        });
    });
      </script>
      <a href="https://example.com" class="popup button">test button 1</a>
      <a href="https://example.com" class="popup button">test button 2</a>
      <?php
    }

    Could anyone help me out, thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You shouldn’t need to enqueue jquery as it comes bundled with WordPress. Note that WordPress uses jQuery in a noConflict mode, which means you can write jQuery code by writing jQuery instead of using the $ symbol.

    Example:

    jQuery(document).ready(function() {
      alert('Hey, this is working in noConflict mode!');
    });

    Thread Starter andym33

    (@andym33)

    I see, thanks for the tip and fast support

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘enqueue jQuery’ is closed to new replies.