Photo Gallery by Envira – Responsive Image Gallery for WordPress - Version 1.0.9

Version Description

  • Fixed JS error issues with WordPress 3.9.
  • Added ability to link to external URLs in images.
  • Other miscellaneous bug fixes and improvements.
Download this release

Release Info

Developer griffinjt
Plugin Icon 128x128 Photo Gallery by Envira – Responsive Image Gallery for WordPress
Version 1.0.9
Comparing to
See all releases

Version 1.0.9

Files changed (51) hide show
  1. README.md +4 -0
  2. assets/css/envira.css +510 -0
  3. assets/css/images/blank.gif +0 -0
  4. assets/css/images/delete.png +0 -0
  5. assets/css/images/delete@2x.png +0 -0
  6. assets/css/images/fancy_close.png +0 -0
  7. assets/css/images/fancy_loading.png +0 -0
  8. assets/css/images/fancy_nav_left.png +0 -0
  9. assets/css/images/fancy_nav_right.png +0 -0
  10. assets/css/images/fancy_shadow_e.png +0 -0
  11. assets/css/images/fancy_shadow_n.png +0 -0
  12. assets/css/images/fancy_shadow_ne.png +0 -0
  13. assets/css/images/fancy_shadow_nw.png +0 -0
  14. assets/css/images/fancy_shadow_s.png +0 -0
  15. assets/css/images/fancy_shadow_se.png +0 -0
  16. assets/css/images/fancy_shadow_sw.png +0 -0
  17. assets/css/images/fancy_shadow_w.png +0 -0
  18. assets/css/images/fancy_title_left.png +0 -0
  19. assets/css/images/fancy_title_main.png +0 -0
  20. assets/css/images/fancy_title_over.png +0 -0
  21. assets/css/images/fancy_title_right.png +0 -0
  22. assets/css/images/fancybox-x.png +0 -0
  23. assets/css/images/fancybox-y.png +0 -0
  24. assets/css/images/fancybox.png +0 -0
  25. assets/css/images/holder.gif +0 -0
  26. assets/css/images/menu-icon.png +0 -0
  27. assets/css/images/menu-icon@2x.png +0 -0
  28. assets/css/images/meta-active.png +0 -0
  29. assets/css/images/meta-active@2x.png +0 -0
  30. assets/css/images/meta.png +0 -0
  31. assets/css/images/meta@2x.png +0 -0
  32. assets/css/images/modify.png +0 -0
  33. assets/css/images/modify@2x.png +0 -0
  34. assets/css/images/preloader.gif +0 -0
  35. assets/css/images/preloader@2x.gif +0 -0
  36. assets/css/metabox.css +503 -0
  37. assets/js/editor.js +123 -0
  38. assets/js/envira-dev-holder.js +97 -0
  39. assets/js/envira.js +18 -0
  40. assets/js/metabox.js +626 -0
  41. envira-gallery-lite.php +443 -0
  42. includes/admin/ajax.php +420 -0
  43. includes/admin/common.php +225 -0
  44. includes/admin/editor.php +232 -0
  45. includes/admin/media.php +249 -0
  46. includes/admin/metaboxes.php +1117 -0
  47. includes/admin/posttype.php +208 -0
  48. includes/global/common.php +455 -0
  49. includes/global/posttype.php +108 -0
  50. includes/global/shortcode.php +536 -0
  51. readme.txt +113 -0
