wp_ajax_closed_postboxes

Ajax handler for closed post boxes.

Description

wp_ajax_closed_postboxes(); 

Usage

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

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_closed_postboxes() { 
  2. check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); 
  3. $closed = isset( $_POST['closed'] ) ? explode( ', ', $_POST['closed']) : array(); 
  4. $closed = array_filter($closed); 
  5.  
  6. $hidden = isset( $_POST['hidden'] ) ? explode( ', ', $_POST['hidden']) : array(); 
  7. $hidden = array_filter($hidden); 
  8.  
  9. $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; 
  10.  
  11. if ( $page != sanitize_key( $page ) ) 
  12. wp_die( 0 ); 
  13.  
  14. if ( ! $user = wp_get_current_user() ) 
  15. wp_die( -1 ); 
  16.  
  17. if ( is_array($closed) ) 
  18. update_user_option($user->ID, "closedpostboxes_$page", $closed, true); 
  19.  
  20. if ( is_array($hidden) ) { 
  21. $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown 
  22. update_user_option($user->ID, "metaboxhidden_$page", $hidden, true); 
  23.  
  24. wp_die( 1 );