forked from mfields/Taxonomy-Images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode-snippets.php
184 lines (137 loc) · 5.5 KB
/
code-snippets.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
<?php
/**
* Tests for various filters.
*/
exit;
/*
* Append the term images to content + excerpt.
*/
function mytheme_append_the_term_images( $content ) {
return $content . apply_filters( 'taxonomy-images-list-the-terms', '', array(
'image_size' => 'detail',
) );
}
add_filter( 'the_content', 'mytheme_append_the_term_images' );
add_filter( 'the_excerpt', 'mytheme_append_the_term_images' );
/*
* Queried Term Image.
*
* Return html markup representing the image associated with the
* currently queried term. In the event that no associated image
* exists, the filter should return an empty object.
*
* In the event that the Taxonomy Images plugin is not installed
* apply_filters() will return it's second parameter.
*/
/* Default */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN' );
print '<h2>taxonomy-images-queried-term-image</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';
/* Inside a yellow box */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array(
'before' => '<div style="padding:20px;background-color:yellow;">',
'after' => '</div>',
) );
print '<h2>taxonomy-images-queried-term-image - custom wrapper element.</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';
/* Medium Size */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'medium',
) );
print '<h2>taxonomy-images-queried-term-image - medium image size</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';
/* Unrecognized size */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'this-is-probably-not-a-real-image-size',
) );
print '<h2>taxonomy-images-queried-term-image - unknown image size</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';
/* Custom attributes. */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array(
'attr' => array(
'alt' => 'Custom alternative text',
'class' => 'my-class-list bunnies turtles',
'src' => 'this-is-where-the-image-lives.png',
'title' => 'Custom Title',
),
) );
print '<h2>taxonomy-images-queried-term-image - custom attributes</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';
/*
* Queried Term Image ID.
*
* Return the id of the image associated with the currently
* queried term. In the event that no associated image exists,
* the filter should return zero.
*
* In the event that the Taxonomy Images plugin is not installed
* apply_filters() will return it's second parameter.
*/
$img = apply_filters( 'taxonomy-images-queried-term-image-id', 'PLEASE INSTALL PLUGIN' );
print '<h2>taxonomy-images-queried-term-image-id</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';
/*
* Queried Term Image Object.
*
* Return an object representing the image associated with the
* currently queried term. In the event that no associated image
* exists, the filter should return an empty object.
*
* In the event that the Taxonomy Images plugin is not installed
* apply_filters() will return it's second parameter.
*/
$img = apply_filters( 'taxonomy-images-queried-term-image-object', 'PLEASE INSTALL PLUGIN' );
print '<h2>taxonomy-images-queried-term-image-object</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';
/*
* Queried Term Image URL.
*
* Return a url to the image associated with the current queried
* term. In the event that no associated image exists, the filter
* should return an empty string.
*
* In the event that the Taxonomy Images plugin is not installed
* apply_filters() will return it's second parameter.
*/
/* Default */
$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN' );
print '<h2>taxonomy-images-queried-term-image-url - Default</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';
/* Medium Size */
$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'medium'
) );
print '<h2>taxonomy-images-queried-term-image-url - Medium</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';
/* Unregistered Size */
$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'this-is-not-real-size-probably-I-hope'
) );
print '<h2>taxonomy-images-queried-term-image-url - Unregistered</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';
/*
* Queried Term Image Data.
*
* Return an array of data about the image associated with the current
* queried term. In the event that no associated image exists, the filter
* should return an empty string.
*
* In the event that the Taxonomy Images plugin is not installed
* apply_filters() will return it's second parameter.
*/
/* Default */
$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN' );
print '<h2>taxonomy-images-queried-term-image-data - Default</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';
/* Medium Size */
$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'medium'
) );
print '<h2>taxonomy-images-queried-term-image-data - Medium</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';
/* Unregistered Size */
$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'this-is-not-real-size-probably-I-hope'
) );
print '<h2>taxonomy-images-queried-term-image-data - Unregistered</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';