Docs: Improve documentation for `postbox_classes()`.

Rename `$page` and `$id` variables to `$screen_id` and `$box_id` for clarity.

Props sharifkiberu, DrewAPicture.
Fixes #45179.

git-svn-id: https://develop.svn.wordpress.org/trunk@45083 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-04-01 12:46:04 +00:00
parent 6abcd97c8c
commit 63b70b892b
1 changed files with 11 additions and 11 deletions

View File

@ -1291,34 +1291,34 @@ function wp_edit_attachments_query( $q = false ) {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $id * @param string $box_id Meta box ID (used in the 'id' attribute for the meta box).
* @param string $page * @param string $screen_id The screen on which the meta box is shown.
* @return string * @return string Space-separated string of class names.
*/ */
function postbox_classes( $id, $page ) { function postbox_classes( $box_id, $screen_id ) {
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) { if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) {
$classes = array( '' ); $classes = array( '' );
} elseif ( $closed = get_user_option( 'closedpostboxes_' . $page ) ) { } elseif ( $closed = get_user_option( 'closedpostboxes_' . $screen_id ) ) {
if ( ! is_array( $closed ) ) { if ( ! is_array( $closed ) ) {
$classes = array( '' ); $classes = array( '' );
} else { } else {
$classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' ); $classes = in_array( $box_id, $closed ) ? array( 'closed' ) : array( '' );
} }
} else { } else {
$classes = array( '' ); $classes = array( '' );
} }
/** /**
* Filters the postbox classes for a specific screen and screen ID combo. * Filters the postbox classes for a specific screen and box ID combo.
* *
* The dynamic portions of the hook name, `$page` and `$id`, refer to * The dynamic portions of the hook name, `$screen_id` and `$box_id`, refer to
* the screen and screen ID, respectively. * the screen ID and meta box ID, respectively.
* *
* @since 3.2.0 * @since 3.2.0
* *
* @param string[] $classes An array of postbox classes. * @param string[] $classes An array of postbox classes.
*/ */
$classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes ); $classes = apply_filters( "postbox_classes_{$screen_id}_{$box_id}", $classes );
return implode( ' ', $classes ); return implode( ' ', $classes );
} }