WC_Admin_Taxonomies::product_cat_column()
Thumbnail column value added to category admin.
Метод класса: WC_Admin_Taxonomies{}
Хуков нет.
Возвращает
Строку
.
Использование
$WC_Admin_Taxonomies = new WC_Admin_Taxonomies(); $WC_Admin_Taxonomies->product_cat_column( $columns, $column, $id );
- $columns(строка) (обязательный)
- Column HTML output.
- $column(строка) (обязательный)
- Column name.
- $id(int) (обязательный)
- Product ID.
Код WC_Admin_Taxonomies::product_cat_column() WC Admin Taxonomies::product cat column WC 9.6.1
public function product_cat_column( $columns, $column, $id ) { if ( 'thumb' === $column ) { // Prepend tooltip for default category. $default_category_id = absint( get_option( 'default_product_cat', 0 ) ); if ( $default_category_id === $id ) { $columns .= wc_help_tip( __( 'This is the default category and it cannot be deleted. It will be automatically assigned to products with no category.', 'woocommerce' ) ); } $thumbnail_id = get_term_meta( $id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = wp_get_attachment_thumb_url( $thumbnail_id ); } else { $image = wc_placeholder_img_src(); } // Prevent esc_url from breaking spaces in urls for image embeds. Ref: https://core.trac.wordpress.org/ticket/23605 . $image = str_replace( ' ', '%20', $image ); $columns .= '<img src="' . esc_url( $image ) . '" alt="' . esc_attr__( 'Thumbnail', 'woocommerce' ) . '" class="wp-post-image" height="48" width="48" />'; } if ( 'handle' === $column ) { $columns .= '<input type="hidden" name="term_id" value="' . esc_attr( $id ) . '" />'; } return $columns; }