monsterinsights_ajax_dismiss_notice

Called whenever a notice is dismissed in MonsterInsights or its Addons.

Description

monsterinsights_ajax_dismiss_notice(); 

Updates a key's value in the options table to mark the notice as dismissed, preventing it from displaying again


Usage

  1. if ( !function_exists( 'monsterinsights_ajax_dismiss_notice' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = monsterinsights_ajax_dismiss_notice(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/ajax.php  
  1. function monsterinsights_ajax_dismiss_notice() { 
  2.  
  3. // Run a security check first. 
  4. check_ajax_referer( 'monsterinsights-dismiss-notice', 'nonce' ); 
  5.  
  6. // Deactivate the notice 
  7. if ( isset( $_POST['notice'] ) ) { 
  8. // Init the notice class and mark notice as deactivated 
  9. MonsterInsights()->notices->dismiss( $_POST['notice'] ); 
  10.  
  11. // Return true 
  12. echo json_encode( true ); 
  13. wp_die(); 
  14.  
  15. // If here, anerroroccured 
  16. echo json_encode( false ); 
  17. wp_die(); 
  18.