admin-common.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. jQuery( document ).ready( function( $ ) {
  2. var is_active = jQuery('#adminmenu a[href$="admin.php?page=monsterinsights_tracking"]').hasClass('current');
  3. jQuery('#adminmenu a[href$="admin.php?page=monsterinsights_tracking"]').parent().remove();
  4. if ( is_active ) {
  5. jQuery('#adminmenu a[href$="admin.php?page=monsterinsights_settings"]').addClass('current');
  6. jQuery('#adminmenu a[href$="admin.php?page=monsterinsights_settings"]').parent().addClass('current');
  7. }
  8. /**
  9. * Dismissable Notices
  10. * - Sends an AJAX request to mark the notice as dismissed
  11. */
  12. $( 'div.monsterinsights-notice' ).on( 'click', 'button.notice-dismiss', function( e ) {
  13. e.preventDefault();
  14. $( this ).closest( 'div.monsterinsights-notice' ).fadeOut();
  15. // If this is a dismissible notice, it means we need to send an AJAX request
  16. if ( $( this ).parent().hasClass( 'is-dismissible' ) ) {
  17. $.post(
  18. monsterinsights_admin_common.ajax,
  19. {
  20. action: 'monsterinsights_ajax_dismiss_notice',
  21. nonce: monsterinsights_admin_common.dismiss_notice_nonce,
  22. notice: $( this ).parent().data( 'notice' )
  23. },
  24. function( response ) {},
  25. 'json'
  26. );
  27. }
  28. } );
  29. });