function my_picu_collection_add_status_admin_column( $columns ) {
$new_columns['selection'] = _x( 'Selection', 'column header', 'picu' );
$offset = 3;
$columns = array_slice( $columns, 0, $offset, true ) + $new_columns + array_slice( $columns, $offset, NULL, true );
return $columns;
}
add_filter( 'manage_picu_collection_posts_columns', 'my_picu_collection_add_status_admin_column', 11 );
function my_picu_column_collection_status( $column, $post_id ) {
$post_status = get_post_status( $post_id );
if ( $column == 'selection' ) {
if ( $post_status == 'delivery-draft' OR $post_status == 'delivered' ) {
echo '-';
}
else {
$total_images = get_post_meta( $post_id, '_picu_collection_gallery_ids', true );
$selected = picu_get_selection_count( $post_id );
echo $selected . ' / ';
echo ( ! empty( $total_images ) ) ? count( explode( ',', $total_images ) ) : '0';
}
}
return $column;
}
add_action( 'manage_picu_collection_posts_custom_column' , 'my_picu_column_collection_status', 10, 2 );
Code language: PHP (php)