get_status() && ! current_user_can( 'read_product', $id ) ) ) { return null; } return $product; } /** * Returns the name of the featured product. * * @param \WC_Product $product Product object. * @return string */ protected function get_item_title( $product ) { return $product->get_title(); } /** * Returns the featured product image URL. * * @param \WC_Product $product Product object. * @param string $size Image size, defaults to 'full'. * @return string */ protected function get_item_image( $product, $size = 'full' ) { $image = ''; if ( $product->get_image_id() ) { $image = wp_get_attachment_image_url( $product->get_image_id(), $size ); } elseif ( $product->get_parent_id() ) { $parent_product = wc_get_product( $product->get_parent_id() ); if ( $parent_product ) { $image = wp_get_attachment_image_url( $parent_product->get_image_id(), $size ); } } return $image; } /** * Renders the featured product attributes. * * @param \WC_Product $product Product object. * @param array $attributes Block attributes. Default empty array. * @return string */ protected function render_attributes( $product, $attributes ) { $output = ''; // Backwards compatibility: Only render legacy attributes if `editMode` exists as boolean value // This allows us to distinguish between old and new version of the block (which accept inner blocks). if ( array_key_exists( 'editMode', $attributes ) && is_bool( $attributes['editMode'] ) ) { $legacy_title = sprintf( '