<?php
// Listing columns
add_filter( 'manage_' . VA_LISTING_PTYPE . '_posts_columns', 'va_listing_manage_columns', 11 );
add_action( 'manage_' . VA_LISTING_PTYPE . '_posts_custom_column', 'va_listing_add_column_data', 10, 2 );
add_filter( 'manage_edit-' . VA_LISTING_PTYPE . '_sortable_columns', 'va_listing_columns_sort' );
function va_listing_manage_columns( $columns ) {
$comments = $columns['comments'];
$date = $columns['date'];
unset($columns['date']);
unset($columns['comments']);
if ( !empty( $_GET['post_status'] ) && VA_LISTING_PTYPE == $_GET['post_type'] && 'pending-claimed' == $_GET['post_status'] ) {
unset($columns['author']);
$columns['claimee'] = __( 'Claimee', APP_TD );
}
$columns['expire'] = __( 'Expire Date', APP_TD );
$columns['listing_tag'] = __( 'Tags', APP_TD ); // should this set the column title?
$columns['comments'] = $comments;
$columns['date'] = $date;
$columns['thumbnail'] = '';
$columns['claimable'] = '';
return $columns;
}
function va_listing_columns_sort($columns) {
$columns['expire'] = 'expire';
$columns['tax_listing_category'] = 'listing_category';
$columns['tax_listing_tag'] = 'listing_tag';
return $columns;
}
function va_listing_add_column_data( $column_index, $post_id ) {
switch ( $column_index ) {
case 'expire' :
$expiration_date = va_get_listing_exipration_date( $post_id );
echo mysql2date( get_option('date_format'), $expiration_date );
break;
case 'listing_tag' :
$terms = get_the_terms( $post_id, 'listing_tag' );
if ( !empty( $terms ) ) {
$out = array();
/* Loop through each term, linking to the 'edit posts' page for the specific term. */
foreach ( $terms as $term ) {
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'listing_tag' => $term->slug ), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'listing_tag', 'display' ) )
);
}
/* Join the terms, separating them with a comma. */
echo join( ', ', $out );
}
break;
case 'thumbnail' :
the_listing_thumbnail( $post_id );
break;
case 'claimee' :
echo va_get_the_author_listings_link( get_post_meta( $post_id, 'claimee', true ) );
break;
case 'claimable' :
echo '<input type="hidden" name="listing_claimable['.$post_id.']" value="'. ( 1 == get_post_meta( $post_id, 'listing_claimable', true ) ? 1 : '') .'" />';
break;
}
}
// more functions below here....
?>
There are currently 1 users browsing this thread. (0 members and 1 guests)