PluginProbe
Photo Gallery by Re Gallery: Responsive Image Gallery with AI SEO / trunk
Photo Gallery by Re Gallery: Responsive Image Gallery with AI SEO vtrunk
1.20.14 1.20.13 1.20.12 1.20.11 1.20.10 1.20.9 1.20.8 1.20.7 1.20.6 1.20.5 1.20.4 1.20.3 1.20.2 1.20.1 1.20.0 1.19.2 1.19.1 1.19.0 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 All 135 releases
regallery / includes / options.php

options.php in Photo Gallery by Re Gallery: Responsive Image Gallery with AI SEO trunk, at includes/options.php

1,427 lines 58.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') || die('Access Denied');
3
4 class REACG_Options {
5 protected $options = [
6 'title' => 'Default', #string
7 'template_id' => 0, #number
8 'templateType' => "", #string
9 'css' => '', #string
10 'custom_css' => '', #string
11 'type' => 'mosaic', #string thumbnails | mosaic | justified | masonry | slideshow | cube | carousel | coverflow | cards | blog | scroller
12 'thumbnails' => [
13 'fillContainer' => FALSE, #boolean
14 'aspectRatio' => '1.77', #string
15 'width' => 430, #number
16 'height' => 380, #number
17 'columns' => 3, #number
18 'gap' => 10, #number
19 'itemBorder' => 0, #number
20 'itemBackgroundColor' => '', #string
21 'itemBorderRadius' => 0, #number
22 'backgroundColor' => '', #string
23 'containerPadding' => 0, #number
24 'padding' => 0, #number
25 'paddingColor' => '', #string
26 'borderRadius' => 0, #number
27 'paginationType' => 'simple', #string simple | scroll | loadMore | none
28 'showAllItems' => TRUE, #boolean
29 'hoverEffect' => 'zoom-in', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
30 'showTitle' => FALSE, #boolean
31 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
32 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
33 'titlePosition' => 'bottom', #string bottom | top | center | above | below
34 'titleFontSize' => 25, #number
35 'titleColor' => '#DDDDDD', #string
36 'titleAlignment' => 'left', #string left | center | right
37 'titleFontFamily' => 'Inherit', #string
38 'titleMaxRowsCount' => 1, #number
39 'captionMaxRowsCount' => 1, #number
40 'overlayTextBackground' => '', #string
41 'invertTextColor' => FALSE, #boolean
42 'showCaption' => FALSE, #boolean
43 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
44 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
45 'captionPosition' => 'bottom', #string bottom | top | center | above | below
46 'captionFontSize' => 20, #number
47 'captionFontColor' => '#DDDDDD', #string
48 'showDescription' => FALSE, #boolean
49 'descriptionSource' => 'description', #string title | caption | alt | price | description | author | date_created | exif
50 'descriptionPosition' => 'below', #string above | below
51 'descriptionFontSize' => 18, #number
52 'descriptionFontColor' => '#DDDDDD', #string
53 'descriptionMaxRowsCount' => 3, #number
54 'showVideoCover' => TRUE, #boolean
55 'showButton' => FALSE, #boolean
56 'buttonText' => 'View more', #string
57 'openInNewTab' => FALSE, #boolean
58 'buttonAlignment' => 'left', #string left | center | right
59 'buttonFontSize' => 20, #number
60 'buttonColor' => '#afafaf80', #string
61 'buttonTextColor' => '#000000de', #string
62 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
63 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
64 'buttonPosition' => 'bottom', #string bottom | top | center | above | below
65 'buttonBorderSize' => 0, #number
66 'buttonBorderColor' => '#afafaf80', #string
67 'buttonBorderRadius' => 4, #number
68 ],
69 'mosaic' => [
70 'width' => 100, #number
71 'direction' => 'vertical', #string horizontal | vertical
72 'gap' => 5, #number
73 'backgroundColor' => '', #string
74 'containerPadding' => 0, #number
75 'padding' => 0, #number
76 'paddingColor' => '', #string
77 'rowHeight' => 200, #number
78 'columns' => 3, #number
79 'borderRadius' => 0, #number
80 'hoverEffect' => 'overlay', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
81 'showTitle' => FALSE, #boolean
82 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
83 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
84 'titlePosition' => 'bottom', #string bottom | top | center | above | below
85 'titleAlignment' => 'left', #string left | center | right
86 'titleColor' => '#DDDDDD', #string
87 'titleFontSize' => 25, #number
88 'titleFontFamily' => 'Inherit', #string
89 'titleMaxRowsCount' => 1, #number
90 'captionMaxRowsCount' => 1, #number
91 'overlayTextBackground' => '', #string
92 'invertTextColor' => FALSE, #boolean
93 'paginationType' => 'simple', #string simple | none
94 'showAllItems' => TRUE, #boolean
95 'showCaption' => FALSE, #boolean
96 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
97 'captionPosition' => 'bottom', #string bottom | top | center
98 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
99 'captionFontSize' => 20, #number
100 'captionFontColor' => '#DDDDDD', #string
101 'showVideoCover' => TRUE, #boolean
102 'showButton' => FALSE, #boolean
103 'buttonText' => 'View more', #string
104 'openInNewTab' => FALSE, #boolean
105 'buttonAlignment' => 'left', #string left | center | right
106 'buttonFontSize' => 20, #number
107 'buttonColor' => '#afafaf80', #string
108 'buttonTextColor' => '#000000de', #string
109 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
110 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
111 'buttonPosition' => 'bottom', #string bottom | top | center
112 'buttonBorderSize' => 0, #number
113 'buttonBorderColor' => '#afafaf80', #string
114 'buttonBorderRadius' => 4, #number
115 ],
116 'justified' => [
117 'width' => 100, #number
118 'gap' => 2, #number
119 'backgroundColor' => '', #string
120 'containerPadding' => 0, #number
121 'padding' => 0, #number
122 'paddingColor' => '', #string
123 'rowHeight' => 300, #number
124 'borderRadius' => 0, #number
125 'hoverEffect' => 'overlay-icon-zoom', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
126 'showTitle' => FALSE, #boolean
127 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
128 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
129 'titlePosition' => 'bottom', #string bottom | top | center | above | below
130 'titleAlignment' => 'left', #string left | center | right
131 'titleColor' => '#DDDDDD', #string
132 'titleFontSize' => 25, #number
133 'titleFontFamily' => 'Inherit', #string
134 'titleMaxRowsCount' => 1, #number
135 'captionMaxRowsCount' => 1, #number
136 'overlayTextBackground' => '', #string
137 'invertTextColor' => FALSE, #boolean
138 'paginationType' => 'simple', #string simple | none
139 'showAllItems' => TRUE, #boolean
140 'showCaption' => FALSE, #boolean
141 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
142 'captionPosition' => 'bottom', #string bottom | top | center
143 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
144 'captionFontSize' => 20, #number
145 'captionFontColor' => '#DDDDDD', #string
146 'showVideoCover' => TRUE, #boolean
147 'showButton' => FALSE, #boolean
148 'buttonText' => 'View more', #string
149 'openInNewTab' => FALSE, #boolean
150 'buttonAlignment' => 'left', #string left | center | right
151 'buttonFontSize' => 20, #number
152 'buttonColor' => '#afafaf80', #string
153 'buttonTextColor' => '#000000de', #string
154 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
155 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
156 'buttonPosition' => 'bottom', #string bottom | top | center
157 'buttonBorderSize' => 0, #number
158 'buttonBorderColor' => '#afafaf80', #string
159 'buttonBorderRadius' => 4, #number
160 ],
161 'masonry' => [
162 'width' => 100, #number
163 'gap' => 20, #number
164 'backgroundColor' => '', #string
165 'containerPadding' => 0, #number
166 'padding' => 0, #number
167 'paddingColor' => '', #string
168 'columns' => 3, #number
169 'borderRadius' => 0, #number
170 'hoverEffect' => 'shine', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
171 'showTitle' => FALSE, #boolean
172 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
173 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
174 'titlePosition' => 'bottom', #string bottom | top | center | above | below
175 'titleAlignment' => 'left', #string left | center | right
176 'titleColor' => '#DDDDDD', #string
177 'titleFontSize' => 25, #number
178 'titleFontFamily' => 'Inherit', #string
179 'titleMaxRowsCount' => 1, #number
180 'captionMaxRowsCount' => 1, #number
181 'overlayTextBackground' => '', #string
182 'invertTextColor' => FALSE, #boolean
183 'paginationType' => 'scroll', #string scroll | loadMore | none
184 'showAllItems' => TRUE, #boolean
185 'showCaption' => FALSE, #boolean
186 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
187 'captionPosition' => 'bottom', #string bottom | top | center
188 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
189 'captionFontSize' => 20, #number
190 'captionFontColor' => '#DDDDDD', #string
191 'showVideoCover' => TRUE, #boolean
192 'showButton' => FALSE, #boolean
193 'buttonText' => 'View more', #string
194 'openInNewTab' => FALSE, #boolean
195 'buttonAlignment' => 'left', #string left | center | right
196 'buttonFontSize' => 20, #number
197 'buttonColor' => '#afafaf80', #string
198 'buttonTextColor' => '#000000de', #string
199 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
200 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
201 'buttonPosition' => 'bottom', #string bottom | top | center
202 'buttonBorderSize' => 0, #number
203 'buttonBorderColor' => '#afafaf80', #string
204 'buttonBorderRadius' => 4, #number
205 ],
206 'slideshow' => [
207 'width' => 1080, #number
208 'height' => 608, #number
209 'isFullCoverImage' => TRUE, #boolean
210 'isInfinite' => TRUE, #boolean
211 'padding' => 0, #number
212 'autoplay' => FALSE, #boolean
213 'slideDuration' => 5000, #number
214 'imageAnimation' => 'slideH', #string fade | blur | slideH | slideV | zoom | flip | rotate
215 'isSlideshowAllowed' => TRUE, #boolean
216 'canFullscreen' => FALSE, #boolean
217 'showCounter' => FALSE, #boolean
218 'canShare' => FALSE, #boolean
219 'canDownload' => FALSE, #boolean
220 'canZoom' => FALSE, #boolean
221 'thumbnailsPosition' => 'none', #string top | bottom | start | end | none
222 'thumbnailWidth' => 120, #number
223 'thumbnailHeight' => 90, #number
224 'thumbnailBorder' => 0, #number
225 'thumbnailBorderColor' => '', #string
226 'thumbnailBorderRadius' => 0, #number
227 'thumbnailPadding' => 0, #number
228 'thumbnailGap' => 5, #number
229 'backgroundColor' => '#000000', #string
230 'textPosition' => 'bottom', #string top | bottom | above | below
231 'textFontFamily' => 'Inherit', #string
232 'textColor' => '#DDDDDD', #string
233 'textBackground' => '', #string
234 'invertTextColor' => FALSE, #boolean
235 'showTitle' => TRUE, #bool
236 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
237 'titleFontSize' => 1.6, #float
238 'titleAlignment' => 'left', #string
239 'showDescription' => TRUE, #bool
240 'descriptionSource' => 'description', #string title | caption | alt | price | description | author | date_created | exif
241 'descriptionFontSize' => 1.3, #float
242 'descriptionMaxRowsCount' => 1, #number
243 'showCaption' => FALSE, #boolean
244 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
245 'captionFontSize' => 1.5, #float
246 'captionFontColor' => '#DDDDDD', #string
247 'showButton' => FALSE, #boolean
248 'buttonText' => 'View more', #string
249 'openInNewTab' => FALSE, #boolean
250 'buttonAlignment' => 'left', #string left | center | right
251 'buttonFontSize' => 1.3, #float
252 'buttonColor' => '#afafaf80', #string
253 'buttonTextColor' => '#000000de', #string
254 'buttonBorderSize' => 0, #number
255 'buttonBorderColor' => '#afafaf80', #string
256 'buttonBorderRadius' => 4, #number
257 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
258 ],
259 'cube' => [
260 'width' => 300, #number
261 'height' => 300, #number
262 'isInfinite' => TRUE, #boolean
263 'autoplay' => TRUE, #boolean
264 'slideDuration' => 3000, #number
265 'playAndPauseAllowed' => FALSE, #boolean
266 'backgroundColor' => '#FFFFFF', #string;
267 'padding' => 0, #number;
268 'shadow' => TRUE, #boolean
269 'hoverEffect' => 'none', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle |push | none
270 'showTitle' => FALSE, #boolean
271 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
272 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
273 'titlePosition' => 'bottom', #string bottom | top | center | above | below
274 'titleFontSize' => 20, #number
275 'titleColor' => '#DDDDDD', #string
276 'titleAlignment' => 'left', #string left | center | right
277 'titleFontFamily' => 'Inherit', #string
278 'titleMaxRowsCount' => 1, #number
279 'captionMaxRowsCount' => 1, #number
280 'overlayTextBackground' => '', #string
281 'invertTextColor' => FALSE, #boolean
282 'showCaption' => FALSE, #boolean
283 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
284 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
285 'captionPosition' => 'bottom', #string bottom | top | center | above | below
286 'captionFontSize' => 18, #number
287 'captionFontColor' => '#DDDDDD', #string
288 'navigation' => 'none', #string none | arrows | dots | arrowsAndDots
289 'arrowsSize' => 26, #number
290 'arrowsColor' => 'rgba(255, 255, 255, 0.8)',
291 'dotsPosition' => 'outside', #string inside | outside
292 'dotsSize' => 13, #number
293 'dotsGap' => 4, #number
294 'activeDotColor' => '#aaaaaa', #string
295 'inactiveDotsColor' => 'rgba(170, 170, 170, 0.4)', #string
296 'showVideoControls' => false,
297 'animationSpeed' => 500, #number
298 'showVideoCover' => FALSE, #boolean
299 'showButton' => FALSE, #boolean
300 'buttonText' => 'View more', #string
301 'openInNewTab' => FALSE, #boolean
302 'buttonAlignment' => 'left', #string left | center | right
303 'buttonFontSize' => 20, #number
304 'buttonColor' => '#afafaf80', #string
305 'buttonTextColor' => '#000000de', #string
306 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
307 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
308 'buttonPosition' => 'bottom', #string bottom | top | center | above | below
309 'buttonBorderSize' => 0, #number
310 'buttonBorderColor' => '#afafaf80', #string
311 'buttonBorderRadius' => 4, #number
312 ],
313 'carousel' => [
314 'width' => 300, #number
315 'height' => 400, #number
316 'backgroundColor' => '', #string;
317 'padding' => 0, #number
318 'autoplay' => FALSE, #boolean
319 'slideDuration' => 3000, #number
320 'playAndPauseAllowed' => FALSE, #boolean
321 'scale' => 1, #float
322 'imagesCount' => 3, #number
323 'enableScrollByImagesCount' => FALSE, #boolean
324 'spaceBetween' => 20, #number
325 'hoverEffect' => 'none', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
326 'showTitle' => FALSE, #boolean
327 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
328 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
329 'titlePosition' => 'bottom', #string bottom | top | center | above | below
330 'titleFontSize' => 20, #number
331 'titleColor' => '#DDDDDD', #string
332 'titleAlignment' => 'left', #string left | center | right
333 'titleFontFamily' => 'Inherit', #string
334 'titleMaxRowsCount' => 1, #number
335 'captionMaxRowsCount' => 1, #number
336 'overlayTextBackground' => '', #string
337 'invertTextColor' => FALSE, #boolean
338 'showCaption' => FALSE, #boolean
339 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
340 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
341 'captionPosition' => 'bottom', #string bottom | top | center | above | below
342 'captionFontSize' => 18, #number
343 'captionFontColor' => '#DDDDDD', #string
344 'navigation' => 'arrows', #string none | arrows | dots | arrowsAndDots
345 'arrowsSize' => 26, #number
346 'arrowsColor' => 'rgba(255, 255, 255, 0.8)',
347 'dotsPosition' => 'outside', #string inside | outside
348 'dotsSize' => 13, #number
349 'dotsGap' => 4, #number
350 'activeDotColor' => '#aaaaaa', #string
351 'inactiveDotsColor' => 'rgba(170, 170, 170, 0.4)', #string
352 'showVideoControls' => false,
353 'animationSpeed' => 500, #number
354 'showVideoCover' => FALSE, #boolean
355 'showButton' => FALSE, #boolean
356 'buttonText' => 'View more', #string
357 'openInNewTab' => FALSE, #boolean
358 'buttonAlignment' => 'left', #string left | center | right
359 'buttonFontSize' => 20, #number
360 'buttonColor' => '#afafaf80', #string
361 'buttonTextColor' => '#000000de', #string
362 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
363 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
364 'buttonPosition' => 'bottom', #string bottom | top | center | above | below
365 'buttonBorderSize' => 0, #number
366 'buttonBorderColor' => '#afafaf80', #string
367 'buttonBorderRadius' => 4, #number
368 ],
369 'cards' => [
370 'width' => 500, #number
371 'height' => 500, #number
372 'perSlideOffset' => 20, #number
373 'playAndPauseAllowed' => FALSE, #boolean
374 'autoplay' => FALSE, #boolean
375 'slideDuration' => 3000, #number
376 'hoverEffect' => 'none', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
377 'showTitle' => FALSE, #boolean
378 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
379 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
380 'titlePosition' => 'bottom', #string bottom | top | center | above | below
381 'titleFontSize' => 20, #number
382 'titleColor' => '#DDDDDD', #string
383 'titleAlignment' => 'left', #string left | center | right
384 'titleFontFamily' => 'Inherit', #string
385 'titleMaxRowsCount' => 1, #number
386 'captionMaxRowsCount' => 1, #number
387 'overlayTextBackground' => '', #string
388 'invertTextColor' => FALSE, #boolean
389 'showCaption' => FALSE, #boolean
390 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
391 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
392 'captionPosition' => 'bottom', #string bottom | top | center | above | below
393 'captionFontSize' => 18, #number
394 'captionFontColor' => '#DDDDDD', #string
395 'navigation' => 'arrows', #string none | arrows | dots | arrowsAndDots
396 'arrowsSize' => 26, #number
397 'arrowsColor' => 'rgba(255, 255, 255, 0.8)',
398 'dotsPosition' => 'outside', #string inside | outside
399 'dotsSize' => 13, #number
400 'dotsGap' => 4, #number
401 'activeDotColor' => '#aaaaaa', #string
402 'inactiveDotsColor' => 'rgba(170, 170, 170, 0.4)', #string
403 'showVideoControls' => false,
404 'animationSpeed' => 500, #number
405 'showVideoCover' => FALSE, #boolean
406 'showButton' => FALSE, #boolean
407 'buttonText' => 'View more', #string
408 'openInNewTab' => FALSE, #boolean
409 'buttonAlignment' => 'left', #string left | center | right
410 'buttonFontSize' => 20, #number
411 'buttonColor' => '#afafaf80', #string
412 'buttonTextColor' => '#000000de', #string
413 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
414 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
415 'buttonPosition' => 'bottom', #string bottom | top | center | above | below
416 'buttonBorderSize' => 0, #number
417 'buttonBorderColor' => '#afafaf80', #string
418 'buttonBorderRadius' => 4, #number
419 ],
420 'coverflow' => [
421 'width' => 500, #number
422 'height' => 700, #number
423 'backgroundColor' => '', #string;
424 'padding' => 0, #number
425 'autoplay' => TRUE, #boolean
426 'slideDuration' => 3000, #number
427 'playAndPauseAllowed' => FALSE, #boolean
428 'rotate' => 50, #number
429 'imagesCount' => 3, #number
430 'hoverEffect' => 'none', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
431 'showTitle' => FALSE, #boolean
432 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
433 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
434 'titlePosition' => 'bottom', #string bottom | top | center | above | below
435 'titleFontSize' => 20, #number
436 'titleColor' => '#DDDDDD', #string
437 'titleAlignment' => 'left', #string left | center | right
438 'titleFontFamily' => 'Inherit', #string
439 'titleMaxRowsCount' => 1, #number
440 'captionMaxRowsCount' => 1, #number
441 'overlayTextBackground' => '', #string
442 'invertTextColor' => FALSE, #boolean
443 'showCaption' => FALSE, #boolean
444 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
445 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
446 'captionPosition' => 'bottom', #string bottom | top | center | above | below
447 'captionFontSize' => 18, #number
448 'captionFontColor' => '#DDDDDD', #string
449 'navigation' => 'none', #string none | arrows | dots | arrowsAndDots
450 'arrowsSize' => 26, #number
451 'arrowsColor' => 'rgba(255, 255, 255, 0.8)',
452 'dotsPosition' => 'outside', #string inside | outside
453 'dotsSize' => 13, #number
454 'dotsGap' => 4, #number
455 'activeDotColor' => '#aaaaaa', #string
456 'inactiveDotsColor' => 'rgba(170, 170, 170, 0.4)', #string
457 'showVideoControls' => false,
458 'animationSpeed' => 800, #number
459 'showVideoCover' => FALSE, #boolean
460 'showButton' => FALSE, #boolean
461 'buttonText' => 'View more', #string
462 'openInNewTab' => FALSE, #boolean
463 'buttonAlignment' => 'left', #string left | center | right
464 'buttonFontSize' => 20, #number
465 'buttonColor' => '#afafaf80', #string
466 'buttonTextColor' => '#000000de', #string
467 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
468 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
469 'buttonPosition' => 'bottom', #string bottom | top | center | above | below
470 'buttonBorderSize' => 0, #number
471 'buttonBorderColor' => '#afafaf80', #string
472 'buttonBorderRadius' => 4, #number
473 ],
474 'scroller' => [
475 'width' => 400, #number
476 'height' => 300, #number
477 'equalWidth' => FALSE, #boolean
478 'equalHeight' => FALSE, #boolean
479 'rowCount' => 1, #number
480 'scrollDirection' => 'left', #string left | right
481 'backgroundColor' => '', #string
482 'containerPadding' => 0, #number
483 'padding' => 0, #number
484 'paddingColor' => '', #string
485 'borderRadius' => 0, #number
486 'gap' => 20, #number
487 'pauseOnHover' => TRUE, #boolean
488 'hoverEffect' => 'zoom-in', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
489 'animationSpeed' => 40, #number
490 'showVideoCover' => TRUE, #boolean
491 'showTitle' => FALSE, #boolean
492 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
493 'titleVisibility' => 'alwaysShown', #string alwaysShown | onHover
494 'titlePosition' => 'bottom', #string bottom | top | center | above | below
495 'titleFontSize' => 20, #number
496 'titleColor' => '#DDDDDD', #string
497 'titleAlignment' => 'left', #string left | center | right
498 'titleFontFamily' => 'Inherit', #string
499 'titleMaxRowsCount' => 1, #number
500 'captionMaxRowsCount' => 1, #number
501 'overlayTextBackground' => '', #string
502 'invertTextColor' => FALSE, #boolean
503 'showCaption' => FALSE, #boolean
504 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
505 'captionVisibility' => 'alwaysShown', #string alwaysShown | onHover
506 'captionPosition' => 'bottom', #string bottom | top | center | above | below
507 'captionFontSize' => 18, #number
508 'captionFontColor' => '#DDDDDD', #string
509 'showButton' => FALSE, #boolean
510 'buttonText' => 'View more', #string
511 'openInNewTab' => FALSE, #boolean
512 'buttonAlignment' => 'left', #string left | center | right
513 'buttonFontSize' => 20, #number
514 'buttonColor' => '#afafaf80', #string
515 'buttonTextColor' => '#000000de', #string
516 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
517 'buttonVisibility' => 'alwaysShown', #string alwaysShown | onHover
518 'buttonPosition' => 'bottom', #string bottom | top | center | above | below
519 'buttonBorderSize' => 0, #number
520 'buttonBorderColor' => '#afafaf80', #string
521 'buttonBorderRadius' => 4, #number
522 ],
523 'blog' => [
524 'imageWidth' => 50, #number
525 'imageWidthType' => '%', #string % | px | vw | rem | em
526 'imageHeight' => 400, #number
527 'imageHeightType' => 'px', #string px | vh | rem | em
528 'imagePosition' => 'staggered', #string left | right | staggered | listed
529 'spacing' => 0, #number
530 'backgroundColor' => '', #string;
531 'containerPadding' => 0, #number
532 'imageRadius' => 0, #number
533 'hoverEffect' => 'zoom-in', #string zoom-out | zoom-in | slide | rotate | blur | scale | sepia | overlay | soft-light | overlay-icon-zoom | overlay-icon-cart | overlay-icon-plus | overlay-icon-fullscreen | flash | shine | circle | push | none
534 'showTitle' => TRUE, #boolean
535 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
536 'titleFontSize' => 36, #number
537 'titleColor' => '#000000', #string
538 'titleAlignment' => 'left', #string left | center | right
539 'titleMaxRowsCount' => 4, #number
540 'captionMaxRowsCount' => 4, #number
541 'showDescription' => TRUE, #boolean
542 'descriptionSource' => 'description', #string title | caption | alt | price | description | author | date_created | exif
543 'descriptionFontSize' => 23, #number
544 'descriptionColor' => '#333333', #string
545 'descriptionMaxRowsCount' => 4, #number
546 'showButton' => TRUE, #boolean
547 'buttonText' => 'View more', #string
548 'openInNewTab' => FALSE, #boolean
549 'buttonAlignment' => 'left', #string left | center | right
550 'buttonFontSize' => 20, #number
551 'buttonColor' => '#afafaf80', #string
552 'buttonTextColor' => '#000000de', #string
553 'buttonBorderSize' => 0, #number
554 'buttonBorderColor' => '#afafaf80', #string
555 'buttonBorderRadius' => 4, #number
556 'textFontFamily' => 'Inherit', #string
557 'textVerticalAlignment' => 'center', #string bottom | top | center
558 'textHorizontalSpacing' => 35, #number
559 'textVerticalSpacing' => 35, #number
560 'paginationType' => 'simple', #string simple | scroll | loadMore | none
561 'showAllItems' => TRUE, #boolean
562 'showCaption' => FALSE, #boolean
563 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
564 'captionFontSize' => 26, #number
565 'captionFontColor' => '#CCCCCC', #string
566 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
567 'showVideoCover' => FALSE, #boolean
568 ],
569 'general' => [
570 'clickAction' => 'lightbox', #string none | lightbox | url
571 'openUrlInNewTab' => FALSE, #boolean
572 'actionUrlSource' => 'action_url', #string action_url | item_url | checkout_url
573 'orderBy' => 'default', #string
574 'orderDirection' => 'asc', #string
575 'itemsPerPage' => 20, #number
576 'activeButtonColor' => '#FFFFFF', #string
577 'inactiveButtonColor' => '#D7D7D7', #string
578 'loadMoreButtonColor' => '#D7D7D7', #string
579 'paginationTextColor' => '#000000de', #string
580 'paginationButtonTextSize' => 0.875, #float
581 'paginationButtonBorderRadius' => 4, #number
582 'paginationButtonBorderSize' => '', #number
583 'paginationButtonBorderColor' => '', #number
584 'loadMoreButtonText' => '', #string
585 'paginationButtonClass' => '', #string
586 'enableWatermark' => FALSE, #boolean
587 'watermarkImageURL' => REACG_PLUGIN_URL . '/assets/images/icon.svg', #string
588 'watermarkTransparency' => 20, #number
589 'watermarkSize' => 30, #number
590 'watermarkPosition' => 'middle-center', #string top-left | top-center | top-right | middle-left | middle-center | middle-right | bottom-left | bottom-center | bottom-right
591 'enableSearch' => FALSE, #boolean
592 'searchPlaceholderText' => '', #string
593 'enableRightClickProtection' => FALSE, #boolean
594 ],
595 'lightbox' => [
596 'isFullscreen' => TRUE, #boolean
597 'width' => 800, #number
598 'height' => 600, #number
599 'areControlButtonsShown' => TRUE, #boolean
600 'isInfinite' => TRUE, #boolean
601 'padding' => 70, #number
602 'showCounter' => FALSE, #boolean
603 'canShare' => FALSE, #boolean
604 'canDownload' => FALSE, #boolean
605 'canZoom' => TRUE, #boolean
606 'autoplay' => FALSE, #boolean
607 'slideDuration' => 5000, #number
608 'imageAnimation' => 'slideH', #string fade | blur | slideH | slideV | zoom | flip | rotate
609 'isSlideshowAllowed' => TRUE, #boolean
610 'canFullscreen' => TRUE, #boolean
611 'thumbnailsPosition' => 'none', #string top | bottom | start | end | none
612 'thumbnailWidth' => 120, #number
613 'thumbnailHeight' => 90, #number
614 'thumbnailBorder' => 0, #number
615 'thumbnailBorderColor' => '', #string
616 'thumbnailBorderRadius' => 0, #number
617 'thumbnailPadding' => 0, #number
618 'thumbnailGap' => 5, #number
619 'backgroundColor' => 'rgba(0, 0, 0, 0.2)', #string;
620 'textPosition' => 'bottom', #string top | bottom | above | below
621 'textFontFamily' => 'Inherit', #string
622 'textColor' => '#FFFFFF', #string
623 'textBackground' => '', #string
624 'invertTextColor' => FALSE, #boolean
625 'showTitle' => TRUE, #bool
626 'titleSource' => 'title', #string title | caption | alt | price | description | author | date_created | exif
627 'titleFontSize' => 1.6, #float
628 'titleAlignment' => 'left', #string left | center | right
629 'showDescription' => TRUE, #bool
630 'descriptionSource' => 'description', #string title | caption | alt | price | description | author | date_created | exif
631 'descriptionFontSize' => 1.3, #float
632 'descriptionMaxRowsCount' => 1, #number
633 'showCaption' => FALSE, #boolean
634 'captionSource' => 'caption', #string title | caption | alt | price | description | author | date_created | exif
635 'captionFontSize' => 1.5, #float
636 'captionFontColor' => '#FFFFFF', #string
637 'showButton' => FALSE, #boolean
638 'buttonText' => 'View more', #string
639 'openInNewTab' => FALSE, #boolean
640 'buttonAlignment' => 'left', #string left | center | right
641 'buttonFontSize' => 1.3, #float
642 'buttonColor' => '#afafaf80', #string
643 'buttonTextColor' => '#000000de', #string
644 'buttonBorderSize' => 0, #number
645 'buttonBorderColor' => '#afafaf80', #string
646 'buttonBorderRadius' => 4, #number
647 'buttonUrlSource' => 'action_url', #string action_url | item_url | checkout_url
648 ],
649 ];
650 protected $name = "reacg_options";
651
652 /**
653 * Validate data on allowed values.
654 *
655 * @param $key
656 * @param $value
657 *
658 * @return mixed
659 */
660 protected function validate($key, $value) {
661 $number = [
662 'width',
663 'height',
664 'columns',
665 'itemsPerPage',
666 'titleFontSize',
667 'thumbnailWidth',
668 'thumbnailHeight',
669 'thumbnailGap',
670 'slideDuration',
671 'rowHeight',
672 'imagesCount',
673 'perSlideOffset',
674 'descriptionFontSize',
675 'titleMaxRowsCount',
676 'captionMaxRowsCount',
677 'descriptionMaxRowsCount',
678 'buttonFontSize',
679 'imageWidth',
680 'imageHeight',
681 'captionFontSize',
682 'arrowsSize',
683 'dotsSize',
684 'dotsGap',
685 'rotate',
686 'scrollSpeed',
687 'rowCount',
688 ];
689 $empty_number = [
690 'template_id',
691 'gap',
692 'itemBorder',
693 'itemBorderRadius',
694 'containerPadding',
695 'padding',
696 'borderRadius',
697 'thumbnailBorder',
698 'thumbnailBorderRadius',
699 'thumbnailPadding',
700 'spacing',
701 'imageRadius',
702 'textHorizontalSpacing',
703 'textVerticalSpacing',
704 'paginationButtonBorderRadius',
705 'paginationButtonBorderSize',
706 'watermarkTransparency',
707 'watermarkSize',
708 'buttonBorderSize',
709 'buttonBorderRadius',
710 'animationSpeed',
711 ];
712 $negative_number = [
713 'spaceBetween',
714 ];
715 $boolean = [
716 'showLightbox',
717 'canFullscreen',
718 'isFullscreen',
719 'areControlButtonsShown',
720 'isInfinite',
721 'showCounter',
722 'canShare',
723 'canDownload',
724 'canZoom',
725 'autoplay',
726 'isSlideshowAllowed',
727 'shadow',
728 'playAndPauseAllowed',
729 'openUrlInNewTab',
730 'showTitle',
731 'showDescription',
732 'showButton',
733 'openInNewTab',
734 'isFullCoverImage',
735 'showCaption',
736 'fillContainer',
737 'invertTextColor',
738 'enableWatermark',
739 'enableSearch',
740 'enableWhiteLabel',
741 'showVideoControls',
742 'enableRightClickProtection',
743 'showAllItems',
744 'enableScrollByImagesCount',
745 'showVideoCover',
746 'equalHeight',
747 'equalWidth',
748 'pauseOnHover',
749 ];
750 $float = [
751 'scale',
752 'titleFontSize',
753 'descriptionFontSize',
754 'captionFontSize',
755 'paginationButtonTextSize',
756 'buttonFontSize',
757 ];
758 $style = [
759 'css',
760 'custom_css',
761 ];
762 $specific = [
763 'type' => [
764 'allowed' => [ 'thumbnails', 'mosaic', 'justified', 'masonry', 'slideshow', 'cube', 'carousel', 'coverflow', 'cards', 'blog', 'scroller' ],
765 'default' => 'thumbnails',
766 ],
767 'direction' => [
768 'allowed' => [ 'horizontal', 'vertical' ],
769 'default' => 'vertical',
770 ],
771 'titleVisibility' => [
772 'allowed' => [ 'alwaysShown', 'onHover' ],
773 'default' => 'alwaysShown',
774 ],
775 'captionVisibility' => [
776 'allowed' => [ 'alwaysShown', 'onHover' ],
777 'default' => 'alwaysShown',
778 ],
779 'buttonVisibility' => [
780 'allowed' => [ 'alwaysShown', 'onHover' ],
781 'default' => 'alwaysShown',
782 ],
783 'titlePosition' => [
784 'allowed' => [ 'bottom', 'top', 'center', 'above', 'below' ],
785 'default' => 'bottom',
786 ],
787 'captionPosition' => [
788 'allowed' => [ 'bottom', 'top', 'center', 'above', 'below' ],
789 'default' => 'bottom',
790 ],
791 'buttonPosition' => [
792 'allowed' => [ 'bottom', 'top', 'center', 'above', 'below' ],
793 'default' => 'bottom',
794 ],
795 'descriptionPosition' => [
796 'allowed' => [ 'above', 'below' ],
797 'default' => 'below',
798 ],
799 'titleSource' => [
800 'allowed' => [ 'title', 'caption', 'alt', 'price', 'description', 'author', 'date_created', 'exif', 'image_title', 'image_caption', 'image_alt', 'image_description' ],
801 'default' => 'title',
802 ],
803 'captionSource' => [
804 'allowed' => [ 'title', 'caption', 'alt', 'price', 'description', 'author', 'date_created', 'exif', 'image_title', 'image_caption', 'image_alt', 'image_description' ],
805 'default' => 'caption',
806 ],
807 'descriptionSource' => [
808 'allowed' => [ 'title', 'caption', 'alt', 'price', 'description', 'author', 'date_created', 'exif', 'image_title', 'image_caption', 'image_alt', 'image_description' ],
809 'default' => 'description',
810 ],
811 'textVerticalAlignment' => [
812 'allowed' => [ 'bottom', 'top', 'center' ],
813 'default' => 'center',
814 ],
815 'titleAlignment' => [
816 'allowed' => [ 'left', 'center', 'right' ],
817 'default' => 'left',
818 ],
819 'buttonAlignment' => [
820 'allowed' => [ 'left', 'center', 'right' ],
821 'default' => 'left',
822 ],
823 'paginationType' => [
824 'allowed' => [ 'simple', 'scroll', 'loadMore', 'none' ],
825 'default' => 'simple',
826 ],
827 'paginationButtonShape' => [
828 'allowed' => [ 'rounded', 'circular' ],
829 'default' => 'circular',
830 ],
831 'thumbnailsPosition' => [
832 'allowed' => [ 'top', 'bottom', 'start', 'end', 'none' ],
833 'default' => 'bottom',
834 ],
835 'textPosition' => [
836 'allowed' => [ 'top', 'bottom', 'above', 'below' ],
837 'default' => 'bottom',
838 ],
839 'imageAnimation' => [
840 'allowed' => [ 'fade', 'blur', 'slideH', 'slideV', 'zoom', 'flip', 'rotate' ],
841 'default' => 'slideH',
842 ],
843 'hoverEffect' => [
844 'allowed' => ['zoom-out', 'zoom-in', 'slide', 'rotate', 'blur', 'scale', 'sepia', 'overlay', 'soft-light', 'overlay-icon-zoom', 'overlay-icon-cart', 'overlay-icon-plus', 'overlay-icon-fullscreen', 'flash', 'shine', 'circle', 'push', 'none'],
845 'default' => 'none',
846 ],
847 'orderBy' => [
848 'allowed' => [ 'default', 'title', 'caption', 'description', 'date' ],
849 'default' => 'default',
850 ],
851 'orderDirection' => [
852 'allowed' => [ 'asc', 'desc' ],
853 'default' => 'asc',
854 ],
855 'clickAction' => [
856 'allowed' => [ 'none', 'lightbox', 'url' ],
857 'default' => 'lightbox',
858 ],
859 'sizeTypeWidth' => [
860 'allowed' => [ '%', 'px', 'vw', 'rem', 'em' ],
861 'default' => '%',
862 ],
863 'sizeTypeHeight' => [
864 'allowed' => [ 'px', 'vh', 'rem', 'em' ],
865 'default' => 'px',
866 ],
867 'imagePosition' => [
868 'allowed' => [ 'left', 'right', 'staggered', 'listed' ],
869 'default' => 'staggered',
870 ],
871 'actionUrlSource' => [
872 'allowed' => [ 'action_url', 'item_url', 'checkout_url' ],
873 'default' => 'action_url',
874 ],
875 'buttonUrlSource' => [
876 'allowed' => [ 'action_url', 'item_url', 'checkout_url' ],
877 'default' => 'action_url',
878 ],
879 'aspectRatio' => [
880 'allowed' => [ '1', '1.33', '1.5', '1.77', '0.75', '0.66', '0.56' ],
881 'default' => '1.77',
882 ],
883 'navigation' => [
884 'allowed' => [ 'none', 'arrows', 'dots', 'arrowsAndDots' ],
885 'default' => 'arrows',
886 ],
887 'dotsPosition' => [
888 'allowed' => [ 'outside', 'inside' ],
889 'default' => 'outside',
890 ],
891 'scrollDirection' => [
892 'allowed' => [ 'left', 'right' ],
893 'default' => 'left',
894 ],
895 ];
896 if ( in_array($key, $float) ) {
897 return floatval($value);
898 }
899 elseif ( in_array($key, $empty_number) ) {
900 return $value === '' || intval($value) < 0 ? '' : intval($value);
901 }
902 elseif ( in_array($key, $negative_number) ) {
903 return intval($value);
904 }
905 elseif ( in_array($key, $number) ) {
906 return intval(max($value, 1));
907 }
908 elseif ( in_array($key, $boolean) ) {
909 return filter_var($value, FILTER_VALIDATE_BOOLEAN);
910 }
911 elseif ( in_array($key, $style) ) {
912 return wp_strip_all_tags($value);
913 }
914 elseif ( array_key_exists($key, $specific) ) {
915 return in_array($value, $specific[$key]['allowed']) ? $value : $specific[$key]['default'];
916 }
917
918 return $value;
919 }
920
921 public function __construct($activate, $gallery_id = 0) {
922 if ( $activate ) {
923 $this->add_option();
924 }
925 elseif ( $gallery_id ) {
926 $this->remove_option($gallery_id);
927 }
928 }
929
930 /**
931 * Set options default values.
932 *
933 * @return void
934 */
935 private function add_option() {
936 add_option($this->name, json_encode($this->options));
937 }
938
939 /**
940 * To check the method.
941 *
942 * @param WP_REST_Request $request
943 *
944 * @return void
945 */
946 public function options(WP_REST_Request $request) {
947 if ( !is_null($request) ) {
948 switch ( $request->get_method() ) {
949 case "GET": {
950 $this->get($request);
951 break;
952 }
953 case "POST":
954 case "PUT":
955 case "PATCH": {
956 $this->set($request);
957 break;
958 }
959 case "DELETE": {
960 $this->reset($request);
961 break;
962 }
963 }
964 }
965 }
966
967 /**
968 * Sanitizing and validating the given data.
969 *
970 * @param $data
971 *
972 * @return mixed
973 */
974 protected function sanitize($data) {
975 foreach ( $data as $key => $item ) {
976 if ( is_array($item) ) {
977 $data[$key] = $this->sanitize($item);
978 }
979 else {
980 $item = sanitize_text_field(stripslashes($item));
981 // Validate data on allowed values.
982 $data[$key] = $this->validate($key, $item);
983 }
984 }
985
986 return $data;
987 }
988
989 /**
990 * Refill the changed data.
991 *
992 * @param $new_data
993 * @param $saved_data
994 *
995 * @return mixed
996 */
997 protected function fill($new_data, $saved_data) {
998 foreach ( $new_data as $key => $option ) {
999 if ( is_array($option) && isset($saved_data[$key]) ) {
1000 // If the option is a group of options.
1001 $saved_data[$key] = $this->fill($new_data[$key], $saved_data[$key]);
1002 }
1003 else {
1004 // If an option has a new value change the old one with it.
1005 $saved_data[$key] = $option;
1006 }
1007 }
1008
1009 return $saved_data;
1010 }
1011
1012 /**
1013 * Set options for the given gallery.
1014 *
1015 * @param WP_REST_Request $request
1016 *
1017 * @return WP_REST_Response
1018 */
1019 private function set(WP_REST_Request $request) {
1020 $gallery_id = REACGLibrary::get_gallery_id($request, 'gallery_id');
1021
1022 $data = $request->get_body();
1023
1024 if ( empty($data) ) {
1025 return wp_send_json(new WP_Error( 'nothing_to_save', __( 'Nothing to save.', 'regallery' ), array( 'status' => 400 ) ), 400);
1026 }
1027 $data = json_decode($data, TRUE);
1028
1029 // Modify the data structure based on the new structure.
1030 $data = $this->modify($data);
1031
1032 // Sanitizing and validating the given data.
1033 $data = $this->sanitize($data);
1034
1035 // Get saved options and add the changed once.
1036 $old_options = get_option($this->name . $gallery_id, FALSE);
1037 if ( !empty($old_options) ) {
1038 $old_data = json_decode($old_options, TRUE);
1039 $old_data = $this->modify($old_data);
1040 $data = $this->fill($data, $old_data);
1041 }
1042
1043 $options = json_encode($data);
1044
1045 $saved = update_option($this->name . $gallery_id, $options);
1046 $new_options = get_option($this->name . $gallery_id, $options);
1047
1048 if ( $saved === TRUE || $old_options === $new_options ) {
1049 /* Update the options timestamp on options save to prevent data from being read from the cache.*/
1050 update_post_meta($gallery_id, 'options_timestamp', time());
1051 return $this->get($request, $gallery_id);
1052 }
1053 else {
1054 return wp_send_json(new WP_Error( 'nothing_saved', __( 'Nothing saved.', 'regallery' ), array( 'status' => 400 ) ), 400);
1055 }
1056 }
1057
1058 /**
1059 * Get the default options or the options for the given gallery.
1060 *
1061 * @param $gallery_id
1062 *
1063 * @return mixed
1064 */
1065 public function get_options($gallery_id) {
1066 // Get options for the gallery.
1067 $options = get_option($this->name . $gallery_id, FALSE);
1068
1069 // Get default options
1070 // if the gallery options do not exist
1071 // or fetching direct with gallery ID 0 on selecting Default template.
1072 if ( $options === FALSE || !$gallery_id ) {
1073 return $this->options;
1074 }
1075
1076 if ( !empty($options) ) {
1077 $options = json_decode($options, TRUE);
1078 }
1079
1080 // Modify the data structure based on the new structure.
1081 $options = $this->modify($options);
1082
1083 // In case of types that previously had no lightbox functionality change their default value to none.
1084 $this->options['general']['clickAction'] = in_array((!isset($options['type']) ? 'thumbnails' : $options['type']), ['thumbnails', 'mosaic', 'masonry']) ? 'lightbox' : 'none';
1085
1086 // If an option is missing add its default value.
1087 $options = $this->defaults($this->options, $options);
1088
1089 // Sanitizing and validating the given data.
1090 $options = $this->sanitize($options);
1091
1092 return $options;
1093 }
1094
1095 /**
1096 * Get options rout.
1097 *
1098 * @param WP_REST_Request $request
1099 * @param int $gallery_id
1100 *
1101 * @return WP_REST_Response
1102 */
1103 private function get( WP_REST_Request $request, int $gallery_id = 0 ) {
1104 if ( $gallery_id === 0 ) {
1105 $gallery_id = REACGLibrary::get_gallery_id($request, 'gallery_id');
1106 }
1107
1108 $options = $this->get_options($gallery_id);
1109
1110 return new WP_REST_Response( wp_send_json($options, 200), 200 );
1111 }
1112
1113 /**
1114 * If an option is missing add its default value.
1115 *
1116 * @param $default_options
1117 * @param $options
1118 *
1119 * @return mixed
1120 */
1121 protected function defaults($default_options, $options) {
1122 if ( !empty($options) ) {
1123 foreach ( $default_options as $key => $option ) {
1124 if ( is_array($option) ) {
1125 // If the option is a group of options (e.g. lightbox).
1126 $options[$key] = $this->defaults($default_options[$key], isset($options[$key]) ? $options[$key] : null);
1127 }
1128 elseif ( !isset($options[$key]) ) {
1129 // If an option is missing add its default value.
1130 $options[$key] = $option;
1131 }
1132 }
1133 }
1134 else {
1135 // If a group of options is missing add its default value.
1136 $options = $default_options;
1137 }
1138
1139 return $options;
1140 }
1141
1142 /**
1143 * Modify the data structure based on the new structure.
1144 *
1145 * @param $options
1146 *
1147 * @return mixed
1148 */
1149 protected function modify($options) {
1150 if ( !empty($options) ) {
1151 // Renamed options.
1152 $renamed = [
1153 'slideshow' => [
1154 ['old' => 'captionsPosition', 'new' => 'textPosition'],
1155 ['old' => 'captionFontFamily', 'new' => 'textFontFamily'],
1156 ['old' => 'captionColor', 'new' => 'textColor'],
1157 ],
1158 'lightbox' => [
1159 ['old' => 'captionsPosition', 'new' => 'textPosition'],
1160 ['old' => 'captionFontFamily', 'new' => 'textFontFamily'],
1161 ['old' => 'captionColor', 'new' => 'textColor'],
1162 ],
1163 ];
1164 foreach ( $renamed as $key => $group ) {
1165 if ( isset($options[$key]) ) {
1166 foreach ( $group as $value ) {
1167 if ( isset($options[$key][$value['old']]) ) {
1168 $options[$key][$value['new']] = $options[$key][$value['old']];
1169 unset($options[$key][$value['old']]);
1170 }
1171 }
1172 }
1173 }
1174
1175 // Renamed options values.
1176 $renamed_values = [
1177 'thumbnails' => [
1178 'hoverEffect' => ['old' => 'overlay-icon', 'new' => 'overlay-icon-zoom'],
1179 ],
1180 'mosaic' => [
1181 'hoverEffect' => ['old' => 'overlay-icon', 'new' => 'overlay-icon-zoom'],
1182 ],
1183 'masonry' => [
1184 'hoverEffect' => ['old' => 'overlay-icon', 'new' => 'overlay-icon-zoom'],
1185 ],
1186 'blog' => [
1187 'hoverEffect' => ['old' => 'overlay-icon', 'new' => 'overlay-icon-zoom'],
1188 ],
1189 ];
1190 foreach ( $renamed_values as $key => $group ) {
1191 if ( isset($options[$key]) ) {
1192 foreach ( $group as $option => $value ) {
1193 if ( isset($options[$key][$option]) && $options[$key][$option] === $value['old'] ) {
1194 $options[$key][$option] = $value['new'];
1195 }
1196 }
1197 }
1198 }
1199
1200 // Options to be moved.
1201 $move = [
1202 'lightbox' => [ 'showLightbox' ],
1203 'thumbnails' => [
1204 'width',
1205 'height',
1206 'columns',
1207 'gap',
1208 'backgroundColor',
1209 'padding',
1210 'paddingColor',
1211 'borderRadius',
1212 'hoverEffect',
1213 'titleVisibility',
1214 'titlePosition',
1215 'titleAlignment',
1216 'titleColor',
1217 'titleFontSize',
1218 'titleFontFamily',
1219 'paginationType',
1220 ],
1221 'general' => [
1222 'orderBy',
1223 'orderDirection',
1224 'itemsPerPage',
1225 'activeButtonColor',
1226 'inactiveButtonColor',
1227 'paginationButtonShape',
1228 'loadMoreButtonColor',
1229 'paginationTextColor',
1230 ],
1231 ];
1232 foreach ( $move as $to => $old_keys ) {
1233 // If the new group exists.
1234 if ( !isset($options[$to]) ) {
1235 $options[$to] = [];
1236 }
1237 foreach ( $old_keys as $old_key ) {
1238 // If the old option exists.
1239 if ( isset($options[$old_key]) ) {
1240 // Move the option to the new group.
1241 $options[$to][$old_key] = $options[$old_key];
1242 // Remove the old option.
1243 unset($options[$old_key]);
1244 }
1245 }
1246 }
1247
1248 if ( isset($options['lightbox']['showLightbox']) ) {
1249 $options['general']['clickAction'] = in_array((!isset($options['type']) ? 'thumbnails' : $options['type']), ['thumbnails', 'mosaic', 'masonry']) && $options['lightbox']['showLightbox'] ? 'lightbox' : 'none';
1250 unset($options['lightbox']['showLightbox']);
1251 }
1252 if ( !empty($options['type']) && $options['type'] === "mosaic"
1253 && !empty($options['mosaic']) && !empty($options['mosaic']['direction']) && $options['mosaic']['direction'] === "horizontal" ) {
1254 $options['type'] = "justified";
1255 $options['justified'] = $options['mosaic'];
1256 unset($options['mosaic']['direction']);
1257 unset($options['mosaic']['rowHeight']);
1258 unset($options['justified']['direction']);
1259 unset($options['justified']['columns']);
1260 }
1261 if ( isset($options['general']['paginationButtonShape']) ) {
1262 unset($options['general']['paginationButtonShape']);
1263 }
1264
1265 if ( isset($options['thumbnails']) ) {
1266 if ( !isset($options['thumbnails']['showTitle']) ) {
1267 if ( isset($options['thumbnails']['titleVisibility'])
1268 && $options['thumbnails']['titleVisibility'] !== "none" ) {
1269 $options['thumbnails']['showTitle'] = TRUE;
1270 }
1271 else {
1272 $options['thumbnails']['showTitle'] = FALSE;
1273 $options['thumbnails']['titleVisibility'] = "alwaysShown";
1274 }
1275 }
1276 if ( !isset($options['thumbnails']['captionVisibility']) ) {
1277 $options['thumbnails']['captionVisibility'] = $options['thumbnails']['titleVisibility'];
1278 }
1279 if ( !isset($options['thumbnails']['captionPosition']) ) {
1280 $options['thumbnails']['captionPosition'] = isset($options['thumbnails']['titlePosition']) ? $options['thumbnails']['titlePosition'] : 'bottom';
1281 }
1282 }
1283
1284 if ( isset($options['mosaic']) ) {
1285 if ( !isset($options['mosaic']['showTitle']) ) {
1286 if ( isset($options['mosaic']['titleVisibility'])
1287 && $options['mosaic']['titleVisibility'] !== "none" ) {
1288 $options['mosaic']['showTitle'] = TRUE;
1289 }
1290 else {
1291 $options['mosaic']['showTitle'] = FALSE;
1292 $options['mosaic']['titleVisibility'] = "alwaysShown";
1293 }
1294 }
1295 if ( !isset($options['mosaic']['captionVisibility']) ) {
1296 $options['mosaic']['captionVisibility'] = $options['mosaic']['titleVisibility'];
1297 }
1298 if ( !isset($options['mosaic']['captionPosition']) ) {
1299 $options['mosaic']['captionPosition'] = isset($options['mosaic']['titlePosition']) ? $options['mosaic']['titlePosition'] : 'bottom';
1300 }
1301 }
1302
1303 if ( isset($options['masonry']) ) {
1304 if ( !isset($options['masonry']['showTitle']) ) {
1305 if ( isset($options['masonry']['titleVisibility'])
1306 && $options['masonry']['titleVisibility'] !== "none" ) {
1307 $options['masonry']['showTitle'] = TRUE;
1308 }
1309 else {
1310 $options['masonry']['showTitle'] = FALSE;
1311 $options['masonry']['titleVisibility'] = "alwaysShown";
1312 }
1313 }
1314 if ( !isset($options['masonry']['captionVisibility']) ) {
1315 $options['masonry']['captionVisibility'] = $options['masonry']['titleVisibility'];
1316 }
1317 if ( !isset($options['masonry']['captionPosition']) ) {
1318 $options['masonry']['captionPosition'] = isset($options['masonry']['titlePosition']) ? $options['masonry']['titlePosition'] : 'bottom';
1319 }
1320 }
1321
1322 if ( isset($options['justified']) ) {
1323 if ( !isset($options['justified']['showTitle']) ) {
1324 if ( isset($options['justified']['titleVisibility'])
1325 && $options['justified']['titleVisibility'] !== "none" ) {
1326 $options['justified']['showTitle'] = TRUE;
1327 }
1328 else {
1329 $options['justified']['showTitle'] = FALSE;
1330 $options['justified']['titleVisibility'] = "alwaysShown";
1331 }
1332 }
1333 if ( !isset($options['justified']['captionVisibility']) ) {
1334 $options['justified']['captionVisibility'] = $options['justified']['titleVisibility'];
1335 }
1336 if ( !isset($options['justified']['captionPosition']) ) {
1337 $options['justified']['captionPosition'] = isset($options['justified']['titlePosition']) ? $options['justified']['titlePosition'] : 'bottom';
1338 }
1339 }
1340 if ( isset($options['slideshow']) ) {
1341 if ( isset($options['slideshow']['textPosition'])
1342 && $options['slideshow']['textPosition'] === "none") {
1343 $options['slideshow']['showTitle'] = FALSE;
1344 $options['slideshow']['showCaption'] = FALSE;
1345 $options['slideshow']['showDescription'] = FALSE;
1346 }
1347 }
1348 if ( isset($options['lightbox']) ) {
1349 if ( isset($options['lightbox']['textPosition'])
1350 && $options['lightbox']['textPosition'] === "none") {
1351 $options['lightbox']['showTitle'] = FALSE;
1352 $options['lightbox']['showCaption'] = FALSE;
1353 $options['lightbox']['showDescription'] = FALSE;
1354 }
1355 if ( isset($options['lightbox']['isFullscreenAllowed']) ) {
1356 $options['lightbox']['canFullscreen'] = $options['lightbox']['isFullscreenAllowed'];
1357 unset($options['lightbox']['isFullscreenAllowed']);
1358 }
1359 }
1360 }
1361
1362 return $options;
1363 }
1364
1365 /**
1366 * Reset the options fot the given gallery.
1367 *
1368 * @param $request
1369 *
1370 * @return WP_REST_Response
1371 */
1372 private function reset($request) {
1373 $gallery_id = REACGLibrary::get_gallery_id($request, 'gallery_id');
1374
1375 // Get saved options to reset only the current type options.
1376 $options = get_option($this->name . $gallery_id, FALSE);
1377 if ( !empty($options) ) {
1378 $data = json_decode($options, TRUE);
1379 if ( isset($data[$data['type']]) ) {
1380 // Remove the current type options.
1381 unset($data[$data['type']]);
1382 }
1383 if ( isset($data['general']) ) {
1384 // Remove general options.
1385 unset($data['general']);
1386 }
1387 if ( isset($data['lightbox']) ) {
1388 // Remove lightbox options.
1389 unset($data['lightbox']);
1390 }
1391 if ( isset($data['template']) ) {
1392 unset($data['template']);
1393 }
1394 if ( isset($data['template_id']) ) {
1395 unset($data['template_id']);
1396 }
1397 if ( isset($data['title']) ) {
1398 unset($data['title']);
1399 }
1400 if ( isset($data['css']) ) {
1401 unset($data['css']);
1402 }
1403
1404 $options = json_encode($data);
1405 $saved = update_option($this->name . $gallery_id, $options);
1406 if ( $saved === TRUE ) {
1407 /* Update the options timestamp on options reset to prevent data from being read from the cache.*/
1408 update_post_meta($gallery_id, 'options_timestamp', time());
1409 return new WP_REST_Response( wp_send_json(__( 'Settings successfully reset.', 'regallery' ), 200), 200 );
1410 }
1411 }
1412
1413 return new WP_REST_Response( wp_send_json(__( 'Settings already reset.', 'regallery' ), 200), 200 );
1414 }
1415
1416 /**
1417 * Remove the options by gallery ID.
1418 *
1419 * @param $gallery_id
1420 *
1421 * @return void
1422 */
1423 private function remove_option($gallery_id) {
1424 delete_option($this->name . $gallery_id);
1425 }
1426 }
1427