$label ) { if ( 'title' === $key ) { $new['aumnexcart_thumb'] = __( 'Cover', 'aumnexcart' ); $new[ $key ] = $label; $new['aumnexcart_price'] = __( 'Price', 'aumnexcart' ); $new['aumnexcart_attrs'] = __( 'Attributes', 'aumnexcart' ); continue; } $new[ $key ] = $label; } return $new; } /** * @param string $column * @param int $post_id */ public function render_column( $column, $post_id ) { switch ( $column ) { case 'aumnexcart_thumb': $this->render_thumb( $post_id ); break; case 'aumnexcart_price': $str = AumNexCart_Frontend_Hooks::format_price( $post_id ); echo $str ? esc_html( $str ) : '—'; break; case 'aumnexcart_attrs': $rows = AumNexCart_Meta::get_attributes( $post_id ); echo count( $rows ) > 0 ? esc_html( count( $rows ) ) : '—'; break; } } /** * Renders a small thumbnail. Prefers featured image; falls back * to the first media item's URL/thumb_url. * * @param int $post_id */ private function render_thumb( $post_id ) { $src = ''; if ( has_post_thumbnail( $post_id ) ) { $src = get_the_post_thumbnail_url( $post_id, 'thumbnail' ); } else { $items = AumNexCart_Meta::get_media( $post_id ); if ( ! empty( $items ) ) { $first = $items[0]; $src = $first['thumb_url'] ? $first['thumb_url'] : ( 'image' === $first['type'] ? $first['url'] : '' ); } } if ( $src ) { echo ''; } else { echo ''; } } }