_args['singular'];
$this->display_tablenav( 'top' );
$this->screen->render_screen_reader_content( 'heading_list' );
$user = wp_get_current_user();
$theme = get_option('cheritto-admin-grid-theme-' . $user->user_nicename);
if (!$theme) $container_bg_class = 'cheritto-admin-grid-bg-ice';
else $container_bg_class = 'cheritto-admin-grid-bg-' . $theme;
?>
display_rows_or_placeholder(); ?>
display_tablenav( 'bottom' );
}
/**
* Gets a list of CSS classes for the WP_List_Table table tag.
*
* @since 3.1.0
*
* @return string[] Array of CSS classes for the table tag.
*/
protected function get_table_classes() {
$mode = get_user_setting( 'posts_list_mode', 'list' );
$mode_class = esc_attr( 'table-view-' . $mode );
return array( 'widefat', 'fixed', 'striped', $mode_class, $this->_args['plural'] );
}
/**
* Generates the table navigation above or below the table
*
* @since 3.1.0
* @param string $which
*/
protected function display_tablenav( $which ) {
if ( 'top' === $which ) {
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
}
?>
has_items() ) : ?>
bulk_actions( $which ); ?>
extra_tablenav( $which );
$this->pagination( $which );
?>
has_items() ) {
$this->display_rows();
} else {
echo '';
$this->no_items();
echo ' ';
}
}
/**
* Generates the table rows.
*
* @since 3.1.0
*/
public function display_rows() {
foreach ( $this->items as $item ) {
$this->single_row( $item );
}
}
/**
* Generates content for a single row of the table.
*
* @since 3.1.0
*
* @param object|array $item The current item
*/
public function single_row( $item ) {
//echo '';
$this->single_row_columns( $item );
//echo ' ';
}
/**
* @param object|array $item
* @param string $column_name
*/
protected function column_default( $item, $column_name ) {}
/**
* @param object|array $item
*/
protected function column_cb( $item ) {}
/**
* Generates the columns for a single row of the table.
*
* @since 3.1.0
*
* @param object|array $item The current item.
*/
protected function single_row_columns( $item ) {
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
$user = wp_get_current_user();
foreach ( $columns as $column_name => $column_display_name ) {
if ( in_array($column_name,['image','title','actions','author','tags','categories','date','cb']) ) {
$show = get_option('cheritto-admin-grid-show-'.$column_name.'-' . $user->user_nicename);
if(!$show) continue;
}
if ($column_name!='comments')
echo '';
$classes = "$column_name column-$column_name";
if ( $primary === $column_name ) {
$classes .= ' has-row-actions column-primary';
}
if ( in_array( $column_name, $hidden, true ) ) {
$classes .= ' hidden';
}
// Comments column uses HTML in the display name with screen reader text.
// Strip tags to get closer to a user-friendly string.
$data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"';
$attributes = "class='$classes' $data";
if ( 'cb' === $column_name ) {
//echo '
';
echo $this->column_cb( $item );
//echo ' ';
} elseif ( method_exists( $this, '_column_' . $column_name ) ) {
echo call_user_func(
array( $this, '_column_' . $column_name ),
$item,
$classes,
$data,
$primary
);
} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
//echo "";
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
echo $this->handle_row_actions( $item, $column_name, $primary );
//echo ' ';
} else {
//echo "";
echo $this->column_default( $item, $column_name );
echo $this->handle_row_actions( $item, $column_name, $primary );
//echo ' ';
}
if ($column_name!='comments')
echo '';
}
}
/**
* Generates and display row actions links for the list table.
*
* @since 4.3.0
*
* @param object|array $item The item being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string The row actions HTML, or an empty string
* if the current column is not the primary column.
*/
protected function handle_row_actions( $item, $column_name, $primary ) {
return $column_name === $primary ? '' . __( 'Show more details' ) . ' ' : '';
}
protected function row_actions( $actions, $always_visible = false ) {
$action_count = count( $actions );
if ( ! $action_count ) {
return '';
}
$mode = get_user_setting( 'posts_list_mode', 'list' );
//if ( 'excerpt' === $mode ) {
$always_visible = true;
//}
$out = '';
$i = 0;
foreach ( $actions as $action => $link ) {
++$i;
$sep = ( $i < $action_count ) ? ' | ' : '';
$out .= "$link$sep ";
}
$out .= '
';
$out .= '' . __( 'Show more details' ) . ' ';
return $out;
}
/**
* Handles an incoming ajax request (called from admin-ajax.php)
*
* @since 3.1.0
*/
public function ajax_response() {
$this->prepare_items();
ob_start();
if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
$this->display_rows();
} else {
$this->display_rows_or_placeholder();
}
$rows = ob_get_clean();
$response = array( 'rows' => $rows );
if ( isset( $this->_pagination_args['total_items'] ) ) {
$response['total_items_i18n'] = sprintf(
/* translators: Number of items. */
_n( '%s item', '%s items', $this->_pagination_args['total_items'] ),
number_format_i18n( $this->_pagination_args['total_items'] )
);
}
if ( isset( $this->_pagination_args['total_pages'] ) ) {
$response['total_pages'] = $this->_pagination_args['total_pages'];
$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
}
die( wp_json_encode( $response ) );
}
/**
* Sends required variables to JavaScript land.
*
* @since 3.1.0
*/
public function _js_vars() {
$args = array(
'class' => get_class( $this ),
'screen' => array(
'id' => $this->screen->id,
'base' => $this->screen->base,
),
);
printf( "\n", wp_json_encode( $args ) );
}
public function views() {
$views = $this->get_views();
/**
* Filters the list of available list table views.
*
* The dynamic portion of the hook name, `$this->screen->id`, refers
* to the ID of the current screen.
*
* @since 3.1.0
*
* @param string[] $views An array of available list table views.
*/
$views = apply_filters( "views_{$this->screen->id}", $views );
if ( empty( $views ) ) {
return;
}
$this->screen->render_screen_reader_content( 'heading_views' );
echo "\n";
foreach ( $views as $class => $view ) {
$view = str_replace("?","&",$view);
$view = str_replace("edit.php","admin.php?page=admin-posts-grid%2Fincludes%2Fwp-admin%2Fedit.php",$view);
$views[ $class ] = "\t$view";
}
echo implode( " | \n", $views ) . "\n";
echo ' ';
}
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 );
$approved_only_phrase = sprintf(
/* translators: %s: Number of comments. */
_n( '%s comment', '%s comments', $approved_comments ),
$approved_comments_number
);
$approved_phrase = sprintf(
/* translators: %s: Number of comments. */
_n( '%s approved comment', '%s approved comments', $approved_comments ),
$approved_comments_number
);
$pending_phrase = sprintf(
/* translators: %s: Number of comments. */
_n( '%s pending comment', '%s pending comments', $pending_comments ),
$pending_comments_number
);
if ( ! $approved_comments && ! $pending_comments ) {
// No comments at all.
printf(
'%s ',
__( 'No comments' )
);
} elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {
// Don't link the comment bubble for a trashed post.
printf(
'%s ',
$approved_comments_number,
$pending_comments ? $approved_phrase : $approved_only_phrase
);
} elseif ( $approved_comments ) {
// Link the comment bubble to approved comments.
printf(
'%s ',
esc_url(
add_query_arg(
array(
'p' => $post_id,
'comment_status' => 'approved',
),
admin_url( 'edit-comments.php' )
)
),
$approved_comments_number,
$pending_comments ? $approved_phrase : $approved_only_phrase
);
} else {
// Don't link the comment bubble when there are no approved comments.
printf(
'',
$approved_comments_number,
$pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
);
}
if ( $pending_comments ) {
printf(
'%s ',
esc_url(
add_query_arg(
array(
'p' => $post_id,
'comment_status' => 'moderated',
),
admin_url( 'edit-comments.php' )
)
),
$pending_comments_number,
$pending_phrase
);
} else {
printf(
'%s ',
$pending_comments_number,
$approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
);
}
}
}