-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
1897 lines (1697 loc) · 81.7 KB
/
Copy pathfunctions.php
File metadata and controls
1897 lines (1697 loc) · 81.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* WP Augoose Theme Functions
*
* @package WP_Augoose
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Load security and performance enhancements
require_once get_template_directory() . '/inc/security.php';
require_once get_template_directory() . '/inc/performance.php';
/**
* Add rewrite rule for payment failed page
*/
add_action( 'init', 'wp_augoose_add_payment_failed_rewrite_rule' );
function wp_augoose_add_payment_failed_rewrite_rule() {
add_rewrite_rule( '^checkout/payment-failed/?$', 'index.php?payment_failed=1', 'top' );
add_rewrite_tag( '%payment_failed%', '([^&]+)' );
}
/**
* Filter query vars to include payment_failed
*/
add_filter( 'query_vars', 'wp_augoose_add_payment_failed_query_var' );
function wp_augoose_add_payment_failed_query_var( $vars ) {
$vars[] = 'payment_failed';
return $vars;
}
/**
* Template redirect for payment failed page
*/
add_action( 'template_redirect', 'wp_augoose_payment_failed_template_redirect' );
function wp_augoose_payment_failed_template_redirect() {
if ( get_query_var( 'payment_failed' ) ) {
$template = locate_template( 'page-payment-failed.php' );
if ( $template ) {
include $template;
exit;
}
}
}
/**
* Theme Setup
*/
function wp_augoose_setup() {
// Load textdomain - moved to init hook to prevent "too early" warning
// Textdomain will be loaded on init hook instead
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
register_nav_menus( array(
'primary' => 'Primary Menu',
'footer' => 'Footer Menu',
'language' => 'Language Switcher Menu',
'footer_about' => 'Footer: About',
'footer_help' => 'Footer: Help',
'footer_shop' => 'Footer: Shop',
) );
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
) );
add_theme_support( 'customize-selective-refresh-widgets' );
add_theme_support( 'custom-logo', array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
) );
// WooCommerce support
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
add_action( 'after_setup_theme', 'wp_augoose_setup' );
/**
* Load theme textdomain on init hook (not too early)
* This prevents WordPress 6.7+ warning about textdomain loaded too early
*/
add_action( 'init', 'wp_augoose_load_textdomain', 1 );
function wp_augoose_load_textdomain() {
load_theme_textdomain( 'wp-augoose', get_template_directory() . '/languages' );
}
/**
* Create core static pages on theme activation (only if missing).
* - Contact Us
* - About Us
* - FAQ
* - Terms of Service (includes privacy/cookies/refund/commercial use/contact)
*/
function wp_augoose_maybe_create_static_pages() {
// Only run in admin context.
if ( ! is_admin() ) {
return;
}
$pages = array(
array(
'slug' => 'contact-us',
'title' => 'Contact Us',
'template' => 'page-contact-us.php',
'content' => '',
),
array(
'slug' => 'about-us',
'title' => 'About Us',
'template' => 'page-about-us.php',
'content' =>
'<div class="augoose-section">' .
'<p class="craftsmanship-text">Started by our vision and love for American workwear.</p>' .
'<p>Each of Augoose\'s pieces is built with steady hands, perfected details, and made to endure the weight of real work. Augoose is a workwear brand that crafts versatile pieces using high-quality, locally sourced materials and collaborates with local tailors to create items with timeless design and long-lasting durability.</p>' .
'<p>We begin with our signature Double Knee pants and have developed to heavy duty Active Jacket.</p>' .
'<p>Each cut is made with precision, ensuring that every detail contributes to the flawless finish of the final product. As we continually refine our technique and craftsmanship, our goal remains simple: to bring you the finest Augoose creations possible.</p>' .
'</div>',
),
array(
'slug' => 'faq',
'title' => 'FAQ',
'template' => 'page-faq.php',
'content' =>
'<div class="augoose-section"><h2>PLEASE READ THEM CAREFULLY.</h2></div>' .
'<div class="augoose-faq">' .
'<details><summary>How do I track my order?</summary><div class="augoose-faq-answer"><p>Once your Augoose order has been shipped, you will receive an email with your tracking information so you may track the package online.</p></div></details>' .
'<details><summary>How do I cancel my order?</summary><div class="augoose-faq-answer"><p>Once you place an order, we cannot change or cancel it as we immediately process your orders for shipment. Please carefully review your order before making payment.</p></div></details>' .
'<details><summary>Can I change or refund my order?</summary><div class="augoose-faq-answer"><p>At the moment we can\'t accept any refund or change any order unless you received an incorrect, unfinished, or defective product. Please carefully review your order before making payment.</p></div></details>' .
'<details><summary>What if I received an incorrect / unfinished / defective product?</summary><div class="augoose-faq-answer"><p>We\'re sorry if it happened to you. Please contact us via email at <a href="mailto:halo@augoose.co">halo@augoose.co</a> for further processing. The product may be exchanged or returned if it meets the following criteria:</p><ol><li>The product has defects or damage to any part of the item.</li><li>The product has a size discrepancy exceeding the acceptable tolerance (±2 cm).</li><li>The product shows a significant color difference.</li><li>The product is received in a damaged condition, such as being torn, etc.</li></ol></div></details>' .
'<details><summary>What payment do you accept?</summary><div class="augoose-faq-answer"><p>We accept various payment methods that you can check on the checkout page (PayPal, Credit/Debit card, QRIS, VA for Indonesia, etc).</p></div></details>' .
'<details><summary>How long is the delivery time?</summary><div class="augoose-faq-answer"><p>Delivery times are estimates. On average it takes 3–5 days to Southeast Asia, 5–7 days to Asia Pacific and Australia, and 7–10 days to Europe and America. Please check your Air Way Bill (AWB) number sent to the email you registered at checkout and frequently track through the shipping portal.</p></div></details>' .
'<details><summary>What is the shipment method?</summary><div class="augoose-faq-answer"><p>We partner with DHL to ship your order.</p></div></details>' .
'</div>',
),
array(
'slug' => 'terms-of-service',
'title' => 'Terms of Service',
'template' => 'page-terms-of-service.php',
'content' =>
'<div class="augoose-section"><h2 id="terms-of-use">Terms of Use</h2>' .
'<p>By using this site, you agree to these terms of use, as well as any other terms, guidelines, or rules that apply to any portion of this site, without limitation or qualification. If you do not agree to these terms of use, you must exit the site immediately and discontinue any use of information or product from this site.</p>' .
'</div>' .
'<div class="augoose-section"><h2 id="privacy-policy">Privacy Policy</h2>' .
'<p>At Augoose, we are committed to protecting your personal information and ensuring your privacy is respected. You can rest assured that any information you submit to us will not be misused, abused, or sold to any other parties. We only use your personal information to complete your order.</p>' .
'</div>' .
'<div class="augoose-section"><h2 id="cookies-tracking">Cookies & Tracking</h2>' .
'<p>Our website may use cookies to enhance your browsing experience and improve functionality. You can manage your cookie preferences through your browser settings at any time.</p>' .
'</div>' .
'<div class="augoose-section"><h2 id="return-refund-policy">Return & Refund Policy</h2>' .
'<p>We always try our best to keep our items in perfect condition before we ship them to you. Currently, we do not offer refunds under any circumstances. We apologize that once you’ve submitted an order, the product cannot be cancelled or exchanged. Please check your item(s) before submitting an order to prevent any mistakes.</p>' .
'<p>If you receive an incorrect, unfinished, or defective product, please contact us at <a href="mailto:halo@augoose.co">halo@augoose.co</a>. The product may be exchanged or returned if it meets the following criteria:</p>' .
'<ol><li>The product has defects or damage to any part of the item.</li><li>The product has a size discrepancy exceeding the acceptable tolerance (±2 cm).</li><li>The product shows a significant color difference.</li><li>The product is received in a damaged condition, such as being torn, etc.</li></ol>' .
'<p>Please make sure you document an unboxing video as proof.</p>' .
'</div>' .
'<div class="augoose-section"><h2 id="commercial-use">Commercial Use</h2>' .
'<p>You may not copy, reproduce, or sell any content of this site for any commercial use on your own site.</p>' .
'</div>' .
'<div class="augoose-section"><h2 id="acceptance">Your Acceptance of These Terms</h2>' .
'<p>By using this site, you accept these terms of use and the privacy policy. By providing us with your information, you agree to the site’s privacy policy. If you do not agree to this policy, please leave this site immediately.</p>' .
'</div>' .
'<div class="augoose-section"><h2 id="contact-us">Contact Us</h2>' .
'<p>For any privacy-related concerns or questions, please contact us at: <a href="mailto:halo@augoose.co">halo@augoose.co</a></p>' .
'</div>',
),
);
foreach ( $pages as $p ) {
$existing = get_page_by_path( $p['slug'] );
if ( $existing instanceof WP_Post ) {
// If template is not set, set it (do not overwrite content).
if ( ! empty( $p['template'] ) ) {
$current_tpl = get_post_meta( $existing->ID, '_wp_page_template', true );
if ( $current_tpl !== $p['template'] ) {
update_post_meta( $existing->ID, '_wp_page_template', $p['template'] );
}
}
// Update content if old email is found (for FAQ and Terms pages)
if ( $p['slug'] === 'faq' || $p['slug'] === 'terms-of-service' ) {
$current_content = $existing->post_content;
// Check if old email exists in content
if ( strpos( $current_content, 'contact@augoose.co' ) !== false ) {
// Replace old email with new email
$updated_content = str_replace( 'contact@augoose.co', 'halo@augoose.co', $current_content );
// Also replace in mailto links
$updated_content = str_replace( 'mailto:contact@augoose.co', 'mailto:halo@augoose.co', $updated_content );
if ( $updated_content !== $current_content ) {
wp_update_post( array(
'ID' => $existing->ID,
'post_content' => $updated_content,
) );
}
}
}
continue;
}
$page_id = wp_insert_post(
array(
'post_type' => 'page',
'post_status' => 'publish',
'post_title' => $p['title'],
'post_name' => $p['slug'],
'post_content' => $p['content'],
),
true
);
if ( is_wp_error( $page_id ) ) {
continue;
}
if ( ! empty( $p['template'] ) ) {
update_post_meta( (int) $page_id, '_wp_page_template', $p['template'] );
}
}
}
function wp_augoose_seed_static_pages_once() {
// Seed once, but allow re-seeding if the option is deleted.
if ( '1' === get_option( 'wp_augoose_static_pages_seeded', '0' ) ) {
return;
}
wp_augoose_maybe_create_static_pages();
update_option( 'wp_augoose_static_pages_seeded', '1' );
}
add_action( 'after_switch_theme', 'wp_augoose_seed_static_pages_once' );
add_action( 'admin_init', 'wp_augoose_seed_static_pages_once' );
/**
* Update email in existing FAQ and Terms pages
* This function updates old email (contact@augoose.co) to new email (halo@augoose.co)
* Runs once on admin_init to update existing pages
*/
function wp_augoose_update_email_in_pages() {
// Only run in admin context
if ( ! is_admin() ) {
return;
}
// Check if already updated (run once)
if ( '1' === get_option( 'wp_augoose_email_updated', '0' ) ) {
return;
}
$pages_to_update = array( 'faq', 'terms-of-service' );
$updated = false;
foreach ( $pages_to_update as $slug ) {
$page = get_page_by_path( $slug );
if ( $page instanceof WP_Post ) {
$current_content = $page->post_content;
$updated_content = $current_content;
// Replace old email with new email (case insensitive)
$updated_content = preg_replace( '/contact@augoose\.co/i', 'halo@augoose.co', $updated_content );
// Also replace in mailto links
$updated_content = preg_replace( '/mailto:contact@augoose\.co/i', 'mailto:halo@augoose.co', $updated_content );
// Only update if content changed
if ( $updated_content !== $current_content ) {
wp_update_post( array(
'ID' => $page->ID,
'post_content' => $updated_content,
) );
$updated = true;
}
}
}
// Mark as updated if any page was updated
if ( $updated ) {
update_option( 'wp_augoose_email_updated', '1' );
}
}
add_action( 'admin_init', 'wp_augoose_update_email_in_pages' );
/**
* =========================
* Integrations: Multi-language + Multi-currency (WooCommerce)
* - UI is provided by theme.
* - Actual translation/currency conversion must be handled by plugins.
* =========================
*/
function wp_augoose_render_language_switcher() {
// Allow plugins/custom code to override completely.
if ( has_action( 'wp_augoose_language_switcher' ) ) {
echo '<div class="header-locale header-language">';
do_action( 'wp_augoose_language_switcher' );
echo '</div>';
return;
}
// Polylang
if ( function_exists( 'pll_the_languages' ) ) {
echo '<div class="header-locale header-language">';
echo '<div class="lang-switcher">';
pll_the_languages(
array(
'show_flags' => 1,
'show_names' => 0,
'dropdown' => 1,
)
);
echo '</div>';
echo '</div>';
return;
}
// WPML
if ( function_exists( 'icl_get_languages' ) ) {
$langs = icl_get_languages( 'skip_missing=0&orderby=code' );
if ( is_array( $langs ) && ! empty( $langs ) ) {
echo '<div class="header-locale header-language"><div class="lang-switcher"><select class="lang-select" onchange="if(this.value){window.location.href=this.value;}">';
foreach ( $langs as $lang_item ) {
$selected = ! empty( $lang_item['active'] ) ? ' selected' : '';
$url = isset( $lang_item['url'] ) ? $lang_item['url'] : '';
$name = '';
if ( isset( $lang_item['native_name'] ) ) {
$name = $lang_item['native_name'];
} elseif ( isset( $lang_item['translated_name'] ) ) {
$name = $lang_item['translated_name'];
} elseif ( isset( $lang_item['language_code'] ) ) {
$name = $lang_item['language_code'];
}
printf( '<option value="%s"%s>%s</option>', esc_url( $url ), $selected, esc_html( $name ) );
}
echo '</select></div></div>';
}
return;
}
// TranslatePress (if they use its shortcode)
if ( shortcode_exists( 'language-switcher' ) ) {
echo '<div class="header-locale header-language">';
echo do_shortcode( '[language-switcher]' );
echo '</div>';
return;
}
// Fallback: WP menu location "language" (user can populate it manually)
if ( has_nav_menu( 'language' ) ) {
echo '<div class="header-locale header-language">';
wp_nav_menu(
array(
'theme_location' => 'language',
'menu_id' => 'language-menu',
'container' => false,
'fallback_cb' => false,
'depth' => 1,
)
);
echo '</div>';
return;
}
// Built-in fallback: Simple language switcher (cookie-based, UI only - no translation)
$current_lang = isset( $_COOKIE['wp_augoose_lang'] ) ? sanitize_text_field( $_COOKIE['wp_augoose_lang'] ) : 'en';
$languages = array(
'en' => 'English',
'id' => 'Indonesia',
);
echo '<div class="header-locale header-language">';
echo '<select class="lang-select augoose-lang-switcher" data-current="' . esc_attr( $current_lang ) . '">';
foreach ( $languages as $code => $name ) {
$selected = ( $code === $current_lang ) ? ' selected' : '';
printf( '<option value="%s"%s>%s</option>', esc_attr( $code ), $selected, esc_html( $name ) );
}
echo '</select>';
echo '</div>';
}
function wp_augoose_render_currency_switcher() {
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
// Allow plugins/custom code to override completely.
if ( has_action( 'wp_augoose_currency_switcher' ) ) {
do_action( 'wp_augoose_currency_switcher' );
return;
}
// WPML WooCommerce Multilingual (WCML) - Let plugin render directly, no wrapper
if ( has_action( 'wcml_currency_switcher' ) ) {
do_action( 'wcml_currency_switcher', array( 'switcher_style' => 'wcml-dropdown' ) );
return;
}
}
/**
* Customizer: Announcement / Discount text (integrated with WP; header prefers Woo Store Notice if enabled).
*/
function wp_augoose_customize_register( $wp_customize ) {
$wp_customize->add_setting(
'wp_augoose_announcement_text',
array(
'default' => 'INTERNATIONAL & DOMESTIC SHIPPING AVAILABLE – FREE SHIPPING OVER $200',
'sanitize_callback' => 'wp_kses_post',
'transport' => 'refresh',
)
);
$wp_customize->add_control(
'wp_augoose_announcement_text',
array(
'type' => 'textarea',
'section' => 'title_tagline',
'label' => __( 'Announcement / Discount text', 'wp-augoose' ),
'description' => __( 'Shown in the top announcement bar. If WooCommerce “Store notice” is enabled, that text will override this.', 'wp-augoose' ),
)
);
// New arrival badge settings (integrated with WP Customizer; used in product cards).
$wp_customize->add_setting(
'wp_augoose_new_arrival_days',
array(
'default' => 30,
'sanitize_callback' => 'absint',
'transport' => 'refresh',
)
);
$wp_customize->add_control(
'wp_augoose_new_arrival_days',
array(
'type' => 'number',
'section' => 'title_tagline',
'label' => __( 'New Arrival: days threshold', 'wp-augoose' ),
'description' => __( 'Show “New Arrival” badge for products published within this many days. Set 0 to disable.', 'wp-augoose' ),
'input_attrs' => array(
'min' => 0,
'max' => 365,
'step' => 1,
),
)
);
$wp_customize->add_setting(
'wp_augoose_new_arrival_label',
array(
'default' => 'New Arrival',
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'refresh',
)
);
$wp_customize->add_control(
'wp_augoose_new_arrival_label',
array(
'type' => 'text',
'section' => 'title_tagline',
'label' => __( 'New Arrival: label text', 'wp-augoose' ),
)
);
/**
* Homepage Hero Image
*/
$wp_customize->add_setting(
'wp_augoose_home_hero_image',
array(
'default' => '',
'sanitize_callback' => 'absint',
'transport' => 'refresh',
)
);
$wp_customize->add_control(
new WP_Customize_Media_Control(
$wp_customize,
'wp_augoose_home_hero_image',
array(
'section' => 'title_tagline',
'label' => __( 'Homepage hero image', 'wp-augoose' ),
'description' => __( 'Background image for the homepage hero section.', 'wp-augoose' ),
'mime_type' => 'image',
)
)
);
}
add_action( 'customize_register', 'wp_augoose_customize_register' );
/**
* Admin-only debug: show enqueued style handles + URLs in HTML comments (helps diagnose broken layouts after migration).
*/
add_action(
'wp_footer',
function () {
if ( ! isset( $_GET['augoose_debug'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}
global $wp_styles;
if ( ! isset( $wp_styles ) || ! is_object( $wp_styles ) || ! property_exists( $wp_styles, 'queue' ) ) {
return;
}
echo "\n<!-- wp-augoose debug: styles queue\n";
foreach ( (array) $wp_styles->queue as $handle ) {
$src = '';
if ( isset( $wp_styles->registered[ $handle ] ) && isset( $wp_styles->registered[ $handle ]->src ) ) {
$src = (string) $wp_styles->registered[ $handle ]->src;
}
echo esc_html( $handle . ': ' . $src ) . "\n";
}
echo "-->\n";
},
9999
);
/**
* Admin-only debug (console): logs which CSS/JS is actually enqueued on the live site.
* Usage: open any page as admin with `?augoose_debug=1` and check DevTools Console.
*/
add_action(
'wp_footer',
function () {
if ( ! isset( $_GET['augoose_debug'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}
global $wp_styles, $wp_scripts;
$styles = array();
$scripts = array();
if ( isset( $wp_styles ) && isset( $wp_styles->queue ) ) {
foreach ( (array) $wp_styles->queue as $handle ) {
$src = '';
if ( isset( $wp_styles->registered[ $handle ] ) && isset( $wp_styles->registered[ $handle ]->src ) ) {
$src = (string) $wp_styles->registered[ $handle ]->src;
}
$styles[] = array(
'handle' => $handle,
'src' => $src,
);
}
}
if ( isset( $wp_scripts ) && isset( $wp_scripts->queue ) ) {
foreach ( (array) $wp_scripts->queue as $handle ) {
$src = '';
if ( isset( $wp_scripts->registered[ $handle ] ) && isset( $wp_scripts->registered[ $handle ]->src ) ) {
$src = (string) $wp_scripts->registered[ $handle ]->src;
}
$scripts[] = array(
'handle' => $handle,
'src' => $src,
);
}
}
$payload = wp_json_encode(
array(
'theme' => wp_get_theme()->get( 'Name' ),
'version' => wp_get_theme()->get( 'Version' ),
'styles' => $styles,
'scripts' => $scripts,
)
);
?>
<script id="wp-augoose-debug-assets">
// <![CDATA[
try {
console.log("wp-augoose debug: assets", <?php echo $payload; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);
} catch (e) {}
// ]]>
</script>
<?php
},
9999
);
/**
* Enqueue scripts and styles
*/
function wp_augoose_scripts() {
$theme_dir = get_template_directory();
$theme_dir_uri = get_template_directory_uri();
$asset_ver = static function ( $relative_path ) use ( $theme_dir ) {
$full = $theme_dir . '/' . ltrim( $relative_path, '/' );
return file_exists( $full ) ? (string) filemtime( $full ) : '1.0.0';
};
wp_enqueue_style( 'wp-augoose-style', get_stylesheet_uri(), array(), $asset_ver( 'style.css' ) );
// Custom CSS files
if ( file_exists( $theme_dir . '/assets/css/header.css' ) ) {
wp_enqueue_style( 'wp-augoose-header', $theme_dir_uri . '/assets/css/header.css', array(), $asset_ver( 'assets/css/header.css' ) );
}
if ( file_exists( $theme_dir . '/assets/css/footer.css' ) ) {
wp_enqueue_style( 'wp-augoose-footer', $theme_dir_uri . '/assets/css/footer.css', array(), $asset_ver( 'assets/css/footer.css' ) );
}
if ( file_exists( $theme_dir . '/assets/css/homepage.css' ) ) {
wp_enqueue_style( 'wp-augoose-homepage', $theme_dir_uri . '/assets/css/homepage.css', array(), $asset_ver( 'assets/css/homepage.css' ) );
}
if ( file_exists( $theme_dir . '/assets/css/brand-guidelines.css' ) ) {
wp_enqueue_style( 'wp-augoose-brand', $theme_dir_uri . '/assets/css/brand-guidelines.css', array(), $asset_ver( 'assets/css/brand-guidelines.css' ) );
}
if ( file_exists( $theme_dir . '/assets/css/pages-static.css' ) ) {
wp_enqueue_style( 'wp-augoose-pages-static', $theme_dir_uri . '/assets/css/pages-static.css', array( 'wp-augoose-brand' ), $asset_ver( 'assets/css/pages-static.css' ) );
// Contact Us page styles
if ( is_page( 'contact-us' ) || is_page_template( 'page-contact-us.php' ) ) {
wp_enqueue_style( 'wp-augoose-contact-us', $theme_dir_uri . '/assets/css/contact-us.css', array(), $asset_ver( 'assets/css/contact-us.css' ) );
}
}
// WooCommerce Integrated Styles - Fully integrated with WooCommerce & WordPress
// Ensure it loads AFTER any legacy WooCommerce custom styles to avoid conflicts.
if ( class_exists( 'WooCommerce' ) && file_exists( $theme_dir . '/assets/css/woocommerce-integrated.css' ) ) {
wp_enqueue_style(
'wp-augoose-woocommerce-integrated',
$theme_dir_uri . '/assets/css/woocommerce-integrated.css',
array( 'wp-augoose-woocommerce-custom' ),
$asset_ver( 'assets/css/woocommerce-integrated.css' )
);
wp_style_add_data( 'wp-augoose-woocommerce-integrated', 'priority', 'high' );
}
// Homepage override styles (MAXIMUM priority - load absolutely last)
if ( file_exists( $theme_dir . '/assets/css/homepage-override.css' ) ) {
wp_enqueue_style( 'wp-augoose-homepage-override', $theme_dir_uri . '/assets/css/homepage-override.css', array( 'wp-augoose-woocommerce', 'wp-augoose-homepage' ), $asset_ver( 'assets/css/homepage-override.css' ) );
// Add critical inline CSS to ensure override
wp_add_inline_style( 'wp-augoose-homepage-override', '
/* EMERGENCY OVERRIDE */
html body .latest-collection .woocommerce ul.products.columns-4 {
display: grid !important;
grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
flex-direction: unset !important;
align-items: unset !important;
flex-wrap: unset !important;
}
html body .latest-collection .woocommerce ul.products.columns-4 li.product {
width: auto !important;
margin: 0 !important;
float: none !important;
display: block !important;
flex: none !important;
}
' );
}
// NUCLEAR OPTION - Load last with highest priority
if ( file_exists( $theme_dir . '/assets/css/nuclear-override.css' ) ) {
wp_enqueue_style( 'wp-augoose-nuclear', $theme_dir_uri . '/assets/css/nuclear-override.css', array(), $asset_ver( 'assets/css/nuclear-override.css' ), 'all' );
wp_style_add_data( 'wp-augoose-nuclear', 'priority', 'high' );
}
// Product Cards Fixed - Image Full & Typography Better
if ( file_exists( $theme_dir . '/assets/css/product-card-fixed.css' ) ) {
wp_enqueue_style( 'wp-augoose-product-fixed', $theme_dir_uri . '/assets/css/product-card-fixed.css', array(), $asset_ver( 'assets/css/product-card-fixed.css' ), 'all' );
wp_enqueue_style( 'wp-augoose-latest-collection-v2', $theme_dir_uri . '/assets/css/latest-collection-v2.css', array( 'wp-augoose-product-fixed', 'wp-augoose-brand' ), $asset_ver( 'assets/css/latest-collection-v2.css' ), 'all' );
wp_enqueue_style( 'wp-augoose-button-global-style', $theme_dir_uri . '/assets/css/button-global-style.css', array( 'wp-augoose-woocommerce', 'wp-augoose-product-fixed', 'wp-augoose-latest-collection-v2' ), $asset_ver( 'assets/css/button-global-style.css' ), 'all' );
wp_style_add_data( 'wp-augoose-button-global-style', 'priority', 'high' );
wp_enqueue_style( 'wp-augoose-header-mobile-fix', $theme_dir_uri . '/assets/css/header-mobile-fix.css', array( 'wp-augoose-header' ), $asset_ver( 'assets/css/header-mobile-fix.css' ), 'all' );
wp_enqueue_style( 'wp-augoose-latest-collection-mobile-fix', $theme_dir_uri . '/assets/css/latest-collection-mobile-fix.css', array( 'wp-augoose-latest-collection-v2' ), $asset_ver( 'assets/css/latest-collection-mobile-fix.css' ), 'all' );
wp_enqueue_style( 'wp-augoose-hero-fixed', $theme_dir_uri . '/assets/css/hero-fixed.css', array( 'wp-augoose-homepage' ), $asset_ver( 'assets/css/hero-fixed.css' ), 'all' );
// Comprehensive Mobile Layout Fix - Checkout button visibility + all mobile layouts
wp_enqueue_style( 'wp-augoose-mobile-layout-complete', $theme_dir_uri . '/assets/css/mobile-layout-complete.css', array( 'wp-augoose-woocommerce-integrated', 'wp-augoose-button-global-style' ), $asset_ver( 'assets/css/mobile-layout-complete.css' ), 'all' );
wp_style_add_data( 'wp-augoose-mobile-layout-complete', 'priority', 'high' );
// Notification & Alert Styling - Separate CSS file for clean notifications
if ( file_exists( $theme_dir . '/assets/css/notification-alerts.css' ) ) {
wp_enqueue_style( 'wp-augoose-notification-alerts', $theme_dir_uri . '/assets/css/notification-alerts.css', array( 'wp-augoose-mobile-layout-complete' ), $asset_ver( 'assets/css/notification-alerts.css' ), 'all' );
wp_style_add_data( 'wp-augoose-notification-alerts', 'priority', 'high' );
}
// Additional Fixes - Latest Collection, Product Details, Checkout, Notices
// No conflicts - consolidates several fixes into one file
if ( file_exists( $theme_dir . '/assets/css/additional-fixes.css' ) ) {
wp_enqueue_style( 'wp-augoose-additional-fixes', $theme_dir_uri . '/assets/css/additional-fixes.css', array( 'wp-augoose-notification-alerts' ), $asset_ver( 'assets/css/additional-fixes.css' ), 'all' );
wp_style_add_data( 'wp-augoose-additional-fixes', 'priority', 'high' );
}
}
// Cart page - redirect to shop, menggunakan cart sidebar saja
// No CSS needed for cart page karena sudah redirect
// Custom Alert Modal - Mobile-friendly alternative to browser alert
// CRITICAL: Don't load on checkout page to prevent conflicts with WooCommerce validation
if ( file_exists( $theme_dir . '/assets/js/custom-alert-modal.js' ) ) {
// Skip on checkout page - WooCommerce needs native alerts
if ( ! ( class_exists( 'WooCommerce' ) && function_exists( 'is_checkout' ) && is_checkout() ) ) {
wp_enqueue_script(
'wp-augoose-custom-alert-modal',
$theme_dir_uri . '/assets/js/custom-alert-modal.js',
array(),
$asset_ver( 'assets/js/custom-alert-modal.js' ),
true
);
}
}
// Single Product Fixed - Sale Badge di dalam gambar
if ( class_exists( 'WooCommerce' ) && ( function_exists( 'is_product' ) && is_product() ) ) {
if ( file_exists( $theme_dir . '/assets/css/single-product-fixed.css' ) ) {
wp_enqueue_style( 'wp-augoose-single-product-fixed', $theme_dir_uri . '/assets/css/single-product-fixed.css', array(), $asset_ver( 'assets/css/single-product-fixed.css' ), 'all' );
wp_style_add_data( 'wp-augoose-single-product-fixed', 'priority', 'high' );
}
// Product Gallery Fixed - Thumbnail di Bawah, No Zoom
// Load LAST untuk override semua styling lain
if ( file_exists( $theme_dir . '/assets/css/product-gallery-fixed.css' ) ) {
wp_enqueue_style(
'wp-augoose-product-gallery-fixed',
$theme_dir_uri . '/assets/css/product-gallery-fixed.css',
array( 'wp-augoose-woocommerce-custom', 'wp-augoose-woocommerce-integrated' ), // Load after both
$asset_ver( 'assets/css/product-gallery-fixed.css' ),
'all'
);
wp_style_add_data( 'wp-augoose-product-gallery-fixed', 'priority', 'high' );
}
// Product Gallery Refactored - Load AFTER gallery-fixed untuk override
// Clean layout, mentok kiri, aspect ratio 3:4
if ( file_exists( $theme_dir . '/assets/css/product-gallery-refactored.css' ) ) {
wp_enqueue_style(
'wp-augoose-product-gallery-refactored',
$theme_dir_uri . '/assets/css/product-gallery-refactored.css',
array( 'wp-augoose-product-gallery-fixed', 'wp-augoose-woocommerce-integrated', 'wp-augoose-woocommerce-custom' ),
$asset_ver( 'assets/css/product-gallery-refactored.css' ),
'all'
);
wp_style_add_data( 'wp-augoose-product-gallery-refactored', 'priority', 'high' );
}
// Product Gallery Navigation - Auto Slide dengan Arrow
if ( file_exists( $theme_dir . '/assets/js/product-gallery-nav.js' ) ) {
wp_enqueue_script( 'wp-augoose-product-gallery-nav', $theme_dir_uri . '/assets/js/product-gallery-nav.js', array( 'jquery' ), $asset_ver( 'assets/js/product-gallery-nav.js' ), true );
}
}
// Shop Page Fixed - 4 Columns, 12 Products, Pagination, Filter Styling
if ( class_exists( 'WooCommerce' ) && ( function_exists( 'is_shop' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) ) {
if ( file_exists( $theme_dir . '/assets/css/shop-page-fixed.css' ) ) {
wp_enqueue_style( 'wp-augoose-shop-fixed', $theme_dir_uri . '/assets/css/shop-page-fixed.css', array(), $asset_ver( 'assets/css/shop-page-fixed.css' ), 'all' );
wp_style_add_data( 'wp-augoose-shop-fixed', 'priority', 'high' );
}
// Off-canvas filter (no layout shift)
if ( file_exists( $theme_dir . '/assets/css/shop-filter-offcanvas.css' ) ) {
wp_enqueue_style( 'wp-augoose-shop-filter-offcanvas', $theme_dir_uri . '/assets/css/shop-filter-offcanvas.css', array( 'wp-augoose-shop-fixed' ), $asset_ver( 'assets/css/shop-filter-offcanvas.css' ), 'all' );
wp_style_add_data( 'wp-augoose-shop-filter-offcanvas', 'priority', 999 ); // Highest priority
}
}
// Cart Sidebar - Detailed & Compact
if ( class_exists( 'WooCommerce' ) ) {
// Currency conversion loading indicator (for cart and checkout)
if ( ( function_exists( 'is_cart' ) && is_cart() ) || ( function_exists( 'is_checkout' ) && is_checkout() ) ) {
if ( file_exists( $theme_dir . '/assets/js/currency-conversion-loader.js' ) ) {
wp_enqueue_script( 'wp-augoose-currency-conversion-loader', $theme_dir_uri . '/assets/js/currency-conversion-loader.js', array( 'jquery', 'wc-cart' ), $asset_ver( 'assets/js/currency-conversion-loader.js' ), true );
// Pass exchange rates to JavaScript for console logging
$exchange_rates_data = array();
if ( class_exists( 'woocommerce_wpml' ) ) {
global $woocommerce_wpml;
if ( $woocommerce_wpml && isset( $woocommerce_wpml->multi_currency ) ) {
$multi_currency = $woocommerce_wpml->multi_currency;
if ( method_exists( $multi_currency, 'get_exchange_rates' ) ) {
$exchange_rates = $multi_currency->get_exchange_rates();
if ( is_array( $exchange_rates ) && ! empty( $exchange_rates ) ) {
$exchange_rates_data = $exchange_rates;
}
}
}
}
wp_localize_script( 'wp-augoose-currency-conversion-loader', 'wpAugooseCurrencyRates', array(
'exchange_rates' => $exchange_rates_data,
'base_currency' => get_woocommerce_currency(),
) );
}
}
if ( file_exists( $theme_dir . '/assets/css/cart-sidebar-detailed.css' ) ) {
wp_enqueue_style( 'wp-augoose-cart-sidebar-detailed', $theme_dir_uri . '/assets/css/cart-sidebar-detailed.css', array(), $asset_ver( 'assets/css/cart-sidebar-detailed.css' ), 'all' );
}
// Wishlist Sidebar (UI)
if ( file_exists( $theme_dir . '/assets/css/wishlist-sidebar.css' ) ) {
wp_enqueue_style( 'wp-augoose-wishlist-sidebar', $theme_dir_uri . '/assets/css/wishlist-sidebar.css', array(), $asset_ver( 'assets/css/wishlist-sidebar.css' ), 'all' );
}
if ( file_exists( $theme_dir . '/assets/js/cart-sidebar-detailed.js' ) ) {
wp_enqueue_script( 'wp-augoose-cart-sidebar-detailed', $theme_dir_uri . '/assets/js/cart-sidebar-detailed.js', array( 'jquery' ), $asset_ver( 'assets/js/cart-sidebar-detailed.js' ), true );
wp_localize_script( 'wp-augoose-cart-sidebar-detailed', 'wc_add_to_cart_params', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'cart_url' => wc_get_cart_url(),
'update_cart_nonce' => wp_create_nonce( 'woocommerce-cart' ),
) );
}
// Keep cart-sidebar.js for open/close functionality
if ( file_exists( $theme_dir . '/assets/js/cart-sidebar.js' ) ) {
wp_enqueue_script( 'wp-augoose-cart-sidebar', $theme_dir_uri . '/assets/js/cart-sidebar.js', array( 'jquery' ), $asset_ver( 'assets/js/cart-sidebar.js' ), true );
wp_localize_script( 'wp-augoose-cart-sidebar', 'wc_add_to_cart_params', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
) );
}
if ( file_exists( $theme_dir . '/assets/js/wishlist-sidebar.js' ) ) {
wp_enqueue_script( 'wp-augoose-wishlist-sidebar', $theme_dir_uri . '/assets/js/wishlist-sidebar.js', array( 'jquery', 'wp-augoose-main' ), $asset_ver( 'assets/js/wishlist-sidebar.js' ), true );
}
}
// Checkout Coupon - Apply Coupon
if ( class_exists( 'WooCommerce' ) && ( function_exists( 'is_checkout' ) && is_checkout() ) ) {
// CRITICAL: Ensure WooCommerce checkout script is enqueued first
// This ensures wc_checkout_form and wc_checkout_params are available
if ( ! wp_script_is( 'wc-checkout', 'enqueued' ) && ! wp_script_is( 'wc-checkout', 'registered' ) ) {
// Try to enqueue WooCommerce checkout script
if ( function_exists( 'WC' ) && WC()->frontend_includes() ) {
// WooCommerce should auto-enqueue, but ensure it's loaded
wp_enqueue_script( 'wc-checkout' );
}
}
if ( file_exists( $theme_dir . '/assets/js/checkout-coupon.js' ) ) {
wp_enqueue_script( 'wp-augoose-checkout-coupon', $theme_dir_uri . '/assets/js/checkout-coupon.js', array( 'jquery', 'wc-checkout' ), $asset_ver( 'assets/js/checkout-coupon.js' ), true );
// CRITICAL: Use unique object name to avoid overriding WooCommerce core wc_checkout_params
wp_localize_script( 'wp-augoose-checkout-coupon', 'wpAugooseCheckoutCoupon', array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'apply-coupon' ),
) );
}
// Checkout Quantity Selector
if ( file_exists( $theme_dir . '/assets/js/checkout-quantity.js' ) ) {
wp_enqueue_script( 'wp-augoose-checkout-quantity', $theme_dir_uri . '/assets/js/checkout-quantity.js', array( 'jquery', 'wc-checkout' ), $asset_ver( 'assets/js/checkout-quantity.js' ), true );
// Get cart hash to prevent checkout.min.js errors
$cart_hash = '';
if ( class_exists( 'WooCommerce' ) && WC()->cart ) {
$cart_hash = WC()->cart->get_cart_hash();
}
// CRITICAL: Use unique object name to avoid overriding WooCommerce core wc_checkout_params
// WooCommerce core uses wc_checkout_params with many fields (nonce, i18n, endpoint, etc.)
// If we override it, core checkout.min.js will break (error .toString, update checkout fails, BlockUI stuck)
wp_localize_script( 'wp-augoose-checkout-quantity', 'wpAugooseCheckoutQty', array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wp_augoose_update_qty' ),
'cartHash' => $cart_hash ? $cart_hash : '',
) );
}
}
// Checkout styling now handled by woocommerce-integrated.css
// No separate checkout CSS file needed
// Shop Filter Toggle - Simple & Direct (No jQuery dependency)
// Load on shop pages and product category pages
if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) ) {
if ( file_exists( $theme_dir . '/assets/js/shop-filter-toggle.js' ) ) {
wp_enqueue_script(
'wp-augoose-shop-filter-toggle',
$theme_dir_uri . '/assets/js/shop-filter-toggle.js',
array(), // No dependencies - pure vanilla JS
$asset_ver( 'assets/js/shop-filter-toggle.js' ),
true
);
}
}
// Main JavaScript
if ( file_exists( $theme_dir . '/assets/js/main.js' ) ) {
wp_enqueue_script( 'wp-augoose-main', $theme_dir_uri . '/assets/js/main.js', array( 'jquery' ), $asset_ver( 'assets/js/main.js' ), true );
// Latest Collection slider (only on homepage)
if ( is_front_page() ) {
wp_enqueue_script( 'wp-augoose-latest-collection-slider', $theme_dir_uri . '/assets/js/latest-collection-slider.js', array( 'jquery' ), $asset_ver( 'assets/js/latest-collection-slider.js' ), true );
}
wp_localize_script(
'wp-augoose-main',
'wpAugoose',
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wp_augoose_nonce' ),
)
);
// Simple Wishlist Script - No dependencies, works immediately
if ( file_exists( $theme_dir . '/assets/js/wishlist-simple.js' ) ) {
wp_enqueue_script(
'wp-augoose-wishlist-simple',
$theme_dir_uri . '/assets/js/wishlist-simple.js',
array(), // No dependencies
$asset_ver( 'assets/js/wishlist-simple.js' ),
true
);
}
// Add nonce to meta tag for wishlist-simple.js
add_action( 'wp_head', function() {
echo '<meta name="wp-augoose-nonce" content="' . esc_attr( wp_create_nonce( 'wp_augoose_nonce' ) ) . '">' . "\n";
}, 1 );
// CRITICAL: Add inline script to ensure wishlist handler works even if main.js fails
$inline_script = "
console.log('=== INLINE WISHLIST SCRIPT LOADED ===');
console.log('wpAugoose:', typeof wpAugoose !== 'undefined' ? wpAugoose : 'NOT DEFINED');
// Attach handler immediately when jQuery is ready
if (typeof jQuery !== 'undefined') {
jQuery(document).ready(function($) {
console.log('=== DOCUMENT READY - ATTACHING WISHLIST HANDLER ===');
console.log('Wishlist buttons found:', $('.add-to-wishlist, .wishlist-toggle').length);
$('.add-to-wishlist, .wishlist-toggle').each(function() {
console.log('Button found:', this, 'Product ID:', $(this).data('product-id'));
});
});
} else {
console.error('jQuery not available in inline script!');
}
";
wp_add_inline_script( 'wp-augoose-main', $inline_script );
}
// Variation swatches (single product)
if ( class_exists( 'WooCommerce' ) && function_exists( 'is_product' ) && is_product() && file_exists( $theme_dir . '/assets/js/variation-swatches.js' ) ) {
wp_enqueue_script(
'wp-augoose-variation-swatches',
$theme_dir_uri . '/assets/js/variation-swatches.js',
array( 'jquery' ),
$asset_ver( 'assets/js/variation-swatches.js' ),
true
);
}
// Shop view toggle (grid/list)
if ( class_exists( 'WooCommerce' ) && ( function_exists( 'is_shop' ) && is_shop() || function_exists( 'is_product_taxonomy' ) && is_product_taxonomy() ) ) {
if ( file_exists( $theme_dir . '/assets/js/shop-view-toggle.js' ) ) {
wp_enqueue_script(
'wp-augoose-shop-view',
$theme_dir_uri . '/assets/js/shop-view-toggle.js',
array( 'jquery' ),
$asset_ver( 'assets/js/shop-view-toggle.js' ),
true
);
}
}
// Simple Product Interactions
if ( file_exists( $theme_dir . '/assets/js/simple-interactions.js' ) ) {
wp_enqueue_script( 'wp-augoose-simple-interactions', $theme_dir_uri . '/assets/js/simple-interactions.js', array( 'jquery' ), $asset_ver( 'assets/js/simple-interactions.js' ), true );
}
// Product Image Swatcher - Color swatches change product image
if ( file_exists( $theme_dir . '/assets/js/product-image-swatcher.js' ) ) {
wp_enqueue_script( 'wp-augoose-image-swatcher', $theme_dir_uri . '/assets/js/product-image-swatcher.js', array( 'jquery' ), $asset_ver( 'assets/js/product-image-swatcher.js' ), true );
}
// Product Tabs - Tab switching on single product pages
if ( class_exists( 'WooCommerce' ) && is_product() ) {
if ( file_exists( $theme_dir . '/assets/js/product-tabs.js' ) ) {
wp_enqueue_script( 'wp-augoose-product-tabs', $theme_dir_uri . '/assets/js/product-tabs.js', array( 'jquery' ), $asset_ver( 'assets/js/product-tabs.js' ), true );
}
}
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'wp_augoose_scripts' );
/**
* Shop filters: hide unwanted widgets (Category) but keep Price range, Size, and Color.
*/
add_filter(
'widget_display_callback',
function ( $instance, $widget, $args ) {
if ( ! class_exists( 'WooCommerce' ) ) {
return $instance;
}
if ( ! ( function_exists( 'is_shop' ) && is_shop() ) && ! ( function_exists( 'is_product_taxonomy' ) && is_product_taxonomy() ) ) {
return $instance;
}
// Hide categories widget on product archives (user is already browsing a category page or shop listing).
if ( $widget instanceof WC_Widget_Product_Categories ) {
return false;
}
// Allow all layered nav widgets including color
// Color filter will now be visible
return $instance;