WC_Admin_List_Table::maybe_render_blank_state │ public │ WC 1.0

Show blank slate.

Method of the class: WC_Admin_List_Table{}

No Hooks.

Returns

null. Nothing (null).

Usage

$WC_Admin_List_Table = new WC_Admin_List_Table();
$WC_Admin_List_Table->maybe_render_blank_state( $which );
$which(string) (required)
String which tablenav is being shown.

WC_Admin_List_Table::maybe_render_blank_state() code WC 11.2.1

public function maybe_render_blank_state( $which ) {
	global $post_type, $wp_query;

	if ( $post_type === $this->list_table_type && 'bottom' === $which ) {
		// Performance note: this is a lightweight alternative to wp_count_posts that does not access the cache or apply filters.
		if ( $wp_query && ! empty( $wp_query->posts ) ) {
			return;
		}

		// Performance note: the results of wp_count_posts are cached and at this point populated by status counters.
		$counts = (array) wp_count_posts( $post_type );
		$count  = array_sum( $counts ) - ( $counts['auto-draft'] ?? 0 );
		if ( $count > 0 ) {
			return;
		}

		$this->render_blank_state();

		echo '<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions, .wrap .subsubsub  { display: none; } #posts-filter .tablenav.bottom { height: auto; } </style>';
	}
}