: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
foreach ( $actions as $action => $link ) {
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
$out .= "<span class='$action'>$link$sep</span>";
$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
* Display a monthly dropdown for filtering items
* @global WP_Locale $wp_locale
* @param string $post_type
protected function months_dropdown( $post_type ) {
global $wpdb, $wp_locale;
* Filter whether to remove the 'Months' drop-down from the post list table.
* @param bool $disable Whether to disable the drop-down. Default false.
* @param string $post_type The post type.
if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
$months = $wpdb->get_results( $wpdb->prepare( "
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
* Filter the 'Months' drop-down results.
* @param object $months The months drop-down query results.
* @param string $post_type The post type.
$months = apply_filters( 'months_dropdown_results', $months, $post_type );
$month_count = count( $months );
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
$m = isset( $_GET['m'] ) ? (int) sanitize_text_field($_GET['m']) : 0;
<label for="filter-by-date" class="screen-reader-text"><?php esc_html_e( 'Filter by date' ); ?></label>
<select name="m" id="filter-by-date">
<option<?php selected( $m, 0 ); ?> value="0"><?php esc_html_e( 'All dates' ); ?></option>
foreach ( $months as $arc_row ) {
if ( 0 == $arc_row->year )
$month = zeroise( $arc_row->month, 2 );
printf( "<option %s value='%s'>%s</option>\n",
selected( $m, $year . $month, false ),
esc_attr( $arc_row->year . $month ),
/* translators: 1: month name, 2: 4-digit year */
sprintf( esc_html__( '%1$s %2$d' ), esc_html($wp_locale->get_month( $month )), esc_html($year) )
* Display a view switcher
* @param string $current_mode
protected function view_switcher( $current_mode ) {
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
<div class="view-switch">
foreach ( $this->modes as $mode => $title ) {
$classes = array( 'view-' . $mode );
if ( $current_mode == $mode )
wp_kses_post( "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n" ),
esc_url( add_query_arg( 'mode', $mode ) ),
esc_html(implode( ' ', $classes )),
* Display a comment count bubble
* @param int $post_id The post ID.
* @param int $pending_comments Number of pending comments.
protected function comments_bubble( $post_id, $pending_comments ) {
$approved_comments = get_comments_number();
$approved_comments_number = number_format_i18n( $approved_comments );
$pending_comments_number = number_format_i18n( $pending_comments );
/* translators: numner comments, numner approved comments */
$approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
/* translators: numner comments, numner approved comments */
$approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
/* translators: numner comments, numner pending comments */
$pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
if ( ! $approved_comments && ! $pending_comments ) {
printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
esc_html__( 'No comments' )
// Approved comments have different display depending on some conditions.
} elseif ( $approved_comments ) {
printf( wp_kses_post('<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>' ),
esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ),
esc_html($approved_comments_number),
$pending_comments ? esc_html($approved_phrase) : esc_html($approved_only_phrase)
printf( wp_kses_post( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>'),
esc_html($approved_comments_number),
$pending_comments ? esc_html__( 'No approved comments' ) : esc_html__( 'No comments' )
if ( $pending_comments ) {
printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ),
esc_html($pending_comments_number),
esc_html($pending_phrase)
* Get the current page number
public function get_pagenum() {
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
$pagenum = $this->_pagination_args['total_pages'];
return max( 1, $pagenum );
* Get number of items to display on a single page
protected function get_items_per_page( $option, $default = 20 ) {
$per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 )
* Filter the number of items to be displayed on each page of the list table.
* The dynamic hook name, $option, refers to the `per_page` option depending
* on the type of list table in use. Possible values include: 'edit_comments_per_page',
* 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page',
* 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page',
* 'edit_{$post_type}_per_page', etc.
* @param int $per_page Number of items to be displayed. Default 20.
return (int) apply_filters( $option, $per_page );
* Display the pagination.
protected function pagination( $which ) {
if ( empty( $this->_pagination_args ) ) {
$total_items = $this->_pagination_args['total_items'];
$total_pages = $this->_pagination_args['total_pages'];
$infinite_scroll = false;
if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
/* translators: total items */
$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
$current = $this->get_pagenum();
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$sbpb_server_host = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field( $_SERVER['HTTP_HOST'] ) : '';
$sbpb_server_requesturi = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '';
$current_url = set_url_scheme( 'http://' . $sbpb_server_host . $sbpb_server_requesturi );
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
$total_pages_before = '<span class="paging-input">';
$total_pages_after = '</span>';
$disable_first = $disable_last = $disable_prev = $disable_next = false;
if ( $current == $total_pages ) {
if ( $current == $total_pages - 1 ) {
$page_links[] = '<span class="tablenav-pages-navspan disabled" aria-hidden="true">«</span>';
$page_links[] = sprintf( "<a class='first-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( remove_query_arg( 'paged', $current_url ) ),
$page_links[] = '<span class="tablenav-pages-navspan disabled" aria-hidden="true">‹</span>';
$page_links[] = sprintf( "<a class='prev-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
if ( 'bottom' == $which ) {
$html_current_page = $current;
$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input">';
$html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
/* translators: current page, total pages */
$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
$page_links[] = '<span class="tablenav-pages-navspan disabled" aria-hidden="true">›</span>';
$page_links[] = sprintf( "<a class='next-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
$page_links[] = '<span class="tablenav-pages-navspan disabled" aria-hidden="true">»</span>';
$page_links[] = sprintf( "<a class='last-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
$pagination_links_class = 'pagination-links';
if ( ! empty( $infinite_scroll ) ) {
$pagination_links_class = ' hide-if-js';
$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
$page_class = $total_pages < 2 ? ' one-page' : '';
$page_class = ' no-pages';
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
echo wp_kses($this->_pagination, AdminHelper::allowed_html_tags());
* Get a list of columns. The format is:
* 'internal-name' => 'Title'
public function get_columns() {
die( 'function WPCListTable::get_columns() must be over-ridden in a sub-class.' );
* Get a list of sortable columns. The format is:
* 'internal-name' => 'orderby'
* 'internal-name' => array( 'orderby', true )
* The second format will make the initial sorting order be descending
protected function get_sortable_columns() {
* Gets the name of the default primary column.
* @return string Name of the default primary column, in this case, an empty string.
protected function get_default_primary_column_name() {
$columns = $this->get_columns();
// We need a primary defined so responsive views show something,
// so let's fall back to the first non-checkbox column.
foreach( $columns as $col => $column_name ) {
* Gets the name of the primary column.
* @return string The name of the primary column.
protected function get_primary_column_name() {
$columns = $this->get_columns();
$default = $this->get_default_primary_column_name();
// If the primary column doesn't exist fall back to the
// first non-checkbox column.
if ( ! isset( $columns[ $default ] ) ) {
$default = $this->get_default_primary_column_name();
* Filter the name of the primary column for the current list table.
* @param string $default Column name default for the specific list table, e.g. 'name'.
* @param string $context Screen ID for specific list table, e.g. 'plugins'.
$column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
* Get a list of all, hidden and sortable columns, with filter applied
protected function get_column_info() {
// $_column_headers is already set / cached
if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
// Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
// In 4.3, we added a fourth argument for primary column.
$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
foreach ( $this->_column_headers as $key => $value ) {
$column_headers[ $key ] = $value;
$columns = get_column_headers( $this->screen );
$hidden = get_hidden_columns( $this->screen );
$sortable_columns = $this->get_sortable_columns();
* Filter the list table sortable columns for a specific screen.
* The dynamic portion of the hook name, `$this->screen->id`, refers
* to the ID of the current screen, usually a string.
* @param array $sortable_columns An array of sortable columns.
$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
foreach ( $_sortable as $id => $data ) {
if ( !isset( $data[1] ) )
$primary = $this->get_primary_column_name();
$this->_column_headers = array( $columns, $hidden, $sortable, $primary );
return $this->_column_headers;
* Return number of visible columns
public function get_column_count() {
list ( $columns, $hidden ) = $this->get_column_info();
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
return count( $columns ) - count( $hidden );
* Print column headers, accounting for hidden and sortable columns.