On this page
postbox_classes( string $box_id, string $screen_id ): string
Returns the list of classes to be used by a meta box.
Parameters
$box_idstring Required-
Meta box ID (used in the
'id'attribute for the meta box). $screen_idstring Required-
The screen on which the meta box is shown.
Return
string Space-separated string of class names.
Source
File: wp-admin/includes/post.php. View all references
function postbox_classes( $box_id, $screen_id ) {
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) {
$classes = array( '' );
} elseif ( get_user_option( 'closedpostboxes_' . $screen_id ) ) {
$closed = get_user_option( 'closedpostboxes_' . $screen_id );
if ( ! is_array( $closed ) ) {
$classes = array( '' );
} else {
$classes = in_array( $box_id, $closed, true ) ? array( 'closed' ) : array( '' );
}
} else {
$classes = array( '' );
}
/**
* Filters the postbox classes for a specific screen and box ID combo.
*
* The dynamic portions of the hook name, `$screen_id` and `$box_id`, refer to
* the screen ID and meta box ID, respectively.
*
* @since 3.2.0
*
* @param string[] $classes An array of postbox classes.
*/
$classes = apply_filters( "postbox_classes_{$screen_id}_{$box_id}", $classes );
return implode( ' ', $classes );
}
Hooks
- apply_filters( "postbox_classes_{$screen_id}_{$box_id}",
string[] $classes ) -
Filters the postbox classes for a specific screen and box ID combo.
Related
Uses
| Uses | Description |
|---|---|
| get_user_option() wp-includes/user.php | Retrieves user option that can be either per Site or per Network. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| do_meta_boxes() wp-admin/includes/template.php | Meta-Box template function. |
| do_accordion_sections() wp-admin/includes/template.php | Meta Box Accordion Template Function. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/post