|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if ( !class_exists( 'FooGallery_Default_Gallery_Template' ) ) { |
|
4
|
|
|
|
|
5
|
|
|
define('FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ )); |
|
6
|
|
|
|
|
7
|
|
|
class FooGallery_Default_Gallery_Template { |
|
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Wire up everything we need to run the extension |
|
10
|
|
|
*/ |
|
11
|
|
|
function __construct() { |
|
|
|
|
|
|
12
|
|
|
add_filter( 'foogallery_gallery_templates', array( $this, 'add_template' ) ); |
|
13
|
|
|
add_filter( 'foogallery_gallery_templates_files', array( $this, 'register_myself' ) ); |
|
14
|
|
|
add_action( 'foogallery_render_gallery_template_field_custom', array( $this, 'render_thumbnail_preview' ), 10, 3 ); |
|
15
|
|
|
add_filter( 'foogallery_located_template-default', array( $this, 'enqueue_dependencies' ) ); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Register myself so that all associated JS and CSS files can be found and automatically included |
|
20
|
|
|
* @param $extensions |
|
21
|
|
|
* |
|
22
|
|
|
* @return array |
|
23
|
|
|
*/ |
|
24
|
|
|
function register_myself( $extensions ) { |
|
|
|
|
|
|
25
|
|
|
$extensions[] = __FILE__; |
|
26
|
|
|
return $extensions; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Add our gallery template to the list of templates available for every gallery |
|
31
|
|
|
* @param $gallery_templates |
|
32
|
|
|
* |
|
33
|
|
|
* @return array |
|
34
|
|
|
*/ |
|
35
|
|
|
function add_template( $gallery_templates ) { |
|
|
|
|
|
|
36
|
|
|
$gallery_templates[] = array( |
|
37
|
|
|
'slug' => 'default', |
|
38
|
|
|
'name' => __( 'Responsive Image Gallery', 'foogallery' ), |
|
39
|
|
|
'preview_css' => FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL . 'css/gallery-default.css', |
|
40
|
|
|
'admin_js' => FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL . 'js/admin-gallery-default.js', |
|
41
|
|
|
'fields' => array( |
|
42
|
|
|
array( |
|
43
|
|
|
'id' => 'lightbox', |
|
44
|
|
|
'title' => __( 'Lightbox', 'foogallery' ), |
|
45
|
|
|
'desc' => __( 'Choose which lightbox you want to use. The lightbox will only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), |
|
46
|
|
|
'type' => 'lightbox', |
|
47
|
|
|
), |
|
48
|
|
|
array( |
|
49
|
|
|
'id' => 'spacing', |
|
50
|
|
|
'title' => __( 'Spacing', 'foogallery' ), |
|
51
|
|
|
'desc' => __( 'The spacing or gap between thumbnails in the gallery.', 'foogallery' ), |
|
52
|
|
|
'type' => 'select', |
|
53
|
|
|
'default' => 'spacing-width-10', |
|
54
|
|
|
'choices' => array( |
|
55
|
|
|
'spacing-width-0' => __( '0 pixels', 'foogallery' ), |
|
56
|
|
|
'spacing-width-5' => __( '5 pixels', 'foogallery' ), |
|
57
|
|
|
'spacing-width-10' => __( '10 pixels', 'foogallery' ), |
|
58
|
|
|
'spacing-width-15' => __( '15 pixels', 'foogallery' ), |
|
59
|
|
|
'spacing-width-20' => __( '20 pixels', 'foogallery' ), |
|
60
|
|
|
'spacing-width-25' => __( '25 pixels', 'foogallery' ), |
|
61
|
|
|
), |
|
62
|
|
|
), |
|
63
|
|
|
array( |
|
64
|
|
|
'id' => 'alignment', |
|
65
|
|
|
'title' => __( 'Alignment', 'foogallery' ), |
|
66
|
|
|
'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ), |
|
67
|
|
|
'default' => 'alignment-center', |
|
68
|
|
|
'type' => 'select', |
|
69
|
|
|
'choices' => array( |
|
70
|
|
|
'alignment-left' => __( 'Left', 'foogallery' ), |
|
71
|
|
|
'alignment-center' => __( 'Center', 'foogallery' ), |
|
72
|
|
|
'alignment-right' => __( 'Right', 'foogallery' ), |
|
73
|
|
|
) |
|
74
|
|
|
), |
|
75
|
|
|
array( |
|
76
|
|
|
'id' => 'thumbnail_dimensions', |
|
77
|
|
|
'title' => __( 'Size', 'foogallery' ), |
|
78
|
|
|
'desc' => __( 'Choose the size of your thumbnails.', 'foogallery' ), |
|
79
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
80
|
|
|
'type' => 'thumb_size', |
|
81
|
|
|
'default' => array( |
|
82
|
|
|
'width' => get_option( 'thumbnail_size_w' ), |
|
83
|
|
|
'height' => get_option( 'thumbnail_size_h' ), |
|
84
|
|
|
'crop' => true, |
|
85
|
|
|
), |
|
86
|
|
|
), |
|
87
|
|
|
array( |
|
88
|
|
|
'id' => 'thumbnail_link', |
|
89
|
|
|
'title' => __( 'Link', 'foogallery' ), |
|
90
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
91
|
|
|
'default' => 'image', |
|
92
|
|
|
'type' => 'thumb_link', |
|
93
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
94
|
|
|
'desc' => __( 'You can choose to link each thumbnail to the full size image, the image\'s attachment page, a custom URL, or you can choose to not link to anything.', 'foogallery' ), |
|
95
|
|
|
), |
|
96
|
|
|
array( |
|
97
|
|
|
'id' => 'border-style', |
|
98
|
|
|
'title' => __( 'Border Style', 'foogallery' ), |
|
99
|
|
|
'desc' => __( 'The border style for each thumbnail in the gallery.', 'foogallery' ), |
|
100
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
101
|
|
|
'type' => 'icon', |
|
102
|
|
|
'default' => 'border-style-square-white', |
|
103
|
|
|
'choices' => array( |
|
104
|
|
|
'border-style-square-white' => array( 'label' => __( 'Square white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-white.png' ), |
|
105
|
|
|
'border-style-circle-white' => array( 'label' => __( 'Circular white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-white.png' ), |
|
106
|
|
|
'border-style-square-black' => array( 'label' => __( 'Square Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-black.png' ), |
|
107
|
|
|
'border-style-circle-black' => array( 'label' => __( 'Circular Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-black.png' ), |
|
108
|
|
|
'border-style-inset' => array( 'label' => __( 'Square Inset' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-inset.png' ), |
|
109
|
|
|
'border-style-rounded' => array( 'label' => __( 'Plain Rounded' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-plain-rounded.png' ), |
|
110
|
|
|
'' => array( 'label' => __( 'Plain' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-none.png' ), |
|
111
|
|
|
) |
|
112
|
|
|
), |
|
113
|
|
|
array( |
|
114
|
|
|
'id' => 'hover-effect-type', |
|
115
|
|
|
'title' => __( 'Hover Effect Type', 'foogallery' ), |
|
116
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
117
|
|
|
'default' => '', |
|
118
|
|
|
'type' => 'radio', |
|
119
|
|
|
'choices' => apply_filters( 'foogallery_gallery_template_hover-effect-types', array( |
|
120
|
|
|
'' => __( 'Icon', 'foogallery' ), |
|
121
|
|
|
'hover-effect-tint' => __( 'Dark Tint', 'foogallery' ), |
|
122
|
|
|
'hover-effect-color' => __( 'Colorize', 'foogallery' ), |
|
123
|
|
|
'hover-effect-caption' => __( 'Caption', 'foogallery' ), |
|
124
|
|
|
'hover-effect-none' => __( 'None', 'foogallery' ) |
|
125
|
|
|
) ), |
|
126
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
127
|
|
|
'desc' => __( 'The type of hover effect the thumbnails will use.', 'foogallery' ), |
|
128
|
|
|
), |
|
129
|
|
|
array( |
|
130
|
|
|
'id' => 'hover-effect', |
|
131
|
|
|
'title' => __( 'Icon Hover Effect', 'foogallery' ), |
|
132
|
|
|
'desc' => __( 'When the hover effect type of Icon is chosen, you can choose which icon is shown when you hover over each thumbnail.', 'foogallery' ), |
|
133
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
134
|
|
|
'type' => 'icon', |
|
135
|
|
|
'default' => 'hover-effect-zoom', |
|
136
|
|
|
'choices' => array( |
|
137
|
|
|
'hover-effect-zoom' => array( 'label' => __( 'Zoom' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom.png' ), |
|
138
|
|
|
'hover-effect-zoom2' => array( 'label' => __( 'Zoom 2' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom2.png' ), |
|
139
|
|
|
'hover-effect-zoom3' => array( 'label' => __( 'Zoom 3' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom3.png' ), |
|
140
|
|
|
'hover-effect-plus' => array( 'label' => __( 'Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-plus.png' ), |
|
141
|
|
|
'hover-effect-circle-plus' => array( 'label' => __( 'Cirlce Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-circle-plus.png' ), |
|
142
|
|
|
'hover-effect-eye' => array( 'label' => __( 'Eye' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-eye.png' ) |
|
143
|
|
|
), |
|
144
|
|
|
), |
|
145
|
|
|
array( |
|
146
|
|
|
'id' => 'caption-hover-effect', |
|
147
|
|
|
'title' => __( 'Caption Effect', 'foogallery' ), |
|
148
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
149
|
|
|
'default' => 'hover-caption-simple', |
|
150
|
|
|
'type' => 'radio', |
|
151
|
|
|
'choices' => apply_filters( 'foogallery_gallery_template_caption-hover-effects', array( |
|
152
|
|
|
'hover-caption-simple' => __( 'Simple', 'foogallery' ), |
|
153
|
|
|
'hover-caption-full-drop' => __( 'Drop', 'foogallery' ), |
|
154
|
|
|
'hover-caption-full-fade' => __( 'Fade In', 'foogallery' ), |
|
155
|
|
|
'hover-caption-push' => __( 'Push', 'foogallery' ), |
|
156
|
|
|
'hover-caption-simple-always' => __( 'Always Visible', 'foogallery' ) |
|
157
|
|
|
) ), |
|
158
|
|
|
'spacer' => '<span class="spacer"></span>' |
|
159
|
|
|
), |
|
160
|
|
|
array( |
|
161
|
|
|
'id' => 'caption-content', |
|
162
|
|
|
'title' => __( 'Caption Content', 'foogallery' ), |
|
163
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
164
|
|
|
'default' => 'title', |
|
165
|
|
|
'type' => 'radio', |
|
166
|
|
|
'choices' => apply_filters( 'foogallery_gallery_template_caption-content', array( |
|
167
|
|
|
'title' => __( 'Title Only', 'foogallery' ), |
|
168
|
|
|
'desc' => __( 'Description Only', 'foogallery' ), |
|
169
|
|
|
'both' => __( 'Title and Description', 'foogallery' ) |
|
170
|
|
|
) ), |
|
171
|
|
|
'spacer' => '<span class="spacer"></span>' |
|
172
|
|
|
), |
|
173
|
|
|
array( |
|
174
|
|
|
'id' => 'thumb_preview', |
|
175
|
|
|
'title' => __( 'Preview', 'foogallery' ), |
|
176
|
|
|
'desc' => __( 'This is what your gallery thumbnails will look like.', 'foogallery' ), |
|
177
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
178
|
|
|
'type' => 'default_thumb_preview', |
|
179
|
|
|
) |
|
180
|
|
|
) |
|
181
|
|
|
); |
|
182
|
|
|
|
|
183
|
|
|
return $gallery_templates; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* Renders the thumbnail preview field |
|
188
|
|
|
* |
|
189
|
|
|
* @param $field array |
|
190
|
|
|
* @param $gallery FooGallery |
|
191
|
|
|
* @param $template array |
|
192
|
|
|
*/ |
|
193
|
|
|
function render_thumbnail_preview( $field, $gallery, $template ) { |
|
|
|
|
|
|
194
|
|
|
if ( 'default_thumb_preview' == $field['type'] ) { |
|
195
|
|
|
$args = $gallery->get_meta( 'default_thumbnail_dimensions', array( |
|
196
|
|
|
'width' => get_option( 'thumbnail_size_w' ), |
|
197
|
|
|
'height' => get_option( 'thumbnail_size_h' ), |
|
198
|
|
|
'crop' => true |
|
199
|
|
|
) ); |
|
200
|
|
|
|
|
201
|
|
|
//override the link so that it does not actually open an image |
|
202
|
|
|
$args['link'] = 'custom'; |
|
203
|
|
|
$args['custom_link'] = '#preview'; |
|
204
|
|
|
|
|
205
|
|
|
$hover_effect = $gallery->get_meta( 'default_hover-effect', 'hover-effect-zoom' ); |
|
206
|
|
|
$border_style = $gallery->get_meta( 'default_border-style', 'border-style-square-white' ); |
|
207
|
|
|
$hover_effect_type = $gallery->get_meta( 'default_hover-effect-type', '' ); |
|
208
|
|
|
$caption_hover_effect = $gallery->get_meta( 'default_caption-hover-effect', 'hover-caption-simple' ); |
|
209
|
|
|
|
|
210
|
|
|
$featured = $gallery->featured_attachment(); |
|
211
|
|
|
|
|
212
|
|
|
if ( false === $featured ) { |
|
213
|
|
|
$featured = new FooGalleryAttachment(); |
|
214
|
|
|
$featured->url = FOOGALLERY_URL . 'assets/test_thumb_1.jpg'; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
echo '<div class="foogallery-default-preview ' . foogallery_build_class_attribute( $gallery, $hover_effect, $border_style, $hover_effect_type, $caption_hover_effect, 'foogallery-thumbnail-preview' ) . '">'; |
|
218
|
|
|
echo $featured->html( $args, true, false ); |
|
219
|
|
|
echo $featured->html_caption( 'both' ); |
|
220
|
|
|
echo '</a>'; |
|
221
|
|
|
echo '</div>'; |
|
222
|
|
|
} |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* Enqueue scripts that the default gallery template relies on |
|
227
|
|
|
*/ |
|
228
|
|
|
function enqueue_dependencies() { |
|
|
|
|
|
|
229
|
|
|
wp_enqueue_script( 'jquery' ); |
|
230
|
|
|
foogallery_enqueue_imagesloaded_script(); |
|
231
|
|
|
} |
|
232
|
|
|
} |
|
233
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.