monsterinsights_ajax_activate_addon

Activates a MonsterInsights addon.

Description

monsterinsights_ajax_activate_addon(); 

Usage

  1. if ( !function_exists( 'monsterinsights_ajax_activate_addon' ) ) { 
  2. require_once '/includes/admin/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = monsterinsights_ajax_activate_addon(); 
  7.  

Defined (1)

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

/includes/admin/ajax.php  
  1. function monsterinsights_ajax_activate_addon() { 
  2.  
  3. // Run a security check first. 
  4. check_ajax_referer( 'monsterinsights-activate', 'nonce' ); 
  5.  
  6. if ( ! current_user_can( 'activate_plugins' ) ) { 
  7. echo json_encode( true ); 
  8.  
  9. // Activate the addon. 
  10. if ( isset( $_POST['plugin'] ) ) { 
  11. if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { 
  12. $activate = activate_plugin( $_POST['plugin'], NULL, true ); 
  13. } else { 
  14. $activate = activate_plugin( $_POST['plugin'] ); 
  15.  
  16. if ( is_wp_error( $activate ) ) { 
  17. echo json_encode( array( 'error' => $activate->get_error_message() ) ); 
  18. wp_die(); 
  19.  
  20. echo json_encode( true ); 
  21. wp_die(); 
  22.