is_product_edit_screen() ) { return; } $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min'; wp_enqueue_script( self::SCRIPT_HANDLE, \WC()->plugin_url() . '/assets/js/admin/variation-gallery' . $suffix . '.js', array( 'wc-admin-variation-meta-boxes', 'wp-a11y' ), Constants::get_constant( 'WC_VERSION' ), true ); wp_localize_script( self::SCRIPT_HANDLE, 'wcVariationGalleryL10n', array( 'manageTitle' => __( 'Manage variation gallery', 'woocommerce' ), 'manageButton' => __( 'Update gallery', 'woocommerce' ), 'replaceTitle' => __( 'Replace image', 'woocommerce' ), 'replaceButton' => __( 'Use this image', 'woocommerce' ), 'replaceLabel' => __( 'Replace', 'woocommerce' ), 'addTitle' => __( 'Add images to variation gallery', 'woocommerce' ), 'addButton' => __( 'Add to gallery', 'woocommerce' ), 'emptyCtaLabel' => __( 'Add variation images', 'woocommerce' ), 'announceUpdated' => __( 'Variation gallery updated.', 'woocommerce' ), 'announceReplaced' => __( 'Image replaced.', 'woocommerce' ), 'announceRemoved' => __( 'Image removed from variation gallery.', 'woocommerce' ), 'announceReorder' => __( 'Variation gallery order updated.', 'woocommerce' ), 'announcePrimary' => __( 'New primary image set.', 'woocommerce' ), 'removeLabel' => __( 'Remove image', 'woocommerce' ), 'countZero' => __( 'No images yet', 'woocommerce' ), /* translators: %d: number of variation gallery images */ 'countSingular' => __( '%d image', 'woocommerce' ), /* translators: %d: number of variation gallery images */ 'countPlural' => __( '%d images', 'woocommerce' ), 'primaryLabel' => __( 'Primary', 'woocommerce' ), /* translators: %d: gallery image position */ 'thumbLabel' => __( 'Show gallery image %d', 'woocommerce' ), 'missingFileLabel' => __( 'Attachment file missing', 'woocommerce' ), ) ); wp_enqueue_style( self::STYLE_HANDLE, \WC()->plugin_url() . '/assets/css/variation-gallery-admin.css', array(), Constants::get_constant( 'WC_VERSION' ) ); } /** * Render the variation gallery field. * * @param int $loop Variation row index. * @param array $variation_data Variation data. * @param WP_Post $variation Variation post object. * @return void */ public function render_variation_gallery_field( int $loop, array $variation_data, WP_Post $variation ): void { $variation_object = wc_get_product( $variation->ID ); if ( ! $variation_object instanceof WC_Product_Variation ) { return; } $image_ids = $this->get_display_image_ids( $variation_object ); $count = count( $image_ids ); $field_id = 'variable_gallery_image_ids_' . $loop; $hero_id = $count > 0 ? $image_ids[0] : 0; ?>
>