'; echo '

' . esc_html__( 'Ready to start selling something awesome?', 'woocommerce' ) . '

'; echo '
'; echo '' . esc_html__( 'Create Product', 'woocommerce' ) . ''; echo '' . esc_html__( 'Start Import', 'woocommerce' ) . ''; echo '
'; do_action( 'wc_marketplace_suggestions_products_empty_state' ); echo ''; } /** * Define primary column. * * @return string */ protected function get_primary_column() { return 'name'; } /** * Get row actions to show in the list table. * * @param array $actions Array of actions. * @param WP_Post $post Current post object. * @return array */ protected function get_row_actions( $actions, $post ) { /* translators: %d: product ID. */ return array_merge( array( 'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $post->ID ) ), $actions ); } /** * Define which columns are sortable. * * @param array $columns Existing columns. * @return array */ public function define_sortable_columns( $columns ) { $custom = array( 'price' => 'price', 'sku' => 'sku', 'name' => 'title', ); return wp_parse_args( $custom, $columns ); } /** * Define which columns to show on this screen. * * @param array $columns Existing columns. * @return array */ public function define_columns( $columns ) { if ( empty( $columns ) && ! is_array( $columns ) ) { $columns = array(); } unset( $columns['title'], $columns['comments'], $columns['date'] ); $show_columns = array(); $show_columns['cb'] = ''; $show_columns['thumb'] = '' . __( 'Image', 'woocommerce' ) . ''; $show_columns['name'] = __( 'Name', 'woocommerce' ); if ( wc_product_sku_enabled() ) { $show_columns['sku'] = __( 'SKU', 'woocommerce' ); } if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) { $show_columns['is_in_stock'] = __( 'Stock', 'woocommerce' ); } $show_columns['price'] = __( 'Price', 'woocommerce' ); $show_columns['product_cat'] = __( 'Categories', 'woocommerce' ); $show_columns['product_tag'] = __( 'Tags', 'woocommerce' ); $show_columns['featured'] = '' . __( 'Featured', 'woocommerce' ) . ''; $show_columns['date'] = __( 'Date', 'woocommerce' ); return array_merge( $show_columns, $columns ); } /** * Pre-fetch any data for the row each column has access to it. the_product global is there for bw compat. * * @param int $post_id Post ID being shown. */ protected function prepare_row_data( $post_id ) { global $the_product; if ( empty( $this->object ) || $this->object->get_id() !== $post_id ) { $the_product = wc_get_product( $post_id ); $this->object = $the_product; } } /** * Render column: thumb. */ protected function render_thumb_column() { echo '' . $this->object->get_image( 'thumbnail' ) . ''; // WPCS: XSS ok. } /** * Render column: name. */ protected function render_name_column() { global $post; $edit_link = get_edit_post_link( $this->object->get_id() ); $title = _draft_or_post_title(); echo '' . esc_html( $title ) . ''; _post_states( $post ); echo ''; if ( $this->object->get_parent_id() > 0 ) { echo '  ← ' . get_the_title( $this->object->get_parent_id() ) . ''; // @codingStandardsIgnoreLine. } get_inline_data( $post ); /* Custom inline data for woocommerce. */ echo ' '; } /** * Render column: sku. */ protected function render_sku_column() { echo $this->object->get_sku() ? esc_html( $this->object->get_sku() ) : ''; } /** * Render column: price. */ protected function render_price_column() { echo $this->object->get_price_html() ? wp_kses_post( $this->object->get_price_html() ) : ''; } /** * Render column: product_cat. */ protected function render_product_cat_column() { $terms = get_the_terms( $this->object->get_id(), 'product_cat' ); if ( ! $terms ) { echo ''; } else { $termlist = array(); foreach ( $terms as $term ) { $termlist[] = '' . esc_html( $term->name ) . ''; } echo apply_filters( 'woocommerce_admin_product_term_list', implode( ', ', $termlist ), 'product_cat', $this->object->get_id(), $termlist, $terms ); // WPCS: XSS ok. } } /** * Render column: product_tag. */ protected function render_product_tag_column() { $terms = get_the_terms( $this->object->get_id(), 'product_tag' ); if ( ! $terms ) { echo ''; } else { $termlist = array(); foreach ( $terms as $term ) { $termlist[] = '' . esc_html( $term->name ) . ''; } echo apply_filters( 'woocommerce_admin_product_term_list', implode( ', ', $termlist ), 'product_tag', $this->object->get_id(), $termlist, $terms ); // WPCS: XSS ok. } } /** * Render column: featured. */ protected function render_featured_column() { $url = wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_feature_product&product_id=' . $this->object->get_id() ), 'woocommerce-feature-product' ); echo ''; if ( $this->object->is_featured() ) { echo '' . esc_html__( 'Yes', 'woocommerce' ) . ''; } else { echo '' . esc_html__( 'No', 'woocommerce' ) . ''; } echo ''; } /** * Render column: is_in_stock. */ protected function render_is_in_stock_column() { if ( $this->object->is_on_backorder() ) { $stock_html = '' . __( 'On backorder', 'woocommerce' ) . ''; } elseif ( $this->object->is_in_stock() ) { $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; } else { $stock_html = '' . __( 'Out of stock', 'woocommerce' ) . ''; } if ( $this->object->managing_stock() ) { $stock_html .= ' (' . wc_stock_amount( $this->object->get_stock_quantity() ) . ')'; } echo wp_kses_post( apply_filters( 'woocommerce_admin_stock_html', $stock_html, $this->object ) ); } /** * Query vars for custom searches. * * @param mixed $public_query_vars Array of query vars. * @return array */ public function add_custom_query_var( $public_query_vars ) { $public_query_vars[] = 'sku'; return $public_query_vars; } /** * Render any custom filters and search inputs for the list table. */ protected function render_filters() { $filters = apply_filters( 'woocommerce_products_admin_list_table_filters', array( 'product_category' => array( $this, 'render_products_category_filter' ), 'product_type' => array( $this, 'render_products_type_filter' ), 'stock_status' => array( $this, 'render_products_stock_status_filter' ), ) ); ob_start(); foreach ( $filters as $filter_callback ) { call_user_func( $filter_callback ); } $output = ob_get_clean(); echo apply_filters( 'woocommerce_product_filters', $output ); // WPCS: XSS ok. } /** * Render the product category filter for the list table. * * @since 3.5.0 */ protected function render_products_category_filter() { $categories_count = (int) wp_count_terms( 'product_cat' ); if ( $categories_count <= apply_filters( 'woocommerce_product_category_filter_threshold', 100 ) ) { wc_product_dropdown_categories( array( 'option_select_text' => __( 'Filter by category', 'woocommerce' ), 'hide_empty' => 0, ) ); } else { $current_category_slug = isset( $_GET['product_cat'] ) ? wc_clean( wp_unslash( $_GET['product_cat'] ) ) : false; // WPCS: input var ok, CSRF ok. $current_category = $current_category_slug ? get_term_by( 'slug', $current_category_slug, 'product_cat' ) : false; ?> '; foreach ( wc_get_product_types() as $value => $label ) { $output .= '