Edit File by line
/home/barbar84/www/wp-admin/includes
File: screen.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Administration Screen API.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Get the column headers for a screen
[9] Fix | Delete
*
[10] Fix | Delete
* @since 2.7.0
[11] Fix | Delete
*
[12] Fix | Delete
* @param string|WP_Screen $screen The screen you want the headers for
[13] Fix | Delete
* @return string[] The column header labels keyed by column ID.
[14] Fix | Delete
*/
[15] Fix | Delete
function get_column_headers( $screen ) {
[16] Fix | Delete
if ( is_string( $screen ) ) {
[17] Fix | Delete
$screen = convert_to_screen( $screen );
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
static $column_headers = array();
[21] Fix | Delete
[22] Fix | Delete
if ( ! isset( $column_headers[ $screen->id ] ) ) {
[23] Fix | Delete
/**
[24] Fix | Delete
* Filters the column headers for a list table on a specific screen.
[25] Fix | Delete
*
[26] Fix | Delete
* The dynamic portion of the hook name, `$screen->id`, refers to the
[27] Fix | Delete
* ID of a specific screen. For example, the screen ID for the Posts
[28] Fix | Delete
* list table is edit-post, so the filter for that screen would be
[29] Fix | Delete
* manage_edit-post_columns.
[30] Fix | Delete
*
[31] Fix | Delete
* @since 3.0.0
[32] Fix | Delete
*
[33] Fix | Delete
* @param string[] $columns The column header labels keyed by column ID.
[34] Fix | Delete
*/
[35] Fix | Delete
$column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() );
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
return $column_headers[ $screen->id ];
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Get a list of hidden columns.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 2.7.0
[45] Fix | Delete
*
[46] Fix | Delete
* @param string|WP_Screen $screen The screen you want the hidden columns for
[47] Fix | Delete
* @return string[] Array of IDs of hidden columns.
[48] Fix | Delete
*/
[49] Fix | Delete
function get_hidden_columns( $screen ) {
[50] Fix | Delete
if ( is_string( $screen ) ) {
[51] Fix | Delete
$screen = convert_to_screen( $screen );
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
$hidden = get_user_option( 'manage' . $screen->id . 'columnshidden' );
[55] Fix | Delete
[56] Fix | Delete
$use_defaults = ! is_array( $hidden );
[57] Fix | Delete
[58] Fix | Delete
if ( $use_defaults ) {
[59] Fix | Delete
$hidden = array();
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Filters the default list of hidden columns.
[63] Fix | Delete
*
[64] Fix | Delete
* @since 4.4.0
[65] Fix | Delete
*
[66] Fix | Delete
* @param string[] $hidden Array of IDs of columns hidden by default.
[67] Fix | Delete
* @param WP_Screen $screen WP_Screen object of the current screen.
[68] Fix | Delete
*/
[69] Fix | Delete
$hidden = apply_filters( 'default_hidden_columns', $hidden, $screen );
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Filters the list of hidden columns.
[74] Fix | Delete
*
[75] Fix | Delete
* @since 4.4.0
[76] Fix | Delete
* @since 4.4.1 Added the `use_defaults` parameter.
[77] Fix | Delete
*
[78] Fix | Delete
* @param string[] $hidden Array of IDs of hidden columns.
[79] Fix | Delete
* @param WP_Screen $screen WP_Screen object of the current screen.
[80] Fix | Delete
* @param bool $use_defaults Whether to show the default columns.
[81] Fix | Delete
*/
[82] Fix | Delete
return apply_filters( 'hidden_columns', $hidden, $screen, $use_defaults );
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* Prints the meta box preferences for screen meta.
[87] Fix | Delete
*
[88] Fix | Delete
* @since 2.7.0
[89] Fix | Delete
*
[90] Fix | Delete
* @global array $wp_meta_boxes
[91] Fix | Delete
*
[92] Fix | Delete
* @param WP_Screen $screen
[93] Fix | Delete
*/
[94] Fix | Delete
function meta_box_prefs( $screen ) {
[95] Fix | Delete
global $wp_meta_boxes;
[96] Fix | Delete
[97] Fix | Delete
if ( is_string( $screen ) ) {
[98] Fix | Delete
$screen = convert_to_screen( $screen );
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
if ( empty( $wp_meta_boxes[ $screen->id ] ) ) {
[102] Fix | Delete
return;
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
$hidden = get_hidden_meta_boxes( $screen );
[106] Fix | Delete
[107] Fix | Delete
foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) {
[108] Fix | Delete
foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
[109] Fix | Delete
if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) {
[110] Fix | Delete
continue;
[111] Fix | Delete
}
[112] Fix | Delete
foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) {
[113] Fix | Delete
if ( false == $box || ! $box['title'] ) {
[114] Fix | Delete
continue;
[115] Fix | Delete
}
[116] Fix | Delete
// Submit box cannot be hidden.
[117] Fix | Delete
if ( 'submitdiv' === $box['id'] || 'linksubmitdiv' === $box['id'] ) {
[118] Fix | Delete
continue;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
$widget_title = $box['title'];
[122] Fix | Delete
[123] Fix | Delete
if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
[124] Fix | Delete
$widget_title = $box['args']['__widget_basename'];
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
$is_hidden = in_array( $box['id'], $hidden, true );
[128] Fix | Delete
[129] Fix | Delete
printf(
[130] Fix | Delete
'<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>',
[131] Fix | Delete
esc_attr( $box['id'] ),
[132] Fix | Delete
checked( $is_hidden, false, false ),
[133] Fix | Delete
$widget_title
[134] Fix | Delete
);
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* Gets an array of IDs of hidden meta boxes.
[142] Fix | Delete
*
[143] Fix | Delete
* @since 2.7.0
[144] Fix | Delete
*
[145] Fix | Delete
* @param string|WP_Screen $screen Screen identifier
[146] Fix | Delete
* @return string[] IDs of hidden meta boxes.
[147] Fix | Delete
*/
[148] Fix | Delete
function get_hidden_meta_boxes( $screen ) {
[149] Fix | Delete
if ( is_string( $screen ) ) {
[150] Fix | Delete
$screen = convert_to_screen( $screen );
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
[154] Fix | Delete
[155] Fix | Delete
$use_defaults = ! is_array( $hidden );
[156] Fix | Delete
[157] Fix | Delete
// Hide slug boxes by default.
[158] Fix | Delete
if ( $use_defaults ) {
[159] Fix | Delete
$hidden = array();
[160] Fix | Delete
if ( 'post' === $screen->base ) {
[161] Fix | Delete
if ( in_array( $screen->post_type, array( 'post', 'page', 'attachment' ), true ) ) {
[162] Fix | Delete
$hidden = array( 'slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv' );
[163] Fix | Delete
} else {
[164] Fix | Delete
$hidden = array( 'slugdiv' );
[165] Fix | Delete
}
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
/**
[169] Fix | Delete
* Filters the default list of hidden meta boxes.
[170] Fix | Delete
*
[171] Fix | Delete
* @since 3.1.0
[172] Fix | Delete
*
[173] Fix | Delete
* @param string[] $hidden An array of IDs of meta boxes hidden by default.
[174] Fix | Delete
* @param WP_Screen $screen WP_Screen object of the current screen.
[175] Fix | Delete
*/
[176] Fix | Delete
$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Filters the list of hidden meta boxes.
[181] Fix | Delete
*
[182] Fix | Delete
* @since 3.3.0
[183] Fix | Delete
*
[184] Fix | Delete
* @param string[] $hidden An array of IDs of hidden meta boxes.
[185] Fix | Delete
* @param WP_Screen $screen WP_Screen object of the current screen.
[186] Fix | Delete
* @param bool $use_defaults Whether to show the default meta boxes.
[187] Fix | Delete
* Default true.
[188] Fix | Delete
*/
[189] Fix | Delete
return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
/**
[193] Fix | Delete
* Register and configure an admin screen option
[194] Fix | Delete
*
[195] Fix | Delete
* @since 3.1.0
[196] Fix | Delete
*
[197] Fix | Delete
* @param string $option An option name.
[198] Fix | Delete
* @param mixed $args Option-dependent arguments.
[199] Fix | Delete
*/
[200] Fix | Delete
function add_screen_option( $option, $args = array() ) {
[201] Fix | Delete
$current_screen = get_current_screen();
[202] Fix | Delete
[203] Fix | Delete
if ( ! $current_screen ) {
[204] Fix | Delete
return;
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
$current_screen->add_option( $option, $args );
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
/**
[211] Fix | Delete
* Get the current screen object
[212] Fix | Delete
*
[213] Fix | Delete
* @since 3.1.0
[214] Fix | Delete
*
[215] Fix | Delete
* @global WP_Screen $current_screen WordPress current screen object.
[216] Fix | Delete
*
[217] Fix | Delete
* @return WP_Screen|null Current screen object or null when screen not defined.
[218] Fix | Delete
*/
[219] Fix | Delete
function get_current_screen() {
[220] Fix | Delete
global $current_screen;
[221] Fix | Delete
[222] Fix | Delete
if ( ! isset( $current_screen ) ) {
[223] Fix | Delete
return null;
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
return $current_screen;
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
/**
[230] Fix | Delete
* Set the current screen object
[231] Fix | Delete
*
[232] Fix | Delete
* @since 3.0.0
[233] Fix | Delete
*
[234] Fix | Delete
* @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
[235] Fix | Delete
* or an existing screen object.
[236] Fix | Delete
*/
[237] Fix | Delete
function set_current_screen( $hook_name = '' ) {
[238] Fix | Delete
WP_Screen::get( $hook_name )->set_current_screen();
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function