-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
669 lines (579 loc) · 28 KB
/
Copy pathfunctions.php
File metadata and controls
669 lines (579 loc) · 28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
<?php
/**
* marinara_blog functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Marinara_Blog
*/
/* Working Protocal Variable */
$protocol = is_ssl() ? 'https' : 'http';
/* Working Premium Theme Variable */
$marinara_blog_premium = marinara_blog_is_premium();
function marinara_blog_is_premium(){
return true;
}
/*
* Sanitize Text
=====================================*/
function marinara_blog_sanitize_text( $text ) {
return sanitize_text_field( $text );
}
/*
* Sanitize TextArea
=====================================*/
// function marinara_blog_sanitize_textarea( $text ) {
// return esc_textarea( $text );
// }
if ( ! function_exists( 'marinara_blog_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function marinara_blog_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on marinara_blog, use a find and replace
* to change 'marinara-blog' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'marinara-blog', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
/*
* Enable support for Page & Post Excerpt.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_post_type_support( 'page', 'excerpt' );
add_post_type_support( 'post', 'excerpt' );
function custom_excerpt_length( $length ) {
return 80;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'header-menu' => esc_html__( 'Header Menu', 'marinara-blog' ),
'footer-menu' => esc_html__( 'Footer Menu', 'marinara-blog' )
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
/*
* Enable support for Post Formats.
* See https://developer.wordpress.org/themes/functionality/post-formats/
*/
add_theme_support( 'post-formats', array(
'aside',
'gallery',
'image',
'video',
// 'audio',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'marinara_blog_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
}
endif; // marinara_blog_setup
add_action( 'after_setup_theme', 'marinara_blog_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function marinara_blog_content_width() {
$GLOBALS['content_width'] = apply_filters( 'marinara_blog_content_width', 640 );
}
add_action( 'after_setup_theme', 'marinara_blog_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function marinara_blog_register_sidebar( $name, $id, $description) {
register_sidebar( array(
// 'name' => esc_html__( $name, 'marinara-blog' ),
'name' => $name,
'id' => $id,
// 'description' => esc_html__( $description, 'marinara-blog'),
'description' => $description,
'before_widget' => '<div class="panel-group widget-group %2$s" id="accordion%1$s" role="tablist" aria-multiselectable="true"><div class="panel panel-default">',
'after_widget' => '</div></div></div></div>',
'before_title' => '<div class="panel-heading" role="tab" id="heading"><h4 class="panel-title"><a role="button" data-toggle="collapse" href="#collapse" aria-expanded="true" aria-controls="collapse">',
'after_title' => '<i class="fa fa-caret-down float-right"></i></a></h4></div><div id="collapse" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading"><div class="panel-body">',
) );
}
function marinara_blog_widgets_init() {
marinara_blog_register_sidebar( 'Page Sidebar', 'page-sidebar-widget', 'Displays on the side of pages with a sidebar.' );
marinara_blog_register_sidebar( 'Header Logged In User Options Dropdown', 'header-user-options-dropdown-widget', 'Displays in the header user dropdown are if a user is loged in.' );
marinara_blog_register_sidebar( 'Single Sidebar', 'single-sidebar-widget', 'Displays on the side of single posts with a sidebar.' );
marinara_blog_register_sidebar( 'Author Sidebar', 'author-sidebar-widget', 'Displays on the side of author pages with sidebar.' );
}
add_action( 'widgets_init', 'marinara_blog_widgets_init' );
function marinara_blog_remove_widget_title( $widget_title ) {
if (!$widget_title):
return 'Set Widget Title';
else:
return $widget_title;
endif;
}
add_filter( 'widget_title', 'marinara_blog_remove_widget_title' );
// function my_jquery_enqueue() {
// wp_deregister_script('jquery');
// wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
// wp_enqueue_script('jquery');
// }
// if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
/**
* Enqueue scripts and styles.
*/
function marinara_blog_scripts() {
wp_enqueue_style('bootstrap-css', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '1.0.5');
wp_enqueue_style('marinara_blog-font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '1.0.5');
wp_enqueue_style('marinara_blog-google-fonts', get_template_directory_uri() . '/css/google-fonts.css', array(), '1.0.5');
wp_enqueue_style('local-fonts', get_template_directory_uri(). '/css/fonts.css');
wp_enqueue_style('marinara_blog-style', get_stylesheet_uri(),
array('bootstrap-css','marinara_blog-font-awesome', 'marinara_blog-google-fonts', 'local-fonts'),
'1.1.0'
);
wp_enqueue_script('bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '1.0.5', true);
wp_enqueue_script( 'marinara_blog-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0.5', true );
wp_enqueue_script( 'marinara_blog-general-theme-script', get_template_directory_uri() . '/js/theme-script.js', array('jquery'), '1.0.5', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'marinara_blog_scripts' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/* Extend bootstrap menus for WP
* Register Custom Navigation Walker */
require_once( get_template_directory() . '/inc/wp_bootstrap_navwalker.php' );
// Enable the use of shortcodes in text widgets.
add_filter( 'widget_text', 'do_shortcode' );
/*
* Favicon
=====================================*/
function marinara_blog_fav() {
if( get_theme_mod( 'marinara_blog_favicon') != "" ):
echo '<link rel="Favicon Icon" href="'; echo get_theme_mod( "marinara_blog_favicon" ); echo '" type="image/ico" sizes="32x32"/>';
else:
echo '<link rel="Favicon Icon" href="'; echo get_template_directory_uri(); echo '/img/favicon/default.png" type="image/ico" sizes="32x32"/>';
endif;
}
add_action( 'login_enqueue_scripts', 'marinara_blog_fav' );
add_action('wp_head', 'marinara_blog_fav');
add_action('admin_head', 'marinara_blog_fav');
/*
* Google Analytics
=====================================*/
function marinara_blog_google_analytics() {
echo '<!-- =================================================================
==================== Google Analytics Tracking ======================
=================================================================== -->';
?>
<script type="text/javascript">
<?php if( get_theme_mod('google_analytics_code') != '' ) {
echo get_theme_mod('google_analytics_code'); ?>
console.log('G Analytics Enabled');
<?php } else { ?>
console.log('G Analytics Not Enabled');
<?php } ?>
</script><?php
}
add_action('wp_footer', 'marinara_blog_google_analytics');
// theme func marinara_blog_social_shares()
function marinara_blog_social_shares_buttons(){
$post = get_post();
// Get Twitter Handle
$twitterHandle = str_replace('https://twitter.com/', '', get_theme_mod('marinara_blog_twitter'));
// Get current page URL
$urlToShare = get_permalink();
// Get current page title
$titleToShare = str_replace( ' ', '%20', $post->post_title);
// Get Post Thumbnail for pinterest
$thumbnailToShare = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
// Get Bloginfo Name
$siteTitle = str_replace( ' ', '%20', get_bloginfo('name'));
// Social Share URL
$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$urlToShare;
if ($twitterHandle){
$twitterURL = 'https://twitter.com/intent/tweet?text='.$titleToShare.'&url='.$urlToShare.'&via='.$twitterHandle;
} else {
$twitterURL = 'https://twitter.com/intent/tweet?text='.$titleToShare.'&url='.$urlToShare.'&via='.$siteTitle;
}
$googleURL = 'https://plus.google.com/share?url='.$urlToShare;
$pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$urlToShare.'&media='.$thumbnailToShare[0].'&description='.$titleToShare;
$output_string = '<ul id="oneday-social-shares" class="social-shares clearfix">
<li class="facebook-share col-xs-3">
<a href="<?php echo $facebookURL; ?>" type="button" data-toggle="tooltip" data-placement="top" title="Share On Facebook" target="_blank">
<i class="fa fa-facebook"></i>
</a>
</li>
<li class="twitter-share col-xs-3">
<a href="<?php echo $twitterURL; ?>" type="button" data-toggle="tooltip" data-placement="top" title="Share On Twitter" rel="nofollow" target="_blank">
<i class="fa fa-twitter"></i>
</a>
</li>
<li class="pinterest-share col-xs-3">
<a href="<?php echo $pinterestURL; ?>" type="button" data-toggle="tooltip" data-placement="top" title="Share On Pinterest" target="_blank">
<i class="fa fa-pinterest"></i>
</a>
</li>
<li class="google-share col-xs-3">
<a href="<?php echo $googleURL; ?>" type="button" data-toggle="tooltip" data-placement="top" title="Share On Google Plus" target="_blank">
<i class="fa fa-google"></i>
</a>
</li>
</ul>';
echo $output_string;
}
function marinara_blog_authors_func( ){
ob_start(); ?>
<div class="author-listing-wrapper clearfix">
<?php
$args = array(
'blog_id' => $GLOBALS['blog_id'],
'role' => '',
'role__in' => array(),
'role__not_in' => array(),
'meta_key' => '',
'meta_value' => '',
'meta_compare' => '',
'meta_query' => array(),
'date_query' => array(),
'include' => array(),
'exclude' => array(),
'orderby' => 'login',
'order' => 'ASC',
'offset' => '',
'search' => '',
'number' => '',
'count_total' => false,
'fields' => 'all',
'who' => '',
);
$authors = get_users( $args );
foreach( $authors as $author ){
$author_avatar_url = esc_attr( get_the_author_meta( 'profile_img', $author->ID ) );
if ( $author_avatar_url == '') {
$author_avatar = get_avatar($author->ID,200);
}
$author_posted_articles_cnt = count_user_posts( $author->ID , 'post' );
$author_email = esc_html($author->user_email);
$author_name = $author->display_name;
$author_url = get_author_posts_url( $author->ID );
?>
<div class="col-xs-12 col-md-6">
<div class="author-row author-row-<?php echo $author->ID; ?> row">
<a href="<?php echo $author_url; ?>" title="<?php echo $author_name; ?>" class="author-avatar-col col-xs-4" style="padding-right: 0;">
<?php if ($author_avatar_url != ''): ?>
<img src="<?php echo $author_avatar_url; ?>" class="avatar" alt="<?php echo $author_name; ?> Avatar"/>
<?php else: ?>
<?php echo $author_avatar; ?>
<?php endif; ?>
</a>
<div class="col-xs-8">
<h4 class="author-name"><a href="<?php echo $author_url; ?>" title="<?php echo $author_name; ?>"><?php echo $author_name; ?></a></h4>
<p class="author-website-count"><i class="fa fa-pencil"></i> <?php echo $author_posted_articles_cnt; ?> <?php echo ($author_posted_articles_cnt==1?'Article':'Articles');?> Written</p>
</div>
</div>
</div>
<?php }
if( empty( $authors ) ) { ?>
<div class="no-authors-col col-xs-12"><h4>There are no users with the role: Author</h4></div>
<?php } ?>
</div><!-- end of <div class="author-listing-wrapper"> -->
<?php
$output_string = ob_get_contents();
ob_end_clean();
return $output_string; ?>
<?php
}
/* BreadCrumb Function
======================================== */
function marinara_blog_breadcrumb() {
// Settings
$separator = '»';
$breadcrums_id = 'breadcrumbs';
$breadcrums_class = 'breadcrumbs';
$home_title = 'Home';
// If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
$custom_taxonomy = 'product_cat';
// Get the query & post information
global $post,$wp_query;
// Do not display on the homepage
if ( !is_front_page() ) {
// Build the breadcrums
echo '<ul id="'.$breadcrums_id.'" class="'. $breadcrums_class.'">';
// Home page
echo '<li class="item-home"><a class="bread-link bread-home" href="' . get_home_url() . '" title="' . $home_title . '">' . $home_title . '</a></li>';
echo '<li class="separator separator-home"> ' . $separator . ' </li>';
if ( is_archive() && !is_tax() && !is_category() && !is_tag() ) {
echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . post_type_archive_title($prefix, false) . '</strong></li>';
} else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
if($post_type != 'post') {
$post_type_object = get_post_type_object($post_type);
$post_type_archive = get_post_type_archive_link($post_type);
echo '<li class="item-cat item-custom-post-type-' . $post_type . '"><a class="bread-cat bread-custom-post-type-' . $post_type . '" href="' . $post_type_archive . '" title="' . $post_type_object->labels->name . '">' . $post_type_object->labels->name . '</a></li>';
echo '<li class="separator"> ' . $separator . ' </li>';
}
$custom_tax_name = get_queried_object()->name;
echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . $custom_tax_name . '</strong></li>';
} else if ( is_single() ) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
if($post_type != 'post') {
$post_type_object = get_post_type_object($post_type);
$post_type_archive = get_post_type_archive_link($post_type);
echo '<li class="item-cat item-custom-post-type-' . $post_type . '"><a class="bread-cat bread-custom-post-type-' . $post_type . '" href="' . $post_type_archive . '" title="' . $post_type_object->labels->name . '">' . $post_type_object->labels->name . '</a></li>';
echo '<li class="separator"> ' . $separator . ' </li>';
}
// Get post category info
$category = get_the_category();
if(!empty($category)) {
// Get last category post is in
$last_category = end(array_values($category));
// Get parent any categories and create array
$get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),',');
$cat_parents = explode(',',$get_cat_parents);
// Loop through parent categories and store in variable $cat_display
$cat_display = '';
foreach($cat_parents as $parents) {
$cat_display .= '<li class="item-cat">'.$parents.'</li>';
$cat_display .= '<li class="separator"> ' . $separator . ' </li>';
}
}
// If it's a custom post type within a custom taxonomy
$taxonomy_exists = taxonomy_exists($custom_taxonomy);
if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
$taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy );
$cat_id = $taxonomy_terms[0]->term_id;
$cat_nicename = $taxonomy_terms[0]->slug;
$cat_link = get_term_link($taxonomy_terms[0]->term_id, $custom_taxonomy);
$cat_name = $taxonomy_terms[0]->name;
}
// Check if the post is in a category
if(!empty($last_category)) {
echo $cat_display;
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
// Else if post is in a custom taxonomy
} else if(!empty($cat_id)) {
echo '<li class="item-cat item-cat-' . $cat_id . ' item-cat-' . $cat_nicename . '"><a class="bread-cat bread-cat-' . $cat_id . ' bread-cat-' . $cat_nicename . '" href="' . $cat_link . '" title="' . $cat_name . '">' . $cat_name . '</a></li>';
echo '<li class="separator"> ' . $separator . ' </li>';
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
} else {
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
}
} else if ( is_category() ) {
// Category page
echo '<li class="item-current item-cat"><strong class="bread-current bread-cat">' . single_cat_title('', false) . '</strong></li>';
} else if ( is_page() ) {
// Standard page
if( $post->post_parent ){
// If child page, get parents
$anc = get_post_ancestors( $post->ID );
// Get parents in the right order
$anc = array_reverse($anc);
// Parent page loop
if ( !isset( $parents ) ) $parents = null;
foreach ( $anc as $ancestor ) {
$parents .= '<li class="item-parent item-parent-' . $ancestor . '"><a class="bread-parent bread-parent-' . $ancestor . '" href="' . get_permalink($ancestor) . '" title="' . get_the_title($ancestor) . '">' . get_the_title($ancestor) . '</a></li>';
$parents .= '<li class="separator separator-' . $ancestor . '"> ' . $separator . ' </li>';
}
// Display parent pages
echo $parents;
// Current page
echo '<li class="item-current item-' . $post->ID . '"><strong title="' . get_the_title() . '"> ' . get_the_title() . '</strong></li>';
} else {
// Just display current page if not parents
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '"> ' . get_the_title() . '</strong></li>';
}
} else if ( is_tag() ) {
// Tag page
// Get tag information
$term_id = get_query_var('tag_id');
$taxonomy = 'post_tag';
$args = 'include=' . $term_id;
$terms = get_terms( $taxonomy, $args );
$get_term_id = $terms[0]->term_id;
$get_term_slug = $terms[0]->slug;
$get_term_name = $terms[0]->name;
// Display the tag name
echo '<li class="item-current item-tag-' . $get_term_id . ' item-tag-' . $get_term_slug . '"><strong class="bread-current bread-tag-' . $get_term_id . ' bread-tag-' . $get_term_slug . '">' . $get_term_name . '</strong></li>';
} elseif ( is_day() ) {
// Day archive
// Year link
echo '<li class="item-year item-year-' . get_the_time('Y') . '"><a class="bread-year bread-year-' . get_the_time('Y') . '" href="' . get_year_link( get_the_time('Y') ) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</a></li>';
echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
// Month link
echo '<li class="item-month item-month-' . get_the_time('m') . '"><a class="bread-month bread-month-' . get_the_time('m') . '" href="' . get_month_link( get_the_time('Y'), get_the_time('m') ) . '" title="' . get_the_time('M') . '">' . get_the_time('M') . ' Archives</a></li>';
echo '<li class="separator separator-' . get_the_time('m') . '"> ' . $separator . ' </li>';
// Day display
echo '<li class="item-current item-' . get_the_time('j') . '"><strong class="bread-current bread-' . get_the_time('j') . '"> ' . get_the_time('jS') . ' ' . get_the_time('M') . ' Archives</strong></li>';
} else if ( is_month() ) {
// Month Archive
// Year link
echo '<li class="item-year item-year-' . get_the_time('Y') . '"><a class="bread-year bread-year-' . get_the_time('Y') . '" href="' . get_year_link( get_the_time('Y') ) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</a></li>';
echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
// Month display
echo '<li class="item-month item-month-' . get_the_time('m') . '"><strong class="bread-month bread-month-' . get_the_time('m') . '" title="' . get_the_time('M') . '">' . get_the_time('M') . ' Archives</strong></li>';
} else if ( is_year() ) {
// Display year archive
echo '<li class="item-current item-current-' . get_the_time('Y') . '"><strong class="bread-current bread-current-' . get_the_time('Y') . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</strong></li>';
} else if ( is_author() ) {
// Auhor archive
// Get the author information
global $author;
$userdata = get_userdata( $author );
// Display author name
echo '<li class="item-current item-current-' . $userdata->user_nicename . '"><strong class="bread-current bread-current-' . $userdata->user_nicename . '" title="' . $userdata->display_name . '">' . 'Author: ' . $userdata->display_name . '</strong></li>';
} else if ( get_query_var('paged') ) {
// Paginated archives
echo '<li class="item-current item-current-' . get_query_var('paged') . '"><strong class="bread-current bread-current-' . get_query_var('paged') . '" title="Page ' . get_query_var('paged') . '">'.__('Page', 'marinara-blog') . ' ' . get_query_var('paged') . '</strong></li>';
} else if ( is_search() ) {
// Search results page
echo '<li class="item-current item-current-' . get_search_query() . '"><strong class="bread-current bread-current-' . get_search_query() . '" title="Search results for: ' . get_search_query() . '">Search results for: ' . get_search_query() . '</strong></li>';
} elseif ( is_404() ) {
// 404 page
echo '<li>' . 'Error 404' . '</li>';
}
echo '</ul>';
}
}
/* ============================================================
Adding Disqus Comment Count Theme Support
============================================================ */
function disqus_count_script() {
$marinara_blog_is_disqus_enabled = false;
if ($marinara_blog_is_disqus_enabled){
echo '<script id="dsq-count-scr" src="//marinara_blog.disqus.com/count.js" async></script>';
}
}
add_action('wp_head', 'disqus_count_script');
/* ============================================================
Pagination
============================================================ */
function marinara_blog_numeric_posts_nav( $query = NULL, $paged = NULL ) {
if ( empty( $query ) ) {
global $wp_query;
} else {
$wp_query = $query;
}
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 ) {
return;
}
if ( empty( $paged ) ) {
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
}
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 ) {
$links[] = $paged;
}
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="pagination-navigation clearfix"><ul style="margin: 0; padding: 0;">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() ) {
printf( '<li>%s</li>' . "\n", get_previous_posts_link() );
}
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>...</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) ) {
echo '<li>...</li>' . "\n";
}
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() ) {
printf( '<li>%s</li>' . "\n", get_next_posts_link() );
}
echo '</ul></div>' . "\n";
}
function strip_shortcode_gallery( $content ) {
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
if ( ! empty( $matches ) ) {
foreach ( $matches as $shortcode ) {
if ( 'gallery' === $shortcode[2] ) {
$pos = strpos( $content, $shortcode[0] );
if( false !== $pos ) {
return substr_replace( $content, '', $pos, strlen( $shortcode[0] ) );
}
}
}
}
return $content;
}