Changeset 3836554
- Timestamp:
- 12/01/2026 04:25:31 AM (less than one hour ago)
- Location:
- ar-vr-3d-model-try-on/trunk
- Files:
-
- 5 edited
-
ar-vr-3d-model-try-on.php (modified) (2 diffs)
-
includes/AR_TRY_ON_Frontend.php (modified) (9 diffs)
-
includes/AR_TRY_ON_Viewer.php (modified) (1 diff)
-
public/js/atlas-ar-front.js (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ar-vr-3d-model-try-on/trunk/ar-vr-3d-model-try-on.php
r3829924 r3836554 15 15 * Plugin URI: https://atlasaidev.com/ 16 16 * Description: 3D Model Viewer & WordPress AR Plugin lets you upload and display 3D models with built-in AR on iOS & Android—no extra apps needed. 17 * Version: 3.1. 117 * Version: 3.1.2 18 18 * Author: AtlasAiDev 19 19 * Author URI: https://atlasaidev.com/ … … 153 153 public static function define_constants() { 154 154 if ( ! defined( 'ATLAS_AR_VERSION' ) ) { 155 define( 'ATLAS_AR_VERSION', apply_filters( 'ATLAS_AR_version', '3.1. 1' ) );155 define( 'ATLAS_AR_VERSION', apply_filters( 'ATLAS_AR_version', '3.1.2' ) ); 156 156 } 157 157 -
ar-vr-3d-model-try-on/trunk/includes/AR_TRY_ON_Frontend.php
r3774402 r3836554 36 36 private static $tryon_done = array(); 37 37 38 /** 39 * AR-192: this page's AtlasAR output, each waiting for its WooCommerce hook. 40 * 41 * @var array[] each: done (bool), print (callable), to ('gallery' | 'cart') 42 */ 43 private static $waiting = array(); 44 45 /** @var callable|null AR-192: prints the tab-only 3D view once (in the tab, else at the end of the page) */ 46 private static $tab_print = null; 47 38 48 /** Called on `init` (atlas_ar_run). */ 39 49 public static function init() { … … 42 52 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'quiet_old_pro' ), 6 ); 43 53 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'drop_old_pro_scripts' ), 21 ); 54 add_action( 'wp_footer', array( __CLASS__, 'print_waiting' ), 0 ); // AR-192: before enqueue_if_used 44 55 add_action( 'wp_footer', array( __CLASS__, 'enqueue_if_used' ), 1 ); 45 56 add_filter( 'script_loader_tag', array( __CLASS__, 'no_optimize' ), 10, 2 ); … … 223 234 case 'gallery3d': 224 235 // Printed after the gallery; atlas-ar-front.js moves it over the main image. 225 add_action(226 'woocommerce_before_single_product_summary',236 self::place_once( 237 array( array( 'woocommerce_before_single_product_summary', 25 ) ), 227 238 function () use ( $post_id, $mode ) { 228 239 $html = AR_TRY_ON_Viewer::render( $post_id, 'gallery' ); … … 231 242 } 232 243 }, 233 25244 'gallery' 234 245 ); 235 246 break; 236 247 case 'slide': 237 add_action(238 'woocommerce_product_thumbnails',248 self::place_once( 249 array( array( 'woocommerce_product_thumbnails', 5 ) ), 239 250 function () use ( $post_id ) { 240 251 $html = AR_TRY_ON_Viewer::render( $post_id, 'slide' ); … … 243 254 } 244 255 }, 245 5256 'cart' // no WooCommerce gallery ran, so no slider to join: the view shows by the cart form 246 257 ); 247 258 break; … … 259 270 break; 260 271 } 272 if ( 'tab' === $mode ) { 273 // AR-192: the tab is the only place: a template without WooCommerce's tabs still shows it. 274 self::$tab_print = self::place_once( 275 array(), 276 function () use ( $post_id ) { 277 AR_TRY_ON_Viewer::print_html( AR_TRY_ON_Viewer::render( $post_id, 'tab' ) ); 278 }, 279 'cart' 280 ); 281 } 261 282 if ( 'tab' === $mode || AR_TRY_ON_Settings::get( 'placement.product_tab' ) ) { 262 283 add_filter( 'woocommerce_product_tabs', array( __CLASS__, 'add_tab' ) ); … … 279 300 * shops) gets no "Add to cart" form, so the form's hooks never fire: it also gets $callback late 280 301 * in the product summary, after where the form would be. Printed once, whichever runs first. 281 * Products that can be bought keep the plain hook. 302 * Products that can be bought keep the plain hook. AR-192: when none of them runs, at the end of 303 * the page (place_once). 282 304 * 283 305 * @param string $hook action … … 287 309 */ 288 310 private static function hook_or_summary( $hook, $priority, $post_id, $callback ) { 311 $hooks = array( array( $hook, $priority ) ); 289 312 $form = array( 'woocommerce_before_add_to_cart_form', 'woocommerce_after_add_to_cart_form' ); 290 313 $product = in_array( $hook, $form, true ) ? wc_get_product( $post_id ) : null; 291 if ( ! $product || ( $product->is_purchasable() && $product->is_in_stock() ) ) { 292 add_action( $hook, $callback, $priority ); 314 if ( $product && ! ( $product->is_purchasable() && $product->is_in_stock() ) ) { 315 $hooks[] = array( 'woocommerce_single_product_summary', 35 ); // add to cart is at 30, meta at 40 316 } 317 self::place_once( $hooks, $callback, 'cart' ); 318 } 319 320 /** 321 * AR-192: print $print once, at the first of $hooks that runs. Page-builder product templates 322 * (Impreza and others) skip some WooCommerce hooks (the summary, the tabs): what was hooked there 323 * is printed at the end of the page instead (print_waiting) and atlas-ar-front.js moves it to 324 * $to: 'gallery' (over the main image) or 'cart' (after the add-to-cart form). 325 * 326 * @param array[] $hooks [ action, priority ] pairs 327 * @param callable $print prints the output 328 * @param string $to gallery | cart 329 * @return callable prints it now, unless it was printed already 330 */ 331 private static function place_once( array $hooks, $print, $to ) { 332 $key = count( self::$waiting ); 333 self::$waiting[ $key ] = array( 334 'done' => false, 335 'print' => $print, 336 'to' => $to, 337 ); 338 $once = function () use ( $key ) { 339 self::print_now( $key ); 340 }; 341 foreach ( $hooks as $hook ) { 342 add_action( $hook[0], $once, $hook[1] ); 343 } 344 return $once; 345 } 346 347 /** AR-192: print one waiting output, unless it was printed already. */ 348 private static function print_now( $key ) { 349 if ( ! isset( self::$waiting[ $key ] ) || self::$waiting[ $key ]['done'] ) { 293 350 return; 294 351 } 295 $done = false; 296 $once = function () use ( &$done, $callback ) { 297 if ( ! $done ) { 298 $done = true; 299 $callback(); 300 } 301 }; 302 add_action( $hook, $once, $priority ); 303 add_action( 'woocommerce_single_product_summary', $once, 35 ); // add to cart is at 30, meta at 40 352 self::$waiting[ $key ]['done'] = true; 353 call_user_func( self::$waiting[ $key ]['print'] ); 354 } 355 356 /** 357 * AR-192: on `wp_footer` (before the scripts are chosen), what no hook printed, each in a hidden 358 * box that atlas-ar-front.js moves to its place and shows. Nothing when everything printed. 359 */ 360 public static function print_waiting() { 361 foreach ( array_keys( self::$waiting ) as $key ) { 362 if ( self::$waiting[ $key ]['done'] ) { 363 continue; 364 } 365 ob_start(); 366 self::print_now( $key ); 367 $html = trim( (string) ob_get_clean() ); 368 if ( '' !== $html ) { 369 AR_TRY_ON_Viewer::print_html( '<div class="atlas-ar-moved" data-atlas-ar-to="' . esc_attr( self::$waiting[ $key ]['to'] ) . '" hidden>' . $html . '</div>' ); 370 } 371 } 372 } 373 374 /** Forget this page's placed output (tests: a new page view in the same PHP run). */ 375 public static function forget() { 376 self::$waiting = array(); 377 self::$tryon_done = array(); 378 self::$tab_print = null; 304 379 } 305 380 … … 310 385 'priority' => 15, 311 386 'callback' => function () { 387 if ( self::$tab_print ) { 388 call_user_func( self::$tab_print ); // AR-192: the tab-only view, printed once 389 return; 390 } 312 391 AR_TRY_ON_Viewer::print_html( AR_TRY_ON_Viewer::render( (int) get_queried_object_id(), 'tab' ) ); 313 392 }, -
ar-vr-3d-model-try-on/trunk/includes/AR_TRY_ON_Viewer.php
r3805400 r3836554 277 277 /** Pro adds the attributes of its options (hotspots, dimensions, items, variants…). */ 278 278 $viewer = (array) apply_filters( 'atlas_ar_viewer_allowed_attributes', $viewer ); 279 $box = array( 'class' => true, 'style' => true, 'hidden' => true, 'data-atlas-ar-start' => true, 'data- thumb' => true, 'data-thumb-alt' => true );279 $box = array( 'class' => true, 'style' => true, 'hidden' => true, 'data-atlas-ar-start' => true, 'data-atlas-ar-to' => true, 'data-thumb' => true, 'data-thumb-alt' => true ); // data-atlas-ar-to: AR-192 280 280 return array( 281 281 'atlasar-viewer' => $viewer, -
ar-vr-3d-model-try-on/trunk/public/js/atlas-ar-front.js
r3805400 r3836554 253 253 } 254 254 255 /* ------------------------------------------------------ AR-192: moved */ 256 // A page-builder product template (Impreza and others) skips some WooCommerce hooks, so the 257 // server printed that output at the end of the page: put it in its place. "gallery": the gallery 258 // view finds the main image itself (setupGallery); "cart" (or no gallery): after the add-to-cart 259 // form, else after the gallery; else it stays where it is. 260 function placeMoved() { 261 Array.prototype.forEach.call(document.querySelectorAll('.atlas-ar-moved'), function (box) { 262 var gallery = document.querySelector('.woocommerce-product-gallery'); 263 var form = document.querySelector('form.cart'); 264 var anchor = box.getAttribute('data-atlas-ar-to') === 'gallery' && gallery ? null : (form || gallery); 265 if (anchor && anchor.parentNode) anchor.parentNode.insertBefore(box, anchor.nextSibling); 266 box.hidden = false; 267 }); 268 } 269 255 270 function start() { 271 placeMoved(); 256 272 Array.prototype.forEach.call(document.querySelectorAll('.atlas-ar-gallery'), setupGallery); 257 273 Array.prototype.forEach.call(document.querySelectorAll('.atlas-ar-slide'), setupSlideThumb); -
ar-vr-3d-model-try-on/trunk/readme.txt
r3829924 r3836554 5 5 Tested up to: 7.2 6 6 Requires PHP: 7.4 7 Stable tag: 3.1. 17 Stable tag: 3.1.2 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.txt … … 210 210 == Changelog == 211 211 212 = 3.1.2 ( 1 December 2026 ) = 213 * Fix: The 3D view and the 3D button show again on product pages built with a page builder or a theme's own product layout (for example Impreza). They had disappeared there after updating to AtlasAR 3, while your settings were fine. 214 212 215 = 3.1.1 ( 27 November 2026 ) = 213 216 * Compatibility: Tested with WordPress 7.2. Nothing changes in how the plugin works. … … 570 573 == Upgrade Notice == 571 574 575 = 3.1.2 = 576 Fixes the 3D view and 3D button missing on product pages built with a page builder or a theme's own product layout. Your settings stay as they are. 577 572 578 = 3.1.1 = 573 579 Tested with WordPress 7.2. No other changes, safe to update.
Note:
See TracChangeset
for help on using the changeset viewer.