-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
executable file
·1860 lines (1480 loc) · 68.2 KB
/
functions.php
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
error_reporting(E_ERROR | E_PARSE);
// define('DM_API_URL', 'http://localhost:8000');
define('DM_API_URL', 'https://app.dropmock.com');
define('DM_CLOUDFRONT_DOMAIN', 'https://d5mnuqe4gnb1i.cloudfront.net');
define('DM_RENDER_URL', 'http://createmy.video');
define('WEBSITE_URL',get_site_url());
define( 'O2_DIRECTORY', get_template_directory() . '/inc/o2/' );
define( 'O2_DIRECTORY_URI', get_template_directory_uri() . '/inc/o2/' );
define('DM_STORE_DIRECTORY', get_theme_root() . '/' . basename(dirname(__FILE__)) . '/');
define('DM_STORE_PARENT_URL', get_theme_root_uri() . '/' . basename(dirname(__FILE__)) . '/');
// define( 'O2_DIRECTORY_URI', get_template_directory_uri() . '/inc/o2/' );
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once ('class-tgm-plugin-activation.php');
if ( class_exists( 'WooCommerce' ) ) {
setThemeDefaultSettings();
}
function setThemeDefaultSettings(){
require_once ('background/example-plugin.php');
createDefaultNavBar();
createDefaultPages();
}
add_action('tgmpa_register','register_required_plugins');
function register_required_plugins() {
$plugins = array(
// This is an example of how to include a plugin pre-packaged with a theme.
array(
'name' => 'WP Pusher', // The plugin name.
'slug' => 'wppusher', // The plugin slug (typically the folder name).
'source' => DM_STORE_DIRECTORY . '/plugins/wppusher.zip', // The plugin source.
'required' => true, // If false, the plugin is only 'recommended' instead of required.
'version' =>'', // E.g. 1.0.0. If set, the active plugin must be this version or higher.
'force_activation' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
'external_url' => '', // If set, overrides default API URL and points to an external URL.
)
);
/**
* Array of configuration settings. Amend each line as needed.
* If you want the default strings to be available under your own theme domain,
* leave the strings uncommented.
* Some of the strings are added into a sprintf, so see the comments at the
* end of each line for what each argument will be.
*/
$config = array(
'default_path' =>'', // Default absolute path to pre-packaged plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' =>'', // Message to output right before the plugins table.
'strings' => array(
'page_title' => __( 'Install Required Plugins', 'tgmpa' ),
'menu_title' => __( 'Install Plugins', 'tgmpa' ),
'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), // %s = plugin name.
'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ),
'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s).
'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s).
'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s).
'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s).
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins' ),
'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ),
'complete' => __( 'All plugins installed and activated successfully. %s', 'tgmpa' ), // %s = dashboard link.
'nag_type' => 'updated' // Determines admin notice type – can only be 'updated', 'update-nag' or 'error'.
)
);
tgmpa( $plugins, $config );
}
/*
CREATE NAVIGATION MENU HOME - ABOUT - CONTACT - BLOG - SEARCH - CART-----START
*/
function createDefaultNavBar(){
$menu_name = 'Navigation Menu';
$menu_exists = wp_get_nav_menu_object( $menu_name );
// If it doesn't exist, let's create it.
if( !$menu_exists){
$menu_id = wp_create_nav_menu($menu_name);
// Set up default menu items
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Home'),
'menu-item-classes' => 'home',
'menu-item-url' => home_url( '/' ),
'menu-item-status' => 'publish'));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Shop'),
'menu-item-classes' => 'shop',
'menu-item-url' => home_url( '/shop/' ),
'menu-item-status' => 'publish'));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('About'),
'menu-item-classes' => 'about',
'menu-item-url' => home_url( '/about/' ),
'menu-item-status' => 'publish'));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Contact'),
'menu-item-classes' => 'contact',
'menu-item-url' => home_url( '/contact/' ),
'menu-item-status' => 'publish'));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Blog'),
'menu-item-url' => home_url( '/blog/' ),
'menu-item-status' => 'publish'));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Cart'),
'menu-item-classes' => 'fas fa-shopping-cart',
'menu-item-url' => get_permalink( wc_get_page_id( 'cart' ) ),
'menu-item-status' => 'publish'));
}
add_option( 'navigation_menu_id',wp_get_nav_menu_object( $menu_name )->term_id , '', 'yes' );
}
/*
----------------------CREATING DEFAULT PAGES--------------------------------START
*/
function createDefaultPages(){
$default_pages_is_created = get_option('default_pages_is_created');
if($default_pages_is_created != '1'){
$pictures = [
'About' => get_template_directory_uri().'/inc/assets/img/about_pic.jpg'
,'Contact' => get_template_directory_uri().'/inc/assets/img/contact_pic.jpg'
];
$default_pages = ['About','Contact','Blog'];
$about_content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
foreach ($default_pages as $page) {
$check = get_page_by_title($page);
if($check == null || $check->post_status == 'trash'){
$new_page = array(
'post_title' => $page,
'post_content' => ($page == 'About')? $about_content : '' ,
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_type' => 'page'
);
$page_id = wp_insert_post($new_page);
$template_file_name = 'page-'.strtolower($page).'.php';
update_post_meta( $page_id, '_wp_page_template', $template_file_name );
if($page == 'About' || 'Contact')
agencytheme_attachImg($pictures[$page], $page_id);
}
}
add_option('default_pages_is_created','1','','yes');
}
}
function searchfilter($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('product'));
$query->set('posts_per_page',1000);
}
return $query;
}
add_filter('pre_get_posts','searchfilter');
if ( ! function_exists( 'wp_bootstrap_starter_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 wp_bootstrap_starter_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on WP Bootstrap Starter, use a find and replace
* to change 'wp-bootstrap-starter' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'wp-bootstrap-starter', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* 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 https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'wp-bootstrap-starter' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'comment-form',
'comment-list',
'caption',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'wp_bootstrap_starter_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
function wp_boostrap_starter_add_editor_styles() {
add_editor_style( 'custom-editor-style.css' );
}
add_action( 'admin_init', 'wp_boostrap_starter_add_editor_styles' );
}
endif;
add_action( 'after_setup_theme', 'wp_bootstrap_starter_setup' );
/**
* Add Welcome message to dashboard
*/
function wp_bootstrap_starter_reminder(){
$theme_page_url = 'https://afterimagedesigns.com/wp-bootstrap-starter/?dashboard=1';
if(!get_option( 'triggered_welcomet')){
$message = sprintf(__( 'Welcome to DropMock Store Theme! Before diving in to your new theme, Please make sure you have reviewed all tutorials needed to start selling on your store.
<a style="color:white" target="_blank" href="https://dropmock.com/fusionstore-tutorial/">Watch Here</a>', 'wp-bootstrap-starter' ),
esc_url( $theme_page_url )
);
printf(
'<div class="notice is-dismissible" style="background-color: #6C2EB9; color: #fff; border-left: none;">
<p>%1$s</p>
</div>',
$message
);
add_option( 'triggered_welcomet', '1', '', 'yes' );
}
}
add_action( 'admin_notices', 'wp_bootstrap_starter_reminder' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function wp_bootstrap_starter_content_width() {
$GLOBALS['content_width'] = apply_filters( 'wp_bootstrap_starter_content_width', 1170 );
}
add_action( 'after_setup_theme', 'wp_bootstrap_starter_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function wp_bootstrap_starter_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'wp-bootstrap-starter' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'wp-bootstrap-starter' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 1', 'wp-bootstrap-starter' ),
'id' => 'footer-1',
'description' => esc_html__( 'Add widgets here.', 'wp-bootstrap-starter' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 2', 'wp-bootstrap-starter' ),
'id' => 'footer-2',
'description' => esc_html__( 'Add widgets here.', 'wp-bootstrap-starter' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 3', 'wp-bootstrap-starter' ),
'id' => 'footer-3',
'description' => esc_html__( 'Add widgets here.', 'wp-bootstrap-starter' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'wp_bootstrap_starter_widgets_init' );
/**
* Enqueue scripts for the admin dashboard.
*/
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 5px;
height: 5px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.dd-selected-icon{
font-size:20px !important;
}
</style>';
}
/**
* Add theme settings in the customizer
*/
add_action('customize_register', function ($wp_customize) {
if( 'DropMock MarketPlace Theme' != get_current_theme())
return;
include('icon_customizer.php');
$wp_customize->remove_control('woocommerce_catalog_columns');
// ADD SECTION - FOOTER SECTION
$wp_customize->add_section('ad_section', array(
'title' => __('Advertisement Section', 'wpdmmp_theme'),
'priority' => 31,
));
// ADD SECTION - SOCIAL LINKS SECTION
$wp_customize->add_section('social_links_section', array(
'title' => __('Social Links', 'wpdmmp_theme'),
'priority' => 31,
));
// ADD SECTION - CONTACT INFO SECTION
$wp_customize->add_section('contact_info_section', array(
'title' => __('Contact Info', 'wpdmmp_theme'),
'priority' => 31,
));
// AD SPACE SETTING
$wp_customize->add_setting('footer_ad_space', array(
'default' => '',
'transport' => 'refresh',
));
// AD SPACE SETTING
$wp_customize->add_setting('footer_ad_height', array(
'default' => '',
'transport' => 'refresh',
));
// AD SPACE SETTING
$wp_customize->add_setting('footer_ad_width', array(
'default' => '',
'transport' => 'refresh',
));
// AD SPACE SETTING
$wp_customize->add_setting('footer_ad_link', array(
'default' => '',
'transport' => 'refresh',
));
//SOCIAL LINKS
$wp_customize->add_setting('social_facebook_link', array('default' => 'http://facebook.com','transport' => 'refresh',));
$wp_customize->add_setting('social_instagram_link', array('default' => 'http://instagram.com','transport' => 'refresh',));
$wp_customize->add_setting('social_twitter_link', array('default' => 'https://twitter.com','transport' => 'refresh',));
$wp_customize->add_setting('social_linkedin_link', array('default' => 'https://www.linkedin.com','transport' => 'refresh',));
//CONTACT INFO
$wp_customize->add_setting('contact_info_phone_1', array('default' => 'phone1','transport' => 'refresh'));
$wp_customize->add_setting('contact_info_phone_2', array('' => 'refresh','default' => 'phone2'));
$wp_customize->add_setting('contact_info_address_1', array('' => 'refresh','default' => 'Address Line 1 '));
$wp_customize->add_setting('contact_info_address_2', array('' => 'refresh','default' => 'Address Line 2'));
$wp_customize->add_setting('contact_info_email', array('' => 'refresh','default' => 'Email'));
// AD SPACE CONTROL
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'footer_ad_space',
array(
'label' => __('Upload an image to be used as AD', 'wpdmmp_theme'),
'section' => 'ad_section',
'settings' => 'footer_ad_space',
'priority' =>12
)
)
);
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'footer_ad_width', array(
'label' => __( 'Width in %', 'wp-bootstrap-starter' ),
'section' => 'ad_section',
'settings' => 'footer_ad_width',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'footer_ad_height', array(
'label' => __( 'Height in Pixels', 'wp-bootstrap-starter' ),
'section' => 'ad_section',
'settings' => 'footer_ad_height',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'footer_ad_link', array(
'label' => __( 'AD URL', 'wp-bootstrap-starter' ),
'section' => 'ad_section',
'settings' => 'footer_ad_link',
'type' => 'text',
'priority' =>10,
)));
/*
---------------SOCIAL LINKS CONTROLS-----------------START
*/
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'social_facebook_link', array(
'label' => __( 'Facebook Link', 'wp-bootstrap-starter' ),
'section' => 'social_links_section',
'settings' => 'social_facebook_link',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'social_instagram_link', array(
'label' => __( 'Instagram Link', 'wp-bootstrap-starter' ),
'section' => 'social_links_section',
'settings' => 'social_instagram_link',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'social_twitter_link', array(
'label' => __( 'Twitter Link', 'wp-bootstrap-starter' ),
'section' => 'social_links_section',
'settings' => 'social_twitter_link',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'social_linkedin_link', array(
'label' => __( 'Linkedin Link', 'wp-bootstrap-starter' ),
'section' => 'social_links_section',
'settings' => 'social_linkedin_link',
'type' => 'text',
'priority' =>10,
)));
/*
---------------SOCIAL LINKS CONTROLS-----------------END
*/
/*
---------------CONTACT INFO CONTROLS-----------------START
*/
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'contact_info_phone_1', array(
'label' => __( 'Phone Line 1', 'wp-bootstrap-starter' ),
'section' => 'contact_info_section',
'settings' => 'contact_info_phone_1',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'contact_info_phone_2', array(
'label' => __( 'Phone Line 2', 'wp-bootstrap-starter' ),
'section' => 'contact_info_section',
'settings' => 'contact_info_phone_2',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'contact_info_address_1', array(
'label' => __( 'Address Line 1', 'wp-bootstrap-starter' ),
'section' => 'contact_info_section',
'settings' => 'contact_info_address_1',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'contact_info_address_2', array(
'label' => __( 'Address Line 2', 'wp-bootstrap-starter' ),
'section' => 'contact_info_section',
'settings' => 'contact_info_address_2',
'type' => 'text',
'priority' =>10,
)));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'contact_info_email', array(
'label' => __( 'Email', 'wp-bootstrap-starter' ),
'section' => 'contact_info_section',
'settings' => 'contact_info_email',
'type' => 'text',
'priority' =>10,
)));
/*
---------------CONTACT INFO CONTROLS-----------------END
*/
// HEADER CALL TO ACTION BUTTON
$wp_customize->add_setting( 'header_banner_button_setting', array(
'default' => __( 'Shop Now','wp-bootstrap-starter' ),
'sanitize_callback' => 'wp_filter_nohtml_kses',
) );
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'header_banner_button_setting', array(
'label' => __( 'Button To Action Text', 'wp-bootstrap-starter' ),
'section' => 'header_image',
'settings' => 'header_banner_button_setting',
'type' => 'text',
'priority' =>30,
)));
//LEFT HEADER SUB-SECTION ICON
$wp_customize->add_setting( 'header_subsection_left_icon', array(
'default' => 'fa-angellist',
'capability' => 'edit_theme_options'
));
$wp_customize->add_control(
new O2_Customizer_Icon_Picker_Control(
$wp_customize,
'header_subsection_left_icon'
, array(
'label' => __('Left Sub Section', 'textdomain'),
'description' => __('Choose an icon', 'textdomain'),
'iconset' => 'fa',
'section' => 'header_image',
'priority' => 40,
'settings' => 'header_subsection_left_icon'
)
)
);
//LEFT HEADER SUB-SECTION TEXT
$wp_customize->add_setting( 'header_subsection_left_text', array(
'default' => __( 'Easy to-use platform','wp-bootstrap-starter' ),
'sanitize_callback' => 'wp_filter_nohtml_kses',
));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'header_subsection_left_text', array(
// 'label' => __( 'Button To Action Text', 'wp-bootstrap-starter' ),
'section' => 'header_image',
'settings' => 'header_subsection_left_text',
'type' => 'text',
'priority' =>41,
)));
//MIDDLE HEADER SUB-SECTION ICON
$wp_customize->add_setting( 'header_subsection_middle_icon', array(
'default' => 'fa-angellist',
'capability' => 'edit_theme_options'
));
$wp_customize->add_control(
new O2_Customizer_Icon_Picker_Control(
$wp_customize,
'header_subsection_middle_icon'
, array(
'label' => __('Middle Sub Section', 'textdomain'),
'description' => __('Choose an icon', 'textdomain'),
'iconset' => 'fa',
'section' => 'header_image',
'priority' => 42,
'settings' => 'header_subsection_middle_icon'
)
)
);
//MIDDLE HEADER SUB-SECTION TEXT
$wp_customize->add_setting( 'header_subsection_middle_text', array(
// 'default' => __( 'Easy to-use platform','wp-bootstrap-starter' ),
'sanitize_callback' => 'wp_filter_nohtml_kses',
) );
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'header_subsection_middle_text', array(
// 'label' => __( 'Button To Action Text', 'wp-bootstrap-starter' ),
'section' => 'header_image',
'settings' => 'header_subsection_middle_text',
'type' => 'text',
'priority' =>42,
) ) );
//RIGHT HEADER SUB-SECTION ICON
$wp_customize->add_setting( 'header_subsection_right_icon', array(
'default' => 'fa-asterisk',
'capability' => 'edit_theme_options'
));
$wp_customize->add_control(
new O2_Customizer_Icon_Picker_Control(
$wp_customize,
'header_subsection_right_icon'
, array(
'label' => __('Right Sub Section', 'textdomain'),
'description' => __('Choose an icon', 'textdomain'),
'iconset' => 'fa',
'section' => 'header_image',
'priority' => 42,
'settings' => 'header_subsection_right_icon'
)
)
);
//RIGHT HEADER SUB-SECTION TEXT
$wp_customize->add_setting( 'header_subsection_right_text', array(
// 'default' => __( 'Easy to-use platform','wp-bootstrap-starter' ),
'sanitize_callback' => 'wp_filter_nohtml_kses',
) );
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'header_subsection_right_text', array(
// 'label' => __( 'Button To Action Text', 'wp-bootstrap-starter' ),
'section' => 'header_image',
'settings' => 'header_subsection_right_text',
'type' => 'text',
'priority' =>42,
) ) );
//RIGHT HEADER SUB-SECTION TEXT
$wp_customize->add_setting( 'homepage_main_heading', array(
'default' => __( 'Templates','wp-bootstrap-starter' ),
'sanitize_callback' => 'wp_filter_nohtml_kses',
) );
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'homepage_main_heading', array(
'label' => __( 'Homepage Main Heading ', 'wp-bootstrap-starter' ),
'section' => 'header_image',
'settings' => 'homepage_main_heading',
'type' => 'text',
'priority' =>43,
) ) );
});
/**
* Enqueue scripts and styles.
*/
function wp_bootstrap_starter_scripts() {
// load bootstrap css
wp_enqueue_style( 'wp-bootstrap-starter-bootstrap-css', get_template_directory_uri() . '/inc/assets/css/bootstrap.min.css' );
// load bootstrap css
// load AItheme styles
// load WP Bootstrap Starter styles
wp_enqueue_style( 'wp-bootstrap-starter-style', get_stylesheet_uri() );
if(get_theme_mod( 'theme_option_setting' ) && get_theme_mod( 'theme_option_setting' ) !== 'default') {
wp_enqueue_style( 'wp-bootstrap-starter-'.get_theme_mod( 'theme_option_setting' ), get_template_directory_uri() . '/inc/assets/css/presets/theme-option/'.get_theme_mod( 'theme_option_setting' ).'.css', false, '' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'poppins-lora') {
wp_enqueue_style( 'wp-bootstrap-starter-poppins-lora-font', '//fonts.googleapis.com/css?family=Lora:400,400i,700,700i|Poppins:300,400,500,600,700' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'montserrat-merriweather') {
wp_enqueue_style( 'wp-bootstrap-starter-montserrat-merriweather-font', '//fonts.googleapis.com/css?family=Merriweather:300,400,400i,700,900|Montserrat:300,400,400i,500,700,800' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'poppins-poppins') {
wp_enqueue_style( 'wp-bootstrap-starter-poppins-font', '//fonts.googleapis.com/css?family=Poppins:300,400,500,600,700' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'roboto-roboto') {
wp_enqueue_style( 'wp-bootstrap-starter-roboto-font', '//fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900,900i' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'arbutusslab-opensans') {
wp_enqueue_style( 'wp-bootstrap-starter-arbutusslab-opensans-font', '//fonts.googleapis.com/css?family=Arbutus+Slab|Open+Sans:300,300i,400,400i,600,600i,700,800' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'oswald-muli') {
wp_enqueue_style( 'wp-bootstrap-starter-oswald-muli-font', '//fonts.googleapis.com/css?family=Muli:300,400,600,700,800|Oswald:300,400,500,600,700' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'montserrat-opensans') {
wp_enqueue_style( 'wp-bootstrap-starter-montserrat-opensans-font', '//fonts.googleapis.com/css?family=Montserrat|Open+Sans:300,300i,400,400i,600,600i,700,800' );
}
if(get_theme_mod( 'preset_style_setting' ) === 'robotoslab-roboto') {
wp_enqueue_style( 'wp-bootstrap-starter-robotoslab-roboto', '//fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700|Roboto:300,300i,400,400i,500,700,700i' );
}
if(get_theme_mod( 'preset_style_setting' ) && get_theme_mod( 'preset_style_setting' ) !== 'default') {
wp_enqueue_style( 'wp-bootstrap-starter-'.get_theme_mod( 'preset_style_setting' ), get_template_directory_uri() . '/inc/assets/css/presets/typography/'.get_theme_mod( 'preset_style_setting' ).'.css', false, '' );
}
//Color Scheme
/*if(get_theme_mod( 'preset_color_scheme_setting' ) && get_theme_mod( 'preset_color_scheme_setting' ) !== 'default') {
wp_enqueue_style( 'wp-bootstrap-starter-'.get_theme_mod( 'preset_color_scheme_setting' ), get_template_directory_uri() . '/inc/assets/css/presets/color-scheme/'.get_theme_mod( 'preset_color_scheme_setting' ).'.css', false, '' );
}else {
wp_enqueue_style( 'wp-bootstrap-starter-default', get_template_directory_uri() . '/inc/assets/css/presets/color-scheme/blue.css', false, '' );
}*/
wp_enqueue_script('jquery');
// Internet Explorer HTML5 support
wp_enqueue_script( 'html5hiv',get_template_directory_uri().'/inc/assets/js/html5.js', array(), '3.7.0', false );
wp_script_add_data( 'html5hiv', 'conditional', 'lt IE 9' );
// load bootstrap js
wp_enqueue_script('wp-bootstrap-starter-fontawesome', get_template_directory_uri() . '/inc/assets/js/fontawesome/fontawesome-all.min.js', array(), '', true );
wp_enqueue_script('wp-bootstrap-starter-fontawesome-v4', get_template_directory_uri() . '/inc/assets/js/fontawesome/fa-v4-shims.min.js', array(), '', true );
wp_enqueue_script('wp-bootstrap-starter-popper', get_template_directory_uri() . '/inc/assets/js/popper.min.js', array(), '', true );
wp_enqueue_script('wp-bootstrap-starter-bootstrapjs', get_template_directory_uri() . '/inc/assets/js/bootstrap.min.js', array(), '', true );
wp_enqueue_script('wp-bootstrap-starter-themejs', get_template_directory_uri() . '/inc/assets/js/theme-script.min.js', array(), '', true );
wp_enqueue_script( 'wp-bootstrap-starter-skip-link-focus-fix', get_template_directory_uri() . '/inc/assets/js/skip-link-focus-fix.min.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'wp_bootstrap_starter_scripts' );
function wp_bootstrap_starter_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
<div class="d-block mb-3">' . __( "To view this protected post, enter the password below:", "wp-bootstrap-starter" ) . '</div>
<div class="form-group form-inline"><label for="' . $label . '" class="mr-2">' . __( "Password:", "wp-bootstrap-starter" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" class="form-control mr-2" /> <input type="submit" name="Submit" value="' . esc_attr__( "Submit", "wp-bootstrap-starter" ) . '" class="btn btn-primary"/></div>
</form>';
return $o;
}
add_filter( 'the_password_form', 'wp_bootstrap_starter_password_form' );
/**
* 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';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load plugin compatibility file.
*/
require get_template_directory() . '/inc/plugin-compatibility/plugin-compatibility.php';
/**
* Load custom WordPress nav walker.
*/
if ( ! class_exists( 'wp_bootstrap_navwalker' )) {
require_once(get_template_directory() . '/inc/wp_bootstrap_navwalker.php');
}
add_action('admin_notices', function () {
if (!class_exists('WooCommerce')) {
echo '<div class="error"><p>Warning: This theme requires <a href="https://wordpress.org/plugins/woocommerce/">WooCommerce</a>. Please install & activate via <a href="' . admin_url('plugin-install.php?tab=search&s=woocommerce') . '">Plugin Admin</a></p></div>';
}
});
function addhttp($url) {
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
$url = "http://" . $url;
}
return $url;
}
function dmmp_product_categories($atts) {
global $woocommerce_loop;
$atts = shortcode_atts(array(
'number' => null,
'orderby' => 'name',
'order' => 'ASC',
'columns' => '4',
'hide_empty' => 1,
'parent' => '',
'ids' => '',
), $atts, 'dmmp_product_categories');
$ids = array_filter(array_map('trim', explode(',', $atts['ids'])));
$hide_empty = (true === $atts['hide_empty'] || 'true' === $atts['hide_empty'] || 1 === $atts['hide_empty'] || '1' === $atts['hide_empty']) ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array(
'orderby' => $atts['orderby'],
'order' => $atts['order'],
'hide_empty' => $hide_empty,
'include' => $ids,
'pad_counts' => true,
'child_of' => $atts['parent'],
);
$product_categories = get_terms('product_cat', $args);
if ('' !== $atts['parent']) {
$product_categories = wp_list_filter($product_categories, array('parent' => $atts['parent']));
}
if ($hide_empty) {
foreach ($product_categories as $key => $category) {
if (0 == $category->count) {
unset($product_categories[$key]);
}
}
}
if ($atts['number']) {
$product_categories = array_slice($product_categories, 0, $atts['number']);
}
ob_start();
if ($product_categories) {
foreach ($product_categories as $category) {
dmmp2_woocommerce_template_loop_category_link_open($category);
dmmp2_woocommerce_template_loop_category_title($category);
echo '</a>';
}
}
woocommerce_reset_loop();
return ob_get_clean();
}
add_shortcode('dmmp_product_categories', 'dmmp_product_categories');
function dmmp2_woocommerce_template_loop_category_link_open($categoryObj) {echo '<a class="ui label" href="' . get_term_link($categoryObj, 'product_cat') . '">';}
function dmmp2_woocommerce_template_loop_category_title($categoryObj) {echo $categoryObj->name;}
function printme($x){
echo '<pre>';
echo print_r($x,true);
echo '</pre>';
}
add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail_dm_mp', 10);
// Add a Menu on Sidebar to Configure DropMock MarketPlace
// Currently we only have one option - Sync Products with DropMock
add_action('admin_menu', function () {
add_menu_page('DropMock', 'DropMock', 'manage_options', 'dropmock-marketplace-settings', 'dropmockMarketPlaceConfiguration', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gUCDTkvWDx0YgAAAwJJREFUOMvVlF9oXFUQxn9z9m5uNmYT1u1NSoJJJanggxIjVA0Yat8UFQRF3aV/bq3KgtTHagpSseuDT5WCVUu6CvYqVPtSnypKC7U0ILbVttZ0m1ZIm2RvdmN2b/dfdu/xIQm1SWPBtw4cDsyc+Wbmm48Dd4XFUplIPOVaS3z/C0tiKTcK+j2Qa6A3gPwEep9jtxXulNybOEZ63/pbAeMpN6ThTdAl4De0voqoZ4DcmdMXR6tz/hugJ9CUQVeAitaS932//8r+DUO3THUgg8S/yHJwS3TRMYDI645t2bGU+3Q+f2PThfNX9ox9/tQIwF7fN2Ymck3tHZHo91/++dHA813HRn8st5YL9Zwgx1HqD1nG54FMOyLbHdva2bnlaFeoseHJ9KfrDwIkM4W3EEa1ZrYlYk4WvdJE5YYMnTtS+jjYqGxgj1oK6GxtmwLd/cr+6yoUMmuIrLlJEA07rfDRbqt5ZHuw4a93Iq3VQAPeoUT7DGiTet1XK/C9WxnBR0EXgTUAL351CoTirvHp8EYRdk/l52uIeC9/dtkAmXO2rUYtl9AUIFdBd6V/HysAawHO/Fzpvzgy3R00zQcXgB5IZgpPiJAPmC1x0D8AywEdu51arVIGeYwTW+vA2d7E8ROgV3f2hA+BvJ90vSMIHVrrX4dWhR20fs6x287Os7Ki2N0d1bK399vE/UWAxOFSy/RE3lq11hjIjtWzKkCrChBAJARkHds6/OyHJzH+Q7dhI2iqWMr9DijPzhYuBUOS/nu8nlZG7dI32zqm//341eEMX7/WdvsOY6mMAbwN8gnaj88LWtQCRUpEBLQCtEZMkGHHtkrASh2KIQrfMNXjKqAulwvaE3WzuK/RZrPc49d01Z/TfX6dEFC67VLmF2OVewbNqDL0ZGefsakpQhGt3cVTzM5dv++R4I5Srj7eM2g+5NhWbjF3RQ7NZnWyd9DsR6Q6/ELr+aXxdZu9a30vNT2M8Msdv6CkW124vXuTrtcI8MHkDADvXhhdjAWTrhflrrN/AJf8PMI6OBrlAAAAAElFTkSuQmCC');
});
function dropmockMarketPlaceConfiguration(){
if (!current_user_can('manage_options')) {
wp_die(__w('You do not have sufficient permissions to access this page :(', 'dm_store_theme'));
}
if ( !class_exists( 'WooCommerce' ) ) {
?>
<div class="card">
<h2>Welcome To DropMock Store</h2>
<div class="error">
<p>You need to install and activate
<a href="https://wordpress.org/plugins/woocommerce/">WooCommerce</a>
before connectiong your store with DropMock.
</p>
</div>
</div>
<?php
exit();
}
$error = false;
$admin_url = WEBSITE_URL.'/wp-admin/admin.php?page=dropmock-marketplace-settings';
if(isset($_GET['action'])){
$action = $_GET['action'];
if($action == 'connect'){
$is_curl_enabled = isCurlEnabled();
if($is_curl_enabled === true){
$result = dropmockCheckAPIKey($_GET['key']);
if($result == 'fail')
$error = 'API Key entered is not correct, Please try again.';
if(strlen($result) > 10)
$error = $result;
}else{
$error = 'Please install and enable Curl on your server to be able to connect with your DropMock Account';
}
}
}
$API_KEY = get_option( 'kinetic_api_key' );
if($API_KEY){
$last_check = get_transient('last_api_check');
if(!$last_check){