term_id, 'category_color', true );
$thumbnail_id = absint( get_term_meta( $term->term_id, 'thumbnail_id', true ) );
$image = $thumbnail_id ? wp_get_attachment_thumb_url( $thumbnail_id ) : bloglex_placeholder_image();
?>
|
|
|
|
__( 'Choose an image', 'bloglex' ),
'btn_txt' => __( 'Use image', 'bloglex' ),
'img' => esc_js( bloglex_placeholder_image() ),
)
);
}
add_action( 'admin_enqueue_scripts', 'bloglex_admin_category_meta_js' );
// Display category image in admin columns
function bloglex_post_cat_column_head( $columns ) {
$new_columns = array();
if ( isset( $columns['cb'] ) ) {
$new_columns['cb'] = $columns['cb'];
unset( $columns['cb'] );
}
$new_columns['thumb'] = __( 'Image', 'bloglex' );
return array_merge( $new_columns, $columns );
}
add_filter( 'manage_edit-category_columns', 'bloglex_post_cat_column_head' );
function bloglex_post_cat_column_body( $columns, $column, $id ) {
if ( 'thumb' === $column ) {
$thumbnail_id = get_term_meta( $id, 'thumbnail_id', true );
$image = $thumbnail_id ? wp_get_attachment_thumb_url( $thumbnail_id ) : bloglex_placeholder_image();
if (!empty($image)) {
$columns .= '
';
}
}
return $columns;
}
add_filter( 'manage_category_custom_column', 'bloglex_post_cat_column_body', 10, 3 );