· 6 years ago · Apr 03, 2019, 04:08 AM
1<?php
2
3add_action( 'template_redirect', 'redirect_to_specific_page' );
4
5function redirect_to_specific_page() {
6
7if ( is_page('slug') && ! is_user_logged_in() ) {
8
9wp_redirect( 'https://billwhittle.com/landing-page/', 302 );
10 exit;
11 }
12}
13
14
15
16
17/////////////////////////////////////////////////////
18//Allow custom characters inside of wordpress usernames
19//USAGE: drop this function and filter into your functions.php file
20/////////////////////////////////////////////////////////
21
22function create_attendee_sanitize_user($username, $raw_username, $strict) {
23
24 $allowed_symbols = "a-z0-9+ _.\-@"; //yes we allow whitespace which will be trimmed further down script
25
26 //Strip HTML Tags
27 $username = wp_strip_all_tags ($raw_username);
28
29 //Remove Accents
30 $username = remove_accents ($username);
31
32 //Kill octets
33 $username = preg_replace ('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);
34
35 //Kill entities
36 $username = preg_replace ('/&.+?;/', '', $username);
37
38 //allow + symbol
39 $username = preg_replace ('|[^'.$allowed_symbols.']|iu', '', $username);
40
41 //Remove Whitespaces
42 $username = trim ($username);
43
44 // Consolidate contiguous Whitespaces
45 $username = preg_replace ('|\s+|', ' ', $username);
46
47 //Done
48 return $username;
49
50}
51
52add_filter ('sanitize_user', 'create_attendee_sanitize_user', 10, 3);
53
54//////////////////////////////////////////
55// DISABLE TOOLBAR ALL BUT ADMIN FIX MENU FLOAT SCOTT OTT
56////////////////////////////////////////
57add_action('after_setup_theme', 'remove_admin_bar');
58
59function remove_admin_bar() {
60if (!current_user_can('administrator') && !is_admin()) {
61 show_admin_bar(false);
62}
63}
64
65/////////////////////////////////////
66// AFTER LOGIN REDIRECT TO PREVIOUS PAGE
67/////////////////////////////////////
68if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['login_location']) && !empty($_POST['login_location'])) ) {
69 add_filter('login_redirect', 'my_login_redirect', 10, 3);
70 function my_login_redirect() {
71 $location = $_SERVER['HTTP_REFERER'];
72 wp_safe_redirect($location);
73 exit();
74 }
75}
76
77
78/////////////////////////////////////
79// Theme Setup
80/////////////////////////////////////
81
82add_action('after_setup_theme', 'mvp_setup');
83function mvp_setup(){
84 load_theme_textdomain('mvp-text', get_template_directory() . '/languages');
85
86 $locale = get_locale();
87 $locale_file = get_template_directory() . "/languages/$locale.php";
88 if ( is_readable( $locale_file ) )
89 require_once( $locale_file );
90}
91
92/////////////////////////////////////
93// Enqueue Javascript Files
94/////////////////////////////////////
95
96function my_scripts_method() {
97 wp_register_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), '', true);
98 wp_register_script('elastislide', get_template_directory_uri() . '/js/jquery.elastislide.js', array('jquery'), '', true);
99 wp_register_script('gameday', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '', true);
100 wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js', array('jquery'), '', true);
101 wp_register_script('nicescroll', get_template_directory_uri() . '/js/jquery.nicescroll.min.js', array('jquery'), '', true);
102 wp_register_script('imagesloaded', get_template_directory_uri() . '/js/jquery.imagesloaded.min.js', array('jquery'), '', true);
103 wp_register_script('retina', get_template_directory_uri() . '/js/retina.js', array('jquery'), '', true);
104
105 wp_enqueue_script( 'flexslider' );
106 wp_enqueue_script( 'elastislide' );
107 wp_enqueue_script( 'gameday' );
108 if ( is_home() || is_category() || is_archive() ) {
109 wp_enqueue_script( 'isotope' );
110 }
111 wp_enqueue_script( 'imagesloaded' );
112 wp_enqueue_script( 'nicescroll' );
113 wp_enqueue_script( 'retina' );
114
115 wp_enqueue_style( 'mvp-style', get_stylesheet_uri() );
116 wp_enqueue_style( 'reset', get_template_directory_uri() . '/css/reset.css' );
117 $gd_respond = get_option('gd_respond'); if ($gd_respond == "true") { if (isset($gd_respond)) {
118 wp_enqueue_style( 'media-queries', get_template_directory_uri() . '/css/media-queries.css' );
119 } }
120 wp_enqueue_style( 'flexcss', get_template_directory_uri() . '/css/flexslider.css' );
121
122 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
123 if (is_plugin_active('menufication/menufication.php')) {
124 wp_enqueue_style( 'menufication', get_template_directory_uri() . '/css/menufication.css' );
125 }
126 wp_enqueue_style( 'mvp-fontawesome', '//netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css' );
127
128}
129add_action('wp_enqueue_scripts', 'my_scripts_method');
130
131/////////////////////////////////////
132// Google Fonts
133/////////////////////////////////////
134
135if ( ! function_exists( 'mvp_studio_fonts_url' ) ) {
136function mvp_studio_fonts_url() {
137 $font_url = '';
138
139 if ( 'off' !== _x( 'on', 'Google font: on or off', 'studio' ) ) {
140 $font_url = add_query_arg( 'family', urlencode( 'Open Sans Condensed:300,700|Open Sans:400,700|Oswald:300,400,700&subset=latin,latin-ext' ), "//fonts.googleapis.com/css" );
141 }
142 return $font_url;
143}
144}
145
146if ( ! function_exists( 'mvp_studio_scripts' ) ) {
147function mvp_studio_scripts() {
148 wp_enqueue_style( 'studio-fonts', mvp_studio_fonts_url(), array(), '1.0.0' );
149}
150}
151add_action( 'wp_enqueue_scripts', 'mvp_studio_scripts' );
152
153/////////////////////////////////////
154// Theme Options
155/////////////////////////////////////
156
157require_once(TEMPLATEPATH . '/admin/admin-functions.php');
158require_once(TEMPLATEPATH . '/admin/admin-interface.php');
159require_once(TEMPLATEPATH . '/admin/theme-settings.php');
160
161function my_wp_head() {
162 $bloginfo = get_template_directory_uri();
163 $primarytheme = get_option('gd_primary_theme');
164 $secondarytheme = get_option('gd_secondary_theme');
165 $link = get_option('gd_link_color');
166 $heading = get_option('gd_heading');
167 $wallad = get_option('gd_wall_ad');
168 echo "
169<style type='text/css'>
170
171#nav-main-wrapper { background: $primarytheme url($bloginfo/images/nav-bg.png) repeat-x bottom; }
172span.headlines-header, #content-social, span.scroll-more, .search-fly-wrap { background: $primarytheme }
173
174.woocommerce .widget_price_filter .ui-slider .ui-slider-handle,
175.woocommerce span.onsale,
176.woocommerce #respond input#submit.alt,
177.woocommerce a.button.alt,
178.woocommerce button.button.alt,
179.woocommerce input.button.alt,
180.woocommerce #respond input#submit.alt:hover,
181.woocommerce a.button.alt:hover,
182.woocommerce button.button.alt:hover,
183.woocommerce input.button.alt:hover {
184 background-color: $primarytheme;
185 }
186
187.woocommerce .widget_price_filter .ui-slider .ui-slider-range {
188 background: $primarytheme;
189 }
190
191#nav-mobi select { background: $primarytheme url($bloginfo/images/triangle-dark.png) no-repeat right; }
192.category-heading { background: $primarytheme url($bloginfo/images/striped-bg.png); }
193ul.score-nav li.active, ul.score-nav li.active:hover, .blog-cat li, .blog-cat-title, .flex-control-paging li a.flex-active { background: $secondarytheme; }
194.prev-post, .next-post { color: $secondarytheme; }
195a, a:visited { color: $link; }
196h3#reply-title, h2.comments, #related-posts h3, h4.widget-header, h4.widget-header-fb { background: $heading url($bloginfo/images/striped-bg.png); }
197#wallpaper { background: url($wallad) no-repeat 50% 0; }
198
199 </style>";
200}
201add_action( 'wp_head', 'my_wp_head' );
202
203/////////////////////////////////////
204// Register Widgets
205/////////////////////////////////////
206
207if ( function_exists('register_sidebar') ) {
208 register_sidebar(array(
209 'id' => 'homepage-widget-area',
210 'name' => 'Homepage Widget Area',
211 'before_widget' => '<div class="widget-container"><div id="%1$s" class="widget-inner %2$s">',
212 'after_widget' => '</div></div>',
213 'before_title' => '<h4 class="widget-header">',
214 'after_title' => '</h4>',
215 ));
216}
217
218if ( function_exists('register_sidebar') ) {
219 register_sidebar(array(
220 'id' => 'homepage-widget',
221 'name' => 'Homepage Blog Sidebar Widget Area',
222 'before_widget' => '<div class="widget-container"><div id="%1$s" class="widget-inner %2$s">',
223 'after_widget' => '</div></div>',
224 'before_title' => '<h4 class="widget-header">',
225 'after_title' => '</h4>',
226 ));
227}
228
229if ( function_exists('register_sidebar') ) {
230 register_sidebar(array(
231 'id' => 'sidebar-widget',
232 'name' => 'Sidebar Widget Area',
233 'before_widget' => '<div class="widget-container"><div id="%1$s" class="widget-inner %2$s">',
234 'after_widget' => '</div></div>',
235 'before_title' => '<h4 class="widget-header">',
236 'after_title' => '</h4>',
237 ));
238}
239
240if ( function_exists('register_sidebar') ) {
241 register_sidebar(array(
242 'id' => 'scoreboard-widget',
243 'name' => 'Scoreboard Widget Area',
244 'before_widget' => '',
245 'after_widget' => '',
246 'before_title' => '',
247 'after_title' => '',
248 ));
249}
250
251if ( function_exists('register_sidebar') ) {
252 register_sidebar(array(
253 'id' => 'sidebar-woo-widget',
254 'name' => 'WooCommerce Sidebar Widget Area',
255 'before_widget' => '<div class="widget-container"><div id="%1$s" class="widget-inner %2$s">',
256 'after_widget' => '</div></div>',
257 'before_title' => '<h4 class="widget-header">',
258 'after_title' => '</h4>',
259 ));
260}
261
262include("widgets/widget-ad125.php");
263include("widgets/widget-ad300.php");
264include("widgets/widget-catfeat.php");
265include("widgets/widget-catlist.php");
266include("widgets/widget-facebook.php");
267include("widgets/widget-scoreboard.php");
268
269/////////////////////////////////////
270// Register Custom Menus
271/////////////////////////////////////
272
273function register_menus() {
274 register_nav_menus(
275 array(
276 'primary-menu' => __( 'Primary Menu' ),
277 'mobile-menu' => __( 'Mobile Menu' ),
278 'footer-menu' => __( 'Footer Menu' ),)
279 );
280 }
281
282add_action( 'init', 'register_menus' );
283
284
285class select_menu_walker extends Walker_Nav_Menu{
286
287 function start_lvl( &$output, $depth = 0, $args = array() ) {
288 $indent = str_repeat("\t", $depth);
289 $output .= "";
290 }
291
292
293 function end_lvl( &$output, $depth = 0, $args = array() ) {
294 $indent = str_repeat("\t", $depth);
295 $output .= "";
296 }
297
298 function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
299 global $wp_query;
300 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
301
302 $class_names = $value = '';
303
304 $classes = empty( $object->classes ) ? array() : (array) $object->classes;
305 $classes[] = 'menu-item-' . $object->ID;
306
307 $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $object, $args ) );
308 $class_names = ' class="' . esc_attr( $class_names ) . '"';
309
310 $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $object->ID, $object, $args );
311 $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
312
313 $attributes = ! empty( $object->attr_title ) ? ' title="' . esc_attr( $object->attr_title ) .'"' : '';
314 $attributes .= ! empty( $object->target ) ? ' target="' . esc_attr( $object->target ) .'"' : '';
315 $attributes .= ! empty( $object->xfn ) ? ' rel="' . esc_attr( $object->xfn ) .'"' : '';
316 $attributes .= ! empty( $object->url ) ? ' href="' . esc_attr( $object->url ) .'"' : '';
317
318 $sel_val = ' value="' . esc_attr( $object->url ) .'"';
319
320 //check if the menu is a submenu
321 switch ($depth){
322 case 0:
323 $dp = "";
324 break;
325 case 1:
326 $dp = "-";
327 break;
328 case 2:
329 $dp = "--";
330 break;
331 case 3:
332 $dp = "---";
333 break;
334 case 4:
335 $dp = "----";
336 break;
337 default:
338 $dp = "";
339 }
340
341 $output .= $indent . '<option'. $sel_val . $id . $value . '>'.$dp;
342
343 $item_output = $args->before;
344 //$item_output .= '<a'. $attributes .'>';
345 $item_output .= $args->link_before . apply_filters( 'the_title', $object->title, $object->ID ) . $args->link_after;
346 //$item_output .= '</a>';
347 $item_output .= $args->after;
348
349 $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $object, $depth, $args );
350 }
351
352 function end_el( &$output, $object, $depth = 0, $args = array() ) {
353 $output .= "</option>\n";
354 }
355
356}
357
358/////////////////////////////////////
359// Register Custom Background
360/////////////////////////////////////
361
362$custombg = array(
363 'default-color' => 'cccccc',
364);
365add_theme_support( 'custom-background', $custombg );
366
367/////////////////////////////////////
368// Register Thumbnails
369/////////////////////////////////////
370
371if ( function_exists( 'add_theme_support' ) ) {
372add_theme_support( 'post-thumbnails' );
373set_post_thumbnail_size( 615, 400, true );
374add_image_size( 'slider-thumb', 615, 400, true );
375add_image_size( 'large-thumb', 300, 195, true );
376add_image_size( 'medium-thumb', 108, 70, true );
377add_image_size( 'small-thumb', 48, 48, true );
378}
379
380/////////////////////////////////////
381// Title Meta Data
382/////////////////////////////////////
383
384add_theme_support( 'title-tag' );
385
386function mvp_filter_home_title(){
387if ( ( is_home() && ! is_front_page() ) || ( ! is_home() && is_front_page() ) ) {
388 $mvpHomeTitle = get_bloginfo( 'name', 'display' );
389 $mvpHomeDesc = get_bloginfo( 'description', 'display' );
390 return $mvpHomeTitle . " - " . $mvpHomeDesc;
391}
392}
393add_filter( 'pre_get_document_title', 'mvp_filter_home_title');
394
395/////////////////////////////////////
396// Register Scores
397/////////////////////////////////////
398
399add_action( 'init', 'create_scores' );
400function create_scores() {
401 register_post_type( 'scoreboard',
402 array(
403 'labels' => array(
404 'name' => __( 'Scores' ),
405 'singular_name' => __( 'Score' )
406 ),
407 'public' => true,
408 'has_archive' => true,
409 )
410 );
411}
412
413add_action( 'init', 'scores_init' );
414function scores_init() {
415 // create a new taxonomy
416 register_taxonomy(
417 'scores_cat',
418 'scoreboard',
419 array(
420 'label' => __( 'Score Categories', 'mvp-text' ),
421 'rewrite' => array( 'slug' => 'scores' ),
422 'hierarchical' => true,
423 'query_var' => true
424 )
425 );
426}
427
428/////////////////////////////////////
429// Add Scores Metabox
430/////////////////////////////////////
431
432$prefix = 'gd_';
433
434$meta_box = array(
435 'id' => 'scores-box',
436 'title' => 'Scores Info',
437 'page' => 'scoreboard',
438 'context' => 'normal',
439 'priority' => 'high',
440 'fields' => array(
441 array(
442 'name' => 'Score Status',
443 'desc' => 'Enter score status (eg. "Fri 8:00pm" or "Final")',
444 'id' => $prefix . 'status',
445 'type' => 'text',
446 ),
447 array(
448 'name' => 'Away Team Abbreviation',
449 'desc' => 'Enter away team abbreviation (eg. "PHI")',
450 'id' => $prefix . 'away_team',
451 'type' => 'text',
452 ),
453 array(
454 'name' => 'Home Team Abbreviation',
455 'desc' => 'Enter home team abbreviation (eg. "PHI")',
456 'id' => $prefix . 'home_team',
457 'type' => 'text',
458 ),
459 array(
460 'name' => 'Away Team Score',
461 'desc' => 'Enter away team score (eg. "10")',
462 'id' => $prefix . 'away_team_score',
463 'type' => 'text',
464 'std' => ' 0'
465 ),
466 array(
467 'name' => 'Home Team Score',
468 'desc' => 'Enter home team score (eg. "10")',
469 'id' => $prefix . 'home_team_score',
470 'type' => 'text',
471 'std' => ' 0'
472 )
473 )
474);
475
476add_action('admin_menu', 'scores_add_box');
477
478// Add meta box
479function scores_add_box() {
480 global $meta_box;
481
482 add_meta_box($meta_box['id'], $meta_box['title'], 'scores_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']);
483}
484
485// Callback function to show fields in meta box
486function scores_show_box() {
487 global $meta_box, $post;
488
489 // Use nonce for verification
490 echo '<input type="hidden" name="scores_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
491
492 echo '<table class="form-table">';
493
494 foreach ($meta_box['fields'] as $field) {
495 // get current post meta data
496 $meta = get_post_meta($post->ID, $field['id'], true);
497
498 echo '<tr>',
499 '<th style="width:20%"><label for="', $field['id'], '"><strong>', $field['name'], ':</strong></label></th>',
500 '<td>';
501 switch ($field['type']) {
502 case 'text':
503 echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />',
504 '<br /><small>', $field['desc'],'</small>';
505 break;
506 case 'textarea':
507 echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>',
508 '<br />', $field['desc'];
509 break;
510 case 'select':
511 echo '<select name="', $field['id'], '" id="', $field['id'], '">';
512 foreach ($field['options'] as $option) {
513 echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
514 }
515 echo '</select>';
516 break;
517 case 'radio':
518 foreach ($field['options'] as $option) {
519 echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
520 }
521 break;
522 case 'checkbox':
523 echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
524 break;
525 }
526 echo '<td>',
527 '</tr>';
528 }
529
530 echo '</table>';
531}
532
533add_action('save_post', 'scores_save_data');
534
535// Save data from meta box
536function scores_save_data($post_id) {
537 global $meta_box;
538
539 // verify nonce
540 if ( !isset( $_POST['scores_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['scores_meta_box_nonce'], basename(__FILE__) ) ) {
541 return $post_id;
542 }
543
544 // check autosave
545 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
546 return $post_id;
547 }
548
549 // check permissions
550 if (!current_user_can('edit_post', $post_id)) {
551 return $post_id;
552 }
553
554 foreach ($meta_box['fields'] as $field) {
555 $old = get_post_meta($post_id, $field['id'], true);
556 $new = isset( $_POST[$field['id']] ) ? $_POST[$field['id']] : '';
557
558 if ($new && $new != $old) {
559 update_post_meta($post_id, $field['id'], $new);
560 } elseif ('' == $new && $old) {
561 delete_post_meta($post_id, $field['id'], $old);
562 }
563 }
564}
565
566/////////////////////////////////////
567// Add Bread Crumbs
568/////////////////////////////////////
569
570function dimox_breadcrumbs() {
571
572 $delimiter = '/';
573 $home = 'Home'; // text for the 'Home' link
574 $before = '<span class="current">'; // tag before the current crumb
575 $after = '</span>'; // tag after the current crumb
576
577 if ( !is_home() && !is_front_page() || is_paged() ) {
578
579 echo '<div id="crumbs">';
580
581 global $post;
582 $homeLink = home_url();
583 echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
584
585 if ( is_category() ) {
586 global $wp_query;
587 $cat_obj = $wp_query->get_queried_object();
588 $thisCat = $cat_obj->term_id;
589 $thisCat = get_category($thisCat);
590 $parentCat = get_category($thisCat->parent);
591 if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
592 echo $before . single_cat_title('', false) . $after;
593
594 } elseif ( is_day() ) {
595 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
596 echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
597 echo $before . get_the_time('d') . $after;
598
599 } elseif ( is_month() ) {
600 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
601 echo $before . get_the_time('F') . $after;
602
603 } elseif ( is_year() ) {
604 echo $before . get_the_time('Y') . $after;
605
606 } elseif ( is_single() && !is_attachment() ) {
607 if ( get_post_type() != 'post' ) {
608 $post_type = get_post_type_object(get_post_type());
609 $slug = $post_type->rewrite;
610 echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $delimiter . ' ';
611 echo $before . get_the_title() . $after;
612 } else {
613 $cat = get_the_category(); $cat = $cat[0];
614 echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
615 echo $before . get_the_title() . $after;
616 }
617
618 } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() && !is_search()) {
619 $post_type = get_post_type_object(get_post_type());
620 echo $before . $post_type->labels->singular_name . $after;
621
622 } elseif ( is_attachment() ) {
623 $parent = get_post($post->post_parent);
624 $cat = get_the_category($parent->ID); $cat = $cat[0];
625 echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
626 echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
627 echo $before . get_the_title() . $after;
628
629 } elseif ( is_page() && !$post->post_parent ) {
630 echo $before . get_the_title() . $after;
631
632 } elseif ( is_page() && $post->post_parent ) {
633 $parent_id = $post->post_parent;
634 $breadcrumbs = array();
635 while ($parent_id) {
636 $page = get_page($parent_id);
637 $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
638 $parent_id = $page->post_parent;
639 }
640 $breadcrumbs = array_reverse($breadcrumbs);
641 foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
642 echo $before . get_the_title() . $after;
643
644 } elseif ( is_search() ) {
645 echo $before . 'Search results for "' . get_search_query() . '"' . $after;
646
647 } elseif ( is_tag() ) {
648 echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
649
650 } elseif ( is_author() ) {
651 global $author;
652 $userdata = get_userdata($author);
653 echo $before . 'Articles posted by ' . $userdata->display_name . $after;
654
655 } elseif ( is_404() ) {
656 echo $before . 'Error 404' . $after;
657 }
658
659 if ( get_query_var('paged') ) {
660 if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
661 echo __('Page') . ' ' . get_query_var('paged');
662 if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
663 }
664
665 echo '</div>';
666
667 }
668} // end dimox_breadcrumbs()
669
670/////////////////////////////////////
671// Add Custom Meta Box
672/////////////////////////////////////
673/* Fire our meta box setup function on the post editor screen. */
674add_action( 'load-post.php', 'mvp_post_meta_boxes_setup' );
675add_action( 'load-post-new.php', 'mvp_post_meta_boxes_setup' );
676
677/* Meta box setup function. */
678function mvp_post_meta_boxes_setup() {
679
680 /* Add meta boxes on the 'add_meta_boxes' hook. */
681 add_action( 'add_meta_boxes', 'mvp_add_post_meta_boxes' );
682
683 /* Save post meta on the 'save_post' hook. */
684 add_action( 'save_post', 'mvp_save_video_embed_meta', 10, 2 );
685 add_action( 'save_post', 'mvp_save_featured_headline_meta', 10, 2 );
686 add_action( 'save_post', 'mvp_save_photo_credit_meta', 10, 2 );
687 add_action( 'save_post', 'mvp_save_featured_image_meta', 10, 2 );
688 add_action( 'save_post', 'mvp_save_post_template_meta', 10, 2 );
689}
690
691/* Create one or more meta boxes to be displayed on the post editor screen. */
692function mvp_add_post_meta_boxes() {
693
694 add_meta_box(
695 'mvp-video-embed', // Unique ID
696 esc_html__( 'Video/Audio Embed', 'mvp-text' ), // Title
697 'mvp_video_embed_meta_box', // Callback function
698 'post', // Admin page (or post type)
699 'normal', // Context
700 'high' // Priority
701 );
702
703 add_meta_box(
704 'mvp-featured-headline', // Unique ID
705 esc_html__( 'Featured Headline', 'mvp-text' ), // Title
706 'mvp_featured_headline_meta_box', // Callback function
707 'post', // Admin page (or post type)
708 'normal', // Context
709 'high' // Priority
710 );
711
712 add_meta_box(
713 'mvp-featured-image', // Unique ID
714 esc_html__( 'Featured Image Show/Hide', 'mvp-text' ), // Title
715 'mvp_featured_image_meta_box', // Callback function
716 'post', // Admin page (or post type)
717 'side', // Context
718 'core' // Priority
719 );
720
721 add_meta_box(
722 'mvp-photo-credit', // Unique ID
723 esc_html__( 'Photo Credit', 'mvp-text' ), // Title
724 'mvp_photo_credit_meta_box', // Callback function
725 'post', // Admin page (or post type)
726 'normal', // Context
727 'high' // Priority
728 );
729
730 add_meta_box(
731 'mvp-post-template', // Unique ID
732 esc_html__( 'Post Template', 'mvp-text' ), // Title
733 'mvp_post_template_meta_box', // Callback function
734 'post', // Admin page (or post type)
735 'side', // Context
736 'core' // Priority
737 );
738}
739
740/* Display the post meta box. */
741if ( !function_exists( 'mvp_video_embed_meta_box' ) ) {
742function mvp_video_embed_meta_box( $object, $box ) { ?>
743
744 <?php wp_nonce_field( basename( __FILE__ ), 'mvp_video_embed_nonce' ); ?>
745
746 <p>
747 <label for="mvp-video-embed"><?php _e( "Enter your video or audio embed code.", 'mvp-text' ); ?></label>
748 <br />
749 <textarea class="widefat" name="mvp-video-embed" id="mvp-video-embed" cols="50" rows="5"><?php echo esc_html__( get_post_meta( $object->ID, 'mvp_video_embed', true ) ); ?></textarea>
750 </p>
751
752<?php }
753}
754
755/* Display the post meta box. */
756function mvp_featured_headline_meta_box( $object, $box ) { ?>
757
758 <?php wp_nonce_field( basename( __FILE__ ), 'mvp_featured_headline_nonce' ); ?>
759
760 <p>
761 <label for="mvp-featured-headline"><?php _e( "Add a custom featured headline that will be displayed in the featured slider.", 'mvp-text' ); ?></label>
762 <br />
763 <input class="widefat" type="text" name="mvp-featured-headline" id="mvp-featured-headline" value="<?php echo esc_html__( get_post_meta( $object->ID, 'mvp_featured_headline', true ) ); ?>" size="30" />
764 </p>
765<?php }
766
767/* Display the post meta box. */
768function mvp_featured_image_meta_box( $object, $box ) { ?>
769
770 <?php wp_nonce_field( basename( __FILE__ ), 'mvp_featured_image_nonce' ); $selected = esc_html__( get_post_meta( $object->ID, 'mvp_featured_image', true ) ); ?>
771
772 <p>
773 <label for="mvp-featured-image"><?php _e( "Select whether to show or hide the featured image from automatically displaying in this post.", 'mvp-text' ); ?></label>
774 <br />
775 <select class="widefat" name="mvp-featured-image" id="mvp-featured-image">
776 <option value="show" <?php selected( $selected, 'show' ); ?>>Show</option>
777 <option value="hide" <?php selected( $selected, 'hide' ); ?>>Hide</option>
778 </select>
779 </p>
780<?php }
781
782/* Display the post meta box. */
783if ( !function_exists( 'mvp_photo_credit_meta_box' ) ) {
784function mvp_photo_credit_meta_box( $object, $box ) { ?>
785
786 <?php wp_nonce_field( basename( __FILE__ ), 'mvp_photo_credit_nonce' ); ?>
787
788 <p>
789 <label for="mvp-photo-credit"><?php _e( "Add a photo credit for the featured image.", 'mvp-text' ); ?></label>
790 <br />
791 <input class="widefat" type="text" name="mvp-photo-credit" id="mvp-photo-credit" value="<?php echo esc_html__( get_post_meta( $object->ID, 'mvp_photo_credit', true ) ); ?>" size="30" />
792 </p>
793
794<?php }
795}
796
797/* Display the post meta box. */
798if ( !function_exists( 'mvp_post_template_meta_box' ) ) {
799function mvp_post_template_meta_box( $object, $box ) { ?>
800
801 <?php wp_nonce_field( basename( __FILE__ ), 'mvp_post_template_nonce' ); $selected = esc_html__( get_post_meta( $object->ID, 'mvp_post_template', true ) ); ?>
802
803 <p>
804 <label for="mvp-post-template"><?php _e( "Select from the default post template or a full-width template.", 'mvp-text' ); ?></label>
805 <br /><br />
806 <select class="widefat" name="mvp-post-template" id="mvp-post-template">
807 <option value="default" <?php selected( $selected, 'default' ); ?>>Default</option>
808 <option value="fullwidth" <?php selected( $selected, 'fullwidth' ); ?>>Full-width</option>
809 </select>
810 </p>
811<?php }
812}
813
814/* Save the meta box's post metadata. */
815if ( !function_exists( 'mvp_save_video_embed_meta' ) ) {
816function mvp_save_video_embed_meta( $post_id, $post ) {
817
818 /* Verify the nonce before proceeding. */
819 if ( !isset( $_POST['mvp_video_embed_nonce'] ) || !wp_verify_nonce( $_POST['mvp_video_embed_nonce'], basename( __FILE__ ) ) )
820 return $post_id;
821
822 /* Get the post type object. */
823 $post_type = get_post_type_object( $post->post_type );
824
825 /* Check if the current user has permission to edit the post. */
826 if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
827 return $post_id;
828
829 /* Get the posted data and sanitize it for use as an HTML class. */
830 $new_meta_value = ( isset( $_POST['mvp-video-embed'] ) ? balanceTags( $_POST['mvp-video-embed'] ) : '' );
831
832 /* Get the meta key. */
833 $meta_key = 'mvp_video_embed';
834
835 /* Get the meta value of the custom field key. */
836 $meta_value = get_post_meta( $post_id, $meta_key, true );
837
838 /* If a new meta value was added and there was no previous value, add it. */
839 if ( $new_meta_value && '' == $meta_value )
840 add_post_meta( $post_id, $meta_key, $new_meta_value, true );
841
842 /* If the new meta value does not match the old value, update it. */
843 elseif ( $new_meta_value && $new_meta_value != $meta_value )
844 update_post_meta( $post_id, $meta_key, $new_meta_value );
845
846 /* If there is no new meta value but an old value exists, delete it. */
847 elseif ( '' == $new_meta_value && $meta_value )
848 delete_post_meta( $post_id, $meta_key, $meta_value );
849} }
850
851/* Save the meta box's post metadata. */
852function mvp_save_featured_headline_meta( $post_id, $post ) {
853
854 /* Verify the nonce before proceeding. */
855 if ( !isset( $_POST['mvp_featured_headline_nonce'] ) || !wp_verify_nonce( $_POST['mvp_featured_headline_nonce'], basename( __FILE__ ) ) )
856 return $post_id;
857
858 /* Get the post type object. */
859 $post_type = get_post_type_object( $post->post_type );
860
861 /* Check if the current user has permission to edit the post. */
862 if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
863 return $post_id;
864
865 /* Get the posted data and sanitize it for use as an HTML class. */
866 $new_meta_value = ( isset( $_POST['mvp-featured-headline'] ) ? balanceTags( $_POST['mvp-featured-headline'] ) : '' );
867
868 /* Get the meta key. */
869 $meta_key = 'mvp_featured_headline';
870
871 /* Get the meta value of the custom field key. */
872 $meta_value = get_post_meta( $post_id, $meta_key, true );
873
874 /* If a new meta value was added and there was no previous value, add it. */
875 if ( $new_meta_value && '' == $meta_value )
876 add_post_meta( $post_id, $meta_key, $new_meta_value, true );
877
878 /* If the new meta value does not match the old value, update it. */
879 elseif ( $new_meta_value && $new_meta_value != $meta_value )
880 update_post_meta( $post_id, $meta_key, $new_meta_value );
881
882 /* If there is no new meta value but an old value exists, delete it. */
883 elseif ( '' == $new_meta_value && $meta_value )
884 delete_post_meta( $post_id, $meta_key, $meta_value );
885}
886
887/* Save the meta box's post metadata. */
888function mvp_save_featured_image_meta( $post_id, $post ) {
889
890 /* Verify the nonce before proceeding. */
891 if ( !isset( $_POST['mvp_featured_image_nonce'] ) || !wp_verify_nonce( $_POST['mvp_featured_image_nonce'], basename( __FILE__ ) ) )
892 return $post_id;
893
894 /* Get the post type object. */
895 $post_type = get_post_type_object( $post->post_type );
896
897 /* Check if the current user has permission to edit the post. */
898 if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
899 return $post_id;
900
901 /* Get the posted data and sanitize it for use as an HTML class. */
902 $new_meta_value = ( isset( $_POST['mvp-featured-image'] ) ? balanceTags( $_POST['mvp-featured-image'] ) : '' );
903
904 /* Get the meta key. */
905 $meta_key = 'mvp_featured_image';
906
907 /* Get the meta value of the custom field key. */
908 $meta_value = get_post_meta( $post_id, $meta_key, true );
909
910 /* If a new meta value was added and there was no previous value, add it. */
911 if ( $new_meta_value && '' == $meta_value )
912 add_post_meta( $post_id, $meta_key, $new_meta_value, true );
913
914 /* If the new meta value does not match the old value, update it. */
915 elseif ( $new_meta_value && $new_meta_value != $meta_value )
916 update_post_meta( $post_id, $meta_key, $new_meta_value );
917
918 /* If there is no new meta value but an old value exists, delete it. */
919 elseif ( '' == $new_meta_value && $meta_value )
920 delete_post_meta( $post_id, $meta_key, $meta_value );
921}
922
923/* Save the meta box's post metadata. */
924if ( !function_exists( 'mvp_save_photo_credit_meta' ) ) {
925function mvp_save_photo_credit_meta( $post_id, $post ) {
926
927 /* Verify the nonce before proceeding. */
928 if ( !isset( $_POST['mvp_photo_credit_nonce'] ) || !wp_verify_nonce( $_POST['mvp_photo_credit_nonce'], basename( __FILE__ ) ) )
929 return $post_id;
930
931 /* Get the post type object. */
932 $post_type = get_post_type_object( $post->post_type );
933
934 /* Check if the current user has permission to edit the post. */
935 if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
936 return $post_id;
937
938 /* Get the posted data and sanitize it for use as an HTML class. */
939 $new_meta_value = ( isset( $_POST['mvp-photo-credit'] ) ? balanceTags( $_POST['mvp-photo-credit'] ) : '' );
940
941 /* Get the meta key. */
942 $meta_key = 'mvp_photo_credit';
943
944 /* Get the meta value of the custom field key. */
945 $meta_value = get_post_meta( $post_id, $meta_key, true );
946
947 /* If a new meta value was added and there was no previous value, add it. */
948 if ( $new_meta_value && '' == $meta_value )
949 add_post_meta( $post_id, $meta_key, $new_meta_value, true );
950
951 /* If the new meta value does not match the old value, update it. */
952 elseif ( $new_meta_value && $new_meta_value != $meta_value )
953 update_post_meta( $post_id, $meta_key, $new_meta_value );
954
955 /* If there is no new meta value but an old value exists, delete it. */
956 elseif ( '' == $new_meta_value && $meta_value )
957 delete_post_meta( $post_id, $meta_key, $meta_value );
958} }
959
960/* Save the meta box's post metadata. */
961if ( !function_exists( 'mvp_save_post_template_meta' ) ) {
962function mvp_save_post_template_meta( $post_id, $post ) {
963
964 /* Verify the nonce before proceeding. */
965 if ( !isset( $_POST['mvp_post_template_nonce'] ) || !wp_verify_nonce( $_POST['mvp_post_template_nonce'], basename( __FILE__ ) ) )
966 return $post_id;
967
968 /* Get the post type object. */
969 $post_type = get_post_type_object( $post->post_type );
970
971 /* Check if the current user has permission to edit the post. */
972 if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
973 return $post_id;
974
975 /* Get the posted data and sanitize it for use as an HTML class. */
976 $new_meta_value = ( isset( $_POST['mvp-post-template'] ) ? balanceTags( $_POST['mvp-post-template'] ) : '' );
977
978 /* Get the meta key. */
979 $meta_key = 'mvp_post_template';
980
981 /* Get the meta value of the custom field key. */
982 $meta_value = get_post_meta( $post_id, $meta_key, true );
983
984 /* If a new meta value was added and there was no previous value, add it. */
985 if ( $new_meta_value && '' == $meta_value )
986 add_post_meta( $post_id, $meta_key, $new_meta_value, true );
987
988 /* If the new meta value does not match the old value, update it. */
989 elseif ( $new_meta_value && $new_meta_value != $meta_value )
990 update_post_meta( $post_id, $meta_key, $new_meta_value );
991
992 /* If there is no new meta value but an old value exists, delete it. */
993 elseif ( '' == $new_meta_value && $meta_value )
994 delete_post_meta( $post_id, $meta_key, $meta_value );
995} }
996
997/////////////////////////////////////
998// Add Content Limit
999/////////////////////////////////////
1000
1001function excerpt($limit) {
1002 $excerpt = explode(' ', get_the_excerpt(), $limit);
1003 if (count($excerpt)>=$limit) {
1004 array_pop($excerpt);
1005 $excerpt = implode(" ",$excerpt).'...';
1006 } else {
1007 $excerpt = implode(" ",$excerpt);
1008 }
1009 $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
1010 return $excerpt;
1011}
1012
1013function content($limit) {
1014 $content = explode(' ', get_the_content(), $limit);
1015 if (count($content)>=$limit) {
1016 array_pop($content);
1017 $content = implode(" ",$content).'...';
1018 } else {
1019 $content = implode(" ",$content);
1020 }
1021 $content = preg_replace('/\[.+\]/','', $content);
1022 $content = apply_filters('the_content', $content);
1023 $content = str_replace(']]>', ']]>', $content);
1024 return $content;
1025}
1026
1027/////////////////////////////////////
1028// Comments
1029/////////////////////////////////////
1030
1031function resport_comment( $comment, $args, $depth ) {
1032 $GLOBALS['comment'] = $comment;
1033 switch ( $comment->comment_type ) :
1034 case '' :
1035 ?>
1036 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
1037
1038
1039 <div class="comment-wrapper" id="comment-<?php comment_ID(); ?>">
1040 <div class="comment-inner">
1041
1042 <div class="comment-avatar">
1043 <?php echo get_avatar( $comment, 40 ); ?>
1044 </div>
1045
1046 <div class="commentmeta">
1047 <p class="comment-meta-1">
1048 <?php printf( __( '%s '), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
1049 </p>
1050 <p class="comment-meta-2">
1051 <?php echo get_comment_date(); ?> <?php _e( 'at', 'advanced'); ?> <?php echo get_comment_time(); ?>
1052 <?php edit_comment_link( __( 'Edit', 'mvp-text'), '(' , ')'); ?>
1053 </p>
1054
1055 </div>
1056
1057 <div class="text">
1058
1059 <?php if ( $comment->comment_approved == '0' ) : ?>
1060 <p class="waiting_approval"><?php _e( 'Your comment is awaiting moderation.', 'mvp-text' ); ?></p>
1061 <?php endif; ?>
1062
1063 <div class="c">
1064 <?php comment_text(); ?>
1065 </div>
1066
1067 </div><!-- .text -->
1068 <div class="clear"></div>
1069 <div class="comment-reply"><span class="reply"><?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></span></div>
1070 </div><!-- comment-inner -->
1071 </div><!-- comment-wrapper -->
1072 <?php
1073 break;
1074 case 'pingback' :
1075 case 'trackback' :
1076 ?>
1077 <li class="post pingback">
1078 <p><?php _e( 'Pingback:', 'mvp-text' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'mvp-text' ), ' ' ); ?></p>
1079 <?php
1080 break;
1081 endswitch;
1082}
1083
1084/////////////////////////////////////
1085// Popular Posts
1086/////////////////////////////////////
1087
1088function popularPosts($num) {
1089 global $wpdb;
1090
1091 $posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");
1092
1093 foreach ($posts as $post) {
1094 setup_postdata($post);
1095 $id = $post->ID;
1096 $title = $post->post_title;
1097 $count = $post->comment_count;
1098
1099 if ($count != 0) {
1100 $popular .= '<li>';
1101 $popular .= '<a href="' . get_permalink($id) . '" title="' . $title . '">' . $title . '</a> ';
1102 $popular .= '</li>';
1103 }
1104 }
1105 return $popular;
1106}
1107
1108/////////////////////////////////////
1109// Related Posts
1110/////////////////////////////////////
1111
1112function getRelatedPosts( $count=3) {
1113 global $post;
1114 $orig_post = $post;
1115
1116 $tags = wp_get_post_tags($post->ID);
1117 if ($tags) {
1118 $tag_ids = array();
1119 foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
1120 $args=array(
1121 'tag__in' => $tag_ids,
1122 'post__not_in' => array($post->ID),
1123 'posts_per_page'=> $count, // Number of related posts that will be shown.
1124 'ignore_sticky_posts'=>1
1125 );
1126 $my_query = new WP_Query( $args );
1127 if( $my_query->have_posts() ) { ?>
1128 <div id="related-posts">
1129 <h3><?php _e( 'Related Posts', 'mvp-text' ); ?></h3>
1130 <ul>
1131 <?php while( $my_query->have_posts() ) { $my_query->the_post(); ?>
1132 <li>
1133 <div class="related-image">
1134 <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?>
1135 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('large-thumb'); ?></a>
1136 <?php } ?>
1137 </div><!--related-image-->
1138 <div class="related-text">
1139 <a href="<?php the_permalink() ?>" class="main-headline"><?php the_title(); ?></a>
1140 </div><!--related-text-->
1141 </li>
1142 <?php }
1143 echo '</ul></div>';
1144 }
1145 }
1146 $post = $orig_post;
1147 wp_reset_query();
1148}
1149
1150/////////////////////////////////////
1151// Pagination
1152/////////////////////////////////////
1153
1154function pagination($pages = '', $range = 4)
1155{
1156 $showitems = ($range * 2)+1;
1157
1158 global $paged;
1159 if(empty($paged)) $paged = 1;
1160
1161 if($pages == '')
1162 {
1163 global $wp_query;
1164 $pages = $wp_query->max_num_pages;
1165 if(!$pages)
1166 {
1167 $pages = 1;
1168 }
1169 }
1170
1171 if(1 != $pages)
1172 {
1173 echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
1174 if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";
1175 if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>";
1176
1177 for ($i=1; $i <= $pages; $i++)
1178 {
1179 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
1180 {
1181 echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
1182 }
1183 }
1184
1185 if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>";
1186 if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";
1187 echo "</div>\n";
1188 }
1189}
1190
1191/////////////////////////////////////
1192// Social Media Javascript
1193/////////////////////////////////////
1194
1195if ( !function_exists( 'mvp_wp_footer' ) ) {
1196function mvp_wp_footer() {
1197
1198?>
1199
1200<?php if ( is_home() || is_category() || is_archive() && ! is_shop() ) { ?>
1201<script type='text/javascript'>
1202jQuery(document).ready(function($) {
1203 var $container = $('#home-widget-wrapper');
1204 $container.imagesLoaded( function(){
1205 $container.isotope({
1206 // options
1207 itemSelector : '.widget-container',
1208 transformsEnabled: false,
1209 layoutMode : 'masonry'
1210 });
1211 });
1212
1213 var $container1 = $('#home-blog-wrapper');
1214 $container1.imagesLoaded( function(){
1215 $container1.isotope({
1216 // options
1217 itemSelector : '.blog-container',
1218 transformsEnabled: false,
1219 layoutMode : 'masonry'
1220 });
1221 });
1222
1223 var $container2 = $('#cat-blog-wrapper');
1224 $container2.imagesLoaded( function(){
1225 $container2.isotope({
1226 // options
1227 itemSelector : '.cat-blog-container',
1228 transformsEnabled: false,
1229 layoutMode : 'masonry'
1230 });
1231 });
1232
1233 var $container3 = $('#sidebar-wrapper');
1234 $container3.imagesLoaded( function(){
1235 $container3.isotope({
1236 // options
1237 itemSelector : '.widget-container',
1238 transformsEnabled: false,
1239 layoutMode : 'masonry'
1240 });
1241 });
1242});
1243</script>
1244<?php } ?>
1245
1246<script type='text/javascript'>
1247//<![CDATA[
1248jQuery(document).ready(function($){
1249 $(window).load(function(){
1250 $('.flexslider').flexslider({
1251 animation: 'fade',
1252 slideshowSpeed: 8000
1253 });
1254 });
1255
1256$('.carousel').elastislide({
1257 imageW : 80,
1258 minItems : 2,
1259 margin : 3
1260});
1261
1262$(window).load(function(){
1263$("#headlines-wrapper").niceScroll({cursorcolor:"#888",cursorwidth: 7,cursorborder: 0,zindex:999999});
1264$("#sidebar-widget-in").getNiceScroll().resize();
1265});
1266
1267});
1268//]]>
1269</script>
1270
1271<script type="text/javascript">
1272//<![CDATA[
1273!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=true;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
1274//]]>
1275</script>
1276
1277<script type="text/javascript">
1278//<![CDATA[
1279(function() {
1280 window.PinIt = window.PinIt || { loaded:false };
1281 if (window.PinIt.loaded) return;
1282 window.PinIt.loaded = true;
1283 function async_load(){
1284 var s = document.createElement("script");
1285 s.type = "text/javascript";
1286 s.async = true;
1287 s.src = "https://assets.pinterest.com/js/pinit.js";
1288 var x = document.getElementsByTagName("script")[0];
1289 x.parentNode.insertBefore(s, x);
1290 }
1291 if (window.attachEvent)
1292 window.attachEvent("onload", async_load);
1293 else
1294 window.addEventListener("load", async_load, false);
1295})();
1296//]]>
1297</script>
1298
1299<script type="text/javascript">
1300//<![CDATA[
1301 (function() {
1302 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
1303 po.src = 'https://apis.google.com/js/plusone.js';
1304 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
1305 })();
1306//]]>
1307</script>
1308
1309<div id="fb-root"></div>
1310<script type="text/javascript">
1311//<![CDATA[
1312(function(d, s, id) {
1313 var js, fjs = d.getElementsByTagName(s)[0];
1314 if (d.getElementById(id)) return;
1315 js = d.createElement(s); js.id = id;
1316 js.async = true;
1317 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
1318 fjs.parentNode.insertBefore(js, fjs);
1319}(document, 'script', 'facebook-jssdk'));
1320//]]>
1321</script>
1322<?php }
1323
1324}
1325add_action( 'wp_footer', 'mvp_wp_footer' );
1326
1327/////////////////////////////////////
1328// Site Layout
1329/////////////////////////////////////
1330
1331if ( !function_exists( 'mvp_site_layout' ) ) {
1332function mvp_site_layout() {
1333
1334?>
1335
1336<?php global $post; $mvp_post_temp = get_post_meta($post->ID, "mvp_post_template", true); if ($mvp_post_temp == "fullwidth") { ?>
1337<style type="text/css">
1338@media screen and (min-width: 600px) {
1339#post-area {
1340 width: 100%;
1341 }
1342}
1343
1344</style>
1345<?php } ?>
1346
1347<?php if(get_option('gd_customcss')) { ?>
1348<style type="text/css">
1349<?php $customcss = get_option('gd_customcss'); if ($customcss) { echo stripslashes($customcss); } ?>
1350</style>
1351<?php } ?>
1352
1353<?php }
1354
1355}
1356
1357add_action( 'wp_head', 'mvp_site_layout' );
1358
1359/////////////////////////////////////
1360// Miscellaneous
1361/////////////////////////////////////
1362
1363// Place Wordpress Admin Bar Below Main Navigation
1364
1365if ( is_user_logged_in() ) {
1366 if ( is_admin_bar_showing() ) {
1367 function mvp_admin_bar() {
1368 echo "
1369 <style type='text/css'>
1370 #nav-main-wrapper {top: 32px !important;}
1371 </style>
1372 ";
1373 }
1374 add_action( 'wp_head', 'mvp_admin_bar' );
1375 }
1376}
1377
1378// Set Content Width
1379if ( ! isset( $content_width ) ) $content_width = 615;
1380
1381// Add RSS links to <head> section
1382add_theme_support( 'automatic-feed-links' );
1383
1384add_action('init', 'do_output_buffer');
1385function do_output_buffer() {
1386 ob_start();
1387}
1388
1389/////////////////////////////////////
1390// WooCommerce
1391/////////////////////////////////////
1392
1393add_theme_support( 'woocommerce' );
1394add_theme_support( 'wc-product-gallery-zoom' );
1395add_theme_support( 'wc-product-gallery-lightbox' );
1396add_theme_support( 'wc-product-gallery-slider' );
1397
1398?>
1399<?php
1400/* SORT SPECIFIED CATEGORIES IN CHRONOLOGICAL ORDER */
1401 function change_category_order( $query ) {
1402 if ( $query->is_category('2786') || is_category('2699') || is_category('3144') && $query->is_main_query() ) {
1403 $query->set( 'order', 'ASC' );
1404 }
1405}
1406add_action( 'pre_get_posts', 'change_category_order' );
1407?>