-
Notifications
You must be signed in to change notification settings - Fork 471
/
storefront-template-functions.php
845 lines (738 loc) · 23.3 KB
/
storefront-template-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
<?php
/**
* Storefront template functions.
*
* @package storefront
*/
if ( ! function_exists( 'storefront_display_comments' ) ) {
/**
* Storefront display comments
*
* @since 1.0.0
*/
function storefront_display_comments() {
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
}
}
if ( ! function_exists( 'storefront_comment' ) ) {
/**
* Storefront comment template
*
* @param array $comment the comment array.
* @param array $args the comment args.
* @param int $depth the comment depth.
* @since 1.0.0
*/
function storefront_comment( $comment, $args, $depth ) {
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo esc_attr( $tag ); ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<div class="comment-body">
<div class="comment-meta commentmetadata">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 128 ); ?>
<?php printf( wp_kses_post( '<cite class="fn">%s</cite>', 'storefront' ), get_comment_author_link() ); ?>
</div>
<?php if ( '0' == $comment->comment_approved ) : ?>
<em class="comment-awaiting-moderation"><?php esc_attr_e( 'Your comment is awaiting moderation.', 'storefront' ); ?></em>
<br />
<?php endif; ?>
<a href="<?php echo esc_url( htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ); ?>" class="comment-date">
<?php echo '<time>' . get_comment_date() . '</time>'; ?>
</a>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-content">
<?php endif; ?>
<div class="comment-text">
<?php comment_text(); ?>
</div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<?php edit_comment_link( __( 'Edit', 'storefront' ), ' ', '' ); ?>
</div>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
}
if ( ! function_exists( 'storefront_footer_widgets' ) ) {
/**
* Display the footer widget regions
*
* @since 1.0.0
* @return void
*/
function storefront_footer_widgets() {
if ( is_active_sidebar( 'footer-4' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 4 );
} elseif ( is_active_sidebar( 'footer-3' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 3 );
} elseif ( is_active_sidebar( 'footer-2' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 2 );
} elseif ( is_active_sidebar( 'footer-1' ) ) {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 1 );
} else {
$widget_columns = apply_filters( 'storefront_footer_widget_regions', 0 );
}
if ( $widget_columns > 0 ) : ?>
<section class="footer-widgets col-<?php echo intval( $widget_columns ); ?> fix">
<?php
$i = 0;
while ( $i < $widget_columns ) : $i++;
if ( is_active_sidebar( 'footer-' . $i ) ) : ?>
<section class="block footer-widget-<?php echo intval( $i ); ?>">
<?php dynamic_sidebar( 'footer-' . intval( $i ) ); ?>
</section>
<?php endif;
endwhile; ?>
</section><!-- /.footer-widgets -->
<?php endif;
}
}
if ( ! function_exists( 'storefront_credit' ) ) {
/**
* Display the theme credit
*
* @since 1.0.0
* @return void
*/
function storefront_credit() {
?>
<div class="site-info">
<?php echo esc_html( apply_filters( 'storefront_copyright_text', $content = '© ' . get_bloginfo( 'name' ) . ' ' . date( 'Y' ) ) ); ?>
<?php if ( apply_filters( 'storefront_credit_link', true ) ) { ?>
<br /> <?php printf( esc_attr__( '%1$s designed by %2$s.', 'storefront' ), 'Storefront', '<a href="http://www.woothemes.com" alt="Premium WordPress Themes & Plugins by WooThemes" title="Premium WordPress Themes & Plugins by WooThemes" rel="designer">WooThemes</a>' ); ?>
<?php } ?>
</div><!-- .site-info -->
<?php
}
}
if ( ! function_exists( 'storefront_header_widget_region' ) ) {
/**
* Display header widget region
*
* @since 1.0.0
*/
function storefront_header_widget_region() {
if ( is_active_sidebar( 'header-1' ) ) {
?>
<div class="header-widget-region" role="complementary">
<div class="col-full">
<?php dynamic_sidebar( 'header-1' ); ?>
</div>
</div>
<?php
}
}
}
if ( ! function_exists( 'storefront_site_branding' ) ) {
/**
* Display Site Branding
*
* @since 1.0.0
* @return void
*/
function storefront_site_branding() {
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
the_custom_logo();
} elseif ( function_exists( 'jetpack_has_site_logo' ) && jetpack_has_site_logo() ) {
jetpack_the_site_logo();
} else { ?>
<div class="site-branding">
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php if ( '' != get_bloginfo( 'description' ) ) { ?>
<p class="site-description"><?php echo bloginfo( 'description' ); ?></p>
<?php } ?>
</div>
<?php }
}
}
if ( ! function_exists( 'storefront_primary_navigation' ) ) {
/**
* Display Primary Navigation
*
* @since 1.0.0
* @return void
*/
function storefront_primary_navigation() {
?>
<nav id="site-navigation" class="main-navigation" role="navigation" aria-label="<?php esc_html_e( 'Primary Navigation', 'storefront' ); ?>">
<button class="menu-toggle" aria-controls="primary-navigation" aria-expanded="false"><span><?php echo esc_attr( apply_filters( 'storefront_menu_toggle_text', __( 'Menu', 'storefront' ) ) ); ?></span></button>
<?php
wp_nav_menu(
array(
'theme_location' => 'primary',
'container_class' => 'primary-navigation',
)
);
wp_nav_menu(
array(
'theme_location' => 'handheld',
'container_class' => 'handheld-navigation',
)
);
?>
</nav><!-- #site-navigation -->
<?php
}
}
if ( ! function_exists( 'storefront_secondary_navigation' ) ) {
/**
* Display Secondary Navigation
*
* @since 1.0.0
* @return void
*/
function storefront_secondary_navigation() {
if ( has_nav_menu( 'secondary' ) ) {
?>
<nav class="secondary-navigation" role="navigation" aria-label="<?php esc_html_e( 'Secondary Navigation', 'storefront' ); ?>">
<?php
wp_nav_menu(
array(
'theme_location' => 'secondary',
'fallback_cb' => '',
)
);
?>
</nav><!-- #site-navigation -->
<?php
}
}
}
if ( ! function_exists( 'storefront_skip_links' ) ) {
/**
* Skip links
*
* @since 1.4.1
* @return void
*/
function storefront_skip_links() {
?>
<a class="skip-link screen-reader-text" href="#site-navigation"><?php esc_attr_e( 'Skip to navigation', 'storefront' ); ?></a>
<a class="skip-link screen-reader-text" href="#content"><?php esc_attr_e( 'Skip to content', 'storefront' ); ?></a>
<?php
}
}
if ( ! function_exists( 'storefront_page_header' ) ) {
/**
* Display the post header with a link to the single post
*
* @since 1.0.0
*/
function storefront_page_header() {
?>
<header class="entry-header">
<?php
storefront_post_thumbnail( 'full' );
the_title( '<h1 class="entry-title">', '</h1>' );
?>
</header><!-- .entry-header -->
<?php
}
}
if ( ! function_exists( 'storefront_page_content' ) ) {
/**
* Display the post content with a link to the single post
*
* @since 1.0.0
*/
function storefront_page_content() {
?>
<div class="entry-content">
<?php the_content(); ?>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'storefront' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<?php
}
}
if ( ! function_exists( 'storefront_post_header' ) ) {
/**
* Display the post header with a link to the single post
*
* @since 1.0.0
*/
function storefront_post_header() {
?>
<header class="entry-header">
<?php
if ( is_single() ) {
storefront_posted_on();
the_title( '<h1 class="entry-title">', '</h1>' );
} else {
if ( 'post' == get_post_type() ) {
storefront_posted_on();
}
the_title( sprintf( '<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' );
}
?>
</header><!-- .entry-header -->
<?php
}
}
if ( ! function_exists( 'storefront_post_content' ) ) {
/**
* Display the post content with a link to the single post
*
* @since 1.0.0
*/
function storefront_post_content() {
?>
<div class="entry-content">
<?php
storefront_post_thumbnail( 'full' );
the_content(
sprintf(
__( 'Continue reading %s', 'storefront' ),
'<span class="screen-reader-text">' . get_the_title() . '</span>'
)
);
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'storefront' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<?php
}
}
if ( ! function_exists( 'storefront_post_meta' ) ) {
/**
* Display the post meta
*
* @since 1.0.0
*/
function storefront_post_meta() {
?>
<aside class="entry-meta">
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search.
?>
<div class="author">
<?php
echo get_avatar( get_the_author_meta( 'ID' ), 128 );
echo '<div class="label">' . esc_attr( __( 'Written by', 'storefront' ) ) . '</div>';
the_author_posts_link();
?>
</div>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'storefront' ) );
if ( $categories_list ) : ?>
<div class="cat-links">
<?php
echo '<div class="label">' . esc_attr( __( 'Posted in', 'storefront' ) ) . '</div>';
echo wp_kses_post( $categories_list );
?>
</div>
<?php endif; // End if categories. ?>
<?php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', 'storefront' ) );
if ( $tags_list ) : ?>
<div class="tags-links">
<?php
echo '<div class="label">' . esc_attr( __( 'Tagged', 'storefront' ) ) . '</div>';
echo wp_kses_post( $tags_list );
?>
</div>
<?php endif; // End if $tags_list. ?>
<?php endif; // End if 'post' == get_post_type(). ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<div class="comments-link">
<?php echo '<div class="label">' . esc_attr( __( 'Comments', 'storefront' ) ) . '</div>'; ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'storefront' ), __( '1 Comment', 'storefront' ), __( '% Comments', 'storefront' ) ); ?></span>
</div>
<?php endif; ?>
</aside>
<?php
}
}
if ( ! function_exists( 'storefront_paging_nav' ) ) {
/**
* Display navigation to next/previous set of posts when applicable.
*/
function storefront_paging_nav() {
global $wp_query;
$args = array(
'type' => 'list',
'next_text' => _x( 'Next', 'Next post', 'storefront' ),
'prev_text' => _x( 'Previous', 'Previous post', 'storefront' ),
);
the_posts_pagination( $args );
}
}
if ( ! function_exists( 'storefront_post_nav' ) ) {
/**
* Display navigation to next/previous post when applicable.
*/
function storefront_post_nav() {
$args = array(
'next_text' => '%title',
'prev_text' => '%title',
);
the_post_navigation( $args );
}
}
if ( ! function_exists( 'storefront_posted_on' ) ) {
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function storefront_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time> <time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
_x( 'Posted on %s', 'post date', 'storefront' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
echo wp_kses( apply_filters( 'storefront_single_post_posted_on_html', '<span class="posted-on">' . $posted_on . '</span>', $posted_on ), array(
'span' => array(
'class' => array(),
),
'a' => array(
'href' => array(),
'title' => array(),
'rel' => array(),
),
'time' => array(
'datetime' => array(),
'class' => array(),
),
) );
}
}
if ( ! function_exists( 'storefront_product_categories' ) ) {
/**
* Display Product Categories
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @param array $args the product section args.
* @return void
*/
function storefront_product_categories( $args ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_product_categories_args', array(
'limit' => 3,
'columns' => 3,
'child_categories' => 0,
'orderby' => 'name',
'title' => __( 'Shop by Category', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-product-categories">';
do_action( 'storefront_homepage_before_product_categories' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_product_categories_title' );
echo storefront_do_shortcode( 'product_categories', array(
'number' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
'orderby' => esc_attr( $args['orderby'] ),
'parent' => esc_attr( $args['child_categories'] ),
) );
do_action( 'storefront_homepage_after_product_categories' );
echo '</section>';
}
}
}
if ( ! function_exists( 'storefront_recent_products' ) ) {
/**
* Display Recent Products
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @param array $args the product section args.
* @return void
*/
function storefront_recent_products( $args ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_recent_products_args', array(
'limit' => 4,
'columns' => 4,
'title' => __( 'New In', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-recent-products">';
do_action( 'storefront_homepage_before_recent_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_recent_products_title' );
echo storefront_do_shortcode( 'recent_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
do_action( 'storefront_homepage_after_recent_products' );
echo '</section>';
}
}
}
if ( ! function_exists( 'storefront_featured_products' ) ) {
/**
* Display Featured Products
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @param array $args the product section args.
* @return void
*/
function storefront_featured_products( $args ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_featured_products_args', array(
'limit' => 4,
'columns' => 4,
'orderby' => 'date',
'order' => 'desc',
'title' => __( 'We Recommend', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-featured-products">';
do_action( 'storefront_homepage_before_featured_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_featured_products_title' );
echo storefront_do_shortcode( 'featured_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
'orderby' => esc_attr( $args['orderby'] ),
'order' => esc_attr( $args['order'] ),
) );
do_action( 'storefront_homepage_after_featured_products' );
echo '</section>';
}
}
}
if ( ! function_exists( 'storefront_popular_products' ) ) {
/**
* Display Popular Products
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @param array $args the product section args.
* @return void
*/
function storefront_popular_products( $args ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_popular_products_args', array(
'limit' => 4,
'columns' => 4,
'title' => __( 'Fan Favorites', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-popular-products">';
do_action( 'storefront_homepage_before_popular_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_popular_products_title' );
echo storefront_do_shortcode( 'top_rated_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
do_action( 'storefront_homepage_after_popular_products' );
echo '</section>';
}
}
}
if ( ! function_exists( 'storefront_on_sale_products' ) ) {
/**
* Display On Sale Products
* Hooked into the `homepage` action in the homepage template
*
* @param array $args the product section args.
* @since 1.0.0
* @return void
*/
function storefront_on_sale_products( $args ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_on_sale_products_args', array(
'limit' => 4,
'columns' => 4,
'title' => __( 'On Sale', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-on-sale-products">';
do_action( 'storefront_homepage_before_on_sale_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_on_sale_products_title' );
echo storefront_do_shortcode( 'sale_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
do_action( 'storefront_homepage_after_on_sale_products' );
echo '</section>';
}
}
}
if ( ! function_exists( 'storefront_best_selling_products' ) ) {
/**
* Display Best Selling Products
* Hooked into the `homepage` action in the homepage template
*
* @since 2.0.0
* @param array $args the product section args.
* @return void
*/
function storefront_best_selling_products( $args ) {
if ( is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_best_selling_products_args', array(
'limit' => 4,
'columns' => 4,
'title' => esc_attr__( 'Best Sellers', 'storefront' ),
) );
echo '<section class="storefront-product-section storefront-best-selling-products">';
do_action( 'storefront_homepage_before_best_selling_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_best_selling_products_title' );
echo storefront_do_shortcode( 'best_selling_products', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) );
do_action( 'storefront_homepage_after_best_selling_products' );
echo '</section>';
}
}
}
if ( ! function_exists( 'storefront_homepage_content' ) ) {
/**
* Display homepage content
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @return void
*/
function storefront_homepage_content() {
while ( have_posts() ) {
the_post();
get_template_part( 'content', 'page' );
} // end of the loop.
}
}
if ( ! function_exists( 'storefront_social_icons' ) ) {
/**
* Display social icons
* If the subscribe and connect plugin is active, display the icons.
*
* @link http://wordpress.org/plugins/subscribe-and-connect/
* @since 1.0.0
*/
function storefront_social_icons() {
if ( class_exists( 'Subscribe_And_Connect' ) ) {
echo '<div class="subscribe-and-connect-connect">';
subscribe_and_connect_connect();
echo '</div>';
}
}
}
if ( ! function_exists( 'storefront_get_sidebar' ) ) {
/**
* Display storefront sidebar
*
* @uses get_sidebar()
* @since 1.0.0
*/
function storefront_get_sidebar() {
get_sidebar();
}
}
if ( ! function_exists( 'storefront_post_thumbnail' ) ) {
/**
* Display post thumbnail
*
* @var $size thumbnail size. thumbnail|medium|large|full|$custom
* @uses has_post_thumbnail()
* @uses the_post_thumbnail
* @param string $size the post thumbnail size.
* @since 1.5.0
*/
function storefront_post_thumbnail( $size ) {
if ( has_post_thumbnail() ) {
the_post_thumbnail( $size );
}
}
}
if ( ! function_exists( 'storefront_primary_navigation_wrapper' ) ) {
/**
* The primary navigation wrapper
*/
function storefront_primary_navigation_wrapper() {
echo '<section class="storefront-primary-navigation">';
}
}
if ( ! function_exists( 'storefront_primary_navigation_wrapper_close' ) ) {
/**
* The primary navigation wrapper close
*/
function storefront_primary_navigation_wrapper_close() {
echo '</section>';
}
}
if ( ! function_exists( 'storefront_init_structured_data' ) ) {
/**
* Generate the structured data...
* Initialize Storefront::$structured_data via Storefront::set_structured_data()...
* Hooked into:
* `storefront_loop_post`
* `storefront_single_post`
* `storefront_page`
* Apply `storefront_structured_data` filter hook for structured data customization :)
*/
function storefront_init_structured_data() {
if ( is_home() || is_category() || is_date() || is_search() || is_single() && ( is_woocommerce_activated() && ! is_woocommerce() ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'normal' );
$logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
$json['@type'] = 'BlogPosting';
$json['mainEntityOfPage'] = array(
'@type' => 'webpage',
'@id' => get_the_permalink(),
);
$json['image'] = array(
'@type' => 'ImageObject',
'url' => $image[0],
'width' => $image[1],
'height' => $image[2],
);
$json['publisher'] = array(
'@type' => 'organization',
'name' => get_bloginfo( 'name' ),
'logo' => array(
'@type' => 'ImageObject',
'url' => $logo[0],
'width' => $logo[1],
'height' => $logo[2],
),
);
$json['author'] = array(
'@type' => 'person',
'name' => get_the_author(),
);
$json['datePublished'] = get_post_time( 'c' );
$json['dateModified'] = get_the_modified_date( 'c' );
$json['name'] = get_the_title();
$json['headline'] = get_the_title();
$json['description'] = get_the_excerpt();
} elseif ( is_page() ) {
$json['@type'] = 'WebPage';
$json['url'] = get_the_permalink();
$json['name'] = get_the_title();
$json['description'] = get_the_excerpt();
}
if ( isset( $json ) ) {
Storefront::set_structured_data( apply_filters( 'storefront_structured_data', $json ) );
}
}
}