Plugin Directory

Changeset 3199623


Ignore:
Timestamp:
11/29/2024 06:13:31 PM (16 months ago)
Author:
lordspace
Message:
  • Fixed how jquery and js was loaded using a different method.
  • Making sure that jquery is loaded.
Location:
orbisius-simple-notice/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orbisius-simple-notice/trunk/orbisius-simple-notice.php

    r2462972 r3199623  
    5858    $dev = empty($_SERVER['DEV_ENV']) ? 0 : 1;
    5959    $suffix = $dev ? '' : '.min';
     60
     61    wp_enqueue_script('jquery');
    6062
    6163    /*wp_register_style('simple_notice', plugins_url("/assets/main{$suffix}.css", __FILE__));
     
    114116        $js_code .= <<<FORM_EOF
    115117    <script>
    116     jQuery(document).ready(function ($) {
    117         var msg_id = jQuery('#orbisius_simple_notice').data('msg_id');
    118 
    119         if (!jQuery('body').hasClass('wp-admin')) { // public area only
    120             var orb_simp_ntc_dismiss_hash = jQuery.cookie('orb_simp_ntc_dismiss') || '';
    121 
    122             /* if the cookie exists and matches the msg_id that means the user has dismissed the message already. So don't show it for another day. */
    123             if (orb_simp_ntc_dismiss_hash == msg_id) {
    124                 jQuery('#orbisius_simple_notice_container').hide();
    125             }
    126         }
    127 
    128         // The user has clicked on the X sign
    129         jQuery('#orbisius_simple_notice_container .dismiss_message').on('click', function() {
    130             jQuery('#orbisius_simple_notice_container').slideUp('slow');
    131 
    132             // for WP admin show the message.
    133             if (jQuery('body').hasClass('wp-admin')) {
    134                 setTimeout(function () {
    135                     jQuery('#orbisius_simple_notice_container').slideDown('slow');
    136                 }, 2000);
    137             } else {
    138                 // this will be empty for new messages or expired cookies
    139                 var orb_simp_ntc_dismiss_hash = jQuery.cookie('orb_simp_ntc_dismiss') || '';
    140 
    141                 if (orb_simp_ntc_dismiss_hash == '') {
    142                     jQuery.cookie('orb_simp_ntc_dismiss', msg_id, { expires: 2 } );
     118    (function ($) {
     119        $(document).ready(function ($) {
     120            let msg_id = jQuery('#orbisius_simple_notice').data('msg_id');
     121   
     122            if (!jQuery('body').hasClass('wp-admin')) { // public area only
     123                let orb_simp_ntc_dismiss_hash = jQuery.cookie('orb_simp_ntc_dismiss') || '';
     124   
     125                /* if the cookie exists and matches the msg_id that means the user has dismissed the message already. So don't show it for another day. */
     126                if (orb_simp_ntc_dismiss_hash == msg_id) {
     127                    jQuery('#orbisius_simple_notice_container').hide();
    143128                }
    144129            }
     130   
     131            // The user has clicked on the X sign
     132            jQuery('#orbisius_simple_notice_container .dismiss_message').on('click', function() {
     133                jQuery('#orbisius_simple_notice_container').slideUp('slow');
     134   
     135                // for WP admin show the message.
     136                if (jQuery('body').hasClass('wp-admin')) {
     137                    setTimeout(function () {
     138                        jQuery('#orbisius_simple_notice_container').slideDown('slow');
     139                    }, 2000);
     140                } else {
     141                    // this will be empty for new messages or expired cookies
     142                    var orb_simp_ntc_dismiss_hash = jQuery.cookie('orb_simp_ntc_dismiss') || '';
     143   
     144                    if (orb_simp_ntc_dismiss_hash == '') {
     145                        jQuery.cookie('orb_simp_ntc_dismiss', msg_id, { expires: 2 } );
     146                    }
     147                }
     148            });
    145149        });
    146     });
     150    })(jQuery);
    147151</script>
    148152FORM_EOF;
     
    207211            $js_code .= <<<FORM_EOF
    208212<script>
    209     jQuery(document).ready(function ($) {
    210         jQuery('#orbisius_simple_notice_container').prependTo('body'); // .css('postion', '')
    211     });
     213    (function($) {
     214        $(document).ready(function ($) {
     215            $('#orbisius_simple_notice_container').prependTo('body'); // .css('postion', '')
     216        });       
     217    })(jQuery);
    212218</script>
    213219FORM_EOF;
  • orbisius-simple-notice/trunk/readme.txt

    r2462972 r3199623  
    6464== Changelog ==
    6565
     66= 1.1.3 =
     67* Fixed how jquery and js was loaded using a different method.
     68* Making sure that jquery is loaded.
     69
    6670= 1.1.2 =
    6771* Added z-index so the links in the message are clickable.
Note: See TracChangeset for help on using the changeset viewer.