|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if ( !class_exists( 'FooGallery_Image_Viewer_Gallery_Template' ) ) { |
|
4
|
|
|
|
|
5
|
|
|
define('FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ )); |
|
6
|
|
|
|
|
7
|
|
|
class FooGallery_Image_Viewer_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
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Register myself so that all associated JS and CSS files can be found and automatically included |
|
19
|
|
|
* @param $extensions |
|
20
|
|
|
* |
|
21
|
|
|
* @return array |
|
22
|
|
|
*/ |
|
23
|
|
|
function register_myself( $extensions ) { |
|
|
|
|
|
|
24
|
|
|
$extensions[] = __FILE__; |
|
25
|
|
|
return $extensions; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Add our gallery template to the list of templates available for every gallery |
|
30
|
|
|
* @param $gallery_templates |
|
31
|
|
|
* |
|
32
|
|
|
* @return array |
|
33
|
|
|
*/ |
|
34
|
|
|
function add_template( $gallery_templates ) { |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
$gallery_templates[] = array( |
|
37
|
|
|
'slug' => 'image-viewer', |
|
38
|
|
|
'name' => __( 'Image Viewer', 'foogallery-image-viewer'), |
|
39
|
|
|
'preview_css' => FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL . 'css/gallery-image-viewer.css', |
|
40
|
|
|
'admin_js' => FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL . 'js/admin-gallery-image-viewer.js', |
|
41
|
|
|
'fields' => array( |
|
42
|
|
|
array( |
|
43
|
|
|
'id' => 'alignment', |
|
44
|
|
|
'title' => __( 'Alignment', 'foogallery' ), |
|
45
|
|
|
'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ), |
|
46
|
|
|
'default' => 'alignment-center', |
|
47
|
|
|
'type' => 'select', |
|
48
|
|
|
'choices' => array( |
|
49
|
|
|
'alignment-left' => __( 'Left', 'foogallery' ), |
|
50
|
|
|
'alignment-center' => __( 'Center', 'foogallery' ), |
|
51
|
|
|
'alignment-right' => __( 'Right', 'foogallery' ), |
|
52
|
|
|
) |
|
53
|
|
|
), |
|
54
|
|
|
array( |
|
55
|
|
|
'id' => 'lightbox', |
|
56
|
|
|
'title' => __('Lightbox', 'foogallery-image-viewer'), |
|
57
|
|
|
'desc' => __('Choose which lightbox you want to use in the gallery.', 'foogallery-image-viewer'), |
|
58
|
|
|
'type' => 'lightbox' |
|
59
|
|
|
), |
|
60
|
|
|
array( |
|
61
|
|
|
'id' => 'theme', |
|
62
|
|
|
'title' => __('Theme', 'foogallery'), |
|
63
|
|
|
'default' => '', |
|
64
|
|
|
'type' => 'radio', |
|
65
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
66
|
|
|
'choices' => array( |
|
67
|
|
|
'' => __( 'Light', 'foogallery' ), |
|
68
|
|
|
'fiv-dark' => __( 'Dark', 'foogallery' ), |
|
69
|
|
|
'fiv-custom' => __( 'Custom', 'foogallery' ) |
|
70
|
|
|
) |
|
71
|
|
|
), |
|
72
|
|
|
array( |
|
73
|
|
|
'id' => 'theme_custom_bgcolor', |
|
74
|
|
|
'title' => __('Background Color', 'foogallery'), |
|
75
|
|
|
'section' => __( 'Custom Theme Colors', 'foogallery' ), |
|
76
|
|
|
'type' => 'colorpicker', |
|
77
|
|
|
'default' => '#FFFFFF', |
|
78
|
|
|
'opacity' => true |
|
79
|
|
|
), |
|
80
|
|
|
array( |
|
81
|
|
|
'id' => 'theme_custom_textcolor', |
|
82
|
|
|
'title' => __('Text Color', 'foogallery'), |
|
83
|
|
|
'section' => __( 'Custom Theme Colors', 'foogallery' ), |
|
84
|
|
|
'type' => 'colorpicker', |
|
85
|
|
|
'default' => '#1b1b1b', |
|
86
|
|
|
'opacity' => true |
|
87
|
|
|
), |
|
88
|
|
|
array( |
|
89
|
|
|
'id' => 'theme_custom_hovercolor', |
|
90
|
|
|
'title' => __('Hover BG Color', 'foogallery'), |
|
91
|
|
|
'section' => __( 'Custom Theme Colors', 'foogallery' ), |
|
92
|
|
|
'type' => 'colorpicker', |
|
93
|
|
|
'default' => '#F2F2F2', |
|
94
|
|
|
'opacity' => true |
|
95
|
|
|
), |
|
96
|
|
|
array( |
|
97
|
|
|
'id' => 'theme_custom_bordercolor', |
|
98
|
|
|
'title' => __('Border Color', 'foogallery'), |
|
99
|
|
|
'section' => __( 'Custom Theme Colors', 'foogallery' ), |
|
100
|
|
|
'type' => 'colorpicker', |
|
101
|
|
|
'default' => '#e6e6e6', |
|
102
|
|
|
'opacity' => true |
|
103
|
|
|
), |
|
104
|
|
|
array( |
|
105
|
|
|
'id' => 'thumbnail_size', |
|
106
|
|
|
'title' => __('Thumbnail Size', 'foogallery-image-viewer'), |
|
107
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
108
|
|
|
'desc' => __('Choose the size of your thumbs.', 'foogallery-image-viewer'), |
|
109
|
|
|
'type' => 'thumb_size', |
|
110
|
|
|
'default' => array( |
|
111
|
|
|
'width' => 640, |
|
112
|
|
|
'height' => 360, |
|
113
|
|
|
'crop' => true |
|
114
|
|
|
) |
|
115
|
|
|
), |
|
116
|
|
|
array( |
|
117
|
|
|
'id' => 'thumbnail_link', |
|
118
|
|
|
'title' => __('Thumbnail Link', 'foogallery-image-viewer'), |
|
119
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
120
|
|
|
'default' => 'image' , |
|
121
|
|
|
'type' => 'thumb_link', |
|
122
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
123
|
|
|
'desc' => __('You can choose to either link each thumbnail to the full size image or to the image\'s attachment page.', 'foogallery-image-viewer') |
|
124
|
|
|
), |
|
125
|
|
|
array( |
|
126
|
|
|
'id' => 'hover-effect-type', |
|
127
|
|
|
'title' => __( 'Hover Effect Type', 'foogallery' ), |
|
128
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
129
|
|
|
'default' => '', |
|
130
|
|
|
'type' => 'radio', |
|
131
|
|
|
'choices' => apply_filters( 'foogallery_gallery_template_hover-effect-types', array( |
|
132
|
|
|
'' => __( 'Icon', 'foogallery' ), |
|
133
|
|
|
'hover-effect-tint' => __( 'Dark Tint', 'foogallery' ), |
|
134
|
|
|
'hover-effect-color' => __( 'Colorize', 'foogallery' ), |
|
135
|
|
|
'hover-effect-none' => __( 'None', 'foogallery' ) |
|
136
|
|
|
) ), |
|
137
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
138
|
|
|
'desc' => __( 'The type of hover effect the thumbnails will use.', 'foogallery' ) |
|
139
|
|
|
), |
|
140
|
|
|
array( |
|
141
|
|
|
'id' => 'hover-effect', |
|
142
|
|
|
'title' => __( 'Icon Hover Effect', 'foogallery' ), |
|
143
|
|
|
'desc' => __( 'When the hover effect type of Icon is chosen, you can choose which icon is shown when you hover over each thumbnail.', 'foogallery' ), |
|
144
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
145
|
|
|
'type' => 'icon', |
|
146
|
|
|
'default' => 'hover-effect-zoom', |
|
147
|
|
|
'choices' => array( |
|
148
|
|
|
'hover-effect-zoom' => array( 'label' => __( 'Zoom' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom.png' ), |
|
149
|
|
|
'hover-effect-zoom2' => array( 'label' => __( 'Zoom 2' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom2.png' ), |
|
150
|
|
|
'hover-effect-zoom3' => array( 'label' => __( 'Zoom 3' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom3.png' ), |
|
151
|
|
|
'hover-effect-plus' => array( 'label' => __( 'Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-plus.png' ), |
|
152
|
|
|
'hover-effect-circle-plus' => array( 'label' => __( 'Circle Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-circle-plus.png' ), |
|
153
|
|
|
'hover-effect-eye' => array( 'label' => __( 'Eye' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-eye.png' ) |
|
154
|
|
|
), |
|
155
|
|
|
), |
|
156
|
|
|
array( |
|
157
|
|
|
'id' => 'caption-content', |
|
158
|
|
|
'title' => __( 'Caption Content', 'foogallery' ), |
|
159
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
160
|
|
|
'default' => 'title', |
|
161
|
|
|
'type' => 'radio', |
|
162
|
|
|
'choices' => apply_filters( 'foogallery_gallery_template_caption-content', array( |
|
163
|
|
|
'none' => __( 'None', 'foogallery' ), |
|
164
|
|
|
'title' => __( 'Title Only', 'foogallery' ), |
|
165
|
|
|
'desc' => __( 'Description Only', 'foogallery' ), |
|
166
|
|
|
'both' => __( 'Title and Description', 'foogallery' ) |
|
167
|
|
|
) ), |
|
168
|
|
|
'spacer' => '<span class="spacer"></span>' |
|
169
|
|
|
), |
|
170
|
|
|
array( |
|
171
|
|
|
'id' => 'thumb_preview', |
|
172
|
|
|
'title' => __( 'Preview', 'foogallery' ), |
|
173
|
|
|
'desc' => __( 'This is what your gallery will look like.', 'foogallery' ), |
|
174
|
|
|
'section' => __( 'Thumbnail Settings', 'foogallery' ), |
|
175
|
|
|
'type' => 'image_viewer_preview', |
|
176
|
|
|
) |
|
177
|
|
|
) |
|
178
|
|
|
); |
|
179
|
|
|
|
|
180
|
|
|
return $gallery_templates; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
function render_thumbnail_preview( $field, $gallery, $template ) { |
|
|
|
|
|
|
184
|
|
|
if ( 'image_viewer_preview' == $field['type'] ) { |
|
185
|
|
|
$args = $gallery->get_meta( 'thumbnail_size', array( |
|
186
|
|
|
'width' => 640, |
|
187
|
|
|
'height' => 360, |
|
188
|
|
|
'crop' => true |
|
189
|
|
|
) ); |
|
190
|
|
|
//override the link so that it does not actually open an image |
|
191
|
|
|
$args['link'] = 'custom'; |
|
192
|
|
|
$args['custom_link'] = '#preview'; |
|
193
|
|
|
$args['link_attributes'] = array( |
|
194
|
|
|
'class' => 'fiv-active' |
|
195
|
|
|
); |
|
196
|
|
|
|
|
197
|
|
|
$hover_effect = $gallery->get_meta( 'image-viewer_hover-effect', 'hover-effect-zoom' ); |
|
198
|
|
|
$hover_effect_type = $gallery->get_meta( 'image-viewer_hover-effect-type', '' ); |
|
199
|
|
|
|
|
200
|
|
|
$featured = $gallery->featured_attachment(); |
|
201
|
|
|
|
|
202
|
|
|
if ( false === $featured ) { |
|
203
|
|
|
$featured = new FooGalleryAttachment(); |
|
204
|
|
|
$featured->url = FOOGALLERY_URL . 'assets/test_thumb_1.jpg'; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
?><div class="foogallery-image-viewer-preview <?php echo foogallery_build_class_attribute( $gallery, $hover_effect, $hover_effect_type ); ?>"> |
|
208
|
|
|
<div class="fiv-inner"> |
|
209
|
|
|
<div class="fiv-inner-container"> |
|
210
|
|
|
<?php |
|
211
|
|
|
echo $featured->html( $args, true, false ); |
|
212
|
|
|
echo $featured->html_caption( 'both' ); |
|
213
|
|
|
echo '</a>'; |
|
214
|
|
|
?> |
|
215
|
|
|
</div> |
|
216
|
|
|
<div class="fiv-ctrls"> |
|
217
|
|
|
<div class="fiv-prev"><span><?php echo __('Prev') ?></span></div> |
|
218
|
|
|
<label class="fiv-count"><span class="fiv-count-current">1</span><?php echo __('of') ?><span>1</span></label> |
|
219
|
|
|
<div class="fiv-next"><span><?php echo __('Next') ?></span></div> |
|
220
|
|
|
</div> |
|
221
|
|
|
</div> |
|
222
|
|
|
</div><?php |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
} |
|
226
|
|
|
} |
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.