1 <?php
2
3 4 5 6 7 8 9
10
11
12
13 14 15 16 17
18
19 function vanilla_theme_head_favicons () { ?>
20
21 <!-- Apple icons (apple-touch-icon-precomposed). -->
22 <link rel = "apple-touch-icon" sizes = "152x152" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-152x152.png" />
23 <link rel = "apple-touch-icon" sizes = "144x144" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-144x144.png" />
24 <link rel = "apple-touch-icon" sizes = "120x120" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-120x120.png" />
25 <link rel = "apple-touch-icon" sizes = "114x114" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-114x114.png" />
26 <link rel = "apple-touch-icon" sizes = "76x76" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-76x76.png" />
27 <link rel = "apple-touch-icon" sizes = "72x72" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-72x72.png" />
28 <link rel = "apple-touch-icon" sizes = "60x60" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-60x60.png" />
29 <link rel = "apple-touch-icon" sizes = "57x57" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-57x57.png" />
30 <link rel = "apple-touch-icon" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-57x57.png" />
31
32 <!-- Your regular png favicon. -->
33 <link rel = "icon" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon.png" />
34 <link rel = "icon" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon.png" sizes = "256x256"/>
35
36 <!-- The rest of the favicon sizes. -->
37 <link rel = "icon" type = "image/png" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-16x16.png" sizes = "16x16" />
38 <link rel = "icon" type = "image/png" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-32x32.png" sizes = "32x32" />
39 <link rel = "icon" type = "image/png" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-64x64.png" sizes = "64x64" />
40 <link rel = "icon" type = "image/png" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-96x96.png" sizes = "96x96" />
41 <link rel = "icon" type = "image/png" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-160x160.png" sizes = "160x160" />
42 <link rel = "icon" type = "image/png" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon-196x196.png" sizes = "196x196" />
43
44 <!-- IE6-9 icon with all 4 dimensions. -->
45 <!--[if IE]>
46 <link rel = "icon" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon.ico" />
47 <![endif]-->
48
49 <!-- IE10 Metro start screen icon. -->
50 <meta name = "msapplication-TileColor" content = "#ffffff" />
51 <meta name = "msapplication-TileImage" content = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon.png" />
52
53 <!-- IE10 icon with all 4 dimensions inside. -->
54 <link rel = "shortcut icon" type = "image/ico" href = "<?php echo get_stylesheet_directory_uri(); ?>/img/favicons/favicon.ico" /> <?php
55
56 }
57
58
59
60 61 62 63 64 65
66
67 function vanilla_theme_enqueue_css () {
68
69 $csss = array(
70 array( 'id' => 'style', 'file' => '/style.css' ),
71 array( 'id' => 'responsiville-def', 'file' => '/inc/vanilla/responsiville/css/responsiville.def.css' ),
72 array( 'id' => 'responsiville-bugsy', 'file' => '/inc/vanilla/responsiville/css/responsiville.bugsy.css' ),
73 array( 'id' => 'responsiville-moressette', 'file' => '/inc/vanilla/responsiville/css/responsiville.moressette.css' ),
74 array( 'id' => 'responsiville-ingrid', 'file' => '/inc/vanilla/responsiville/css/responsiville.ingrid.css' ),
75 array( 'id' => 'responsiville-accordion', 'file' => '/inc/vanilla/responsiville/css/responsiville.accordion.css' ),
76 array( 'id' => 'responsiville-drawers', 'file' => '/inc/vanilla/responsiville/css/responsiville.drawers.css' ),
77 array( 'id' => 'responsiville-megamenu', 'file' => '/inc/vanilla/responsiville/css/responsiville.megamenu.css' ),
78 array( 'id' => 'responsiville-mobimenu', 'file' => '/inc/vanilla/responsiville/css/responsiville.mobimenu.css' ),
79 array( 'id' => 'responsiville-popup', 'file' => '/inc/vanilla/responsiville/css/responsiville.popup.css' ),
80 array( 'id' => 'responsiville-scrollmenu', 'file' => '/inc/vanilla/responsiville/css/responsiville.scrollmenu.css' ),
81 array( 'id' => 'responsiville-slideshow', 'file' => '/inc/vanilla/responsiville/css/responsiville.slideshow.css' ),
82 array( 'id' => 'vanilla-theme', 'file' => '/inc/vanilla/base/css/vanilla.theme.css' ),
83 array( 'id' => 'nevma-popup', 'file' => '/inc/vanilla/base/css/jquery.nevma.popup-1.2.css' ),
84 array( 'id' => 'nevma-anchorPopup', 'file' => '/inc/vanilla/base/css/jquery.nevma.anchorPopup-1.0.css' )
85 );
86
87 foreach ( $csss as $css ) {
88 wp_enqueue_style( $css['id'], get_template_directory_uri() . $css['file'], array(), filemtime( get_template_directory() . $css['file'] ), 'all' );
89 }
90
91 }
92
93
94
95 96 97 98 99 100
101
102 function vanilla_theme_enqueue_js () {
103
104
105
106 $in_header = false;
107 $in_footer = true;
108
109
110
111
112
113 wp_enqueue_script( 'polyfill-io', 'https://cdn.polyfill.io/v2/polyfill.min.js', array(), null, $in_header );
114
115
116
117
118
119 global $wp_scripts;
120
121 $jquery_core = array( 'src' => $wp_scripts->registered['jquery-core']->src, 'ver' => $wp_scripts->registered['jquery-core']->ver );
122 $jquery_migrate = array( 'src' => $wp_scripts->registered['jquery-migrate']->src, 'ver' => $wp_scripts->registered['jquery-migrate']->ver );
123
124 wp_dequeue_script( 'jquery' );
125 wp_dequeue_script( 'jquery-migrate' );
126
127 wp_deregister_script( 'jquery' );
128 wp_deregister_script( 'jquery-migrate' );
129
130 wp_enqueue_script( 'jquery', $jquery_core['src'], array( 'polyfill-io' ), $jquery_core['ver'], $in_header );
131 wp_enqueue_script( 'jquery-migrate-x', $jquery_migrate['src'], array( 'jquery' ), $jquery_migrate['ver'], $in_header );
132
133
134
135
136
137 $jsss = array(
138 array( 'id' => 'cssutils', 'file' => '/inc/vanilla/base/js/cssutilities.nevma.min.js', 'deps' => array( 'jquery' ), 'place' => $in_header ),
139 array( 'id' => 'fixcssvars', 'file' => '/inc/vanilla/base/js/nevma.fixcssvars.js', 'deps' => array( 'cssutils' ), 'place' => $in_header ),
140 array( 'id' => 'fixcssvars-run', 'file' => '/inc/vanilla/base/js/nevma.fixcssvars.run.js', 'deps' => array( 'fixcssvars' ), 'place' => $in_header ),
141 array( 'id' => 'responsiville-flags', 'file' => '/inc/vanilla/base/js/responsiville.flags.js', 'deps' => array( 'jquery' ), 'place' => $in_header ),
142 array( 'id' => 'responsiville', 'file' => '/inc/vanilla/responsiville/js/responsiville.def.js', 'deps' => array( 'responsiville-flags' ), 'place' => $in_header ),
143 array( 'id' => 'responsiville-bugsy', 'file' => '/inc/vanilla/responsiville/js/responsiville.bugsy.js', 'deps' => array( 'responsiville' ), 'place' => $in_header ),
144 array( 'id' => 'responsiville-events', 'file' => '/inc/vanilla/responsiville/js/responsiville.events.js', 'deps' => array( 'responsiville-bugsy' ), 'place' => $in_header ),
145 array( 'id' => 'responsiville-main', 'file' => '/inc/vanilla/responsiville/js/responsiville.main.js', 'deps' => array( 'responsiville-events' ), 'place' => $in_header ),
146 array( 'id' => 'responsiville-main-run', 'file' => '/inc/vanilla/responsiville/js/responsiville.main.run.js', 'deps' => array( 'responsiville-main' ), 'place' => $in_header ),
147 array( 'id' => 'velocity', 'file' => '/inc/vanilla/base/js/velocity.min.js', 'deps' => array( 'jquery' ), 'place' => $in_footer ),
148 array( 'id' => 'hammer', 'file' => '/inc/vanilla/base/js/hammer.min.js', 'deps' => array( 'jquery' ), 'place' => $in_footer ),
149 array( 'id' => 'hammer-jquery', 'file' => '/inc/vanilla/base/js/jquery.hammer.js', 'deps' => array( 'hammer' ), 'place' => $in_footer ),
150 array( 'id' => 'responsiville-accordion', 'file' => '/inc/vanilla/responsiville/js/responsiville.accordion.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
151 array( 'id' => 'responsiville-drawers', 'file' => '/inc/vanilla/responsiville/js/responsiville.drawers.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
152 array( 'id' => 'responsiville-equalheights', 'file' => '/inc/vanilla/responsiville/js/responsiville.equalheights.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
153 array( 'id' => 'responsiville-lazyimage', 'file' => '/inc/vanilla/responsiville/js/responsiville.lazymg.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
154 array( 'id' => 'responsiville-megamenu', 'file' => '/inc/vanilla/responsiville/js/responsiville.megamenu.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
155 array( 'id' => 'responsiville-mobimenu', 'file' => '/inc/vanilla/responsiville/js/responsiville.mobimenu.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
156 array( 'id' => 'responsiville-parallax', 'file' => '/inc/vanilla/responsiville/js/responsiville.parallax.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
157 array( 'id' => 'responsiville-popup', 'file' => '/inc/vanilla/responsiville/js/responsiville.popup.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
158 array( 'id' => 'responsiville-resp-element', 'file' => '/inc/vanilla/responsiville/js/responsiville.responsiveelement.js','deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
159 array( 'id' => 'responsiville-scrollmenu', 'file' => '/inc/vanilla/responsiville/js/responsiville.scrollmenu.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
160 array( 'id' => 'responsiville-slideshow', 'file' => '/inc/vanilla/responsiville/js/responsiville.slideshow.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
161 array( 'id' => 'responsiville-run', 'file' => '/inc/vanilla/responsiville/js/responsiville.run.js', 'deps' => array( 'responsiville-main-run' ), 'place' => $in_footer ),
162 array( 'id' => 'nevma-greekuppercase', 'file' => '/inc/vanilla/base/js/jquery.nevma.greekUppercase-1.0.min.js', 'deps' => array( 'jquery' ), 'place' => $in_footer ),
163 array( 'id' => 'nevma-noscrolllayer', 'file' => '/inc/vanilla/base/js/jquery.nevma.noScrollLayer-1.0.min.js', 'deps' => array( 'jquery' ), 'place' => $in_footer ),
164 array( 'id' => 'nevma-popup', 'file' => '/inc/vanilla/base/js/jquery.nevma.popup-1.2.min.js', 'deps' => array( 'jquery' ), 'place' => $in_footer ),
165 array( 'id' => 'nevma-anchorPopup', 'file' => '/inc/vanilla/base/js/jquery.nevma.anchorPopup-1.0.min.js', 'deps' => array( 'nevma-popup' ), 'place' => $in_footer )
166 );
167
168 foreach ( $jsss as $js ) {
169 wp_enqueue_script( $js['id'], get_template_directory_uri() . $js['file'], $js['deps'], filemtime( get_template_directory() . $js['file'] ), $js['place'] );
170 }
171
172 vanilla_theme_head_js_localise();
173
174 }
175
176
177
178 179 180 181 182 183 184
185
186 function vanilla_theme_head_js_localise () {
187
188 global $LANG;
189
190 wp_localize_script( 'responsiville-flags', 'VANILLA',
191 array(
192 'LANG' => $LANG,
193 'BLOG_URL' => home_url(),
194 'TEMPLATE_URL' => get_template_directory_uri(),
195 'AJAX_URL' => admin_url( 'admin-ajax.php' ),
196 'WP_DEBUG' => defined( 'WP_DEBUG' ) && WP_DEBUG ? true : false,
197 'VANILLA_DEBUG' => defined( 'VANILLA_DEBUG' ) && VANILLA_DEBUG ? true : false,
198 'RESPONSIVILLE_DEBUG' => defined( 'RESPONSIVILLE_DEBUG' ) && RESPONSIVILLE_DEBUG ? true : false,
199 'RESPONSIVILLE_AUTO_INIT' => defined( 'RESPONSIVILLE_AUTO_INIT' ) && RESPONSIVILLE_AUTO_INIT ? true : false
200 )
201 );
202
203 }
204
205
206
207 208 209 210 211
212
213 function vanilla_theme_head_scripts_and_styles () {
214
215
216
217 vanilla_theme_enqueue_css();
218
219
220
221 vanilla_theme_enqueue_js();
222
223 }
224
225
226
227 228 229 230 231 232
233
234 function vanilla_theme_index_title () {
235
236 if ( is_single() || is_page() || is_home() || is_front_page() ) {
237
238
239 $title = single_post_title( '', false );
240
241 } else if ( is_category() || is_tag() ) {
242
243
244 $title = single_cat_title( '', false );
245
246 } else if ( is_tax() ) {
247
248
249 $title = single_term_title( '', false );
250
251 } else if ( is_post_type_archive() ) {
252
253
254 $title = post_type_archive_title( '', false );
255
256 } else if ( is_author() ) {
257
258
259 $title = the_author( '', false );
260
261 } else if ( is_archive() ) {
262
263
264 $title = the_archive_title( '', false );
265
266 } else if ( is_search() ) {
267
268
269 global $wp_query;
270
271 $title =
272 __( 'You searched for: ', 'nevma-theme' ) . '"' . $_GET['s'] . '" <br />' .
273 '<small>' . __( 'we found', 'nevma-theme' ) . ' ' . $wp_query->found_posts . __( ' result(s)', 'nevma-theme' ) . '</small>';
274
275 } else {
276
277
278 $title = wp_title( '', false );
279
280 }
281
282 echo apply_filters( 'vanilla_theme_index_title', $title );
283
284 }
285
286
287
288 289 290 291 292 293 294 295
296
297 function vanilla_theme_replace_accented_letters ( $text ) {
298
299 $acc_vowels = array( 'ά','έ','ή','ί','ΐ','ό','ύ','ΰ','ώ','ς' );
300
301 $vowels = array( 'α','ε','η','ι','ι','ο','υ','υ','ω','σ' );
302
303 return str_replace( $acc_vowels, $vowels, $text);
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 function vanilla_theme_replace_months ( $input ) {
329
330 $months_genitive = array( 'Ιανουαρίου', 'Φεβρουαρίου','Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου' );
331 $months_nominative = array( 'Ιανουάριος', 'Φεβρουάριος','Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος' );
332
333 if ( is_string( $input ) && ctype_digit( $input ) ) {
334 $input = intval( $input );
335 }
336
337 if ( is_string( $input ) ) {
338 return str_replace( $months_genitive, $months_nominative, $input );
339 }
340
341 if ( is_int( $input ) && $input >= 1 && $input <= 12 ) {
342 return $months_nominative[$input-1];
343 }
344
345 return $input;
346 }
347
348
349
350 351 352 353 354 355 356 357 358 359 360
361
362 function vanilla_theme_get_the_date_declined ( $date_format, $timestamp=NULL ) {
363
364 global $wp_locale;
365
366 if ( $timestamp == NULL ) {
367 $date = get_the_date( $date_format );
368 } else {
369 $date = date_i18n( $date_format, $timestamp );
370 }
371
372 if ( 'on' == _x( 'off', 'decline months names: on or off' ) ) {
373
374 $months = $wp_locale->month;
375 $months_genitive = $wp_locale->month_genitive;
376
377 foreach ( $months as $key => $month ) {
378 $months[ $key ] = $month;
379 }
380
381 foreach ( $months_genitive as $key => $month ) {
382 $months_genitive[ $key ] = ' ' . $month;
383 }
384
385 $date = str_replace( $months, $months_genitive, $date );
386
387 return $date;
388
389 } else {
390
391 return $date;
392
393 }
394
395 }
396
397
398
399 400 401 402 403 404 405 406 407 408 409 410
411
412 function vanilla_theme_get_image_src ( $image_ID, $image_size = 'thumbnail' ) {
413
414 $image_data = wp_get_attachment_image_src( $image_ID, $image_size );
415
416 if ( $image_data ) {
417 return $image_data[0];
418 } else {
419 return false;
420 }
421 }
422
423
424
425 426 427 428 429 430 431 432
433
434 function vanilla_theme_get_image_alt ( $image_ID ) {
435
436 return get_post_meta( $image_ID, '_wp_attachment_image_alt', true );
437
438 }
439
440
441
442 443 444 445 446 447 448 449 450
451
452 function vanilla_theme_get_image_title ( $image_ID ) {
453
454 return get_the_title( $image_ID );
455
456 }
457
458
459
460 461 462 463 464 465 466 467 468
469
470 function vanilla_theme_get_image_description ( $image_ID ) {
471
472 $image = get_post( $image_ID );
473 $image_description = $image->post_content;
474
475 return $image_description;
476
477 }
478
479
480
481 482 483 484 485 486 487 488 489
490
491 function vanilla_theme_get_image_caption ( $image_ID ) {
492
493 return wp_get_attachment_caption( $image_ID );
494
495 }
496
497
498
499 500 501 502 503 504 505 506 507 508
509
510 function vanilla_theme_get_image_alt_html ( $image_ID ) {
511
512 $image_alt = vanilla_theme_get_image_alt( $image_ID );
513
514 if ( $image_alt ) {
515 return $image_alt;
516 }
517
518 $image_description = vanilla_theme_get_image_description( $image_ID );
519
520 if ( $image_description ) {
521 return $image_description;
522 }
523
524 $image_caption = vanilla_theme_get_image_caption( $image_ID );
525
526 if ( $image_caption ) {
527 return $image_caption;
528 }
529
530 $image_title = vanilla_theme_get_image_title( $image_ID );
531
532 if ( $image_title ) {
533 return $image_title;
534 }
535
536 }
537
538
539
540 541 542 543 544 545 546 547 548 549 550
551
552 function vanilla_theme_is_page ( $acf_field_slug, $post_ID=null ) {
553
554 if ( ! $post_ID ) {
555 $post_ID = get_the_ID();
556 }
557
558 $acf_field_value = get_field( $acf_field_slug, 'option' );
559
560 return $post_ID == $acf_field_value;
561
562 }
563
564
565
566 567 568 569 570 571 572 573 574 575
576
577 function vanilla_theme_get_first_available_image () {
578
579 global $post;
580
581 $first_img = '';
582
583 if ( ! $post ) {
584 return $first_img;
585 }
586
587 $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
588 $first_img = count( $matches[1] ) > 0 ? $matches[1][0] : false;
589
590 if ( ! $first_img ) {
591 $first_img = vanilla_theme_get_site_logo_url();
592 }
593
594 return $first_img;
595
596 }
597
598
599
600 601 602 603 604 605 606 607
608
609 function vanilla_theme_get_facebook_featured_image () {
610
611 if ( is_front_page() || is_home() ) : ?>
612
613 <meta property = "og:image" content = "<?php echo vanilla_theme_get_site_logo_url(); ?>" />
614
615 <?php elseif ( has_post_thumbnail() ) : ?>
616
617 <meta property = "og:image" content = "<?php echo vanilla_theme_get_image_src( get_post_thumbnail_id(), 'full' ); ?>" />
618
619 <?php else : ?>
620
621 <meta property = "og:image" content = "<?php echo vanilla_theme_get_first_available_image(); ?>" />
622
623 <?php endif;
624
625 }
626
627
628
629 630 631 632 633 634 635 636
637
638 function vanilla_theme_get_site_logo_url () {
639
640 return apply_filters( 'vanilla_get_site_logo_url', get_template_directory_uri() . '/img/logo.png' );
641
642 }
643
644
645
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
661
662 function vanilla_theme_enable_responsiville_megamenus ( $atts, $item, $args ) {
663
664 if ( ! empty( $args->responsiville_megamenu ) &&
665 ! empty( $item->classes ) &&
666 in_array( 'menu-item-has-children', $item->classes ) ) {
667
668 if ( empty( $atts['class'] ) ) {
669 $atts['class'] = 'responsiville-megamenu';
670 } else {
671 $atts['class'] .= ' responsiville-megamenu';
672 }
673
674 if ( is_array( $args->responsiville_megamenu ) ) {
675 foreach( $args->responsiville_megamenu as $key => $value) {
676 $atts['data-' . $key] = $value;
677 }
678 }
679
680 }
681
682 return $atts;
683
684 }
685
686 ?>