This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attachment.php
95 lines (87 loc) · 2.49 KB
/
attachment.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
<?php
/**
* Attachment Template File
*
* Displays File Attachments
*
* @package Mayflower
*/
get_header(); ?>
<?php
/**
* Load Variables
*/
global $mayflower_brand;
$mayflower_options = mayflower_get_options();
$current_layout = $mayflower_options['default_layout'];
$description = $post->post_content;
$caption = $post->post_excerpt;
?>
<?php if ( has_active_sidebar() ) : ?>
<div class="col-md-9 order-1
<?php
if ( 'sidebar-content' !== $current_layout ) {
?>
order-md-0<?php } ?>">
<?php else : // Full Width Container. ?>
<div class="col-md-12">
<?php endif; ?>
<?php
if ( have_posts() ) :
while ( have_posts() ) :
the_post(); /* Template format for images */
?>
<main role="main">
<?php
/*
* Check if attachment is an image
*/
if ( wp_attachment_is_image( $post->id ) ) :
?>
<h1><?php the_title(); ?></h1>
<div class="wp-block-image">
<figure class="aligncenter">
<a href="<?php echo esc_url( wp_get_attachment_url( $post->id ) ); ?>" rel="attachment">
<?php echo wp_get_attachment_image( get_the_ID(), 'large', false, array( 'class' => 'attachment-large img-fluid' ) ); ?>
</a>
<?php if ( ! empty( $caption ) ) { ?>
<figcaption><?php echo wp_kses_post( $caption ); ?></figcaption>
<?php } ?>
</figure>
</div>
<?php if ( ! empty( $description ) ) { ?>
<hr>
<p><?php echo wp_kses_post( $description ); ?></p>
<?php } ?>
<?php
/*
* If attachment is non-image
*/
else :
?>
<h1>Download File</h1>
<div class="media">
<div class="media-left">
<?php echo wp_get_attachment_image( $post->id, 'thumbnail', true, array( 'class' => 'media-object' ) ); ?>
</div>
<div class="media-body">
<h4 class="media-heading"><a href="<?php echo esc_url( wp_get_attachment_url( $post->ID ) ); ?>"><?php the_title(); ?></a></h4>
<?php if ( ! empty( $description ) ) { ?>
<p><?php echo wp_kses_post( $description ); ?></p>
<?php } ?>
</div>
</div>
<?php endif; ?>
</main><!-- content-padding -->
<?php endwhile; ?>
<?php
wp_reset_query();
endif;
?>
</div>
<?php if ( has_active_sidebar() ) : ?>
<?php
get_sidebar();
endif;
?>
<?php get_footer(); ?>