README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ Envira Gallery Lite
2
+ ==============
3
+
4
+ Envira Gallery Lite is the best responsive WordPress gallery plugin. Made lite and free.
assets/css/envira.css ADDED
@@ -0,0 +1,510 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ==========================================================================
2
+ Envira Gallery Styles
3
+ ========================================================================== */
4
+
5
+ .envira-gallery-wrap,
6
+ .envira-gallery-wrap * {
7
+ background:none;
8
+ border:0;
9
+ border-radius:0;
10
+ -webkit-border-radius:0;
11
+ -moz-border-radius:0;
12
+ float:none;
13
+ font:normal 100%/normal helvetica,arial,sans-serif;
14
+ -webkit-font-smoothing:antialiased;
15
+ height:auto;
16
+ letter-spacing:normal;
17
+ list-style:none;
18
+ outline:none;
19
+ position:static;
20
+ text-decoration:none;
21
+ text-indent:0;
22
+ text-shadow:none;
23
+ text-transform:none;
24
+ width:auto;
25
+ visibility:visible;
26
+ overflow:visible;
27
+ margin:0;
28
+ padding:0;
29
+ line-height:1;
30
+ box-sizing:border-box;
31
+ -webkit-box-sizing:border-box;
32
+ -moz-box-sizing:border-box;
33
+ -webkit-box-shadow:none;
34
+ -moz-box-shadow:none;
35
+ -ms-box-shadow:none;
36
+ -o-box-shadow:none;
37
+ box-shadow:none;
38
+ -webkit-appearance:none;
39
+ transition: none;
40
+ -webkit-transition: none;
41
+ -moz-transition: none;
42
+ -o-transition: none;
43
+ -ms-transition: none;
44
+ }
45
+
46
+ .envira-gallery-wrap {
47
+ opacity: 1;
48
+ min-height: 16px;
49
+ background: transparent url('images/preloader.gif') no-repeat scroll 50% 0;
50
+ }
51
+
52
+ .envira-gallery-public,
53
+ .envira-gallery-public .envira-gallery-item {
54
+ -webkit-transition-duration: 0.8s;
55
+ -moz-transition-duration: 0.8s;
56
+ -ms-transition-duration: 0.8s;
57
+ -o-transition-duration: 0.8s;
58
+ transition-duration: 0.8s;
59
+ }
60
+
61
+ .envira-gallery-public,
62
+ .envira-gallery-wrap {
63
+ -webkit-transition-property: height, width;
64
+ -moz-transition-property: height, width;
65
+ -ms-transition-property: height, width;
66
+ -o-transition-property: height, width;
67
+ transition-property: height, width;
68
+ margin: 0 auto 20px;
69
+ max-width: 100%;
70
+ -webkit-box-sizing: border-box;
71
+ -moz-box-sizing: border-box;
72
+ box-sizing: border-box;
73
+ }
74
+
75
+ .envira-gallery-public .envira-gallery-item {
76
+ -webkit-transition-property: -webkit-transform, top, left, opacity;
77
+ -moz-transition-property: -moz-transform, top, left, opacity;
78
+ -ms-transition-property: -ms-transform, top, left, opacity;
79
+ -o-transition-property: -o-transform, top, left, opacity;
80
+ transition-property: transform, top, left, opacity;
81
+ margin-bottom: 10px;
82
+ float: left;
83
+ width: 200px;
84
+ }
85
+
86
+ .envira-gallery-public .envira-gallery-item.envira-item-last {
87
+ margin-right: 0;
88
+ }
89
+
90
+ .envira-gallery-public .envira-gallery-item > .envira-gallery-link {
91
+ display: block;
92
+ outline: none;
93
+ border: 0 none;
94
+ }
95
+
96
+ .envira-gallery-public .envira-gallery-item img {
97
+ display: block;
98
+ max-width: 100%;
99
+ margin: 0 auto;
100
+ opacity: 0;
101
+ transition: opacity .3s ease-in;
102
+ -moz-transition: opacity .3s ease-in;
103
+ -webkit-transition: opacity .3s ease-in;
104
+ -ms-transition: opacity .3s ease-in;
105
+ -o-transition: opacity .3s ease-in;
106
+ }
107
+
108
+ .envira-clear {
109
+ clear: both;
110
+ }
111
+
112
+ .envira-clear:after {
113
+ clear: both;
114
+ content: '.';
115
+ display: block;
116
+ height: 0;
117
+ line-height: 0;
118
+ overflow: auto;
119
+ visibility: hidden;
120
+ zoom: 1;
121
+ }
122
+
123
+ /* ==========================================================================
124
+ Envira Lightbox Gallery Styles
125
+ ========================================================================== */
126
+
127
+ /*
128
+ * FancyBox - jQuery Plugin
129
+ * Simple and fancy lightbox alternative
130
+ *
131
+ * Examples and documentation at: http://fancybox.net
132
+ *
133
+ * Copyright (c) 2008 - 2010 Janis Skarnelis
134
+ * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
135
+ *
136
+ * Version: 1.3.4 (11/11/2010)
137
+ * Requires: jQuery v1.3+
138
+ *
139
+ * Dual licensed under the MIT and GPL licenses:
140
+ * http://www.opensource.org/licenses/mit-license.php
141
+ * http://www.gnu.org/licenses/gpl.html
142
+ */
143
+
144
+ #fancybox-wrap,
145
+ #fancybox-wrap *,
146
+ #fancybox-overlay {
147
+ box-sizing: content-box;
148
+ -webkit-box-sizing: content-box;
149
+ -moz-box-sizing: content-box;
150
+ }
151
+
152
+ #fancybox-loading {
153
+ position: fixed;
154
+ top: 50%;
155
+ left: 50%;
156
+ width: 40px;
157
+ height: 40px;
158
+ margin-top: -20px;
159
+ margin-left: -20px;
160
+ cursor: pointer;
161
+ overflow: hidden;
162
+ z-index: 1104;
163
+ display: none;
164
+ }
165
+
166
+ #fancybox-loading div {
167
+ position: absolute;
168
+ top: 0;
169
+ left: 0;
170
+ width: 40px;
171
+ height: 480px;
172
+ background-image: url('images/fancybox.png');
173
+ }
174
+
175
+ #fancybox-overlay {
176
+ position: absolute;
177
+ top: 0;
178
+ left: 0;
179
+ width: 100%;
180
+ z-index: 1100;
181
+ display: none;
182
+ }
183
+
184
+ #fancybox-tmp {
185
+ padding: 0;
186
+ margin: 0;
187
+ border: 0;
188
+ overflow: auto;
189
+ display: none;
190
+ }
191
+
192
+ #fancybox-wrap {
193
+ position: absolute;
194
+ top: 0;
195
+ left: 0;
196
+ padding: 20px;
197
+ z-index: 1101;
198
+ outline: none;
199
+ display: none;
200
+ }
201
+
202
+ #fancybox-outer {
203
+ position: relative;
204
+ width: 100%;
205
+ height: 100%;
206
+ background: #fff;
207
+ }
208
+
209
+ #fancybox-content {
210
+ width: 0;
211
+ height: 0;
212
+ padding: 0;
213
+ outline: none;
214
+ position: relative;
215
+ overflow: hidden;
216
+ z-index: 1102;
217
+ border: 0px solid #fff;
218
+ }
219
+
220
+ #fancybox-hide-sel-frame {
221
+ position: absolute;
222
+ top: 0;
223
+ left: 0;
224
+ width: 100%;
225
+ height: 100%;
226
+ background: transparent;
227
+ z-index: 1101;
228
+ }
229
+
230
+ #fancybox-close {
231
+ position: absolute;
232
+ top: -15px;
233
+ right: -15px;
234
+ width: 30px;
235
+ height: 30px;
236
+ background: transparent url('images/fancybox.png') -40px 0px;
237
+ cursor: pointer;
238
+ z-index: 1103;
239
+ display: none;
240
+ }
241
+
242
+ #fancybox-error {
243
+ color: #444;
244
+ font: normal 12px/20px Arial;
245
+ padding: 14px;
246
+ margin: 0;
247
+ }
248
+
249
+ #fancybox-img {
250
+ width: 100%;
251
+ height: 100%;
252
+ padding: 0;
253
+ margin: 0;
254
+ border: none;
255
+ outline: none;
256
+ line-height: 0;
257
+ vertical-align: top;
258
+ }
259
+
260
+ #fancybox-frame {
261
+ width: 100%;
262
+ height: 100%;
263
+ border: none;
264
+ display: block;
265
+ }
266
+
267
+ #fancybox-left, #fancybox-right {
268
+ position: absolute;
269
+ bottom: 0px;
270
+ height: 100%;
271
+ width: 35%;
272
+ cursor: pointer;
273
+ outline: none;
274
+ background: transparent url('images/blank.gif');
275
+ z-index: 1102;
276
+ display: none;
277
+ }
278
+
279
+ #fancybox-left {
280
+ left: 0px;
281
+ }
282
+
283
+ #fancybox-right {
284
+ right: 0px;
285
+ }
286
+
287
+ #fancybox-left-ico, #fancybox-right-ico {
288
+ position: absolute;
289
+ top: 50%;
290
+ left: -9999px;
291
+ width: 30px;
292
+ height: 30px;
293
+ margin-top: -15px;
294
+ cursor: pointer;
295
+ z-index: 1102;
296
+ display: block;
297
+ }
298
+
299
+ #fancybox-left-ico {
300
+ background-image: url('images/fancybox.png');
301
+ background-position: -40px -30px;
302
+ }
303
+
304
+ #fancybox-right-ico {
305
+ background-image: url('images/fancybox.png');
306
+ background-position: -40px -60px;
307
+ }
308
+
309
+ #fancybox-left:hover, #fancybox-right:hover {
310
+ visibility: visible; /* IE6 */
311
+ }
312
+
313
+ #fancybox-left:hover span {
314
+ left: 20px;
315
+ }
316
+
317
+ #fancybox-right:hover span {
318
+ left: auto;
319
+ right: 20px;
320
+ }
321
+
322
+ .fancybox-bg {
323
+ position: absolute;
324
+ padding: 0;
325
+ margin: 0;
326
+ border: 0;
327
+ width: 20px;
328
+ height: 20px;
329
+ z-index: 1001;
330
+ }
331
+
332
+ #fancybox-bg-n {
333
+ top: -20px;
334
+ left: 0;
335
+ width: 100%;
336
+ background-image: url('images/fancybox-x.png');
337
+ }
338
+
339
+ #fancybox-bg-ne {
340
+ top: -20px;
341
+ right: -20px;
342
+ background-image: url('images/fancybox.png');
343
+ background-position: -40px -162px;
344
+ }
345
+
346
+ #fancybox-bg-e {
347
+ top: 0;
348
+ right: -20px;
349
+ height: 100%;
350
+ background-image: url('images/fancybox-y.png');
351
+ background-position: -20px 0px;
352
+ }
353
+
354
+ #fancybox-bg-se {
355
+ bottom: -20px;
356
+ right: -20px;
357
+ background-image: url('images/fancybox.png');
358
+ background-position: -40px -182px;
359
+ }
360
+
361
+ #fancybox-bg-s {
362
+ bottom: -20px;
363
+ left: 0;
364
+ width: 100%;
365
+ background-image: url('images/fancybox-x.png');
366
+ background-position: 0px -20px;
367
+ }
368
+
369
+ #fancybox-bg-sw {
370
+ bottom: -20px;
371
+ left: -20px;
372
+ background-image: url('images/fancybox.png');
373
+ background-position: -40px -142px;
374
+ }
375
+
376
+ #fancybox-bg-w {
377
+ top: 0;
378
+ left: -20px;
379
+ height: 100%;
380
+ background-image: url('images/fancybox-y.png');
381
+ }
382
+
383
+ #fancybox-bg-nw {
384
+ top: -20px;
385
+ left: -20px;
386
+ background-image: url('images/fancybox.png');
387
+ background-position: -40px -122px;
388
+ }
389
+
390
+ #fancybox-title {
391
+ font-family: Helvetica;
392
+ font-size: 12px;
393
+ z-index: 1102;
394
+ }
395
+
396
+ .fancybox-title-inside {
397
+ padding-bottom: 10px;
398
+ text-align: center;
399
+ color: #333;
400
+ background: #fff;
401
+ position: relative;
402
+ }
403
+
404
+ .fancybox-title-outside {
405
+ padding-top: 10px;
406
+ color: #fff;
407
+ }
408
+
409
+ .fancybox-title-over {
410
+ position: absolute;
411
+ bottom: 0;
412
+ left: 0;
413
+ color: #FFF;
414
+ text-align: left;
415
+ }
416
+
417
+ #fancybox-title-over {
418
+ padding: 10px;
419
+ background-image: url('images/fancy_title_over.png');
420
+ display: block;
421
+ }
422
+
423
+ .fancybox-title-float {
424
+ position: absolute;
425
+ left: 0;
426
+ bottom: -20px;
427
+ height: 32px;
428
+ }
429
+
430
+ #fancybox-title-float-wrap {
431
+ border: none;
432
+ border-collapse: collapse;
433
+ width: auto;
434
+ }
435
+
436
+ #fancybox-title-float-wrap tbody,
437
+ #fancybox-title-float-wrap td {
438
+ border: none;
439
+ white-space: nowrap;
440
+ }
441
+
442
+ #fancybox-title-float-left {
443
+ padding: 0 0 0 15px;
444
+ background: url('images/fancybox.png') -40px -90px no-repeat;
445
+ }
446
+
447
+ #fancybox-title-float-main {
448
+ color: #FFF;
449
+ line-height: 29px;
450
+ font-weight: bold;
451
+ padding: 0 0 3px 0;
452
+ background: url('images/fancybox-x.png') 0px -40px;
453
+ }
454
+
455
+ #fancybox-title-float-right {
456
+ padding: 0 0 0 15px;
457
+ background: url('images/fancybox.png') -55px -90px no-repeat;
458
+ }
459
+
460
+ /* IE6 */
461
+
462
+ .fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_close.png', sizingMethod='scale'); }
463
+
464
+ .fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_nav_left.png', sizingMethod='scale'); }
465
+ .fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_nav_right.png', sizingMethod='scale'); }
466
+
467
+ .fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
468
+ .fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_title_left.png', sizingMethod='scale'); }
469
+ .fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_title_main.png', sizingMethod='scale'); }
470
+ .fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_title_right.png', sizingMethod='scale'); }
471
+
472
+ .fancybox-ie6 #fancybox-bg-w, .fancybox-ie6 #fancybox-bg-e, .fancybox-ie6 #fancybox-left, .fancybox-ie6 #fancybox-right, #fancybox-hide-sel-frame {
473
+ height: expression(this.parentNode.clientHeight + "px");
474
+ }
475
+
476
+ #fancybox-loading.fancybox-ie6 {
477
+ position: absolute; margin-top: 0;
478
+ top: expression( (-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px');
479
+ }
480
+
481
+ #fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_loading.png', sizingMethod='scale'); }
482
+
483
+ /* IE6, IE7, IE8 */
484
+
485
+ .fancybox-ie .fancybox-bg { background: transparent !important; }
486
+
487
+ .fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
488
+ .fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
489
+ .fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
490
+ .fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
491
+ .fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
492
+ .fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
493
+ .fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
494
+ .fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }
495
+
496
+ /* Retina stuff */
497
+ @media
498
+ only screen and (-webkit-min-device-pixel-ratio: 2),
499
+ only screen and ( min--moz-device-pixel-ratio: 2),
500
+ only screen and ( -o-min-device-pixel-ratio: 2/1),
501
+ only screen and ( min-device-pixel-ratio: 2),
502
+ only screen and ( min-resolution: 192dpi),
503
+ only screen and ( min-resolution: 2dppx) {
504
+
505
+ .envira-gallery-wrap {
506
+ background-image: url('images/preloader@2x.gif');
507
+ background-size: 16px 16px;
508
+ }
509
+
510
+ }
assets/css/images/blank.gif ADDED
Binary file
assets/css/images/delete.png ADDED
Binary file
assets/css/images/delete@2x.png ADDED
Binary file
assets/css/images/fancy_close.png ADDED
Binary file
assets/css/images/fancy_loading.png ADDED
Binary file
assets/css/images/fancy_nav_left.png ADDED
Binary file
assets/css/images/fancy_nav_right.png ADDED
Binary file
assets/css/images/fancy_shadow_e.png ADDED
Binary file
assets/css/images/fancy_shadow_n.png ADDED
Binary file
assets/css/images/fancy_shadow_ne.png ADDED
Binary file
assets/css/images/fancy_shadow_nw.png ADDED
Binary file
assets/css/images/fancy_shadow_s.png ADDED
Binary file
assets/css/images/fancy_shadow_se.png ADDED
Binary file
assets/css/images/fancy_shadow_sw.png ADDED
Binary file
assets/css/images/fancy_shadow_w.png ADDED
Binary file
assets/css/images/fancy_title_left.png ADDED
Binary file
assets/css/images/fancy_title_main.png ADDED
Binary file
assets/css/images/fancy_title_over.png ADDED
Binary file
assets/css/images/fancy_title_right.png ADDED
Binary file
assets/css/images/fancybox-x.png ADDED
Binary file
assets/css/images/fancybox-y.png ADDED
Binary file
assets/css/images/fancybox.png ADDED
Binary file
assets/css/images/holder.gif ADDED
Binary file
assets/css/images/menu-icon.png ADDED
Binary file
assets/css/images/menu-icon@2x.png ADDED
Binary file
assets/css/images/meta-active.png ADDED
Binary file
assets/css/images/meta-active@2x.png ADDED
Binary file
assets/css/images/meta.png ADDED
Binary file
assets/css/images/meta@2x.png ADDED
Binary file
assets/css/images/modify.png ADDED
Binary file
assets/css/images/modify@2x.png ADDED
Binary file
assets/css/images/preloader.gif ADDED
Binary file
assets/css/images/preloader@2x.gif ADDED
Binary file
assets/css/metabox.css ADDED
@@ -0,0 +1,503 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ==========================================================================
2
+ Metabox Styles
3
+ ========================================================================== */
4
+
5
+ .envira-gallery-spinner {
6
+ float: none;
7
+ display: inline-block;
8
+ margin-top: 0;
9
+ }
10
+
11
+ #envira-gallery {
12
+ position: relative;
13
+ }
14
+
15
+ #envira-gallery .envira-clear {
16
+ clear: both;
17
+ }
18
+
19
+ #envira-gallery .envira-clear:after {
20
+ clear: both;
21
+ content: '.';
22
+ display: block;
23
+ height: 0;
24
+ line-height: 0;
25
+ overflow: auto;
26
+ visibility: hidden;
27
+ zoom: 1;
28
+ }
29
+
30
+ #envira-gallery p.description {
31
+ font-size: 13px;
32
+ }
33
+
34
+ #envira-gallery .inside {
35
+ margin: 10px 0;
36
+ padding: 0 10px;
37
+ }
38
+
39
+ #envira-gallery #envira-tabs {
40
+ position: relative;
41
+ }
42
+
43
+ #envira-gallery #envira-tabs-nav {
44
+ list-style: none;
45
+ margin: 0 0 10px;
46
+ padding: 0;
47
+ border-bottom: 1px solid #cecece;
48
+ }
49
+
50
+ #envira-gallery #envira-tabs-nav li {
51
+ float: left;
52
+ margin: 0 10px -1px 0;
53
+ }
54
+
55
+ #envira-gallery #envira-tabs-nav li a {
56
+ display: block;
57
+ padding: 7px 10px 5px;
58
+ font-size: 14px;
59
+ color: #aaa;
60
+ font-weight: 300;
61
+ text-decoration: none;
62
+ outline: none;
63
+ }
64
+
65
+ #envira-gallery #envira-tabs-nav li.envira-active a {
66
+ border: 1px solid #cecece;
67
+ border-bottom-color: #fff;
68
+ -moz-border-radius: 3px 3px 0 0;
69
+ -webkit-border-radius: 3px 3px 0 0;
70
+ border-radius: 3px 3px 0 0;
71
+ color: #21759b;
72
+ padding-top: 6px;
73
+ }
74
+
75
+ #envira-gallery #envira-tabs-nav li a:hover {
76
+ color: #21759b;
77
+ }
78
+
79
+ #envira-gallery .envira-meta-close-text {
80
+ display: none;
81
+ color: #fff;
82
+ font-style: italic;
83
+ font-size: 11px;
84
+ position: absolute;
85
+ z-index: 98;
86
+ top: 6px;
87
+ right: 27px;
88
+ }
89
+
90
+ #envira-gallery .envira-helper-active .envira-meta-close-text {
91
+ display: inline;
92
+ }
93
+
94
+ #envira-gallery .envira-meta-icon {
95
+ position: absolute;
96
+ width: 19px;
97
+ height: 16px;
98
+ top: 6px;
99
+ right: 0;
100
+ background: url(images/meta.png) no-repeat scroll 0 0;
101
+ display: block;
102
+ outline: none;
103
+ z-index: 98;
104
+ }
105
+
106
+ #envira-gallery .envira-helper-active .envira-meta-icon {
107
+ background-image: url(images/meta-active.png);
108
+ }
109
+
110
+ #envira-gallery .envira-meta-information {
111
+ display: none;
112
+ padding: 0 1em 1em;
113
+ position: absolute;
114
+ right: 0;
115
+ top: 30px;
116
+ width: 278px;
117
+ background: #fff;
118
+ border: 1px solid #e5e5e5;
119
+ -webkit-box-shadow: 0 5px 15px rgba(0,0,0,.7);
120
+ box-shadow: 0 5px 15px rgba(0,0,0,.7);
121
+ z-index: 98;
122
+ }
123
+
124
+ #envira-gallery .envira-helper-active .envira-meta-information {
125
+ display: block;
126
+ }
127
+
128
+ #envira-gallery .envira-meta-helper-overlay {
129
+ position: absolute;
130
+ z-index: 97;
131
+ background: #000;
132
+ opacity: .7;
133
+ filter: alpha(opacity=70);
134
+ width: 100%;
135
+ height: 100%;
136
+ }
137
+
138
+ #envira-gallery .envira-tab {
139
+ display: none;
140
+ }
141
+
142
+ #envira-gallery .envira-tab.envira-active {
143
+ display: block;
144
+ }
145
+
146
+ #envira-gallery .envira-tab p.envira-intro {
147
+ margin: 1.5em 0 .5em;
148
+ }
149
+
150
+ #envira-gallery .envira-tab th,
151
+ #envira-gallery .envira-tab input[type="text"],
152
+ #envira-gallery .envira-tab input[type="number"],
153
+ #envira-gallery .envira-tab input[type="password"],
154
+ #envira-gallery .envira-tab select {
155
+ width: 210px;
156
+ padding-right: 0;
157
+ }
158
+
159
+ #envira-gallery .envira-progress-bar {
160
+ display: none;
161
+ width: 100%;
162
+ position: relative;
163
+ height: 10px;
164
+ width: 100%;
165
+ margin: 10px auto;
166
+ border-radius: 10px;
167
+ background: #dfdfdf;
168
+ background: rgba(0,0,0,.1);
169
+ }
170
+
171
+ #envira-gallery .envira-progress-bar div {
172
+ height: 10px;
173
+ min-width: 20px;
174
+ width: 0;
175
+ background: #aaa;
176
+ background: rgba(0,0,0,.2);
177
+ border-radius: 10px;
178
+ -webkit-transition: width 300ms;
179
+ -moz-transition: width 300ms;
180
+ -ms-transition: width 300ms;
181
+ -o-transition: width 300ms;
182
+ transition: width 300ms;
183
+ }
184
+
185
+ #envira-gallery .upload-flash-bypass {
186
+ display: none;
187
+ }
188
+
189
+ #envira-gallery .max-upload-size {
190
+ display: block;
191
+ margin: 10px 0;
192
+ }
193
+
194
+ #envira-gallery .envira-tab {
195
+ min-height: 320px;
196
+ }
197
+
198
+ #envira-gallery #envira-gallery-output {
199
+ margin: 20px 0 10px;
200
+ padding: 0;
201
+ list-style: none;
202
+ }
203
+
204
+ #envira-gallery #envira-gallery-output li {
205
+ background: #fff;
206
+ display: block;
207
+ float: left;
208
+ margin: 0 10px 10px 0;
209
+ padding: 4px;
210
+ list-style: none;
211
+ border: 1px solid #cecece;
212
+ -moz-border-radius: 3px;
213
+ -webkit-border-radius: 3px;
214
+ border-radius: 3px;
215
+ -moz-background-clip: padding;
216
+ -webkit-background-clip: padding-box;
217
+ background-clip: padding-box;
218
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,.06);
219
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.06);
220
+ box-shadow: 0 1px 2px rgba(0,0,0,.06);
221
+ cursor: move;
222
+ position: relative;
223
+ width: 150px;
224
+ height: 150px;
225
+ }
226
+
227
+ #envira-gallery #envira-gallery-output li.envira-gallery-status-pending {
228
+ background-color: #faebcc;
229
+ border-color: #8a6d3b;
230
+ }
231
+
232
+ #envira-gallery #envira-gallery-output li.envira-gallery-status-active {
233
+ background-color: #dff0d8;
234
+ border-color: #3c763d;
235
+ }
236
+
237
+ #envira-gallery #envira-gallery-output li.dropzone {
238
+ background: transparent;
239
+ border: 1px dashed #d5d5d5;
240
+ -moz-box-shadow: none;
241
+ -webkit-box-shadow: none;
242
+ box-shadow: none;
243
+ }
244
+
245
+ #envira-gallery #envira-gallery-output li img {
246
+ display: block;
247
+ margin: auto;
248
+ position: absolute;
249
+ top: 0;
250
+ left: 0;
251
+ right: 0;
252
+ bottom: 0;
253
+ max-width: 150px;
254
+ max-height: 150px;
255
+ }
256
+
257
+ #envira-gallery #envira-gallery-output li .envira-gallery-remove-image {
258
+ background: url(images/delete.png) no-repeat scroll 0 0;
259
+ display: block;
260
+ height: 16px;
261
+ left: -8px;
262
+ outline: none;
263
+ position: absolute;
264
+ top: -8px;
265
+ width: 16px;
266
+ z-index: 20;
267
+ }
268
+
269
+ #envira-gallery #envira-gallery-output li .envira-gallery-modify-image {
270
+ background: url(images/modify.png) no-repeat scroll 0 0;
271
+ display: block;
272
+ height: 16px;
273
+ left: 12px;
274
+ outline: none;
275
+ position: absolute;
276
+ top: -8px;
277
+ width: 16px;
278
+ z-index: 20;
279
+ }
280
+
281
+ #media-items .media-item .edit-attachment,
282
+ .envira-gallery-media-frame .upload-flash-bypass {
283
+ display: none !important;
284
+ }
285
+
286
+ #media-items {
287
+ margin: 0 0 16px;
288
+ overflow: hidden;
289
+ width: 100%;
290
+ }
291
+
292
+ #media-items .media-item {
293
+ width: auto;
294
+ float: left;
295
+ margin: 0 8px 8px 0;
296
+ }
297
+
298
+ #media-items .media-item img {
299
+ max-width: 150px;
300
+ max-height: 150px;
301
+ float: none;
302
+ margin: 4px;
303
+ display: block;
304
+ }
305
+
306
+ .envira-gallery-gallery {
307
+ padding-left: 7px;
308
+ }
309
+
310
+ .envira-gallery-gallery .attachment {
311
+ margin: 8px;
312
+ }
313
+
314
+ .envira-gallery-gallery .attachment-preview,
315
+ .envira-gallery-gallery .attachment-preview .thumbnail {
316
+ max-width: 150px;
317
+ max-height: 150px;
318
+ }
319
+
320
+ .envira-gallery-media-frame .max-upload-size {
321
+ display: block;
322
+ margin: 1em 0;
323
+ }
324
+
325
+ .envira-gallery-media-frame .envira-gallery-library-toolbar {
326
+ top: 5px;
327
+ }
328
+
329
+ .envira-gallery-media-frame .attachment.envira-gallery-in-gallery {
330
+ box-shadow: 0 0 0 1px #fff, 0 0 0 5px #519e0c;
331
+ }
332
+
333
+ .envira-gallery-media-frame .attachment.envira-gallery-in-gallery .attachment-preview,
334
+ .envira-gallery-media-frame .attachment.envira-gallery-in-gallery .attachment-preview .check {
335
+ cursor: default;
336
+ }
337
+
338
+ .envira-gallery-media-frame .attachment.envira-gallery-in-gallery .check {
339
+ box-shadow: 0 0 0 1px #519e0c;
340
+ background: #519e0c;
341
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#519e0c), to(#519e0c));
342
+ background-image: -webkit-linear-gradient(top, #519e0c, #407f08);
343
+ background-image: -moz-linear-gradient(top, #519e0c, #407f08);
344
+ background-image: -o-linear-gradient(top, #519e0c, #407f08);
345
+ background-image: linear-gradient(to bottom, #519e0c, #407f08);
346
+ }
347
+
348
+ .envira-gallery-media-frame .attachment.envira-gallery-in-gallery .check div,
349
+ .envira-gallery-media-frame .attachment.envira-gallery-in-gallery .check:hover div {
350
+ background-position: -21px 0;
351
+ }
352
+
353
+ .envira-gallery-meta-wrap .envira-gallery-meta-sidebar {
354
+ overflow: auto;
355
+ position: relative;
356
+ }
357
+
358
+ .envira-gallery-media-frame .media-sidebar h3 {
359
+ margin: 1.1em 0 1em;
360
+ }
361
+
362
+ .envira-gallery-media-frame .media-sidebar p {
363
+ margin: 0 0 1.5em;
364
+ }
365
+
366
+ .envira-gallery-meta {
367
+ overflow: auto;
368
+ padding: 0 16px;
369
+ }
370
+
371
+ .media-frame.envira-gallery-media-frame input:focus,
372
+ .media-frame.envira-gallery-media-frame textarea:focus,
373
+ .media-frame.envira-gallery-media-frame select:focus {
374
+ border-color: #aaa;
375
+ }
376
+
377
+ .envira-gallery-meta-wrap .envira-gallery-meta.attachments {
378
+ top: 0;
379
+ }
380
+
381
+ .envira-gallery-ui-content {
382
+ top: 16px !important;
383
+ }
384
+
385
+ .envira-gallery-meta-wrap .form-table {
386
+ margin: 0;
387
+ }
388
+
389
+ .envira-gallery-meta-wrap .form-table input[type=text],
390
+ .envira-gallery-meta-wrap .form-table textarea {
391
+ width: 100%;
392
+ }
393
+
394
+ #envira-gallery .envira-gallery-import-form {
395
+ margin-bottom: 20px;
396
+ padding-bottom: 20px;
397
+ border-bottom: 1px solid #ddd;
398
+ }
399
+
400
+ #envira-gallery .envira-unit {
401
+ font-style: normal;
402
+ font-weight: 700;
403
+ font-size: 13px;
404
+ }
405
+
406
+ #envira-gallery textarea {
407
+ width: 100%;
408
+ }
409
+
410
+ .envira-alert {
411
+ padding: 15px;
412
+ margin-bottom: 20px;
413
+ border: 1px solid #faebcc;
414
+ border-radius: 4px;
415
+ background-color: #fcf8e3;
416
+ color: #8a6d3b;
417
+ }
418
+
419
+ /* ==========================================================================
420
+ Plupload Styles
421
+ ========================================================================== */
422
+
423
+ #envira-gallery-plupload-upload-ui {
424
+ position: relative;
425
+ }
426
+
427
+ #envira-gallery-drag-drop-area {
428
+ border: 4px dashed #bbb;
429
+ height: 200px;
430
+ }
431
+
432
+ #envira-gallery-plupload-upload-ui.drag-over #envira-gallery-drag-drop-area {
433
+ border-color: #83b4d8;
434
+ }
435
+
436
+ #envira-gallery .envira-gallery-progress-bar {
437
+ display: none;
438
+ width: 100%;
439
+ position: relative;
440
+ height: 10px;
441
+ width: 100%;
442
+ margin: 10px auto;
443
+ border-radius: 10px;
444
+ background: #dfdfdf;
445
+ background: rgba(0,0,0,.1);
446
+ }
447
+
448
+ #envira-gallery .envira-gallery-progress-bar div {
449
+ height: 10px;
450
+ min-width: 20px;
451
+ width: 0;
452
+ background: #aaa;
453
+ background: rgba(0,0,0,.2);
454
+ border-radius: 10px;
455
+ -webkit-transition: width 300ms;
456
+ -moz-transition: width 300ms;
457
+ -ms-transition: width 300ms;
458
+ -o-transition: width 300ms;
459
+ transition: width 300ms;
460
+ }
461
+
462
+ #envira-gallery .upload-flash-bypass {
463
+ display: none;
464
+ }
465
+
466
+ #envira-gallery .max-upload-size {
467
+ display: block;
468
+ margin: 10px 0;
469
+ }
470
+
471
+ /* ==========================================================================
472
+ Retina Styles
473
+ ========================================================================== */
474
+
475
+ @media
476
+ only screen and (-webkit-min-device-pixel-ratio: 2),
477
+ only screen and ( min--moz-device-pixel-ratio: 2),
478
+ only screen and ( -o-min-device-pixel-ratio: 2/1),
479
+ only screen and ( min-device-pixel-ratio: 2),
480
+ only screen and ( min-resolution: 192dpi),
481
+ only screen and ( min-resolution: 2dppx) {
482
+
483
+ #envira-gallery .envira-meta-icon {
484
+ background-image: url(images/meta@2x.png);
485
+ background-size: 19px 16px;
486
+ }
487
+
488
+ #envira-gallery .envira-helper-active .envira-meta-icon {
489
+ background-image: url(images/meta-active@2x.png);
490
+ background-size: 19px 16px;
491
+ }
492
+
493
+ #envira-gallery #envira-gallery-output li .envira-gallery-remove-image {
494
+ background-image: url(images/delete@2x.png);
495
+ background-size: 16px 16px;
496
+ }
497
+
498
+ #envira-gallery #envira-gallery-output li .envira-gallery-modify-image {
499
+ background-image: url(images/modify@2x.png);
500
+ background-size: 16px 16px;
501
+ }
502
+
503
+ }
assets/js/editor.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ==========================================================
2
+ * editor.js
3
+ * http://enviragallery.com/
4
+ *
5
+ * This file can be used by 3rd party plugins to integrate
6
+ * with their custom field systems. It allows the selection
7
+ * process to be standardized so that 3rd party plugins can
8
+ * trigger modal selection windows and receive the corresponding
9
+ * selected data objects.
10
+ *
11
+ * Using this file requires three actions for the 3rd party plugin.
12
+ *
13
+ * 1. The media modal HTML output needs to be inserted directly
14
+ * after the option/dropdown/button that is to be used to
15
+ * trigger the modal. This can be done by placing the following
16
+ * code after the output (first to return, latter to echo):
17
+ *
18
+ * Envira_Gallery_Editor::get_instance()->gallery_selection_modal();
19
+ *
20
+ * 2. This file should be enqueued on the page where the field resides.
21
+ * You should add the class ".envira-gallery-modal-trigger" to the
22
+ * option/dropdown/button that will trigger the modal. This will
23
+ * be used as a reference point for showing, hiding and passing data
24
+ * between the modal and your plugin.
25
+ *
26
+ * 3. Attaching to a global event that is fired once the data for the
27
+ * selection has been retrieved. You should listen on the document
28
+ * object for the "enviraGalleryModalData" event, like this:
29
+ *
30
+ * $(document).on("enviraGalleryModalData", function(e){
31
+ * console.log(e.gallery);
32
+ * });
33
+ *
34
+ * This will give you access to the entire array of gallery data that
35
+ * the user has selected, including ID, title, slug and settings.
36
+ * ==========================================================
37
+ * Copyright 2013 Thomas Griffin.
38
+ *
39
+ * Licensed under the GPL License, Version 2.0 or later (the "License");
40
+ * you may not use this file except in compliance with the License.
41
+ * You may obtain a copy of the License at
42
+ *
43
+ * http://www.gnu.org/licenses/gpl-2.0.html
44
+ *
45
+ * Unless required by applicable law or agreed to in writing, software
46
+ * distributed under the License is distributed on an "AS IS" BASIS,
47
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
+ * See the License for the specific language governing permissions and
49
+ * limitations under the License.
50
+ * ========================================================== */
51
+ ;(function($){
52
+ $(function(){
53
+ // Close the modal window on user action.
54
+ var envira_trigger_target = envira_editor_frame = false;
55
+ var envira_append_and_hide = function(e){
56
+ e.preventDefault();
57
+ $('.envira-gallery-default-ui .selected').removeClass('details selected');
58
+ $('.envira-gallery-default-ui').appendTo('.envira-gallery-default-ui-wrapper').hide();
59
+ envira_trigger_target = envira_editor_frame = false;
60
+ };
61
+
62
+ $(document).on('click', '.envira-gallery-choose-gallery, .envira-gallery-modal-trigger', function(e){
63
+ e.preventDefault();
64
+
65
+ // Store the trigger target.
66
+ envira_trigger_target = e.target;
67
+
68
+ // Show the modal.
69
+ envira_editor_frame = true;
70
+ $('.envira-gallery-default-ui').appendTo('body').show();
71
+
72
+ $(document).on('click', '.media-modal-close, .media-modal-backdrop, .envira-gallery-cancel-insertion', envira_append_and_hide);
73
+ $(document).on('keydown', function(e){
74
+ if ( 27 == e.keyCode && envira_editor_frame ) {
75
+ envira_append_and_hide(e);
76
+ }
77
+ });
78
+ });
79
+
80
+ $(document).on('click', '.envira-gallery-default-ui .thumbnail, .envira-gallery-default-ui .check, .envira-gallery-default-ui .media-modal-icon', function(e){
81
+ e.preventDefault();
82
+ if ( $(this).parent().parent().hasClass('selected') ) {
83
+ $(this).parent().parent().removeClass('details selected');
84
+ $('.envira-gallery-insert-gallery').attr('disabled', 'disabled');
85
+ } else {
86
+ $(this).parent().parent().parent().find('.selected').removeClass('details selected');
87
+ $(this).parent().parent().addClass('details selected');
88
+ $('.envira-gallery-insert-gallery').removeAttr('disabled');
89
+ }
90
+ });
91
+
92
+ $(document).on('click', '.envira-gallery-default-ui .check', function(e){
93
+ e.preventDefault();
94
+ $(this).parent().parent().removeClass('details selected');
95
+ $('.envira-gallery-insert-gallery').attr('disabled', 'disabled');
96
+ });
97
+
98
+ $(document).on('click', '.envira-gallery-default-ui .envira-gallery-insert-gallery', function(e){
99
+ e.preventDefault();
100
+
101
+ // Either insert into an editor or make an ajax request.
102
+ if ( $(envira_trigger_target).hasClass('envira-gallery-choose-gallery') ) {
103
+ wp.media.editor.insert('[envira-gallery id="' + $('.envira-gallery-default-ui .selected').data('envira-gallery-id') + '"]');
104
+ } else {
105
+ // Make the ajax request.
106
+ var req_data = {
107
+ action: 'envira_gallery_load_gallery_data',
108
+ id: $('.envira-gallery-default-ui:first .selected').data('envira-gallery-id')
109
+ };
110
+ $.post(ajaxurl, req_data, function(res){
111
+ // Trigger the event.
112
+ $(document).trigger({ type: 'enviraGalleryModalData', gallery: res });
113
+
114
+ // Close the modal.
115
+ envira_append_and_hide(e);
116
+ }, 'json');
117
+ }
118
+
119
+ // Hide the modal.
120
+ envira_append_and_hide(e);
121
+ });
122
+ });
123
+ }(jQuery));
assets/js/envira-dev-holder.js ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Needed functions.
2
+ function enviraGetColWidth(container, gutter) {
3
+ var width,
4
+ windowWidth = $(window).width(),
5
+ numColumns = container.data('envira-columns');
6
+
7
+ switch(numColumns){
8
+ case 1 :
9
+ width = container.width();
10
+ break;
11
+ case 2 :
12
+ if ( windowWidth <= 480 ) {
13
+ width = container.width();
14
+ } else {
15
+ width = container.width() / 2;
16
+ }
17
+ break;
18
+ case 3 :
19
+ if ( windowWidth <= 480 ) {
20
+ width = container.width();
21
+ } else if ( windowWidth <= 768 ) {
22
+ width = container.width() / 2;
23
+ } else {
24
+ width = container.width() / 3;
25
+ }
26
+ case 4 :
27
+ case 5 :
28
+ case 6 :
29
+ if ( windowWidth <= 480 ) {
30
+ width = container.width();
31
+ } else if ( windowWidth <= 768 ) {
32
+ width = container.width() / 2;
33
+ } else if ( windowWidth <= 1024 ) {
34
+ width = container.width() / 3;
35
+ } else {
36
+ width = container.width() / numColumns;
37
+ }
38
+ break;
39
+ }
40
+
41
+ return parseInt(width - (gutter*(numColumns-1))/numColumns);
42
+ }
43
+
44
+ function enviraSetWidths(container, gutter) {
45
+ var colWidth = enviraGetColWidth(container, gutter);
46
+ container.children().css({ width: colWidth });
47
+ }
48
+
49
+ // Custom Isotope extensions.
50
+ $.Isotope.prototype._getMasonryGutterColumns = function() {
51
+ var gutter = this.options.masonry && this.options.masonry.gutterWidth || 0;
52
+ containerWidth = this.element.width();
53
+
54
+ this.masonry.columnWidth = this.options.masonry && this.options.masonry.columnWidth ||
55
+ // Or use the size of the first item
56
+ this.$filteredAtoms.outerWidth(true) ||
57
+ // If there's no items, use size of container
58
+ containerWidth;
59
+
60
+ this.masonry.columnWidth += gutter;
61
+
62
+ this.masonry.cols = Math.floor((containerWidth + gutter) / this.masonry.columnWidth);
63
+ this.masonry.cols = Math.max(this.masonry.cols, 1);
64
+ };
65
+
66
+ $.Isotope.prototype._masonryReset = function() {
67
+ // Layout-specific props
68
+ this.masonry = {};
69
+ // FIXME shouldn't have to call this again
70
+ this._getMasonryGutterColumns();
71
+ var i = this.masonry.cols;
72
+ this.masonry.colYs = [];
73
+ while (i--) {
74
+ this.masonry.colYs.push(0);
75
+ }
76
+ };
77
+
78
+ $.Isotope.prototype._masonryResizeChanged = function() {
79
+ var prevSegments = this.masonry.cols;
80
+ // Update cols/rows
81
+ this._getMasonryGutterColumns();
82
+ // Return if updated cols/rows is not equal to previous
83
+ return (this.masonry.cols !== prevSegments);
84
+ };
85
+
86
+ function enviraThrottle(func, wait) {
87
+ return function() {
88
+ var that = this,
89
+ args = [].slice(arguments);
90
+
91
+ clearTimeout(func._throttleTimeout);
92
+
93
+ func._throttleTimeout = setTimeout(function() {
94
+ func.apply(that, args);
95
+ }, wait);
96
+ };
97
+ }
assets/js/envira.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Isotope 1.5.26.
2
+ ;(function(n,f,i){var s=n.document;var w=s.documentElement;var k=n.Modernizr;var p=function(z){return z.charAt(0).toUpperCase()+z.slice(1)};var u="Moz Webkit O Ms".split(" ");var o=function(D){var C=w.style,A;if(typeof C[D]==="string"){return D}D=p(D);for(var B=0,z=u.length;B<z;B++){A=u[B]+D;if(typeof C[A]==="string"){return A}}};var c=o("transform"),v=o("transitionProperty");
3
+ ;var j={csstransforms:function(){return !!c},csstransforms3d:function(){var B=!!o("perspective");if(B&&"webkitPerspective" in w.style){var A=f("<style>@media (transform-3d),(-webkit-transform-3d){#modernizr{height:3px}}</style>").appendTo("head"),z=f('<div id="modernizr" />').appendTo("html");B=z.height()===3;z.remove();A.remove()}return B},csstransitions:function(){return !!v}};var m;if(k){for(m in j){if(!k.hasOwnProperty(m)){k.addTest(m,j[m])}}}else{k=n.Modernizr={_version:"1.6ish: miniModernizr for Isotope"};var y=" ";var q;for(m in j){q=j[m]();k[m]=q;y+=" "+(q?"":"no-")+m}f("html").addClass(y)}if(k.csstransforms){var e=k.csstransforms3d?{translate:function(z){return"translate3d("+z[0]+"px, "+z[1]+"px, 0) "},scale:function(z){return"scale3d("+z+", "+z+", 1) "}}:{translate:function(z){return"translate("+z[0]+"px, "+z[1]+"px) "},scale:function(z){return"scale("+z+") "}};var t=function(C,A,H){var F=f.data(C,"isoTransform")||{},J={},B,D={},G;J[A]=H;f.extend(F,J);for(B in F){G=F[B];D[B]=e[B](G)}var E=D.translate||"",I=D.scale||"",z=E+I;f.data(C,"isoTransform",F);C.style[c]=z};f.cssNumber.scale=true;f.cssHooks.scale={set:function(z,A){t(z,"scale",A)},get:function(B,A){var z=f.data(B,"isoTransform");return z&&z.scale?z.scale:1}};f.fx.step.scale=function(z){f.cssHooks.scale.set(z.elem,z.now+z.unit)};f.cssNumber.translate=true;f.cssHooks.translate={set:function(z,A){t(z,"translate",A)},get:function(B,A){var z=f.data(B,"isoTransform");return z&&z.translate?z.translate:[0,0]}}}var b,a;if(k.csstransitions){b={WebkitTransitionProperty:"webkitTransitionEnd",MozTransitionProperty:"transitionend",OTransitionProperty:"oTransitionEnd otransitionend",transitionProperty:"transitionend"}[v];a=o("transitionDuration")}var l=f.event,h=f.event.handle?"handle":"dispatch",d;l.special.smartresize={setup:function(){f(this).bind("resize",l.special.smartresize.handler)},teardown:function(){f(this).unbind("resize",l.special.smartresize.handler)},handler:function(C,z){var B=this,A=arguments;C.type="smartresize";if(d){clearTimeout(d)}d=setTimeout(function(){l[h].apply(B,A)},z==="execAsap"?0:100)}};f.fn.smartresize=function(z){return z?this.bind("smartresize",z):this.trigger("smartresize",["execAsap"])};f.Isotope=function(z,A,B){this.element=f(A);this._create(z);this._init(B)};var g=["width","height"];var r=f(n);f.Isotope.settings={resizable:true,layoutMode:"masonry",containerClass:"isotope",itemClass:"isotope-item",hiddenClass:"isotope-hidden",hiddenStyle:{opacity:0,scale:0.001},visibleStyle:{opacity:1,scale:1},containerStyle:{position:"relative",overflow:"hidden"},animationEngine:"best-available",animationOptions:{queue:false,duration:800},sortBy:"original-order",sortAscending:true,resizesContainer:true,transformsEnabled:true,itemPositionDataEnabled:false};f.Isotope.prototype={_create:function(E){this.options=f.extend({},f.Isotope.settings,E);this.styleQueue=[];this.elemCount=0;var C=this.element[0].style;this.originalStyle={};var B=g.slice(0);for(var G in this.options.containerStyle){B.push(G)}for(var F=0,A=B.length;F<A;F++){G=B[F];this.originalStyle[G]=C[G]||""}this.element.css(this.options.containerStyle);this._updateAnimationEngine();this._updateUsingTransforms();var D={"original-order":function(I,H){H.elemCount++;return H.elemCount},random:function(){return Math.random()}};this.options.getSortData=f.extend(this.options.getSortData,D);this.reloadItems();this.offset={left:parseInt((this.element.css("padding-left")||0),10),top:parseInt((this.element.css("padding-top")||0),10)};var z=this;setTimeout(function(){z.element.addClass(z.options.containerClass)},0);if(this.options.resizable){r.bind("smartresize.isotope",function(){z.resize()})}this.element.delegate("."+this.options.hiddenClass,"click",function(){return false})},_getAtoms:function(C){var z=this.options.itemSelector,B=z?C.filter(z).add(C.find(z)):C,A={position:"absolute"};B=B.filter(function(D,E){return E.nodeType===1});if(this.usingTransforms){A.left=0;A.top=0}B.css(A).addClass(this.options.itemClass);this.updateSortData(B,true);return B},_init:function(z){this.$filteredAtoms=this._filter(this.$allAtoms);this._sort();this.reLayout(z)},option:function(B){if(f.isPlainObject(B)){this.options=f.extend(true,this.options,B);var z;for(var A in B){z="_update"+p(A);if(this[z]){this[z]()}}}},_updateAnimationEngine:function(){var A=this.options.animationEngine.toLowerCase().replace(/[ _\-]/g,"");var z;switch(A){case"css":case"none":z=false;break;case"jquery":z=true;break;default:z=!k.csstransitions}this.isUsingJQueryAnimation=z;this._updateUsingTransforms()},_updateTransformsEnabled:function(){this._updateUsingTransforms()},_updateUsingTransforms:function(){var z=this.usingTransforms=this.options.transformsEnabled&&k.csstransforms&&k.csstransitions&&!this.isUsingJQueryAnimation;if(!z){delete this.options.hiddenStyle.scale;delete this.options.visibleStyle.scale}this.getPositionStyles=z?this._translate:this._positionAbs},_filter:function(F){var B=this.options.filter===""?"*":this.options.filter;if(!B){return F}var E=this.options.hiddenClass,A="."+E,D=F.filter(A),z=D;if(B!=="*"){z=D.filter(B);var C=F.not(A).not(B).addClass(E);this.styleQueue.push({$el:C,style:this.options.hiddenStyle})}this.styleQueue.push({$el:z,style:this.options.visibleStyle});z.removeClass(E);return F.filter(B)},updateSortData:function(E,B){var A=this,C=this.options.getSortData,D,z;E.each(function(){D=f(this);z={};for(var F in C){if(!B&&F==="original-order"){z[F]=f.data(this,"isotope-sort-data")[F]}else{z[F]=C[F](D,A)}}f.data(this,"isotope-sort-data",z)})},_sort:function(){var C=this.options.sortBy,B=this._getSorter,z=this.options.sortAscending?1:-1,A=function(G,F){var E=B(G,C),D=B(F,C);if(E===D&&C!=="original-order"){E=B(G,"original-order");D=B(F,"original-order")}return((E>D)?1:(E<D)?-1:0)*z};this.$filteredAtoms.sort(A)},_getSorter:function(z,A){return f.data(z,"isotope-sort-data")[A]},_translate:function(z,A){return{translate:[z,A]}},_positionAbs:function(z,A){return{left:z,top:A}},_pushPosition:function(B,A,C){A=Math.round(A+this.offset.left);C=Math.round(C+this.offset.top);var z=this.getPositionStyles(A,C);this.styleQueue.push({$el:B,style:z});if(this.options.itemPositionDataEnabled){B.data("isotope-item-position",{x:A,y:C})}},layout:function(C,B){var A=this.options.layoutMode;this["_"+A+"Layout"](C);if(this.options.resizesContainer){var z=this["_"+A+"GetContainerSize"]();this.styleQueue.push({$el:this.element,style:z})}this._processStyleQueue(C,B);this.isLaidOut=true},_processStyleQueue:function(A,P){var C=!this.isLaidOut?"css":(this.isUsingJQueryAnimation?"animate":"css"),F=this.options.animationOptions,G=this.options.onLayout,N,D,J,K;D=function(Q,R){R.$el[C](R.style,F)};if(this._isInserting&&this.isUsingJQueryAnimation){D=function(Q,R){N=R.$el.hasClass("no-transition")?"css":C;R.$el[N](R.style,F)}}else{if(P||G||F.complete){var B=false,I=[P,G,F.complete],O=this;J=true;K=function(){if(B){return}var S;for(var R=0,Q=I.length;R<Q;R++){S=I[R];if(typeof S==="function"){S.call(O.element,A,O)}}B=true};if(this.isUsingJQueryAnimation&&C==="animate"){F.complete=K;J=false}else{if(k.csstransitions){var H=0,L=this.styleQueue[0],M=L&&L.$el,z;while(!M||!M.length){z=this.styleQueue[H++];if(!z){return}M=z.$el}var E=parseFloat(getComputedStyle(M[0])[a]);if(E>0){D=function(Q,R){R.$el[C](R.style,F).one(b,K)};J=false}}}}}f.each(this.styleQueue,D);if(J){K()}this.styleQueue=[]},resize:function(){if(this["_"+this.options.layoutMode+"ResizeChanged"]()){this.reLayout()}},reLayout:function(z){this["_"+this.options.layoutMode+"Reset"]();this.layout(this.$filteredAtoms,z)},addItems:function(A,B){var z=this._getAtoms(A);this.$allAtoms=this.$allAtoms.add(z);if(B){B(z)}},insert:function(A,B){this.element.append(A);var z=this;this.addItems(A,function(C){var D=z._filter(C);z._addHideAppended(D);z._sort();z.reLayout();z._revealAppended(D,B)})},appended:function(A,B){var z=this;this.addItems(A,function(C){z._addHideAppended(C);z.layout(C);z._revealAppended(C,B)})},_addHideAppended:function(z){this.$filteredAtoms=this.$filteredAtoms.add(z);z.addClass("no-transition");this._isInserting=true;this.styleQueue.push({$el:z,style:this.options.hiddenStyle})},_revealAppended:function(A,B){var z=this;setTimeout(function(){A.removeClass("no-transition");z.styleQueue.push({$el:A,style:z.options.visibleStyle});z._isInserting=false;z._processStyleQueue(A,B)},10)},reloadItems:function(){this.$allAtoms=this._getAtoms(this.element.children())},remove:function(B,C){this.$allAtoms=this.$allAtoms.not(B);this.$filteredAtoms=this.$filteredAtoms.not(B);var z=this;var A=function(){B.remove();if(C){C.call(z.element)}};if(B.filter(":not(."+this.options.hiddenClass+")").length){this.styleQueue.push({$el:B,style:this.options.hiddenStyle});this._sort();this.reLayout(A)}else{A()}},shuffle:function(z){this.updateSortData(this.$allAtoms);this.options.sortBy="random";this._sort();this.reLayout(z)},destroy:function(){var B=this.usingTransforms;var A=this.options;this.$allAtoms.removeClass(A.hiddenClass+" "+A.itemClass).each(function(){var D=this.style;D.position="";D.top="";D.left="";D.opacity="";if(B){D[c]=""}});var z=this.element[0].style;for(var C in this.originalStyle){z[C]=this.originalStyle[C]}this.element.unbind(".isotope").undelegate("."+A.hiddenClass,"click").removeClass(A.containerClass).removeData("isotope");r.unbind(".isotope")},_getSegments:function(F){var C=this.options.layoutMode,B=F?"rowHeight":"columnWidth",A=F?"height":"width",E=F?"rows":"cols",G=this.element[A](),z,D=this.options[C]&&this.options[C][B]||this.$filteredAtoms["outer"+p(A)](true)||G;z=Math.floor(G/D);z=Math.max(z,1);this[C][E]=z;this[C][B]=D},_checkIfSegmentsChanged:function(C){var A=this.options.layoutMode,B=C?"rows":"cols",z=this[A][B];this._getSegments(C);return(this[A][B]!==z)},_masonryReset:function(){this.masonry={};this._getSegments();var z=this.masonry.cols;this.masonry.colYs=[];while(z--){this.masonry.colYs.push(0)}},_masonryLayout:function(B){var z=this,A=z.masonry;B.each(function(){var G=f(this),E=Math.ceil(G.outerWidth(true)/A.columnWidth);E=Math.min(E,A.cols);if(E===1){z._masonryPlaceBrick(G,A.colYs)}else{var H=A.cols+1-E,D=[],F,C;for(C=0;C<H;C++){F=A.colYs.slice(C,C+E);D[C]=Math.max.apply(Math,F)}z._masonryPlaceBrick(G,D)}})},_masonryPlaceBrick:function(C,G){var z=Math.min.apply(Math,G),I=0;for(var B=0,D=G.length;B<D;B++){if(G[B]===z){I=B;break}}var H=this.masonry.columnWidth*I,F=z;this._pushPosition(C,H,F);var E=z+C.outerHeight(true),A=this.masonry.cols+1-D;for(B=0;B<A;B++){this.masonry.colYs[I+B]=E}},_masonryGetContainerSize:function(){var z=Math.max.apply(Math,this.masonry.colYs);return{height:z}},_masonryResizeChanged:function(){return this._checkIfSegmentsChanged()},_fitRowsReset:function(){this.fitRows={x:0,y:0,height:0}},_fitRowsLayout:function(C){var z=this,B=this.element.width(),A=this.fitRows;C.each(function(){var F=f(this),E=F.outerWidth(true),D=F.outerHeight(true);if(A.x!==0&&E+A.x>B){A.x=0;A.y=A.height}z._pushPosition(F,A.x,A.y);A.height=Math.max(A.y+D,A.height);A.x+=E})},_fitRowsGetContainerSize:function(){return{height:this.fitRows.height}},_fitRowsResizeChanged:function(){return true},_cellsByRowReset:function(){this.cellsByRow={index:0};this._getSegments();this._getSegments(true)},_cellsByRowLayout:function(B){var z=this,A=this.cellsByRow;B.each(function(){var E=f(this),D=A.index%A.cols,F=Math.floor(A.index/A.cols),C=(D+0.5)*A.columnWidth-E.outerWidth(true)/2,G=(F+0.5)*A.rowHeight-E.outerHeight(true)/2;z._pushPosition(E,C,G);A.index++})},_cellsByRowGetContainerSize:function(){return{height:Math.ceil(this.$filteredAtoms.length/this.cellsByRow.cols)*this.cellsByRow.rowHeight+this.offset.top}},_cellsByRowResizeChanged:function(){return this._checkIfSegmentsChanged()},_straightDownReset:function(){this.straightDown={y:0}},_straightDownLayout:function(A){var z=this;A.each(function(B){var C=f(this);z._pushPosition(C,0,z.straightDown.y);z.straightDown.y+=C.outerHeight(true)})},_straightDownGetContainerSize:function(){return{height:this.straightDown.y}},_straightDownResizeChanged:function(){return true},_masonryHorizontalReset:function(){this.masonryHorizontal={};this._getSegments(true);var z=this.masonryHorizontal.rows;this.masonryHorizontal.rowXs=[];while(z--){this.masonryHorizontal.rowXs.push(0)}},_masonryHorizontalLayout:function(B){var z=this,A=z.masonryHorizontal;B.each(function(){var G=f(this),E=Math.ceil(G.outerHeight(true)/A.rowHeight);E=Math.min(E,A.rows);if(E===1){z._masonryHorizontalPlaceBrick(G,A.rowXs)}else{var H=A.rows+1-E,D=[],F,C;for(C=0;C<H;C++){F=A.rowXs.slice(C,C+E);D[C]=Math.max.apply(Math,F)}z._masonryHorizontalPlaceBrick(G,D)}})},_masonryHorizontalPlaceBrick:function(C,H){var z=Math.min.apply(Math,H),F=0;for(var B=0,D=H.length;B<D;B++){if(H[B]===z){F=B;break}}var I=z,G=this.masonryHorizontal.rowHeight*F;this._pushPosition(C,I,G);var E=z+C.outerWidth(true),A=this.masonryHorizontal.rows+1-D;for(B=0;B<A;B++){this.masonryHorizontal.rowXs[F+B]=E}},_masonryHorizontalGetContainerSize:function(){var z=Math.max.apply(Math,this.masonryHorizontal.rowXs);return{width:z}},_masonryHorizontalResizeChanged:function(){return this._checkIfSegmentsChanged(true)},_fitColumnsReset:function(){this.fitColumns={x:0,y:0,width:0}},_fitColumnsLayout:function(C){var z=this,B=this.element.height(),A=this.fitColumns;C.each(function(){var F=f(this),E=F.outerWidth(true),D=F.outerHeight(true);if(A.y!==0&&D+A.y>B){A.x=A.width;A.y=0}z._pushPosition(F,A.x,A.y);A.width=Math.max(A.x+E,A.width);A.y+=D})},_fitColumnsGetContainerSize:function(){return{width:this.fitColumns.width}},_fitColumnsResizeChanged:function(){return true},_cellsByColumnReset:function(){this.cellsByColumn={index:0};this._getSegments();this._getSegments(true)},_cellsByColumnLayout:function(B){var z=this,A=this.cellsByColumn;B.each(function(){var E=f(this),D=Math.floor(A.index/A.rows),F=A.index%A.rows,C=(D+0.5)*A.columnWidth-E.outerWidth(true)/2,G=(F+0.5)*A.rowHeight-E.outerHeight(true)/2;z._pushPosition(E,C,G);A.index++})},_cellsByColumnGetContainerSize:function(){return{width:Math.ceil(this.$filteredAtoms.length/this.cellsByColumn.rows)*this.cellsByColumn.columnWidth}},_cellsByColumnResizeChanged:function(){return this._checkIfSegmentsChanged(true)},_straightAcrossReset:function(){this.straightAcross={x:0}},_straightAcrossLayout:function(A){var z=this;A.each(function(B){var C=f(this);z._pushPosition(C,z.straightAcross.x,0);z.straightAcross.x+=C.outerWidth(true)})},_straightAcrossGetContainerSize:function(){return{width:this.straightAcross.x}},_straightAcrossResizeChanged:function(){return true}};
4
+ ;f.fn.imagesLoaded=function(G){var E=this,C=E.find("img").add(E.filter("img")),z=C.length,F="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",B=[];function D(){G.call(E,C)}function A(I){var H=I.target;if(H.src!==F&&f.inArray(H,B)===-1){B.push(H);if(--z<=0){setTimeout(D);C.unbind(".imagesLoaded",A)}}}if(!z){D()}C.bind("load.imagesLoaded error.imagesLoaded",A).each(function(){var H=this.src;this.src=F;this.src=H});return E};var x=function(z){if(n.console){n.console.error(z)}};f.fn.isotope=function(A,B){if(typeof A==="string"){var z=Array.prototype.slice.call(arguments,1);this.each(function(){var C=f.data(this,"isotope");if(!C){x("cannot call methods on isotope prior to initialization; attempted to call method '"+A+"'");return}if(!f.isFunction(C[A])||A.charAt(0)==="_"){x("no such method '"+A+"' for isotope instance");return}C[A].apply(C,z)})}else{this.each(function(){var C=f.data(this,"isotope");if(C){C.option(A);C._init(B)}else{f.data(this,"isotope",new f.Isotope(A,this,B))}})}return this}})(window,jQuery);
5
+ // Isoptope custom extensions and methods.
6
+ jQuery.Isotope.prototype._getMasonryGutterColumns=function(){var a=this.options.masonry&&this.options.masonry.gutterWidth||0;containerWidth=this.element.width();this.masonry.columnWidth=this.options.masonry&&this.options.masonry.columnWidth||this.$filteredAtoms.outerWidth(true)||containerWidth;this.masonry.columnWidth+=a;this.masonry.cols=Math.floor((containerWidth+a)/this.masonry.columnWidth);this.masonry.cols=Math.max(this.masonry.cols,1)};jQuery.Isotope.prototype._masonryReset=function(){this.masonry={};this._getMasonryGutterColumns();var a=this.masonry.cols;this.masonry.colYs=[];while(a--){this.masonry.colYs.push(0)}};jQuery.Isotope.prototype._masonryResizeChanged=function(){var a=this.masonry.cols;this._getMasonryGutterColumns();return(this.masonry.cols!==a)};
7
+ // Fancybox v1.3.4
8
+ (function(B){var L,T,Q,M,d,m,J,A,O,z,C=0,H={},j=[],e=0,G={},y=[],f=null,o=new Image(),i=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,k=/[^\.]\.(swf)\s*$/i,p,N=1,h=0,t="",b,c,P=false,s=B.extend(B("<div/>")[0],{prop:0}),S=B.browser.msie&&B.browser.version<7&&!window.XMLHttpRequest,r=function(){T.hide();o.onerror=o.onload=null;if(f){f.abort()}L.empty()},x=function(){if(false===H.onError(j,C,H)){T.hide();P=false;return}H.titleShow=false;H.width="auto";H.height="auto";L.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');n()},w=function(){var Z=j[C],W,Y,ab,aa,V,X;r();H=B.extend({},B.fn.fancybox.defaults,(typeof B(Z).data("fancybox")=="undefined"?H:B(Z).data("fancybox")));X=H.onStart(j,C,H);if(X===false){P=false;return}else{if(typeof X=="object"){H=B.extend(H,X)}}ab=H.title||(Z.nodeName?B(Z).attr("title"):Z.title)||"";if(Z.nodeName&&!H.orig){H.orig=B(Z).children("img:first").length?B(Z).children("img:first"):B(Z)}if(ab===""&&H.orig&&H.titleFromAlt){ab=H.orig.attr("alt")}W=H.href||(Z.nodeName?B(Z).attr("href"):Z.href)||null;if((/^(?:javascript)/i).test(W)||W=="#"){W=null}if(H.type){Y=H.type;if(!W){W=H.content}}else{if(H.content){Y="html"}else{if(W){if(W.match(i)){Y="image"}else{if(W.match(k)){Y="swf"}else{if(B(Z).hasClass("iframe")){Y="iframe"}else{if(W.indexOf("#")===0){Y="inline"}else{Y="ajax"}}}}}}}if(!Y){x();return}if(Y=="inline"){Z=W.substr(W.indexOf("#"));Y=B(Z).length>0?"inline":"ajax"}H.type=Y;H.href=W;H.title=ab;if(H.autoDimensions){if(H.type=="html"||H.type=="inline"||H.type=="ajax"){H.width="auto";H.height="auto"}else{H.autoDimensions=false}}if(H.modal){H.overlayShow=true;H.hideOnOverlayClick=false;H.hideOnContentClick=false;H.enableEscapeButton=false;H.showCloseButton=false}H.padding=parseInt(H.padding,10);H.margin=parseInt(H.margin,10);L.css("padding",(H.padding+H.margin));B(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){B(this).replaceWith(m.children())});switch(Y){case"html":L.html(H.content);n();break;case"inline":if(B(Z).parent().is("#fancybox-content")===true){P=false;return}B('<div class="fancybox-inline-tmp" />').hide().insertBefore(B(Z)).bind("fancybox-cleanup",function(){B(this).replaceWith(m.children())}).bind("fancybox-cancel",function(){B(this).replaceWith(L.children())});B(Z).appendTo(L);n();break;case"image":P=false;B.fancybox.showActivity();o=new Image();o.onerror=function(){x()};o.onload=function(){P=true;o.onerror=o.onload=null;F()};o.src=W;break;case"swf":H.scrolling="no";aa='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+H.width+'" height="'+H.height+'"><param name="movie" value="'+W+'"></param>';V="";B.each(H.swf,function(ac,ad){aa+='<param name="'+ac+'" value="'+ad+'"></param>';V+=" "+ac+'="'+ad+'"'});aa+='<embed src="'+W+'" type="application/x-shockwave-flash" width="'+H.width+'" height="'+H.height+'"'+V+"></embed></object>";L.html(aa);n();break;case"ajax":P=false;B.fancybox.showActivity();H.ajax.win=H.ajax.success;f=B.ajax(B.extend({},H.ajax,{url:W,data:H.ajax.data||{},error:function(ac,ae,ad){if(ac.status>0){x()}},success:function(ad,af,ac){var ae=typeof ac=="object"?ac:f;if(ae.status==200){if(typeof H.ajax.win=="function"){X=H.ajax.win(W,ad,af,ac);if(X===false){T.hide();return}else{if(typeof X=="string"||typeof X=="object"){ad=X}}}L.html(ad);n()}}}));break;case"iframe":E();break}},n=function(){var V=H.width,W=H.height;if(V.toString().indexOf("%")>-1){V=parseInt((B(window).width()-(H.margin*2))*parseFloat(V)/100,10)+"px"}else{V=V=="auto"?"auto":V+"px"}if(W.toString().indexOf("%")>-1){W=parseInt((B(window).height()-(H.margin*2))*parseFloat(W)/100,10)+"px"}else{W=W=="auto"?"auto":W+"px"}L.wrapInner('<div style="width:'+V+";height:"+W+";overflow: "+(H.scrolling=="auto"?"auto":(H.scrolling=="yes"?"scroll":"hidden"))+';position:relative;"></div>');H.width=L.width();H.height=L.height();E()},F=function(){H.width=o.width;H.height=o.height;B("<img />").attr({id:"fancybox-img",src:o.src,alt:H.title}).appendTo(L);E()},E=function(){var W,V;T.hide();if(M.is(":visible")&&false===G.onCleanup(y,e,G)){B.event.trigger("fancybox-cancel");P=false;return}P=true;B(m.add(Q)).unbind();B(window).unbind("resize.fb scroll.fb");B(document).unbind("keydown.fb");if(M.is(":visible")&&G.titlePosition!=="outside"){M.css("height",M.height())}y=j;e=C;G=H;if(G.overlayShow){Q.css({"background-color":G.overlayColor,opacity:G.overlayOpacity,cursor:G.hideOnOverlayClick?"pointer":"auto",height:B(document).height()});if(!Q.is(":visible")){if(S){B("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"})}Q.show()}}else{Q.hide()}c=R();l();if(M.is(":visible")){B(J.add(O).add(z)).hide();W=M.position(),b={top:W.top,left:W.left,width:M.width(),height:M.height()};V=(b.width==c.width&&b.height==c.height);m.fadeTo(G.changeFade,0.3,function(){var X=function(){m.html(L.contents()).fadeTo(G.changeFade,1,v)};B.event.trigger("fancybox-change");m.empty().removeAttr("filter").css({"border-width":G.padding,width:c.width-G.padding*2,height:H.autoDimensions?"auto":c.height-h-G.padding*2});if(V){X()}else{s.prop=0;B(s).animate({prop:1},{duration:G.changeSpeed,easing:G.easingChange,step:U,complete:X})}});return}M.removeAttr("style");m.css("border-width",G.padding);if(G.transitionIn=="elastic"){b=I();m.html(L.contents());M.show();if(G.opacity){c.opacity=0}s.prop=0;B(s).animate({prop:1},{duration:G.speedIn,easing:G.easingIn,step:U,complete:v});return}if(G.titlePosition=="inside"&&h>0){A.show()}m.css({width:c.width-G.padding*2,height:H.autoDimensions?"auto":c.height-h-G.padding*2}).html(L.contents());M.css(c).fadeIn(G.transitionIn=="none"?0:G.speedIn,v)},D=function(V){if(V&&V.length){if(G.titlePosition=="float"){return'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+V+'</td><td id="fancybox-title-float-right"></td></tr></table>'}return'<div id="fancybox-title-'+G.titlePosition+'">'+V+"</div>"}return false},l=function(){t=G.title||"";h=0;A.empty().removeAttr("style").removeClass();if(G.titleShow===false){A.hide();return}t=B.isFunction(G.titleFormat)?G.titleFormat(t,y,e,G):D(t);if(!t||t===""){A.hide();return}A.addClass("fancybox-title-"+G.titlePosition).html(t).appendTo("body").show();switch(G.titlePosition){case"inside":A.css({width:c.width-(G.padding*2),marginLeft:G.padding,marginRight:G.padding});h=A.outerHeight(true);A.appendTo(d);c.height+=h;break;case"over":A.css({marginLeft:G.padding,width:c.width-(G.padding*2),bottom:G.padding}).appendTo(d);break;case"float":A.css("left",parseInt((A.width()-c.width-40)/2,10)*-1).appendTo(M);break;default:A.css({width:c.width-(G.padding*2),paddingLeft:G.padding,paddingRight:G.padding}).appendTo(M);break}A.hide()},g=function(){if(G.enableEscapeButton||G.enableKeyboardNav){B(document).bind("keydown.fb",function(V){if(V.keyCode==27&&G.enableEscapeButton){V.preventDefault();B.fancybox.close()}else{if((V.keyCode==37||V.keyCode==39)&&G.enableKeyboardNav&&V.target.tagName!=="INPUT"&&V.target.tagName!=="TEXTAREA"&&V.target.tagName!=="SELECT"){V.preventDefault();B.fancybox[V.keyCode==37?"prev":"next"]()}}})}if(!G.showNavArrows){O.hide();z.hide();return}if((G.cyclic&&y.length>1)||e!==0){O.show()}if((G.cyclic&&y.length>1)||e!=(y.length-1)){z.show()}},v=function(){if(!B.support.opacity){m.get(0).style.removeAttribute("filter");M.get(0).style.removeAttribute("filter")}if(H.autoDimensions){m.css("height","auto")}M.css("height","auto");if(t&&t.length){A.show()}if(G.showCloseButton){J.show()}g();if(G.hideOnContentClick){m.bind("click",B.fancybox.close)}if(G.hideOnOverlayClick){Q.bind("click",B.fancybox.close)}B(window).bind("resize.fb",B.fancybox.resize);if(G.centerOnScroll){B(window).bind("scroll.fb",B.fancybox.center)}if(G.type=="iframe"){B('<iframe id="fancybox-frame" name="fancybox-frame'+new Date().getTime()+'" frameborder="0" hspace="0" '+(B.browser.msie?'allowtransparency="true""':"")+' scrolling="'+H.scrolling+'" src="'+G.href+'"></iframe>').appendTo(m)}M.show();P=false;B.fancybox.center();G.onComplete(y,e,G);K()},K=function(){var V,W;if((y.length-1)>e){V=y[e+1].href;if(typeof V!=="undefined"&&V.match(i)){W=new Image();W.src=V}}if(e>0){V=y[e-1].href;if(typeof V!=="undefined"&&V.match(i)){W=new Image();W.src=V}}},U=function(W){var V={width:parseInt(b.width+(c.width-b.width)*W,10),height:parseInt(b.height+(c.height-b.height)*W,10),top:parseInt(b.top+(c.top-b.top)*W,10),left:parseInt(b.left+(c.left-b.left)*W,10)};if(typeof c.opacity!=="undefined"){V.opacity=W<0.5?0.5:W}M.css(V);m.css({width:V.width-G.padding*2,height:V.height-(h*W)-G.padding*2})},u=function(){return[B(window).width()-(G.margin*2),B(window).height()-(G.margin*2),B(document).scrollLeft()+G.margin,B(document).scrollTop()+G.margin]},R=function(){var V=u(),Z={},W=G.autoScale,X=G.padding*2,Y;if(G.width.toString().indexOf("%")>-1){Z.width=parseInt((V[0]*parseFloat(G.width))/100,10)}else{Z.width=G.width+X}if(G.height.toString().indexOf("%")>-1){Z.height=parseInt((V[1]*parseFloat(G.height))/100,10)}else{Z.height=G.height+X}if(W&&(Z.width>V[0]||Z.height>V[1])){if(H.type=="image"||H.type=="swf"){Y=(G.width)/(G.height);if((Z.width)>V[0]){Z.width=V[0];Z.height=parseInt(((Z.width-X)/Y)+X,10)}if((Z.height)>V[1]){Z.height=V[1];Z.width=parseInt(((Z.height-X)*Y)+X,10)}}else{Z.width=Math.min(Z.width,V[0]);Z.height=Math.min(Z.height,V[1])}}Z.top=parseInt(Math.max(V[3]-20,V[3]+((V[1]-Z.height-40)*0.5)),10);Z.left=parseInt(Math.max(V[2]-20,V[2]+((V[0]-Z.width-40)*0.5)),10);return Z},q=function(V){var W=V.offset();W.top+=parseInt(V.css("paddingTop"),10)||0;W.left+=parseInt(V.css("paddingLeft"),10)||0;W.top+=parseInt(V.css("border-top-width"),10)||0;W.left+=parseInt(V.css("border-left-width"),10)||0;W.width=V.width();W.height=V.height();return W},I=function(){var Y=H.orig?B(H.orig):false,X={},W,V;if(Y&&Y.length){W=q(Y);X={width:W.width+(G.padding*2),height:W.height+(G.padding*2),top:W.top-G.padding-20,left:W.left-G.padding-20}}else{V=u();X={width:G.padding*2,height:G.padding*2,top:parseInt(V[3]+V[1]*0.5,10),left:parseInt(V[2]+V[0]*0.5,10)}}return X},a=function(){if(!T.is(":visible")){clearInterval(p);return}B("div",T).css("top",(N*-40)+"px");N=(N+1)%12};B.fn.fancybox=function(V){if(!B(this).length){return this}B(this).data("fancybox",B.extend({},V,(B.metadata?B(this).metadata():{}))).unbind("click.fb").bind("click.fb",function(X){X.preventDefault();if(P){return}P=true;B(this).blur();j=[];C=0;var W=B(this).attr("rel")||"";if(!W||W==""||W==="nofollow"){j.push(this)}else{j=B("a[rel="+W+"], area[rel="+W+"]");C=j.index(this)}w();return});return this};B.fancybox=function(Y){var X;if(P){return}P=true;X=typeof arguments[1]!=="undefined"?arguments[1]:{};j=[];C=parseInt(X.index,10)||0;if(B.isArray(Y)){for(var W=0,V=Y.length;W<V;W++){if(typeof Y[W]=="object"){B(Y[W]).data("fancybox",B.extend({},X,Y[W]))}else{Y[W]=B({}).data("fancybox",B.extend({content:Y[W]},X))}}j=jQuery.merge(j,Y)}else{if(typeof Y=="object"){B(Y).data("fancybox",B.extend({},X,Y))}else{Y=B({}).data("fancybox",B.extend({content:Y},X))}j.push(Y)}if(C>j.length||C<0){C=0}w()};B.fancybox.showActivity=function(){clearInterval(p);T.show();p=setInterval(a,66)};B.fancybox.hideActivity=function(){T.hide()};B.fancybox.next=function(){return B.fancybox.pos(e+1)};B.fancybox.prev=function(){return B.fancybox.pos(e-1)};B.fancybox.pos=function(V){if(P){return}V=parseInt(V);j=y;if(V>-1&&V<y.length){C=V;w()}else{if(G.cyclic&&y.length>1){C=V>=y.length?0:y.length-1;w()}}return};B.fancybox.cancel=function(){if(P){return}P=true;B.event.trigger("fancybox-cancel");r();H.onCancel(j,C,H);P=false};B.fancybox.close=function(){if(P||M.is(":hidden")){return}P=true;if(G&&false===G.onCleanup(y,e,G)){P=false;return}r();B(J.add(O).add(z)).hide();B(m.add(Q)).unbind();B(window).unbind("resize.fb scroll.fb");B(document).unbind("keydown.fb");m.find("iframe").attr("src",S&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");if(G.titlePosition!=="inside"){A.empty()}M.stop();function V(){Q.fadeOut("fast");A.empty().hide();M.hide();B.event.trigger("fancybox-cleanup");m.empty();G.onClosed(y,e,G);y=H=[];e=C=0;G=H={};P=false}if(G.transitionOut=="elastic"){b=I();var W=M.position();c={top:W.top,left:W.left,width:M.width(),height:M.height()};if(G.opacity){c.opacity=1}A.empty().hide();s.prop=1;B(s).animate({prop:0},{duration:G.speedOut,easing:G.easingOut,step:U,complete:V})}else{M.fadeOut(G.transitionOut=="none"?0:G.speedOut,V)}};B.fancybox.resize=function(){if(Q.is(":visible")){Q.css("height",B(document).height())}var W,V;c=R();l();A.show();W=M.position(),b={top:W.top,left:W.left,width:M.width(),height:M.height()};V=(b.width==c.width&&b.height==c.height);if(V){}else{s.prop=0;B(s).animate({prop:1},{duration:G.changeSpeed,easing:G.easingChange,step:U})}m.css({width:c.width-G.padding*2,height:H.autoDimensions?"auto":c.height-h-G.padding*2});M.css(c);B.fancybox.center(true)};B.fancybox.center=function(){var V,W;if(P){return}W=arguments[0]===true?1:0;V=u();if(!W&&(M.width()>V[0]||M.height()>V[1])){return}M.stop().animate({top:parseInt(Math.max(V[3]-20,V[3]+((V[1]-m.height()-40)*0.5)-G.padding)),left:parseInt(Math.max(V[2]-20,V[2]+((V[0]-m.width()-40)*0.5)-G.padding))},typeof arguments[0]=="number"?arguments[0]:200)};B.fancybox.init=function(){if(B("#fancybox-wrap").length){return}B("body").append(L=B('<div id="fancybox-tmp"></div>'),T=B('<div id="fancybox-loading"><div></div></div>'),Q=B('<div id="fancybox-overlay"></div>'),M=B('<div id="fancybox-wrap"></div>'));d=B('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(M);d.append(m=B('<div id="fancybox-content"></div>'),J=B('<a id="fancybox-close"></a>'),A=B('<div id="fancybox-title"></div>'),O=B('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),z=B('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));J.click(B.fancybox.close);T.click(B.fancybox.cancel);O.click(function(V){V.preventDefault();B.fancybox.prev()});z.click(function(V){V.preventDefault();B.fancybox.next()});if(B.fn.mousewheel){M.bind("mousewheel.fb",function(V,W){if(P){V.preventDefault()}else{if(B(V.target).get(0).clientHeight==0||B(V.target).get(0).scrollHeight===B(V.target).get(0).clientHeight){V.preventDefault();B.fancybox[W>0?"prev":"next"]()}}})}if(!B.support.opacity){M.addClass("fancybox-ie")}if(S){T.addClass("fancybox-ie6");M.addClass("fancybox-ie6");B('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(d)}};B.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};B(document).ready(function(){B.fancybox.init()})})(jQuery);
9
+ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
10
+ * Licensed under the MIT License (LICENSE.txt).
11
+ *
12
+ * Version: 3.1.9
13
+ *
14
+ * Requires: jQuery 1.2.2+
15
+ */
16
+ (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports==="object"){module.exports=a}else{a(jQuery)}}}(function(c){var d=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],k=("onwheel" in document||document.documentMode>=9)?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],h=Array.prototype.slice,j,b;if(c.event.fixHooks){for(var e=d.length;e;){c.event.fixHooks[d[--e]]=c.event.mouseHooks}}var f=c.event.special.mousewheel={version:"3.1.9",setup:function(){if(this.addEventListener){for(var m=k.length;m;){this.addEventListener(k[--m],l,false)}}else{this.onmousewheel=l}c.data(this,"mousewheel-line-height",f.getLineHeight(this));c.data(this,"mousewheel-page-height",f.getPageHeight(this))},teardown:function(){if(this.removeEventListener){for(var m=k.length;m;){this.removeEventListener(k[--m],l,false)}}else{this.onmousewheel=null}},getLineHeight:function(i){return parseInt(c(i)["offsetParent" in c.fn?"offsetParent":"parent"]().css("fontSize"),10)},getPageHeight:function(i){return c(i).height()},settings:{adjustOldDeltas:true}};c.fn.extend({mousewheel:function(i){return i?this.bind("mousewheel",i):this.trigger("mousewheel")},unmousewheel:function(i){return this.unbind("mousewheel",i)}});function l(i){var n=i||window.event,r=h.call(arguments,1),t=0,p=0,o=0,q=0;i=c.event.fix(n);i.type="mousewheel";if("detail" in n){o=n.detail*-1}if("wheelDelta" in n){o=n.wheelDelta}if("wheelDeltaY" in n){o=n.wheelDeltaY}if("wheelDeltaX" in n){p=n.wheelDeltaX*-1}if("axis" in n&&n.axis===n.HORIZONTAL_AXIS){p=o*-1;o=0}t=o===0?p:o;if("deltaY" in n){o=n.deltaY*-1;t=o}if("deltaX" in n){p=n.deltaX;if(o===0){t=p*-1}}if(o===0&&p===0){return}if(n.deltaMode===1){var s=c.data(this,"mousewheel-line-height");t*=s;o*=s;p*=s}else{if(n.deltaMode===2){var m=c.data(this,"mousewheel-page-height");t*=m;o*=m;p*=m}}q=Math.max(Math.abs(o),Math.abs(p));if(!b||q<b){b=q;if(a(n,q)){b/=40}}if(a(n,q)){t/=40;p/=40;o/=40}t=Math[t>=1?"floor":"ceil"](t/b);p=Math[p>=1?"floor":"ceil"](p/b);o=Math[o>=1?"floor":"ceil"](o/b);i.deltaX=p;i.deltaY=o;i.deltaFactor=b;i.deltaMode=0;r.unshift(i,t,p,o);if(j){clearTimeout(j)}j=setTimeout(g,200);return(c.event.dispatch||c.event.handle).apply(this,r)}function g(){b=null}function a(m,i){return f.settings.adjustOldDeltas&&m.type==="mousewheel"&&i%120===0}}));
17
+ // Envira functions.
18
+ function enviraGetColWidth(a,e){var d,c=jQuery(window).width(),b=a.data("envira-columns");switch(b){case 1:d=a.width();break;case 2:if(c<=480){d=a.width()}else{d=a.width()/2}break;case 3:if(c<=480){d=a.width()}else{if(c<=768){d=a.width()/2}else{d=a.width()/3}}case 4:case 5:case 6:if(c<=480){d=a.width()}else{if(c<=768){d=a.width()/2}else{if(c<=1024){d=a.width()/3}else{d=a.width()/b}}}break}return parseInt(d-(e*(b-1))/b)}function enviraSetWidths(a,c){var b=enviraGetColWidth(a,c);a.children().css({width:b})};function enviraIsMobile(){var check = false;(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check=true})(navigator.userAgent||navigator.vendor||window.opera);return check;}function enviraThrottle(a,b){return function(){var d=this,c=[].slice(arguments);clearTimeout(a._throttleTimeout);a._throttleTimeout=setTimeout(function(){a.apply(d,c)},b)}};
assets/js/metabox.js ADDED
@@ -0,0 +1,626 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ==========================================================
2
+ * metabox.js
3
+ * http://enviragallery.com/
4
+ * ==========================================================
5
+ * Copyright 2014 Thomas Griffin.
6
+ *
7
+ * Licensed under the GPL License, Version 2.0 or later (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.gnu.org/licenses/gpl-2.0.html
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ========================================================== */
19
+ ;(function($){
20
+ $(function(){
21
+ // Initialize the slider tabs.
22
+ var envira_tabs = $('#envira-tabs'),
23
+ envira_tabs_nav = $('#envira-tabs-nav'),
24
+ envira_tabs_hash = window.location.hash,
25
+ envira_tabs_hash_sani = window.location.hash.replace('!', '');
26
+
27
+ // If we have a hash and it begins with "envira-tab", set the proper tab to be opened.
28
+ if ( envira_tabs_hash && envira_tabs_hash.indexOf('envira-tab-') >= 0 ) {
29
+ $('.envira-active').removeClass('envira-active');
30
+ envira_tabs_nav.find('li a[href="' + envira_tabs_hash_sani + '"]').parent().addClass('envira-active');
31
+ envira_tabs.find(envira_tabs_hash_sani).addClass('envira-active').show();
32
+
33
+ // Update the post action to contain our hash so the proper tab can be loaded on save.
34
+ var post_action = $('#post').attr('action');
35
+ if ( post_action ) {
36
+ post_action = post_action.split('#')[0];
37
+ $('#post').attr('action', post_action + envira_tabs_hash);
38
+ }
39
+ }
40
+
41
+ // Change tabs on click.
42
+ $(document).on('click', '#envira-tabs-nav li a', function(e){
43
+ e.preventDefault();
44
+ var $this = $(this);
45
+ if ( $this.parent().hasClass('envira-active') ) {
46
+ return;
47
+ } else {
48
+ window.location.hash = envira_tabs_hash = this.hash.split('#').join('#!');
49
+ var current = envira_tabs_nav.find('.envira-active').removeClass('envira-active').find('a').attr('href');
50
+ $this.parent().addClass('envira-active');
51
+ envira_tabs.find(current).removeClass('envira-active').hide();
52
+ envira_tabs.find($this.attr('href')).addClass('envira-active').show();
53
+
54
+ // Update the post action to contain our hash so the proper tab can be loaded on save.
55
+ var post_action = $('#post').attr('action');
56
+ if ( post_action ) {
57
+ post_action = post_action.split('#')[0];
58
+ $('#post').attr('action', post_action + envira_tabs_hash);
59
+ }
60
+ }
61
+ });
62
+
63
+ // Load plupload.
64
+ var envira_uploader;
65
+ enviraPlupload();
66
+
67
+ // Conditionally show necessary fields.
68
+ enviraConditionals();
69
+
70
+ // Handle the meta icon helper.
71
+ if ( 0 !== $('.envira-helper-needed').length ) {
72
+ $('<div class="envira-meta-helper-overlay" />').prependTo('#envira-gallery');
73
+ }
74
+
75
+ $(document).on('click', '.envira-meta-icon', function(e){
76
+ e.preventDefault();
77
+ var $this = $(this),
78
+ container = $this.parent(),
79
+ helper = $this.next();
80
+ if ( helper.is(':visible') ) {
81
+ $('.envira-meta-helper-overlay').remove();
82
+ container.removeClass('envira-helper-active');
83
+ } else {
84
+ if ( 0 === $('.envira-meta-helper-overlay').length ) {
85
+ $('<div class="envira-meta-helper-overlay" />').prependTo('#envira-gallery');
86
+ }
87
+ container.addClass('envira-helper-active');
88
+ }
89
+ });
90
+
91
+ // Open up the media manager modal.
92
+ $(document).on('click', '.envira-media-library', function(e){
93
+ e.preventDefault();
94
+
95
+ // Show the modal.
96
+ envira_main_frame = true;
97
+ $('#envira-gallery-upload-ui').appendTo('body').show();
98
+ });
99
+
100
+ // Add the selected state to images when selected from the library view.
101
+ $('.envira-gallery-gallery').on('click', '.thumbnail, .check, .media-modal-icon', function(e){
102
+ e.preventDefault();
103
+ if ( $(this).parent().parent().hasClass('envira-gallery-in-gallery') )
104
+ return;
105
+ if ( $(this).parent().parent().hasClass('selected') )
106
+ $(this).parent().parent().removeClass('details selected');
107
+ else
108
+ $(this).parent().parent().addClass('details selected');
109
+ });
110
+
111
+ // Load more images into the library view.
112
+ $('.envira-gallery-load-library').on('click', function(e){
113
+ e.preventDefault();
114
+ var $this = $(this);
115
+ $this.next().css({'display' : 'inline-block', 'margin-top' : '14px', 'margin-left' : '-5px'});
116
+
117
+ // Prepare our data to be sent via Ajax.
118
+ var load = {
119
+ action: 'envira_gallery_load_library',
120
+ offset: parseInt($this.attr('data-envira-gallery-offset')),
121
+ post_id: envira_gallery_metabox.id,
122
+ nonce: envira_gallery_metabox.load_gallery
123
+ };
124
+
125
+ // Process the Ajax response and output all the necessary data.
126
+ $.post(
127
+ envira_gallery_metabox.ajax,
128
+ load,
129
+ function(response) {
130
+ $this.attr('data-envira-gallery-offset', parseInt($this.attr('data-envira-gallery-offset')) + 20);
131
+
132
+ // Append the response data.
133
+ if ( response && response.html && $this.hasClass('has-search') ) {
134
+ $('.envira-gallery-gallery').html(response.html);
135
+ $this.removeClass('has-search');
136
+ } else {
137
+ $('.envira-gallery-gallery').append(response.html);
138
+ }
139
+
140
+ // Remove the spinner.
141
+ $this.next().hide();
142
+ },
143
+ 'json'
144
+ );
145
+ });
146
+
147
+ // Load images related to the search term specified
148
+ $(document).on('keyup keydown', '#envira-gallery-gallery-search', function(){
149
+ var $this = $(this);
150
+ $this.prev().css({'display' : 'inline-block', 'margin-top' : '1px', 'vertical-align' : 'middle', 'margin-right' : '4px'});
151
+
152
+ var text = $(this).val();
153
+ var search = {
154
+ action: 'envira_gallery_library_search',
155
+ nonce: envira_gallery_metabox.library_search,
156
+ post_id: envira_gallery_metabox.id,
157
+ search: text
158
+ };
159
+
160
+ // Send the ajax request with a delay (500ms after the user stops typing).
161
+ delay(function() {
162
+ // Process the Ajax response and output all the necessary data.
163
+ $.post(
164
+ envira_gallery_metabox.ajax,
165
+ search,
166
+ function(response) {
167
+ // Notify the load button that we have entered a search and reset the offset counter.
168
+ $('.envira-load-library').addClass('has-search').attr('data-envira-offset', parseInt(0));
169
+
170
+ // Append the response data.
171
+ if ( response )
172
+ $('.envira-gallery-gallery').html(response.html);
173
+
174
+ // Remove the spinner.
175
+ $this.prev().hide();
176
+ },
177
+ 'json'
178
+ );
179
+ }, '500');
180
+ });
181
+
182
+ // Process inserting slides into slider when the Insert button is pressed.
183
+ $(document).on('click', '.envira-gallery-media-insert', function(e){
184
+ e.preventDefault();
185
+ var $this = $(this),
186
+ text = $(this).text(),
187
+ data = {
188
+ action: 'envira_gallery_insert_images',
189
+ nonce: envira_gallery_metabox.insert_nonce,
190
+ post_id: envira_gallery_metabox.id,
191
+ images: {}
192
+ },
193
+ selected = false,
194
+ insert_e = e;
195
+ $this.text(envira_gallery_metabox.inserting);
196
+
197
+ // Loop through potential data to send when inserting images.
198
+ // First, we loop through the selected items and add them to the data var.
199
+ $('.envira-gallery-media-frame').find('.attachment.selected:not(.envira-gallery-in-gallery)').each(function(i, el){
200
+ data.images[i] = $(el).attr('data-attachment-id');
201
+ selected = true;
202
+ });
203
+
204
+ // Send the ajax request with our data to be processed.
205
+ $.post(
206
+ envira_gallery_metabox.ajax,
207
+ data,
208
+ function(response){
209
+ // Set small delay before closing modal.
210
+ setTimeout(function(){
211
+ // Re-append modal to correct spot and revert text back to default.
212
+ append_and_hide(insert_e);
213
+ $this.text(text);
214
+
215
+ // If we have selected items, be sure to properly load first images back into view.
216
+ if ( selected )
217
+ $('.envira-gallery-load-library').attr('data-envira-gallery-offset', 0).addClass('has-search').trigger('click');
218
+ }, 500);
219
+ },
220
+ 'json'
221
+ );
222
+
223
+ });
224
+
225
+ // Make gallery items sortable.
226
+ var gallery = $('#envira-gallery-output');
227
+
228
+ // Use ajax to make the images sortable.
229
+ gallery.sortable({
230
+ containment: '#envira-gallery-output',
231
+ items: 'li',
232
+ cursor: 'move',
233
+ forcePlaceholderSize: true,
234
+ placeholder: 'dropzone',
235
+ update: function(event, ui) {
236
+ // Make ajax request to sort out items.
237
+ var opts = {
238
+ url: envira_gallery_metabox.ajax,
239
+ type: 'post',
240
+ async: true,
241
+ cache: false,
242
+ dataType: 'json',
243
+ data: {
244
+ action: 'envira_gallery_sort_images',
245
+ order: gallery.sortable('toArray').toString(),
246
+ post_id: envira_gallery_metabox.id,
247
+ nonce: envira_gallery_metabox.sort
248
+ },
249
+ success: function(response) {
250
+ return;
251
+ },
252
+ error: function(xhr, textStatus ,e) {
253
+ return;
254
+ }
255
+ };
256
+ $.ajax(opts);
257
+ }
258
+ });
259
+
260
+ // Process image removal from a gallery.
261
+ $('#envira-gallery').on('click', '.envira-gallery-remove-image', function(e){
262
+ e.preventDefault();
263
+
264
+ // Bail out if the user does not actually want to remove the image.
265
+ var confirm_delete = confirm(envira_gallery_metabox.remove);
266
+ if ( ! confirm_delete )
267
+ return;
268
+
269
+ // Prepare our data to be sent via Ajax.
270
+ var attach_id = $(this).parent().attr('id'),
271
+ remove = {
272
+ action: 'envira_gallery_remove_image',
273
+ attachment_id: attach_id,
274
+ post_id: envira_gallery_metabox.id,
275
+ nonce: envira_gallery_metabox.remove_nonce
276
+ };
277
+
278
+ // Process the Ajax response and output all the necessary data.
279
+ $.post(
280
+ envira_gallery_metabox.ajax,
281
+ remove,
282
+ function(response) {
283
+ $('#' + attach_id).fadeOut('normal', function() {
284
+ $(this).remove();
285
+
286
+ // Refresh the modal view to ensure no items are still checked if they have been removed.
287
+ $('.envira-gallery-load-library').attr('data-envira-gallery-offset', 0).addClass('has-search').trigger('click');
288
+ });
289
+ },
290
+ 'json'
291
+ );
292
+ });
293
+
294
+ // Open up the media modal area for modifying gallery metadata.
295
+ $('#envira-gallery').on('click.enviraModify', '.envira-gallery-modify-image', function(e){
296
+ e.preventDefault();
297
+ var attach_id = $(this).parent().data('envira-gallery-image'),
298
+ formfield = 'envira-gallery-meta-' + attach_id;
299
+
300
+ // Show the modal.
301
+ envira_main_frame = true;
302
+ $('#' + formfield).appendTo('body').show();
303
+
304
+ // Close the modal window on user action
305
+ var append_and_hide = function(e){
306
+ e.preventDefault();
307
+ $('#' + formfield).appendTo('#' + attach_id).hide();
308
+ envira_main_frame = false;
309
+ };
310
+ $(document).on('click.enviraIframe', '.media-modal-close, .media-modal-backdrop', append_and_hide);
311
+ $(document).on('keydown.enviraIframe', function(e){
312
+ if ( 27 == e.keyCode && envira_main_frame )
313
+ append_and_hide(e);
314
+ });
315
+ });
316
+
317
+ // Save the gallery metadata.
318
+ $(document).on('click', '.envira-gallery-meta-submit', function(e){
319
+ e.preventDefault();
320
+ var $this = $(this),
321
+ default_t = $this.text(),
322
+ attach_id = $this.data('envira-gallery-item'),
323
+ formfield = 'envira-gallery-meta-' + attach_id,
324
+ meta = {};
325
+
326
+ // Output saving text...
327
+ $this.text(envira_gallery_metabox.saving);
328
+
329
+ // Add the title since it is a special field.
330
+ meta.caption = $('#envira-gallery-meta-table-' + attach_id).find('textarea[name="_envira_gallery[meta_caption]"]').val();
331
+
332
+ // Get all meta fields and values.
333
+ $('#envira-gallery-meta-table-' + attach_id).find(':input').not('.ed_button').each(function(i, el){
334
+ if ( $(this).data('envira-meta') )
335
+ meta[$(this).data('envira-meta')] = $(this).val();
336
+ });
337
+
338
+ // Prepare the data to be sent.
339
+ var data = {
340
+ action: 'envira_gallery_save_meta',
341
+ nonce: envira_gallery_metabox.save_nonce,
342
+ attach_id: attach_id,
343
+ post_id: envira_gallery_metabox.id,
344
+ meta: meta
345
+ };
346
+
347
+ $.post(
348
+ envira_gallery_metabox.ajax,
349
+ data,
350
+ function(res){
351
+ setTimeout(function(){
352
+ $('#' + formfield).appendTo('#' + attach_id).hide();
353
+ $this.text(default_t);
354
+ }, 500);
355
+ },
356
+ 'json'
357
+ );
358
+ });
359
+
360
+ // Append spinner when importing a gallery.
361
+ $('#envira-gallery-import-submit').on('click', function(e){
362
+ $(this).next().css('display', 'inline-block');
363
+ if ( $('#envira-config-import-gallery').val().length === 0 ) {
364
+ e.preventDefault();
365
+ $(this).next().hide();
366
+ alert(envira_gallery_metabox.import);
367
+ }
368
+ });
369
+
370
+ // Polling function for typing and other user centric items.
371
+ var delay = (function() {
372
+ var timer = 0;
373
+ return function(callback, ms) {
374
+ clearTimeout(timer);
375
+ timer = setTimeout(callback, ms);
376
+ };
377
+ })();
378
+
379
+ // Close the modal window on user action.
380
+ var envira_main_frame = false;
381
+ var append_and_hide = function(e){
382
+ e.preventDefault();
383
+ $('#envira-gallery-upload-ui').appendTo('#envira-gallery-upload-ui-wrapper').hide();
384
+ enviraRefresh();
385
+ envira_main_frame = false;
386
+ };
387
+ $(document).on('click', '#envira-gallery-upload-ui .media-modal-close, #envira-gallery-upload-ui .media-modal-backdrop', append_and_hide);
388
+ $(document).on('keydown', function(e){
389
+ if ( 27 == e.keyCode && envira_main_frame )
390
+ append_and_hide(e);
391
+ });
392
+
393
+ // Function to refresh images in the gallery.
394
+ function enviraRefresh(){
395
+ var data = {
396
+ action: 'envira_gallery_refresh',
397
+ post_id: envira_gallery_metabox.id,
398
+ nonce: envira_gallery_metabox.refresh_nonce
399
+ };
400
+
401
+ $('.envira-media-library').after('<span class="spinner envira-gallery-spinner envira-gallery-spinner-refresh"></span>');
402
+ $('.envira-gallery-spinner-refresh').css({'display' : 'inline-block', 'margin-top' : '-3px'});
403
+
404
+ $.post(
405
+ envira_gallery_metabox.ajax,
406
+ data,
407
+ function(res){
408
+ if ( res && res.success ) {
409
+ $('#envira-gallery-output').html(res.success);
410
+ $('#envira-gallery-output').find('.wp-editor-wrap').each(function(i, el){
411
+ var qt = $(el).find('.quicktags-toolbar');
412
+ if ( qt.length > 0 ) {
413
+ return;
414
+ }
415
+
416
+ var arr = $(el).attr('id').split('-'),
417
+ id = arr.slice(4, -1).join('-');
418
+ quicktags({id: 'envira-gallery-caption-' + id, buttons: 'strong,em,link,ul,ol,li,close'});
419
+ QTags._buttonsInit(); // Force buttons to initialize.
420
+ });
421
+
422
+ // Trigger a custom event for 3rd party scripts.
423
+ $('#envira-gallery-output').trigger({ type: 'enviraRefreshed', html: res.success, id: envira_gallery_metabox.id });
424
+ }
425
+
426
+ // Remove the spinner.
427
+ $('.envira-gallery-spinner-refresh').fadeOut(300, function(){
428
+ $(this).remove();
429
+ });
430
+ },
431
+ 'json'
432
+ );
433
+ }
434
+
435
+ // Function to show conditional fields.
436
+ function enviraConditionals() {
437
+ var envira_crop_option = $('#envira-config-crop'),
438
+ envira_mobile_option = $('#envira-config-mobile'),
439
+ envira_toolbar_option = $('#envira-config-lightbox-toolbar');
440
+ if ( envira_crop_option.is(':checked') )
441
+ $('#envira-config-crop-size-box').fadeIn(300);
442
+ envira_crop_option.on('change', function(){
443
+ if ( $(this).is(':checked') )
444
+ $('#envira-config-crop-size-box').fadeIn(300);
445
+ else
446
+ $('#envira-config-crop-size-box').fadeOut(300);
447
+ });
448
+ if ( envira_mobile_option.is(':checked') )
449
+ $('#envira-config-mobile-size-box').fadeIn(300);
450
+ envira_mobile_option.on('change', function(){
451
+ if ( $(this).is(':checked') )
452
+ $('#envira-config-mobile-size-box').fadeIn(300);
453
+ else
454
+ $('#envira-config-mobile-size-box').fadeOut(300);
455
+ });
456
+ if ( envira_toolbar_option.is(':checked') )
457
+ $('#envira-config-lightbox-toolbar-position-box').fadeIn(300);
458
+ envira_toolbar_option.on('change', function(){
459
+ if ( $(this).is(':checked') )
460
+ $('#envira-config-lightbox-toolbar-position-box').fadeIn(300);
461
+ else
462
+ $('#envira-config-lightbox-toolbar-position-box').fadeOut(300);
463
+ });
464
+ }
465
+
466
+ // Function to initialize plupload.
467
+ function enviraPlupload() {
468
+ // Append the custom loading progress bar.
469
+ $('#envira-gallery .drag-drop-inside').append('<div class="envira-progress-bar"><div></div></div>');
470
+
471
+ // Prepare variables.
472
+ envira_uploader = new plupload.Uploader(envira_gallery_metabox.plupload);
473
+ var envira_bar = $('#envira-gallery .envira-progress-bar'),
474
+ envira_progress = $('#envira-gallery .envira-progress-bar div'),
475
+ envira_output = $('#envira-gallery-output');
476
+
477
+ // Only move forward if the uploader is present.
478
+ if ( envira_uploader ) {
479
+ // Append a link to use images from the user's media library.
480
+ $('#envira-gallery .max-upload-size').append(' <a class="envira-media-library button button-primary" href="#" title="' + envira_gallery_metabox.gallery + '" style="vertical-align: baseline;">' + envira_gallery_metabox.gallery + '</a>');
481
+
482
+ envira_uploader.bind('Init', function(up) {
483
+ var uploaddiv = $('#envira-gallery-plupload-upload-ui');
484
+
485
+ // If drag and drop, make that happen.
486
+ if ( up.features.dragdrop && ! $(document.body).hasClass('mobile') ) {
487
+ uploaddiv.addClass('drag-drop');
488
+ $('#envira-gallery-drag-drop-area').bind('dragover.wp-uploader', function(){
489
+ uploaddiv.addClass('drag-over');
490
+ }).bind('dragleave.wp-uploader, drop.wp-uploader', function(){
491
+ uploaddiv.removeClass('drag-over');
492
+ });
493
+ } else {
494
+ uploaddiv.removeClass('drag-drop');
495
+ $('#envira-gallery-drag-drop-area').unbind('.wp-uploader');
496
+ }
497
+
498
+ // If we have an HTML4 runtime, hide the flash bypass.
499
+ if ( up.runtime == 'html4' )
500
+ $('.upload-flash-bypass').hide();
501
+ });
502
+
503
+ // Initialize the uploader.
504
+ envira_uploader.init();
505
+
506
+ // Bind to the FilesAdded event to show the progess bar.
507
+ envira_uploader.bind('FilesAdded', function(up, files){
508
+ var hundredmb = 100 * 1024 * 1024,
509
+ max = parseInt(up.settings.max_file_size, 10);
510
+
511
+ // Remove any errors.
512
+ $('#envira-gallery-upload-error').html('');
513
+
514
+ // Show the progress bar.
515
+ $(envira_bar).show().css('display', 'block');
516
+
517
+ // Upload the files.
518
+ plupload.each(files, function(file){
519
+ if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' ) {
520
+ enviraUploadError( up, file, true );
521
+ }
522
+ });
523
+
524
+ // Refresh and start.
525
+ up.refresh();
526
+ up.start();
527
+ });
528
+
529
+ // Bind to the UploadProgress event to manipulate the progress bar.
530
+ envira_uploader.bind('UploadProgress', function(up, file){
531
+ $(envira_progress).css('width', up.total.percent + '%');
532
+ });
533
+
534
+ // Bind to the FileUploaded event to set proper UI display for slider.
535
+ envira_uploader.bind('FileUploaded', function(up, file, info){
536
+ // Make an ajax request to generate and output the image in the slider UI.
537
+ $.post(
538
+ envira_gallery_metabox.ajax,
539
+ {
540
+ action: 'envira_gallery_load_image',
541
+ nonce: envira_gallery_metabox.load_image,
542
+ id: info.response,
543
+ post_id: envira_gallery_metabox.id
544
+ },
545
+ function(res){
546
+ $(envira_output).append(res);
547
+ $(res).find('.wp-editor-container').each(function(i, el){
548
+ var id = $(el).attr('id').split('-')[4];
549
+ quicktags({id: 'envira-gallery-caption-' + id, buttons: 'strong,em,link,ul,ol,li,close'});
550
+ QTags._buttonsInit(); // Force buttons to initialize.
551
+ });
552
+ },
553
+ 'json'
554
+ );
555
+ });
556
+
557
+ // Bind to the UploadComplete event to hide and reset the progress bar.
558
+ envira_uploader.bind('UploadComplete', function(){
559
+ $(envira_bar).hide().css('display', 'none');
560
+ $(envira_progress).removeAttr('style');
561
+ });
562
+
563
+ // Bind to any errors and output them on the screen.
564
+ envira_uploader.bind('Error', function(up, error) {
565
+ var hundredmb = 100 * 1024 * 1024,
566
+ error_el = $('#envira-gallery-upload-error'),
567
+ max;
568
+ switch (error) {
569
+ case plupload.FAILED:
570
+ case plupload.FILE_EXTENSION_ERROR:
571
+ error_el.html('<p class="error">' + pluploadL10n.upload_failed + '</p>');
572
+ break;
573
+ case plupload.FILE_SIZE_ERROR:
574
+ enviraUploadError(up, error.file);
575
+ break;
576
+ case plupload.IMAGE_FORMAT_ERROR:
577
+ wpFileError(fileObj, pluploadL10n.not_an_image);
578
+ break;
579
+ case plupload.IMAGE_MEMORY_ERROR:
580
+ wpFileError(fileObj, pluploadL10n.image_memory_exceeded);
581
+ break;
582
+ case plupload.IMAGE_DIMENSIONS_ERROR:
583
+ wpFileError(fileObj, pluploadL10n.image_dimensions_exceeded);
584
+ break;
585
+ case plupload.GENERIC_ERROR:
586
+ wpQueueError(pluploadL10n.upload_failed);
587
+ break;
588
+ case plupload.IO_ERROR:
589
+ max = parseInt(uploader.settings.max_file_size, 10);
590
+
591
+ if ( max > hundredmb && fileObj.size > hundredmb )
592
+ wpFileError(fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
593
+ else
594
+ wpQueueError(pluploadL10n.io_error);
595
+ break;
596
+ case plupload.HTTP_ERROR:
597
+ wpQueueError(pluploadL10n.http_error);
598
+ break;
599
+ case plupload.INIT_ERROR:
600
+ $('.media-upload-form').addClass('html-uploader');
601
+ break;
602
+ case plupload.SECURITY_ERROR:
603
+ wpQueueError(pluploadL10n.security_error);
604
+ break;
605
+ default:
606
+ wpFileError(fileObj, pluploadL10n.default_error);
607
+ }
608
+ up.refresh();
609
+ });
610
+ }
611
+ }
612
+
613
+ // Function for displaying file upload errors.
614
+ function enviraUploadError( up, file, over100mb ) {
615
+ var message;
616
+
617
+ if ( over100mb )
618
+ message = pluploadL10n.big_upload_queued.replace('%s', file.name) + ' ' + pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>');
619
+ else
620
+ message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);
621
+
622
+ $('#envira-gallery-upload-error').html('<p class="error">' + message + '</p>');
623
+ up.removeFile(file);
624
+ }
625
+ });
626
+ }(jQuery));
envira-gallery-lite.php ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Envira Gallery Lite
4
+ * Plugin URI: http://enviragallery.com
5
+ * Description: Envira Gallery is best responsive WordPress gallery plugin. This is the lite version.
6
+ * Author: Thomas Griffin
7
+ * Author URI: http://thomasgriffinmedia.com
8
+ * Version: 1.0.9
9
+ * Text Domain: envira-gallery
10
+ * Domain Path: languages
11
+ *
12
+ * Envira Gallery is free software: you can redistribute it and/or modify
13
+ * it under the terms of the GNU General Public License as published by
14
+ * the Free Software Foundation, either version 2 of the License, or
15
+ * any later version.
16
+ *
17
+ * Envira Gallery is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License
23
+ * along with Envira Gallery. If not, see <http://www.gnu.org/licenses/>.
24
+ */
25
+
26
+ // Exit if accessed directly.
27
+ if ( ! defined( 'ABSPATH' ) ) {
28
+ exit;
29
+ }
30
+
31
+ /**
32
+ * Main plugin class.
33
+ *
34
+ * @since 1.0.0
35
+ *
36
+ * @package Envira_Gallery_Lite
37
+ * @author Thomas Griffin
38
+ */
39
+ class Envira_Gallery_Lite {
40
+
41
+ /**
42
+ * Holds the class object.
43
+ *
44
+ * @since 1.0.0
45
+ *
46
+ * @var object
47
+ */
48
+ public static $instance;
49
+
50
+ /**
51
+ * Plugin version, used for cache-busting of style and script file references.
52
+ *
53
+ * @since 1.0.0
54
+ *
55
+ * @var string
56
+ */
57
+ public $version = '1.0.9';
58
+
59
+ /**
60
+ * The name of the plugin.
61
+ *
62
+ * @since 1.0.0
63
+ *
64
+ * @var string
65
+ */
66
+ public $plugin_name = 'Envira Gallery Lite';
67
+
68
+ /**
69
+ * Unique plugin slug identifier.
70
+ *
71
+ * @since 1.0.0
72
+ *
73
+ * @var string
74
+ */
75
+ public $plugin_slug = 'envira-gallery-lite';
76
+
77
+ /**
78
+ * Plugin textdomain.
79
+ *
80
+ * @since 1.0.0
81
+ *
82
+ * @var string
83
+ */
84
+ public $domain = 'envira-gallery';
85
+
86
+ /**
87
+ * Plugin file.
88
+ *
89
+ * @since 1.0.0
90
+ *
91
+ * @var string
92
+ */
93
+ public $file = __FILE__;
94
+
95
+ /**
96
+ * Limit helper for lite.
97
+ *
98
+ * @since 1.0.0
99
+ *
100
+ * @var bool
101
+ */
102
+ public $limit = false;
103
+
104
+ /**
105
+ * Number helper for lite.
106
+ *
107
+ * @since 1.0.0
108
+ *
109
+ * @var int
110
+ */
111
+ public $number = 0;
112
+
113
+ /**
114
+ * Primary class constructor.
115
+ *
116
+ * @since 1.0.0
117
+ */
118
+ public function __construct() {
119
+
120
+ // Fire a hook before the class is setup.
121
+ do_action( 'envira_gallery_pre_init' );
122
+
123
+ // Load the plugin textdomain.
124
+ add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ), 11 );
125
+
126
+ // Load the plugin.
127
+ add_action( 'init', array( $this, 'init' ), 1 );
128
+
129
+ }
130
+
131
+ /**
132
+ * Loads the plugin textdomain for translation.
133
+ *
134
+ * @since 1.0.0
135
+ */
136
+ public function load_plugin_textdomain() {
137
+
138
+ // Do nothing if the full version of Envira Gallery is already active.
139
+ if ( class_exists( 'Envira_Gallery' ) ) {
140
+ return;
141
+ }
142
+
143
+ $domain = $this->domain;
144
+ $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
145
+
146
+ load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
147
+ load_plugin_textdomain( $domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
148
+
149
+ }
150
+
151
+ /**
152
+ * Loads the plugin into WordPress.
153
+ *
154
+ * @since 1.0.0
155
+ */
156
+ public function init() {
157
+
158
+ // Do nothing if the full version of Envira Gallery is already active.
159
+ if ( class_exists( 'Envira_Gallery' ) ) {
160
+ return;
161
+ }
162
+
163
+ // Run hook once Envira has been initialized.
164
+ do_action( 'envira_gallery_init' );
165
+
166
+ // Load admin only components.
167
+ if ( is_admin() ) {
168
+ $this->require_admin();
169
+ }
170
+
171
+ // Load global components.
172
+ $this->require_global();
173
+
174
+ }
175
+
176
+ /**
177
+ * Loads all admin related files into scope.
178
+ *
179
+ * @since 1.0.0
180
+ */
181
+ public function require_admin() {
182
+
183
+ require plugin_dir_path( __FILE__ ) . 'includes/admin/ajax.php';
184
+ require plugin_dir_path( __FILE__ ) . 'includes/admin/common.php';
185
+ require plugin_dir_path( __FILE__ ) . 'includes/admin/editor.php';
186
+ require plugin_dir_path( __FILE__ ) . 'includes/admin/media.php';
187
+ require plugin_dir_path( __FILE__ ) . 'includes/admin/metaboxes.php';
188
+ require plugin_dir_path( __FILE__ ) . 'includes/admin/posttype.php';
189
+
190
+ }
191
+
192
+ /**
193
+ * Loads all global files into scope.
194
+ *
195
+ * @since 1.0.0
196
+ */
197
+ public function require_global() {
198
+
199
+ require plugin_dir_path( __FILE__ ) . 'includes/global/common.php';
200
+ require plugin_dir_path( __FILE__ ) . 'includes/global/posttype.php';
201
+ require plugin_dir_path( __FILE__ ) . 'includes/global/shortcode.php';
202
+
203
+ }
204
+
205
+ /**
206
+ * Returns a gallery based on ID.
207
+ *
208
+ * @since 1.0.0
209
+ *
210
+ * @param int $id The gallery ID used to retrieve a gallery.
211
+ * @return array|bool Array of gallery data or false if none found.
212
+ */
213
+ public function get_gallery( $id ) {
214
+
215
+ // Attempt to return the transient first, otherwise generate the new query to retrieve the data.
216
+ if ( false === ( $gallery = get_transient( '_eg_cache_' . $id ) ) ) {
217
+ $gallery = $this->_get_gallery( $id );
218
+ if ( $gallery ) {
219
+ set_transient( '_eg_cache_' . $id, $gallery, DAY_IN_SECONDS );
220
+ }
221
+ }
222
+
223
+ // Return the gallery data.
224
+ return $gallery;
225
+
226
+ }
227
+
228
+ /**
229
+ * Internal method that returns a gallery based on ID.
230
+ *
231
+ * @since 1.0.0
232
+ *
233
+ * @param int $id The gallery ID used to retrieve a gallery.
234
+ * @return array|bool Array of gallery data or false if none found.
235
+ */
236
+ public function _get_gallery( $id ) {
237
+
238
+ $gallery = get_post_meta( $id, '_eg_gallery_data', true );
239
+ if ( empty( $gallery ) || empty( $gallery['gallery'] ) ) {
240
+ return false;
241
+ } else {
242
+ return $gallery;
243
+ }
244
+
245
+ }
246
+
247
+ /**
248
+ * Returns a gallery based on slug.
249
+ *
250
+ * @since 1.0.0
251
+ *
252
+ * @param string $slug The gallery slug used to retrieve a gallery.
253
+ * @return array|bool Array of gallery data or false if none found.
254
+ */
255
+ public function get_gallery_by_slug( $slug ) {
256
+
257
+ // Attempt to return the transient first, otherwise generate the new query to retrieve the data.
258
+ if ( false === ( $gallery = get_transient( '_eg_cache_' . $slug ) ) ) {
259
+ $gallery = $this->_get_gallery_by_slug( $slug );
260
+ if ( $gallery ) {
261
+ set_transient( '_eg_cache_' . $slug, $gallery, DAY_IN_SECONDS );
262
+ }
263
+ }
264
+
265
+ // Return the gallery data.
266
+ return $gallery;
267
+
268
+ }
269
+
270
+ /**
271
+ * Internal method that returns a gallery based on slug.
272
+ *
273
+ * @since 1.0.0
274
+ *
275
+ * @param string $slug The gallery slug used to retrieve a gallery.
276
+ * @return array|bool Array of gallery data or false if none found.
277
+ */
278
+ public function _get_gallery_by_slug( $slug ) {
279
+
280
+ $galleries = get_posts(
281
+ array(
282
+ 'post_type' => 'any',
283
+ 'no_found_rows' => true,
284
+ 'cache_results' => false,
285
+ 'nopaging' => true,
286
+ 'fields' => 'ids',
287
+ 'meta_query' => array(
288
+ array(
289
+ 'key' => '_eg_gallery_data',
290
+ 'value' => maybe_serialize( strval( $slug ) ),
291
+ 'compare' => 'LIKE'
292
+ )
293
+ )
294
+ )
295
+ );
296
+ if ( empty( $galleries ) ) {
297
+ return false;
298
+ } else {
299
+ return get_post_meta( $galleries[0], '_eg_gallery_data', true );
300
+ }
301
+
302
+ }
303
+
304
+ /**
305
+ * Returns all galleries created on the site.
306
+ *
307
+ * @since 1.0.0
308
+ *
309
+ * @return array|bool Array of gallery data or false if none found.
310
+ */
311
+ public function get_galleries() {
312
+
313
+ // Attempt to return the transient first, otherwise generate the new query to retrieve the data.
314
+ if ( false === ( $galleries = get_transient( '_eg_cache_all' ) ) ) {
315
+ $galleries = $this->_get_galleries();
316
+ if ( $galleries ) {
317
+ set_transient( '_eg_cache_all', $galleries, DAY_IN_SECONDS );
318
+ }
319
+ }
320
+
321
+ // Return the gallery data.
322
+ return $galleries;
323
+
324
+ }
325
+
326
+ /**
327
+ * Internal method that returns all galleries created on the site.
328
+ *
329
+ * @since 1.0.0
330
+ *
331
+ * @return array|bool Array of gallery data or false if none found.
332
+ */
333
+ public function _get_galleries() {
334
+
335
+ $galleries = get_posts(
336
+ array(
337
+ 'post_type' => 'any',
338
+ 'no_found_rows' => true,
339
+ 'cache_results' => false,
340
+ 'nopaging' => true,
341
+ 'fields' => 'ids',
342
+ 'meta_query' => array(
343
+ array(
344
+ 'key' => '_eg_gallery_data'
345
+ )
346
+ )
347
+ )
348
+ );
349
+ if ( empty( $galleries ) ) {
350
+ return false;
351
+ }
352
+
353
+ // Now loop through all the galleries found and only use galleries that have images in them.
354
+ $ret = array();
355
+ foreach ( $galleries as $id ) {
356
+ $data = get_post_meta( $id, '_eg_gallery_data', true );
357
+ if ( empty( $data['gallery'] ) ) {
358
+ continue;
359
+ }
360
+
361
+ $ret[] = $data;
362
+ }
363
+
364
+ // Return the gallery data.
365
+ return $ret;
366
+
367
+ }
368
+
369
+ /**
370
+ * Returns the singleton instance of the class.
371
+ *
372
+ * @since 1.0.0
373
+ *
374
+ * @return object The Envira_Gallery_Lite object.
375
+ */
376
+ public static function get_instance() {
377
+
378
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Lite ) ) {
379
+ self::$instance = new Envira_Gallery_Lite();
380
+ }
381
+
382
+ return self::$instance;
383
+
384
+ }
385
+
386
+ }
387
+
388
+ register_activation_hook( __FILE__, 'envira_gallery_lite_activation_hook' );
389
+ /**
390
+ * Fired when the plugin is activated.
391
+ *
392
+ * @since 1.0.0
393
+ *
394
+ * @global int $wp_version The version of WordPress for this install.
395
+ * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false otherwise.
396
+ */
397
+ function envira_gallery_lite_activation_hook( $network_wide ) {
398
+
399
+ global $wp_version;
400
+ if ( version_compare( $wp_version, '3.8', '<' ) && ! defined( 'ENVIRA_FORCE_ACTIVATION' ) ) {
401
+ deactivate_plugins( plugin_basename( __FILE__ ) );
402
+ wp_die( sprintf( __( 'Sorry, but your version of WordPress does not meet Envira Gallery\'s required version of <strong>3.8</strong> to run properly. The plugin has been deactivated. <a href="%s">Click here to return to the Dashboard</a>.', 'envira-gallery' ), get_admin_url() ) );
403
+ }
404
+
405
+ }
406
+
407
+ // Load the main plugin class.
408
+ $envira_gallery_lite = Envira_Gallery_Lite::get_instance();
409
+
410
+ // Conditionally load the template tag.
411
+ if ( ! function_exists( 'envira_gallery' ) ) {
412
+ /**
413
+ * Primary template tag for outputting Envira galleries in templates.
414
+ *
415
+ * @since 1.0.0
416
+ *
417
+ * @param int $gallery_id The ID of the gallery to load.
418
+ * @param string $type The type of field to query.
419
+ * @param array $args Associative array of args to be passed.
420
+ * @param bool $return Flag to echo or return the gallery HTML.
421
+ */
422
+ function envira_gallery( $id, $type = 'id', $args = array(), $return = false ) {
423
+
424
+ // If we have args, build them into a shortcode format.
425
+ $args_string = '';
426
+ if ( ! empty( $args ) ) {
427
+ foreach ( (array) $args as $key => $value ) {
428
+ $args_string .= ' ' . $key . '="' . $value . '"';
429
+ }
430
+ }
431
+
432
+ // Build the shortcode.
433
+ $shortcode = ! empty( $args_string ) ? '[envira-gallery ' . $type . '="' . $id . '"' . $args_string . ']' : '[envira-gallery ' . $type . '="' . $id . '"]';
434
+
435
+ // Return or echo the shortcode output.
436
+ if ( $return ) {
437
+ return do_shortcode( $shortcode );
438
+ } else {
439
+ echo do_shortcode( $shortcode );
440
+ }
441
+
442
+ }
443
+ }
includes/admin/ajax.php ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handles all admin ajax interactions for the Envira Gallery plugin.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+
11
+ add_action( 'wp_ajax_envira_gallery_load_image', 'envira_gallery_lite_ajax_load_image' );
12
+ /**
13
+ * Loads an image into a gallery.
14
+ *
15
+ * @since 1.0.0
16
+ */
17
+ function envira_gallery_lite_ajax_load_image() {
18
+
19
+ // Run a security check first.
20
+ check_ajax_referer( 'envira-gallery-load-image', 'nonce' );
21
+
22
+ // Prepare variables.
23
+ $id = absint( $_POST['id'] );
24
+ $post_id = absint( $_POST['post_id'] );
25
+
26
+ // Set post meta to show that this image is attached to one or more Envira galleries.
27
+ $has_gallery = get_post_meta( $id, '_eg_has_gallery', true );
28
+ if ( empty( $has_gallery ) ) {
29
+ $has_gallery = array();
30
+ }
31
+
32
+ $has_gallery[] = $post_id;
33
+ update_post_meta( $id, '_eg_has_gallery', $has_gallery );
34
+
35
+ // Set post meta to show that this image is attached to a gallery on this page.
36
+ $in_gallery = get_post_meta( $post_id, '_eg_in_gallery', true );
37
+ if ( empty( $in_gallery ) ) {
38
+ $in_gallery = array();
39
+ }
40
+
41
+ $in_gallery[] = $id;
42
+ update_post_meta( $post_id, '_eg_in_gallery', $in_gallery );
43
+
44
+ // Set data and order of image in gallery.
45
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
46
+ if ( empty( $gallery_data ) ) {
47
+ $gallery_data = array();
48
+ }
49
+
50
+ // If no gallery ID has been set, set it now.
51
+ if ( empty( $gallery_data['id'] ) ) {
52
+ $gallery_data['id'] = $post_id;
53
+ }
54
+
55
+ // Set data and update the meta information.
56
+ $gallery_data = envira_gallery_lite_ajax_prepare_gallery_data( $gallery_data, $id );
57
+ update_post_meta( $post_id, '_eg_gallery_data', $gallery_data );
58
+
59
+ // Run hook before building out the item.
60
+ do_action( 'envira_gallery_ajax_load_image', $id, $post_id );
61
+
62
+ // Build out the individual HTML output for the gallery image that has just been uploaded.
63
+ $html = Envira_Gallery_Metaboxes_Lite::get_instance()->get_gallery_item( $id, $gallery_data['gallery'][$id], $post_id );
64
+
65
+ // Flush the gallery cache.
66
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $post_id );
67
+
68
+ echo json_encode( $html );
69
+ die;
70
+
71
+ }
72
+
73
+ add_action( 'wp_ajax_envira_gallery_load_library', 'envira_gallery_lite_ajax_load_library' );
74
+ /**
75
+ * Loads the Media Library images into the media modal window for selection.
76
+ *
77
+ * @since 1.0.0
78
+ */
79
+ function envira_gallery_lite_ajax_load_library() {
80
+
81
+ // Run a security check first.
82
+ check_ajax_referer( 'envira-gallery-load-gallery', 'nonce' );
83
+
84
+ // Prepare variables.
85
+ $offset = (int) $_POST['offset'];
86
+ $post_id = absint( $_POST['post_id'] );
87
+ $html = '';
88
+
89
+ // Grab the library contents with the included offset parameter.
90
+ $library = get_posts( array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'any', 'posts_per_page' => 20, 'offset' => $offset ) );
91
+ if ( $library ) {
92
+ foreach ( (array) $library as $image ) {
93
+ $has_gallery = get_post_meta( $image->ID, '_eg_has_gallery', true );
94
+ $class = $has_gallery && in_array( $post_id, (array) $has_gallery ) ? ' selected envira-gallery-in-gallery' : '';
95
+
96
+ $html .= '<li class="attachment' . $class . '" data-attachment-id="' . absint( $image->ID ) . '">';
97
+ $html .= '<div class="attachment-preview landscape">';
98
+ $html .= '<div class="thumbnail">';
99
+ $html .= '<div class="centered">';
100
+ $src = wp_get_attachment_image_src( $image->ID, 'thumbnail' );
101
+ $html .= '<img src="' . esc_url( $src[0] ) . '" />';
102
+ $html .= '</div>';
103
+ $html .= '</div>';
104
+ $html .= '<a class="check" href="#"><div class="media-modal-icon"></div></a>';
105
+ $html .= '</div>';
106
+ $html .= '</li>';
107
+ }
108
+ }
109
+
110
+ echo json_encode( array( 'html' => stripslashes( $html ) ) );
111
+ die;
112
+
113
+ }
114
+
115
+ add_action( 'wp_ajax_envira_gallery_library_search', 'envira_gallery_lite_ajax_library_search' );
116
+ /**
117
+ * Searches the Media Library for images matching the term specified in the search.
118
+ *
119
+ * @since 1.0.0
120
+ */
121
+ function envira_gallery_lite_ajax_library_search() {
122
+
123
+ // Run a security check first.
124
+ check_ajax_referer( 'envira-gallery-library-search', 'nonce' );
125
+
126
+ // Prepare variables.
127
+ $search = stripslashes( $_POST['search'] );
128
+ $post_id = absint( $_POST['post_id'] );
129
+ $html = '';
130
+
131
+ // Grab the library contents with the included offset parameter.
132
+ $library = get_posts( array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'any', 'posts_per_page' => -1, 's' => $search ) );
133
+ if ( $library ) {
134
+ foreach ( (array) $library as $image ) {
135
+ $has_gallery = get_post_meta( $image->ID, '_eg_has_gallery', true );
136
+ $class = $has_gallery && in_array( $post_id, (array) $has_gallery ) ? ' selected envira-gallery-in-gallery' : '';
137
+
138
+ $html .= '<li class="attachment' . $class . '" data-attachment-id="' . absint( $image->ID ) . '">';
139
+ $html .= '<div class="attachment-preview landscape">';
140
+ $html .= '<div class="thumbnail">';
141
+ $html .= '<div class="centered">';
142
+ $src = wp_get_attachment_image_src( $image->ID, 'thumbnail' );
143
+ $html .= '<img src="' . esc_url( $src[0] ) . '" />';
144
+ $html .= '</div>';
145
+ $html .= '</div>';
146
+ $html .= '<a class="check" href="#"><div class="media-modal-icon"></div></a>';
147
+ $html .= '</div>';
148
+ $html .= '</li>';
149
+ }
150
+ }
151
+
152
+ echo json_encode( array( 'html' => stripslashes( $html ) ) );
153
+ die;
154
+
155
+ }
156
+
157
+ add_action( 'wp_ajax_envira_gallery_insert_images', 'envira_gallery_lite_ajax_insert_images' );
158
+ /**
159
+ * Inserts one or more images from the Media Library into a gallery.
160
+ *
161
+ * @since 1.0.0
162
+ */
163
+ function envira_gallery_lite_ajax_insert_images() {
164
+
165
+ // Run a security check first.
166
+ check_ajax_referer( 'envira-gallery-insert-images', 'nonce' );
167
+
168
+ // Prepare variables.
169
+ $images = stripslashes_deep( (array) $_POST['images'] );
170
+ $post_id = absint( $_POST['post_id'] );
171
+
172
+ // Grab and update any gallery data if necessary.
173
+ $in_gallery = get_post_meta( $post_id, '_eg_in_gallery', true );
174
+ if ( empty( $in_gallery ) ) {
175
+ $in_gallery = array();
176
+ }
177
+
178
+ // Set data and order of image in gallery.
179
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
180
+ if ( empty( $gallery_data ) ) {
181
+ $gallery_data = array();
182
+ }
183
+
184
+ // If no gallery ID has been set, set it now.
185
+ if ( empty( $gallery_data['id'] ) ) {
186
+ $gallery_data['id'] = $post_id;
187
+ }
188
+
189
+ // Loop through the images and add them to the gallery.
190
+ foreach ( (array) $images as $i => $id ) {
191
+ // Update the attachment image post meta first.
192
+ $has_gallery = get_post_meta( $id, '_eg_has_gallery', true );
193
+ if ( empty( $has_gallery ) ) {
194
+ $has_gallery = array();
195
+ }
196
+
197
+ $has_gallery[] = $post_id;
198
+ update_post_meta( $id, '_eg_has_gallery', $has_gallery );
199
+
200
+ // Now add the image to the gallery for this particular post.
201
+ $in_gallery[] = $id;
202
+ $gallery_data = envira_gallery_lite_ajax_prepare_gallery_data( $gallery_data, $id );
203
+ }
204
+
205
+ // Update the gallery data.
206
+ update_post_meta( $post_id, '_eg_in_gallery', $in_gallery );
207
+ update_post_meta( $post_id, '_eg_gallery_data', $gallery_data );
208
+
209
+ // Run hook before finishing.
210
+ do_action( 'envira_gallery_ajax_insert_images', $images, $post_id );
211
+
212
+ // Flush the gallery cache.
213
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $post_id );
214
+
215
+ echo json_encode( true );
216
+ die;
217
+
218
+ }
219
+
220
+ add_action( 'wp_ajax_envira_gallery_sort_images', 'envira_gallery_lite_ajax_sort_images' );
221
+ /**
222
+ * Sorts images based on user-dragged position in the gallery.
223
+ *
224
+ * @since 1.0.0
225
+ */
226
+ function envira_gallery_lite_ajax_sort_images() {
227
+
228
+ // Run a security check first.
229
+ check_ajax_referer( 'envira-gallery-sort', 'nonce' );
230
+
231
+ // Prepare variables.
232
+ $order = explode( ',', $_POST['order'] );
233
+ $post_id = absint( $_POST['post_id'] );
234
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
235
+ $new_order = array();
236
+
237
+ // Loop through the order and generate a new array based on order received.
238
+ foreach ( $order as $id ) {
239
+ $new_order['gallery'][$id] = $gallery_data['gallery'][$id];
240
+ }
241
+
242
+ // Update the gallery data.
243
+ update_post_meta( $post_id, '_eg_gallery_data', $new_order );
244
+
245
+ // Flush the gallery cache.
246
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $post_id );
247
+
248
+ echo json_encode( true );
249
+ die;
250
+
251
+ }
252
+
253
+ add_action( 'wp_ajax_envira_gallery_remove_image', 'envira_gallery_lite_ajax_remove_image' );
254
+ /**
255
+ * Removes an image from a gallery.
256
+ *
257
+ * @since 1.0.0
258
+ */
259
+ function envira_gallery_lite_ajax_remove_image() {
260
+
261
+ // Run a security check first.
262
+ check_ajax_referer( 'envira-gallery-remove-image', 'nonce' );
263
+
264
+ // Prepare variables.
265
+ $post_id = absint( $_POST['post_id'] );
266
+ $attach_id = absint( $_POST['attachment_id'] );
267
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
268
+ $in_gallery = get_post_meta( $post_id, '_eg_in_gallery', true );
269
+ $has_gallery = get_post_meta( $attach_id, '_eg_has_gallery', true );
270
+
271
+ // Unset the image from the gallery, in_gallery and has_gallery checkers.
272
+ unset( $gallery_data['gallery'][$attach_id] );
273
+
274
+ if ( ( $key = array_search( $attach_id, (array) $in_gallery ) ) !== false ) {
275
+ unset( $in_gallery[$key] );
276
+ }
277
+
278
+ if ( ( $key = array_search( $post_id, (array) $has_gallery ) ) !== false ) {
279
+ unset( $has_gallery[$key] );
280
+ }
281
+
282
+ // Update the gallery data.
283
+ update_post_meta( $post_id, '_eg_gallery_data', $gallery_data );
284
+ update_post_meta( $post_id, '_eg_in_gallery', $in_gallery );
285
+ update_post_meta( $attach_id, '_eg_has_gallery', $has_gallery );
286
+
287
+ // Run hook before finishing the reponse.
288
+ do_action( 'envira_gallery_ajax_remove_images', $attach_id, $post_id );
289
+
290
+ // Flush the gallery cache.
291
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $post_id );
292
+
293
+ echo json_encode( true );
294
+ die;
295
+
296
+ }
297
+
298
+ add_action( 'wp_ajax_envira_gallery_save_meta', 'envira_gallery_lite_ajax_save_meta' );
299
+ /**
300
+ * Saves the metadata for an image in a gallery.
301
+ *
302
+ * @since 1.0.0
303
+ */
304
+ function envira_gallery_lite_ajax_save_meta() {
305
+
306
+ // Run a security check first.
307
+ check_ajax_referer( 'envira-gallery-save-meta', 'nonce' );
308
+
309
+ // Prepare variables.
310
+ $post_id = absint( $_POST['post_id'] );
311
+ $attach_id = absint( $_POST['attach_id'] );
312
+ $meta = $_POST['meta'];
313
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
314
+
315
+ if ( isset( $meta['title'] ) ) {
316
+ $gallery_data['gallery'][$attach_id]['title'] = trim( $meta['title'] );
317
+ }
318
+
319
+ if ( isset( $meta['alt'] ) ) {
320
+ $gallery_data['gallery'][$attach_id]['alt'] = trim( esc_html( $meta['alt'] ) );
321
+ }
322
+
323
+ if ( isset( $meta['link'] ) ) {
324
+ $gallery_data['gallery'][$attach_id]['link'] = esc_url( $meta['link'] );
325
+ }
326
+
327
+ // Allow filtering of meta before saving.
328
+ $gallery_data = apply_filters( 'envira_gallery_ajax_save_meta', $gallery_data, $meta, $attach_id, $post_id );
329
+
330
+ // Update the gallery data.
331
+ update_post_meta( $post_id, '_eg_gallery_data', $gallery_data );
332
+
333
+ // Flush the gallery cache.
334
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $post_id );
335
+
336
+ echo json_encode( true );
337
+ die;
338
+
339
+ }
340
+
341
+ add_action( 'wp_ajax_envira_gallery_refresh', 'envira_gallery_lite_ajax_refresh' );
342
+ /**
343
+ * Refreshes the DOM view for a gallery.
344
+ *
345
+ * @since 1.0.0
346
+ */
347
+ function envira_gallery_lite_ajax_refresh() {
348
+
349
+ // Run a security check first.
350
+ check_ajax_referer( 'envira-gallery-refresh', 'nonce' );
351
+
352
+ // Prepare variables.
353
+ $post_id = absint( $_POST['post_id'] );
354
+ $gallery = '';
355
+
356
+ // Grab all gallery data.
357
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
358
+
359
+ // If there are no gallery items, don't do anything.
360
+ if ( empty( $gallery_data ) || empty( $gallery_data['gallery'] ) ) {
361
+ echo json_encode( array( 'error' => true ) );
362
+ die;
363
+ }
364
+
365
+ // Loop through the data and build out the gallery view.
366
+ foreach ( (array) $gallery_data['gallery'] as $id => $data ) {
367
+ $gallery .= Envira_Gallery_Metaboxes_Lite::get_instance()->get_gallery_item( $id, $data, $post_id );
368
+ }
369
+
370
+ echo json_encode( array( 'success' => $gallery ) );
371
+ die;
372
+
373
+ }
374
+
375
+ add_action( 'wp_ajax_envira_gallery_load_gallery_data', 'envira_gallery_lite_ajax_load_gallery_data' );
376
+ /**
377
+ * Retrieves and return gallery data for the specified ID.
378
+ *
379
+ * @since 1.0.0
380
+ */
381
+ function envira_gallery_lite_ajax_load_gallery_data() {
382
+
383
+ // Prepare variables and grab the gallery data.
384
+ $gallery_id = absint( $_POST['post_id'] );
385
+ $gallery_data = get_post_meta( $gallery_id, '_eg_gallery_data', true );
386
+
387
+ // Send back the gallery data.
388
+ echo json_encode( $gallery_data );
389
+ die;
390
+
391
+ }
392
+
393
+ /**
394
+ * Helper function to prepare the metadata for an image in a gallery.
395
+ *
396
+ * @since 1.0.0
397
+ *
398
+ * @param array $gallery_data Array of data for the gallery.
399
+ * @param int $id The attachment ID to prepare data for.
400
+ * @return array $gallery_data Amended gallery data with updated image metadata.
401
+ */
402
+ function envira_gallery_lite_ajax_prepare_gallery_data( $gallery_data, $id ) {
403
+
404
+ $attachment = get_post( $id );
405
+ $url = wp_get_attachment_image_src( $id, 'full' );
406
+ $alt_text = get_post_meta( $id, '_wp_attachment_image_alt', true );
407
+ $gallery_data['gallery'][$id] = array(
408
+ 'status' => 'pending',
409
+ 'src' => isset( $url[0] ) ? esc_url( $url[0] ) : '',
410
+ 'title' => get_the_title( $id ),
411
+ 'link' => isset( $url[0] ) ? esc_url( $url[0] ) : '',
412
+ 'alt' => ! empty( $alt_text ) ? $alt_text : '',
413
+ 'thumb' => ''
414
+ );
415
+
416
+ $gallery_data = apply_filters( 'envira_gallery_ajax_item_data', $gallery_data, $attachment, $id );
417
+
418
+ return $gallery_data;
419
+
420
+ }
includes/admin/common.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Common admin class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Common_Admin_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Load the base class object.
47
+ $this->base = Envira_Gallery_Lite::get_instance();
48
+
49
+ // Delete any gallery association on attachment deletion. Also delete any extra cropped images.
50
+ add_action( 'delete_attachment', array( $this, 'delete_gallery_association' ) );
51
+ add_action( 'delete_attachment', array( $this, 'delete_cropped_image' ) );
52
+
53
+ // Ensure gallery display is correct when trashing/untrashing galleries.
54
+ add_action( 'wp_trash_post', array( $this, 'trash_gallery' ) );
55
+ add_action( 'untrash_post', array( $this, 'untrash_gallery' ) );
56
+
57
+ }
58
+
59
+ /**
60
+ * Deletes the Envira gallery association for the image being deleted.
61
+ *
62
+ * @since 1.0.0
63
+ *
64
+ * @param int $attach_id The attachment ID being deleted.
65
+ */
66
+ public function delete_gallery_association( $attach_id ) {
67
+
68
+ $has_gallery = get_post_meta( $attach_id, '_eg_has_gallery', true );
69
+
70
+ // Only proceed if the image is attached to any Envira galleries.
71
+ if ( ! empty( $has_gallery ) ) {
72
+ foreach ( (array) $has_gallery as $post_id ) {
73
+ // Remove the in_gallery association.
74
+ $in_gallery = get_post_meta( $post_id, '_eg_in_gallery', true );
75
+ if ( ! empty( $in_gallery ) ) {
76
+ if ( ( $key = array_search( $attach_id, (array) $in_gallery ) ) !== false ) {
77
+ unset( $in_gallery[$key] );
78
+ }
79
+ }
80
+
81
+ update_post_meta( $post_id, '_eg_in_gallery', $in_gallery );
82
+
83
+ // Remove the image from the gallery altogether.
84
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
85
+ if ( ! empty( $gallery_data['gallery'] ) ) {
86
+ unset( $gallery_data['gallery'][$attach_id] );
87
+ }
88
+
89
+ // Update the post meta for the gallery.
90
+ update_post_meta( $post_id, '_eg_gallery_data', $gallery_data );
91
+
92
+ // Flush necessary gallery caches.
93
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $post_id, ( ! empty( $gallery_data['config']['slug'] ) ? $gallery_data['config']['slug'] : '' ) );
94
+ }
95
+ }
96
+
97
+ }
98
+
99
+ /**
100
+ * Removes any extra cropped images when an attachment is deleted.
101
+ *
102
+ * @since 1.0.0
103
+ *
104
+ * @param int $post_id The post ID.
105
+ * @return null Return early if the appropriate metadata cannot be retrieved.
106
+ */
107
+ public function delete_cropped_image( $post_id ) {
108
+
109
+ // Get attachment image metadata.
110
+ $metadata = wp_get_attachment_metadata( $post_id );
111
+
112
+ // Return if no metadata is found.
113
+ if ( ! $metadata ) {
114
+ return;
115
+ }
116
+
117
+ // Return if we don't have the proper metadata.
118
+ if ( ! isset( $metadata['file'] ) || ! isset( $metadata['image_meta']['resized_images'] ) ) {
119
+ return;
120
+ }
121
+
122
+ // Grab the necessary info to removed the cropped images.
123
+ $wp_upload_dir = wp_upload_dir();
124
+ $pathinfo = pathinfo( $metadata['file'] );
125
+ $resized_images = $metadata['image_meta']['resized_images'];
126
+
127
+ // Loop through and deleted and resized/cropped images.
128
+ foreach ( $resized_images as $dims ) {
129
+ // Get the resized images filename and delete the image.
130
+ $file = $wp_upload_dir['basedir'] . '/' . $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '-' . $dims . '.' . $pathinfo['extension'];
131
+
132
+ // Delete the resized image.
133
+ if ( file_exists( $file ) ) {
134
+ @unlink( $file );
135
+ }
136
+ }
137
+
138
+ }
139
+
140
+ /**
141
+ * Trash a gallery when the gallery post type is trashed.
142
+ *
143
+ * @since 1.0.0
144
+ *
145
+ * @param $id The post ID being trashed.
146
+ * @return null Return early if no gallery is found.
147
+ */
148
+ public function trash_gallery( $id ) {
149
+
150
+ $gallery = get_post( $id );
151
+
152
+ // Flush necessary gallery caches to ensure trashed galleries are not showing.
153
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $id );
154
+
155
+ // Return early if not an Envira gallery.
156
+ if ( 'envira' !== $gallery->post_type ) {
157
+ return;
158
+ }
159
+
160
+ // Set the gallery status to inactive.
161
+ $gallery_data = get_post_meta( $id, '_eg_gallery_data', true );
162
+ if ( empty( $gallery_data ) ) {
163
+ return;
164
+ }
165
+
166
+ $gallery_data['status'] = 'inactive';
167
+ update_post_meta( $id, '_eg_gallery_data', $gallery_data );
168
+
169
+ }
170
+
171
+ /**
172
+ * Untrash a gallery when the gallery post type is untrashed.
173
+ *
174
+ * @since 1.0.0
175
+ *
176
+ * @param $id The post ID being untrashed.
177
+ * @return null Return early if no gallery is found.
178
+ */
179
+ public function untrash_gallery( $id ) {
180
+
181
+ $gallery = get_post( $id );
182
+
183
+ // Flush necessary gallery caches to ensure untrashed galleries are showing.
184
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $id );
185
+
186
+ // Return early if not an Envira gallery.
187
+ if ( 'envira' !== $gallery->post_type ) {
188
+ return;
189
+ }
190
+
191
+ // Set the gallery status to inactive.
192
+ $gallery_data = get_post_meta( $id, '_eg_gallery_data', true );
193
+ if ( empty( $gallery_data ) ) {
194
+ return;
195
+ }
196
+
197
+ if ( isset( $gallery_data['status'] ) ) {
198
+ unset( $gallery_data['status'] );
199
+ }
200
+
201
+ update_post_meta( $id, '_eg_gallery_data', $gallery_data );
202
+
203
+ }
204
+
205
+ /**
206
+ * Returns the singleton instance of the class.
207
+ *
208
+ * @since 1.0.0
209
+ *
210
+ * @return object The Envira_Gallery_Common_Admin_Lite object.
211
+ */
212
+ public static function get_instance() {
213
+
214
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Common_Admin_Lite ) ) {
215
+ self::$instance = new Envira_Gallery_Common_Admin_Lite();
216
+ }
217
+
218
+ return self::$instance;
219
+
220
+ }
221
+
222
+ }
223
+
224
+ // Load the common admin class.
225
+ $envira_gallery_common_admin_lite = Envira_Gallery_Common_Admin_Lite::get_instance();
includes/admin/editor.php ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Editor class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Editor_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Flag to determine if media modal is loaded.
41
+ *
42
+ * @since 1.0.0
43
+ *
44
+ * @var object
45
+ */
46
+ public $loaded = false;
47
+
48
+ /**
49
+ * Primary class constructor.
50
+ *
51
+ * @since 1.0.0
52
+ */
53
+ public function __construct() {
54
+
55
+ // Load the base class object.
56
+ $this->base = Envira_Gallery_Lite::get_instance();
57
+
58
+ // Add a custom media button to the editor.
59
+ add_filter( 'media_buttons_context', array( $this, 'media_button' ) );
60
+
61
+ }
62
+
63
+ /**
64
+ * Adds a custom gallery insert button beside the media uploader button.
65
+ *
66
+ * @since 1.0.0
67
+ *
68
+ * @param string $buttons The media buttons context HTML.
69
+ * @return string $buttons Amended media buttons context HTML.
70
+ */
71
+ public function media_button( $buttons ) {
72
+
73
+ // Create the media button.
74
+ $button = '<style type="text/css">@media only screen and (-webkit-min-device-pixel-ratio: 2),only screen and (min--moz-device-pixel-ratio: 2),only screen and (-o-min-device-pixel-ratio: 2/1),only screen and (min-device-pixel-ratio: 2),only screen and (min-resolution: 192dpi),only screen and (min-resolution: 2dppx) { #envira-media-modal-button .envira-media-icon[style] { background-image: url(' . plugins_url( 'assets/css/images/menu-icon@2x.png', $this->base->file ) . ') !important; background-size: 16px 16px !important; } }</style>';
75
+ $button .= '<a id="envira-media-modal-button" href="#" class="button envira-gallery-choose-gallery" title="' . esc_attr__( 'Add Gallery', 'envira-gallery' ) . '" style="padding-left: .4em;"><span class="envira-media-icon" style="background: transparent url(' . plugins_url( 'assets/css/images/menu-icon.png', $this->base->file ) . ') no-repeat scroll 0 0; width: 16px; height: 16px; display: inline-block; vertical-align: text-top;"></span> ' . __( 'Add Gallery', 'envira-gallery' ) . '</a>';
76
+
77
+ // Enqueue the script that will trigger the editor button.
78
+ wp_enqueue_script( $this->base->plugin_slug . '-editor-script', plugins_url( 'assets/js/editor.js', $this->base->file ), array( 'jquery' ), $this->base->version, true );
79
+
80
+ // Add the action to the footer to output the modal window.
81
+ add_action( 'admin_footer', array( $this, 'gallery_selection_modal' ) );
82
+
83
+ // Append the button.
84
+ return $buttons . $button;
85
+
86
+ }
87
+
88
+ /**
89
+ * Outputs the gallery selection modal to insert a gallery into an editor.
90
+ *
91
+ * @since 1.0.0
92
+ */
93
+ public function gallery_selection_modal() {
94
+
95
+ echo $this->get_gallery_selection_modal();
96
+
97
+ }
98
+
99
+ /**
100
+ * Returns the gallery selection modal to insert a gallery into an editor.
101
+ *
102
+ * @since 1.0.0
103
+ *
104
+ * @global object $post The current post object.
105
+ * @return string Empty string if no galleries are found, otherwise modal UI.
106
+ */
107
+ public function get_gallery_selection_modal() {
108
+
109
+ // Return early if already loaded.
110
+ if ( $this->loaded ) {
111
+ return '';
112
+ }
113
+
114
+ // Set the loaded flag to true.
115
+ $this->loaded = true;
116
+
117
+ global $post;
118
+ $galleries = $this->base->get_galleries();
119
+
120
+ ob_start();
121
+ ?>
122
+ <div class="envira-gallery-default-ui-wrapper" style="display: none;">
123
+ <div class="envira-gallery-default-ui envira-gallery-image-meta">
124
+ <div class="media-modal wp-core-ui">
125
+ <a class="media-modal-close" href="#"><span class="media-modal-icon"></span>
126
+ </a>
127
+ <div class="media-modal-content">
128
+ <div class="media-frame wp-core-ui hide-menu hide-router envira-gallery-meta-wrap">
129
+ <div class="media-frame-title">
130
+ <h1><?php _e( 'Choose Your Gallery', 'envira-gallery' ); ?></h1>
131
+ </div>
132
+ <div class="media-frame-content">
133
+ <div class="attachments-browser">
134
+ <ul class="envira-gallery-meta attachments" style="padding-left: 8px; top: 1em;">
135
+ <li class="attachment" data-envira-gallery-id="<?php echo absint( $post->ID ); ?>" style="margin: 8px;">
136
+ <div class="attachment-preview landscape">
137
+ <div class="thumbnail" style="display: table;">
138
+ <div style="display: table-cell; vertical-align: middle; text-align: center;">
139
+ <h3 style="margin: 0;color: #7ad03a;"><?php _e( 'This Post\'s Gallery', 'envira-gallery' ); ?></h3>
140
+ <code style="color: #7ad03a;">[envira-gallery id="<?php echo absint( $post->ID ); ?>"]</code>
141
+ </div>
142
+ </div>
143
+ <a class="check" href="#"><div class="media-modal-icon"></div></a>
144
+ </div>
145
+ </li>
146
+ <?php foreach ( (array) $galleries as $gallery ) : if ( $post->ID == $gallery['id'] ) continue; ?>
147
+ <li class="attachment" data-envira-gallery-id="<?php echo absint( $gallery['id'] ); ?>" style="margin: 8px;">
148
+ <div class="attachment-preview landscape">
149
+ <div class="thumbnail" style="display: table;">
150
+ <div style="display: table-cell; vertical-align: middle; text-align: center;">
151
+ <?php
152
+ if ( ! empty( $gallery['config']['title'] ) ) {
153
+ $title = $gallery['config']['title'];
154
+ } else if ( ! empty( $gallery['config']['slug'] ) ) {
155
+ $title = $gallery['config']['title'];
156
+ } else {
157
+ $title = sprintf( __( 'Gallery ID #%s', 'envira-gallery' ), $gallery['id'] );
158
+ }
159
+ ?>
160
+ <h3 style="margin: 0;"><?php echo $title; ?></h3>
161
+ <code>[envira-gallery id="<?php echo absint( $gallery['id'] ); ?>"]</code>
162
+ </div>
163
+ </div>
164
+ <a class="check" href="#"><div class="media-modal-icon"></div></a>
165
+ </div>
166
+ </li>
167
+ <?php endforeach; ?>
168
+ </ul>
169
+ <!-- end .envira-gallery-meta -->
170
+ <div class="media-sidebar">
171
+ <div class="envira-gallery-meta-sidebar">
172
+ <h3 style="margin: 1.4em 0 1em;"><?php _e( 'Helpful Tips', 'envira-gallery' ); ?></h3>
173
+ <strong><?php _e( 'Choosing Your Gallery', 'envira-gallery' ); ?></strong>
174
+ <p style="margin: 0 0 1.5em;"><?php _e( 'To choose your gallery, simply click on one of the boxes to the left. The "Insert Gallery" button will be activated once you have selected a gallery.', 'envira-gallery' ); ?></p>
175
+ <strong><?php _e( 'Inserting Your Gallery', 'envira-gallery' ); ?></strong>
176
+ <p style="margin: 0 0 1.5em;"><?php _e( 'To insert your gallery into the editor, click on the "Insert Gallery" button below.', 'envira-gallery' ); ?></p>
177
+ </div>
178
+ <!-- end .envira-gallery-meta-sidebar -->
179
+ </div>
180
+ <!-- end .media-sidebar -->
181
+ </div>
182
+ <!-- end .attachments-browser -->
183
+ </div>
184
+ <!-- end .media-frame-content -->
185
+ <div class="media-frame-toolbar">
186
+ <div class="media-toolbar">
187
+ <div class="media-toolbar-secondary">
188
+ <a href="#" class="envira-gallery-cancel-insertion button media-button button-large button-secondary media-button-insert" title="<?php esc_attr_e( 'Cancel Gallery Insertion', 'envira-gallery' ); ?>"><?php _e( 'Cancel Gallery Insertion', 'envira-gallery' ); ?></a>
189
+ </div>
190
+ <div class="media-toolbar-primary">
191
+ <a href="#" class="envira-gallery-insert-gallery button media-button button-large button-primary media-button-insert" disabled="disabled" title="<?php esc_attr_e( 'Insert Gallery', 'envira-gallery' ); ?>"><?php _e( 'Insert Gallery', 'envira-gallery' ); ?></a>
192
+ </div>
193
+ <!-- end .media-toolbar-primary -->
194
+ </div>
195
+ <!-- end .media-toolbar -->
196
+ </div>
197
+ <!-- end .media-frame-toolbar -->
198
+ </div>
199
+ <!-- end .media-frame -->
200
+ </div>
201
+ <!-- end .media-modal-content -->
202
+ </div>
203
+ <!-- end .media-modal -->
204
+ <div class="media-modal-backdrop"></div>
205
+ </div><!-- end #envira-gallery-default-ui -->
206
+ </div><!-- end #envira-gallery-default-ui-wrapper -->
207
+ <?php
208
+ return ob_get_clean();
209
+
210
+ }
211
+
212
+ /**
213
+ * Returns the singleton instance of the class.
214
+ *
215
+ * @since 1.0.0
216
+ *
217
+ * @return object The Envira_Gallery_Editor_Lite object.
218
+ */
219
+ public static function get_instance() {
220
+
221
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Editor_Lite ) ) {
222
+ self::$instance = new Envira_Gallery_Editor_Lite();
223
+ }
224
+
225
+ return self::$instance;
226
+
227
+ }
228
+
229
+ }
230
+
231
+ // Load the editor class.
232
+ $envira_gallery_editor_lite = Envira_Gallery_Editor_Lite::get_instance();
includes/admin/media.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Media class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Media_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Load the base class object.
47
+ $this->base = Envira_Gallery_Lite::get_instance();
48
+
49
+ }
50
+
51
+ /**
52
+ * Prepares a custom media upload form that allows multiple forms on one page.
53
+ *
54
+ * @since 1.0.0
55
+ *
56
+ * @return null Return early if the form cannot be output.
57
+ */
58
+ public function media_upload_form() {
59
+
60
+ do_action( 'pre-upload-ui' );
61
+
62
+ if ( ! $this->device_can_upload() ) {
63
+ echo '<p>' . sprintf( __( 'The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.', 'envira-gallery' ), 'http://wordpress.org/mobile/' ) . '</p>';
64
+ return;
65
+ }
66
+
67
+ if ( ! $this->has_upload_capacity() ) {
68
+ do_action( 'upload_ui_over_quota' );
69
+ return;
70
+ }
71
+
72
+ // Get both resize width and height for the media form.
73
+ $width = $this->get_resize_width();
74
+ $height = $this->get_resize_height();
75
+
76
+ // Output the media form.
77
+ $this->do_media_upload_form( $width, $height );
78
+
79
+ }
80
+
81
+ /**
82
+ * Outputs a custom media upload form that allows multiple forms on one page.
83
+ *
84
+ * @since 1.0.0
85
+ *
86
+ * @global bool $ie_IE Flag for Internet Explorer.
87
+ * @global bool $is_opera Flag for Opera.
88
+ * @param int $width The media resize width.
89
+ * @param int $height The media resize height.
90
+ */
91
+ public function do_media_upload_form( $width, $height ) {
92
+
93
+ // Prepare globals and variables.
94
+ global $is_IE, $is_opera;
95
+ $sizes = array( 'KB', 'MB', 'GB' );
96
+ $max_upload_size = wp_max_upload_size();
97
+
98
+ ?>
99
+ <script type="text/javascript">var resize_width = <?php echo $width; ?>, resize_height = <?php echo $height; ?>;</script>
100
+ <div id="envira-gallery-upload-error"></div>
101
+ <div id="envira-gallery-plupload-upload-ui" class="hide-if-no-js">
102
+ <?php do_action( 'pre-plupload-upload-ui' ); ?>
103
+ <div id="envira-gallery-drag-drop-area">
104
+ <div class="drag-drop-inside">
105
+ <p class="drag-drop-info"><?php _e( 'Drop images here', 'envira-gallery' ); ?></p>
106
+ <p><?php _ex( 'or', 'Uploader: Drop images here - or - Select Images', 'envira-gallery' ); ?></p>
107
+ <p class="drag-drop-buttons">
108
+ <input id="envira-gallery-plupload-browse-button" type="button" value="<?php esc_attr_e( 'Select Images', 'envira-gallery' ); ?>" class="button" />
109
+ </p>
110
+ </div>
111
+ </div>
112
+ <?php do_action( 'post-plupload-upload-ui' ); ?>
113
+ </div>
114
+
115
+ <div id="envira-gallery-html-upload-ui" class="hide-if-js">
116
+ <?php do_action('pre-html-upload-ui'); ?>
117
+ <p id="envira-gallery-async-upload-wrap">
118
+ <label class="screen-reader-text" for="envira-gallery-async-upload"><?php _e( 'Upload', 'envira-gallery' ); ?></label>
119
+ <input type="file" name="async-upload" id="envira-gallery-async-upload" />
120
+ <?php submit_button( __( 'Upload', 'envira-gallery' ), 'button', 'html-upload', false ); ?>
121
+ <a href="#" onclick="try{top.tb_remove();}catch(e){};return false;"><?php _e( 'Cancel', 'envira-gallery' ); ?></a>
122
+ </p>
123
+ <div class="clear"></div>
124
+ <?php do_action( 'post-html-upload-ui' ); ?>
125
+ </div>
126
+
127
+ <span class="max-upload-size"><?php printf( __( 'Maximum upload file size: %d%s.', 'envira-gallery' ), esc_html( $this->get_upload_size_unit( $sizes ) ), esc_html( $sizes[$this->get_upload_size_unit( $sizes, 'unit' )] ) ); ?></span>
128
+ <?php
129
+
130
+ // Output a notice if the browser may have trouble with uploading large images.
131
+ if ( ( $is_IE || $is_opera ) && $max_upload_size > 100 * 1024 * 1024 ) {
132
+ echo '<span class="big-file-warning">' . __( 'Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.', 'envira-gallery' ) . '</span>';
133
+ }
134
+
135
+ do_action( 'post-upload-ui' );
136
+
137
+ }
138
+
139
+ /**
140
+ * Flag if the device can upload images.
141
+ *
142
+ * @since 1.0.0
143
+ *
144
+ * @return bool True if it can, false otherwise.
145
+ */
146
+ public function device_can_upload() {
147
+
148
+ // Why is this method internal? It is quite useful.
149
+ return _device_can_upload();
150
+
151
+ }
152
+
153
+ /**
154
+ * Flag if the site has the capacity to receive an upload.
155
+ *
156
+ * @since 1.0.0
157
+ *
158
+ * @return bool True if it can, false otherwise.
159
+ */
160
+ public function has_upload_capacity() {
161
+
162
+ return ! ( is_multisite() && ! is_upload_space_available() );
163
+
164
+ }
165
+
166
+ /**
167
+ * Returns the resize width for the media form.
168
+ *
169
+ * @since 1.0.0
170
+ *
171
+ * @return int $width The resize width.
172
+ */
173
+ public function get_resize_width() {
174
+
175
+ $width = absint( get_option( 'large_size_w' ) );
176
+ if ( ! $width ) {
177
+ $width = 1024;
178
+ }
179
+
180
+ return $width;
181
+
182
+ }
183
+
184
+ /**
185
+ * Returns the resize height for the media form.
186
+ *
187
+ * @since 1.0.0
188
+ *
189
+ * @return int $width The resize height.
190
+ */
191
+ public function get_resize_height() {
192
+
193
+ $height = absint( get_option( 'large_size_h' ) );
194
+ if ( ! $height ) {
195
+ $height = 1024;
196
+ }
197
+
198
+ return $height;
199
+
200
+ }
201
+
202
+ /**
203
+ * Returns the upload unit for the media uploader.
204
+ *
205
+ * @since 1.0.0
206
+ *
207
+ * @param array $sizes Array of sizes to use for units.
208
+ * @param string $type Type of unit to retrieve ('size' or 'unit').
209
+ */
210
+ public function get_upload_size_unit( $sizes, $type = 'size' ) {
211
+
212
+ $upload_size_unit = wp_max_upload_size();
213
+ for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) {
214
+ $upload_size_unit /= 1024;
215
+ }
216
+
217
+ // If the upload size is 0, disable uploading, otherwise allow uploading to continue.
218
+ if ( $u < 0 ) {
219
+ $upload_size_unit = 0;
220
+ $u = 0;
221
+ } else {
222
+ $upload_size_unit = (int) $upload_size_unit;
223
+ }
224
+
225
+ return 'unit' == $type ? $u : $upload_size_unit;
226
+
227
+ }
228
+
229
+ /**
230
+ * Returns the singleton instance of the class.
231
+ *
232
+ * @since 1.0.0
233
+ *
234
+ * @return object The Envira_Gallery_Media_Lite object.
235
+ */
236
+ public static function get_instance() {
237
+
238
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Media_Lite ) ) {
239
+ self::$instance = new Envira_Gallery_Media_Lite();
240
+ }
241
+
242
+ return self::$instance;
243
+
244
+ }
245
+
246
+ }
247
+
248
+ // Load the media class.
249
+ $envira_gallery_media_lite = Envira_Gallery_Media_Lite::get_instance();
includes/admin/metaboxes.php ADDED
@@ -0,0 +1,1117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Metabox class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Metaboxes_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Load the base class object.
47
+ $this->base = Envira_Gallery_Lite::get_instance();
48
+
49
+ // Load metabox assets.
50
+ add_action( 'admin_enqueue_scripts', array( $this, 'meta_box_styles' ) );
51
+ add_action( 'admin_enqueue_scripts', array( $this, 'meta_box_scripts' ) );
52
+
53
+ // Load the metabox hooks and filters.
54
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 100 );
55
+
56
+ // Load all tabs.
57
+ add_action( 'envira_gallery_tab_images', array( $this, 'images_tab' ) );
58
+ add_action( 'envira_gallery_tab_config', array( $this, 'config_tab' ) );
59
+ add_action( 'envira_gallery_tab_lightbox', array( $this, 'lightbox_tab' ) );
60
+ add_action( 'envira_gallery_tab_misc', array( $this, 'misc_tab' ) );
61
+
62
+ // Add action to save metabox config options.
63
+ add_action( 'save_post', array( $this, 'save_meta_boxes' ), 10, 2 );
64
+
65
+ }
66
+
67
+ /**
68
+ * Loads styles for our metaboxes.
69
+ *
70
+ * @since 1.0.0
71
+ *
72
+ * @return null Return early if not on the proper screen.
73
+ */
74
+ public function meta_box_styles() {
75
+
76
+ if ( 'post' !== get_current_screen()->base ) {
77
+ return;
78
+ }
79
+
80
+ if ( isset( get_current_screen()->post_type ) && in_array( get_current_screen()->post_type, $this->get_skipped_posttypes() ) ) {
81
+ return;
82
+ }
83
+
84
+ // Load necessary metabox styles.
85
+ wp_register_style( $this->base->plugin_slug . '-metabox-style', plugins_url( 'assets/css/metabox.css', $this->base->file ), array(), $this->base->version );
86
+ wp_enqueue_style( $this->base->plugin_slug . '-metabox-style' );
87
+
88
+ }
89
+
90
+ /**
91
+ * Loads scripts for our metaboxes.
92
+ *
93
+ * @since 1.0.0
94
+ *
95
+ * @global int $id The current post ID.
96
+ * @global object $post The current post object..
97
+ * @return null Return early if not on the proper screen.
98
+ */
99
+ public function meta_box_scripts( $hook ) {
100
+
101
+ global $id, $post;
102
+
103
+ if ( isset( get_current_screen()->base ) && 'post' !== get_current_screen()->base ) {
104
+ return;
105
+ }
106
+
107
+ if ( isset( get_current_screen()->post_type ) && in_array( get_current_screen()->post_type, $this->get_skipped_posttypes() ) ) {
108
+ return;
109
+ }
110
+
111
+ // Set the post_id for localization.
112
+ $post_id = isset( $post->ID ) ? $post->ID : (int) $id;
113
+
114
+ // Load WordPress necessary scripts.
115
+ wp_enqueue_script( 'plupload-handlers' );
116
+ wp_enqueue_script( 'jquery-ui-sortable' );
117
+ wp_enqueue_media( array( 'post' => $post_id ) );
118
+
119
+ // Load necessary metabox scripts.
120
+ wp_register_script( $this->base->plugin_slug . '-metabox-script', plugins_url( 'assets/js/metabox.js', $this->base->file ), array( 'jquery', 'plupload-handlers', 'quicktags', 'jquery-ui-sortable' ), $this->base->version, true );
121
+ wp_enqueue_script( $this->base->plugin_slug . '-metabox-script' );
122
+ wp_localize_script(
123
+ $this->base->plugin_slug . '-metabox-script',
124
+ 'envira_gallery_metabox',
125
+ array(
126
+ 'ajax' => admin_url( 'admin-ajax.php' ),
127
+ 'gallery' => esc_attr__( 'Click Here to Insert from Other Image Sources', 'envira-gallery' ),
128
+ 'id' => $post_id,
129
+ 'import' => __( 'You must select a file to import before continuing.', 'envira-gallery' ),
130
+ 'insert_nonce' => wp_create_nonce( 'envira-gallery-insert-images' ),
131
+ 'inserting' => __( 'Inserting...', 'envira-gallery' ),
132
+ 'library_search' => wp_create_nonce( 'envira-gallery-library-search' ),
133
+ 'load_image' => wp_create_nonce( 'envira-gallery-load-image' ),
134
+ 'load_gallery' => wp_create_nonce( 'envira-gallery-load-gallery' ),
135
+ 'plupload' => $this->get_plupload_init( $post_id ),
136
+ 'refresh_nonce' => wp_create_nonce( 'envira-gallery-refresh' ),
137
+ 'remove' => __( 'Are you sure you want to remove this image from the gallery?', 'envira-gallery' ),
138
+ 'remove_nonce' => wp_create_nonce( 'envira-gallery-remove-image' ),
139
+ 'save_nonce' => wp_create_nonce( 'envira-gallery-save-meta' ),
140
+ 'saving' => __( 'Saving...', 'envira-gallery' ),
141
+ 'sort' => wp_create_nonce( 'envira-gallery-sort' )
142
+ )
143
+ );
144
+
145
+ // If on an Envira post type, add custom CSS for hiding specific things.
146
+ if ( isset( get_current_screen()->post_type ) && 'envira' == get_current_screen()->post_type ) {
147
+ add_action( 'admin_head', array( $this, 'meta_box_css' ) );
148
+ }
149
+
150
+ }
151
+
152
+ /**
153
+ * Returns custom plupload init properties for the media uploader.
154
+ *
155
+ * @since 1.0.0
156
+ *
157
+ * @param int $post_id The current post ID.
158
+ * @return array Array of plupload init data.
159
+ */
160
+ public function get_plupload_init( $post_id ) {
161
+
162
+ // Prepare $_POST form variables and apply backwards compat filter.
163
+ $post_params = array(
164
+ 'post_id' => $post_id,
165
+ '_wpnonce' => wp_create_nonce( 'media-form' ),
166
+ 'type' => '',
167
+ 'tab' => '',
168
+ 'short' => 3
169
+ );
170
+ $post_params = apply_filters( 'upload_post_params', $post_params );
171
+
172
+ // Prepare upload size parameters.
173
+ $max_upload_size = wp_max_upload_size();
174
+
175
+ // Prepare the plupload init array.
176
+ $plupload_init = array(
177
+ 'runtimes' => 'html5,silverlight,flash,html4',
178
+ 'browse_button' => 'envira-gallery-plupload-browse-button',
179
+ 'container' => 'envira-gallery-plupload-upload-ui',
180
+ 'drop_element' => 'envira-gallery-drag-drop-area',
181
+ 'file_data_name' => 'async-upload',
182
+ 'multiple_queues' => true,
183
+ 'max_file_size' => $max_upload_size . 'b',
184
+ 'url' => admin_url( 'async-upload.php' ),
185
+ 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
186
+ 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
187
+ 'filters' => array(
188
+ array(
189
+ 'title' => __( 'Allowed Files', 'envira-gallery' ),
190
+ 'extensions' => '*'
191
+ ),
192
+ ),
193
+ 'multipart' => true,
194
+ 'urlstream_upload' => true,
195
+ 'multipart_params' => $post_params,
196
+ 'resize' => array(
197
+ 'width' => Envira_Gallery_Media_Lite::get_instance()->get_resize_width(),
198
+ 'height' => Envira_Gallery_Media_Lite::get_instance()->get_resize_height(),
199
+ 'quality' => 100,
200
+ 'enabled' => true
201
+ )
202
+ );
203
+
204
+ // If we are on a mobile device, disable multi selection.
205
+ if ( wp_is_mobile() ) {
206
+ $plupload_init['multi_selection'] = false;
207
+ }
208
+
209
+ // Apply backwards compat filter.
210
+ $plupload_init = apply_filters( 'plupload_init', $plupload_init );
211
+
212
+ // Return and apply a custom filter to our init data.
213
+ return apply_filters( 'envira_gallery_plupload_init', $plupload_init, $post_id );
214
+
215
+ }
216
+
217
+ /**
218
+ * Hides unnecessary meta box items on Envira post type screens.
219
+ *
220
+ * @since 1.0.0
221
+ */
222
+ public function meta_box_css() {
223
+
224
+ ?>
225
+ <style type="text/css">.misc-pub-section:not(.misc-pub-post-status) { display: none; }</style>
226
+ <?php
227
+
228
+ }
229
+
230
+ /**
231
+ * Creates metaboxes for handling and managing galleries.
232
+ *
233
+ * @since 1.0.0
234
+ */
235
+ public function add_meta_boxes() {
236
+
237
+ // Let's remove all of those dumb metaboxes from our post type screen to control the experience.
238
+ $this->remove_all_the_metaboxes();
239
+
240
+ // Get all public post types.
241
+ $post_types = get_post_types( array( 'public' => true ) );
242
+
243
+ // Splice the envira post type since it is not visible to the public by default.
244
+ $post_types[] = 'envira';
245
+
246
+ // Loops through the post types and add the metaboxes.
247
+ foreach ( (array) $post_types as $post_type ) {
248
+ // Don't output boxes on these post types.
249
+ if ( in_array( $post_type, $this->get_skipped_posttypes() ) ) {
250
+ continue;
251
+ }
252
+
253
+ add_meta_box( 'envira-gallery', __( 'Envira Gallery Settings', 'envira-gallery' ), array( $this, 'meta_box_callback' ), $post_type, 'normal', 'high' );
254
+ }
255
+
256
+ }
257
+
258
+ /**
259
+ * Removes all the metaboxes except the ones I want on MY POST TYPE. RAGE.
260
+ *
261
+ * @since 1.0.0
262
+ *
263
+ * @global array $wp_meta_boxes Array of registered metaboxes.
264
+ * @return smile $for_my_buyers Happy customers with no spammy metaboxes!
265
+ */
266
+ public function remove_all_the_metaboxes() {
267
+
268
+ global $wp_meta_boxes;
269
+
270
+ // This is the post type you want to target. Adjust it to match yours.
271
+ $post_type = 'envira';
272
+
273
+ // These are the metabox IDs you want to pass over. They don't have to match exactly. preg_match will be run on them.
274
+ $pass_over = apply_filters( 'envira_gallery_metabox_ids', array( 'submitdiv', 'envira' ) );
275
+
276
+ // All the metabox contexts you want to check.
277
+ $contexts = apply_filters( 'envira_gallery_metabox_contexts', array( 'normal', 'advanced', 'side' ) );
278
+
279
+ // All the priorities you want to check.
280
+ $priorities = apply_filters( 'envira_gallery_metabox_priorities', array( 'high', 'core', 'default', 'low' ) );
281
+
282
+ // Loop through and target each context.
283
+ foreach ( $contexts as $context ) {
284
+ // Now loop through each priority and start the purging process.
285
+ foreach ( $priorities as $priority ) {
286
+ if ( isset( $wp_meta_boxes[$post_type][$context][$priority] ) ) {
287
+ foreach ( (array) $wp_meta_boxes[$post_type][$context][$priority] as $id => $metabox_data ) {
288
+ // If the metabox ID to pass over matches the ID given, remove it from the array and continue.
289
+ if ( in_array( $id, $pass_over ) ) {
290
+ unset( $pass_over[$id] );
291
+ continue;
292
+ }
293
+
294
+ // Otherwise, loop through the pass_over IDs and if we have a match, continue.
295
+ foreach ( $pass_over as $to_pass ) {
296
+ if ( preg_match( '#^' . $id . '#i', $to_pass ) ) {
297
+ continue;
298
+ }
299
+ }
300
+
301
+ // If we reach this point, remove the metabox completely.
302
+ unset( $wp_meta_boxes[$post_type][$context][$priority][$id] );
303
+ }
304
+ }
305
+ }
306
+ }
307
+
308
+ }
309
+
310
+ /**
311
+ * Callback for displaying content in the registered metabox.
312
+ *
313
+ * @since 1.0.0
314
+ *
315
+ * @param object $post The current post object.
316
+ */
317
+ public function meta_box_callback( $post ) {
318
+
319
+ // Keep security first.
320
+ wp_nonce_field( 'envira-gallery', 'envira-gallery' );
321
+
322
+ // Check for our meta overlay helper.
323
+ $gallery_data = get_post_meta( $post->ID, '_eg_gallery_data', true );
324
+ $helper = get_post_meta( $post->ID, '_eg_just_published', true );
325
+ $class = '';
326
+ if ( $helper ) {
327
+ $class = 'envira-helper-needed';
328
+ }
329
+
330
+ ?>
331
+ <div id="envira-tabs" class="envira-clear <?php echo $class; ?>">
332
+ <?php $this->meta_helper( $post, $gallery_data ); ?>
333
+ <ul id="envira-tabs-nav" class="envira-clear">
334
+ <?php $i = 0; foreach ( (array) $this->get_envira_tab_nav() as $id => $title ) : $class = 0 === $i ? 'envira-active' : ''; ?>
335
+ <li class="<?php echo $class; ?>"><a href="#envira-tab-<?php echo $id; ?>" title="<?php echo $title; ?>"><?php echo $title; ?></a></li>
336
+ <?php $i++; endforeach; ?>
337
+ </ul>
338
+ <?php $i = 0; foreach ( (array) $this->get_envira_tab_nav() as $id => $title ) : $class = 0 === $i ? 'envira-active' : ''; ?>
339
+ <div id="envira-tab-<?php echo $id; ?>" class="envira-tab envira-clear <?php echo $class; ?>">
340
+ <?php do_action( 'envira_gallery_tab_' . $id, $post ); ?>
341
+ </div>
342
+ <?php $i++; endforeach; ?>
343
+ </div>
344
+ <?php
345
+
346
+ }
347
+
348
+ /**
349
+ * Callback for getting all of the tabs for Envira galleries.
350
+ *
351
+ * @since 1.0.0
352
+ *
353
+ * @return array Array of tab information.
354
+ */
355
+ public function get_envira_tab_nav() {
356
+
357
+ $tabs = array(
358
+ 'images' => __( 'Images', 'envira-gallery' ),
359
+ 'config' => __( 'Config', 'envira-gallery' ),
360
+ 'lightbox' => __( 'Lightbox', 'envira-gallery' )
361
+ );
362
+ $tabs = apply_filters( 'envira_gallery_tab_nav', $tabs );
363
+
364
+ // "Misc" tab is required.
365
+ $tabs['misc'] = __( 'Misc', 'envira-gallery' );
366
+
367
+ return $tabs;
368
+
369
+ }
370
+
371
+ /**
372
+ * Callback for displaying the UI for main images tab.
373
+ *
374
+ * @since 1.0.0
375
+ *
376
+ * @param object $post The current post object.
377
+ */
378
+ public function images_tab( $post ) {
379
+
380
+ ?>
381
+ <div class="envira-alert envira-clear" style="margin-bottom:10px;">
382
+ <?php _e( '<em>Want to make your gallery workflow even better?</em> By upgrading to Envira Pro, you can get access to numerous other features, including: <strong>a fully featured gallery widget</strong>, <strong>complete gallery API</strong>, <strong>powerful gallery documentation</strong>, <strong>full mobile and Retina support</strong>, <strong>dedicated customer support</strong> and so much more! <a href="http://enviragallery.com/lite/?utm_source=liteplugin&utm_medium=link&utm_campaign=WordPress" title="Click here to upgrade to Envira Pro!" target="_blank">Click here to upgrade to Envira Pro!</a>', 'envira-gallery' ); ?>
383
+ </div>
384
+ <?php
385
+
386
+ // Output the custom media upload form.
387
+ Envira_Gallery_Media_Lite::get_instance()->media_upload_form();
388
+
389
+ // Prepare output data.
390
+ $gallery_data = get_post_meta( $post->ID, '_eg_gallery_data', true );
391
+
392
+ ?>
393
+ <ul id="envira-gallery-output" class="envira-clear">
394
+ <?php if ( ! empty( $gallery_data['gallery'] ) ) : ?>
395
+ <?php foreach ( $gallery_data['gallery'] as $id => $data ) : ?>
396
+ <?php echo $this->get_gallery_item( $id, $data, $post->ID ); ?>
397
+ <?php endforeach; ?>
398
+ <?php endif; ?>
399
+ </ul>
400
+ <?php $this->media_library( $post );
401
+
402
+ }
403
+
404
+ /**
405
+ * Inserts the meta icon for displaying useful gallery meta like shortcode and template tag.
406
+ *
407
+ * @since 1.0.0
408
+ *
409
+ * @param object $post The current post object.
410
+ * @param array $gallery_data Array of gallery data for the current post.
411
+ * @return null Return early if this is an auto-draft.
412
+ */
413
+ public function meta_helper( $post, $gallery_data ) {
414
+
415
+ if ( isset( $post->post_status ) && 'auto-draft' == $post->post_status ) {
416
+ return;
417
+ }
418
+
419
+ // Check for our meta overlay helper.
420
+ $helper = get_post_meta( $post->ID, '_eg_just_published', true );
421
+ $class = '';
422
+ if ( $helper ) {
423
+ $class = 'envira-helper-active';
424
+ delete_post_meta( $post->ID, '_eg_just_published' );
425
+ }
426
+
427
+ ?>
428
+ <div class="envira-meta-helper <?php echo $class; ?>">
429
+ <span class="envira-meta-close-text"><?php _e( '(click the icon to open and close the overlay dialog)', 'envira-gallery' ); ?></span>
430
+ <a href="#" class="envira-meta-icon" title="<?php esc_attr__( 'Click here to view meta information about this gallery.', 'envira-gallery' ); ?>"></a>
431
+ <div class="envira-meta-information">
432
+ <p><?php _e( 'You can place this gallery anywhere into your posts, pages, custom post types or widgets by using the shortcode(s) below:', 'envira-gallery' ); ?></p>
433
+ <code><?php echo '[envira-gallery id="' . $post->ID . '"]'; ?></code>
434
+ <?php if ( ! empty( $gallery_data['config']['slug'] ) ) : ?>
435
+ <br><code><?php echo '[envira-gallery slug="' . $gallery_data['config']['slug'] . '"]'; ?></code>
436
+ <?php endif; ?>
437
+ <p><?php _e( 'You can also place this gallery into your template files by using the template tag(s) below:', 'envira-gallery' ); ?></p>
438
+ <code><?php echo 'if ( function_exists( \'envira_gallery\' ) ) { envira_gallery( \'' . $post->ID . '\' ); }'; ?></code>
439
+ <?php if ( ! empty( $gallery_data['config']['slug'] ) ) : ?>
440
+ <br><code><?php echo 'if ( function_exists( \'envira_gallery\' ) ) { envira_gallery( \'' . $gallery_data['config']['slug'] . '\', \'slug\' ); }'; ?></code>
441
+ <?php endif; ?>
442
+ </div>
443
+ </div>
444
+ <?php
445
+
446
+ }
447
+
448
+ /**
449
+ * Callback for displaying the UI for selecting images from the media library to insert.
450
+ *
451
+ * @since 1.0.0
452
+ *
453
+ * @param object $post The current post object.
454
+ */
455
+ public function media_library( $post ) {
456
+
457
+ ?>
458
+ <div id="envira-gallery-upload-ui-wrapper">
459
+ <div id="envira-gallery-upload-ui" class="envira-gallery-image-meta" style="display: none;">
460
+ <div class="media-modal wp-core-ui">
461
+ <a class="media-modal-close" href="#"><span class="media-modal-icon"></span></a>
462
+ <div class="media-modal-content">
463
+ <div class="media-frame envira-gallery-media-frame wp-core-ui hide-menu envira-gallery-meta-wrap">
464
+ <div class="media-frame-title">
465
+ <h1><?php _e( 'Insert Images into Gallery', 'envira-gallery' ); ?></h1>
466
+ </div>
467
+ <div class="media-frame-router">
468
+ <div class="media-router">
469
+ <a href="#" class="media-menu-item active"><?php _e( 'Images', 'envira-gallery' ); ?></a>
470
+ <?php do_action( 'envira_gallery_modal_router', $post ); ?>
471
+ </div><!-- end .media-router -->
472
+ </div><!-- end .media-frame-router -->
473
+ <!-- begin content for inserting slides from media library -->
474
+ <div id="envira-gallery-select-images">
475
+ <div class="media-frame-content">
476
+ <div class="attachments-browser">
477
+ <div class="media-toolbar envira-gallery-library-toolbar">
478
+ <div class="media-toolbar-primary">
479
+ <span class="spinner envira-gallery-spinner"></span><input type="search" placeholder="<?php esc_attr_e( 'Search', 'envira-gallery' ); ?>" id="envira-gallery-gallery-search" class="search" value="" />
480
+ </div>
481
+ <div class="media-toolbar-secondary">
482
+ <a class="button media-button button-large button-secodary envira-gallery-load-library" href="#" data-envira-gallery-offset="20"><?php _e( 'Load More Images from Library', 'envira-gallery' ); ?></a></a><span class="spinner envira-gallery-spinner"></span>
483
+ </div>
484
+ </div>
485
+ <?php $library = get_posts( array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'posts_per_page' => 20 ) ); ?>
486
+ <?php if ( $library ) : ?>
487
+ <ul class="attachments envira-gallery-gallery">
488
+ <?php foreach ( (array) $library as $image ) :
489
+ $has_gallery = get_post_meta( $image->ID, '_eg_has_gallery', true );
490
+ $class = $has_gallery && in_array( $post->ID, (array) $has_gallery ) ? ' selected envira-gallery-in-gallery' : ''; ?>
491
+ <li class="attachment<?php echo $class; ?>" data-attachment-id="<?php echo absint( $image->ID ); ?>">
492
+ <div class="attachment-preview landscape">
493
+ <div class="thumbnail">
494
+ <div class="centered">
495
+ <?php $src = wp_get_attachment_image_src( $image->ID, 'thumbnail' ); ?>
496
+ <img src="<?php echo esc_url( $src[0] ); ?>" />
497
+ </div>
498
+ </div>
499
+ <a class="check" href="#"><div class="media-modal-icon"></div></a>
500
+ </div>
501
+ </li>
502
+ <?php endforeach; ?>
503
+ </ul><!-- end .envira-gallery-meta -->
504
+ <?php endif; ?>
505
+ <div class="media-sidebar">
506
+ <div class="envira-gallery-meta-sidebar">
507
+ <h3><?php _e( 'Helpful Tips', 'envira-gallery' ); ?></h3>
508
+ <strong><?php _e( 'Selecting Images', 'envira-gallery' ); ?></strong>
509
+ <p><?php _e( 'You can insert any image from your Media Library into your gallery. If the image you want to insert is not shown on the screen, you can either click on the "Load More Images from Library" button to load more images or use the search box to find the images you are looking for.', 'envira-gallery' ); ?></p>
510
+ </div><!-- end .envira-gallery-meta-sidebar -->
511
+ </div><!-- end .media-sidebar -->
512
+ </div><!-- end .attachments-browser -->
513
+ </div><!-- end .media-frame-content -->
514
+ </div><!-- end #envira-gallery-image-slides -->
515
+ <!-- end content for inserting slides from media library -->
516
+ <div class="media-frame-toolbar">
517
+ <div class="media-toolbar">
518
+ <div class="media-toolbar-primary">
519
+ <a href="#" class="envira-gallery-media-insert button media-button button-large button-primary media-button-insert" title="<?php esc_attr_e( 'Insert Images into Gallery', 'envira-gallery' ); ?>"><?php _e( 'Insert Images into Gallery', 'envira-gallery' ); ?></a>
520
+ </div><!-- end .media-toolbar-primary -->
521
+ </div><!-- end .media-toolbar -->
522
+ </div><!-- end .media-frame-toolbar -->
523
+ </div><!-- end .media-frame -->
524
+ </div><!-- end .media-modal-content -->
525
+ </div><!-- end .media-modal -->
526
+ <div class="media-modal-backdrop"></div>
527
+ </div><!-- end .envira-gallery-image-meta -->
528
+ </div><!-- end #envira-gallery-upload-ui-wrapper-->
529
+ <?php
530
+
531
+ }
532
+
533
+ /**
534
+ * Callback for displaying the UI for setting gallery config options.
535
+ *
536
+ * @since 1.0.0
537
+ *
538
+ * @param object $post The current post object.
539
+ */
540
+ public function config_tab( $post ) {
541
+
542
+ ?>
543
+ <div id="envira-config">
544
+ <p class="envira-intro"><?php _e( 'The settings below adjust the basic configuration options for the gallery lightbox display.', 'envira-gallery' ); ?></p>
545
+ <table class="form-table">
546
+ <tbody>
547
+ <tr id="envira-config-columns-box">
548
+ <th scope="row">
549
+ <label for="envira-config-columns"><?php _e( 'Number of Gallery Columns', 'envira-gallery' ); ?></label>
550
+ </th>
551
+ <td>
552
+ <select id="envira-config-columns" name="_envira_gallery[columns]">
553
+ <?php foreach ( (array) $this->get_columns() as $i => $data ) : ?>
554
+ <option value="<?php echo $data['value']; ?>"<?php selected( $data['value'], $this->get_config( 'columns', $this->get_config_default( 'columns' ) ) ); ?>><?php echo $data['name']; ?></option>
555
+ <?php endforeach; ?>
556
+ </select>
557
+ <p class="description"><?php _e( 'Determines the number of columns in the gallery.', 'envira-gallery' ); ?></p>
558
+ </td>
559
+ </tr>
560
+ <tr id="envira-config-gallery-theme-box" class="envira-lite-disabled">
561
+ <th scope="row">
562
+ <label for="envira-config-gallery-theme"><?php _e( 'Gallery Theme', 'envira-gallery' ); ?></label>
563
+ </th>
564
+ <td>
565
+ <select id="envira-config-gallery-theme" name="_envira_gallery[gallery_theme]">
566
+ <?php foreach ( (array) $this->get_gallery_themes() as $i => $data ) : ?>
567
+ <option value="<?php echo $data['value']; ?>"<?php selected( $data['value'], $this->get_config( 'gallery_theme', $this->get_config_default( 'gallery_theme' ) ) ); ?>><?php echo $data['name']; ?></option>
568
+ <?php endforeach; ?>
569
+ </select>
570
+ <p class="description"><?php _e( 'Sets the theme for the gallery display.', 'envira-gallery' ); ?></p>
571
+ </td>
572
+ </tr>
573
+ <tr id="envira-config-gutter-box">
574
+ <th scope="row">
575
+ <label for="envira-config-gutter"><?php _e( 'Column Gutter Width', 'envira-gallery' ); ?></label>
576
+ </th>
577
+ <td>
578
+ <input id="envira-config-gutter" type="number" name="_envira_gallery[gutter]" value="<?php echo $this->get_config( 'gutter', $this->get_config_default( 'gutter' ) ); ?>" />
579
+ <p class="description"><?php _e( 'Sets the space between the columns (defaults to 10).', 'envira-gallery' ); ?></p>
580
+ </td>
581
+ </tr>
582
+ <tr id="envira-config-margin-box">
583
+ <th scope="row">
584
+ <label for="envira-config-margin"><?php _e( 'Margin Below Each Image', 'envira-gallery' ); ?></label>
585
+ </th>
586
+ <td>
587
+ <input id="envira-config-margin" type="number" name="_envira_gallery[margin]" value="<?php echo $this->get_config( 'margin', $this->get_config_default( 'margin' ) ); ?>" />
588
+ <p class="description"><?php _e( 'Sets the space below each item in the gallery.', 'envira-gallery' ); ?></p>
589
+ </td>
590
+ </tr>
591
+ <tr id="envira-config-crop-box">
592
+ <th scope="row">
593
+ <label for="envira-config-crop"><?php _e( 'Crop Images in Gallery?', 'envira-gallery' ); ?></label>
594
+ </th>
595
+ <td>
596
+ <input id="envira-config-crop" type="checkbox" name="_envira_gallery[crop]" value="<?php echo $this->get_config( 'crop', $this->get_config_default( 'crop' ) ); ?>" <?php checked( $this->get_config( 'crop', $this->get_config_default( 'crop' ) ), 1 ); ?> />
597
+ <span class="description"><?php _e( 'Enables or disables image cropping for the main gallery images.', 'envira-gallery' ); ?></span>
598
+ </td>
599
+ </tr>
600
+ <tr id="envira-config-crop-size-box" style="display:none;">
601
+ <th scope="row">
602
+ <label for="envira-config-crop-width"><?php _e( 'Crop Dimensions', 'envira-gallery' ); ?></label>
603
+ </th>
604
+ <td>
605
+ <input id="envira-config-crop-width" type="number" name="_envira_gallery[crop_width]" value="<?php echo $this->get_config( 'crop_width', $this->get_config_default( 'crop_width' ) ); ?>" <?php checked( $this->get_config( 'crop_width', $this->get_config_default( 'crop_width' ) ), 1 ); ?> /> &#215; <input id="envira-config-crop-height" type="number" name="_envira_gallery[crop_height]" value="<?php echo $this->get_config( 'crop_height', $this->get_config_default( 'crop_height' ) ); ?>" <?php checked( $this->get_config( 'crop_height', $this->get_config_default( 'crop_height' ) ), 1 ); ?> />
606
+ <p class="description"><?php _e( 'You should adjust these dimensions based on the number of columns in your gallery.', 'envira-gallery' ); ?></p>
607
+ </td>
608
+ </tr>
609
+ <?php do_action( 'envira_gallery_config_box', $post ); ?>
610
+ </tbody>
611
+ </table>
612
+ <div class="envira-alert envira-clear">
613
+ <?php _e( '<em>Want to do even more with your gallery display?</em> By upgrading to Envira Pro, you can get access to numerous other gallery display features, including: <strong>custom image tagging and filtering</strong>, <strong>mobile specific image assets for blazing fast load times</strong>, <strong>dedicated and unique gallery URLs</strong>, <strong>custom gallery themes</strong>, <strong>gallery thumbnail support</strong> and so much more! <a href="http://enviragallery.com/lite/?utm_source=liteplugin&utm_medium=link&utm_campaign=WordPress" title="Click here to upgrade to Envira Pro!" target="_blank">Click here to upgrade to Envira Pro!</a>', 'envira-gallery' ); ?>
614
+ </div>
615
+ </div>
616
+ <?php
617
+
618
+ }
619
+
620
+ /**
621
+ * Callback for displaying the UI for setting gallery lightbox options.
622
+ *
623
+ * @since 1.0.0
624
+ *
625
+ * @param object $post The current post object.
626
+ */
627
+ public function lightbox_tab( $post ) {
628
+
629
+ ?>
630
+ <div id="envira-lightbox">
631
+ <p class="envira-intro"><?php _e( 'The settings below adjust the lightbox outputs and displays.', 'envira-gallery' ); ?></p>
632
+ <table class="form-table">
633
+ <tbody>
634
+ <tr id="envira-config-lightbox-theme-box">
635
+ <th scope="row">
636
+ <label for="envira-config-lightbox-theme"><?php _e( 'Gallery Lightbox Theme', 'envira-gallery' ); ?></label>
637
+ </th>
638
+ <td>
639
+ <select id="envira-config-lightbox-theme" name="_envira_gallery[lightbox_theme]">
640
+ <?php foreach ( (array) $this->get_lightbox_themes() as $i => $data ) : ?>
641
+ <option value="<?php echo $data['value']; ?>"<?php selected( $data['value'], $this->get_config( 'lightbox_theme', $this->get_config_default( 'lightbox_theme' ) ) ); ?>><?php echo $data['name']; ?></option>
642
+ <?php endforeach; ?>
643
+ </select>
644
+ <p class="description"><?php _e( 'Sets the theme for the gallery lightbox display.', 'envira-gallery' ); ?></p>
645
+ </td>
646
+ </tr>
647
+ <?php do_action( 'envira_gallery_lightbox_box', $post ); ?>
648
+ </tbody>
649
+ </table>
650
+ <div class="envira-alert envira-clear">
651
+ <?php _e( '<em>Want even more fine tuned control over your lightbox display?</em> By upgrading to Envira Pro, you can get access to numerous other lightbox features, including: <strong>custom lightbox titles</strong>, <strong>enable/disable lightbox controls (arrow, keyboard and mousehweel navigation)</strong>, <strong>custom lightbox transition effects</strong>, <strong>native fullscreen support</strong>, <strong>gallery deeplinking</strong>, <strong>image protection</strong>, <strong>lightbox supersize effects</strong>, <strong>lightbox slideshows</strong> and so much more! <a href="http://enviragallery.com/lite/?utm_source=liteplugin&utm_medium=link&utm_campaign=WordPress" title="Click here to upgrade to Envira Pro!" target="_blank">Click here to upgrade to Envira Pro!</a>', 'envira-gallery' ); ?>
652
+ </div>
653
+ </div>
654
+ <?php
655
+
656
+ }
657
+
658
+ /**
659
+ * Callback for displaying the UI for setting gallery miscellaneous options.
660
+ *
661
+ * @since 1.0.0
662
+ *
663
+ * @param object $post The current post object.
664
+ */
665
+ public function misc_tab( $post ) {
666
+
667
+ ?>
668
+ <div id="envira-misc">
669
+ <p class="envira-intro"><?php _e( 'The settings below adjust the miscellaneous settings for the gallery lightbox display.', 'envira-gallery' ); ?></p>
670
+ <table class="form-table">
671
+ <tbody>
672
+ <tr id="envira-config-title-box">
673
+ <th scope="row">
674
+ <label for="envira-config-title"><?php _e( 'Gallery Title', 'envira-gallery' ); ?></label>
675
+ </th>
676
+ <td>
677
+ <input id="envira-config-title" type="text" name="_envira_gallery[title]" value="<?php echo $this->get_config( 'title', $this->get_config_default( 'title' ) ); ?>" />
678
+ <p class="description"><?php _e( 'Internal gallery title for identification in the admin.', 'envira-gallery' ); ?></p>
679
+ </td>
680
+ </tr>
681
+ <tr id="envira-config-slug-box">
682
+ <th scope="row">
683
+ <label for="envira-config-slug"><?php _e( 'Gallery Slug', 'envira-gallery' ); ?></label>
684
+ </th>
685
+ <td>
686
+ <input id="envira-config-slug" type="text" name="_envira_gallery[slug]" value="<?php echo $this->get_config( 'slug', $this->get_config_default( 'slug' ) ); ?>" />
687
+ <p class="description"><?php _e( '<strong>Unique</strong> internal gallery slug for identification and advanced gallery queries.', 'envira-gallery' ); ?></p>
688
+ </td>
689
+ </tr>
690
+ <tr id="envira-config-classes-box">
691
+ <th scope="row">
692
+ <label for="envira-config-classes"><?php _e( 'Custom Gallery Classes', 'envira-gallery' ); ?></label>
693
+ </th>
694
+ <td>
695
+ <textarea id="envira-config-classes" rows="5" cols="75" name="_envira_gallery[classes]" placeholder="<?php _e( 'Enter custom gallery CSS classes here, one per line.', 'envira-gallery' ); ?>"><?php echo implode( "\n", (array) $this->get_config( 'classes', $this->get_config_default( 'classes' ) ) ); ?></textarea>
696
+ <p class="description"><?php _e( 'Adds custom CSS classes to this gallery. Enter one class per line.', 'envira-gallery' ); ?></p>
697
+ </td>
698
+ </tr>
699
+ <?php do_action( 'envira_gallery_misc_box', $post ); ?>
700
+ </tbody>
701
+ </table>
702
+ <div class="envira-alert envira-clear">
703
+ <?php _e( '<em>Want to take your galleries further?</em> By upgrading to Envira Pro, you can get access to numerous other features, including: <strong>a fully-integrated import/export module for your galleries</strong>, <strong>custom CSS controls for each gallery</strong> and so much more! <a href="http://enviragallery.com/lite/?utm_source=liteplugin&utm_medium=link&utm_campaign=WordPress" title="Click here to upgrade to Envira Pro!" target="_blank">Click here to upgrade to Envira Pro!</a>', 'envira-gallery' ); ?>
704
+ </div>
705
+ </div>
706
+ <?php
707
+
708
+ }
709
+
710
+ /**
711
+ * Callback for saving values from Envira metaboxes.
712
+ *
713
+ * @since 1.0.0
714
+ *
715
+ * @param int $post_id The current post ID.
716
+ * @param object $post The current post object.
717
+ */
718
+ public function save_meta_boxes( $post_id, $post ) {
719
+
720
+ // Bail out if we fail a security check.
721
+ if ( ! isset( $_POST['envira-gallery'] ) || ! wp_verify_nonce( $_POST['envira-gallery'], 'envira-gallery' ) || ! isset( $_POST['_envira_gallery'] ) ) {
722
+ return;
723
+ }
724
+
725
+ // Bail out if running an autosave, ajax, cron or revision.
726
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
727
+ return;
728
+ }
729
+
730
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
731
+ return;
732
+ }
733
+
734
+ if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
735
+ return;
736
+ }
737
+
738
+ if ( wp_is_post_revision( $post_id ) ) {
739
+ return;
740
+ }
741
+
742
+ // Bail out if the user doesn't have the correct permissions to update the slider.
743
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
744
+ return;
745
+ }
746
+
747
+ // If the post has just been published for the first time, set meta field for the gallery meta overlay helper.
748
+ if ( isset( $post->post_date ) && isset( $post->post_modified ) && $post->post_date === $post->post_modified ) {
749
+ update_post_meta( $post_id, '_eg_just_published', true );
750
+ }
751
+
752
+ // Sanitize all user inputs.
753
+ $settings = get_post_meta( $post_id, '_eg_gallery_data', true );
754
+ if ( empty( $settings ) ) {
755
+ $settings = array();
756
+ }
757
+
758
+ // If the ID of the gallery is not set or is lost, replace it now.
759
+ if ( empty( $settings['id'] ) || ! $settings['id'] ) {
760
+ $settings['id'] = $post_id;
761
+ }
762
+
763
+ // Save the config settings.
764
+ $settings['config']['columns'] = preg_replace( '#[^a-z0-9-_]#', '', $_POST['_envira_gallery']['columns'] );
765
+ $settings['config']['gutter'] = absint( $_POST['_envira_gallery']['gutter'] );
766
+ $settings['config']['margin'] = absint( $_POST['_envira_gallery']['margin'] );
767
+ $settings['config']['crop'] = isset( $_POST['_envira_gallery']['crop'] ) ? 1 : 0;
768
+ $settings['config']['crop_width'] = absint( $_POST['_envira_gallery']['crop_width'] );
769
+ $settings['config']['crop_height'] = absint( $_POST['_envira_gallery']['crop_height'] );
770
+ $settings['config']['classes'] = explode( "\n", $_POST['_envira_gallery']['classes'] );
771
+ $settings['config']['title'] = trim( strip_tags( $_POST['_envira_gallery']['title'] ) );
772
+ $settings['config']['slug'] = sanitize_text_field( $_POST['_envira_gallery']['slug'] );
773
+
774
+ // If on an envira post type, map the title and slug of the post object to the custom fields if no value exists yet.
775
+ if ( isset( $post->post_type ) && 'envira' == $post->post_type ) {
776
+ $settings['config']['title'] = trim( strip_tags( $post->post_title ) );
777
+ $settings['config']['slug'] = sanitize_text_field( $post->post_name );
778
+ }
779
+
780
+ // Provide a filter to override settings.
781
+ $settings = apply_filters( 'envira_gallery_save_settings', $settings, $post_id, $post );
782
+
783
+ // Update the post meta.
784
+ update_post_meta( $post_id, '_eg_gallery_data', $settings );
785
+
786
+ // Change states of images in gallery from pending to active.
787
+ $this->change_gallery_states( $post_id );
788
+
789
+ // If the crop option is checked, crop images accordingly.
790
+ if ( isset( $settings['config']['crop'] ) && $settings['config']['crop'] ) {
791
+ $args = apply_filters( 'envira_gallery_crop_image_args',
792
+ array(
793
+ 'position' => 'c',
794
+ 'width' => $this->get_config( 'crop_width', $this->get_config_default( 'crop_width' ) ),
795
+ 'height' => $this->get_config( 'crop_height', $this->get_config_default( 'crop_height' ) ),
796
+ 'quality' => 100,
797
+ 'retina' => false
798
+ )
799
+ );
800
+ $this->crop_images( $args, $post_id );
801
+ }
802
+
803
+ // Finally, flush all gallery caches to ensure everything is up to date.
804
+ $this->flush_gallery_caches( $post_id, $settings['config']['slug'] );
805
+
806
+ }
807
+
808
+ /**
809
+ * Helper method for retrieving the gallery layout for an item in the admin.
810
+ *
811
+ * @since 1.0.0
812
+ *
813
+ * @param int $id The ID of the item to retrieve.
814
+ * @param array $data Array of data for the item.
815
+ * @param int $post_id The current post ID.
816
+ * @return string The HTML output for the gallery item.
817
+ */
818
+ public function get_gallery_item( $id, $data, $post_id = 0 ) {
819
+
820
+ $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); ob_start(); ?>
821
+ <li id="<?php echo $id; ?>" class="envira-gallery-image envira-gallery-status-<?php echo $data['status']; ?>" data-envira-gallery-image="<?php echo $id; ?>">
822
+ <img src="<?php echo esc_url( $thumbnail[0] ); ?>" alt="<?php esc_attr_e( $data['alt'] ); ?>" />
823
+ <a href="#" class="envira-gallery-remove-image" title="<?php esc_attr_e( 'Remove Image from Gallery?', 'envira-gallery' ); ?>"></a>
824
+ <a href="#" class="envira-gallery-modify-image" title="<?php esc_attr_e( 'Modify Image', 'envira-gallery' ); ?>"></a>
825
+ <?php echo $this->get_gallery_item_meta( $id, $data, $post_id ); ?>
826
+ </li>
827
+ <?php
828
+ return ob_get_clean();
829
+
830
+ }
831
+
832
+ /**
833
+ * Helper method for retrieving the gallery metadata editing modal.
834
+ *
835
+ * @since 1.0.0
836
+ *
837
+ * @param int $id The ID of the item to retrieve.
838
+ * @param array $data Array of data for the item.
839
+ * @param int $post_id The current post ID.
840
+ * @return string The HTML output for the gallery item.
841
+ */
842
+ public function get_gallery_item_meta( $id, $data, $post_id ) {
843
+
844
+ ob_start(); ?>
845
+ <div id="envira-gallery-meta-<?php echo $id; ?>" class="envira-gallery-meta-container" style="display:none;">
846
+ <div class="media-modal wp-core-ui">
847
+ <a class="media-modal-close" href="#"><span class="media-modal-icon"></span></a>
848
+ <div class="media-modal-content">
849
+ <div class="media-frame envira-gallery-media-frame wp-core-ui hide-menu hide-router envira-gallery-meta-wrap">
850
+ <div class="media-frame-title">
851
+ <h1><?php _e( 'Edit Metadata', 'envira-gallery' ); ?></h1>
852
+ </div>
853
+ <div class="media-frame-content">
854
+ <div class="attachments-browser">
855
+ <div class="envira-gallery-meta attachments">
856
+ <?php do_action( 'envira_gallery_before_meta_table', $id, $data, $post_id ); ?>
857
+ <table id="envira-gallery-meta-table-<?php echo $id; ?>" class="form-table envira-gallery-meta-table" data-envira-meta-id="<?php echo $id; ?>">
858
+ <tbody>
859
+ <?php do_action( 'envira_gallery_before_meta_settings', $id, $data, $post_id ); ?>
860
+ <tr id="envira-gallery-title-box-<?php echo $id; ?>" valign="middle">
861
+ <th scope="row"><label for="envira-gallery-title-<?php echo $id; ?>"><?php _e( 'Image Title', 'envira-gallery' ); ?></label></th>
862
+ <td>
863
+ <?php wp_editor( $data['title'], 'envira-gallery-title-' . $id, array( 'media_buttons' => false, 'tinymce' => false, 'textarea_name' => '_envira_gallery[meta_title]', 'quicktags' => array( 'buttons' => 'strong,em,link,ul,ol,li,close' ) ) ); ?>
864
+ <p class="description"><?php _e( 'Image titles can take any type of HTML.', 'envira-gallery' ); ?></p>
865
+ </td>
866
+ </tr>
867
+ <tr id="envira-gallery-alt-box-<?php echo $id; ?>" valign="middle">
868
+ <th scope="row"><label for="envira-gallery-alt-<?php echo $id; ?>"><?php _e( 'Image Alt Text', 'envira-gallery' ); ?></label></th>
869
+ <td>
870
+ <input id="envira-gallery-alt-<?php echo $id; ?>" class="envira-gallery-alt" type="text" name="_envira_gallery[meta_alt]" value="<?php echo esc_attr( $data['alt'] ); ?>" data-envira-meta="alt" />
871
+ <p class="description"><?php _e( 'The image alt text is used for SEO. You should probably fill this one out!', 'envira-gallery' ); ?></p>
872
+ </td>
873
+ </tr>
874
+ <tr id="envira-gallery-link-box-<?php echo $id; ?>" class="envira-gallery-link-cell" valign="middle">
875
+ <th scope="row"><label for="envira-gallery-link-<?php echo $id; ?>"><?php _e( 'Image Hyperlink', 'envira-gallery' ); ?></label></th>
876
+ <td>
877
+ <input id="envira-gallery-link-<?php echo $id; ?>" class="envira-gallery-link" type="text" name="_envira_gallery[meta_link]" value="<?php echo esc_url( $data['link'] ); ?>" data-envira-meta="link" />
878
+ <p class="description"><?php _e( 'The image hyperlink determines what opens up in the lightbox once the image is clicked. If this link is set to a regular web page, it will go to that page. Defaults to a larger version of the image itself.', 'envira-gallery' ); ?></p>
879
+ </td>
880
+ </tr>
881
+ <?php do_action( 'envira_gallery_after_meta_settings', $id, $data, $post_id ); ?>
882
+ </tbody>
883
+ </table>
884
+ <?php do_action( 'envira_gallery_after_meta_table', $id, $data, $post_id ); ?>
885
+ </div><!-- end .envira-gallery-meta -->
886
+ <div class="media-sidebar">
887
+ <div class="envira-gallery-meta-sidebar">
888
+ <h3><?php _e( 'Helpful Tips', 'envira-gallery' ); ?></h3>
889
+ <strong><?php _e( 'Image Titles', 'envira-gallery' ); ?></strong>
890
+ <p><?php _e( 'Image titles can take any type of HTML. You can adjust the position of the titles in the main Lightbox settings.', 'envira-gallery' ); ?></p>
891
+ <strong><?php _e( 'Image Hyperlinks', 'envira-gallery' ); ?></strong>
892
+ <p><?php _e( 'The image hyperlink field is used when you click on an image in the gallery. It determines what is displayed in the lightbox view. It could be a larger version of the image, a video, or some other form of content.', 'envira-gallery' ); ?></p>
893
+ <strong><?php _e( 'Saving and Exiting', 'envira-gallery' ); ?></strong>
894
+ <p class="no-margin"><?php _e( 'Click on the button below to save your image metadata. You can close this window by either clicking on the "X" above or hitting the <code>esc</code> key on your keyboard.', 'envira-gallery' ); ?></p>
895
+ </div><!-- end .envira-gallery-meta-sidebar -->
896
+ </div><!-- end .media-sidebar -->
897
+ </div><!-- end .attachments-browser -->
898
+ </div><!-- end .media-frame-content -->
899
+ <div class="media-frame-toolbar">
900
+ <div class="media-toolbar">
901
+ <div class="media-toolbar-primary">
902
+ <a href="#" class="envira-gallery-meta-submit button media-button button-large button-primary media-button-insert" title="<?php esc_attr_e( 'Save Metadata', 'envira-gallery' ); ?>" data-envira-gallery-item="<?php echo $id; ?>"><?php _e( 'Save Metadata', 'envira-gallery' ); ?></a>
903
+ </div><!-- end .media-toolbar-primary -->
904
+ </div><!-- end .media-toolbar -->
905
+ </div><!-- end .media-frame-toolbar -->
906
+ </div><!-- end .media-frame -->
907
+ </div><!-- end .media-modal-content -->
908
+ </div><!-- end .media-modal -->
909
+ <div class="media-modal-backdrop"></div>
910
+ </div>
911
+ <?php
912
+ return ob_get_clean();
913
+
914
+ }
915
+
916
+ /**
917
+ * Helper method to change a gallery state from pending to active. This is done
918
+ * automatically on post save. For previewing galleries before publishing,
919
+ * simply click the "Preview" button and Envira will load all the images present
920
+ * in the gallery at that time.
921
+ *
922
+ * @since 1.0.0
923
+ *
924
+ * @param int $id The current post ID.
925
+ */
926
+ public function change_gallery_states( $post_id ) {
927
+
928
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
929
+ if ( ! empty( $gallery_data['gallery'] ) ) {
930
+ foreach ( (array) $gallery_data['gallery'] as $id => $item ) {
931
+ $gallery_data['gallery'][$id]['status'] = 'active';
932
+ }
933
+ }
934
+
935
+ update_post_meta( $post_id, '_eg_gallery_data', $gallery_data );
936
+
937
+ }
938
+
939
+ /**
940
+ * Helper method to crop gallery images to the specified sizes.
941
+ *
942
+ * @since 1.0.0
943
+ *
944
+ * @param array $args Array of args used when cropping the images.
945
+ * @param int $post_id The current post ID.
946
+ */
947
+ public function crop_images( $args, $post_id ) {
948
+
949
+ // Gather all available images to crop.
950
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
951
+ $images = ! empty( $gallery_data['gallery'] ) ? $gallery_data['gallery'] : false;
952
+ $common = Envira_Gallery_Common_Lite::get_instance();
953
+
954
+ // Loop through the images and crop them.
955
+ if ( $images ) {
956
+ // Increase the time limit to account for large image sets and suspend cache invalidations.
957
+ set_time_limit( 0 );
958
+ wp_suspend_cache_invalidation( true );
959
+
960
+ foreach ( $images as $id => $item ) {
961
+ // Get the full image attachment. If it does not return the data we need, skip over it.
962
+ $image = wp_get_attachment_image_src( $id, 'full' );
963
+ if ( ! is_array( $image ) ) {
964
+ continue;
965
+ }
966
+
967
+ // Generate the cropped image.
968
+ $cropped_image = $common->resize_image( $image[0], $args['width'], $args['height'], true, $args['position'], $args['quality'], $args['retina'] );
969
+
970
+ // If there is an error, possibly output error message, otherwise woot!
971
+ if ( is_wp_error( $cropped_image ) ) {
972
+ // If debugging is defined, print out the error.
973
+ if ( defined( 'ENVIRA_GALLERY_CROP_DEBUG' ) && ENVIRA_GALLERY_CROP_DEBUG ) {
974
+ echo '<pre>' . var_export( $cropped_image->get_error_message(), true ) . '</pre>';
975
+ }
976
+ }
977
+ }
978
+
979
+ // Turn off cache suspension and flush the cache to remove any cache inconsistencies.
980
+ wp_suspend_cache_invalidation( false );
981
+ wp_cache_flush();
982
+ }
983
+
984
+ }
985
+
986
+ /**
987
+ * Helper method to flush gallery caches once a gallery is updated.
988
+ *
989
+ * @since 1.0.0
990
+ *
991
+ * @param int $post_id The current post ID.
992
+ * @param string $slug The unique gallery slug.
993
+ */
994
+ public function flush_gallery_caches( $post_id, $slug ) {
995
+
996
+ Envira_Gallery_Common_Lite::get_instance()->flush_gallery_caches( $post_id, $slug );
997
+
998
+ }
999
+
1000
+ /**
1001
+ * Helper method for retrieving config values.
1002
+ *
1003
+ * @since 1.0.0
1004
+ *
1005
+ * @global int $id The current post ID.
1006
+ * @global object $post The current post object.
1007
+ * @param string $key The config key to retrieve.
1008
+ * @param string $default A default value to use.
1009
+ * @return string Key value on success, empty string on failure.
1010
+ */
1011
+ public function get_config( $key, $default = false ) {
1012
+
1013
+ global $id, $post;
1014
+
1015
+ // Get the current post ID.
1016
+ $post_id = isset( $post->ID ) ? $post->ID : (int) $id;
1017
+
1018
+ $settings = get_post_meta( $post_id, '_eg_gallery_data', true );
1019
+ if ( isset( $settings['config'][$key] ) ) {
1020
+ return $settings['config'][$key];
1021
+ } else {
1022
+ return $default ? $default : '';
1023
+ }
1024
+
1025
+ }
1026
+
1027
+ /**
1028
+ * Helper method for setting default config values.
1029
+ *
1030
+ * @since 1.0.0
1031
+ *
1032
+ * @param string $key The default config key to retrieve.
1033
+ * @return string Key value on success, false on failure.
1034
+ */
1035
+ public function get_config_default( $key ) {
1036
+
1037
+ $instance = Envira_Gallery_Common_Lite::get_instance();
1038
+ return $instance->get_config_default( $key );
1039
+
1040
+ }
1041
+
1042
+ /**
1043
+ * Helper method for retrieving columns.
1044
+ *
1045
+ * @since 1.0.0
1046
+ *
1047
+ * @return array Array of column data.
1048
+ */
1049
+ public function get_columns() {
1050
+
1051
+ $instance = Envira_Gallery_Common_Lite::get_instance();
1052
+ return $instance->get_columns();
1053
+
1054
+ }
1055
+
1056
+ /**
1057
+ * Helper method for retrieving gallery themes.
1058
+ *
1059
+ * @since 1.0.0
1060
+ *
1061
+ * @return array Array of gallery theme data.
1062
+ */
1063
+ public function get_gallery_themes() {
1064
+
1065
+ $instance = Envira_Gallery_Common_Lite::get_instance();
1066
+ return $instance->get_gallery_themes();
1067
+
1068
+ }
1069
+
1070
+ /**
1071
+ * Helper method for retrieving lightbox themes.
1072
+ *
1073
+ * @since 1.0.0
1074
+ *
1075
+ * @return array Array of lightbox theme data.
1076
+ */
1077
+ public function get_lightbox_themes() {
1078
+
1079
+ $instance = Envira_Gallery_Common_Lite::get_instance();
1080
+ return $instance->get_lightbox_themes();
1081
+
1082
+ }
1083
+
1084
+ /**
1085
+ * Returns the post types to skip for loading Envira metaboxes.
1086
+ *
1087
+ * @since 1.0.7
1088
+ *
1089
+ * @return array Array of skipped posttypes.
1090
+ */
1091
+ public function get_skipped_posttypes() {
1092
+
1093
+ return apply_filters( 'envira_gallery_skipped_posttypes', array( 'attachment', 'revision', 'nav_menu_item', 'soliloquy', 'soliloquyv2' ) );
1094
+
1095
+ }
1096
+
1097
+ /**
1098
+ * Returns the singleton instance of the class.
1099
+ *
1100
+ * @since 1.0.0
1101
+ *
1102
+ * @return object The Envira_Gallery_Metaboxes_Lite object.
1103
+ */
1104
+ public static function get_instance() {
1105
+
1106
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Metaboxes_Lite ) ) {
1107
+ self::$instance = new Envira_Gallery_Metaboxes_Lite();
1108
+ }
1109
+
1110
+ return self::$instance;
1111
+
1112
+ }
1113
+
1114
+ }
1115
+
1116
+ // Load the metabox class.
1117
+ $envira_gallery_metaboxes_lite = Envira_Gallery_Metaboxes_Lite::get_instance();
includes/admin/posttype.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Posttype admin class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Posttype_Admin_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Load the base class object.
47
+ $this->base = Envira_Gallery_Lite::get_instance();
48
+
49
+ // Remove quick editing from the Envira post type row actions.
50
+ add_filter( 'post_row_actions', array( $this, 'row_actions' ) );
51
+
52
+ // Manage post type columns.
53
+ add_filter( 'manage_edit-envira_columns', array( $this, 'envira_columns' ) );
54
+ add_filter( 'manage_envira_posts_custom_column', array( $this, 'envira_custom_columns' ), 10, 2 );
55
+
56
+ // Update post type messages.
57
+ add_filter( 'post_updated_messages', array( $this, 'messages' ) );
58
+
59
+ // Force the menu icon to be scaled to proper size (for Retina displays).
60
+ add_action( 'admin_head', array( $this, 'menu_icon' ) );
61
+
62
+ }
63
+
64
+ /**
65
+ * Customize the post columns for the Envira post type.
66
+ *
67
+ * @since 1.0.0
68
+ *
69
+ * @param array $columns The default columns.
70
+ * @return array $columns Amended columns.
71
+ */
72
+ public function envira_columns( $columns ) {
73
+
74
+ $columns = array(
75
+ 'cb' => '<input type="checkbox" />',
76
+ 'title' => __( 'Title', 'envira-gallery' ),
77
+ 'shortcode' => __( 'Shortcode', 'envira-gallery' ),
78
+ 'template' => __( 'Function', 'envira-gallery' ),
79
+ 'images' => __( 'Number of Images', 'envira-gallery' ),
80
+ 'modified' => __( 'Last Modified', 'envira-gallery' ),
81
+ 'date' => __( 'Date', 'envira-gallery' )
82
+ );
83
+
84
+ return $columns;
85
+
86
+ }
87
+
88
+ /**
89
+ * Add data to the custom columns added to the Envira post type.
90
+ *
91
+ * @since 1.0.0
92
+ *
93
+ * @global object $post The current post object
94
+ * @param string $column The name of the custom column
95
+ * @param int $post_id The current post ID
96
+ */
97
+ public function envira_custom_columns( $column, $post_id ) {
98
+
99
+ global $post;
100
+ $post_id = absint( $post_id );
101
+
102
+ switch ( $column ) {
103
+ case 'shortcode' :
104
+ echo '<code>[envira-gallery id="' . $post_id . '"]</code>';
105
+ break;
106
+
107
+ case 'template' :
108
+ echo '<code>if ( function_exists( \'envira_gallery\' ) ) { envira_gallery( \'' . $post_id . '\' ); }</code>';
109
+ break;
110
+
111
+ case 'images' :
112
+ $gallery_data = get_post_meta( $post_id, '_eg_gallery_data', true );
113
+ echo ( ! empty( $gallery_data['gallery'] ) ? count( $gallery_data['gallery'] ) : 0 );
114
+ break;
115
+
116
+ case 'modified' :
117
+ the_modified_date();
118
+ break;
119
+ }
120
+
121
+ }
122
+
123
+ /**
124
+ * Filter out unnecessary row actions from the Envira post table.
125
+ *
126
+ * @since 1.0.0
127
+ *
128
+ * @param array $actions Default row actions.
129
+ * @return array $actions Amended row actions.
130
+ */
131
+ public function row_actions( $actions ) {
132
+
133
+ if ( isset( get_current_screen()->post_type ) && 'envira' == get_current_screen()->post_type ) {
134
+ unset( $actions['inline hide-if-no-js'] );
135
+ }
136
+
137
+ return $actions;
138
+
139
+ }
140
+
141
+ /**
142
+ * Contextualizes the post updated messages.
143
+ *
144
+ * @since 1.0.0
145
+ *
146
+ * @global object $post The current post object.
147
+ * @param array $messages Array of default post updated messages.
148
+ * @return array $messages Amended array of post updated messages.
149
+ */
150
+ public function messages( $messages ) {
151
+
152
+ global $post;
153
+
154
+ // Contextualize the messages.
155
+ $messages['envira'] = apply_filters( 'envira_gallery_messages',
156
+ array(
157
+ 0 => '',
158
+ 1 => __( 'Envira gallery updated.', 'envira-gallery' ),
159
+ 2 => __( 'Envira gallery custom field updated.', 'envira-gallery' ),
160
+ 3 => __( 'Envira gallery custom field deleted.', 'envira-gallery' ),
161
+ 4 => __( 'Envira gallery updated.', 'envira-gallery' ),
162
+ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Envira gallery restored to revision from %s.', 'envira-gallery' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
163
+ 6 => __( 'Envira gallery published.', 'envira-gallery' ),
164
+ 7 => __( 'Envira gallery saved.', 'envira-gallery' ),
165
+ 8 => __( 'Envira gallery submitted.', 'envira-gallery' ),
166
+ 9 => sprintf( __( 'Envira gallery scheduled for: <strong>%1$s</strong>.', 'envira-gallery' ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ) ),
167
+ 10 => __( 'Envira gallery draft updated.', 'envira-gallery' )
168
+ )
169
+ );
170
+
171
+ return $messages;
172
+
173
+ }
174
+
175
+ /**
176
+ * Forces the Envira menu icon width/height for Retina devices.
177
+ *
178
+ * @since 1.0.0
179
+ */
180
+ public function menu_icon() {
181
+
182
+ ?>
183
+ <style type="text/css">#menu-posts-envira .wp-menu-image img { width: 16px; height: 16px; }</style>
184
+ <?php
185
+
186
+ }
187
+
188
+ /**
189
+ * Returns the singleton instance of the class.
190
+ *
191
+ * @since 1.0.0
192
+ *
193
+ * @return object The Envira_Gallery_Posttype_Admin_Lite object.
194
+ */
195
+ public static function get_instance() {
196
+
197
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Posttype_Admin_Lite ) ) {
198
+ self::$instance = new Envira_Gallery_Posttype_Admin_Lite();
199
+ }
200
+
201
+ return self::$instance;
202
+
203
+ }
204
+
205
+ }
206
+
207
+ // Load the posttype admin class.
208
+ $envira_gallery_posttype_admin_lite = Envira_Gallery_Posttype_Admin_Lite::get_instance();
includes/global/common.php ADDED
@@ -0,0 +1,455 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Common class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Common_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Load the base class object.
47
+ $this->base = Envira_Gallery_Lite::get_instance();
48
+
49
+ }
50
+
51
+ /**
52
+ * Helper method for retrieving columns.
53
+ *
54
+ * @since 1.0.0
55
+ *
56
+ * @return array Array of column data.
57
+ */
58
+ public function get_columns() {
59
+
60
+ $columns = array(
61
+ array(
62
+ 'value' => '1',
63
+ 'name' => __( 'One Column (1)', 'envira-gallery' )
64
+ ),
65
+ array(
66
+ 'value' => '2',
67
+ 'name' => __( 'Two Columns (2)', 'envira-gallery' )
68
+ ),
69
+ array(
70
+ 'value' => '3',
71
+ 'name' => __( 'Three Columns (3)', 'envira-gallery' )
72
+ ),
73
+ array(
74
+ 'value' => '4',
75
+ 'name' => __( 'Four Columns (4)', 'envira-gallery' )
76
+ ),
77
+ array(
78
+ 'value' => '5',
79
+ 'name' => __( 'Five Columns (5)', 'envira-gallery' )
80
+ ),
81
+ array(
82
+ 'value' => '6',
83
+ 'name' => __( 'Six Columns (6)', 'envira-gallery' )
84
+ )
85
+ );
86
+
87
+ return apply_filters( 'envira_gallery_columns', $columns );
88
+
89
+ }
90
+
91
+ /**
92
+ * Helper method for retrieving gallery themes.
93
+ *
94
+ * @since 1.0.0
95
+ *
96
+ * @return array Array of gallery theme data.
97
+ */
98
+ public function get_gallery_themes() {
99
+
100
+ $themes = array(
101
+ array(
102
+ 'value' => 'base',
103
+ 'name' => __( 'Base', 'envira-gallery' ),
104
+ 'file' => $this->base->file
105
+ )
106
+ );
107
+
108
+ return apply_filters( 'envira_gallery_gallery_themes', $themes );
109
+
110
+ }
111
+
112
+ /**
113
+ * Helper method for retrieving lightbox themes.
114
+ *
115
+ * @since 1.0.0
116
+ *
117
+ * @return array Array of lightbox theme data.
118
+ */
119
+ public function get_lightbox_themes() {
120
+
121
+ $themes = array(
122
+ array(
123
+ 'value' => 'base',
124
+ 'name' => __( 'Base', 'envira-gallery' ),
125
+ 'file' => $this->base->file
126
+ )
127
+ );
128
+
129
+ return apply_filters( 'envira_gallery_lightbox_themes', $themes );
130
+
131
+ }
132
+
133
+ /**
134
+ * Helper method for setting default config values.
135
+ *
136
+ * @since 1.0.0
137
+ *
138
+ * @global int $id The current post ID.
139
+ * @global object $post The current post object.
140
+ * @param string $key The default config key to retrieve.
141
+ * @return string Key value on success, false on failure.
142
+ */
143
+ public function get_config_default( $key ) {
144
+
145
+ global $id, $post;
146
+
147
+ // Get the current post ID.
148
+ $post_id = ( null === $id ) ? $post->ID : $id;
149
+
150
+ // Prepare default values.
151
+ $defaults = array(
152
+ 'columns' => '1',
153
+ 'gallery_theme' => 'base',
154
+ 'lightbox_theme' => 'base',
155
+ 'gutter' => 10,
156
+ 'margin' => 10,
157
+ 'crop' => 0,
158
+ 'crop_width' => 960,
159
+ 'crop_height' => 300,
160
+ 'arrows' => 1,
161
+ 'keyboard' => 1,
162
+ 'mousewheel' => 1,
163
+ 'aspect' => 1,
164
+ 'toolbar' => 0,
165
+ 'toolbar_position' => 'top',
166
+ 'loop' => 1,
167
+ 'classes' => array(),
168
+ 'title' => '',
169
+ 'slug' => ''
170
+ );
171
+
172
+ // Allow devs to filter the defaults.
173
+ $defaults = apply_filters( 'envira_gallery_defaults', $defaults, $post_id );
174
+
175
+ // Return the key specified.
176
+ return isset( $defaults[$key] ) ? $defaults[$key] : false;
177
+
178
+ }
179
+
180
+ /**
181
+ * API method for cropping images.
182
+ *
183
+ * @since 1.0.0
184
+ *
185
+ * @global object $wpdb The $wpdb database object.
186
+ *
187
+ * @param string $url The URL of the image to resize.
188
+ * @param int $width The width for cropping the image.
189
+ * @param int $height The height for cropping the image.
190
+ * @param bool $crop Whether or not to crop the image (default yes).
191
+ * @param string $align The crop position alignment.
192
+ * @param bool $retina Whether or not to make a retina copy of image.
193
+ * @return WP_Error|string Return WP_Error on error, URL of resized image on success.
194
+ */
195
+ public function resize_image( $url, $width = null, $height = null, $crop = true, $align = 'c', $quality = 100, $retina = false ) {
196
+
197
+ global $wpdb;
198
+
199
+ // Get common vars.
200
+ $args = func_get_args();
201
+ $common = $this->get_image_info( $args );
202
+
203
+ // Unpack variables if an array, otherwise return WP_Error.
204
+ if ( is_wp_error( $common ) ) {
205
+ return $common;
206
+ } else {
207
+ extract( $common );
208
+ }
209
+
210
+ // If the destination width/height values are the same as the original, don't do anything.
211
+ if ( $orig_width === $dest_width && $orig_height === $dest_height ) {
212
+ return $url;
213
+ }
214
+
215
+ // If the file doesn't exist yet, we need to create it.
216
+ if ( ! file_exists( $dest_file_name ) ) {
217
+ // We only want to resize Media Library images, so we can be sure they get deleted correctly when appropriate.
218
+ $get_attachment = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE guid='%s'", $url ) );
219
+
220
+ // Load the WordPress image editor.
221
+ $editor = wp_get_image_editor( $file_path );
222
+
223
+ // If an editor cannot be found, the user needs to have GD or Imagick installed.
224
+ if ( is_wp_error( $editor ) ) {
225
+ return new WP_Error( 'envira-gallery-error-no-editor', __( 'No image editor could be selected. Please verify with your webhost that you have either the GD or Imagick image library compiled with your PHP install on your server.', 'envira-gallery' ) );
226
+ }
227
+
228
+ // Set the image editor quality.
229
+ $editor->set_quality( $quality );
230
+
231
+ // If cropping, process cropping.
232
+ if ( $crop ) {
233
+ $src_x = $src_y = 0;
234
+ $src_w = $orig_width;
235
+ $src_h = $orig_height;
236
+
237
+ $cmp_x = $orig_width / $dest_width;
238
+ $cmp_y = $orig_height / $dest_height;
239
+
240
+ // Calculate x or y coordinate and width or height of source
241
+ if ( $cmp_x > $cmp_y ) {
242
+ $src_w = round( $orig_width / $cmp_x * $cmp_y );
243
+ $src_x = round( ($orig_width - ($orig_width / $cmp_x * $cmp_y)) / 2 );
244
+ } else if ( $cmp_y > $cmp_x ) {
245
+ $src_h = round( $orig_height / $cmp_y * $cmp_x );
246
+ $src_y = round( ($orig_height - ($orig_height / $cmp_y * $cmp_x)) / 2 );
247
+ }
248
+
249
+ // Positional cropping.
250
+ if ( $align && $align != 'c' ) {
251
+ if ( strpos( $align, 't' ) !== false || strpos( $align, 'tr' ) !== false || strpos( $align, 'tl' ) !== false ) {
252
+ $src_y = 0;
253
+ }
254
+
255
+ if ( strpos( $align, 'b' ) !== false || strpos( $align, 'br' ) !== false || strpos( $align, 'bl' ) !== false ) {
256
+ $src_y = $orig_height - $src_h;
257
+ }
258
+
259
+ if ( strpos( $align, 'l' ) !== false ) {
260
+ $src_x = 0;
261
+ }
262
+
263
+ if ( strpos ( $align, 'r' ) !== false ) {
264
+ $src_x = $orig_width - $src_w;
265
+ }
266
+ }
267
+
268
+ // Crop the image.
269
+ $editor->crop( $src_x, $src_y, $src_w, $src_h, $dest_width, $dest_height );
270
+ } else {
271
+ // Just resize the image.
272
+ $editor->resize( $dest_width, $dest_height );
273
+ }
274
+
275
+ // Save the image.
276
+ $saved = $editor->save( $dest_file_name );
277
+
278
+ // Print possible out of memory errors.
279
+ if ( is_wp_error( $saved ) ) {
280
+ @unlink( $dest_file_name );
281
+ return $saved;
282
+ }
283
+
284
+ // Add the resized dimensions and alignment to original image metadata, so the images
285
+ // can be deleted when the original image is delete from the Media Library.
286
+ if ( $get_attachment ) {
287
+ $metadata = wp_get_attachment_metadata( $get_attachment[0]->ID );
288
+
289
+ if ( isset( $metadata['image_meta'] ) ) {
290
+ $md = $saved['width'] . 'x' . $saved['height'];
291
+
292
+ if ( $crop ) {
293
+ $md .= $align ? "_${align}" : "_c";
294
+ }
295
+
296
+ $metadata['image_meta']['resized_images'][] = $md;
297
+ wp_update_attachment_metadata( $get_attachment[0]->ID, $metadata );
298
+ }
299
+ }
300
+
301
+ // Set the resized image URL.
302
+ $resized_url = str_replace( basename( $url ), basename( $saved['path'] ), $url );
303
+ } else {
304
+ // Set the resized image URL.
305
+ $resized_url = str_replace( basename( $url ), basename( $dest_file_name ), $url );
306
+ }
307
+
308
+ // Return the resized image URL.
309
+ return $resized_url;
310
+
311
+ }
312
+
313
+ /**
314
+ * Helper method to return common information about an image.
315
+ *
316
+ * @since 1.0.0
317
+ *
318
+ * @param array $args List of resizing args to expand for gathering info.
319
+ * @return WP_Error|string Return WP_Error on error, array of data on success.
320
+ */
321
+ public function get_image_info( $args ) {
322
+
323
+ // Unpack arguments.
324
+ list( $url, $width, $height, $crop, $align, $quality, $retina ) = $args;
325
+
326
+ // Return an error if no URL is present.
327
+ if ( empty( $url ) ) {
328
+ return new WP_Error( 'envira-gallery-error-no-url', __( 'No image URL specified for cropping.', 'envira-gallery' ) );
329
+ }
330
+
331
+ // Get the image file path.
332
+ $urlinfo = parse_url( $url );
333
+ $wp_upload_dir = wp_upload_dir();
334
+
335
+ // Interpret the file path of the image.
336
+ if ( preg_match( '/\/[0-9]{4}\/[0-9]{2}\/.+$/', $urlinfo['path'], $matches ) ) {
337
+ $file_path = $wp_upload_dir['basedir'] . $matches[0];
338
+ } else {
339
+ $pathinfo = parse_url( $url );
340
+ $uploads_dir = is_multisite() ? '/files/' : '/wp-content/';
341
+ $file_path = ABSPATH . str_replace( dirname( $_SERVER['SCRIPT_NAME'] ) . '/', '', strstr( $pathinfo['path'], $uploads_dir ) );
342
+ $file_path = preg_replace( '/(\/\/)/', '/', $file_path );
343
+ }
344
+
345
+ // Don't process a file that does not exist.
346
+ if ( ! file_exists( $file_path ) ) {
347
+ return new WP_Error( 'envira-gallery-error-no-file', __( 'No file could be found for the image URL specified.', 'envira-gallery' ) );
348
+ }
349
+
350
+ // Get original image size
351
+ $size = @getimagesize( $file_path );
352
+
353
+ // If no size data obtained, return an error.
354
+ if ( ! $size ) {
355
+ return new WP_Error( 'envira-gallery-error-no-size', __( 'The dimensions of the original image could not be retrieved for cropping.', 'envira-gallery' ) );
356
+ }
357
+
358
+ // Set original width and height.
359
+ list( $orig_width, $orig_height, $orig_type ) = $size;
360
+
361
+ // Generate width or height if not provided.
362
+ if ( $width && ! $height ) {
363
+ $height = floor( $orig_height * ($width / $orig_width) );
364
+ } else if ( $height && ! $width ) {
365
+ $width = floor( $orig_width * ($height / $orig_height) );
366
+ } else if ( ! $width && ! $height ) {
367
+ return new WP_Error( 'envira-gallery-error-no-size', __( 'The dimensions of the original image could not be retrieved for cropping.', 'envira-gallery' ) );
368
+ }
369
+
370
+ // Allow for different retina image sizes.
371
+ $retina = $retina ? ( $retina === true ? 2 : $retina ) : 1;
372
+
373
+ // Destination width and height variables
374
+ $dest_width = $width * $retina;
375
+ $dest_height = $height * $retina;
376
+
377
+ // Some additional info about the image.
378
+ $info = pathinfo( $file_path );
379
+ $dir = $info['dirname'];
380
+ $ext = $info['extension'];
381
+ $name = wp_basename( $file_path, ".$ext" );
382
+
383
+ // Suffix applied to filename
384
+ $suffix = "${dest_width}x${dest_height}";
385
+
386
+ // Set alignment information on the file.
387
+ if ( $crop ) {
388
+ $suffix .= ( $align ) ? "_${align}" : "_c";
389
+ }
390
+
391
+ // Get the destination file name
392
+ $dest_file_name = "${dir}/${name}-${suffix}.${ext}";
393
+
394
+ // Return the info.
395
+ return array(
396
+ 'dir' => $dir,
397
+ 'name' => $name,
398
+ 'ext' => $ext,
399
+ 'suffix' => $suffix,
400
+ 'orig_width' => $orig_width,
401
+ 'orig_height' => $orig_height,
402
+ 'orig_type' => $orig_type,
403
+ 'dest_width' => $dest_width,
404
+ 'dest_height' => $dest_height,
405
+ 'file_path' => $file_path,
406
+ 'dest_file_name' => $dest_file_name,
407
+ );
408
+
409
+ }
410
+
411
+ /**
412
+ * Helper method to flush gallery caches once a gallery is updated.
413
+ *
414
+ * @since 1.0.0
415
+ *
416
+ * @param int $post_id The current post ID.
417
+ * @param string $slug The unique gallery slug.
418
+ */
419
+ public function flush_gallery_caches( $post_id, $slug = '' ) {
420
+
421
+ // Delete known gallery caches.
422
+ delete_transient( '_eg_cache_' . $post_id );
423
+ delete_transient( '_eg_cache_all' );
424
+
425
+ // Possibly delete slug gallery cache if available.
426
+ if ( ! empty( $slug ) ) {
427
+ delete_transient( '_eg_cache_' . $slug );
428
+ }
429
+
430
+ // Run a hook for Addons to access.
431
+ do_action( 'envira_gallery_flush_caches', $post_id, $slug );
432
+
433
+ }
434
+
435
+ /**
436
+ * Returns the singleton instance of the class.
437
+ *
438
+ * @since 1.0.0
439
+ *
440
+ * @return object The Envira_Gallery_Common_Lite object.
441
+ */
442
+ public static function get_instance() {
443
+
444
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Common_Lite ) ) {
445
+ self::$instance = new Envira_Gallery_Common_Lite();
446
+ }
447
+
448
+ return self::$instance;
449
+
450
+ }
451
+
452
+ }
453
+
454
+ // Load the common class.
455
+ $envira_gallery_common_lite = Envira_Gallery_Common_Lite::get_instance();
includes/global/posttype.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Posttype class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Posttype_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct() {
45
+
46
+ // Load the base class object.
47
+ $this->base = Envira_Gallery_Lite::get_instance();
48
+
49
+ // Build the labels for the post type.
50
+ $labels = apply_filters( 'envira_gallery_post_type_labels',
51
+ array(
52
+ 'name' => __( 'Envira Gallery', 'envira-gallery' ),
53
+ 'singular_name' => __( 'Envira Gallery', 'envira-gallery' ),
54
+ 'add_new' => __( 'Add New', 'envira-gallery' ),
55
+ 'add_new_item' => __( 'Add New Envira Gallery', 'envira-gallery' ),
56
+ 'edit_item' => __( 'Edit Envira Gallery', 'envira-gallery' ),
57
+ 'new_item' => __( 'New Envira Gallery', 'envira-gallery' ),
58
+ 'view_item' => __( 'View Envira Gallery', 'envira-gallery' ),
59
+ 'search_items' => __( 'Search Envira Galleries', 'envira-gallery' ),
60
+ 'not_found' => __( 'No Envira galleries found.', 'envira-gallery' ),
61
+ 'not_found_in_trash' => __( 'No Envira galleries found in trash.', 'envira-gallery' ),
62
+ 'parent_item_colon' => '',
63
+ 'menu_name' => __( 'Envira Gallery', 'envira-gallery' )
64
+ )
65
+ );
66
+
67
+ // Build out the post type arguments.
68
+ $args = apply_filters( 'envira_gallery_post_type_args',
69
+ array(
70
+ 'labels' => $labels,
71
+ 'public' => false,
72
+ 'exclude_from_search' => false,
73
+ 'show_ui' => true,
74
+ 'show_in_admin_bar' => false,
75
+ 'rewrite' => false,
76
+ 'query_var' => false,
77
+ 'menu_position' => apply_filters( 'envira_gallery_post_type_menu_position', 247 ),
78
+ 'menu_icon' => plugins_url( 'assets/css/images/menu-icon@2x.png', $this->base->file ),
79
+ 'supports' => array( 'title' )
80
+ )
81
+ );
82
+
83
+ // Register the post type with WordPress.
84
+ register_post_type( 'envira', $args );
85
+
86
+ }
87
+
88
+ /**
89
+ * Returns the singleton instance of the class.
90
+ *
91
+ * @since 1.0.0
92
+ *
93
+ * @return object The Envira_Gallery_Posttype_Lite object.
94
+ */
95
+ public static function get_instance() {
96
+
97
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Posttype_Lite ) ) {
98
+ self::$instance = new Envira_Gallery_Posttype_Lite();
99
+ }
100
+
101
+ return self::$instance;
102
+
103
+ }
104
+
105
+ }
106
+
107
+ // Load the posttype class.
108
+ $envira_gallery_posttype_lite = Envira_Gallery_Posttype_Lite::get_instance();
includes/global/shortcode.php ADDED
@@ -0,0 +1,536 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shortcode class.
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package Envira_Gallery_Lite
8
+ * @author Thomas Griffin
9
+ */
10
+ class Envira_Gallery_Shortcode_Lite {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.0.0
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.0.0
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the base class object.
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @var object
36
+ */
37
+ public $base;
38
+
39
+ /**
40
+ * Holds the gallery data.
41
+ *
42
+ * @since 1.0.0
43
+ *
44
+ * @var array
45
+ */
46
+ public $data;
47
+
48
+ /**
49
+ * Holds gallery IDs for init firing checks.
50
+ *
51
+ * @since 1.0.0
52
+ *
53
+ * @var array
54
+ */
55
+ public $done = array();
56
+
57
+ /**
58
+ * Iterator for galleries on the page.
59
+ *
60
+ * @since 1.0.0
61
+ *
62
+ * @var int
63
+ */
64
+ public $counter = 1;
65
+
66
+ /**
67
+ * Primary class constructor.
68
+ *
69
+ * @since 1.0.0
70
+ */
71
+ public function __construct() {
72
+
73
+ // Load the base class object.
74
+ $this->base = Envira_Gallery_Lite::get_instance();
75
+
76
+ // Register main gallery style.
77
+ wp_register_style( $this->base->plugin_slug . '-style', plugins_url( 'assets/css/envira.css', $this->base->file ), array(), $this->base->version );
78
+
79
+ // Register main gallery script.
80
+ wp_register_script( $this->base->plugin_slug . '-script', plugins_url( 'assets/js/envira.js', $this->base->file ), array( 'jquery' ), $this->base->version, true );
81
+
82
+ // Load hooks and filters.
83
+ add_shortcode( 'envira-gallery', array( $this, 'shortcode' ) );
84
+
85
+ }
86
+
87
+ /**
88
+ * Creates the shortcode for the plugin.
89
+ *
90
+ * @since 1.0.0
91
+ *
92
+ * @global object $post The current post object.
93
+ *
94
+ * @param array $atts Array of shortcode attributes.
95
+ * @return string The gallery output.
96
+ */
97
+ public function shortcode( $atts ) {
98
+
99
+ global $post;
100
+
101
+ // If no attributes have been passed, the gallery should be pulled from the current post.
102
+ $gallery_id = false;
103
+ if ( empty( $atts ) ) {
104
+ $gallery_id = $post->ID;
105
+ $data = is_preview() ? $this->base->_get_gallery( $gallery_id ) : $this->base->get_gallery( $gallery_id );
106
+ } else if ( isset( $atts['id'] ) ) {
107
+ $gallery_id = (int) $atts['id'];
108
+ $data = is_preview() ? $this->base->_get_gallery( $gallery_id ) : $this->base->get_gallery( $gallery_id );
109
+ } else if ( isset( $atts['slug'] ) ) {
110
+ $gallery_id = $atts['slug'];
111
+ $data = is_preview() ? $this->base->_get_gallery_by_slug( $gallery_id ) : $this->base->get_gallery_by_slug( $gallery_id );
112
+ } else {
113
+ // A custom attribute must have been passed. Allow it to be filtered to grab data from a custom source.
114
+ $data = apply_filters( 'envira_gallery_custom_gallery_data', false, $atts, $post );
115
+ }
116
+
117
+ // If there is no data to output or the gallery is inactive, do nothing.
118
+ if ( ! $data || empty( $data['gallery'] ) || isset( $data['status'] ) && 'inactive' == $data['status'] && ! is_preview() ) {
119
+ return;
120
+ }
121
+
122
+ // Get rid of any external plugins trying to jack up our stuff where a gallery is present.
123
+ $this->plugin_humility();
124
+
125
+ // Allow the data to be filtered before it is stored and used to create the gallery output.
126
+ $data = apply_filters( 'envira_gallery_pre_data', $data, $gallery_id );
127
+
128
+ // Prepare variables.
129
+ $this->data[] = $data;
130
+ $gallery = '';
131
+ $i = 1;
132
+
133
+ // If this is a feed view, customize the output and return early.
134
+ if ( is_feed() ) {
135
+ return $this->do_feed_output( $data );
136
+ }
137
+
138
+ // Load scripts and styles.
139
+ wp_enqueue_style( $this->base->plugin_slug . '-style' );
140
+ wp_enqueue_script( $this->base->plugin_slug . '-script' );
141
+
142
+ // Load gallery init code in the footer.
143
+ add_action( 'wp_footer', array( $this, 'gallery_init' ), 1000 );
144
+
145
+ // Run a hook before the gallery output begins but after scripts and inits have been set.
146
+ do_action( 'envira_gallery_before_output', $data );
147
+
148
+ // Apply a filter before starting the gallery HTML.
149
+ $gallery = apply_filters( 'envira_gallery_output_start', $gallery, $data );
150
+
151
+ // Build out the gallery HTML.
152
+ $gallery .= '<div id="envira-gallery-wrap-' . sanitize_html_class( $data['id'] ) . '" class="' . $this->get_gallery_classes( $data ) . '">';
153
+ $gallery = apply_filters( 'envira_gallery_output_before_container', $gallery, $data );
154
+ $gallery .= '<div id="envira-gallery-' . sanitize_html_class( $data['id'] ) . '" class="envira-gallery-public envira-gallery-' . sanitize_html_class( $this->get_config( 'columns', $data ) ) . '-columns envira-clear isotope" data-envira-columns="' . $this->get_config( 'columns', $data ) . '">';
155
+ foreach ( $data['gallery'] as $id => $item ) {
156
+ // Skip over images that are pending (ignore if in Preview mode).
157
+ if ( isset( $item['status'] ) && 'pending' == $item['status'] && ! is_preview() ) {
158
+ continue;
159
+ }
160
+
161
+ $imagesrc = $this->get_image_src( $id, $item, $data );
162
+ $gallery = apply_filters( 'envira_gallery_output_before_item', $gallery, $id, $item, $data, $i );
163
+ $output = '<div id="envira-gallery-item-' . sanitize_html_class( $id ) . '" class="' . $this->get_gallery_item_classes( $item, $i, $data ) . '" style="margin-bottom: ' . $this->get_config( 'margin', $data ) . 'px;" ' . apply_filters( 'envira_gallery_output_item_attr', '', $id, $item, $data, $i ) . '>';
164
+
165
+ if ( ! empty( $item['link'] ) ) {
166
+ $output = apply_filters( 'envira_gallery_output_before_link', $output, $id, $item, $data, $i );
167
+ $output .= '<a href="' . esc_url( $item['link'] ) . '" class="envira-gallery-' . sanitize_html_class( $data['id'] ) . ' envira-gallery-link" rel="enviragallery' . sanitize_html_class( $data['id'] ) . '" title="' . esc_attr( $item['title'] ) . '" data-thumbnail="' . esc_url( $item['thumb'] ) . '">';
168
+ }
169
+
170
+ $output = apply_filters( 'envira_gallery_output_before_image', $output, $id, $item, $data, $i );
171
+ $output .= '<img id="envira-gallery-image-' . sanitize_html_class( $id ) . '" class="envira-gallery-image envira-gallery-preload envira-gallery-image-' . $i . '" src="' . esc_url( plugins_url( 'assets/css/images/holder.gif', dirname( dirname( __FILE__ ) ) ) ) . '" data-envira-src="' . esc_url( $imagesrc ) . '" alt="' . esc_attr( $item['title'] ) . '" ' . apply_filters( 'envira_gallery_output_image_attr', '', $id, $item, $data, $i ) . ' />';
172
+ $output = apply_filters( 'envira_gallery_output_after_image', $output, $id, $item, $data, $i );
173
+
174
+ if ( ! empty( $item['link'] ) ) {
175
+ $output .= '</a>';
176
+ $output = apply_filters( 'envira_gallery_output_after_link', $output, $id, $item, $data, $i );
177
+ }
178
+
179
+ $output .= '</div>';
180
+ $output = apply_filters( 'envira_gallery_output_single_item', $output, $id, $item, $data, $i );
181
+ $gallery .= $output;
182
+ $gallery = apply_filters( 'envira_gallery_output_after_item', $gallery, $id, $item, $data, $i );
183
+
184
+ // Increment the iterator.
185
+ $i++;
186
+ }
187
+ $gallery .= '</div>';
188
+ $gallery = apply_filters( 'envira_gallery_output_after_container', $gallery, $data );
189
+ $gallery .= '</div>';
190
+ $gallery = apply_filters( 'envira_gallery_output_end', $gallery, $data );
191
+
192
+ // Increment the counter.
193
+ $this->counter++;
194
+
195
+ // Return the gallery HTML.
196
+ return apply_filters( 'envira_gallery_output', $gallery, $data );
197
+
198
+ }
199
+
200
+ /**
201
+ * Outputs the gallery init script in the footer.
202
+ *
203
+ * @since 1.0.0
204
+ */
205
+ public function gallery_init() {
206
+
207
+ ?>
208
+ <script type="text/javascript">jQuery(document).ready(function($){<?php ob_start();
209
+ do_action( 'envira_gallery_api_start_global' );
210
+ foreach ( $this->data as $data ) :
211
+ // Prevent multiple init scripts for the same gallery ID.
212
+ if ( in_array( $data['id'], $this->done ) )
213
+ continue;
214
+ $this->done[] = $data['id'];
215
+
216
+ do_action( 'envira_gallery_api_start', $data ); ?>
217
+
218
+ var envira_container_<?php echo $data['id']; ?> = $('#envira-gallery-<?php echo $data['id']; ?>'),
219
+ envira_on_show_<?php echo $data['id']; ?>,
220
+ envira_on_render_<?php echo $data['id']; ?>,
221
+ envira_holder_<?php echo $data['id']; ?> = $('#envira-gallery-<?php echo $data['id']; ?>').find(".envira-gallery-preload"),
222
+ envira_throttle_<?php echo $data['id']; ?> = <?php echo apply_filters( 'envira_gallery_isotope_throttle', 500, $data ); ?>;
223
+
224
+ function enviraOnFinished<?php echo $data['id']; ?>(){
225
+ envira_container_<?php echo $data['id']; ?>.isotope('reLayout');
226
+ envira_container_<?php echo $data['id']; ?>.parent().css('background-image', 'none');
227
+ }
228
+
229
+ envira_container_<?php echo $data['id']; ?>.isotope({
230
+ <?php do_action( 'envira_gallery_api_enviratope_config', $data ); ?>
231
+ transformsEnabled: false,
232
+ masonry: {
233
+ gutterWidth: <?php echo absint( $this->get_config( 'gutter', $data ) ); ?>,
234
+ columnWidth: enviraGetColWidth(envira_container_<?php echo $data['id']; ?>, <?php echo absint( $this->get_config( 'gutter', $data ) ); ?>)
235
+ },
236
+ onLayout: function( $elems, instance ) {
237
+ envira_container_<?php echo $data['id']; ?>.css('overflow', 'visible');
238
+ <?php do_action( 'envira_gallery_api_enviratope_layout', $data ); ?>
239
+ }
240
+ }, enviraOnFinished<?php echo $data['id']; ?>);
241
+
242
+ var enviraApplyIsotope<?php echo $data['id']; ?> = enviraThrottle(function(){
243
+ envira_container_<?php echo $data['id']; ?>.isotope('reLayout');
244
+ }, envira_throttle_<?php echo $data['id']; ?>);
245
+
246
+ if ( 0 !== envira_holder_<?php echo $data['id']; ?>.length ) {
247
+ var envira_src_attr = 'data-envira-src';
248
+ $.each(envira_holder_<?php echo $data['id']; ?>, function(i, el){
249
+ var envira_src = $(this).attr(envira_src_attr);
250
+ if ( typeof envira_src === 'undefined' || false === envira_src ) {
251
+ return;
252
+ }
253
+
254
+ var envira_image = new Image();
255
+ envira_image.src = envira_src;
256
+ $(this).attr('src', envira_src).removeAttr(envira_src_attr).css('opacity', '1');
257
+ envira_image.onload = function(){
258
+ enviraApplyIsotope<?php echo $data['id']; ?>();
259
+ };
260
+
261
+ // If loading in the last image, don't throttle the reLayout method - just do it.
262
+ if ( (i + 1) === envira_holder_<?php echo $data['id']; ?>.length ) {
263
+ envira_container_<?php echo $data['id']; ?>.parent().css('background-image', 'none');
264
+ }
265
+ });
266
+ }
267
+
268
+ <?php do_action( 'envira_gallery_api_preload', $data ); ?>
269
+
270
+ enviraSetWidths(envira_container_<?php echo $data['id']; ?>, <?php echo absint( $this->get_config( 'gutter', $data ) ); ?>);
271
+
272
+ $(window).smartresize(function(){
273
+ enviraSetWidths(envira_container_<?php echo $data['id']; ?>, <?php echo absint( $this->get_config( 'gutter', $data ) ); ?>);
274
+ envira_container_<?php echo $data['id']; ?>.isotope({
275
+ <?php do_action( 'envira_gallery_api_isotope_config', $data ); // Deprecated. ?>
276
+ <?php do_action( 'envira_gallery_api_enviratope_config', $data ); ?>
277
+ transformsEnabled: false,
278
+ masonry: {
279
+ gutterWidth: <?php echo absint( $this->get_config( 'gutter', $data ) ); ?>,
280
+ columnWidth: enviraGetColWidth(envira_container_<?php echo $data['id']; ?>, <?php echo absint( $this->get_config( 'gutter', $data ) ); ?>)
281
+ },
282
+ onLayout: function( $elems, instance ) {
283
+ envira_container_<?php echo $data['id']; ?>.css('overflow', 'visible');
284
+ <?php do_action( 'envira_gallery_api_isotope_layout', $data ); // Deprecated. ?>
285
+ <?php do_action( 'envira_gallery_api_enviratope_layout', $data ); ?>
286
+ }
287
+ }, enviraOnFinished<?php echo $data['id']; ?>);
288
+ });
289
+
290
+ <?php do_action( 'envira_gallery_api_isotope', $data ); // Deprecated. ?>
291
+ <?php do_action( 'envira_gallery_api_enviratope', $data ); ?>
292
+
293
+
294
+ $('.envira-gallery-<?php echo $data['id']; ?>').fancybox({
295
+ <?php do_action( 'envira_gallery_api_config', $data ); ?>
296
+ cyclic: true,
297
+ centerOnScroll: true,
298
+ <?php do_action( 'envira_gallery_api_config_callback', $data ); ?>
299
+ onStart: function(data, index, opts){
300
+ $(window).on({
301
+ 'resize' : function(){
302
+ $.fancybox.resize();
303
+ $.fancybox.center();
304
+ }
305
+ });
306
+
307
+ var obj = data[index],
308
+ href = opts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;
309
+
310
+ if ((/^(?:javascript)/i).test(href) || href == '#') {
311
+ href = null;
312
+ }
313
+
314
+ if ( href && ! href.match(/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i) ) {
315
+ window.location.href = href;
316
+ return false;
317
+ }
318
+ }
319
+ });
320
+
321
+ <?php do_action( 'envira_gallery_api_lightbox', $data ); ?>
322
+ <?php do_action( 'envira_gallery_api_end', $data ); endforeach;
323
+
324
+ // Minify before outputting to improve page load time.
325
+ do_action( 'envira_gallery_api_end_global' );
326
+ echo $this->minify( ob_get_clean() ); ?>});</script>
327
+ <?php
328
+
329
+ }
330
+
331
+ /**
332
+ * Helper method for adding custom gallery classes.
333
+ *
334
+ * @since 1.0.0
335
+ *
336
+ * @param array $data The gallery data to use for retrieval.
337
+ * @return string String of space separated gallery classes.
338
+ */
339
+ public function get_gallery_classes( $data ) {
340
+
341
+ // Set default class.
342
+ $classes = array();
343
+ $classes[] = 'envira-gallery-wrap';
344
+
345
+ // Add custom class based on data provided.
346
+ $classes[] = 'envira-gallery-theme-' . $this->get_config( 'gallery_theme', $data );
347
+ $classes[] = 'envira-lightbox-theme-' . $this->get_config( 'lightbox_theme', $data );
348
+
349
+ // If we have custom classes defined for this gallery, output them now.
350
+ foreach ( (array) $this->get_config( 'classes', $data ) as $class ) {
351
+ $classes[] = $class;
352
+ }
353
+
354
+ // Allow filtering of classes and then return what's left.
355
+ $classes = apply_filters( 'envira_gallery_output_classes', $classes, $data );
356
+ return trim( implode( ' ', array_map( 'trim', array_map( 'sanitize_html_class', array_unique( $classes ) ) ) ) );
357
+
358
+ }
359
+
360
+ /**
361
+ * Helper method for adding custom gallery classes.
362
+ *
363
+ * @since 1.0.4
364
+ *
365
+ * @param array $item Array of item data.
366
+ * @param int $i The current position in the gallery.
367
+ * @param array $data The gallery data to use for retrieval.
368
+ * @return string String of space separated gallery item classes.
369
+ */
370
+ public function get_gallery_item_classes( $item, $i, $data ) {
371
+
372
+ // Set default class.
373
+ $classes = array();
374
+ $classes[] = 'envira-gallery-item';
375
+ $classes[] = 'isotope-item';
376
+ $classes[] = 'envira-gallery-item-' . $i;
377
+
378
+ // Allow filtering of classes and then return what's left.
379
+ $classes = apply_filters( 'envira_gallery_output_item_classes', $classes, $item, $i, $data );
380
+ return trim( implode( ' ', array_map( 'trim', array_map( 'sanitize_html_class', array_unique( $classes ) ) ) ) );
381
+
382
+ }
383
+
384
+ /**
385
+ * Helper method to retrieve the proper image src attribute based on gallery settings.
386
+ *
387
+ * @since 1.0.0
388
+ *
389
+ * @param int $id The image attachment ID to use.
390
+ * @param array $item Gallery item data.
391
+ * @param array $data The gallery data to use for retrieval.
392
+ * @param bool $mobile Whether or not to retrieve the mobile image.
393
+ * @return string The proper image src attribute for the image.
394
+ */
395
+ public function get_image_src( $id, $item, $data, $mobile = false ) {
396
+
397
+ // Get the full image src. If it does not return the data we need, return the image link instead.
398
+ $src = wp_get_attachment_image_src( $id, 'full' );
399
+ $image = ! empty( $src[0] ) ? $src[0] : false;
400
+ if ( ! $image ) {
401
+ $image = ! empty( $item['src'] ) ? $item['src'] : false;
402
+ if ( ! $image ) {
403
+ return apply_filters( 'envira_gallery_no_image_src', $item['link'], $id, $item, $data );
404
+ }
405
+ }
406
+
407
+ // Generate the cropped image if necessary.
408
+ $type = $mobile ? 'mobile' : 'crop';
409
+ if ( isset( $data['config'][$type] ) && $data['config'][$type] ) {
410
+ $common = Envira_Gallery_Common_Lite::get_instance();
411
+ $args = apply_filters( 'envira_gallery_crop_image_args',
412
+ array(
413
+ 'position' => 'c',
414
+ 'width' => $this->get_config( $type . '_width', $data ),
415
+ 'height' => $this->get_config( $type . '_height', $data ),
416
+ 'quality' => 100,
417
+ 'retina' => false
418
+ )
419
+ );
420
+ $cropped_image = $common->resize_image( $image, $args['width'], $args['height'], true, $args['position'], $args['quality'], $args['retina'] );
421
+
422
+ // If there is an error, possibly output error message and return the default image src.
423
+ if ( is_wp_error( $cropped_image ) ) {
424
+ // If debugging is defined, print out the error.
425
+ if ( defined( 'ENVIRA_GALLERY_CROP_DEBUG' ) && ENVIRA_GALLERY_CROP_DEBUG ) {
426
+ echo '<pre>' . var_export( $cropped_image->get_error_message(), true ) . '</pre>';
427
+ }
428
+
429
+ // Return the non-cropped image as a fallback.
430
+ return apply_filters( 'envira_gallery_image_src', $image, $id, $item, $data );
431
+ } else {
432
+ return apply_filters( 'envira_gallery_image_src', $cropped_image, $id, $item, $data );
433
+ }
434
+ } else {
435
+ return apply_filters( 'envira_gallery_image_src', $image, $id, $item, $data );
436
+ }
437
+
438
+ }
439
+
440
+ /**
441
+ * Helper method for retrieving config values.
442
+ *
443
+ * @since 1.0.0
444
+ *
445
+ * @param string $key The config key to retrieve.
446
+ * @param array $data The gallery data to use for retrieval.
447
+ * @return string Key value on success, default if not set.
448
+ */
449
+ public function get_config( $key, $data ) {
450
+
451
+ $instance = Envira_Gallery_Common_Lite::get_instance();
452
+ return isset( $data['config'][$key] ) ? $data['config'][$key] : $instance->get_config_default( $key );
453
+
454
+ }
455
+
456
+ /**
457
+ * Helper method to minify a string of data.
458
+ *
459
+ * @since 1.0.4
460
+ *
461
+ * @param string $string String of data to minify.
462
+ * @return string $string Minified string of data.
463
+ */
464
+ public function minify( $string ) {
465
+
466
+ $clean = preg_replace( '/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/', '', $string );
467
+ $clean = str_replace( array( "\r\n", "\r", "\t", "\n", ' ', ' ', ' ' ), '', $clean );
468
+ return apply_filters( 'envira_gallery_minified_string', $clean, $string );
469
+
470
+ }
471
+
472
+ /**
473
+ * I'm sure some plugins mean well, but they go a bit too far trying to reduce
474
+ * conflicts without thinking of the consequences.
475
+ *
476
+ * 1. Prevents Foobox from completely borking Fancybox as if Foobox rules the world.
477
+ *
478
+ * @since 1.0.0
479
+ */
480
+ public function plugin_humility() {
481
+
482
+ if ( class_exists( 'fooboxV2' ) ) {
483
+ remove_action( 'wp_footer', array( $GLOBALS['foobox'], 'disable_other_lightboxes' ), 200 );
484
+ }
485
+
486
+ }
487
+
488
+ /**
489
+ * Outputs only the first image of the gallery inside a regular <div> tag
490
+ * to avoid styling issues with feeds.
491
+ *
492
+ * @since 1.0.5
493
+ *
494
+ * @param array $data Array of gallery data.
495
+ * @return string $gallery Custom gallery output for feeds.
496
+ */
497
+ public function do_feed_output( $data ) {
498
+
499
+ $gallery = '<div class="envira-gallery-feed-output">';
500
+ foreach ( $data['gallery'] as $id => $item ) {
501
+ // Skip over images that are pending (ignore if in Preview mode).
502
+ if ( isset( $item['status'] ) && 'pending' == $item['status'] && ! is_preview() ) {
503
+ continue;
504
+ }
505
+
506
+ $imagesrc = $this->get_image_src( $id, $item, $data );
507
+ $gallery .= '<img class="envira-gallery-feed-image" src="' . esc_url( $imagesrc ) . '" title="' . trim( esc_html( $item['title'] ) ) . '" alt="' .trim( esc_html( $item['alt'] ) ) . '" />';
508
+ break;
509
+ }
510
+ $gallery .= '</div>';
511
+
512
+ return apply_filters( 'envira_gallery_feed_output', $gallery, $data );
513
+
514
+ }
515
+
516
+ /**
517
+ * Returns the singleton instance of the class.
518
+ *
519
+ * @since 1.0.0
520
+ *
521
+ * @return object The Envira_Gallery_Shortcode_Lite object.
522
+ */
523
+ public static function get_instance() {
524
+
525
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Gallery_Shortcode_Lite ) ) {
526
+ self::$instance = new Envira_Gallery_Shortcode_Lite();
527
+ }
528
+
529
+ return self::$instance;
530
+
531
+ }
532
+
533
+ }
534
+
535
+ // Load the shortcode class.
536
+ $envira_gallery_shortcode_lite = Envira_Gallery_Shortcode_Lite::get_instance();
readme.txt ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Responsive WordPress Gallery - Envira Gallery Lite ===
2
+ Contributors: griffinjt
3
+ Tags: wordpress gallery, gallery, wordpress gallery plugin, gallery plugin, responsive, responsive gallery, image gallery, image gallery plugin, responsive gallery plugin, responsive image gallery, responsive image gallery plugin, custom post types, slideshow, responsive slideshow, slideshow plugin, responsive slideshow plugin, rotator, image rotator, responsive rotator, jquery gallery, javascript gallery, jquery rotator, javascript rotator, picture gallery, photo gallery, photo rotator, shortcode, template tag, custom post type, media uploader, ajax, wordpress galleries, responsive galleries, fullscreen, deeplinking, best wordpress gallery, best wordpress gallery plugin, best gallery plugin
4
+ Requires at least: 3.8
5
+ Tested up to: 3.9
6
+ Stable tag: trunk
7
+ License: GNU General Public License v2.0 or later
8
+
9
+ The best responsive WordPress gallery plugin. Made lite and free.
10
+
11
+ == Description ==
12
+
13
+ Envira Gallery, the <a href="http://enviragallery.com/?utm_source=orgrepo&utm_medium=link&utm_campaign=WordPress" rel="friend" title="Envira Gallery - The Best Responsive WordPress Gallery Plugin">best responsive WordPress gallery plugin</a>, is now available in its Lite form! Envira Gallery is the absolute easiest, fastest and most efficient gallery plugin for WordPress. Creating galleries is intuitive using all native WordPress features, and your galleries are responsive right out of the box. You can create global and post dependent responsive WordPress galleries that can be exported and imported anywhere. This plugin is insanely fast, and unlike some other popular gallery plugins, Envira Gallery is built with an incredibly slim but powerful codebase that is optimized for performance. All of your gallery queries using SMART caching and query technology to allow you to showcase your content with worrying about speed.
14
+
15
+ **Note: This is the lite version of the Envira Gallery WordPress gallery plugin. Want even more WordPress gallery features, including _unlimited_ galleries, widgets and access to all gallery features? <a href="http://enviragallery.com/?utm_source=orgrepo&utm_medium=link&utm_campaign=WordPress" rel="friend" title="Click here to purchase the best responsive WordPress gallery plugin now!">Click here to purchase the best responsive WordPress gallery plugin now!</a>**
16
+
17
+ = Features =
18
+
19
+ * Create galleries right within your posts or pages, or create "global" galleries to be used anywhere.
20
+ * Responsive right out of the box, from gallery display to lightbox views.
21
+ * Ridiculously fast queries and caching everywhere. From the admin to the frontend, Envira Gallery is incredibly lightweight without sacrificing features.
22
+ * Dynamic asynchronous ajax preloading of images for _insanely fast gallery load times._
23
+ * Simplified gallery workflows to make creating, modifying and using your galleries easier than ever before.
24
+ * Modular so that you can start small and grow with Addons as you need.
25
+
26
+ Beyond the features mentioned above, there are plenty of other **WordPress gallery features** inside of the plugin that make it an indispensable part of your gallery collection. You gain the benefit of an intuitive user interface that makes gallery management easy, simple to understand gallery options, powerful and efficient gallery queries and a plethora of hooks and filters to **manipulate the gallery output.**
27
+
28
+ _It's hard to go wrong by choosing <a href="http://enviragallery.com/?utm_source=orgrepo&utm_medium=link&utm_campaign=WordPress" rel="friend" title="Envira Gallery">Envira Gallery</a> as your all-in-one **WordPress gallery plugin** solution!_
29
+
30
+ == Installation ==
31
+
32
+ 1. Install Envira Gallery Lite either via the WordPress.org plugin repository, or by uploading the files to your server.
33
+ 2. Activate Envira Gallery Lite.
34
+ 3. Navigate to the Envira Gallery tab at the bottom of your admin menu and click "Add New" to begin creating your new WordPress gallery, or you can create a new gallery directly inside the post/page/custom post type of your choice.
35
+ 4. Salivate for new features and <a href="http://enviragallery.com/?utm_source=orgrepo&utm_medium=link&utm_campaign=WordPress" rel="friend" title="Envira Gallery">purchase the full version of Envira Gallery</a>!
36
+
37
+ == Screenshots ==
38
+
39
+ 1. Envira Gallery post type overview screen.
40
+ 2. Modal box to select images from your Media Library.
41
+ 3. Overlay helper with shortcode and template tag information.
42
+ 4. Media modal for inserting a gallery into your WYSIWYG editor.
43
+ 5. Gallery display on the front-end with 2 columns.
44
+ 6. Lightbox view of the gallery.
45
+
46
+ == Frequently Asked Questions ==
47
+
48
+ = I'd like access to more features. How can I get them? =
49
+
50
+ You can get access to more features, Addons and support by <a href="http://enviragallery.com/?utm_source=orgrepo&utm_medium=link&utm_campaign=WordPress" rel="friend" title="Click here to learn more about Envira Gallery!">visiting the Envira Gallery website and purchasing a support license</a>. Purchasing a support license gets you access to the full version of Envira Gallery, automatic updates and support, and depending on the level of support license, you can even get exclusive access to Envira Gallery Addons!
51
+
52
+ == Notes ==
53
+
54
+ Envira Gallery is absolutely, positively the <a href="http://enviragallery.com/?utm_source=orgrepo&utm_medium=link&utm_campaign=WordPress" rel="friend" title="Click here to purchase the best responsive WordPress gallery plugin now!">best responsive WordPress gallery plugin</a> on the market. It is fast, flexible and allows you to create insanely powerful responsive WordPress galleries with half of the effort. Envira Gallery gets out of your way so you can showcase your content in beautiful and powerful ways.
55
+
56
+ == Changelog ==
57
+
58
+ = 1.0.9 =
59
+ * Fixed JS error issues with WordPress 3.9.
60
+ * Added ability to link to external URLs in images.
61
+ * Other miscellaneous bug fixes and improvements.
62
+
63
+ = 1.0.8.1 =
64
+ * Fixed fatal error with calling wrong class name.
65
+
66
+ = 1.0.8 =
67
+ * Fixed bug where URLs would not switch over if migrating to a new site.
68
+ * Fixed bug with image uploader and WordPress 3.9.
69
+ * Fixed bug with Quicktags duplicating for image uploaded with the drag-and-drop uploader.
70
+
71
+ = 1.0.7 =
72
+ * Don’t crop images where the original and destination dimensions match.
73
+ * Ensure to restrain thumbnail views.
74
+
75
+ = 1.0.6.1 =
76
+ * Ensure post form is available before setting post hash.
77
+
78
+ = 1.0.6 =
79
+ * Added hash support for settings tabs.
80
+
81
+ = 1.0.5 =
82
+ * Fixed undefined index notice with media max_upload_size variable.
83
+
84
+ = 1.0.4 =
85
+ * No more gallery limit restrictions. You can now create as many galleries as you want.
86
+ * Features not accessible in Lite version are now removed from display.
87
+ * Fixed bug with gallery not resizing properly on window resize.
88
+ * Updated the uploader script to reduce outside conflicts.
89
+ * Better style support for the gallery display.
90
+ * Numerous other bug fixes and improvements.
91
+
92
+ = 1.0.3.1 =
93
+ * Flush gallery caches when interacting with meta.
94
+ * Fixed Isotope init on resize.
95
+ * Added Isotope config hooks.
96
+ * Added constant ENVIRA_FORCE_ACTIVATION that, when defined, allows you to load Envira on WordPress installs less than 3.8 (no guarantees of everything working properly).
97
+ * Fixed improper mobile loading.
98
+
99
+ = 1.0.3 =
100
+ * Fixed performance leak with Isotope. Galleries should load much faster now!
101
+
102
+ = 1.0.2.1 =
103
+ * Added ability to pass args in template tag.
104
+
105
+ = 1.0.2 =
106
+ * Fixed bug with cropped images not loading properly.
107
+ * Added hook for cache flush utility method.
108
+
109
+ = 1.0.1 =
110
+ * Fixed bug with preloading a bunch of images and the gallery display not resorting properly.
111
+
112
+ = 1.0.0 =
113
+ * Initial release.