: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$this->_screen_settings = '';
if ( 'post' === $this->base ) {
$expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
$this->_screen_settings = $expand;
* Filters the screen settings text displayed in the Screen Options tab.
* @param string $screen_settings Screen settings.
* @param WP_Screen $screen WP_Screen object.
$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
if ( $this->_screen_settings || $this->_options ) {
* Filters whether to show the Screen Options tab.
* @param bool $show_screen Whether to show Screen Options tab.
* @param WP_Screen $screen Current WP_Screen instance.
$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
return $this->_show_screen_options;
* Renders the screen options tab.
* @param array $options {
* @type bool $wrap Whether the screen-options-wrap div will be included. Defaults to true.
public function render_screen_options( $options = array() ) {
$options = wp_parse_args(
// Output optional wrapper.
if ( $options['wrap'] ) {
$wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">';
// Don't output the form and nonce for the widgets accessibility mode links.
if ( 'widgets' !== $this->base ) {
$form_start = "\n<form id='adv-settings' method='post'>\n";
$form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
echo $wrapper_start . $form_start;
$this->render_meta_boxes_preferences();
$this->render_list_table_columns_preferences();
$this->render_screen_layout();
$this->render_per_page_options();
$this->render_view_mode();
echo $this->_screen_settings;
* Filters whether to show the Screen Options submit button.
* @param bool $show_button Whether to show Screen Options submit button.
* @param WP_Screen $screen Current WP_Screen instance.
$show_button = apply_filters( 'screen_options_show_submit', false, $this );
submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true );
echo $form_end . $wrapper_end;
* Renders the meta boxes preferences.
* @global array $wp_meta_boxes Global meta box state.
public function render_meta_boxes_preferences() {
if ( ! isset( $wp_meta_boxes[ $this->id ] ) ) {
<fieldset class="metabox-prefs">
<legend><?php _e( 'Screen elements' ); ?></legend>
<?php _e( 'Some screen elements can be shown or hidden by using the checkboxes.' ); ?>
<?php _e( 'Expand or collapse the elements by clicking on their headings, and arrange them by dragging their headings or by clicking on the up and down arrows.' ); ?>
<div class="metabox-prefs-container">
if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
if ( isset( $_GET['welcome'] ) ) {
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
$welcome_checked = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
if ( 2 === $welcome_checked && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) {
$welcome_checked = false;
echo '<label for="wp_welcome_panel-hide">';
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
* Renders the list table columns preferences.
public function render_list_table_columns_preferences() {
$columns = get_column_headers( $this );
$hidden = get_hidden_columns( $this );
$legend = ! empty( $columns['_title'] ) ? $columns['_title'] : __( 'Columns' );
<fieldset class="metabox-prefs">
<legend><?php echo $legend; ?></legend>
$special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
foreach ( $columns as $column => $title ) {
// Can't hide these for they are special.
if ( in_array( $column, $special, true ) ) {
* The Comments column uses HTML in the display name with some screen
* reader text. Make sure to strip tags from the Comments column
* title and any other custom column title plugins might add.
$title = wp_strip_all_tags( $title );
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $column, $hidden, true ), true, false ) . ' />';
* Renders the option for number of columns on the page.
public function render_screen_layout() {
if ( ! $this->get_option( 'layout_columns' ) ) {
$screen_layout_columns = $this->get_columns();
$num = $this->get_option( 'layout_columns', 'max' );
<fieldset class='columns-prefs'>
<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend>
<?php for ( $i = 1; $i <= $num; ++$i ) : ?>
<label class="columns-prefs-<?php echo $i; ?>">
<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>' <?php checked( $screen_layout_columns, $i ); ?> />
/* translators: %s: Number of columns on the page. */
_n( '%s column', '%s columns', $i ),
* Renders the items per page option.
public function render_per_page_options() {
if ( null === $this->get_option( 'per_page' ) ) {
$per_page_label = $this->get_option( 'per_page', 'label' );
if ( null === $per_page_label ) {
$per_page_label = __( 'Number of items per page:' );
$option = $this->get_option( 'per_page', 'option' );
$option = str_replace( '-', '_', "{$this->id}_per_page" );
$per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 ) {
$per_page = $this->get_option( 'per_page', 'default' );
if ( 'edit_comments_per_page' === $option ) {
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
$per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
} elseif ( 'categories_per_page' === $option ) {
/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
$per_page = apply_filters( 'edit_categories_per_page', $per_page );
/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
$per_page = apply_filters( "{$option}", $per_page );
if ( isset( $this->post_type ) ) {
/** This filter is documented in wp-admin/includes/post.php */
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
// This needs a submit button.
add_filter( 'screen_options_show_submit', '__return_true' );
<fieldset class="screen-options">
<legend><?php _e( 'Pagination' ); ?></legend>
<?php if ( $per_page_label ) : ?>
<label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
id="<?php echo esc_attr( $option ); ?>"
value="<?php echo esc_attr( $per_page ); ?>" />
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
* Renders the list table view mode preferences.
* @global string $mode List table view mode.
public function render_view_mode() {
$screen = get_current_screen();
// Currently only enabled for posts and comments lists.
if ( 'edit' !== $screen->base && 'edit-comments' !== $screen->base ) {
$view_mode_post_types = get_post_types( array( 'show_ui' => true ) );
* Filters the post types that have different view mode options.
* @param string[] $view_mode_post_types Array of post types that can change view modes.
* Default post types with show_ui on.
$view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types );
if ( 'edit' === $screen->base && ! in_array( $this->post_type, $view_mode_post_types, true ) ) {
if ( ! isset( $mode ) ) {
$mode = get_user_setting( 'posts_list_mode', 'list' );
// This needs a submit button.
add_filter( 'screen_options_show_submit', '__return_true' );
<fieldset class="metabox-prefs view-mode">
<legend><?php _e( 'View mode' ); ?></legend>
<label for="list-view-mode">
<input id="list-view-mode" type="radio" name="mode" value="list" <?php checked( 'list', $mode ); ?> />
<?php _e( 'Compact view' ); ?>
<label for="excerpt-view-mode">
<input id="excerpt-view-mode" type="radio" name="mode" value="excerpt" <?php checked( 'excerpt', $mode ); ?> />
<?php _e( 'Extended view' ); ?>
* Renders screen reader text.
* @param string $key The screen reader text array named key.
* @param string $tag Optional. The HTML tag to wrap the screen reader text. Default h2.
public function render_screen_reader_content( $key = '', $tag = 'h2' ) {
if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
echo "<$tag class='screen-reader-text'>" . $this->_screen_reader_content[ $key ] . "</$tag>";