-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
1568 lines (1325 loc) · 47 KB
/
functions.php
File metadata and controls
1568 lines (1325 loc) · 47 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
/**
* Sydney functions and definitions
*
* @package Sydney
*/
if (!function_exists('sydney_setup')) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function sydney_setup()
{
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Sydney, use a find and replace
* to change 'sydney' to the name of your theme in all the template files
*/
load_theme_textdomain('sydney', get_template_directory() . '/languages');
// Add default posts and comments RSS feed links to head.
add_theme_support('automatic-feed-links');
// Content width
global $content_width;
if (!isset($content_width)) {
$content_width = 1170; /* pixels */
}
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support('title-tag');
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support('post-thumbnails');
add_image_size('sydney-large-thumb', 1000);
add_image_size('sydney-medium-thumb', 550, 400, true);
add_image_size('sydney-small-thumb', 230);
add_image_size('sydney-service-thumb', 350);
add_image_size('sydney-mas-thumb', 480);
// This theme uses wp_nav_menu() in one location.
register_nav_menus(array(
'primary' => __('Primary Menu', 'sydney'),
'mobile' => __('Mobile menu (optional)', 'sydney'),
));
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support('html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
));
/*
* Enable support for Post Formats.
* See http://codex.wordpress.org/Post_Formats
*/
add_theme_support('post-formats', array(
'aside', 'image', 'video', 'quote', 'link',
));
// Set up the WordPress core custom background feature.
add_theme_support('custom-background', apply_filters('sydney_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
)));
//Gutenberg align-wide support
add_theme_support('align-wide');
//Enable template editing. Can't use theme.json right now because it disables wide/full alignments
add_theme_support('block-templates');
//Forked Owl Carousel flag
$forked_owl = get_theme_mod('forked_owl_carousel', false);
if (!$forked_owl) {
set_theme_mod('forked_owl_carousel', true);
}
//Set the compare icon for YTIH button
update_option('yith_woocompare_button_text', sydney_get_svg_icon('icon-compare', false));
}
endif; // sydney_setup
add_action('after_setup_theme', 'sydney_setup');
/**
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function sydney_widgets_init()
{
register_sidebar(array(
'name' => __('Sidebar', 'sydney'),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
//Footer widget areas
for ($i = 1; $i <= 4; $i++) {
register_sidebar(array(
'name' => __('Footer ', 'sydney') . $i,
'id' => 'footer-' . $i,
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
}
//Register the front page widgets
if (defined('SITEORIGIN_PANELS_VERSION')) {
register_widget('Sydney_List');
register_widget('Sydney_Services_Type_A');
register_widget('Sydney_Services_Type_B');
register_widget('Sydney_Facts');
register_widget('Sydney_Clients');
register_widget('Sydney_Testimonials');
register_widget('Sydney_Skills');
register_widget('Sydney_Action');
register_widget('Sydney_Video_Widget');
register_widget('Sydney_Social_Profile');
register_widget('Sydney_Employees');
register_widget('Sydney_Latest_News');
register_widget('Sydney_Portfolio');
}
register_widget('Sydney_Contact_Info');
}
add_action('widgets_init', 'sydney_widgets_init');
/**
* Load the front page widgets.
*/
if (defined('SITEORIGIN_PANELS_VERSION')) {
require get_template_directory() . "/widgets/fp-list.php";
require get_template_directory() . "/widgets/fp-services-type-a.php";
require get_template_directory() . "/widgets/fp-services-type-b.php";
require get_template_directory() . "/widgets/fp-facts.php";
require get_template_directory() . "/widgets/fp-clients.php";
require get_template_directory() . "/widgets/fp-testimonials.php";
require get_template_directory() . "/widgets/fp-skills.php";
require get_template_directory() . "/widgets/fp-call-to-action.php";
require get_template_directory() . "/widgets/video-widget.php";
require get_template_directory() . "/widgets/fp-social.php";
require get_template_directory() . "/widgets/fp-employees.php";
require get_template_directory() . "/widgets/fp-latest-news.php";
require get_template_directory() . "/widgets/fp-portfolio.php";
/**
* Page builder support
*/
require get_template_directory() . '/inc/so-page-builder.php';
}
require get_template_directory() . "/widgets/contact-info.php";
/**
* Enqueue scripts and styles.
*/
function sydney_admin_scripts()
{
wp_enqueue_script('sydney-admin-functions', get_template_directory_uri() . '/js/admin-functions.js', array('jquery'), '20211006', true);
wp_localize_script('sydney-admin-functions', 'sydneyadm', array(
'fontawesomeUpdate' => array(
'confirmMessage' => __('Are you sure? Keep in mind this is a global change and you will need update your icons class names in all theme widgets and post types that use Font Awesome 4 icons.', 'sydney'),
'errorMessage' => __('It was not possible complete the request, please reload the page and try again.', 'sydney')
),
'headerUpdate' => array(
'confirmMessage' => __('Are you sure you want to upgrade your header?', 'sydney'),
'errorMessage' => __('It was not possible complete the request, please reload the page and try again.', 'sydney')
),
'headerUpdateDimiss' => array(
'confirmMessage' => __('Are you sure you want to dismiss this notice?', 'sydney'),
'errorMessage' => __('It was not possible complete the request, please reload the page and try again.', 'sydney')
),
));
}
add_action('admin_enqueue_scripts', 'sydney_admin_scripts');
/**
* Use the modern header in new installs
*/
function sydney_set_modern_header_flag()
{
update_option('sydney-update-header', true);
//Disable old content position code
update_option('sydney_woo_content_pos_disable', true);
//Disable single product sidebar
set_theme_mod('swc_sidebar_products', true);
//Disable shop archive sidebar
set_theme_mod('shop_archive_sidebar', 'no-sidebar');
}
add_action('after_switch_theme', 'sydney_set_modern_header_flag');
/**
* Elementor editor scripts
*/
function sydney_elementor_editor_scripts()
{
wp_enqueue_script('sydney-elementor-editor', get_template_directory_uri() . '/js/elementor.js', array('jquery'), '20200504', true);
}
add_action('elementor/frontend/after_register_scripts', 'sydney_elementor_editor_scripts');
/**
* Enqueue scripts and styles.
*/
function sydney_scripts()
{
$is_amp = sydney_is_amp();
if (null !== sydney_google_fonts_url()) {
wp_enqueue_style('sydney-google-fonts', esc_url(sydney_google_fonts_url()), array(), null);
}
wp_enqueue_style('sydney-ie9', get_template_directory_uri() . '/css/ie9.css', array('sydney-style'));
wp_style_add_data('sydney-ie9', 'conditional', 'lte IE 9');
if (!$is_amp) {
wp_enqueue_script('sydney-functions', get_template_directory_uri() . '/js/functions.min.js', array(), '20240307', true);
//Enqueue hero slider script only if the slider is in use
$slider_home = get_theme_mod('front_header_type', 'nothing');
$slider_site = get_theme_mod('site_header_type');
if (($slider_home == 'slider' && is_front_page()) || ($slider_site == 'slider' && !is_front_page())) {
wp_enqueue_script('sydney-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '', true);
wp_enqueue_script('sydney-hero-slider', get_template_directory_uri() . '/js/hero-slider.js', array('jquery'), '', true);
wp_enqueue_style('sydney-hero-slider', get_template_directory_uri() . '/css/components/hero-slider.min.css', array(), '20220824');
}
}
if (class_exists('Elementor\Plugin')) {
wp_enqueue_script('sydney-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '', true);
wp_enqueue_style('sydney-elementor', get_template_directory_uri() . '/css/components/elementor.min.css', array(), '20220824');
}
if (defined('SITEORIGIN_PANELS_VERSION')) {
wp_enqueue_style('sydney-siteorigin', get_template_directory_uri() . '/css/components/siteorigin.min.css', array(), '20220824');
wp_enqueue_script('sydney-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '', true);
wp_enqueue_script('sydney-so-legacy-scripts', get_template_directory_uri() . '/js/so-legacy.js', array('jquery'), '', true);
wp_enqueue_script('sydney-so-legacy-main', get_template_directory_uri() . '/js/so-legacy-main.min.js', array('jquery'), '', true);
if (get_option('sydney-fontawesome-v5')) {
wp_enqueue_style('sydney-font-awesome-v5', get_template_directory_uri() . '/fonts/font-awesome-v5/all.min.css');
} else {
wp_enqueue_style('sydney-font-awesome', get_template_directory_uri() . '/fonts/font-awesome.min.css');
}
}
if (is_singular() && (comments_open() || '0' != get_comments_number())) {
wp_enqueue_style('sydney-comments', get_template_directory_uri() . '/css/components/comments.min.css', array(), '20220824');
}
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
wp_enqueue_style('sydney-style-min', get_template_directory_uri() . '/css/styles.min.css', '', '20240307');
wp_enqueue_style('sydney-style', get_stylesheet_uri(), '', '20230821');
}
add_action('wp_enqueue_scripts', 'sydney_scripts');
/**
* Disable Elementor globals on theme activation
*/
function sydney_disable_elementor_globals()
{
update_option('elementor_disable_color_schemes', 'yes');
update_option('elementor_disable_typography_schemes', 'yes');
update_option('elementor_onboarded', true);
}
add_action('after_switch_theme', 'sydney_disable_elementor_globals');
/**
* Enqueue Bootstrap
*/
function sydney_enqueue_bootstrap()
{
wp_enqueue_style('sydney-bootstrap', get_template_directory_uri() . '/css/bootstrap/bootstrap.min.css', array(), true);
}
add_action('wp_enqueue_scripts', 'sydney_enqueue_bootstrap', 9);
/**
* Elementor editor scripts
*/
/**
* Change the excerpt length
*/
function sydney_excerpt_length($length)
{
$excerpt = get_theme_mod('exc_lenght', 22);
return $excerpt;
}
add_filter('excerpt_length', 'sydney_excerpt_length', 999);
/**
* Blog layout
*/
function sydney_blog_layout()
{
$layout = get_theme_mod('blog_layout', 'layout2');
return $layout;
}
/**
* Menu fallback
*/
function sydney_menu_fallback()
{
if (current_user_can('edit_theme_options')) {
echo '<a class="menu-fallback" href="' . admin_url('nav-menus.php') . '">' . __('Create your menu here', 'sydney') . '</a>';
}
}
/**
* Header image overlay
*/
function sydney_header_overlay()
{
$overlay = get_theme_mod('hide_overlay', 0);
if (!$overlay) {
echo '<div class="overlay"></div>';
}
}
/**
* Header video
*/
function sydney_header_video()
{
if (!function_exists('the_custom_header_markup')) {
return;
}
$front_header_type = get_theme_mod('front_header_type');
$site_header_type = get_theme_mod('site_header_type');
if ((get_theme_mod('front_header_type') == 'core-video' && is_front_page() || get_theme_mod('site_header_type') == 'core-video' && !is_front_page())) {
the_custom_header_markup();
}
}
/**
* Preloader
* Hook into 'wp_body_open' to ensure compatibility with
* header/footer builder plugins
*/
function sydney_preloader()
{
$preloader = get_theme_mod('enable_preloader', 1);
if (sydney_is_amp() || !$preloader) {
return;
}
?>
<div class="preloader">
<div class="spinner">
<div class="pre-bounce1"></div>
<div class="pre-bounce2"></div>
</div>
</div>
<?php
}
add_action('wp_body_open', 'sydney_preloader');
add_action('elementor/theme/before_do_header', 'sydney_preloader'); // Elementor Pro Header Builder
/**
* Header clone
*/
function sydney_header_clone()
{
$front_header_type = get_theme_mod('front_header_type', 'nothing');
$site_header_type = get_theme_mod('site_header_type');
if (class_exists('Woocommerce')) {
if (is_shop()) {
$shop_thumb = get_the_post_thumbnail_url(get_option('woocommerce_shop_page_id'));
if ($shop_thumb) {
return;
}
} elseif (is_product_category()) {
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_term_meta($cat->term_id, 'thumbnail_id', true);
$shop_archive_thumb = wp_get_attachment_url($thumbnail_id);
if ($shop_archive_thumb) {
return;
}
}
}
if (($front_header_type == 'nothing' && is_front_page()) || ($site_header_type == 'nothing' && !is_front_page())) {
echo '<div class="header-clone"></div>';
}
}
add_action('sydney_before_header', 'sydney_header_clone');
/**
* Get image alt
*/
function sydney_get_image_alt($image)
{
global $wpdb;
if (empty($image)) {
return false;
}
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid=%s;", strtolower($image)));
$id = (!empty($attachment)) ? $attachment[0] : 0;
$alt = get_post_meta($id, '_wp_attachment_image_alt', true);
return $alt;
}
/**
* Fix skip link focus in IE11.
*
* This does not enqueue the script because it is tiny and because it is only for IE11,
* thus it does not warrant having an entire dedicated blocking script being loaded.
*
* from TwentyTwenty
*
* @link https://git.io/vWdr2
*/
function sydney_skip_link_focus_fix()
{
if (sydney_is_amp()) {
return;
}
?>
<script>
/(trident|msie)/i.test(navigator.userAgent) && document.getElementById && window.addEventListener && window.addEventListener("hashchange", function() {
var t, e = location.hash.substring(1);
/^[A-z0-9_-]+$/.test(e) && (t = document.getElementById(e)) && (/^(?:a|select|input|button|textarea)$/i.test(t.tagName) || (t.tabIndex = -1), t.focus())
}, !1);
</script>
<?php
}
add_action('wp_print_footer_scripts', 'sydney_skip_link_focus_fix');
/**
* Get SVG code for specific theme icon
*/
function sydney_get_svg_icon($icon, $echo = false)
{
$svg_code = wp_kses( //From TwentTwenty. Keeps only allowed tags and attributes
Sydney_SVG_Icons::get_svg_icon($icon),
array(
'svg' => array(
'class' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true,
'aria-hidden' => true,
'role' => true,
'focusable' => true,
'fill' => true,
),
'path' => array(
'fill' => true,
'fill-rule' => true,
'd' => true,
'transform' => true,
'stroke' => true,
'stroke-width' => true,
'stroke-linejoin' => true
),
'polygon' => array(
'fill' => true,
'fill-rule' => true,
'points' => true,
'transform' => true,
'focusable' => true,
),
'rect' => array(
'x' => true,
'y' => true,
'width' => true,
'height' => true,
'transform' => true
),
)
);
if ($echo != false) {
echo $svg_code; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
return $svg_code;
}
}
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Page metabox
*/
require get_template_directory() . '/inc/classes/class-sydney-page-metabox.php';
/**
* Posts archive
*/
require get_template_directory() . '/inc/classes/class-sydney-posts-archive.php';
/**
* Display conditions
*/
require get_template_directory() . '/inc/display-conditions.php';
/**
* Header
*/
require get_template_directory() . '/inc/classes/class-sydney-header.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Slider
*/
require get_template_directory() . '/inc/slider.php';
/**
* Styles
*/
require get_template_directory() . '/inc/styles.php';
/**
* Woocommerce basic integration
*/
require get_template_directory() . '/inc/woocommerce.php';
/**
* WPML
*/
if (class_exists('SitePress')) {
require get_template_directory() . '/inc/integrations/wpml/class-sydney-wpml.php';
}
/**
* LifterLMS
*/
if (class_exists('LifterLMS')) {
require get_template_directory() . '/inc/integrations/lifter/class-sydney-lifterlms.php';
}
/**
* Learndash
*/
if (class_exists('SFWD_LMS')) {
require get_template_directory() . '/inc/integrations/learndash/class-sydney-learndash.php';
}
/**
* Learnpress
*/
if (class_exists('LearnPress')) {
require get_template_directory() . '/inc/integrations/learnpress/class-sydney-learnpress.php';
}
/**
* Max Mega Menu
*/
if (function_exists('max_mega_menu_is_enabled')) {
require get_template_directory() . '/inc/integrations/class-sydney-maxmegamenu.php';
}
/**
* AMP
*/
require get_template_directory() . '/inc/integrations/class-sydney-amp.php';
/**
* Upsell
*/
require get_template_directory() . '/inc/customizer/upsell/class-customize.php';
/**
* Gutenberg
*/
require get_template_directory() . '/inc/editor.php';
/**
* Fonts
*/
require get_template_directory() . '/inc/fonts.php';
/**
* SVG codes
*/
require get_template_directory() . '/inc/classes/class-sydney-svg-icons.php';
/**
* Review notice
*/
require get_template_directory() . '/inc/notices/class-sydney-review.php';
/**
* Schema
*/
require get_template_directory() . '/inc/schema.php';
/**
* Theme update migration functions
*/
require get_template_directory() . '/inc/theme-update.php';
/**
* Theme dashboard.
*/
require get_template_directory() . '/inc/dashboard/class-dashboard.php';
/**
* Theme dashboard settings.
*/
require get_template_directory() . '/inc/dashboard/class-dashboard-settings.php';
/**
* Performance
*/
require get_template_directory() . '/inc/performance/class-sydney-performance.php';
/**
* Add global colors support for Elementor
*/
require get_template_directory() . '/inc/integrations/elementor/class-sydney-elementor-global-colors.php';
/**
* Template library for Elementor
*/
function sydney_elementor_template_library()
{
if (did_action('elementor/loaded')) {
require get_template_directory() . '/inc/integrations/elementor/library/library-manager.php';
require get_template_directory() . '/inc/integrations/elementor/library/library-source.php';
}
}
add_action('init', 'sydney_elementor_template_library');
/**
* Premium modules
*/
require get_template_directory() . '/inc/classes/class-sydney-modules.php';
/**
* Block styles
*/
require get_template_directory() . '/inc/block-styles.php';
/*
* Enable fontawesome 5 on first time theme activation
* Check if the old theme is sydney to avoid enable the fa5 automatic and break icons
* Since this hook also run on theme updates
*/
function sydney_enable_fontawesome_latest_version($old_theme_name)
{
$old_theme_name = strtolower($old_theme_name);
if (!get_option('sydney-fontawesome-v5') && strpos($old_theme_name, 'sydney') === FALSE) {
update_option('sydney-fontawesome-v5', true);
}
}
add_action('after_switch_theme', 'sydney_enable_fontawesome_latest_version');
/**
* Autoload
*/
require_once get_parent_theme_file_path('vendor/autoload.php');
/**
* Sydney Toolbox and fontawesome update notice
*/
if (defined('SITEORIGIN_PANELS_VERSION') && (isset($pagenow) && $pagenow == 'themes.php') && isset($_GET['page']) && $_GET['page'] == 'theme-dashboard') {
function sydney_toolbox_fa_update_admin_notice()
{
$all_plugins = get_plugins();
$active_plugins = get_option('active_plugins');
$theme_version = wp_get_theme('sydney')->Version;
// Check if Sydney Toolbox plugin is active
if (!in_array('sydney-toolbox/sydney-toolbox.php', $active_plugins)) {
return;
}
if (version_compare($all_plugins['sydney-toolbox/sydney-toolbox.php']['Version'], '1.16', '>=')) {
if (!get_option('sydney-fontawesome-v5')) { ?>
<div class="notice notice-success thd-theme-dashboard-notice-success is-dismissible">
<p>
<strong><?php esc_html_e('Sydney Font Awesome Update: ', 'sydney'); ?></strong> <?php esc_html_e('Your website is currently running the version 4. Click in the below button to update to version 5.', 'sydney'); ?>
<br>
<strong><?php esc_html_e('Important: ', 'sydney'); ?></strong> <?php esc_html_e('This is a global change. That means this change will affect all website icons and you will need update the icons class names in all theme widgets and post types that use Font Awesome 4 icons. For example: "fa-android" to "fab fa-android".', 'sydney'); ?>
</p>
<a href="#" class="button sydney-update-fontawesome" data-nonce="<?php echo esc_attr(wp_create_nonce('sydney-fa-updt-nonce')); ?>" style="margin-bottom: 9px;"><?php esc_html_e('Update to v5', 'sydney'); ?></a>
<br>
</div>
<?php
}
return;
} ?>
<div class="notice notice-success thd-theme-dashboard-notice-success is-dismissible">
<p>
<?php echo wp_kses_post(sprintf(__('<strong>Optional:</strong> Now <strong>Sydney</strong> is compatible with Font Awesome 5. For it is needed the latest version of <strong>Sydney Toolbox</strong> plugin. You can update the plugin <a href="%s">here</a>.', 'sydney'), admin_url('plugins.php'))); ?><br>
<strong><?php esc_html_e('Important: ', 'sydney'); ?></strong> <?php esc_html_e('This is a global change. That means this change will affect all website icons and you will need update the icons class names in all theme widgets and post types that use Font Awesome 4 icons. For example: "fa-android" to "fab fa-android".', 'sydney'); ?>
</p>
</div>
<?php
}
add_action('admin_notices', 'sydney_toolbox_fa_update_admin_notice');
}
$movies = array(
array(
'title' => 'Форрест Гамп',
'content' => 'Форрест Гамп - невероятная история человека с низким IQ, который становится свидетелем и участником ключевых событий 20 века.',
'price' => '200',
'release_date' => '1994-07-06',
'genres' => array('драма', 'романтика'),
'actors' => array('Том Хэнкс', 'Робин Райт'),
'country' => 'США',
'thumbnail' => 'https://avatars.mds.yandex.net/get-kinopoisk-image/1599028/3560b757-9b95-45ec-af8c-623972370f9d/220x330',
),
array(
'title' => 'Зеленая миля',
'content' => 'История охранника тюрьмы, который обнаруживает, что один из заключенных обладает необычными способностями.',
'price' => '180',
'release_date' => '1999-12-10',
'genres' => array('драма', 'фэнтези'),
'actors' => array('Том Хэнкс', 'Майкл Кларк Дункан'),
'country' => 'США',
'thumbnail' => 'https://upload.wikimedia.org/wikipedia/ru/b/b0/Green_mile_film.jpg'
),
array(
'title' => 'Побег из Шоушенка',
'content' => 'Драматическая история о невинно осужденном банкире Энди Дюфрейне, который строит дружбу с заключенным Реддом.',
'price' => '220',
'release_date' => '1994-09-23',
'genres' => array('драма'),
'actors' => array('Тим Роббинс', 'Морган Фриман'),
'country' => 'США',
'thumbnail' => 'https://upload.wikimedia.org/wikipedia/ru/d/de/Movie_poster_the_shawshank_redemption.jpg'
),
array(
'title' => 'Звёздные войны: Эпизод 4 – Новая надежда',
'content' => 'Эпическая космическая сага о борьбе между добром и злом в далекой галактике.',
'price' => '150',
'release_date' => '1977-05-25',
'genres' => array('фантастика', 'боевик'),
'actors' => array('Марк Хэмилл', 'Харрисон Форд', 'Кэрри Фишер'),
'country' => 'США',
'thumbnail' => 'https://avatars.mds.yandex.net/get-kinopoisk-image/1600647/9bdc6690-de82-4a8c-a114-aa3a353bc1da/220x330'
),
array(
'title' => 'Назад в будущее',
'content' => 'Молодой изобретатель Док Браун создает машину времени из автомобиля и отправляет своего друга Марти МакФлай в прошлое.',
'price' => '190',
'release_date' => '1985-07-03',
'genres' => array('фантастика', 'комедия'),
'actors' => array('Майкл Дж. Фокс', 'Кристофер Ллойд'),
'country' => 'США',
'thumbnail' => 'https://upload.wikimedia.org/wikipedia/ru/9/90/BTTF_DVD_rus.jpg'
),
array(
'title' => 'Интерстеллар',
'content' => 'Группа исследователей путешествует сквозь червоточины в космосе в поисках нового дома для человечества.',
'price' => '240',
'release_date' => '2014-11-07',
'genres' => array('фантастика', 'драма'),
'actors' => array('Мэттью Макконахи', 'Энн Хэтэуэй'),
'country' => 'США',
'thumbnail' => 'https://upload.wikimedia.org/wikipedia/ru/c/c3/Interstellar_2014.jpg'
),
array(
'title' => 'Темный рыцарь',
'content' => 'Бэтмен сражается с преступным гением Джокером, который хочет привести Готэм к хаосу.',
'price' => '210',
'release_date' => '2008-07-18',
'genres' => array('боевик', 'драма'),
'actors' => array('Кристиан Бэйл', 'Хит Леджер'),
'country' => 'США',
'thumbnail' => 'https://thumbs.dfs.ivi.ru/storage5/contents/3/b/0d5de29534357c386470875cabb776.jpg'
),
array(
'title' => 'Пираты Карибского моря: Проклятие Черной жемчужины',
'content' => 'Капитан Джек Воробей и команда отправляются на поиски пропавшей легендарной ацтекской монеты.',
'price' => '170',
'release_date' => '2003-07-09',
'genres' => array('приключения', 'фэнтези'),
'actors' => array('Джонни Депп', 'Орландо Блум', 'Кира Найтли'),
'country' => 'США',
'thumbnail' => 'https://avatars.mds.yandex.net/get-kinopoisk-image/1773646/d7e3dbd6-e4a9-4485-b751-d02f49825166/220x330'
),
array(
'title' => 'Титаник',
'content' => 'Романтическая история о пассажирах лайнера "Титаник", который столкнулся с айсбергом во время своего первого плавания.',
'price' => '220',
'release_date' => '1997-12-19',
'genres' => array('драма', 'романтика'),
'actors' => array('Леонардо ДиКаприо', 'Кейт Уинслет'),
'country' => 'США',
'thumbnail' => 'https://mogilevnews.by/sites/default/files/uploaded/titanik_1.jpg'
),
array(
'title' => 'Гарри Поттер и философский камень',
'content' => 'Юный волшебник Гарри Поттер учится в Хогвартсе и раскрывает тайну таинственного камня.',
'price' => '160',
'release_date' => '2001-11-16',
'genres' => array('фэнтези', 'приключения'),
'actors' => array('Дэниел Рэдклифф', 'Эмма Уотсон', 'Руперт Гринт'),
'country' => 'Великобритания',
'thumbnail' => 'https://avatars.mds.yandex.net/get-kinopoisk-image/1898899/27ed5c19-a045-49dd-8624-5f629c5d96e0/600x900'
),
);
function create_movie_post_type()
{
$labels = array(
'name' => 'Фильмы',
'singular_name' => 'Фильм',
'add_new' => 'Добавить новый',
'add_new_item' => 'Добавить новый фильм',
'edit_item' => 'Редактировать фильм',
'new_item' => 'Новый фильм',
'view_item' => 'Посмотреть фильм',
'search_items' => 'Найти фильм',
'not_found' => 'Фильмы не найдены',
'not_found_in_trash' => 'В корзине фильмы не найдены',
'parent_item_colon' => '',
'menu_name' => 'Фильмы'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'movie'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields')
);
register_post_type('movie', $args);
}
add_action('init', 'create_movie_post_type');
function add_movies_from_array($movies)
{
foreach ($movies as $movie) {
$existing_post = get_page_by_title($movie['title'], OBJECT, 'movie');
if ($existing_post) {
continue;
}
$post_id = wp_insert_post(array(
'post_type' => 'movie',
'post_title' => $movie['title'],
'post_content' => $movie['content'],
'post_status' => 'publish',
));
if ($post_id) {
foreach ($movie as $key => $value) {
if (in_array($key, array('title', 'content', 'actors', 'genres', 'release_date', 'country', 'price', 'thumbnail'))) {
continue;
}
update_post_meta($post_id, $key, $value);
}
update_post_meta($post_id, 'actors', $movie['actors']);
update_post_meta($post_id, 'genres', $movie['genres']);
update_post_meta($post_id, 'thumbnail', $movie['thumbnail']);
}
}
}
add_movies_from_array($movies);
function create_movie_taxonomies()
{
$labels = array(
'name' => 'Жанры',
'singular_name' => 'Жанр',
'search_items' => 'Искать Жанр',
'all_items' => 'Все Жанры',
'parent_item' => 'Родительский Жанр',
'parent_item_colon' => 'Родительский Жанр:',
'edit_item' => 'Редактировать Жанр',
'update_item' => 'Обновить Жанр',
'add_new_item' => 'Добавить новый Жанр',
'new_item_name' => 'Новое имя Жанра',
'menu_name' => 'Жанры',
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'genre'),
);
register_taxonomy('genre', 'movie', $args);
$labels = array(
'name' => 'Страны',
'singular_name' => 'Страна',
'search_items' => 'Искать Страну',
'all_items' => 'Все Страны',
'edit_item' => 'Редактировать Страну',
'update_item' => 'Обновить Страну',
'add_new_item' => 'Добавить новую Страну',
'new_item_name' => 'Новое имя Страны',
'menu_name' => 'Страны',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'country'),
);
register_taxonomy('country', 'movie', $args);
$labels = array(
'name' => 'Актеры',
'singular_name' => 'Актер',
'search_items' => 'Искать Актера',
'all_items' => 'Все Актеры',
'edit_item' => 'Редактировать Актера',
'update_item' => 'Обновить Актера',