forked from starverte/flint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat-gallery.php
87 lines (77 loc) · 3.26 KB
/
format-gallery.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
<?php
/**
* Gallery Post Format Template
*
* The template for displaying the post content for gallery posts
*
* @package Flint
* @since 1.0.1
*/
?>
<div class="row">
<?php echo flint_post_margin( true ); ?>
<article id="post-<?php the_ID(); ?>" <?php flint_post_class(); ?>>
<header class="entry-header">
<h2 class="entry-title"><?php
if ( is_single() ) {
echo the_title();
} else {
echo '<a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a>';
} ?></h2>
<?php edit_post_link( __( 'Edit Gallery', 'flint' ), '', '', 0, 'btn btn-default btn-sm btn-edit hidden-xs' ); ?>
<?php if ( ! is_single() ) { ?><a class="btn btn-info btn-block visible-xs-block" href="<?php echo get_permalink(); ?>">View gallery</a><?php } ?>
<div class="entry-meta">
<?php do_action( 'flint_entry_meta_above_post' ); ?>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<?php if ( is_search() ) : ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content"><?php
if ( is_single() ) {
flint_the_content();
} else {
$pattern = get_shortcode_regex();
preg_match( "/$pattern/s", get_the_content(), $match );
$atts = isset( $match[3] ) ? shortcode_parse_atts( $match[3] ) : array();
$images = isset( $atts['ids'] ) ? explode( ',', $atts['ids'] ) : false;
if ( ! $images ) {
$images = get_posts( array(
'post_parent' => get_the_ID(),
'fields' => 'ids',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => 12,
'suppress_filters' => false,
) );
}
if ( $images ) {
$total_images = count( $images );
$image = array_shift( $images ); ?>
<p><a class="gallery-thumb hidden-xs" href="<?php the_permalink(); ?>"><?php echo wp_get_attachment_image( $image, 'large' ); ?></a></p>
<p class="gallery-info"><?php
printf(
_n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'flint' ),
'href="' . get_permalink() . '" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'flint' ), the_title_attribute( 'echo=0' ) ) ) . '" rel="bookmark"',
number_format_i18n( $total_images )
);
?></p><?php
the_excerpt();
}
}
flint_link_pages( array(
'before' => '<ul class="pagination">',
'after' => '</ul>',
) );
?></div><!-- .entry-content -->
<?php endif; ?>
<footer class="entry-meta clearfix">
<?php do_action( 'flint_entry_meta_below_post' ); ?>
</footer><!-- .entry-meta -->
</article><!-- #page-<?php the_ID(); ?> -->
<?php echo flint_post_margin(); ?>
</div><!-- .row -->