postbox_classes

The timeline below displays how wordpress function postbox_classes has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Returns the list of classes to be used by a meta box.
 *
 * @since 2.5.0
 *
 * @param string $box_id    Meta box ID (used in the 'id' attribute for the meta box).
 * @param string $screen_id The screen on which the meta box is shown.
 * @return string Space-separated string of class names.
 */
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);
}

WordPress Version: 5.3

/**
 * Returns the list of classes to be used by a meta box.
 *
 * @since 2.5.0
 *
 * @param string $box_id    Meta box ID (used in the 'id' attribute for the meta box).
 * @param string $screen_id The screen on which the meta box is shown.
 * @return string Space-separated string of class names.
 */
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) ? 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);
}

WordPress Version: 5.2

/**
 * Returns the list of classes to be used by a meta box.
 *
 * @since 2.5.0
 *
 * @param string $box_id    Meta box ID (used in the 'id' attribute for the meta box).
 * @param string $screen_id The screen on which the meta box is shown.
 * @return string Space-separated string of class names.
 */
function postbox_classes($box_id, $screen_id)
{
    if (isset($_GET['edit']) && $_GET['edit'] == $box_id) {
        $classes = array('');
    } elseif ($closed = get_user_option('closedpostboxes_' . $screen_id)) {
        if (!is_array($closed)) {
            $classes = array('');
        } else {
            $classes = in_array($box_id, $closed) ? 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);
}

WordPress Version: 5.1

/**
 * Returns the list of classes to be used by a meta box.
 *
 * @since 2.5.0
 *
 * @param string $id
 * @param string $page
 * @return string
 */
function postbox_classes($id, $page)
{
    if (isset($_GET['edit']) && $_GET['edit'] == $id) {
        $classes = array('');
    } elseif ($closed = get_user_option('closedpostboxes_' . $page)) {
        if (!is_array($closed)) {
            $classes = array('');
        } else {
            $classes = in_array($id, $closed) ? array('closed') : array('');
        }
    } else {
        $classes = array('');
    }
    /**
     * Filters the postbox classes for a specific screen and screen ID combo.
     *
     * The dynamic portions of the hook name, `$page` and `$id`, refer to
     * the screen and screen ID, respectively.
     *
     * @since 3.2.0
     *
     * @param string[] $classes An array of postbox classes.
     */
    $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes);
    return implode(' ', $classes);
}

WordPress Version: 4.6

/**
 * Returns the list of classes to be used by a meta box.
 *
 * @since 2.5.0
 *
 * @param string $id
 * @param string $page
 * @return string
 */
function postbox_classes($id, $page)
{
    if (isset($_GET['edit']) && $_GET['edit'] == $id) {
        $classes = array('');
    } elseif ($closed = get_user_option('closedpostboxes_' . $page)) {
        if (!is_array($closed)) {
            $classes = array('');
        } else {
            $classes = in_array($id, $closed) ? array('closed') : array('');
        }
    } else {
        $classes = array('');
    }
    /**
     * Filters the postbox classes for a specific screen and screen ID combo.
     *
     * The dynamic portions of the hook name, `$page` and `$id`, refer to
     * the screen and screen ID, respectively.
     *
     * @since 3.2.0
     *
     * @param array $classes An array of postbox classes.
     */
    $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes);
    return implode(' ', $classes);
}

WordPress Version: 4.1

/**
 * Returns the list of classes to be used by a metabox
 *
 * @since 2.5.0
 *
 * @param string $id
 * @param string $page
 * @return string
 */
function postbox_classes($id, $page)
{
    if (isset($_GET['edit']) && $_GET['edit'] == $id) {
        $classes = array('');
    } elseif ($closed = get_user_option('closedpostboxes_' . $page)) {
        if (!is_array($closed)) {
            $classes = array('');
        } else {
            $classes = in_array($id, $closed) ? array('closed') : array('');
        }
    } else {
        $classes = array('');
    }
    /**
     * Filter the postbox classes for a specific screen and screen ID combo.
     *
     * The dynamic portions of the hook name, `$page` and `$id`, refer to
     * the screen and screen ID, respectively.
     *
     * @since 3.2.0
     *
     * @param array $classes An array of postbox classes.
     */
    $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes);
    return implode(' ', $classes);
}

WordPress Version: 3.9

/**
 * Returns the list of classes to be used by a metabox
 *
 * @uses get_user_option()
 * @since 2.5.0
 *
 * @param unknown_type $id
 * @param unknown_type $page
 * @return unknown
 */
function postbox_classes($id, $page)
{
    if (isset($_GET['edit']) && $_GET['edit'] == $id) {
        $classes = array('');
    } elseif ($closed = get_user_option('closedpostboxes_' . $page)) {
        if (!is_array($closed)) {
            $classes = array('');
        } else {
            $classes = in_array($id, $closed) ? array('closed') : array('');
        }
    } else {
        $classes = array('');
    }
    /**
     * Filter the postbox classes for a specific screen and screen ID combo.
     *
     * The dynamic portions of the hook name, $page, and $id, refer to
     * the screen, and screen ID, respectively.
     *
     * @since 3.2.0
     *
     * @param array $classes An array of postbox classes.
     */
    $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes);
    return implode(' ', $classes);
}

WordPress Version: 3.7

/**
 * Returns the list of classes to be used by a metabox
 *
 * @uses get_user_option()
 * @since 2.5.0
 *
 * @param unknown_type $id
 * @param unknown_type $page
 * @return unknown
 */
function postbox_classes($id, $page)
{
    if (isset($_GET['edit']) && $_GET['edit'] == $id) {
        $classes = array('');
    } elseif ($closed = get_user_option('closedpostboxes_' . $page)) {
        if (!is_array($closed)) {
            $classes = array('');
        } else {
            $classes = in_array($id, $closed) ? array('closed') : array('');
        }
    } else {
        $classes = array('');
    }
    $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes);
    return implode(' ', $classes);
}