Changeset 3388695
- Timestamp:
- 11/03/2025 08:55:51 AM (4 months ago)
- Location:
- spiraclethemes-site-library
- Files:
-
- 180 added
- 8 edited
-
tags/1.5.7 (added)
-
tags/1.5.7/Changelogs.txt (added)
-
tags/1.5.7/LICENSE (added)
-
tags/1.5.7/README.txt (added)
-
tags/1.5.7/admin (added)
-
tags/1.5.7/admin/admin-init.php (added)
-
tags/1.5.7/admin/assets (added)
-
tags/1.5.7/admin/assets/css (added)
-
tags/1.5.7/admin/assets/css/admin.css (added)
-
tags/1.5.7/admin/assets/css/toggle-switch.css (added)
-
tags/1.5.7/admin/assets/images (added)
-
tags/1.5.7/admin/assets/images/menu-icon.png (added)
-
tags/1.5.7/admin/assets/js (added)
-
tags/1.5.7/admin/assets/js/admin-plugin-settings.js (added)
-
tags/1.5.7/admin/assets/js/admin.js (added)
-
tags/1.5.7/admin/includes (added)
-
tags/1.5.7/admin/includes/system-info.php (added)
-
tags/1.5.7/admin/includes/system-settings.php (added)
-
tags/1.5.7/css (added)
-
tags/1.5.7/css/main.css (added)
-
tags/1.5.7/elements (added)
-
tags/1.5.7/elements/blogson (added)
-
tags/1.5.7/elements/blogson/helper-functions.php (added)
-
tags/1.5.7/elements/blogson/post-grid (added)
-
tags/1.5.7/elements/blogson/post-grid/template (added)
-
tags/1.5.7/elements/blogson/post-grid/template/config.php (added)
-
tags/1.5.7/elements/blogson/post-grid/template/view.php (added)
-
tags/1.5.7/elements/blogson/widget-category.php (added)
-
tags/1.5.7/elements/blogson/widgets.php (added)
-
tags/1.5.7/elements/own-shop (added)
-
tags/1.5.7/elements/own-shop/featured-prod (added)
-
tags/1.5.7/elements/own-shop/featured-prod/template (added)
-
tags/1.5.7/elements/own-shop/featured-prod/template/config.php (added)
-
tags/1.5.7/elements/own-shop/featured-prod/template/view.php (added)
-
tags/1.5.7/elements/own-shop/helper-functions.php (added)
-
tags/1.5.7/elements/own-shop/list-prod (added)
-
tags/1.5.7/elements/own-shop/list-prod/template (added)
-
tags/1.5.7/elements/own-shop/list-prod/template/config.php (added)
-
tags/1.5.7/elements/own-shop/list-prod/template/view.php (added)
-
tags/1.5.7/elements/own-shop/new-prod (added)
-
tags/1.5.7/elements/own-shop/new-prod/template (added)
-
tags/1.5.7/elements/own-shop/new-prod/template/config.php (added)
-
tags/1.5.7/elements/own-shop/new-prod/template/view.php (added)
-
tags/1.5.7/elements/own-shop/popular-prod (added)
-
tags/1.5.7/elements/own-shop/popular-prod/template (added)
-
tags/1.5.7/elements/own-shop/popular-prod/template/config.php (added)
-
tags/1.5.7/elements/own-shop/popular-prod/template/view.php (added)
-
tags/1.5.7/elements/own-shop/recent-blog (added)
-
tags/1.5.7/elements/own-shop/recent-blog/template (added)
-
tags/1.5.7/elements/own-shop/recent-blog/template/config.php (added)
-
tags/1.5.7/elements/own-shop/recent-blog/template/view.php (added)
-
tags/1.5.7/elements/own-shop/widget-category.php (added)
-
tags/1.5.7/elements/own-shop/widgets.php (added)
-
tags/1.5.7/img (added)
-
tags/1.5.7/img/moredemo.jpg (added)
-
tags/1.5.7/img/no-image.jpg (added)
-
tags/1.5.7/img/rocket.svg (added)
-
tags/1.5.7/inc (added)
-
tags/1.5.7/inc/blogson-functions.php (added)
-
tags/1.5.7/inc/colon-functions.php (added)
-
tags/1.5.7/inc/colon-plus-functions.php (added)
-
tags/1.5.7/inc/crater-free-functions.php (added)
-
tags/1.5.7/inc/krystal-business-functions.php (added)
-
tags/1.5.7/inc/krystal-functions.php (added)
-
tags/1.5.7/inc/krystal-lawyer-functions.php (added)
-
tags/1.5.7/inc/krystal-shop-functions.php (added)
-
tags/1.5.7/inc/lawfiz-functions.php (added)
-
tags/1.5.7/inc/lawfiz-one-functions.php (added)
-
tags/1.5.7/inc/legalblow-functions.php (added)
-
tags/1.5.7/inc/mestore-functions.php (added)
-
tags/1.5.7/inc/own-shop-functions.php (added)
-
tags/1.5.7/inc/own-shop-lite-functions.php (added)
-
tags/1.5.7/inc/own-shop-trend-functions.php (added)
-
tags/1.5.7/inc/own-shope-functions.php (added)
-
tags/1.5.7/inc/own-store-functions.php (added)
-
tags/1.5.7/inc/purea-fashion-functions.php (added)
-
tags/1.5.7/inc/purea-magazine-functions.php (added)
-
tags/1.5.7/inc/somalite-functions.php (added)
-
tags/1.5.7/inc/themes.php (added)
-
tags/1.5.7/inc/widget (added)
-
tags/1.5.7/inc/widget/widget.php (added)
-
tags/1.5.7/index.php (added)
-
tags/1.5.7/spiraclethemes-site-library.php (added)
-
tags/1.5.7/vendor (added)
-
tags/1.5.7/vendor/admin-notices (added)
-
tags/1.5.7/vendor/admin-notices/AdminNotice.php (added)
-
tags/1.5.7/vendor/admin-notices/LICENSE.txt (added)
-
tags/1.5.7/vendor/admin-notices/README.md (added)
-
tags/1.5.7/vendor/admin-notices/bin (added)
-
tags/1.5.7/vendor/admin-notices/bin/install-wp-tests.sh (added)
-
tags/1.5.7/vendor/admin-notices/dismiss-notice.js (added)
-
tags/1.5.7/vendor/ocdi (added)
-
tags/1.5.7/vendor/ocdi/assets (added)
-
tags/1.5.7/vendor/ocdi/assets/css (added)
-
tags/1.5.7/vendor/ocdi/assets/css/main.css (added)
-
tags/1.5.7/vendor/ocdi/assets/css/main.min.css (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/about-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/book-now-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/contact-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/faq-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/meet-the-team-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/menu-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/portfolio-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/services-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/shop-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/demo-content/testimonials-page.xml (added)
-
tags/1.5.7/vendor/ocdi/assets/images (added)
-
tags/1.5.7/vendor/ocdi/assets/images/error.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/brush.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/check-solid-white.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/content.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/copy.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/info-circle.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/layout.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/lock.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/long-arrow-alt-left-blue.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/plugins.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/question-circle.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/redux.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/star.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/icons/widgets.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/importing.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/loader.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/success.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/images/warning.svg (added)
-
tags/1.5.7/vendor/ocdi/assets/js (added)
-
tags/1.5.7/vendor/ocdi/assets/js/main.js (added)
-
tags/1.5.7/vendor/ocdi/assets/js/main.min.js (added)
-
tags/1.5.7/vendor/ocdi/inc (added)
-
tags/1.5.7/vendor/ocdi/inc/CreateDemoContent (added)
-
tags/1.5.7/vendor/ocdi/inc/CreateDemoContent/DemoContentCreator.php (added)
-
tags/1.5.7/vendor/ocdi/inc/CustomizerImporter.php (added)
-
tags/1.5.7/vendor/ocdi/inc/CustomizerOption.php (added)
-
tags/1.5.7/vendor/ocdi/inc/Downloader.php (added)
-
tags/1.5.7/vendor/ocdi/inc/Helpers.php (added)
-
tags/1.5.7/vendor/ocdi/inc/ImportActions.php (added)
-
tags/1.5.7/vendor/ocdi/inc/Importer.php (added)
-
tags/1.5.7/vendor/ocdi/inc/Logger.php (added)
-
tags/1.5.7/vendor/ocdi/inc/OneClickDemoImport.php (added)
-
tags/1.5.7/vendor/ocdi/inc/PluginInstaller.php (added)
-
tags/1.5.7/vendor/ocdi/inc/PluginInstallerSkin.php (added)
-
tags/1.5.7/vendor/ocdi/inc/PluginInstallerSkinSilent.php (added)
-
tags/1.5.7/vendor/ocdi/inc/ReduxImporter.php (added)
-
tags/1.5.7/vendor/ocdi/inc/ViewHelpers.php (added)
-
tags/1.5.7/vendor/ocdi/inc/WPCLICommands.php (added)
-
tags/1.5.7/vendor/ocdi/inc/WXRImporter.php (added)
-
tags/1.5.7/vendor/ocdi/inc/WidgetImporter.php (added)
-
tags/1.5.7/vendor/ocdi/one-click-demo-import.php (added)
-
tags/1.5.7/vendor/ocdi/vendor (added)
-
tags/1.5.7/vendor/ocdi/vendor/autoload.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2 (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/README.md (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/composer.json (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/src (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/src/Importer.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/src/WPImporterLogger.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/src/WPImporterLoggerCLI.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/src/WXRImportInfo.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/awesomemotive/wp-content-importer-v2/src/WXRImporter.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/ClassLoader.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/LICENSE (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/autoload_classmap.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/autoload_namespaces.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/autoload_psr4.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/autoload_real.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/autoload_static.php (added)
-
tags/1.5.7/vendor/ocdi/vendor/composer/installed.json (added)
-
tags/1.5.7/vendor/ocdi/views (added)
-
tags/1.5.7/vendor/ocdi/views/create-content.php (added)
-
tags/1.5.7/vendor/ocdi/views/import.php (added)
-
tags/1.5.7/vendor/ocdi/views/install-plugins.php (added)
-
tags/1.5.7/vendor/ocdi/views/plugin-page.php (added)
-
trunk/Changelogs.txt (modified) (1 diff)
-
trunk/README.txt (modified) (1 diff)
-
trunk/css/own-shop-quick-view.css (added)
-
trunk/css/own-store-quick-view.css (added)
-
trunk/inc/own-shop-functions.php (modified) (2 diffs)
-
trunk/inc/own-shop-lite-functions.php (modified) (2 diffs)
-
trunk/inc/own-shop-trend-functions.php (modified) (1 diff)
-
trunk/inc/own-shope-functions.php (modified) (2 diffs)
-
trunk/inc/own-store-functions.php (modified) (2 diffs)
-
trunk/js (added)
-
trunk/js/own-shop-quick-view.js (added)
-
trunk/spiraclethemes-site-library.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
spiraclethemes-site-library/trunk/Changelogs.txt
r3360556 r3388695 1 1 2 2 == Changelog == 3 4 == 1.5.8 == 5 - Fixed some issues 3 6 4 7 == 1.5.7 == -
spiraclethemes-site-library/trunk/README.txt
r3360556 r3388695 3 3 Contributors: spiraclethemes 4 4 Tags: spiraclethemes, demo, import, themes 5 Stable tag: 1.5. 75 Stable tag: 1.5.8 6 6 Requires at least: 5.0 7 7 Requires PHP: 5.6 -
spiraclethemes-site-library/trunk/inc/own-shop-functions.php
r3327924 r3388695 87 87 'name' => 'WooCommerce', 88 88 'slug' => 'woocommerce', 89 'required' => true,90 ],91 [92 'name' => 'YITH WooCommerce Quick View',93 'slug' => 'yith-woocommerce-quick-view',94 89 'required' => true, 95 90 ], … … 446 441 add_shortcode('recentblog', 'spiraclethemes_site_library_own_shop_recentblog'); 447 442 } 443 444 /** 445 * Quick View Functions 446 */ 447 448 /** 449 * Add Quick View Button to WooCommerce Product Loop 450 */ 451 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_button') ) { 452 function spiraclethemes_site_library_own_shop_add_quick_view_button() { 453 global $product; 454 if ( $product && is_a( $product, 'WC_Product' ) ) { 455 echo '<a href="#" class="own-shop-quick-view-btn" data-product-id="' . esc_attr( $product->get_id() ) . '" data-product-type="' . esc_attr( $product->get_type() ) . '" aria-label="' . esc_attr__( 'Quick View', 'spiraclethemes-site-library' ) . '"></a>'; 456 } 457 } 458 } 459 460 /** 461 * Enqueue Quick View Scripts 462 */ 463 if( !function_exists('spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts') ) { 464 function spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts() { 465 wp_enqueue_script( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../js/own-shop-quick-view.js', array( 'jquery' ), '1.0.0', true ); 466 wp_localize_script( 'own-shop-quick-view', 'own_shop_quick_view_ajax', array( 467 'ajax_url' => admin_url( 'admin-ajax.php' ), 468 'nonce' => wp_create_nonce( 'own_shop_quick_view_nonce' ) 469 )); 470 wp_enqueue_style( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../css/own-shop-quick-view.css', array(), '1.0.0' ); 471 } 472 add_action( 'wp_enqueue_scripts', 'spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts' ); 473 } 474 475 /** 476 * AJAX Handler for Quick View 477 */ 478 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_ajax_handler') ) { 479 function spiraclethemes_site_library_own_shop_quick_view_ajax_handler() { 480 check_ajax_referer( 'own_shop_quick_view_nonce', 'nonce' ); 481 482 $product_id = intval( $_POST['product_id'] ); 483 $product = wc_get_product( $product_id ); 484 485 if ( !$product ) { 486 wp_die( esc_html__( 'Product not found.', 'spiraclethemes-site-library' ) ); 487 } 488 489 ob_start(); 490 ?> 491 <div class="own-shop-quick-view-modal"> 492 <div class="quick-view-content"> 493 <button class="quick-view-close" onclick="closeOwnShopQuickView()" aria-label="Close"> 494 <i class="las la-times-circle"></i> 495 </button> 496 <div class="quick-view-body"> 497 <div class="quick-view-images-section"> 498 <?php 499 $attachment_ids = $product->get_gallery_image_ids(); 500 $main_image_url = has_post_thumbnail( $product_id ) ? get_the_post_thumbnail_url( $product_id, 'large' ) : wc_placeholder_img_src(); 501 ?> 502 <img id="quick-view-main-image" class="quick-view-main-image" src="<?php echo esc_url( $main_image_url ); ?>" alt="<?php echo esc_attr( $product->get_name() ); ?>"> 503 504 <?php if ( count( $attachment_ids ) > 1 || has_post_thumbnail( $product_id ) ) : ?> 505 <div class="quick-view-thumbnails"> 506 <?php 507 if ( has_post_thumbnail( $product_id ) ) { 508 $thumbnail_url = get_the_post_thumbnail_url( $product_id, 'thumbnail' ); 509 echo '<img class="thumbnail active" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $thumbnail_url ) . '\', this)">'; 510 } 511 if ( $attachment_ids ) { 512 foreach ( $attachment_ids as $attachment_id ) { 513 $thumbnail_url = wp_get_attachment_image_url( $attachment_id, 'thumbnail' ); 514 $large_url = wp_get_attachment_image_url( $attachment_id, 'large' ); 515 echo '<img class="thumbnail" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $large_url ) . '\', this)">'; 516 } 517 } 518 ?> 519 </div> 520 <?php endif; ?> 521 </div> 522 <div class="quick-view-details"> 523 <h2 class="quick-view-title"><?php echo esc_html( $product->get_name() ); ?></h2> 524 525 <div class="quick-view-rating"> 526 <?php 527 $rating_count = $product->get_rating_count(); 528 $review_count = $product->get_review_count(); 529 $average = $product->get_average_rating(); 530 ?> 531 <?php echo wc_get_rating_html( $average, $rating_count ); ?> 532 <?php if ( comments_open() && $review_count ) : ?> 533 <span class="modal-reviews"><?php printf( _n( '(%s review)', '(%s reviews)', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?></span> 534 <?php endif ?> 535 </div> 536 537 <div class="quick-view-price"><?php echo $product->get_price_html(); ?></div> 538 539 <div class="quick-view-description"> 540 <?php echo wp_kses_post( $product->get_short_description() ? $product->get_short_description() : $product->get_description() ); ?> 541 </div> 542 543 <!-- Stock Status --> 544 <div class="modal-stock"><?php echo esc_html( $product->is_in_stock() ? 'In Stock' : 'Out of Stock' ); ?></div> 545 546 <div class="quick-view-quantity"> 547 <span class="quantity-label"><?php esc_html_e('Quantity:', 'woocommerce'); ?></span> 548 <div class="quantity-input"> 549 <button class="quantity-btn" onclick="decreaseQuickViewQuantity()">-</button> 550 <input type="number" class="quantity-value" id="quick-view-quantity" value="1" min="1" readonly> 551 <button class="quantity-btn" onclick="increaseQuickViewQuantity()">+</button> 552 </div> 553 </div> 554 555 <button class="modal-add-to-cart" onclick="addQuickViewToCart(<?php echo esc_js($product_id); ?>)"> 556 <i class="fas fa-shopping-cart"></i> <?php echo esc_html($product->single_add_to_cart_text()); ?> 557 </button> 558 559 <!-- Meta Information --> 560 <div class="modal-meta"> 561 <div><span><?php esc_html_e('SKU:', 'spiraclethemes-site-library'); ?></span> <span><?php echo esc_html( $product->get_sku() ? $product->get_sku() : esc_html__('N/A', 'spiraclethemes-site-library') ); ?></span></div> 562 <div><span><?php esc_html_e('Category:', 'spiraclethemes-site-library'); ?></span> 563 <?php 564 $categories = wp_get_post_terms( $product_id, 'product_cat' ); 565 $category_names = array(); 566 foreach ( $categories as $category ) { 567 $category_names[] = esc_html( $category->name ); 568 } 569 echo '<span>' . implode( ', ', $category_names ) . '</span>'; 570 ?> 571 </div> 572 </div> 573 </div> 574 </div> 575 </div> 576 </div> 577 <?php 578 $content = ob_get_clean(); 579 580 wp_send_json_success( $content ); 581 } 582 add_action( 'wp_ajax_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 583 add_action( 'wp_ajax_nopriv_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 584 } 585 586 /** 587 * AJAX Handler for Quick View Add to Cart 588 */ 589 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax') ) { 590 function spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax() { 591 check_ajax_referer( 'own_shop_quick_view_nonce', 'security' ); 592 593 $product_id = intval( $_POST['product_id'] ); 594 $quantity = intval( $_POST['quantity'] ); 595 $variation_id = isset( $_POST['variation_id'] ) ? intval( $_POST['variation_id'] ) : 0; 596 $variations = isset( $_POST['variation'] ) ? $_POST['variation'] : array(); 597 598 if ( ! $product_id || $quantity < 1 ) { 599 wp_send_json_error( __( 'Invalid product or quantity.', 'spiraclethemes-site-library' ) ); 600 } 601 602 $product = wc_get_product( $product_id ); 603 604 if ( ! $product ) { 605 wp_send_json_error( __( 'Product not found.', 'spiraclethemes-site-library' ) ); 606 } 607 608 // Handle variable products 609 if ( $product->is_type( 'variable' ) ) { 610 if ( ! $variation_id ) { 611 wp_send_json_error( __( 'Please select product options.', 'spiraclethemes-site-library' ) ); 612 } 613 614 $variation = wc_get_product( $variation_id ); 615 if ( ! $variation || ! $variation->exists() || ! $variation->is_in_stock() ) { 616 wp_send_json_error( __( 'Invalid variation selected.', 'spiraclethemes-site-library' ) ); 617 } 618 619 $product_id = $variation_id; 620 } 621 622 // Check if product is in stock 623 if ( ! $product->is_in_stock() ) { 624 wp_send_json_error( __( 'Sorry, this product is out of stock.', 'spiraclethemes-site-library' ) ); 625 } 626 627 // Check stock quantity 628 if ( ! $product->has_enough_stock( $quantity ) ) { 629 wp_send_json_error( sprintf( __( 'Sorry, we do not have enough "%s" in stock to fulfill your order.', 'woocommerce' ), $product->get_name() ) ); 630 } 631 632 // Add to cart 633 $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ); 634 635 if ( ! $cart_item_key ) { 636 wp_send_json_error( __( 'Failed to add product to cart.', 'spiraclethemes-site-library' ) ); 637 } 638 639 // Return success response 640 wp_send_json_success( array( 641 'cart_hash' => WC()->cart->get_cart_hash(), 642 'fragments' => apply_filters( 'woocommerce_add_to_cart_fragments', array() ), 643 'cart_url' => wc_get_cart_url(), 644 'message' => sprintf( __( '"%s" has been added to your cart.', 'woocommerce' ), $product->get_name() ), 645 ) ); 646 } 647 add_action( 'wp_ajax_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 648 add_action( 'wp_ajax_nopriv_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 649 } 650 651 /** 652 * Add Quick View Button to Product Actions 653 */ 654 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop') ) { 655 function spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop() { 656 add_action( 'woocommerce_after_shop_loop_item', 'spiraclethemes_site_library_own_shop_add_quick_view_button', 15 ); 657 } 658 add_action( 'woocommerce_init', 'spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop' ); 659 } -
spiraclethemes-site-library/trunk/inc/own-shop-lite-functions.php
r3327924 r3388695 83 83 'name' => 'WooCommerce', 84 84 'slug' => 'woocommerce', 85 'required' => true,86 ],87 [88 'name' => 'YITH WooCommerce Quick View',89 'slug' => 'yith-woocommerce-quick-view',90 85 'required' => true, 91 86 ], … … 442 437 add_shortcode('recentblog', 'spiraclethemes_site_library_own_shop_recentblog'); 443 438 } 439 440 /** 441 * Quick View Functions 442 */ 443 444 /** 445 * Add Quick View Button to WooCommerce Product Loop 446 */ 447 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_button') ) { 448 function spiraclethemes_site_library_own_shop_add_quick_view_button() { 449 global $product; 450 if ( $product && is_a( $product, 'WC_Product' ) ) { 451 echo '<a href="#" class="own-shop-quick-view-btn" data-product-id="' . esc_attr( $product->get_id() ) . '" data-product-type="' . esc_attr( $product->get_type() ) . '" aria-label="' . esc_attr__( 'Quick View', 'spiraclethemes-site-library' ) . '"></a>'; 452 } 453 } 454 } 455 456 /** 457 * Enqueue Quick View Scripts 458 */ 459 if( !function_exists('spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts') ) { 460 function spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts() { 461 wp_enqueue_script( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../js/own-shop-quick-view.js', array( 'jquery' ), '1.0.0', true ); 462 wp_localize_script( 'own-shop-quick-view', 'own_shop_quick_view_ajax', array( 463 'ajax_url' => admin_url( 'admin-ajax.php' ), 464 'nonce' => wp_create_nonce( 'own_shop_quick_view_nonce' ) 465 )); 466 // Enqueue parent quick view CSS 467 wp_enqueue_style( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../css/own-shop-quick-view.css', array(), '1.0.0' ); 468 // Enqueue own-store specific CSS 469 wp_enqueue_style( 'own-store-quick-view', plugin_dir_url( __FILE__ ) . '../css/own-store-quick-view.css', array('own-shop-quick-view'), '1.0.0' ); 470 } 471 add_action( 'wp_enqueue_scripts', 'spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts' ); 472 } 473 474 /** 475 * AJAX Handler for Quick View 476 */ 477 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_ajax_handler') ) { 478 function spiraclethemes_site_library_own_shop_quick_view_ajax_handler() { 479 check_ajax_referer( 'own_shop_quick_view_nonce', 'nonce' ); 480 481 $product_id = intval( $_POST['product_id'] ); 482 $product = wc_get_product( $product_id ); 483 484 if ( !$product ) { 485 wp_die( esc_html__( 'Product not found.', 'spiraclethemes-site-library' ) ); 486 } 487 488 ob_start(); 489 ?> 490 <div class="own-shop-quick-view-modal"> 491 <div class="quick-view-content"> 492 <button class="quick-view-close" onclick="closeOwnShopQuickView()" aria-label="Close"> 493 <i class="las la-times-circle"></i> 494 </button> 495 <div class="quick-view-body"> 496 <div class="quick-view-images-section"> 497 <?php 498 $attachment_ids = $product->get_gallery_image_ids(); 499 $main_image_url = has_post_thumbnail( $product_id ) ? get_the_post_thumbnail_url( $product_id, 'large' ) : wc_placeholder_img_src(); 500 ?> 501 <img id="quick-view-main-image" class="quick-view-main-image" src="<?php echo esc_url( $main_image_url ); ?>" alt="<?php echo esc_attr( $product->get_name() ); ?>"> 502 503 <?php if ( count( $attachment_ids ) > 1 || has_post_thumbnail( $product_id ) ) : ?> 504 <div class="quick-view-thumbnails"> 505 <?php 506 if ( has_post_thumbnail( $product_id ) ) { 507 $thumbnail_url = get_the_post_thumbnail_url( $product_id, 'thumbnail' ); 508 echo '<img class="thumbnail active" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $thumbnail_url ) . '\', this)">'; 509 } 510 if ( $attachment_ids ) { 511 foreach ( $attachment_ids as $attachment_id ) { 512 $thumbnail_url = wp_get_attachment_image_url( $attachment_id, 'thumbnail' ); 513 $large_url = wp_get_attachment_image_url( $attachment_id, 'large' ); 514 echo '<img class="thumbnail" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $large_url ) . '\', this)">'; 515 } 516 } 517 ?> 518 </div> 519 <?php endif; ?> 520 </div> 521 <div class="quick-view-details"> 522 <h2 class="quick-view-title"><?php echo esc_html( $product->get_name() ); ?></h2> 523 524 <div class="quick-view-rating"> 525 <?php 526 $rating_count = $product->get_rating_count(); 527 $review_count = $product->get_review_count(); 528 $average = $product->get_average_rating(); 529 ?> 530 <?php echo wc_get_rating_html( $average, $rating_count ); ?> 531 <?php if ( comments_open() && $review_count ) : ?> 532 <span class="modal-reviews"><?php printf( _n( '(%s review)', '(%s reviews)', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?></span> 533 <?php endif ?> 534 </div> 535 536 <div class="quick-view-price"><?php echo $product->get_price_html(); ?></div> 537 538 <div class="quick-view-description"> 539 <?php echo wp_kses_post( $product->get_short_description() ? $product->get_short_description() : $product->get_description() ); ?> 540 </div> 541 542 <!-- Stock Status --> 543 <div class="modal-stock"><?php echo esc_html( $product->is_in_stock() ? 'In Stock' : 'Out of Stock' ); ?></div> 544 545 <div class="quick-view-quantity"> 546 <span class="quantity-label"><?php esc_html_e('Quantity:', 'woocommerce'); ?></span> 547 <div class="quantity-input"> 548 <button class="quantity-btn" onclick="decreaseQuickViewQuantity()">-</button> 549 <input type="number" class="quantity-value" id="quick-view-quantity" value="1" min="1" readonly> 550 <button class="quantity-btn" onclick="increaseQuickViewQuantity()">+</button> 551 </div> 552 </div> 553 554 <button class="modal-add-to-cart" onclick="addQuickViewToCart(<?php echo esc_js($product_id); ?>)"> 555 <i class="fas fa-shopping-cart"></i> <?php echo esc_html($product->single_add_to_cart_text()); ?> 556 </button> 557 558 <!-- Meta Information --> 559 <div class="modal-meta"> 560 <div><span><?php esc_html_e('SKU:', 'spiraclethemes-site-library'); ?></span> <span><?php echo esc_html( $product->get_sku() ? $product->get_sku() : esc_html__('N/A', 'spiraclethemes-site-library') ); ?></span></div> 561 <div><span><?php esc_html_e('Category:', 'spiraclethemes-site-library'); ?></span> 562 <?php 563 $categories = wp_get_post_terms( $product_id, 'product_cat' ); 564 $category_names = array(); 565 foreach ( $categories as $category ) { 566 $category_names[] = esc_html( $category->name ); 567 } 568 echo '<span>' . implode( ', ', $category_names ) . '</span>'; 569 ?> 570 </div> 571 </div> 572 </div> 573 </div> 574 </div> 575 </div> 576 <?php 577 $content = ob_get_clean(); 578 579 wp_send_json_success( $content ); 580 } 581 add_action( 'wp_ajax_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 582 add_action( 'wp_ajax_nopriv_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 583 } 584 585 /** 586 * AJAX Handler for Quick View Add to Cart 587 */ 588 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax') ) { 589 function spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax() { 590 check_ajax_referer( 'own_shop_quick_view_nonce', 'security' ); 591 592 $product_id = intval( $_POST['product_id'] ); 593 $quantity = intval( $_POST['quantity'] ); 594 $variation_id = isset( $_POST['variation_id'] ) ? intval( $_POST['variation_id'] ) : 0; 595 $variations = isset( $_POST['variation'] ) ? $_POST['variation'] : array(); 596 597 if ( ! $product_id || $quantity < 1 ) { 598 wp_send_json_error( __( 'Invalid product or quantity.', 'spiraclethemes-site-library' ) ); 599 } 600 601 $product = wc_get_product( $product_id ); 602 603 if ( ! $product ) { 604 wp_send_json_error( __( 'Product not found.', 'spiraclethemes-site-library' ) ); 605 } 606 607 // Handle variable products 608 if ( $product->is_type( 'variable' ) ) { 609 if ( ! $variation_id ) { 610 wp_send_json_error( __( 'Please select product options.', 'spiraclethemes-site-library' ) ); 611 } 612 613 $variation = wc_get_product( $variation_id ); 614 if ( ! $variation || ! $variation->exists() || ! $variation->is_in_stock() ) { 615 wp_send_json_error( __( 'Invalid variation selected.', 'spiraclethemes-site-library' ) ); 616 } 617 618 $product_id = $variation_id; 619 } 620 621 // Check if product is in stock 622 if ( ! $product->is_in_stock() ) { 623 wp_send_json_error( __( 'Sorry, this product is out of stock.', 'spiraclethemes-site-library' ) ); 624 } 625 626 // Check stock quantity 627 if ( ! $product->has_enough_stock( $quantity ) ) { 628 wp_send_json_error( sprintf( __( 'Sorry, we do not have enough "%s" in stock to fulfill your order.', 'woocommerce' ), $product->get_name() ) ); 629 } 630 631 // Add to cart 632 $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ); 633 634 if ( ! $cart_item_key ) { 635 wp_send_json_error( __( 'Failed to add product to cart.', 'spiraclethemes-site-library' ) ); 636 } 637 638 // Return success response 639 wp_send_json_success( array( 640 'cart_hash' => WC()->cart->get_cart_hash(), 641 'fragments' => apply_filters( 'woocommerce_add_to_cart_fragments', array() ), 642 'cart_url' => wc_get_cart_url(), 643 'message' => sprintf( __( '"%s" has been added to your cart.', 'woocommerce' ), $product->get_name() ), 644 ) ); 645 } 646 add_action( 'wp_ajax_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 647 add_action( 'wp_ajax_nopriv_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 648 } 649 650 /** 651 * Add Quick View Button to Product Actions 652 */ 653 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop') ) { 654 function spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop() { 655 add_action( 'woocommerce_after_shop_loop_item', 'spiraclethemes_site_library_own_shop_add_quick_view_button', 15 ); 656 } 657 add_action( 'woocommerce_init', 'spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop' ); 658 } -
spiraclethemes-site-library/trunk/inc/own-shop-trend-functions.php
r3166955 r3388695 86 86 ], 87 87 [ 88 'name' => 'YITH WooCommerce Quick View',89 'slug' => 'yith-woocommerce-quick-view',90 'required' => true,91 ],92 [93 88 'name' => 'Contact Form 7', 94 89 'slug' => 'contact-form-7', -
spiraclethemes-site-library/trunk/inc/own-shope-functions.php
r3327924 r3388695 83 83 'name' => 'WooCommerce', 84 84 'slug' => 'woocommerce', 85 'required' => true,86 ],87 [88 'name' => 'YITH WooCommerce Quick View',89 'slug' => 'yith-woocommerce-quick-view',90 85 'required' => true, 91 86 ], … … 442 437 add_shortcode('recentblog', 'spiraclethemes_site_library_own_shop_recentblog'); 443 438 } 439 440 /** 441 * Quick View Functions 442 */ 443 444 /** 445 * Add Quick View Button to WooCommerce Product Loop 446 */ 447 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_button') ) { 448 function spiraclethemes_site_library_own_shop_add_quick_view_button() { 449 global $product; 450 if ( $product && is_a( $product, 'WC_Product' ) ) { 451 echo '<a href="#" class="own-shop-quick-view-btn" data-product-id="' . esc_attr( $product->get_id() ) . '" data-product-type="' . esc_attr( $product->get_type() ) . '" aria-label="' . esc_attr__( 'Quick View', 'spiraclethemes-site-library' ) . '"></a>'; 452 } 453 } 454 } 455 456 /** 457 * Enqueue Quick View Scripts 458 */ 459 if( !function_exists('spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts') ) { 460 function spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts() { 461 wp_enqueue_script( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../js/own-shop-quick-view.js', array( 'jquery' ), '1.0.0', true ); 462 wp_localize_script( 'own-shop-quick-view', 'own_shop_quick_view_ajax', array( 463 'ajax_url' => admin_url( 'admin-ajax.php' ), 464 'nonce' => wp_create_nonce( 'own_shop_quick_view_nonce' ) 465 )); 466 // Enqueue parent quick view CSS 467 wp_enqueue_style( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../css/own-shop-quick-view.css', array(), '1.0.0' ); 468 // Enqueue own-store specific CSS 469 wp_enqueue_style( 'own-store-quick-view', plugin_dir_url( __FILE__ ) . '../css/own-store-quick-view.css', array('own-shop-quick-view'), '1.0.0' ); 470 } 471 add_action( 'wp_enqueue_scripts', 'spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts' ); 472 } 473 474 /** 475 * AJAX Handler for Quick View 476 */ 477 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_ajax_handler') ) { 478 function spiraclethemes_site_library_own_shop_quick_view_ajax_handler() { 479 check_ajax_referer( 'own_shop_quick_view_nonce', 'nonce' ); 480 481 $product_id = intval( $_POST['product_id'] ); 482 $product = wc_get_product( $product_id ); 483 484 if ( !$product ) { 485 wp_die( esc_html__( 'Product not found.', 'spiraclethemes-site-library' ) ); 486 } 487 488 ob_start(); 489 ?> 490 <div class="own-shop-quick-view-modal"> 491 <div class="quick-view-content"> 492 <button class="quick-view-close" onclick="closeOwnShopQuickView()" aria-label="Close"> 493 <i class="las la-times-circle"></i> 494 </button> 495 <div class="quick-view-body"> 496 <div class="quick-view-images-section"> 497 <?php 498 $attachment_ids = $product->get_gallery_image_ids(); 499 $main_image_url = has_post_thumbnail( $product_id ) ? get_the_post_thumbnail_url( $product_id, 'large' ) : wc_placeholder_img_src(); 500 ?> 501 <img id="quick-view-main-image" class="quick-view-main-image" src="<?php echo esc_url( $main_image_url ); ?>" alt="<?php echo esc_attr( $product->get_name() ); ?>"> 502 503 <?php if ( count( $attachment_ids ) > 1 || has_post_thumbnail( $product_id ) ) : ?> 504 <div class="quick-view-thumbnails"> 505 <?php 506 if ( has_post_thumbnail( $product_id ) ) { 507 $thumbnail_url = get_the_post_thumbnail_url( $product_id, 'thumbnail' ); 508 echo '<img class="thumbnail active" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $thumbnail_url ) . '\', this)">'; 509 } 510 if ( $attachment_ids ) { 511 foreach ( $attachment_ids as $attachment_id ) { 512 $thumbnail_url = wp_get_attachment_image_url( $attachment_id, 'thumbnail' ); 513 $large_url = wp_get_attachment_image_url( $attachment_id, 'large' ); 514 echo '<img class="thumbnail" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $large_url ) . '\', this)">'; 515 } 516 } 517 ?> 518 </div> 519 <?php endif; ?> 520 </div> 521 <div class="quick-view-details"> 522 <h2 class="quick-view-title"><?php echo esc_html( $product->get_name() ); ?></h2> 523 524 <div class="quick-view-rating"> 525 <?php 526 $rating_count = $product->get_rating_count(); 527 $review_count = $product->get_review_count(); 528 $average = $product->get_average_rating(); 529 ?> 530 <?php echo wc_get_rating_html( $average, $rating_count ); ?> 531 <?php if ( comments_open() && $review_count ) : ?> 532 <span class="modal-reviews"><?php printf( _n( '(%s review)', '(%s reviews)', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?></span> 533 <?php endif ?> 534 </div> 535 536 <div class="quick-view-price"><?php echo $product->get_price_html(); ?></div> 537 538 <div class="quick-view-description"> 539 <?php echo wp_kses_post( $product->get_short_description() ? $product->get_short_description() : $product->get_description() ); ?> 540 </div> 541 542 <!-- Stock Status --> 543 <div class="modal-stock"><?php echo esc_html( $product->is_in_stock() ? 'In Stock' : 'Out of Stock' ); ?></div> 544 545 <div class="quick-view-quantity"> 546 <span class="quantity-label"><?php esc_html_e('Quantity:', 'woocommerce'); ?></span> 547 <div class="quantity-input"> 548 <button class="quantity-btn" onclick="decreaseQuickViewQuantity()">-</button> 549 <input type="number" class="quantity-value" id="quick-view-quantity" value="1" min="1" readonly> 550 <button class="quantity-btn" onclick="increaseQuickViewQuantity()">+</button> 551 </div> 552 </div> 553 554 <button class="modal-add-to-cart" onclick="addQuickViewToCart(<?php echo esc_js($product_id); ?>)"> 555 <i class="fas fa-shopping-cart"></i> <?php echo esc_html($product->single_add_to_cart_text()); ?> 556 </button> 557 558 <!-- Meta Information --> 559 <div class="modal-meta"> 560 <div><span><?php esc_html_e('SKU:', 'spiraclethemes-site-library'); ?></span> <span><?php echo esc_html( $product->get_sku() ? $product->get_sku() : esc_html__('N/A', 'spiraclethemes-site-library') ); ?></span></div> 561 <div><span><?php esc_html_e('Category:', 'spiraclethemes-site-library'); ?></span> 562 <?php 563 $categories = wp_get_post_terms( $product_id, 'product_cat' ); 564 $category_names = array(); 565 foreach ( $categories as $category ) { 566 $category_names[] = esc_html( $category->name ); 567 } 568 echo '<span>' . implode( ', ', $category_names ) . '</span>'; 569 ?> 570 </div> 571 </div> 572 </div> 573 </div> 574 </div> 575 </div> 576 <?php 577 $content = ob_get_clean(); 578 579 wp_send_json_success( $content ); 580 } 581 add_action( 'wp_ajax_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 582 add_action( 'wp_ajax_nopriv_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 583 } 584 585 /** 586 * AJAX Handler for Quick View Add to Cart 587 */ 588 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax') ) { 589 function spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax() { 590 check_ajax_referer( 'own_shop_quick_view_nonce', 'security' ); 591 592 $product_id = intval( $_POST['product_id'] ); 593 $quantity = intval( $_POST['quantity'] ); 594 $variation_id = isset( $_POST['variation_id'] ) ? intval( $_POST['variation_id'] ) : 0; 595 $variations = isset( $_POST['variation'] ) ? $_POST['variation'] : array(); 596 597 if ( ! $product_id || $quantity < 1 ) { 598 wp_send_json_error( __( 'Invalid product or quantity.', 'spiraclethemes-site-library' ) ); 599 } 600 601 $product = wc_get_product( $product_id ); 602 603 if ( ! $product ) { 604 wp_send_json_error( __( 'Product not found.', 'spiraclethemes-site-library' ) ); 605 } 606 607 // Handle variable products 608 if ( $product->is_type( 'variable' ) ) { 609 if ( ! $variation_id ) { 610 wp_send_json_error( __( 'Please select product options.', 'spiraclethemes-site-library' ) ); 611 } 612 613 $variation = wc_get_product( $variation_id ); 614 if ( ! $variation || ! $variation->exists() || ! $variation->is_in_stock() ) { 615 wp_send_json_error( __( 'Invalid variation selected.', 'spiraclethemes-site-library' ) ); 616 } 617 618 $product_id = $variation_id; 619 } 620 621 // Check if product is in stock 622 if ( ! $product->is_in_stock() ) { 623 wp_send_json_error( __( 'Sorry, this product is out of stock.', 'spiraclethemes-site-library' ) ); 624 } 625 626 // Check stock quantity 627 if ( ! $product->has_enough_stock( $quantity ) ) { 628 wp_send_json_error( sprintf( __( 'Sorry, we do not have enough "%s" in stock to fulfill your order.', 'woocommerce' ), $product->get_name() ) ); 629 } 630 631 // Add to cart 632 $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ); 633 634 if ( ! $cart_item_key ) { 635 wp_send_json_error( __( 'Failed to add product to cart.', 'spiraclethemes-site-library' ) ); 636 } 637 638 // Return success response 639 wp_send_json_success( array( 640 'cart_hash' => WC()->cart->get_cart_hash(), 641 'fragments' => apply_filters( 'woocommerce_add_to_cart_fragments', array() ), 642 'cart_url' => wc_get_cart_url(), 643 'message' => sprintf( __( '"%s" has been added to your cart.', 'woocommerce' ), $product->get_name() ), 644 ) ); 645 } 646 add_action( 'wp_ajax_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 647 add_action( 'wp_ajax_nopriv_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 648 } 649 650 /** 651 * Add Quick View Button to Product Actions 652 */ 653 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop') ) { 654 function spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop() { 655 add_action( 'woocommerce_after_shop_loop_item', 'spiraclethemes_site_library_own_shop_add_quick_view_button', 15 ); 656 } 657 add_action( 'woocommerce_init', 'spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop' ); 658 } -
spiraclethemes-site-library/trunk/inc/own-store-functions.php
r3327924 r3388695 83 83 'name' => 'WooCommerce', 84 84 'slug' => 'woocommerce', 85 'required' => true,86 ],87 [88 'name' => 'YITH WooCommerce Quick View',89 'slug' => 'yith-woocommerce-quick-view',90 85 'required' => true, 91 86 ], … … 442 437 add_shortcode('recentblog', 'spiraclethemes_site_library_own_shop_recentblog'); 443 438 } 439 440 441 /** 442 * Quick View Functions 443 */ 444 445 /** 446 * Add Quick View Button to WooCommerce Product Loop 447 */ 448 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_button') ) { 449 function spiraclethemes_site_library_own_shop_add_quick_view_button() { 450 global $product; 451 if ( $product && is_a( $product, 'WC_Product' ) ) { 452 echo '<a href="#" class="own-shop-quick-view-btn" data-product-id="' . esc_attr( $product->get_id() ) . '" data-product-type="' . esc_attr( $product->get_type() ) . '" aria-label="' . esc_attr__( 'Quick View', 'spiraclethemes-site-library' ) . '"></a>'; 453 } 454 } 455 } 456 457 /** 458 * Enqueue Quick View Scripts 459 */ 460 if( !function_exists('spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts') ) { 461 function spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts() { 462 wp_enqueue_script( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../js/own-shop-quick-view.js', array( 'jquery' ), '1.0.0', true ); 463 wp_localize_script( 'own-shop-quick-view', 'own_shop_quick_view_ajax', array( 464 'ajax_url' => admin_url( 'admin-ajax.php' ), 465 'nonce' => wp_create_nonce( 'own_shop_quick_view_nonce' ) 466 )); 467 // Enqueue parent quick view CSS 468 wp_enqueue_style( 'own-shop-quick-view', plugin_dir_url( __FILE__ ) . '../css/own-shop-quick-view.css', array(), '1.0.0' ); 469 // Enqueue own-store specific CSS 470 wp_enqueue_style( 'own-store-quick-view', plugin_dir_url( __FILE__ ) . '../css/own-store-quick-view.css', array('own-shop-quick-view'), '1.0.0' ); 471 } 472 add_action( 'wp_enqueue_scripts', 'spiraclethemes_site_library_own_shop_enqueue_quick_view_scripts' ); 473 } 474 475 /** 476 * AJAX Handler for Quick View 477 */ 478 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_ajax_handler') ) { 479 function spiraclethemes_site_library_own_shop_quick_view_ajax_handler() { 480 check_ajax_referer( 'own_shop_quick_view_nonce', 'nonce' ); 481 482 $product_id = intval( $_POST['product_id'] ); 483 $product = wc_get_product( $product_id ); 484 485 if ( !$product ) { 486 wp_die( esc_html__( 'Product not found.', 'spiraclethemes-site-library' ) ); 487 } 488 489 ob_start(); 490 ?> 491 <div class="own-shop-quick-view-modal"> 492 <div class="quick-view-content"> 493 <button class="quick-view-close" onclick="closeOwnShopQuickView()" aria-label="Close"> 494 <i class="las la-times-circle"></i> 495 </button> 496 <div class="quick-view-body"> 497 <div class="quick-view-images-section"> 498 <?php 499 $attachment_ids = $product->get_gallery_image_ids(); 500 $main_image_url = has_post_thumbnail( $product_id ) ? get_the_post_thumbnail_url( $product_id, 'large' ) : wc_placeholder_img_src(); 501 ?> 502 <img id="quick-view-main-image" class="quick-view-main-image" src="<?php echo esc_url( $main_image_url ); ?>" alt="<?php echo esc_attr( $product->get_name() ); ?>"> 503 504 <?php if ( count( $attachment_ids ) > 1 || has_post_thumbnail( $product_id ) ) : ?> 505 <div class="quick-view-thumbnails"> 506 <?php 507 if ( has_post_thumbnail( $product_id ) ) { 508 $thumbnail_url = get_the_post_thumbnail_url( $product_id, 'thumbnail' ); 509 echo '<img class="thumbnail active" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $thumbnail_url ) . '\', this)">'; 510 } 511 if ( $attachment_ids ) { 512 foreach ( $attachment_ids as $attachment_id ) { 513 $thumbnail_url = wp_get_attachment_image_url( $attachment_id, 'thumbnail' ); 514 $large_url = wp_get_attachment_image_url( $attachment_id, 'large' ); 515 echo '<img class="thumbnail" src="' . esc_url( $thumbnail_url ) . '" alt="Thumbnail" onclick="changeQuickViewImage(\'' . esc_js( $large_url ) . '\', this)">'; 516 } 517 } 518 ?> 519 </div> 520 <?php endif; ?> 521 </div> 522 <div class="quick-view-details"> 523 <h2 class="quick-view-title"><?php echo esc_html( $product->get_name() ); ?></h2> 524 525 <div class="quick-view-rating"> 526 <?php 527 $rating_count = $product->get_rating_count(); 528 $review_count = $product->get_review_count(); 529 $average = $product->get_average_rating(); 530 ?> 531 <?php echo wc_get_rating_html( $average, $rating_count ); ?> 532 <?php if ( comments_open() && $review_count ) : ?> 533 <span class="modal-reviews"><?php printf( _n( '(%s review)', '(%s reviews)', $review_count, 'woocommerce' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?></span> 534 <?php endif ?> 535 </div> 536 537 <div class="quick-view-price"><?php echo $product->get_price_html(); ?></div> 538 539 <div class="quick-view-description"> 540 <?php echo wp_kses_post( $product->get_short_description() ? $product->get_short_description() : $product->get_description() ); ?> 541 </div> 542 543 <!-- Stock Status --> 544 <div class="modal-stock"><?php echo esc_html( $product->is_in_stock() ? 'In Stock' : 'Out of Stock' ); ?></div> 545 546 <div class="quick-view-quantity"> 547 <span class="quantity-label"><?php esc_html_e('Quantity:', 'woocommerce'); ?></span> 548 <div class="quantity-input"> 549 <button class="quantity-btn" onclick="decreaseQuickViewQuantity()">-</button> 550 <input type="number" class="quantity-value" id="quick-view-quantity" value="1" min="1" readonly> 551 <button class="quantity-btn" onclick="increaseQuickViewQuantity()">+</button> 552 </div> 553 </div> 554 555 <button class="modal-add-to-cart" onclick="addQuickViewToCart(<?php echo esc_js($product_id); ?>)"> 556 <i class="fas fa-shopping-cart"></i> <?php echo esc_html($product->single_add_to_cart_text()); ?> 557 </button> 558 559 <!-- Meta Information --> 560 <div class="modal-meta"> 561 <div><span><?php esc_html_e('SKU:', 'spiraclethemes-site-library'); ?></span> <span><?php echo esc_html( $product->get_sku() ? $product->get_sku() : esc_html__('N/A', 'spiraclethemes-site-library') ); ?></span></div> 562 <div><span><?php esc_html_e('Category:', 'spiraclethemes-site-library'); ?></span> 563 <?php 564 $categories = wp_get_post_terms( $product_id, 'product_cat' ); 565 $category_names = array(); 566 foreach ( $categories as $category ) { 567 $category_names[] = esc_html( $category->name ); 568 } 569 echo '<span>' . implode( ', ', $category_names ) . '</span>'; 570 ?> 571 </div> 572 </div> 573 </div> 574 </div> 575 </div> 576 </div> 577 <?php 578 $content = ob_get_clean(); 579 580 wp_send_json_success( $content ); 581 } 582 add_action( 'wp_ajax_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 583 add_action( 'wp_ajax_nopriv_own_shop_quick_view', 'spiraclethemes_site_library_own_shop_quick_view_ajax_handler' ); 584 } 585 586 /** 587 * AJAX Handler for Quick View Add to Cart 588 */ 589 if( !function_exists('spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax') ) { 590 function spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax() { 591 check_ajax_referer( 'own_shop_quick_view_nonce', 'security' ); 592 593 $product_id = intval( $_POST['product_id'] ); 594 $quantity = intval( $_POST['quantity'] ); 595 $variation_id = isset( $_POST['variation_id'] ) ? intval( $_POST['variation_id'] ) : 0; 596 $variations = isset( $_POST['variation'] ) ? $_POST['variation'] : array(); 597 598 if ( ! $product_id || $quantity < 1 ) { 599 wp_send_json_error( __( 'Invalid product or quantity.', 'spiraclethemes-site-library' ) ); 600 } 601 602 $product = wc_get_product( $product_id ); 603 604 if ( ! $product ) { 605 wp_send_json_error( __( 'Product not found.', 'spiraclethemes-site-library' ) ); 606 } 607 608 // Handle variable products 609 if ( $product->is_type( 'variable' ) ) { 610 if ( ! $variation_id ) { 611 wp_send_json_error( __( 'Please select product options.', 'spiraclethemes-site-library' ) ); 612 } 613 614 $variation = wc_get_product( $variation_id ); 615 if ( ! $variation || ! $variation->exists() || ! $variation->is_in_stock() ) { 616 wp_send_json_error( __( 'Invalid variation selected.', 'spiraclethemes-site-library' ) ); 617 } 618 619 $product_id = $variation_id; 620 } 621 622 // Check if product is in stock 623 if ( ! $product->is_in_stock() ) { 624 wp_send_json_error( __( 'Sorry, this product is out of stock.', 'spiraclethemes-site-library' ) ); 625 } 626 627 // Check stock quantity 628 if ( ! $product->has_enough_stock( $quantity ) ) { 629 wp_send_json_error( sprintf( __( 'Sorry, we do not have enough "%s" in stock to fulfill your order.', 'woocommerce' ), $product->get_name() ) ); 630 } 631 632 // Add to cart 633 $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ); 634 635 if ( ! $cart_item_key ) { 636 wp_send_json_error( __( 'Failed to add product to cart.', 'spiraclethemes-site-library' ) ); 637 } 638 639 // Return success response 640 wp_send_json_success( array( 641 'cart_hash' => WC()->cart->get_cart_hash(), 642 'fragments' => apply_filters( 'woocommerce_add_to_cart_fragments', array() ), 643 'cart_url' => wc_get_cart_url(), 644 'message' => sprintf( __( '"%s" has been added to your cart.', 'woocommerce' ), $product->get_name() ), 645 ) ); 646 } 647 add_action( 'wp_ajax_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 648 add_action( 'wp_ajax_nopriv_own_shop_quick_view_add_to_cart', 'spiraclethemes_site_library_own_shop_quick_view_add_to_cart_ajax' ); 649 } 650 651 /** 652 * Add Quick View Button to Product Actions 653 */ 654 if( !function_exists('spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop') ) { 655 function spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop() { 656 add_action( 'woocommerce_after_shop_loop_item', 'spiraclethemes_site_library_own_shop_add_quick_view_button', 15 ); 657 } 658 add_action( 'woocommerce_init', 'spiraclethemes_site_library_own_shop_add_quick_view_to_product_loop' ); 659 } -
spiraclethemes-site-library/trunk/spiraclethemes-site-library.php
r3360556 r3388695 4 4 * Plugin URI: https://wordpress.org/plugins/spiraclethemes-site-library/ 5 5 * Description: A plugin by Spiracle Themes that adds one-click demo import, theme customization, starter templates, and page builder support to its free themes. 6 * Version: 1.5. 76 * Version: 1.5.8 7 7 * Author: SpiracleThemes 8 8 * Author URI: https://spiraclethemes.com … … 53 53 delete_user_meta( $user_id, 'spiraclethemes_sitelib_rating_ignore_notice' ); 54 54 delete_user_meta( $user_id, 'spiraclethemes_sitelib_training_ignore_notice' ); 55 // Clean up new $3/monthplan notice meta keys56 delete_user_meta( $user_id, 'spiraclethemes_sitelib_ 3dollar_0day_notice' );57 delete_user_meta( $user_id, 'spiraclethemes_sitelib_ 3dollar_7day_notice' );58 delete_user_meta( $user_id, 'spiraclethemes_sitelib_ 3dollar_14day_notice' );59 delete_user_meta( $user_id, 'spiraclethemes_sitelib_ 3dollar_28day_notice' );60 delete_user_meta( $user_id, 'spiraclethemes_sitelib_ 3dollar_60day_notice' );55 // Clean up plan notice meta keys 56 delete_user_meta( $user_id, 'spiraclethemes_sitelib_49dollar_0day_notice' ); 57 delete_user_meta( $user_id, 'spiraclethemes_sitelib_49dollar_7day_notice' ); 58 delete_user_meta( $user_id, 'spiraclethemes_sitelib_49dollar_14day_notice' ); 59 delete_user_meta( $user_id, 'spiraclethemes_sitelib_49dollar_28day_notice' ); 60 delete_user_meta( $user_id, 'spiraclethemes_sitelib_49dollar_60day_notice' ); 61 61 } 62 62 … … 101 101 add_action( 'admin_init', [ $this, 'spiraclethemes_site_library_set_notification' ] ); 102 102 add_action( 'admin_notices', [ $this, 'spiraclethemes_site_library_display_welcome_notice' ] ); 103 add_action( 'admin_notices', [ $this, 'spiraclethemes_site_library_display_ 3dollar_notices' ] );103 add_action( 'admin_notices', [ $this, 'spiraclethemes_site_library_display_49dollar_notices' ] ); 104 104 add_action( 'admin_init', [ $this, 'spiraclethemes_site_library_ignore_rating_notice' ] ); 105 add_action( 'admin_init', [ $this, 'spiraclethemes_site_library_ignore_ 3dollar_notices' ] );105 add_action( 'admin_init', [ $this, 'spiraclethemes_site_library_ignore_49dollar_notices' ] ); 106 106 } 107 107 add_action('init', [ $this, 'spiraclethemes_site_library_load_plugin_textdomain' ] ); … … 193 193 } 194 194 195 // Reusable method to build $3/month plan notice message 196 private function spiraclethemes_site_library_build_3dollar_notice( $days, $ignore_param, $theme_name ) { 197 $pricing_url = esc_url( 'https://spiraclethemes.com/pricing/' ); 198 195 // Get theme-specific pricing URL 196 private function spiraclethemes_site_library_get_theme_pricing_url() { 197 $theme_pricing_urls = [ 198 'own-shop' => 'https://spiraclethemes.com/own-shop-pro-addons/', 199 'purea-magazine' => 'https://spiraclethemes.com/purea-magazine-pro-addons', 200 'colon' => 'https://spiraclethemes.com/colon-pro-addons/', 201 'somalite' => 'https://spiraclethemes.com/soma-pro-addons/', 202 'purea-fashion' => 'https://spiraclethemes.com/purea-magazine-pro-addons/', 203 'own-store' => 'https://spiraclethemes.com/own-shop-pro-addons/', 204 'colon-plus' => 'https://spiraclethemes.com/colon-pro-addons/', 205 'own-shop-lite' => 'https://spiraclethemes.com/own-shop-lite-pro-addons/', 206 'mestore' => 'https://spiraclethemes.com/mestore-pro-addons', 207 'blogson' => 'https://spiraclethemes.com/blogson-pro-addons/', 208 'blogson-child' => 'https://spiraclethemes.com/blogson-pro-addons/', 209 'own-shope' => 'https://spiraclethemes.com/own-shope-free-wordpress-theme/#pricing', 210 'crater-free' => 'https://spiraclethemes.com/crater-pro-addons/', 211 'lawfiz' => 'https://spiraclethemes.com/lawfiz-theme/#pricing', 212 'legalblow' => 'https://spiraclethemes.com/legalblow-theme/#pricing', 213 'own-shop-trend' => 'https://spiraclethemes.com/own-shop-pro-addons/', 214 'lawfiz-one' => 'https://spiraclethemes.com/lawfiz-one-theme/#pricing', 215 'krystal' => 'https://spiraclethemes.com/krystal-pro-addons/', 216 'krystal-lawyer' => 'https://spiraclethemes.com/krystal-pro-addons/', 217 'krystal-business' => 'https://spiraclethemes.com/krystal-pro-addons/', 218 'krystal-shop' => 'https://spiraclethemes.com/krystal-pro-addons/' 219 ]; 220 221 return isset($theme_pricing_urls[$this->theme_slug]) ? esc_url($theme_pricing_urls[$this->theme_slug]) : esc_url('https://spiraclethemes.com/pricing/'); 222 } 223 224 // Reusable method to build $49/year plan notice message 225 private function spiraclethemes_site_library_build_49dollar_notice( $days, $ignore_param, $theme_name ) { 226 $pricing_url = $this->spiraclethemes_site_library_get_theme_pricing_url(); 227 199 228 // Convert theme name to title case and append "Pro" 200 229 $theme_pro_name = ucwords( $theme_name ) . ' Pro'; 201 230 202 231 // For all notices, use "Remind me later" option 203 232 $ignore_url = esc_url( wp_nonce_url( admin_url( 'themes.php?' . $ignore_param . '=0' ), $ignore_param . '_nonce' ) ); 204 $message = __( '🎉 Special Offer! %3$s now at just <span style="background: #319942; padding: 4px 8px; border-radius: 25px; color: #fff;"><strong>$ 3/month</strong></span> <del>$5/month</del> – making Pro accessible to all! Visit <a href="%1$s" target="_blank">our pricing page</a> to learn more. <a href="%2$s">Remind me later</a>', 'spiraclethemes-site-library' );233 $message = __( '🎉 Special Offer! %3$s now at just <span style="background: #319942; padding: 4px 8px; border-radius: 25px; color: #fff;"><strong>$49</strong></span> <del>$59</del> – making Pro accessible to all! Visit <a href="%1$s" target="_blank">our pricing page</a> to learn more. <a href="%2$s">Remind me later</a>', 'spiraclethemes-site-library' ); 205 234 return sprintf( wp_kses_post( $message ), $pricing_url, $ignore_url, $theme_pro_name ); 206 235 } … … 221 250 } 222 251 223 // Show rating notice after 7 days, but only if $ 3/monthnotices haven't been shown252 // Show rating notice after 7 days, but only if $49/year notices haven't been shown 224 253 $should_show_rating = true; 225 254 $notice_schedule = [ 226 ['days' => 0, 'key' => 'spiraclethemes_sitelib_ 3dollar_0day_notice'],227 ['days' => 7, 'key' => 'spiraclethemes_sitelib_ 3dollar_7day_notice'],228 ['days' => 14, 'key' => 'spiraclethemes_sitelib_ 3dollar_14day_notice'],229 ['days' => 28, 'key' => 'spiraclethemes_sitelib_ 3dollar_28day_notice'],230 ['days' => 60, 'key' => 'spiraclethemes_sitelib_ 3dollar_60day_notice']255 ['days' => 0, 'key' => 'spiraclethemes_sitelib_49dollar_0day_notice'], 256 ['days' => 7, 'key' => 'spiraclethemes_sitelib_49dollar_7day_notice'], 257 ['days' => 14, 'key' => 'spiraclethemes_sitelib_49dollar_14day_notice'], 258 ['days' => 28, 'key' => 'spiraclethemes_sitelib_49dollar_28day_notice'], 259 ['days' => 60, 'key' => 'spiraclethemes_sitelib_49dollar_60day_notice'] 231 260 ]; 232 233 // Check if any $ 3/monthnotices have been shown or should be shown261 262 // Check if any $49/year notices have been shown or should be shown 234 263 foreach ($notice_schedule as $notice) { 235 264 if ($days_since >= $notice['days']) { … … 241 270 } 242 271 } 243 244 // Show rating notice after 7 days if no $ 3/monthnotices have been shown272 273 // Show rating notice after 7 days if no $49/year notices have been shown 245 274 if ( $should_show_rating && $days_since >= 7 && $this->spiraclethemes_site_library_should_display_notice( 'spiraclethemes_sitelib_rating_ignore_notice', 7 ) ) { 246 275 $theme_info_url = esc_url( admin_url( 'themes.php' ) ); … … 263 292 264 293 265 // Reusable method to check if $ 3/monthplan notice should be shown266 private function spiraclethemes_site_library_should_display_ 3dollar_notice( $ignore_key, $days_after_install, $is_permanent = false ) {294 // Reusable method to check if $49/year plan notice should be shown 295 private function spiraclethemes_site_library_should_display_49dollar_notice( $ignore_key, $days_after_install, $is_permanent = false ) { 267 296 $install_date = get_option( 'spiraclethemes_sitelib_install_date' ); 268 297 if ( strtotime( "+$days_after_install days", strtotime( $install_date ) ) > time() ) { … … 272 301 $user_id = get_current_user_id(); 273 302 $dismissal_data = get_user_meta( $user_id, $ignore_key, true ); 274 303 275 304 // If no dismissal data, show the notice 276 305 if ( empty( $dismissal_data ) ) { 277 306 return true; 278 307 } 279 308 280 309 // If permanent dismissal, never show again 281 310 if ( $is_permanent ) { 282 311 return false; 283 312 } 284 313 285 314 // For temporary dismissal, check if it's time to remind again 286 315 $reminder_time = intval( $dismissal_data ); … … 288 317 } 289 318 290 // $ 3/monthplan notices - single function to determine which notice to show291 public function spiraclethemes_site_library_display_ 3dollar_notices() {319 // $49/year plan notices - single function to determine which notice to show 320 public function spiraclethemes_site_library_display_49dollar_notices() { 292 321 $days_since = $this->spiraclethemes_site_library_get_days_since_install(); 293 322 $user_id = get_current_user_id(); 294 323 295 324 // Define notice schedule 296 325 $notice_schedule = [ 297 ['days' => 0, 'key' => 'spiraclethemes_sitelib_ 3dollar_0day_notice'],298 ['days' => 7, 'key' => 'spiraclethemes_sitelib_ 3dollar_7day_notice'],299 ['days' => 14, 'key' => 'spiraclethemes_sitelib_ 3dollar_14day_notice'],300 ['days' => 28, 'key' => 'spiraclethemes_sitelib_ 3dollar_28day_notice'],301 ['days' => 60, 'key' => 'spiraclethemes_sitelib_ 3dollar_60day_notice']326 ['days' => 0, 'key' => 'spiraclethemes_sitelib_49dollar_0day_notice'], 327 ['days' => 7, 'key' => 'spiraclethemes_sitelib_49dollar_7day_notice'], 328 ['days' => 14, 'key' => 'spiraclethemes_sitelib_49dollar_14day_notice'], 329 ['days' => 28, 'key' => 'spiraclethemes_sitelib_49dollar_28day_notice'], 330 ['days' => 60, 'key' => 'spiraclethemes_sitelib_49dollar_60day_notice'] 302 331 ]; 303 332 … … 333 362 // Show the appropriate notice 334 363 if ($notice_to_show) { 335 $message = $this->spiraclethemes_site_library_build_ 3dollar_notice(364 $message = $this->spiraclethemes_site_library_build_49dollar_notice( 336 365 $notice_to_show['days'], 337 'wp_spiraclethemes_sitelib_ 3dollar_ignore',366 'wp_spiraclethemes_sitelib_49dollar_ignore', 338 367 $this->theme_name 339 368 ); … … 343 372 344 373 345 // Public ignore handlers for $ 3/monthplan notices346 public function spiraclethemes_site_library_ignore_ 3dollar_notices() {347 if ( current_user_can( 'manage_options' ) && isset( $_GET['wp_spiraclethemes_sitelib_ 3dollar_ignore'] ) && isset( $_GET['_wpnonce'] ) ) {348 if ( wp_verify_nonce( sanitize_text_field($_GET['_wpnonce']), 'wp_spiraclethemes_sitelib_ 3dollar_ignore_nonce' ) ) {374 // Public ignore handlers for $49/year plan notices 375 public function spiraclethemes_site_library_ignore_49dollar_notices() { 376 if ( current_user_can( 'manage_options' ) && isset( $_GET['wp_spiraclethemes_sitelib_49dollar_ignore'] ) && isset( $_GET['_wpnonce'] ) ) { 377 if ( wp_verify_nonce( sanitize_text_field($_GET['_wpnonce']), 'wp_spiraclethemes_sitelib_49dollar_ignore_nonce' ) ) { 349 378 $user_id = get_current_user_id(); 350 379 $days_since = $this->spiraclethemes_site_library_get_days_since_install(); 351 380 352 381 // Define notice schedule 353 382 $notice_schedule = [ 354 ['days' => 0, 'key' => 'spiraclethemes_sitelib_ 3dollar_0day_notice'],355 ['days' => 7, 'key' => 'spiraclethemes_sitelib_ 3dollar_7day_notice'],356 ['days' => 14, 'key' => 'spiraclethemes_sitelib_ 3dollar_14day_notice'],357 ['days' => 28, 'key' => 'spiraclethemes_sitelib_ 3dollar_28day_notice'],358 ['days' => 60, 'key' => 'spiraclethemes_sitelib_ 3dollar_60day_notice']383 ['days' => 0, 'key' => 'spiraclethemes_sitelib_49dollar_0day_notice'], 384 ['days' => 7, 'key' => 'spiraclethemes_sitelib_49dollar_7day_notice'], 385 ['days' => 14, 'key' => 'spiraclethemes_sitelib_49dollar_14day_notice'], 386 ['days' => 28, 'key' => 'spiraclethemes_sitelib_49dollar_28day_notice'], 387 ['days' => 60, 'key' => 'spiraclethemes_sitelib_49dollar_60day_notice'] 359 388 ]; 360 389
Note: See TracChangeset
for help on using the changeset viewer.