reset( $user->id );
// Add some css
?>
Users can reset the following preferences they have made in the admin area with the defaults: which columns are hidden in admin list tables, which meta boxes are hidden, and where meta boxes are positioned on edit pages.
| Reset Hidden Admin List Columns | $value ) {
// Get only these meta keys
if ( str_starts_with( $key, 'manageedit-' ) && str_ends_with( $key, 'columnshidden' ) ) {
// Strip the key to get the post type
$manageedit_post_type = str_replace( [ 'manageedit-', 'columnshidden' ], '', $key );
// Fetch the post type object
$post_type_obj = get_post_type_object( $manageedit_post_type );
// Check if post type still exists, and is on this site
// Note: user may have additional post type options for different sites if on multisite
if ( !is_null( $post_type_obj ) ) {
// Get the values
$values = unserialize( $value[0] );
// Skip empty values
if ( empty( $values ) ) {
continue;
}
// Get the post type name
$post_type_name = $post_type_obj->labels->name;
// Add a link to reset only this post type
$manageedit_links[ $post_type_name ] = ''.esc_html( $post_type_name ).' Only — currently hiding: '.esc_html( implode( ', ', $values ) ).'';
}
}
}
// If none found
if ( empty( $manageedit_links ) ) {
?>None found
ALL POST TYPES ⤷ |
|---|---|
| Reset Hidden Meta Boxes | $value ) {
// Get only these meta keys
if ( str_starts_with( $key, 'metaboxhidden_' ) ) {
// Strip the key to get the post type
$metaboxhidden_area = str_replace( 'metaboxhidden_', '', $key );
// Fetch the post type object
$post_type_obj = get_post_type_object( $metaboxhidden_area );
// Allowed exceptions
$exceptions = [
'dashboard' => 'Dashboard',
'dashboard-network' => 'Dashboard (Network)',
'nav-menus' => 'Navigation Menus'
];
// Check if post type still exists, and is on this site
// Note: user may have additional post type options for different sites if on multisite
if ( !is_null( $post_type_obj ) || array_key_exists( $metaboxhidden_area, $exceptions ) ) {
// Get the values
$values = unserialize( $value[0] );
// Skip empty values
if ( empty( $values ) ) {
continue;
}
// Get the post type name
if ( !is_null( $post_type_obj ) ) {
$name = $post_type_obj->labels->name;
} else {
$name = $exceptions[ $metaboxhidden_area ];
}
// Add a link to reset only this post type
$metaboxhidden_links[ $name ] = ''.esc_html( $name ).' Only — currently hiding: '.esc_html( implode( ', ', $values ) ).'';
}
}
}
// If none found
if ( empty( $metaboxhidden_links ) ) {
?>None found
ALL AREAS ⤷ |
| Reset Meta Box Positions | $value ) {
// Get only these meta keys
if ( str_starts_with( $key, 'meta-box-order_' ) ) {
// Strip the key to get the post type
$metaboxorder_area = str_replace( 'meta-box-order_', '', $key );
// Fetch the post type object
$post_type_obj = get_post_type_object( $metaboxorder_area );
// Allowed exceptions
$exceptions = [
'dashboard' => 'Dashboard',
'dashboard-network' => 'Dashboard (Network)',
'nav-menus' => 'Navigation Menus'
];
// Check if post type still exists, and is on this site
// Note: user may have additional post type options for different sites if on multisite
if ( !is_null( $post_type_obj ) || array_key_exists( $metaboxorder_area, $exceptions ) ) {
// Get the values
$values = unserialize( $value[0] );
// Skip empty values
if ( empty( $values ) ) {
continue;
}
// Get the post type name
if ( !is_null( $post_type_obj ) ) {
$name = $post_type_obj->labels->name;
} else {
$name = $exceptions[ $metaboxorder_area ];
}
// Add a link to reset only this post type
$metaboxorder_links[ $name ] = ''.esc_html( $name ).' Only';
}
}
}
// If none found
if ( empty( $metaboxorder_links ) ) {
?>None found
ALL AREAS ⤷ |