postbox_classes

Returns the list of classes to be used by a meta box.

Description

(string) postbox_classes( (string) $id, (string) $page ); 

Returns (string)

Parameters (2)

0. $id (string)
The id.
1. $page (string)
The page.

Usage

  1. if ( !function_exists( 'postbox_classes' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/post.php'; 
  3.  
  4. // The id. 
  5. $id = ''; 
  6.  
  7. // The page. 
  8. $page = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = postbox_classes($id, $page); 
  12.  

Defined (1)

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

/wp-admin/includes/post.php  
  1. function postbox_classes( $id, $page ) { 
  2. if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) { 
  3. $classes = array( '' ); 
  4. } elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) { 
  5. if ( !is_array( $closed ) ) { 
  6. $classes = array( '' ); 
  7. } else { 
  8. $classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' ); 
  9. } else { 
  10. $classes = array( '' ); 
  11.  
  12. /** 
  13. * Filters the postbox classes for a specific screen and screen ID combo. 
  14. * The dynamic portions of the hook name, `$page` and `$id`, refer to 
  15. * the screen and screen ID, respectively. 
  16. * @since 3.2.0 
  17. * @param array $classes An array of postbox classes. 
  18. */ 
  19. $classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes ); 
  20. return implode( ' ', $classes );