-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatured-images.php
More file actions
146 lines (135 loc) · 4.49 KB
/
featured-images.php
File metadata and controls
146 lines (135 loc) · 4.49 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
<?php
/**
* Template Name: Post
* Template Post Type: Featured Image
* Description: .
* @package
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'creativity_post_image' ) ) {
add_action( 'creativity_after_entry_header', 'creativity_post_image' );
/**
* Prints the Post Image to post excerpts
*/
function creativity_post_image() {
// If there's no featured image, return.
if ( ! has_post_thumbnail() ) {
return;
}
// If we're not on any single post/page or the 404 template, we must be showing excerpts.
if ( ! is_singular() && ! is_404() ) {
echo '<div class="post-image">
<a href="' . esc_url( get_permalink() ) . '">
' . get_the_post_thumbnail(
get_the_ID(),
apply_filters( 'creativity_pageheader_default_size', 'full' ),
array(
'itemprop' => 'image',
)
) . '
</a>
</div>';
}
}
}
if ( ! function_exists( 'creativity_featured_page_header_area' ) ) {
/**
* Build the page header.
*
*
* @param string The featured image container class
*/
function creativity_featured_page_header_area( $class ) {
// Don't run the function unless we're on a page it applies to.
if ( ! is_singular() ) {
return;
}
// Don't run the function unless we have a post thumbnail.
if ( ! has_post_thumbnail() ) {
return;
}
?>
<div class="<?php echo esc_attr( $class ); ?> grid-parent">
<?php the_post_thumbnail(
apply_filters( 'creativity_pageheader_default_size', 'full' ),
array(
'itemprop' => 'image',
)
); ?>
</div>
<?php
}
}
if ( ! function_exists( 'creativity_featured_page_header' ) ) {
add_action( 'creativity_after_header', 'creativity_featured_page_header', 10 );
/**
* Add page header above content.
*
*/
function creativity_featured_page_header() {
if ( function_exists( 'creativity_pageheader' ) ) {
return;
}
if ( is_page() ) {
creativity_featured_page_header_area( 'page-header-image' );
}
}
}
if ( ! function_exists( 'creativity_blog_header_image' ) ) {
add_action( 'creativity_after_header', 'creativity_blog_header_image', 11 );
/**
* Add blog header above content.
*
*/
function creativity_blog_header_image() {
if ( ( is_front_page() && is_home() ) || ( is_home() ) ) {
$blog_header_image = creativity_get_setting( 'blog_header_image' );
$blog_header_title = creativity_get_setting( 'blog_header_title' );
$blog_header_text = creativity_get_setting( 'blog_header_text' );
$blog_header_button_text = creativity_get_setting( 'blog_header_button_text' );
$blog_header_button_url = creativity_get_setting( 'blog_header_button_url' );
if ( $blog_header_image != '' ) { ?>
<div class="page-header-image grid-parent page-header-blog" style="background-image: url(<?php echo esc_url($blog_header_image); ?>)">
<div class="page-header-blog-inner">
<div class="page-header-blog-content-h grid-container">
<div class="page-header-blog-content">
<?php if ( ( $blog_header_title != '' ) || ( $blog_header_title != '' ) ) { ?>
<?php if ( $blog_header_title != '' ) { ?>
<h2><?php echo wp_kses_post( $blog_header_title ); ?></h2>
<div class="clearfix"></div>
<?php } ?>
<?php if ( $blog_header_title != '' ) { ?>
<p><?php echo wp_kses_post( $blog_header_text ); ?></p>
<div class="clearfix"></div>
<?php } ?>
<?php if ( $blog_header_button_text != '' ) { ?>
<a class="read-more button" href="<?php echo esc_url( $blog_header_button_url ); ?>"><?php echo esc_html( $blog_header_button_text ); ?></a>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
</div>
<?php
}
}
}
}
if ( ! function_exists( 'creativity_featured_page_header_inside_single' ) ) {
add_action( 'creativity_before_content', 'creativity_featured_page_header_inside_single', 10 );
/**
* Add post header inside content.
* Only add to single post.
*
*/
function creativity_featured_page_header_inside_single() {
if ( function_exists( 'creativity_pageheader' ) ) {
return;
}
if ( is_single() ) {
creativity_featured_page_header_area( 'page-header-image-single' );
}
}
}