-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfunctions.php
2361 lines (1843 loc) · 94.1 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
/**
* Openlab Lite functions and definitions
*/
function openlab_setup() {
global $content_width;
if (!isset($content_width)) {
$content_width = 640;
}
if(!defined('OPENLAB_PATH_IMG')):
define( "OPENLAB_PATH_IMG", get_template_directory() .'/images' );
endif;
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on openlab, use a find and replace
* to change 'openlab-txtd' to the name of your theme in all the template files
*/
load_theme_textdomain('openlab-txtd', get_template_directory() . '/languages');
add_theme_support('automatic-feed-links');
/*
* Enable support for Post Thumbnails on posts and pages.
*/
add_theme_support('post-thumbnails');
/* Set the image size by cropping the image */
add_image_size('post-thumbnail', 250, 250, true);
add_image_size( 'post-thumbnail-large', 750, 500, true ); /* blog thumbnail */
add_image_size( 'post-thumbnail-large-table', 600, 300, true ); /* blog thumbnail for table */
add_image_size( 'post-thumbnail-large-mobile', 400, 200, true ); /* blog thumbnail for mobile */
add_image_size('openlab_project_photo', 285, 214, true);
add_image_size('openlab_our_team_photo', 174, 174, true);
/* Register primary menu */
register_nav_menus(array(
'primary' => __('Primary Menu', 'openlab-txtd'),
));
/* Enable support for Post Formats. */
//add_theme_support('post-formats', array('aside', 'image', 'video', 'quote', 'link'));
/* Setup the WordPress core custom background feature. */
add_theme_support('custom-background', apply_filters('openlab_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => get_stylesheet_directory_uri() . "/images/slide1.jpg",
)));
/* Enable support for HTML5 markup. */
add_theme_support('html5', array(
'comment-list',
'search-form',
'comment-form',
'gallery',
));
/* Enable support for title-tag */
add_theme_support( 'title-tag' );
/* 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';
/* tgm-plugin-activation */
require_once get_template_directory() . '/class-tgm-plugin-activation.php';
/* woocommerce support */
add_theme_support( 'woocommerce' );
/*******************************************/
/************* Welcome screen *************/
/*******************************************/
if ( is_admin() ) {
global $openlab_required_actions;
/*
* id - unique id; required
* title
* description
* check - check for plugins (if installed)
* plugin_slug - the plugin's slug (used for installing the plugin)
*
*/
$openlab_required_actions = array(
array(
"id" => 'openlab-txtd-req-ac-install-pirate-forms',
"title" => esc_html__( 'Install Pirate Forms' ,'openlab-txtd' ),
"description"=> esc_html__( 'Please make sure you install the Pirate Forms plugin.','openlab-txtd' ),
"check" => defined("PIRATE_FORMS_VERSION"),
"plugin_slug" => 'pirate-forms'
),
array(
"id" => 'openlab-txtd-req-ac-install-meta-box',
"title" => esc_html__( 'Install Meta box' ,'openlab-txtd' ),
"description"=> esc_html__( 'Please make sure you install the Meta Box plugin.','openlab-txtd' ),
"check" => defined('RWMB_VER'),
"plugin_slug" => 'meta-box'
),
array(
"id" => 'openlab-txtd-req-ac-install-ninja-forms',
"title" => esc_html__( 'Install Ninja Forms' ,'openlab-txtd' ),
"description"=> esc_html__( 'Please make sure you install the Ninja Forms plugin.','openlab-txtd' ),
"check" => defined('NF_PLUGIN_VERSION'),
"plugin_slug" => 'ninja-forms'
),
array(
"id" => 'openlab-txtd-req-ac-install-cff',
"title" => esc_html__( 'Install Custom Facebook Feed' ,'openlab-txtd' ),
"description"=> esc_html__( 'Please make sure you install the Facebook Feed plugin.','openlab-txtd' ),
"check" => defined('CFFVER'),
"plugin_slug" => 'custom-facebook-feed'
),
);
require get_template_directory() . '/inc/admin/welcome-screen/welcome-screen.php';
}
}
add_action('after_setup_theme', 'openlab_setup');
/**
* Register widgetized area and update sidebar with default widgets.
*/
function openlab_widgets_init() {
register_sidebar(array(
'name' => __('Sidebar', 'openlab-txtd'),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
}
add_action('widgets_init', 'openlab_widgets_init');
function openlab_slug_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Lora, translate this to 'off'. Do not translate
* into your own language.
*/
$lato = _x( 'on', 'Lato font: on or off', 'openlab-txtd' );
$homemade = _x( 'on', 'Homemade font: on or off', 'openlab-txtd' );
/* Translators: If there are characters in your language that are not
* supported by Open Sans, translate this to 'off'. Do not translate
* into your own language.
*/
$monserrat = _x( 'on', 'Monserrat font: on or off', 'openlab-txtd' );
if ( 'off' !== $lato || 'off' !== $monserrat|| 'off' !== $homemade ) {
$font_families = array();
if ( 'off' !== $lato ) {
$font_families[] = 'Lato:300,400,700,400italic';
}
if ( 'off' !== $monserrat ) {
$font_families[] = 'Montserrat:700';
}
if ( 'off' !== $homemade ) {
$font_families[] = 'Homemade Apple';
}
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
}
return $fonts_url;
}
/**
* Enqueue scripts and styles.
*/
function openlab_scripts() {
//wp_enqueue_style('openlab_font', openlab_slug_fonts_url(), array(), null );
//wp_enqueue_style( 'openlab_font_all', '//fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600italic,600,700,700italic,800,800italic');
wp_enqueue_style('openlab_bootstrap_style', get_template_directory_uri() . '/css/bootstrap.css');
wp_style_add_data( 'openlab_bootstrap_style', 'rtl', 'replace' );
wp_enqueue_style('openlab_fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), 'v1');
wp_enqueue_style('openlab_pixeden_style', get_template_directory_uri() . '/css/pixeden-icons.css', array('openlab_fontawesome'), 'v1');
wp_enqueue_style('openlab_style', get_stylesheet_uri(), array('openlab_pixeden_style'), 'v1');
wp_enqueue_style('openlab_responsive_style', get_template_directory_uri() . '/css/responsive.css', array('openlab_style'), 'v1');
wp_enqueue_style('openlab_custom_style', get_template_directory_uri() . '/css/main.css', array(), 'v1');
wp_enqueue_style('openlab_leaflet', get_template_directory_uri() . '/css/leaflet.css', array(), 'v1');
if ( wp_is_mobile() ){
wp_enqueue_style( 'openlab_style_mobile', get_template_directory_uri() . '/css/style-mobile.css', array('openlab_bootstrap_style', 'openlab_style'),'v1' );
}
wp_enqueue_script('jquery');
/* Bootstrap script */
wp_enqueue_script('openlab_bootstrap_script', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '20120206', true);
/* Flickity Slider */
wp_enqueue_script('openlab_flickity', get_template_directory_uri() . '/js/flickity.js', array("jquery"), '20120206', true);
/* Perfect ScrollBar */
wp_enqueue_script('openlab_perfect_scrolbar', get_template_directory_uri() . '/js/perfect-scrollbar.jquery.js', array("jquery"), '20120206', true);
/* Flickity */
wp_enqueue_script('openlab_flickity', get_template_directory_uri() . '/js/flickity.js', array("jquery"), '20120206', true);
/* Smootscroll script */
$openlab_disable_smooth_scroll = get_theme_mod('openlab_disable_smooth_scroll');
if( isset($openlab_disable_smooth_scroll) && ($openlab_disable_smooth_scroll != 1)):
wp_enqueue_script('openlab_smoothscroll', get_template_directory_uri() . '/js/smoothscroll.js', array("jquery"), '20120206', true);
endif;
/* scrollReveal script */
if ( !wp_is_mobile() ){
wp_enqueue_script( 'openlab_scrollReveal_script', get_template_directory_uri() . '/js/scrollReveal.js', array("jquery"), '20120206', true );
}
/* Leaflet JS (Maps) */
wp_enqueue_script('openlab_leaflet', get_template_directory_uri() . '/js/leaflet.js', array("jquery"), '20120206', true );
/* openlab script */
wp_enqueue_script('openlab_script', get_template_directory_uri() . '/js/openlab.js', array("jquery"), '20120206', true);
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
/* parallax effect */
if ( !wp_is_mobile() ){
/* include parallax only if on frontpage and the parallax effect is activated */
$openlab_parallax_use = get_theme_mod('openlab_parallax_show');
if ( !empty($openlab_parallax_use) && ($openlab_parallax_use == 1) && is_front_page() ):
wp_enqueue_script( 'openlab_parallax', get_template_directory_uri() . '/js/parallax.js', array("jquery"), 'v1', true );
endif;
}
add_editor_style('/css/custom-editor-style.css');
}
add_action('wp_enqueue_scripts', 'openlab_scripts');
add_action('tgmpa_register', 'openlab_register_required_plugins');
function openlab_register_required_plugins() {
$wp_version_nr = get_bloginfo('version');
if( $wp_version_nr < 3.9 ):
$plugins = array(
array(
'name' => 'Meta Box',
'slug' => 'meta-box',
'required' => true,
),
array(
'name' => 'Pirate Forms',
'slug' => 'pirate-forms',
'required' => true,
),
array(
'name' => 'Ninja Forms',
'slug' => 'ninja-forms',
'required' => true,
),
array(
'name' => 'Custom Facebook Feed',
'slug' => 'custom-facebook-feed',
'required' => true,
)
);
else:
$plugins = array(
array(
'name' => 'Pirate Forms',
'slug' => 'pirate-forms',
'required' => true,
),
array(
'name' => 'Ninja Forms',
'slug' => 'ninja-forms',
'required' => true,
),
array(
'name' => 'Custom Facebook Feed',
'slug' => 'custom-facebook-feed',
'required' => true,
),
array(
'name' => 'Meta Box',
'slug' => 'meta-box',
'required' => true,
)
);
endif;
$config = array(
'default_path' => '',
'menu' => 'tgmpa-install-plugins',
'has_notices' => true,
'dismissable' => true,
'dismiss_msg' => '',
'is_automatic' => false,
'message' => '',
'strings' => array(
'page_title' => __('Install Required Plugins', 'openlab-txtd'),
'menu_title' => __('Install Plugins', 'openlab-txtd'),
'installing' => __('Installing Plugin: %s', 'openlab-txtd'),
'oops' => __('Something went wrong with the plugin API.', 'openlab-txtd'),
'notice_can_install_required' => _n_noop('This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.','openlab-txtd'),
'notice_can_install_recommended' => _n_noop('This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.','openlab-txtd'),
'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.','openlab-txtd'),
'notice_can_activate_required' => _n_noop('The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.','openlab-txtd'),
'notice_can_activate_recommended' => _n_noop('The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.','openlab-txtd'),
'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.','openlab-txtd'),
'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.','openlab-txtd'),
'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.','openlab-txtd'),
'install_link' => _n_noop('Begin installing plugin', 'Begin installing plugins','openlab-txtd'),
'activate_link' => _n_noop('Begin activating plugin', 'Begin activating plugins','openlab-txtd'),
'return' => __('Return to Required Plugins Installer', 'openlab-txtd'),
'plugin_activated' => __('Plugin activated successfully.', 'openlab-txtd'),
'complete' => __('All plugins installed and activated successfully. %s', 'openlab-txtd'),
'nag_type' => 'updated'
)
);
tgmpa($plugins, $config);
}
/* Load Jetpack compatibility file. */
require get_template_directory() . '/inc/jetpack.php';
function openlab_wp_page_menu() {
echo '<ul class="nav navbar-nav navbar-right responsive-nav main-nav-list">';
wp_list_pages(array('title_li' => '', 'depth' => 1));
echo '</ul>';
}
add_filter('the_title', 'openlab_default_title');
function openlab_default_title($title) {
if ($title == '')
$title = __("Default title",'openlab-txtd');
return $title;
}
/*****************************************/
/****** WIDGETS *************/
/*****************************************/
add_action('widgets_init', 'openlab_register_widgets');
function openlab_register_widgets() {
register_widget('openlab_team_widget');
register_widget('openlab_events_archive_widget');
//Sidebars
$openlab_lite_sidebars = array (
'sidebar-ourteam' => 'sidebar-ourteam' );
/* Register sidebars */
foreach ( $openlab_lite_sidebars as $openlab_lite_sidebar ):
if( $openlab_lite_sidebar == 'sidebar-ourteam' ):
$openlab_lite_name = __('Our team section widgets', 'openlab-txtd');
else:
$openlab_lite_name = $openlab_lite_sidebar;
endif;
register_sidebar(
array (
'name' => $openlab_lite_name,
'id' => $openlab_lite_sidebar,
'before_widget' => '',
'after_widget' => ''
)
);
endforeach;
}
/**
* Add default widgets
*/
add_action('after_switch_theme', 'openlab_register_default_widgets');
function openlab_register_default_widgets() {
$openlab_lite_sidebars = array (
'sidebar-ourteam' => 'sidebar-ourteam'
);
$active_widgets = get_option( 'sidebars_widgets' );
/**
* Default Our Team widgets
*/
if ( empty ( $active_widgets[ $openlab_lite_sidebars['sidebar-ourteam'] ] ) ):
$openlab_lite_counter = 1;
/* our team widget #1 */
$active_widgets[ 'sidebar-ourteam' ][0] = 'openlab_team-widget-' . $openlab_lite_counter;
$ourteam_content[ $openlab_lite_counter ] = array ( 'name' => 'NAME SURNAME', 'position' => 'Title', 'description' => 'Description', 'fb_link' => '#', 'tw_link' => '#', 'bh_link' => '#', 'gp_link' => '#', 'ln_link' => '#', 'image_uri' => get_template_directory_uri()."/images/people-empty.svg" );
update_option( 'widget_openlab_team-widget', $ourteam_content );
$openlab_lite_counter++;
/* our team widget #2 */
$active_widgets[ 'sidebar-ourteam' ][] = 'openlab_team-widget-' . $openlab_lite_counter;
$ourteam_content[ $openlab_lite_counter ] = array ( 'name' => 'NAME SURNAME', 'position' => 'Title', 'description' => 'Description', 'fb_link' => '#', 'tw_link' => '#', 'bh_link' => '#', 'gp_link' => '#', 'ln_link' => '#', 'image_uri' => get_template_directory_uri()."/images/people-empty.svg" );
update_option( 'widget_openlab_team-widget', $ourteam_content );
$openlab_lite_counter++;
/* our team widget #3 */
$active_widgets[ 'sidebar-ourteam' ][] = 'openlab_team-widget-' . $openlab_lite_counter;
$ourteam_content[ $openlab_lite_counter ] = array ( 'name' => 'NAME SURNAME', 'position' => 'Title', 'description' => 'Description', 'fb_link' => '#', 'tw_link' => '#', 'bh_link' => '#', 'gp_link' => '#', 'ln_link' => '#', 'image_uri' => get_template_directory_uri()."/images/people-empty.svg" );
update_option( 'widget_openlab_team-widget', $ourteam_content );
$openlab_lite_counter++;
/* our team widget #4 */
$active_widgets[ 'sidebar-ourteam' ][] = 'openlab_team-widget-' . $openlab_lite_counter;
$ourteam_content[ $openlab_lite_counter ] = array ( 'name' => 'NAME SURNAME', 'position' => 'Title', 'description' => 'Description', 'fb_link' => '#', 'tw_link' => '#', 'bh_link' => '#', 'gp_link' => '#', 'ln_link' => '#', 'image_uri' => get_template_directory_uri()."/images/people-empty.svg" );
update_option( 'widget_openlab_team-widget', $ourteam_content );
$openlab_lite_counter++;
update_option( 'sidebars_widgets', $active_widgets );
endif;
}
/**************************/
/****** our focus widget */
/************************/
//add_action('admin_enqueue_scripts', 'openlab_ourfocus_widget_scripts');
function openlab_ourfocus_widget_scripts() {
wp_enqueue_media();
wp_enqueue_script('openlab_our_focus_widget_script', get_template_directory_uri() . '/js/widget.js', false, '1.0', true);
}
/*
class openlab_ourfocus extends WP_Widget {
public function __construct() {
parent::__construct(
'ctUp-ads-widget',
__( 'Openlab - Our focus widget', 'openlab-txtd' )
);
}
function widget($args, $instance) {
extract($args);
echo $before_widget;
?>
<div class="col-lg-3 col-sm-3 focus-box" data-scrollreveal="enter left after 0.15s over 1s">
<?php if( !empty($instance['image_uri']) ): ?>
<div class="service-icon">
<?php if( !empty($instance['link']) ): ?>
<a href="<?php echo $instance['link']; ?>"><i class="pixeden" style="background:url(<?php echo esc_url($instance['image_uri']); ?>) no-repeat center;width:100%; height:100%;"></i> <!-- FOCUS ICON--></a>
<?php else: ?>
<i class="pixeden" style="background:url(<?php echo esc_url($instance['image_uri']); ?>) no-repeat center;width:100%; height:100%;"></i> <!-- FOCUS ICON-->
<?php endif; ?>
</div>
<?php endif; ?>
<h3 class="red-border-bottom"><?php if( !empty($instance['title']) ): echo apply_filters('widget_title', $instance['title']); endif; ?></h3>
<!-- FOCUS HEADING -->
<?php
if( !empty($instance['text']) ):
echo '<p>';
echo htmlspecialchars_decode(apply_filters('widget_title', $instance['text']));
echo '</p>';
endif;
?>
</div>
<?php
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['text'] = stripslashes(wp_filter_post_kses($new_instance['text']));
$instance['title'] = strip_tags($new_instance['title']);
$instance['link'] = strip_tags( $new_instance['link'] );
$instance['image_uri'] = strip_tags($new_instance['image_uri']);
return $instance;
}
function form($instance) {
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'openlab-txtd'); ?></label><br/>
<input type="text" name="<?php echo $this->get_field_name('title'); ?>" id="<?php echo $this->get_field_id('title'); ?>" value="<?php if( !empty($instance['title']) ): echo $instance['title']; endif; ?>" class="widefat">
</p>
<p>
<label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Text', 'openlab-txtd'); ?></label><br/>
<textarea class="widefat" rows="8" cols="20" name="<?php echo $this->get_field_name('text'); ?>" id="<?php echo $this->get_field_id('text'); ?>"><?php if( !empty($instance['text']) ): echo htmlspecialchars_decode($instance['text']); endif; ?></textarea>
</p>
<p>
<label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link','openlab-txtd'); ?></label><br />
<input type="text" name="<?php echo $this->get_field_name('link'); ?>" id="<?php echo $this->get_field_id('link'); ?>" value="<?php if( !empty($instance['link']) ): echo $instance['link']; endif; ?>" class="widefat">
</p>
<p>
<label for="<?php echo $this->get_field_id('image_uri'); ?>"><?php _e('Image', 'openlab-txtd'); ?></label><br/>
<?php
if ( !empty($instance['image_uri']) ) :
echo '<img class="custom_media_image" src="' . $instance['image_uri'] . '" style="margin:0;padding:0;max-width:100px;float:left;display:inline-block" alt="'.__( 'Uploaded image', 'openlab-txtd' ).'" /><br />';
endif;
?>
<input type="text" class="widefat custom_media_url" name="<?php echo $this->get_field_name('image_uri'); ?>" id="<?php echo $this->get_field_id('image_uri'); ?>" value="<?php if( !empty($instance['image_uri']) ): echo $instance['image_uri']; endif; ?>" style="margin-top:5px;">
<input type="button" class="button button-primary custom_media_button" id="custom_media_button" name="<?php echo $this->get_field_name('image_uri'); ?>" value="<?php _e('Upload Image','openlab-txtd'); ?>" style="margin-top:5px;"/>
</p>
<?php
}
}
*/
/****************************/
/****** Next Event widget **/
/***************************/
class openlab_next_event_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'openlab-next-event-widget',
__( 'Openlab - Next Event widget', 'openlab-txtd' )
);
}
function widget($args, $instance) {
extract($args);
echo $before_widget;
?>
<div class="col-lg-3 col-sm-3 focus-box next-event" data-scrollreveal="enter left after 0.15s over 1s" data-sr-init="true" data-sr-complete="true">
<div class="next-event-wrap">
<?php
$args = array( 'numberposts' => '1', 'post_type' => 'event' );
$recent_events = wp_get_recent_posts( $args );
if($recent_events[0]){
$trimmed_content = wp_trim_words( $recent_events[0]['post_content'] , $num_words = 20, $more = null );
$next_event_title = $recent_events[0]['post_title'];
$post_permalink = get_post_permalink($recent_events[0]['ID']);
$event_future_date = get_post_meta($recent_events[0]['ID'], 'event_datetime_start', true);
//convert to readable Format ( example: 28 NOV )
if($event_future_date){
$event_future_date = gmdate("j M", $event_future_date);
}
if( $post_permalink ){
echo '<div class="next-event-image-wrap">';
if($event_future_date){
echo '<span class="event-date">'. $event_future_date .'</span>';
}
echo '<a href="'. $post_permalink .'">
<svg version="1.1" class="events-top-icon widget-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
<path fill="#231F20" d="M60.628,36.324c-0.651,0-1.184-0.533-1.184-1.184v-8.459c0-0.65,0.532-1.184,1.184-1.184
c0.65,0,1.183,0.533,1.183,1.184v8.459C61.811,35.791,61.278,36.324,60.628,36.324z"/>
<path fill="#231F20" d="M38.146,36.324c-0.651,0-1.183-0.533-1.183-1.184v-8.459c0-0.65,0.531-1.184,1.183-1.184
s1.183,0.533,1.183,1.184v8.459C39.329,35.791,38.798,36.324,38.146,36.324z"/>
<g>
<rect x="41.696" y="29.291" fill="#231F20" width="15.382" height="2.248"/>
<path fill="#231F20" d="M89.514,29.291H64.178v2.248h25.336c1.242,0,2.248,1.006,2.248,2.248v37.037
c0,1.242-1.006,2.248-2.248,2.248H9.261c-1.243,0-2.248-1.006-2.248-2.248V33.848c0-1.244,1.005-2.25,2.248-2.25h25.336V29.35
H9.261c-2.485,0-4.556,2.012-4.556,4.557v37.035c0,2.484,2.011,4.557,4.556,4.557h80.253c2.484,0,4.556-2.014,4.556-4.557V33.848
C94.069,31.303,91.998,29.291,89.514,29.291z"/>
</g>
</svg>
</a>
</div>';
}
if($next_event_title && $post_permalink){
echo '<div class="next-event-title"><h3><a href="'. $post_permalink .'">'. $next_event_title .'</a></h3></div>';
}
if($trimmed_content){
echo '<div class="next-event-content"><span>'. $trimmed_content .'</span></div>';
}
}
?>
</div>
</div>
<?php
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
return $instance;
}
function form($instance) {
}
}
/****************************/
/****** Latest Post widget **/
/***************************/
class openlab_latest_post_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'openlab-latest-post-widget',
__( 'Openlab - Latest Post widget', 'openlab-txtd' )
);
}
function widget($args, $instance) {
extract($args);
echo $before_widget;
$openlab_accessibility = get_theme_mod('openlab_accessibility');
// open link in a new tab when checkbox "accessibility" is not ticked
$attribut_new_tab = (isset($openlab_accessibility) && ($openlab_accessibility != 1) ? ' target="_blank"' : '' );
?>
<div class="col-lg-3 col-sm-3 focus-box latest-post" data-scrollreveal="enter left after 0.15s over 1s" data-sr-init="true" data-sr-complete="true">
<div class="latest-post-wrap">
<?php
$args = array( 'numberposts' => '1', 'post_type' => 'post' );
$recent_posts = wp_get_recent_posts( $args );
if($recent_posts[0]){
//$default_img = get_template_directory_uri() . '/images/announcement-white.svg';
$trimmed_content = strip_tags( wp_trim_words( $recent_posts[0]['post_content'] , $num_words = 20, $more = null ) );
$latest_post_title = $recent_posts[0]['post_title'];
$post_permalink = get_post_permalink($recent_posts[0]['ID']);
if( $post_permalink ){
echo '<div class="latest-post-image-wrap"><a href="'. $post_permalink .'">
<svg version="1.1" class="posts-top-icon widget-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
<g>
<path fill="#231F20" d="M56.854,51.256c0.197-0.092,0.357-0.236,0.473-0.41c0.115-0.172,0.188-0.383,0.188-0.609
c-0.002-0.303-0.131-0.574-0.324-0.768c-0.195-0.195-0.465-0.322-0.77-0.324h-19c-0.024,0-0.024,0-0.047,0
c-0.023,0-0.047,0-0.071,0h-0.014l-0.014,0.002c-0.151,0.01-0.292,0.053-0.415,0.117c-0.185,0.098-0.332,0.242-0.437,0.414
s-0.169,0.371-0.169,0.586c0,0.023,0.001,0.049,0.003,0.076l0.001,0.014l0.001,0.012c0.04,0.291,0.193,0.531,0.389,0.703
c0.197,0.17,0.448,0.281,0.732,0.285c0.017,0,0.031-0.002,0.047-0.002H56.42C56.576,51.352,56.725,51.314,56.854,51.256z"/>
<path fill="#231F20" d="M25.614,67.787l0.001,0.014c0.039,0.281,0.184,0.518,0.377,0.688c0.194,0.17,0.446,0.281,0.729,0.281
c0.026,0,0.053-0.002,0.079-0.006h16.307c0.013,0,0.024,0.002,0.036,0.002c0.153,0,0.298-0.037,0.426-0.096
c0.192-0.088,0.35-0.227,0.466-0.395c0.116-0.17,0.191-0.377,0.191-0.604c0-0.156-0.037-0.303-0.098-0.434
c-0.092-0.197-0.235-0.357-0.41-0.473c-0.174-0.113-0.383-0.186-0.609-0.186h-16.31c-0.047,0-0.07,0-0.094,0s-0.048,0-0.07,0
h-0.031l-0.029,0.004c-0.278,0.041-0.512,0.186-0.682,0.381c-0.169,0.195-0.282,0.451-0.283,0.738c0,0.02,0.001,0.045,0.002,0.07
L25.614,67.787z"/>
<path fill="#231F20" d="M37.255,44.223h19.329c0.15,0,0.291-0.035,0.418-0.09c0.189-0.086,0.352-0.217,0.475-0.387
c0.121-0.17,0.203-0.381,0.203-0.617V31.904c0-0.156-0.037-0.303-0.096-0.432c-0.088-0.195-0.225-0.357-0.393-0.479
s-0.375-0.203-0.607-0.205H37.255c-0.023,0-0.047,0-0.07,0.002h-0.031l-0.03,0.004c-0.28,0.039-0.518,0.186-0.687,0.381
c-0.168,0.195-0.275,0.449-0.276,0.729v11.225c0.001,0.305,0.131,0.576,0.325,0.77C36.681,44.092,36.952,44.221,37.255,44.223z
M38.35,32.996h17.117v9.041H38.35V32.996z"/>
<path fill="#231F20" d="M79.283,38.074c-0.689-0.686-1.643-1.119-2.684-1.119h-2.352v-8.156c0-1.041-0.436-1.99-1.125-2.678
S71.482,25,70.441,25H23.378c-1.043,0-1.991,0.434-2.674,1.123c-0.685,0.688-1.112,1.639-1.112,2.676v42.402
c0,1.049,0.428,2,1.112,2.686C21.389,74.574,22.338,75,23.378,75h51.213h1.699H76.6c0.047,0,0.092,0,0.141,0h0.693v-0.104
c0.82-0.18,1.549-0.629,2.078-1.256c0.555-0.654,0.896-1.508,0.896-2.439V40.754C80.408,39.713,79.973,38.764,79.283,38.074z
M78.219,71.201c0,0.447-0.182,0.848-0.475,1.141c-0.295,0.295-0.697,0.475-1.145,0.475h-0.26c-0.232-0.02-0.477-0.076-0.779-0.217
c-0.16-0.08-0.312-0.178-0.457-0.311c-0.219-0.201-0.426-0.482-0.586-0.941c-0.16-0.461-0.27-1.1-0.27-1.982V39.162H76.6
c0.451,0,0.854,0.178,1.146,0.465s0.471,0.68,0.473,1.127V71.201z M23.378,27.209h47.061c0.451,0,0.854,0.178,1.146,0.465
s0.471,0.68,0.473,1.125v9.084c-0.01,0.039-0.018,0.082-0.018,0.129s0.008,0.09,0.018,0.127v30.145v1.084
c0,0.955,0.129,1.768,0.355,2.455c0.119,0.367,0.268,0.695,0.436,0.994H23.378c-0.449,0-0.843-0.18-1.132-0.471
c-0.288-0.293-0.465-0.695-0.465-1.145V28.799c0-0.449,0.176-0.842,0.462-1.129C22.531,27.385,22.926,27.209,23.378,27.209z"/>
<path fill="#231F20" d="M25.614,61.977l0.001,0.014c0.039,0.281,0.184,0.516,0.377,0.686c0.194,0.17,0.447,0.281,0.729,0.281
c0.027,0,0.054-0.002,0.079-0.006h16.31l0,0c0.012,0.002,0.025,0.002,0.037,0.002c0.152,0,0.297-0.035,0.425-0.094
c0.192-0.088,0.35-0.227,0.465-0.396c0.115-0.168,0.19-0.377,0.19-0.602c0-0.156-0.037-0.305-0.098-0.436
c-0.092-0.195-0.235-0.355-0.409-0.471c-0.175-0.113-0.384-0.186-0.61-0.188h-16.31c-0.047,0-0.07,0-0.094,0s-0.048,0-0.07,0
h-0.032l-0.03,0.006c-0.143,0.021-0.273,0.072-0.387,0.139c-0.171,0.104-0.309,0.244-0.409,0.41
c-0.101,0.164-0.166,0.359-0.167,0.572c0,0.02,0.001,0.043,0.003,0.07L25.614,61.977z"/>
<path fill="#231F20" d="M67.65,66.766c-0.176-0.113-0.385-0.186-0.609-0.186H50.732c-0.023,0-0.048,0-0.094,0
c-0.024,0-0.024,0-0.047,0h-0.03l-0.027,0.004c-0.272,0.035-0.51,0.17-0.683,0.357s-0.289,0.439-0.289,0.723
c0,0.035,0.003,0.07,0.007,0.105l0,0c0,0,0.001,0.014,0.001,0.021c0.002,0.004,0.002,0.008,0.002,0.008v0.004
c0.027,0.277,0.165,0.516,0.351,0.682c0.194,0.174,0.448,0.285,0.731,0.285c0.025,0,0.053-0.002,0.078-0.006h16.307
c0.012,0,0.023,0.002,0.035,0.002c0.154,0,0.299-0.037,0.426-0.096c0.193-0.088,0.35-0.227,0.467-0.395
c0.115-0.17,0.191-0.377,0.191-0.604c0-0.156-0.037-0.305-0.098-0.434C67.967,67.041,67.824,66.881,67.65,66.766z"/>
<path fill="#231F20" d="M67.65,60.955c-0.174-0.113-0.383-0.186-0.609-0.188H50.732c-0.023,0-0.048,0-0.094,0
c-0.024,0-0.024,0-0.047,0h-0.03l-0.029,0.004c-0.28,0.041-0.515,0.182-0.685,0.371c-0.168,0.189-0.283,0.434-0.285,0.715
c0,0.033,0.003,0.066,0.007,0.102l0,0c0,0,0.001,0.018,0.003,0.027c0,0.004,0,0.006,0,0.006l0.001,0.002
c0.028,0.277,0.166,0.512,0.35,0.678c0.194,0.174,0.449,0.283,0.731,0.285c0.025,0,0.053-0.002,0.078-0.006l0,0h16.309l0,0
c0.012,0.002,0.025,0.002,0.035,0.002c0.154,0,0.299-0.035,0.426-0.094c0.191-0.088,0.35-0.227,0.465-0.396
c0.115-0.168,0.191-0.377,0.191-0.602c0-0.156-0.037-0.307-0.098-0.436C67.967,61.23,67.824,61.07,67.65,60.955z"/>
<path fill="#231F20" d="M25.614,56.166l0.001,0.012c0.039,0.281,0.185,0.52,0.379,0.688s0.447,0.279,0.729,0.281
c0.026,0,0.051-0.004,0.077-0.006h16.307c0.013,0.002,0.024,0.002,0.036,0.002c0.153,0,0.298-0.035,0.426-0.096
c0.192-0.088,0.35-0.227,0.467-0.395c0.115-0.17,0.19-0.379,0.19-0.605c0-0.154-0.037-0.303-0.098-0.434
c-0.092-0.195-0.235-0.355-0.409-0.471c-0.175-0.115-0.384-0.186-0.61-0.186h-16.31c-0.047,0-0.07,0-0.094,0s-0.048,0-0.07,0
h-0.032l-0.03,0.002c-0.143,0.021-0.273,0.074-0.387,0.141c-0.172,0.104-0.309,0.244-0.41,0.41c-0.1,0.164-0.165,0.359-0.166,0.572
c0,0.021,0.001,0.045,0.003,0.072L25.614,56.166z"/>
<path fill="#231F20" d="M50.638,54.957c-0.024,0-0.024,0-0.047,0h-0.03l-0.027,0.002c-0.282,0.039-0.517,0.182-0.688,0.369
c-0.169,0.191-0.284,0.438-0.284,0.719c0,0.031,0.003,0.066,0.007,0.1h-0.002c0.001,0.008,0.002,0.018,0.003,0.025
c0,0,0,0.006,0.002,0.01l0,0c0.013,0.133,0.052,0.258,0.109,0.367c0.093,0.182,0.232,0.326,0.399,0.43
c0.166,0.104,0.363,0.168,0.573,0.168c0.027,0,0.053-0.004,0.077-0.006h16.306c0.014,0.002,0.025,0.002,0.037,0.002
c0.152,0,0.297-0.035,0.426-0.096c0.191-0.088,0.35-0.227,0.467-0.395c0.115-0.17,0.189-0.379,0.189-0.605
c0-0.156-0.037-0.303-0.098-0.434c-0.092-0.197-0.236-0.355-0.41-0.471s-0.383-0.186-0.609-0.186H50.732
C50.708,54.957,50.684,54.957,50.638,54.957z"/>
</g>
</svg>
</a>
</div>';
}
if($latest_post_title && $post_permalink){
echo '<div class="latest-post-title"><h3><a href="'. $post_permalink .'">'. $latest_post_title .'</a></h3></div>';
}
if($trimmed_content){
echo '<div class="latest-post-content"><span>'. $trimmed_content .'</span></div>';
}
}
?>
</div>
</div>
<?php
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
return $instance;
}
function form($instance) {
}
}
/****** Latest 3 EVENTS widget **/
/***************************/
class openlab_events_archive_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'openlab-events-archive-widget',
__( 'Openlab - Events Archive widget', 'openlab-txtd' )
);
}
function widget($args, $instance) {
extract($args);
echo $before_widget;
$viewed_in = $GLOBALS['post']->ID;
$args = array( 'numberposts' => '3', 'post_type' => 'event', 'post__not_in' => array($viewed_in) );
$recent_events = wp_get_recent_posts( $args );
$archive_permalink = get_post_type_archive_link( 'event' );
$ev_title = '';
$ev_date = '';
$ev_permalink = '';
$ev_type = '';
?>
<div class="recent-events-archive widget">
<h2 class="events-widget"><?php echo __('Other Events', 'openlab-txtd') ?></h2>
<div class="recent-events-wrap">
<?php
if($recent_events):
foreach($recent_events as $ev):
$ev_type = get_post_meta($ev['ID'], 'event_type', true);
$ev_title = $ev['post_title'];
$ev_date = get_post_meta($ev['ID'], 'event_datetime_start', true);
if($ev_date):
$ev_date = gmdate('j F Y', $ev_date);
endif;
$ev_permalink = esc_url( get_post_permalink($ev['ID']) );
echo '<div class="widget-event '. $ev_type .'">';
if($ev_date){
echo '<p class="event-date">'. $ev_date .'</p>';
}
if($ev_title && $ev_permalink){
echo '<h4 class="event-title"><a href="'. esc_url($ev_permalink) .'">'. $ev_title .'</a></h4>';
}
echo '</div>';
endforeach;
endif;
?>
</div>
</div>
<?php
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
return $instance;
}
function form($instance) {
}
}
/****************************/
/****** Map Detals widget **/
/***************************/
class openlab_map_details_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'openlab_map_details_widget',
__( 'Openlab - Map Details Widget', 'openlab-txtd' )
);
}
function widget($args, $instance) {
extract($args);
echo $before_widget;
?>
<div class="col-lg-3 col-sm-3 focus-box map-details" data-scrollreveal="enter left after 0.15s over 1s" data-sr-init="true" data-sr-complete="true">
<div class="map-details-wrap">
<?php
//$openlab_map_icon = get_theme_mod('openlab_contact_map_icon', get_template_directory_uri().'/images/location-white.svg');
$openlab_map_address = get_theme_mod('openlab_map_address', 'Leoxarous 17, Athens, Greece');
$openlab_details_text = get_theme_mod('openlab_contact_details_text', '<p>Company Name</p><p>Address</p><p>Tel</p><p>email@email.com</p>');
if( $openlab_map_address){
if( !empty($openlab_map_address) ) {
echo '<a data-toggle="modal" href="#openlab-embed">
<svg version="1.1" class="map-top-icon widget-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
<g>
<path fill="#231F20" d="M74.442,73.932l-6.93-24.93l-0.012-0.031c-0.246-0.49-0.725-0.82-1.191-0.82h-8.629
c2.479-4.404,3.735-7.789,3.735-10.064c0-6.941-5.368-12.588-11.967-12.588s-11.967,5.646-11.967,12.588
c0,2.275,1.257,5.66,3.735,10.064h-7.181c-0.505,0-0.979,0.369-1.097,0.844L24.569,73.9c-0.271,0.428-0.064,0.836,0.116,1.105
l0.021,0.027c0.14,0.139,0.513,0.465,0.952,0.465h47.58c0.423,0,0.76-0.17,0.974-0.492C74.477,74.609,74.552,74.256,74.442,73.932z
M49.449,27.916c5.354,0,9.548,4.467,9.548,10.17c0,4.859-8.064,16.262-9.548,18.32c-1.085-1.5-3.05-4.299-4.956-7.449
c-0.059-0.191-0.156-0.354-0.291-0.482c-2.813-4.721-4.301-8.312-4.301-10.389C39.901,32.479,44.185,27.916,49.449,27.916z
M49.449,59.672c0.423,0,0.759-0.17,0.974-0.492c0.033-0.051,0.137-0.191,0.298-0.412c0.802-1.1,3.23-4.426,5.538-8.197h9.193
l6.213,22.508H27.351l7.537-22.508h7.752c2.309,3.773,4.736,7.1,5.539,8.197c0.16,0.221,0.264,0.361,0.297,0.412
C48.69,59.502,49.026,59.672,49.449,59.672z"/>
<path fill="#231F20" d="M49.449,44.777c3.519,0,6.382-3.002,6.382-6.691c0-3.691-2.863-6.693-6.382-6.693s-6.382,3.002-6.382,6.693
C43.067,41.775,45.931,44.777,49.449,44.777z M49.449,33.812c2.185,0,3.962,1.916,3.962,4.273c0,2.355-1.777,4.271-3.962,4.271
s-3.962-1.916-3.962-4.271C45.487,35.729,47.265,33.812,49.449,33.812z"/>
</g>
</svg>
</a>';
}
if( !empty($openlab_map_address) ) echo '<div class="map-details-title"><h3>'. $openlab_map_address .'</h3></div>';
if( !empty($openlab_details_text) ) echo '<div class="details-text">'. $openlab_details_text .'</div>';
}
?>
</div>
</div>
<?php
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
return $instance;
}
function form($instance) {
}
}
/****************************/
/****** Events Calendar **/
/***************************/
class event_cpt_calendar extends WP_Widget {
function event_cpt_calendar() {
parent::__construct(false, $name = 'Openlab - Events Calendar');
}
function widget($args, $instance) {
extract( $args );
?>
<?php echo '<div class="col-lg-3 col-sm-3 focus-box events-calendar" data-scrollreveal="enter left after 0.15s over 1s" data-sr-init="true" data-sr-complete="true">'; ?>
<?php echo $before_widget; ?>
<div class="widget-events-calendar">
<div id="calendar_wrap">
<?php oplb_events_get_calendar(); ?>
</div>
</div>