Slide Anything – Responsive Content / HTML Slider and Carousel - Version 2.4.6

Version Description

  • Removed the 'Slider Preview' feature as it was causing issues on some installations of WordPress.
Download this release

Release Info

Developer simonpedge
Plugin Icon 128x128 Slide Anything – Responsive Content / HTML Slider and Carousel
Version 2.4.6
Comparing to
See all releases

Code changes from version 2.4.5 to 2.4.6

css/slide-anything-admin.css CHANGED
@@ -1611,6 +1611,15 @@ input.sa_slide_popup_imagetitle:-ms-input-placeholder { color:#c0c0c0 !important
1611
  .ui-dialog[aria-describedby='sa_dialog_box'] #sa_dialog_box {
1612
  padding:15px 10px 10px !important;
1613
  }
 
 
 
 
 
 
 
 
 
1614
 
1615
  /* ### JQUERY UI - PREVIEW SLIDER DIALOG BOX ### */
1616
  #sa_preview_box {
1611
  .ui-dialog[aria-describedby='sa_dialog_box'] #sa_dialog_box {
1612
  padding:15px 10px 10px !important;
1613
  }
1614
+ .ui-dialog[aria-describedby='sa_dialog_box'] .ui-dialog-titlebar button {
1615
+ color:transparent;
1616
+ border-width:1px;
1617
+ padding:5px;
1618
+ }
1619
+ .ui-dialog[aria-describedby='sa_dialog_box'] .ui-dialog-buttonset button {
1620
+ border-width:1px;
1621
+ padding:5px;
1622
+ }
1623
 
1624
  /* ### JQUERY UI - PREVIEW SLIDER DIALOG BOX ### */
1625
  #sa_preview_box {
lightgallery/lightgallery.umd.js DELETED
@@ -1,2733 +0,0 @@
1
- /*!
2
- * lightgallery | 2.5.0 | June 13th 2022
3
- * http://www.lightgalleryjs.com/
4
- * Copyright (c) 2020 Sachin Neravath;
5
- * @license GPLv3
6
- */
7
-
8
- (function (global, factory) {
9
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
10
- typeof define === 'function' && define.amd ? define(factory) :
11
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lightGallery = factory());
12
- }(this, (function () { 'use strict';
13
-
14
- /*! *****************************************************************************
15
- Copyright (c) Microsoft Corporation.
16
-
17
- Permission to use, copy, modify, and/or distribute this software for any
18
- purpose with or without fee is hereby granted.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
- PERFORMANCE OF THIS SOFTWARE.
27
- ***************************************************************************** */
28
-
29
- var __assign = function() {
30
- __assign = Object.assign || function __assign(t) {
31
- for (var s, i = 1, n = arguments.length; i < n; i++) {
32
- s = arguments[i];
33
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34
- }
35
- return t;
36
- };
37
- return __assign.apply(this, arguments);
38
- };
39
-
40
- function __spreadArrays() {
41
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
42
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
43
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
44
- r[k] = a[j];
45
- return r;
46
- }
47
-
48
- /**
49
- * List of lightGallery events
50
- * All events should be documented here
51
- * Below interfaces are used to build the website documentations
52
- * */
53
- var lGEvents = {
54
- afterAppendSlide: 'lgAfterAppendSlide',
55
- init: 'lgInit',
56
- hasVideo: 'lgHasVideo',
57
- containerResize: 'lgContainerResize',
58
- updateSlides: 'lgUpdateSlides',
59
- afterAppendSubHtml: 'lgAfterAppendSubHtml',
60
- beforeOpen: 'lgBeforeOpen',
61
- afterOpen: 'lgAfterOpen',
62
- slideItemLoad: 'lgSlideItemLoad',
63
- beforeSlide: 'lgBeforeSlide',
64
- afterSlide: 'lgAfterSlide',
65
- posterClick: 'lgPosterClick',
66
- dragStart: 'lgDragStart',
67
- dragMove: 'lgDragMove',
68
- dragEnd: 'lgDragEnd',
69
- beforeNextSlide: 'lgBeforeNextSlide',
70
- beforePrevSlide: 'lgBeforePrevSlide',
71
- beforeClose: 'lgBeforeClose',
72
- afterClose: 'lgAfterClose',
73
- rotateLeft: 'lgRotateLeft',
74
- rotateRight: 'lgRotateRight',
75
- flipHorizontal: 'lgFlipHorizontal',
76
- flipVertical: 'lgFlipVertical',
77
- autoplay: 'lgAutoplay',
78
- autoplayStart: 'lgAutoplayStart',
79
- autoplayStop: 'lgAutoplayStop',
80
- };
81
-
82
- var lightGalleryCoreSettings = {
83
- mode: 'lg-slide',
84
- easing: 'ease',
85
- speed: 400,
86
- licenseKey: '0000-0000-000-0000',
87
- height: '100%',
88
- width: '100%',
89
- addClass: '',
90
- startClass: 'lg-start-zoom',
91
- backdropDuration: 300,
92
- container: '',
93
- startAnimationDuration: 400,
94
- zoomFromOrigin: true,
95
- hideBarsDelay: 0,
96
- showBarsAfter: 10000,
97
- slideDelay: 0,
98
- supportLegacyBrowser: true,
99
- allowMediaOverlap: false,
100
- videoMaxSize: '1280-720',
101
- loadYouTubePoster: true,
102
- defaultCaptionHeight: 0,
103
- ariaLabelledby: '',
104
- ariaDescribedby: '',
105
- resetScrollPosition: true,
106
- hideScrollbar: false,
107
- closable: true,
108
- swipeToClose: true,
109
- closeOnTap: true,
110
- showCloseIcon: true,
111
- showMaximizeIcon: false,
112
- loop: true,
113
- escKey: true,
114
- keyPress: true,
115
- trapFocus: true,
116
- controls: true,
117
- slideEndAnimation: true,
118
- hideControlOnEnd: false,
119
- mousewheel: false,
120
- getCaptionFromTitleOrAlt: true,
121
- appendSubHtmlTo: '.lg-sub-html',
122
- subHtmlSelectorRelative: false,
123
- preload: 2,
124
- numberOfSlideItemsInDom: 10,
125
- selector: '',
126
- selectWithin: '',
127
- nextHtml: '',
128
- prevHtml: '',
129
- index: 0,
130
- iframeWidth: '100%',
131
- iframeHeight: '100%',
132
- iframeMaxWidth: '100%',
133
- iframeMaxHeight: '100%',
134
- download: true,
135
- counter: true,
136
- appendCounterTo: '.lg-toolbar',
137
- swipeThreshold: 50,
138
- enableSwipe: true,
139
- enableDrag: true,
140
- dynamic: false,
141
- dynamicEl: [],
142
- extraProps: [],
143
- exThumbImage: '',
144
- isMobile: undefined,
145
- mobileSettings: {
146
- controls: false,
147
- showCloseIcon: false,
148
- download: false,
149
- },
150
- plugins: [],
151
- strings: {
152
- closeGallery: 'Close gallery',
153
- toggleMaximize: 'Toggle maximize',
154
- previousSlide: 'Previous slide',
155
- nextSlide: 'Next slide',
156
- download: 'Download',
157
- playVideo: 'Play video',
158
- },
159
- };
160
-
161
- function initLgPolyfills() {
162
- (function () {
163
- if (typeof window.CustomEvent === 'function')
164
- return false;
165
- function CustomEvent(event, params) {
166
- params = params || {
167
- bubbles: false,
168
- cancelable: false,
169
- detail: null,
170
- };
171
- var evt = document.createEvent('CustomEvent');
172
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
173
- return evt;
174
- }
175
- window.CustomEvent = CustomEvent;
176
- })();
177
- (function () {
178
- if (!Element.prototype.matches) {
179
- Element.prototype.matches =
180
- Element.prototype.msMatchesSelector ||
181
- Element.prototype.webkitMatchesSelector;
182
- }
183
- })();
184
- }
185
- var lgQuery = /** @class */ (function () {
186
- function lgQuery(selector) {
187
- this.cssVenderPrefixes = [
188
- 'TransitionDuration',
189
- 'TransitionTimingFunction',
190
- 'Transform',
191
- 'Transition',
192
- ];
193
- this.selector = this._getSelector(selector);
194
- this.firstElement = this._getFirstEl();
195
- return this;
196
- }
197
- lgQuery.generateUUID = function () {
198
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
199
- var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
200
- return v.toString(16);
201
- });
202
- };
203
- lgQuery.prototype._getSelector = function (selector, context) {
204
- if (context === void 0) { context = document; }
205
- if (typeof selector !== 'string') {
206
- return selector;
207
- }
208
- context = context || document;
209
- var fl = selector.substring(0, 1);
210
- if (fl === '#') {
211
- return context.querySelector(selector);
212
- }
213
- else {
214
- return context.querySelectorAll(selector);
215
- }
216
- };
217
- lgQuery.prototype._each = function (func) {
218
- if (!this.selector) {
219
- return this;
220
- }
221
- if (this.selector.length !== undefined) {
222
- [].forEach.call(this.selector, func);
223
- }
224
- else {
225
- func(this.selector, 0);
226
- }
227
- return this;
228
- };
229
- lgQuery.prototype._setCssVendorPrefix = function (el, cssProperty, value) {
230
- // prettier-ignore
231
- var property = cssProperty.replace(/-([a-z])/gi, function (s, group1) {
232
- return group1.toUpperCase();
233
- });
234
- if (this.cssVenderPrefixes.indexOf(property) !== -1) {
235
- el.style[property.charAt(0).toLowerCase() + property.slice(1)] = value;
236
- el.style['webkit' + property] = value;
237
- el.style['moz' + property] = value;
238
- el.style['ms' + property] = value;
239
- el.style['o' + property] = value;
240
- }
241
- else {
242
- el.style[property] = value;
243
- }
244
- };
245
- lgQuery.prototype._getFirstEl = function () {
246
- if (this.selector && this.selector.length !== undefined) {
247
- return this.selector[0];
248
- }
249
- else {
250
- return this.selector;
251
- }
252
- };
253
- lgQuery.prototype.isEventMatched = function (event, eventName) {
254
- var eventNamespace = eventName.split('.');
255
- return event
256
- .split('.')
257
- .filter(function (e) { return e; })
258
- .every(function (e) {
259
- return eventNamespace.indexOf(e) !== -1;
260
- });
261
- };
262
- lgQuery.prototype.attr = function (attr, value) {
263
- if (value === undefined) {
264
- if (!this.firstElement) {
265
- return '';
266
- }
267
- return this.firstElement.getAttribute(attr);
268
- }
269
- this._each(function (el) {
270
- el.setAttribute(attr, value);
271
- });
272
- return this;
273
- };
274
- lgQuery.prototype.find = function (selector) {
275
- return $LG(this._getSelector(selector, this.selector));
276
- };
277
- lgQuery.prototype.first = function () {
278
- if (this.selector && this.selector.length !== undefined) {
279
- return $LG(this.selector[0]);
280
- }
281
- else {
282
- return $LG(this.selector);
283
- }
284
- };
285
- lgQuery.prototype.eq = function (index) {
286
- return $LG(this.selector[index]);
287
- };
288
- lgQuery.prototype.parent = function () {
289
- return $LG(this.selector.parentElement);
290
- };
291
- lgQuery.prototype.get = function () {
292
- return this._getFirstEl();
293
- };
294
- lgQuery.prototype.removeAttr = function (attributes) {
295
- var attrs = attributes.split(' ');
296
- this._each(function (el) {
297
- attrs.forEach(function (attr) { return el.removeAttribute(attr); });
298
- });
299
- return this;
300
- };
301
- lgQuery.prototype.wrap = function (className) {
302
- if (!this.firstElement) {
303
- return this;
304
- }
305
- var wrapper = document.createElement('div');
306
- wrapper.className = className;
307
- this.firstElement.parentNode.insertBefore(wrapper, this.firstElement);
308
- this.firstElement.parentNode.removeChild(this.firstElement);
309
- wrapper.appendChild(this.firstElement);
310
- return this;
311
- };
312
- lgQuery.prototype.addClass = function (classNames) {
313
- if (classNames === void 0) { classNames = ''; }
314
- this._each(function (el) {
315
- // IE doesn't support multiple arguments
316
- classNames.split(' ').forEach(function (className) {
317
- if (className) {
318
- el.classList.add(className);
319
- }
320
- });
321
- });
322
- return this;
323
- };
324
- lgQuery.prototype.removeClass = function (classNames) {
325
- this._each(function (el) {
326
- // IE doesn't support multiple arguments
327
- classNames.split(' ').forEach(function (className) {
328
- if (className) {
329
- el.classList.remove(className);
330
- }
331
- });
332
- });
333
- return this;
334
- };
335
- lgQuery.prototype.hasClass = function (className) {
336
- if (!this.firstElement) {
337
- return false;
338
- }
339
- return this.firstElement.classList.contains(className);
340
- };
341
- lgQuery.prototype.hasAttribute = function (attribute) {
342
- if (!this.firstElement) {
343
- return false;
344
- }
345
- return this.firstElement.hasAttribute(attribute);
346
- };
347
- lgQuery.prototype.toggleClass = function (className) {
348
- if (!this.firstElement) {
349
- return this;
350
- }
351
- if (this.hasClass(className)) {
352
- this.removeClass(className);
353
- }
354
- else {
355
- this.addClass(className);
356
- }
357
- return this;
358
- };
359
- lgQuery.prototype.css = function (property, value) {
360
- var _this = this;
361
- this._each(function (el) {
362
- _this._setCssVendorPrefix(el, property, value);
363
- });
364
- return this;
365
- };
366
- // Need to pass separate namespaces for separate elements
367
- lgQuery.prototype.on = function (events, listener) {
368
- var _this = this;
369
- if (!this.selector) {
370
- return this;
371
- }
372
- events.split(' ').forEach(function (event) {
373
- if (!Array.isArray(lgQuery.eventListeners[event])) {
374
- lgQuery.eventListeners[event] = [];
375
- }
376
- lgQuery.eventListeners[event].push(listener);
377
- _this.selector.addEventListener(event.split('.')[0], listener);
378
- });
379
- return this;
380
- };
381
- // @todo - test this
382
- lgQuery.prototype.once = function (event, listener) {
383
- var _this = this;
384
- this.on(event, function () {
385
- _this.off(event);
386
- listener(event);
387
- });
388
- return this;
389
- };
390
- lgQuery.prototype.off = function (event) {
391
- var _this = this;
392
- if (!this.selector) {
393
- return this;
394
- }
395
- Object.keys(lgQuery.eventListeners).forEach(function (eventName) {
396
- if (_this.isEventMatched(event, eventName)) {
397
- lgQuery.eventListeners[eventName].forEach(function (listener) {
398
- _this.selector.removeEventListener(eventName.split('.')[0], listener);
399
- });
400
- lgQuery.eventListeners[eventName] = [];
401
- }
402
- });
403
- return this;
404
- };
405
- lgQuery.prototype.trigger = function (event, detail) {
406
- if (!this.firstElement) {
407
- return this;
408
- }
409
- var customEvent = new CustomEvent(event.split('.')[0], {
410
- detail: detail || null,
411
- });
412
- this.firstElement.dispatchEvent(customEvent);
413
- return this;
414
- };
415
- // Does not support IE
416
- lgQuery.prototype.load = function (url) {
417
- var _this = this;
418
- fetch(url)
419
- .then(function (res) { return res.text(); })
420
- .then(function (html) {
421
- _this.selector.innerHTML = html;
422
- });
423
- return this;
424
- };
425
- lgQuery.prototype.html = function (html) {
426
- if (html === undefined) {
427
- if (!this.firstElement) {
428
- return '';
429
- }
430
- return this.firstElement.innerHTML;
431
- }
432
- this._each(function (el) {
433
- el.innerHTML = html;
434
- });
435
- return this;
436
- };
437
- lgQuery.prototype.append = function (html) {
438
- this._each(function (el) {
439
- if (typeof html === 'string') {
440
- el.insertAdjacentHTML('beforeend', html);
441
- }
442
- else {
443
- el.appendChild(html);
444
- }
445
- });
446
- return this;
447
- };
448
- lgQuery.prototype.prepend = function (html) {
449
- this._each(function (el) {
450
- el.insertAdjacentHTML('afterbegin', html);
451
- });
452
- return this;
453
- };
454
- lgQuery.prototype.remove = function () {
455
- this._each(function (el) {
456
- el.parentNode.removeChild(el);
457
- });
458
- return this;
459
- };
460
- lgQuery.prototype.empty = function () {
461
- this._each(function (el) {
462
- el.innerHTML = '';
463
- });
464
- return this;
465
- };
466
- lgQuery.prototype.scrollTop = function (scrollTop) {
467
- if (scrollTop !== undefined) {
468
- document.body.scrollTop = scrollTop;
469
- document.documentElement.scrollTop = scrollTop;
470
- return this;
471
- }
472
- else {
473
- return (window.pageYOffset ||
474
- document.documentElement.scrollTop ||
475
- document.body.scrollTop ||
476
- 0);
477
- }
478
- };
479
- lgQuery.prototype.scrollLeft = function (scrollLeft) {
480
- if (scrollLeft !== undefined) {
481
- document.body.scrollLeft = scrollLeft;
482
- document.documentElement.scrollLeft = scrollLeft;
483
- return this;
484
- }
485
- else {
486
- return (window.pageXOffset ||
487
- document.documentElement.scrollLeft ||
488
- document.body.scrollLeft ||
489
- 0);
490
- }
491
- };
492
- lgQuery.prototype.offset = function () {
493
- if (!this.firstElement) {
494
- return {
495
- left: 0,
496
- top: 0,
497
- };
498
- }
499
- var rect = this.firstElement.getBoundingClientRect();
500
- var bodyMarginLeft = $LG('body').style().marginLeft;
501
- // Minus body margin - https://stackoverflow.com/questions/30711548/is-getboundingclientrect-left-returning-a-wrong-value
502
- return {
503
- left: rect.left - parseFloat(bodyMarginLeft) + this.scrollLeft(),
504
- top: rect.top + this.scrollTop(),
505
- };
506
- };
507
- lgQuery.prototype.style = function () {
508
- if (!this.firstElement) {
509
- return {};
510
- }
511
- return (this.firstElement.currentStyle ||
512
- window.getComputedStyle(this.firstElement));
513
- };
514
- // Width without padding and border even if box-sizing is used.
515
- lgQuery.prototype.width = function () {
516
- var style = this.style();
517
- return (this.firstElement.clientWidth -
518
- parseFloat(style.paddingLeft) -
519
- parseFloat(style.paddingRight));
520
- };
521
- // Height without padding and border even if box-sizing is used.
522
- lgQuery.prototype.height = function () {
523
- var style = this.style();
524
- return (this.firstElement.clientHeight -
525
- parseFloat(style.paddingTop) -
526
- parseFloat(style.paddingBottom));
527
- };
528
- lgQuery.eventListeners = {};
529
- return lgQuery;
530
- }());
531
- function $LG(selector) {
532
- initLgPolyfills();
533
- return new lgQuery(selector);
534
- }
535
-
536
- var defaultDynamicOptions = [
537
- 'src',
538
- 'sources',
539
- 'subHtml',
540
- 'subHtmlUrl',
541
- 'html',
542
- 'video',
543
- 'poster',
544
- 'slideName',
545
- 'responsive',
546
- 'srcset',
547
- 'sizes',
548
- 'iframe',
549
- 'downloadUrl',
550
- 'download',
551
- 'width',
552
- 'facebookShareUrl',
553
- 'tweetText',
554
- 'iframeTitle',
555
- 'twitterShareUrl',
556
- 'pinterestShareUrl',
557
- 'pinterestText',
558
- 'fbHtml',
559
- 'disqusIdentifier',
560
- 'disqusUrl',
561
- ];
562
- // Convert html data-attribute to camalcase
563
- function convertToData(attr) {
564
- // FInd a way for lgsize
565
- if (attr === 'href') {
566
- return 'src';
567
- }
568
- attr = attr.replace('data-', '');
569
- attr = attr.charAt(0).toLowerCase() + attr.slice(1);
570
- attr = attr.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
571
- return attr;
572
- }
573
- var utils = {
574
- /**
575
- * get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option
576
- */
577
- getSize: function (el, container, spacing, defaultLgSize) {
578
- if (spacing === void 0) { spacing = 0; }
579
- var LGel = $LG(el);
580
- var lgSize = LGel.attr('data-lg-size') || defaultLgSize;
581
- if (!lgSize) {
582
- return;
583
- }
584
- var isResponsiveSizes = lgSize.split(',');
585
- // if at-least two viewport sizes are available
586
- if (isResponsiveSizes[1]) {
587
- var wWidth = window.innerWidth;
588
- for (var i = 0; i < isResponsiveSizes.length; i++) {
589
- var size_1 = isResponsiveSizes[i];
590
- var responsiveWidth = parseInt(size_1.split('-')[2], 10);
591
- if (responsiveWidth > wWidth) {
592
- lgSize = size_1;
593
- break;
594
- }
595
- // take last item as last option
596
- if (i === isResponsiveSizes.length - 1) {
597
- lgSize = size_1;
598
- }
599
- }
600
- }
601
- var size = lgSize.split('-');
602
- var width = parseInt(size[0], 10);
603
- var height = parseInt(size[1], 10);
604
- var cWidth = container.width();
605
- var cHeight = container.height() - spacing;
606
- var maxWidth = Math.min(cWidth, width);
607
- var maxHeight = Math.min(cHeight, height);
608
- var ratio = Math.min(maxWidth / width, maxHeight / height);
609
- return { width: width * ratio, height: height * ratio };
610
- },
611
- /**
612
- * @desc Get transform value based on the imageSize. Used for ZoomFromOrigin option
613
- * @param {jQuery Element}
614
- * @returns {String} Transform CSS string
615
- */
616
- getTransform: function (el, container, top, bottom, imageSize) {
617
- if (!imageSize) {
618
- return;
619
- }
620
- var LGel = $LG(el).find('img').first();
621
- if (!LGel.get()) {
622
- return;
623
- }
624
- var containerRect = container.get().getBoundingClientRect();
625
- var wWidth = containerRect.width;
626
- // using innerWidth to include mobile safari bottom bar
627
- var wHeight = container.height() - (top + bottom);
628
- var elWidth = LGel.width();
629
- var elHeight = LGel.height();
630
- var elStyle = LGel.style();
631
- var x = (wWidth - elWidth) / 2 -
632
- LGel.offset().left +
633
- (parseFloat(elStyle.paddingLeft) || 0) +
634
- (parseFloat(elStyle.borderLeft) || 0) +
635
- $LG(window).scrollLeft() +
636
- containerRect.left;
637
- var y = (wHeight - elHeight) / 2 -
638
- LGel.offset().top +
639
- (parseFloat(elStyle.paddingTop) || 0) +
640
- (parseFloat(elStyle.borderTop) || 0) +
641
- $LG(window).scrollTop() +
642
- top;
643
- var scX = elWidth / imageSize.width;
644
- var scY = elHeight / imageSize.height;
645
- var transform = 'translate3d(' +
646
- (x *= -1) +
647
- 'px, ' +
648
- (y *= -1) +
649
- 'px, 0) scale3d(' +
650
- scX +
651
- ', ' +
652
- scY +
653
- ', 1)';
654
- return transform;
655
- },
656
- getIframeMarkup: function (iframeWidth, iframeHeight, iframeMaxWidth, iframeMaxHeight, src, iframeTitle) {
657
- var title = iframeTitle ? 'title="' + iframeTitle + '"' : '';
658
- return "<div class=\"lg-video-cont lg-has-iframe\" style=\"width:" + iframeWidth + "; max-width:" + iframeMaxWidth + "; height: " + iframeHeight + "; max-height:" + iframeMaxHeight + "\">\n <iframe class=\"lg-object\" frameborder=\"0\" " + title + " src=\"" + src + "\" allowfullscreen=\"true\"></iframe>\n </div>";
659
- },
660
- getImgMarkup: function (index, src, altAttr, srcset, sizes, sources) {
661
- var srcsetAttr = srcset ? "srcset=\"" + srcset + "\"" : '';
662
- var sizesAttr = sizes ? "sizes=\"" + sizes + "\"" : '';
663
- var imgMarkup = "<img " + altAttr + " " + srcsetAttr + " " + sizesAttr + " class=\"lg-object lg-image\" data-index=\"" + index + "\" src=\"" + src + "\" />";
664
- var sourceTag = '';
665
- if (sources) {
666
- var sourceObj = typeof sources === 'string' ? JSON.parse(sources) : sources;
667
- sourceTag = sourceObj.map(function (source) {
668
- var attrs = '';
669
- Object.keys(source).forEach(function (key) {
670
- // Do not remove the first space as it is required to separate the attributes
671
- attrs += " " + key + "=\"" + source[key] + "\"";
672
- });
673
- return "<source " + attrs + "></source>";
674
- });
675
- }
676
- return "" + sourceTag + imgMarkup;
677
- },
678
- // Get src from responsive src
679
- getResponsiveSrc: function (srcItms) {
680
- var rsWidth = [];
681
- var rsSrc = [];
682
- var src = '';
683
- for (var i = 0; i < srcItms.length; i++) {
684
- var _src = srcItms[i].split(' ');
685
- // Manage empty space
686
- if (_src[0] === '') {
687
- _src.splice(0, 1);
688
- }
689
- rsSrc.push(_src[0]);
690
- rsWidth.push(_src[1]);
691
- }
692
- var wWidth = window.innerWidth;
693
- for (var j = 0; j < rsWidth.length; j++) {
694
- if (parseInt(rsWidth[j], 10) > wWidth) {
695
- src = rsSrc[j];
696
- break;
697
- }
698
- }
699
- return src;
700
- },
701
- isImageLoaded: function (img) {
702
- if (!img)
703
- return false;
704
- // During the onload event, IE correctly identifies any images that
705
- // weren’t downloaded as not complete. Others should too. Gecko-based
706
- // browsers act like NS4 in that they report this incorrectly.
707
- if (!img.complete) {
708
- return false;
709
- }
710
- // However, they do have two very useful properties: naturalWidth and
711
- // naturalHeight. These give the true size of the image. If it failed
712
- // to load, either of these should be zero.
713
- if (img.naturalWidth === 0) {
714
- return false;
715
- }
716
- // No other way of checking: assume it’s ok.
717
- return true;
718
- },
719
- getVideoPosterMarkup: function (_poster, dummyImg, videoContStyle, playVideoString, _isVideo) {
720
- var videoClass = '';
721
- if (_isVideo && _isVideo.youtube) {
722
- videoClass = 'lg-has-youtube';
723
- }
724
- else if (_isVideo && _isVideo.vimeo) {
725
- videoClass = 'lg-has-vimeo';
726
- }
727
- else {
728
- videoClass = 'lg-has-html5';
729
- }
730
- return "<div class=\"lg-video-cont " + videoClass + "\" style=\"" + videoContStyle + "\">\n <div class=\"lg-video-play-button\">\n <svg\n viewBox=\"0 0 20 20\"\n preserveAspectRatio=\"xMidYMid\"\n focusable=\"false\"\n aria-labelledby=\"" + playVideoString + "\"\n role=\"img\"\n class=\"lg-video-play-icon\"\n >\n <title>" + playVideoString + "</title>\n <polygon class=\"lg-video-play-icon-inner\" points=\"1,0 20,10 1,20\"></polygon>\n </svg>\n <svg class=\"lg-video-play-icon-bg\" viewBox=\"0 0 50 50\" focusable=\"false\">\n <circle cx=\"50%\" cy=\"50%\" r=\"20\"></circle></svg>\n <svg class=\"lg-video-play-icon-circle\" viewBox=\"0 0 50 50\" focusable=\"false\">\n <circle cx=\"50%\" cy=\"50%\" r=\"20\"></circle>\n </svg>\n </div>\n " + (dummyImg || '') + "\n <img class=\"lg-object lg-video-poster\" src=\"" + _poster + "\" />\n </div>";
731
- },
732
- getFocusableElements: function (container) {
733
- var elements = container.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');
734
- var visibleElements = [].filter.call(elements, function (element) {
735
- var style = window.getComputedStyle(element);
736
- return style.display !== 'none' && style.visibility !== 'hidden';
737
- });
738
- return visibleElements;
739
- },
740
- /**
741
- * @desc Create dynamic elements array from gallery items when dynamic option is false
742
- * It helps to avoid frequent DOM interaction
743
- * and avoid multiple checks for dynamic elments
744
- *
745
- * @returns {Array} dynamicEl
746
- */
747
- getDynamicOptions: function (items, extraProps, getCaptionFromTitleOrAlt, exThumbImage) {
748
- var dynamicElements = [];
749
- var availableDynamicOptions = __spreadArrays(defaultDynamicOptions, extraProps);
750
- [].forEach.call(items, function (item) {
751
- var dynamicEl = {};
752
- for (var i = 0; i < item.attributes.length; i++) {
753
- var attr = item.attributes[i];
754
- if (attr.specified) {
755
- var dynamicAttr = convertToData(attr.name);
756
- var label = '';
757
- if (availableDynamicOptions.indexOf(dynamicAttr) > -1) {
758
- label = dynamicAttr;
759
- }
760
- if (label) {
761
- dynamicEl[label] = attr.value;
762
- }
763
- }
764
- }
765
- var currentItem = $LG(item);
766
- var alt = currentItem.find('img').first().attr('alt');
767
- var title = currentItem.attr('title');
768
- var thumb = exThumbImage
769
- ? currentItem.attr(exThumbImage)
770
- : currentItem.find('img').first().attr('src');
771
- dynamicEl.thumb = thumb;
772
- if (getCaptionFromTitleOrAlt && !dynamicEl.subHtml) {
773
- dynamicEl.subHtml = title || alt || '';
774
- }
775
- dynamicEl.alt = alt || title || '';
776
- dynamicElements.push(dynamicEl);
777
- });
778
- return dynamicElements;
779
- },
780
- isMobile: function () {
781
- return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
782
- },
783
- /**
784
- * @desc Check the given src is video
785
- * @param {String} src
786
- * @return {Object} video type
787
- * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
788
- *
789
- * @todo - this information can be moved to dynamicEl to avoid frequent calls
790
- */
791
- isVideo: function (src, isHTML5VIdeo, index) {
792
- if (!src) {
793
- if (isHTML5VIdeo) {
794
- return {
795
- html5: true,
796
- };
797
- }
798
- else {
799
- console.error('lightGallery :- data-src is not provided on slide item ' +
800
- (index + 1) +
801
- '. Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/');
802
- return;
803
- }
804
- }
805
- var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
806
- var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i);
807
- var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
808
- if (youtube) {
809
- return {
810
- youtube: youtube,
811
- };
812
- }
813
- else if (vimeo) {
814
- return {
815
- vimeo: vimeo,
816
- };
817
- }
818
- else if (wistia) {
819
- return {
820
- wistia: wistia,
821
- };
822
- }
823
- },
824
- };
825
-
826
- // @ref - https://stackoverflow.com/questions/3971841/how-to-resize-images-proportionally-keeping-the-aspect-ratio
827
- // @ref - https://2ality.com/2017/04/setting-up-multi-platform-packages.html
828
- // Unique id for each gallery
829
- var lgId = 0;
830
- var LightGallery = /** @class */ (function () {
831
- function LightGallery(element, options) {
832
- this.lgOpened = false;
833
- this.index = 0;
834
- // lightGallery modules
835
- this.plugins = [];
836
- // false when lightGallery load first slide content;
837
- this.lGalleryOn = false;
838
- // True when a slide animation is in progress
839
- this.lgBusy = false;
840
- this.currentItemsInDom = [];
841
- // Scroll top value before lightGallery is opened
842
- this.prevScrollTop = 0;
843
- this.bodyPaddingRight = 0;
844
- this.isDummyImageRemoved = false;
845
- this.dragOrSwipeEnabled = false;
846
- this.mediaContainerPosition = {
847
- top: 0,
848
- bottom: 0,
849
- };
850
- if (!element) {
851
- return this;
852
- }
853
- lgId++;
854
- this.lgId = lgId;
855
- this.el = element;
856
- this.LGel = $LG(element);
857
- this.generateSettings(options);
858
- this.buildModules();
859
- // When using dynamic mode, ensure dynamicEl is an array
860
- if (this.settings.dynamic &&
861
- this.settings.dynamicEl !== undefined &&
862
- !Array.isArray(this.settings.dynamicEl)) {
863
- throw 'When using dynamic mode, you must also define dynamicEl as an Array.';
864
- }
865
- this.galleryItems = this.getItems();
866
- this.normalizeSettings();
867
- // Gallery items
868
- this.init();
869
- this.validateLicense();
870
- return this;
871
- }
872
- LightGallery.prototype.generateSettings = function (options) {
873
- // lightGallery settings
874
- this.settings = __assign(__assign({}, lightGalleryCoreSettings), options);
875
- if (this.settings.isMobile &&
876
- typeof this.settings.isMobile === 'function'
877
- ? this.settings.isMobile()
878
- : utils.isMobile()) {
879
- var mobileSettings = __assign(__assign({}, this.settings.mobileSettings), this.settings.mobileSettings);
880
- this.settings = __assign(__assign({}, this.settings), mobileSettings);
881
- }
882
- };
883
- LightGallery.prototype.normalizeSettings = function () {
884
- if (this.settings.slideEndAnimation) {
885
- this.settings.hideControlOnEnd = false;
886
- }
887
- if (!this.settings.closable) {
888
- this.settings.swipeToClose = false;
889
- }
890
- // And reset it on close to get the correct value next time
891
- this.zoomFromOrigin = this.settings.zoomFromOrigin;
892
- // At the moment, Zoom from image doesn't support dynamic options
893
- // @todo add zoomFromOrigin support for dynamic images
894
- if (this.settings.dynamic) {
895
- this.zoomFromOrigin = false;
896
- }
897
- if (!this.settings.container) {
898
- this.settings.container = document.body;
899
- }
900
- // settings.preload should not be grater than $item.length
901
- this.settings.preload = Math.min(this.settings.preload, this.galleryItems.length);
902
- };
903
- LightGallery.prototype.init = function () {
904
- var _this = this;
905
- this.addSlideVideoInfo(this.galleryItems);
906
- this.buildStructure();
907
- this.LGel.trigger(lGEvents.init, {
908
- instance: this,
909
- });
910
- if (this.settings.keyPress) {
911
- this.keyPress();
912
- }
913
- setTimeout(function () {
914
- _this.enableDrag();
915
- _this.enableSwipe();
916
- _this.triggerPosterClick();
917
- }, 50);
918
- this.arrow();
919
- if (this.settings.mousewheel) {
920
- this.mousewheel();
921
- }
922
- if (!this.settings.dynamic) {
923
- this.openGalleryOnItemClick();
924
- }
925
- };
926
- LightGallery.prototype.openGalleryOnItemClick = function () {
927
- var _this = this;
928
- var _loop_1 = function (index) {
929
- var element = this_1.items[index];
930
- var $element = $LG(element);
931
- // Using different namespace for click because click event should not unbind if selector is same object('this')
932
- // @todo manage all event listners - should have namespace that represent element
933
- var uuid = lgQuery.generateUUID();
934
- $element
935
- .attr('data-lg-id', uuid)
936
- .on("click.lgcustom-item-" + uuid, function (e) {
937
- e.preventDefault();
938
- var currentItemIndex = _this.settings.index || index;
939
- _this.openGallery(currentItemIndex, element);
940
- });
941
- };
942
- var this_1 = this;
943
- // Using for loop instead of using bubbling as the items can be any html element.
944
- for (var index = 0; index < this.items.length; index++) {
945
- _loop_1(index);
946
- }
947
- };
948
- /**
949
- * Module constructor
950
- * Modules are build incrementally.
951
- * Gallery should be opened only once all the modules are initialized.
952
- * use moduleBuildTimeout to make sure this
953
- */
954
- LightGallery.prototype.buildModules = function () {
955
- var _this = this;
956
- this.settings.plugins.forEach(function (plugin) {
957
- _this.plugins.push(new plugin(_this, $LG));
958
- });
959
- };
960
- LightGallery.prototype.validateLicense = function () {
961
- if (!this.settings.licenseKey) {
962
- console.error('Please provide a valid license key');
963
- }
964
- else if (this.settings.licenseKey === '0000-0000-000-0000') {
965
- console.warn("lightGallery: " + this.settings.licenseKey + " license key is not valid for production use");
966
- }
967
- };
968
- LightGallery.prototype.getSlideItem = function (index) {
969
- return $LG(this.getSlideItemId(index));
970
- };
971
- LightGallery.prototype.getSlideItemId = function (index) {
972
- return "#lg-item-" + this.lgId + "-" + index;
973
- };
974
- LightGallery.prototype.getIdName = function (id) {
975
- return id + "-" + this.lgId;
976
- };
977
- LightGallery.prototype.getElementById = function (id) {
978
- return $LG("#" + this.getIdName(id));
979
- };
980
- LightGallery.prototype.manageSingleSlideClassName = function () {
981
- if (this.galleryItems.length < 2) {
982
- this.outer.addClass('lg-single-item');
983
- }
984
- else {
985
- this.outer.removeClass('lg-single-item');
986
- }
987
- };
988
- LightGallery.prototype.buildStructure = function () {
989
- var _this = this;
990
- var container = this.$container && this.$container.get();
991
- if (container) {
992
- return;
993
- }
994
- var controls = '';
995
- var subHtmlCont = '';
996
- // Create controls
997
- if (this.settings.controls) {
998
- controls = "<button type=\"button\" id=\"" + this.getIdName('lg-prev') + "\" aria-label=\"" + this.settings.strings['previousSlide'] + "\" class=\"lg-prev lg-icon\"> " + this.settings.prevHtml + " </button>\n <button type=\"button\" id=\"" + this.getIdName('lg-next') + "\" aria-label=\"" + this.settings.strings['nextSlide'] + "\" class=\"lg-next lg-icon\"> " + this.settings.nextHtml + " </button>";
999
- }
1000
- if (this.settings.appendSubHtmlTo !== '.lg-item') {
1001
- subHtmlCont =
1002
- '<div class="lg-sub-html" role="status" aria-live="polite"></div>';
1003
- }
1004
- var addClasses = '';
1005
- if (this.settings.allowMediaOverlap) {
1006
- // Do not remove space before last single quote
1007
- addClasses += 'lg-media-overlap ';
1008
- }
1009
- var ariaLabelledby = this.settings.ariaLabelledby
1010
- ? 'aria-labelledby="' + this.settings.ariaLabelledby + '"'
1011
- : '';
1012
- var ariaDescribedby = this.settings.ariaDescribedby
1013
- ? 'aria-describedby="' + this.settings.ariaDescribedby + '"'
1014
- : '';
1015
- var containerClassName = "lg-container " + this.settings.addClass + " " + (document.body !== this.settings.container ? 'lg-inline' : '');
1016
- var closeIcon = this.settings.closable && this.settings.showCloseIcon
1017
- ? "<button type=\"button\" aria-label=\"" + this.settings.strings['closeGallery'] + "\" id=\"" + this.getIdName('lg-close') + "\" class=\"lg-close lg-icon\"></button>"
1018
- : '';
1019
- var maximizeIcon = this.settings.showMaximizeIcon
1020
- ? "<button type=\"button\" aria-label=\"" + this.settings.strings['toggleMaximize'] + "\" id=\"" + this.getIdName('lg-maximize') + "\" class=\"lg-maximize lg-icon\"></button>"
1021
- : '';
1022
- var template = "\n <div class=\"" + containerClassName + "\" id=\"" + this.getIdName('lg-container') + "\" tabindex=\"-1\" aria-modal=\"true\" " + ariaLabelledby + " " + ariaDescribedby + " role=\"dialog\"\n >\n <div id=\"" + this.getIdName('lg-backdrop') + "\" class=\"lg-backdrop\"></div>\n\n <div id=\"" + this.getIdName('lg-outer') + "\" class=\"lg-outer lg-use-css3 lg-css3 lg-hide-items " + addClasses + " \">\n\n <div id=\"" + this.getIdName('lg-content') + "\" class=\"lg-content\">\n <div id=\"" + this.getIdName('lg-inner') + "\" class=\"lg-inner\">\n </div>\n " + controls + "\n </div>\n <div id=\"" + this.getIdName('lg-toolbar') + "\" class=\"lg-toolbar lg-group\">\n " + maximizeIcon + "\n " + closeIcon + "\n </div>\n " + (this.settings.appendSubHtmlTo === '.lg-outer'
1023
- ? subHtmlCont
1024
- : '') + "\n <div id=\"" + this.getIdName('lg-components') + "\" class=\"lg-components\">\n " + (this.settings.appendSubHtmlTo === '.lg-sub-html'
1025
- ? subHtmlCont
1026
- : '') + "\n </div>\n </div>\n </div>\n ";
1027
- $LG(this.settings.container).append(template);
1028
- if (document.body !== this.settings.container) {
1029
- $LG(this.settings.container).css('position', 'relative');
1030
- }
1031
- this.outer = this.getElementById('lg-outer');
1032
- this.$lgComponents = this.getElementById('lg-components');
1033
- this.$backdrop = this.getElementById('lg-backdrop');
1034
- this.$container = this.getElementById('lg-container');
1035
- this.$inner = this.getElementById('lg-inner');
1036
- this.$content = this.getElementById('lg-content');
1037
- this.$toolbar = this.getElementById('lg-toolbar');
1038
- this.$backdrop.css('transition-duration', this.settings.backdropDuration + 'ms');
1039
- var outerClassNames = this.settings.mode + " ";
1040
- this.manageSingleSlideClassName();
1041
- if (this.settings.enableDrag) {
1042
- outerClassNames += 'lg-grab ';
1043
- }
1044
- this.outer.addClass(outerClassNames);
1045
- this.$inner.css('transition-timing-function', this.settings.easing);
1046
- this.$inner.css('transition-duration', this.settings.speed + 'ms');
1047
- if (this.settings.download) {
1048
- this.$toolbar.append("<a id=\"" + this.getIdName('lg-download') + "\" target=\"_blank\" rel=\"noopener\" aria-label=\"" + this.settings.strings['download'] + "\" download class=\"lg-download lg-icon\"></a>");
1049
- }
1050
- this.counter();
1051
- $LG(window).on("resize.lg.global" + this.lgId + " orientationchange.lg.global" + this.lgId, function () {
1052
- _this.refreshOnResize();
1053
- });
1054
- this.hideBars();
1055
- this.manageCloseGallery();
1056
- this.toggleMaximize();
1057
- this.initModules();
1058
- };
1059
- LightGallery.prototype.refreshOnResize = function () {
1060
- if (this.lgOpened) {
1061
- var currentGalleryItem = this.galleryItems[this.index];
1062
- var __slideVideoInfo = currentGalleryItem.__slideVideoInfo;
1063
- this.mediaContainerPosition = this.getMediaContainerPosition();
1064
- var _a = this.mediaContainerPosition, top_1 = _a.top, bottom = _a.bottom;
1065
- this.currentImageSize = utils.getSize(this.items[this.index], this.outer, top_1 + bottom, __slideVideoInfo && this.settings.videoMaxSize);
1066
- if (__slideVideoInfo) {
1067
- this.resizeVideoSlide(this.index, this.currentImageSize);
1068
- }
1069
- if (this.zoomFromOrigin && !this.isDummyImageRemoved) {
1070
- var imgStyle = this.getDummyImgStyles(this.currentImageSize);
1071
- this.outer
1072
- .find('.lg-current .lg-dummy-img')
1073
- .first()
1074
- .attr('style', imgStyle);
1075
- }
1076
- this.LGel.trigger(lGEvents.containerResize);
1077
- }
1078
- };
1079
- LightGallery.prototype.resizeVideoSlide = function (index, imageSize) {
1080
- var lgVideoStyle = this.getVideoContStyle(imageSize);
1081
- var currentSlide = this.getSlideItem(index);
1082
- currentSlide.find('.lg-video-cont').attr('style', lgVideoStyle);
1083
- };
1084
- /**
1085
- * Update slides dynamically.
1086
- * Add, edit or delete slides dynamically when lightGallery is opened.
1087
- * Modify the current gallery items and pass it via updateSlides method
1088
- * @note
1089
- * - Do not mutate existing lightGallery items directly.
1090
- * - Always pass new list of gallery items
1091
- * - You need to take care of thumbnails outside the gallery if any
1092
- * - user this method only if you want to update slides when the gallery is opened. Otherwise, use `refresh()` method.
1093
- * @param items Gallery items
1094
- * @param index After the update operation, which slide gallery should navigate to
1095
- * @category lGPublicMethods
1096
- * @example
1097
- * const plugin = lightGallery();
1098
- *
1099
- * // Adding slides dynamically
1100
- * let galleryItems = [
1101
- * // Access existing lightGallery items
1102
- * // galleryItems are automatically generated internally from the gallery HTML markup
1103
- * // or directly from galleryItems when dynamic gallery is used
1104
- * ...plugin.galleryItems,
1105
- * ...[
1106
- * {
1107
- * src: 'img/img-1.png',
1108
- * thumb: 'img/thumb1.png',
1109
- * },
1110
- * ],
1111
- * ];
1112
- * plugin.updateSlides(
1113
- * galleryItems,
1114
- * plugin.index,
1115
- * );
1116
- *
1117
- *
1118
- * // Remove slides dynamically
1119
- * galleryItems = JSON.parse(
1120
- * JSON.stringify(updateSlideInstance.galleryItems),
1121
- * );
1122
- * galleryItems.shift();
1123
- * updateSlideInstance.updateSlides(galleryItems, 1);
1124
- * @see <a href="/demos/update-slides/">Demo</a>
1125
- */
1126
- LightGallery.prototype.updateSlides = function (items, index) {
1127
- if (this.index > items.length - 1) {
1128
- this.index = items.length - 1;
1129
- }
1130
- if (items.length === 1) {
1131
- this.index = 0;
1132
- }
1133
- if (!items.length) {
1134
- this.closeGallery();
1135
- return;
1136
- }
1137
- var currentSrc = this.galleryItems[index].src;
1138
- this.galleryItems = items;
1139
- this.updateControls();
1140
- this.$inner.empty();
1141
- this.currentItemsInDom = [];
1142
- var _index = 0;
1143
- // Find the current index based on source value of the slide
1144
- this.galleryItems.some(function (galleryItem, itemIndex) {
1145
- if (galleryItem.src === currentSrc) {
1146
- _index = itemIndex;
1147
- return true;
1148
- }
1149
- return false;
1150
- });
1151
- this.currentItemsInDom = this.organizeSlideItems(_index, -1);
1152
- this.loadContent(_index, true);
1153
- this.getSlideItem(_index).addClass('lg-current');
1154
- this.index = _index;
1155
- this.updateCurrentCounter(_index);
1156
- this.LGel.trigger(lGEvents.updateSlides);
1157
- };
1158
- // Get gallery items based on multiple conditions
1159
- LightGallery.prototype.getItems = function () {
1160
- // Gallery items
1161
- this.items = [];
1162
- if (!this.settings.dynamic) {
1163
- if (this.settings.selector === 'this') {
1164
- this.items.push(this.el);
1165
- }
1166
- else if (this.settings.selector) {
1167
- if (typeof this.settings.selector === 'string') {
1168
- if (this.settings.selectWithin) {
1169
- var selectWithin = $LG(this.settings.selectWithin);
1170
- this.items = selectWithin
1171
- .find(this.settings.selector)
1172
- .get();
1173
- }
1174
- else {
1175
- this.items = this.el.querySelectorAll(this.settings.selector);
1176
- }
1177
- }
1178
- else {
1179
- this.items = this.settings.selector;
1180
- }
1181
- }
1182
- else {
1183
- this.items = this.el.children;
1184
- }
1185
- return utils.getDynamicOptions(this.items, this.settings.extraProps, this.settings.getCaptionFromTitleOrAlt, this.settings.exThumbImage);
1186
- }
1187
- else {
1188
- return this.settings.dynamicEl || [];
1189
- }
1190
- };
1191
- LightGallery.prototype.shouldHideScrollbar = function () {
1192
- return (this.settings.hideScrollbar &&
1193
- document.body === this.settings.container);
1194
- };
1195
- LightGallery.prototype.hideScrollbar = function () {
1196
- if (!this.shouldHideScrollbar()) {
1197
- return;
1198
- }
1199
- this.bodyPaddingRight = parseFloat($LG('body').style().paddingRight);
1200
- var bodyRect = document.documentElement.getBoundingClientRect();
1201
- var scrollbarWidth = window.innerWidth - bodyRect.width;
1202
- $LG(document.body).css('padding-right', scrollbarWidth + this.bodyPaddingRight + 'px');
1203
- $LG(document.body).addClass('lg-overlay-open');
1204
- };
1205
- LightGallery.prototype.resetScrollBar = function () {
1206
- if (!this.shouldHideScrollbar()) {
1207
- return;
1208
- }
1209
- $LG(document.body).css('padding-right', this.bodyPaddingRight + 'px');
1210
- $LG(document.body).removeClass('lg-overlay-open');
1211
- };
1212
- /**
1213
- * Open lightGallery.
1214
- * Open gallery with specific slide by passing index of the slide as parameter.
1215
- * @category lGPublicMethods
1216
- * @param {Number} index - index of the slide
1217
- * @param {HTMLElement} element - Which image lightGallery should zoom from
1218
- *
1219
- * @example
1220
- * const $dynamicGallery = document.getElementById('dynamic-gallery-demo');
1221
- * const dynamicGallery = lightGallery($dynamicGallery, {
1222
- * dynamic: true,
1223
- * dynamicEl: [
1224
- * {
1225
- * src: 'img/1.jpg',
1226
- * thumb: 'img/thumb-1.jpg',
1227
- * subHtml: '<h4>Image 1 title</h4><p>Image 1 descriptions.</p>',
1228
- * },
1229
- * ...
1230
- * ],
1231
- * });
1232
- * $dynamicGallery.addEventListener('click', function () {
1233
- * // Starts with third item.(Optional).
1234
- * // This is useful if you want use dynamic mode with
1235
- * // custom thumbnails (thumbnails outside gallery),
1236
- * dynamicGallery.openGallery(2);
1237
- * });
1238
- *
1239
- */
1240
- LightGallery.prototype.openGallery = function (index, element) {
1241
- var _this = this;
1242
- if (index === void 0) { index = this.settings.index; }
1243
- // prevent accidental double execution
1244
- if (this.lgOpened)
1245
- return;
1246
- this.lgOpened = true;
1247
- this.outer.removeClass('lg-hide-items');
1248
- this.hideScrollbar();
1249
- // Add display block, but still has opacity 0
1250
- this.$container.addClass('lg-show');
1251
- var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, index);
1252
- this.currentItemsInDom = itemsToBeInsertedToDom;
1253
- var items = '';
1254
- itemsToBeInsertedToDom.forEach(function (item) {
1255
- items = items + ("<div id=\"" + item + "\" class=\"lg-item\"></div>");
1256
- });
1257
- this.$inner.append(items);
1258
- this.addHtml(index);
1259
- var transform = '';
1260
- this.mediaContainerPosition = this.getMediaContainerPosition();
1261
- var _a = this.mediaContainerPosition, top = _a.top, bottom = _a.bottom;
1262
- if (!this.settings.allowMediaOverlap) {
1263
- this.setMediaContainerPosition(top, bottom);
1264
- }
1265
- var __slideVideoInfo = this.galleryItems[index].__slideVideoInfo;
1266
- if (this.zoomFromOrigin && element) {
1267
- this.currentImageSize = utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
1268
- transform = utils.getTransform(element, this.outer, top, bottom, this.currentImageSize);
1269
- }
1270
- if (!this.zoomFromOrigin || !transform) {
1271
- this.outer.addClass(this.settings.startClass);
1272
- this.getSlideItem(index).removeClass('lg-complete');
1273
- }
1274
- var timeout = this.settings.zoomFromOrigin
1275
- ? 100
1276
- : this.settings.backdropDuration;
1277
- setTimeout(function () {
1278
- _this.outer.addClass('lg-components-open');
1279
- }, timeout);
1280
- this.index = index;
1281
- this.LGel.trigger(lGEvents.beforeOpen);
1282
- // add class lg-current to remove initial transition
1283
- this.getSlideItem(index).addClass('lg-current');
1284
- this.lGalleryOn = false;
1285
- // Store the current scroll top value to scroll back after closing the gallery..
1286
- this.prevScrollTop = $LG(window).scrollTop();
1287
- setTimeout(function () {
1288
- // Need to check both zoomFromOrigin and transform values as we need to set set the
1289
- // default opening animation if user missed to add the lg-size attribute
1290
- if (_this.zoomFromOrigin && transform) {
1291
- var currentSlide_1 = _this.getSlideItem(index);
1292
- currentSlide_1.css('transform', transform);
1293
- setTimeout(function () {
1294
- currentSlide_1
1295
- .addClass('lg-start-progress lg-start-end-progress')
1296
- .css('transition-duration', _this.settings.startAnimationDuration + 'ms');
1297
- _this.outer.addClass('lg-zoom-from-image');
1298
- });
1299
- setTimeout(function () {
1300
- currentSlide_1.css('transform', 'translate3d(0, 0, 0)');
1301
- }, 100);
1302
- }
1303
- setTimeout(function () {
1304
- _this.$backdrop.addClass('in');
1305
- _this.$container.addClass('lg-show-in');
1306
- }, 10);
1307
- setTimeout(function () {
1308
- if (_this.settings.trapFocus &&
1309
- document.body === _this.settings.container) {
1310
- _this.trapFocus();
1311
- }
1312
- }, _this.settings.backdropDuration + 50);
1313
- // lg-visible class resets gallery opacity to 1
1314
- if (!_this.zoomFromOrigin || !transform) {
1315
- setTimeout(function () {
1316
- _this.outer.addClass('lg-visible');
1317
- }, _this.settings.backdropDuration);
1318
- }
1319
- // initiate slide function
1320
- _this.slide(index, false, false, false);
1321
- _this.LGel.trigger(lGEvents.afterOpen);
1322
- });
1323
- if (document.body === this.settings.container) {
1324
- $LG('html').addClass('lg-on');
1325
- }
1326
- };
1327
- /**
1328
- * Note - Changing the position of the media on every slide transition creates a flickering effect.
1329
- * Therefore, The height of the caption is calculated dynamically, only once based on the first slide caption.
1330
- * if you have dynamic captions for each media,
1331
- * you can provide an appropriate height for the captions via allowMediaOverlap option
1332
- */
1333
- LightGallery.prototype.getMediaContainerPosition = function () {
1334
- if (this.settings.allowMediaOverlap) {
1335
- return {
1336
- top: 0,
1337
- bottom: 0,
1338
- };
1339
- }
1340
- var top = this.$toolbar.get().clientHeight || 0;
1341
- var subHtml = this.outer.find('.lg-components .lg-sub-html').get();
1342
- var captionHeight = this.settings.defaultCaptionHeight ||
1343
- (subHtml && subHtml.clientHeight) ||
1344
- 0;
1345
- var thumbContainer = this.outer.find('.lg-thumb-outer').get();
1346
- var thumbHeight = thumbContainer ? thumbContainer.clientHeight : 0;
1347
- var bottom = thumbHeight + captionHeight;
1348
- return {
1349
- top: top,
1350
- bottom: bottom,
1351
- };
1352
- };
1353
- LightGallery.prototype.setMediaContainerPosition = function (top, bottom) {
1354
- if (top === void 0) { top = 0; }
1355
- if (bottom === void 0) { bottom = 0; }
1356
- this.$content.css('top', top + 'px').css('bottom', bottom + 'px');
1357
- };
1358
- LightGallery.prototype.hideBars = function () {
1359
- var _this = this;
1360
- // Hide controllers if mouse doesn't move for some period
1361
- setTimeout(function () {
1362
- _this.outer.removeClass('lg-hide-items');
1363
- if (_this.settings.hideBarsDelay > 0) {
1364
- _this.outer.on('mousemove.lg click.lg touchstart.lg', function () {
1365
- _this.outer.removeClass('lg-hide-items');
1366
- clearTimeout(_this.hideBarTimeout);
1367
- // Timeout will be cleared on each slide movement also
1368
- _this.hideBarTimeout = setTimeout(function () {
1369
- _this.outer.addClass('lg-hide-items');
1370
- }, _this.settings.hideBarsDelay);
1371
- });
1372
- _this.outer.trigger('mousemove.lg');
1373
- }
1374
- }, this.settings.showBarsAfter);
1375
- };
1376
- LightGallery.prototype.initPictureFill = function ($img) {
1377
- if (this.settings.supportLegacyBrowser) {
1378
- try {
1379
- picturefill({
1380
- elements: [$img.get()],
1381
- });
1382
- }
1383
- catch (e) {
1384
- console.warn('lightGallery :- If you want srcset or picture tag to be supported for older browser please include picturefil javascript library in your document.');
1385
- }
1386
- }
1387
- };
1388
- /**
1389
- * @desc Create image counter
1390
- * Ex: 1/10
1391
- */
1392
- LightGallery.prototype.counter = function () {
1393
- if (this.settings.counter) {
1394
- var counterHtml = "<div class=\"lg-counter\" role=\"status\" aria-live=\"polite\">\n <span id=\"" + this.getIdName('lg-counter-current') + "\" class=\"lg-counter-current\">" + (this.index + 1) + " </span> /\n <span id=\"" + this.getIdName('lg-counter-all') + "\" class=\"lg-counter-all\">" + this.galleryItems.length + " </span></div>";
1395
- this.outer.find(this.settings.appendCounterTo).append(counterHtml);
1396
- }
1397
- };
1398
- /**
1399
- * @desc add sub-html into the slide
1400
- * @param {Number} index - index of the slide
1401
- */
1402
- LightGallery.prototype.addHtml = function (index) {
1403
- var subHtml;
1404
- var subHtmlUrl;
1405
- if (this.galleryItems[index].subHtmlUrl) {
1406
- subHtmlUrl = this.galleryItems[index].subHtmlUrl;
1407
- }
1408
- else {
1409
- subHtml = this.galleryItems[index].subHtml;
1410
- }
1411
- if (!subHtmlUrl) {
1412
- if (subHtml) {
1413
- // get first letter of sub-html
1414
- // if first letter starts with . or # get the html form the jQuery object
1415
- var fL = subHtml.substring(0, 1);
1416
- if (fL === '.' || fL === '#') {
1417
- if (this.settings.subHtmlSelectorRelative &&
1418
- !this.settings.dynamic) {
1419
- subHtml = $LG(this.items)
1420
- .eq(index)
1421
- .find(subHtml)
1422
- .first()
1423
- .html();
1424
- }
1425
- else {
1426
- subHtml = $LG(subHtml).first().html();
1427
- }
1428
- }
1429
- }
1430
- else {
1431
- subHtml = '';
1432
- }
1433
- }
1434
- if (this.settings.appendSubHtmlTo !== '.lg-item') {
1435
- if (subHtmlUrl) {
1436
- this.outer.find('.lg-sub-html').load(subHtmlUrl);
1437
- }
1438
- else {
1439
- this.outer.find('.lg-sub-html').html(subHtml);
1440
- }
1441
- }
1442
- else {
1443
- var currentSlide = $LG(this.getSlideItemId(index));
1444
- if (subHtmlUrl) {
1445
- currentSlide.load(subHtmlUrl);
1446
- }
1447
- else {
1448
- currentSlide.append("<div class=\"lg-sub-html\">" + subHtml + "</div>");
1449
- }
1450
- }
1451
- // Add lg-empty-html class if title doesn't exist
1452
- if (typeof subHtml !== 'undefined' && subHtml !== null) {
1453
- if (subHtml === '') {
1454
- this.outer
1455
- .find(this.settings.appendSubHtmlTo)
1456
- .addClass('lg-empty-html');
1457
- }
1458
- else {
1459
- this.outer
1460
- .find(this.settings.appendSubHtmlTo)
1461
- .removeClass('lg-empty-html');
1462
- }
1463
- }
1464
- this.LGel.trigger(lGEvents.afterAppendSubHtml, {
1465
- index: index,
1466
- });
1467
- };
1468
- /**
1469
- * @desc Preload slides
1470
- * @param {Number} index - index of the slide
1471
- * @todo preload not working for the first slide, Also, should work for the first and last slide as well
1472
- */
1473
- LightGallery.prototype.preload = function (index) {
1474
- for (var i = 1; i <= this.settings.preload; i++) {
1475
- if (i >= this.galleryItems.length - index) {
1476
- break;
1477
- }
1478
- this.loadContent(index + i, false);
1479
- }
1480
- for (var j = 1; j <= this.settings.preload; j++) {
1481
- if (index - j < 0) {
1482
- break;
1483
- }
1484
- this.loadContent(index - j, false);
1485
- }
1486
- };
1487
- LightGallery.prototype.getDummyImgStyles = function (imageSize) {
1488
- if (!imageSize)
1489
- return '';
1490
- return "width:" + imageSize.width + "px;\n margin-left: -" + imageSize.width / 2 + "px;\n margin-top: -" + imageSize.height / 2 + "px;\n height:" + imageSize.height + "px";
1491
- };
1492
- LightGallery.prototype.getVideoContStyle = function (imageSize) {
1493
- if (!imageSize)
1494
- return '';
1495
- return "width:" + imageSize.width + "px;\n height:" + imageSize.height + "px";
1496
- };
1497
- LightGallery.prototype.getDummyImageContent = function ($currentSlide, index, alt) {
1498
- var $currentItem;
1499
- if (!this.settings.dynamic) {
1500
- $currentItem = $LG(this.items).eq(index);
1501
- }
1502
- if ($currentItem) {
1503
- var _dummyImgSrc = void 0;
1504
- if (!this.settings.exThumbImage) {
1505
- _dummyImgSrc = $currentItem.find('img').first().attr('src');
1506
- }
1507
- else {
1508
- _dummyImgSrc = $currentItem.attr(this.settings.exThumbImage);
1509
- }
1510
- if (!_dummyImgSrc)
1511
- return '';
1512
- var imgStyle = this.getDummyImgStyles(this.currentImageSize);
1513
- var dummyImgContent = "<img " + alt + " style=\"" + imgStyle + "\" class=\"lg-dummy-img\" src=\"" + _dummyImgSrc + "\" />";
1514
- $currentSlide.addClass('lg-first-slide');
1515
- this.outer.addClass('lg-first-slide-loading');
1516
- return dummyImgContent;
1517
- }
1518
- return '';
1519
- };
1520
- LightGallery.prototype.setImgMarkup = function (src, $currentSlide, index) {
1521
- var currentGalleryItem = this.galleryItems[index];
1522
- var alt = currentGalleryItem.alt, srcset = currentGalleryItem.srcset, sizes = currentGalleryItem.sizes, sources = currentGalleryItem.sources;
1523
- // Use the thumbnail as dummy image which will be resized to actual image size and
1524
- // displayed on top of actual image
1525
- var imgContent = '';
1526
- var altAttr = alt ? 'alt="' + alt + '"' : '';
1527
- if (this.isFirstSlideWithZoomAnimation()) {
1528
- imgContent = this.getDummyImageContent($currentSlide, index, altAttr);
1529
- }
1530
- else {
1531
- imgContent = utils.getImgMarkup(index, src, altAttr, srcset, sizes, sources);
1532
- }
1533
- var imgMarkup = "<picture class=\"lg-img-wrap\"> " + imgContent + "</picture>";
1534
- $currentSlide.prepend(imgMarkup);
1535
- };
1536
- LightGallery.prototype.onSlideObjectLoad = function ($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
1537
- var mediaObject = $slide.find('.lg-object').first();
1538
- if (utils.isImageLoaded(mediaObject.get()) ||
1539
- isHTML5VideoWithoutPoster) {
1540
- onLoad();
1541
- }
1542
- else {
1543
- mediaObject.on('load.lg error.lg', function () {
1544
- onLoad && onLoad();
1545
- });
1546
- mediaObject.on('error.lg', function () {
1547
- onError && onError();
1548
- });
1549
- }
1550
- };
1551
- /**
1552
- *
1553
- * @param $el Current slide item
1554
- * @param index
1555
- * @param delay Delay is 0 except first time
1556
- * @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
1557
- * @param isFirstSlide
1558
- */
1559
- LightGallery.prototype.onLgObjectLoad = function (currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
1560
- var _this = this;
1561
- this.onSlideObjectLoad(currentSlide, isHTML5VideoWithoutPoster, function () {
1562
- _this.triggerSlideItemLoad(currentSlide, index, delay, speed, isFirstSlide);
1563
- }, function () {
1564
- currentSlide.addClass('lg-complete lg-complete_');
1565
- currentSlide.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
1566
- });
1567
- };
1568
- LightGallery.prototype.triggerSlideItemLoad = function ($currentSlide, index, delay, speed, isFirstSlide) {
1569
- var _this = this;
1570
- var currentGalleryItem = this.galleryItems[index];
1571
- // Adding delay for video slides without poster for better performance and user experience
1572
- // Videos should start playing once once the gallery is completely loaded
1573
- var _speed = isFirstSlide &&
1574
- this.getSlideType(currentGalleryItem) === 'video' &&
1575
- !currentGalleryItem.poster
1576
- ? speed
1577
- : 0;
1578
- setTimeout(function () {
1579
- $currentSlide.addClass('lg-complete lg-complete_');
1580
- _this.LGel.trigger(lGEvents.slideItemLoad, {
1581
- index: index,
1582
- delay: delay || 0,
1583
- isFirstSlide: isFirstSlide,
1584
- });
1585
- }, _speed);
1586
- };
1587
- LightGallery.prototype.isFirstSlideWithZoomAnimation = function () {
1588
- return !!(!this.lGalleryOn &&
1589
- this.zoomFromOrigin &&
1590
- this.currentImageSize);
1591
- };
1592
- // Add video slideInfo
1593
- LightGallery.prototype.addSlideVideoInfo = function (items) {
1594
- var _this = this;
1595
- items.forEach(function (element, index) {
1596
- element.__slideVideoInfo = utils.isVideo(element.src, !!element.video, index);
1597
- if (element.__slideVideoInfo &&
1598
- _this.settings.loadYouTubePoster &&
1599
- !element.poster &&
1600
- element.__slideVideoInfo.youtube) {
1601
- element.poster = "//img.youtube.com/vi/" + element.__slideVideoInfo.youtube[1] + "/maxresdefault.jpg";
1602
- }
1603
- });
1604
- };
1605
- /**
1606
- * Load slide content into slide.
1607
- * This is used to load content into slides that is not visible too
1608
- * @param {Number} index - index of the slide.
1609
- * @param {Boolean} rec - if true call loadcontent() function again.
1610
- */
1611
- LightGallery.prototype.loadContent = function (index, rec) {
1612
- var _this = this;
1613
- var currentGalleryItem = this.galleryItems[index];
1614
- var $currentSlide = $LG(this.getSlideItemId(index));
1615
- var poster = currentGalleryItem.poster, srcset = currentGalleryItem.srcset, sizes = currentGalleryItem.sizes, sources = currentGalleryItem.sources;
1616
- var src = currentGalleryItem.src;
1617
- var video = currentGalleryItem.video;
1618
- var _html5Video = video && typeof video === 'string' ? JSON.parse(video) : video;
1619
- if (currentGalleryItem.responsive) {
1620
- var srcDyItms = currentGalleryItem.responsive.split(',');
1621
- src = utils.getResponsiveSrc(srcDyItms) || src;
1622
- }
1623
- var videoInfo = currentGalleryItem.__slideVideoInfo;
1624
- var lgVideoStyle = '';
1625
- var iframe = !!currentGalleryItem.iframe;
1626
- var isFirstSlide = !this.lGalleryOn;
1627
- // delay for adding complete class. it is 0 except first time.
1628
- var delay = 0;
1629
- if (isFirstSlide) {
1630
- if (this.zoomFromOrigin && this.currentImageSize) {
1631
- delay = this.settings.startAnimationDuration + 10;
1632
- }
1633
- else {
1634
- delay = this.settings.backdropDuration + 10;
1635
- }
1636
- }
1637
- if (!$currentSlide.hasClass('lg-loaded')) {
1638
- if (videoInfo) {
1639
- var _a = this.mediaContainerPosition, top_2 = _a.top, bottom = _a.bottom;
1640
- var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, videoInfo && this.settings.videoMaxSize);
1641
- lgVideoStyle = this.getVideoContStyle(videoSize);
1642
- }
1643
- if (iframe) {
1644
- var markup = utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, this.settings.iframeMaxWidth, this.settings.iframeMaxHeight, src, currentGalleryItem.iframeTitle);
1645
- $currentSlide.prepend(markup);
1646
- }
1647
- else if (poster) {
1648
- var dummyImg = '';
1649
- var hasStartAnimation = isFirstSlide &&
1650
- this.zoomFromOrigin &&
1651
- this.currentImageSize;
1652
- if (hasStartAnimation) {
1653
- dummyImg = this.getDummyImageContent($currentSlide, index, '');
1654
- }
1655
- var markup = utils.getVideoPosterMarkup(poster, dummyImg || '', lgVideoStyle, this.settings.strings['playVideo'], videoInfo);
1656
- $currentSlide.prepend(markup);
1657
- }
1658
- else if (videoInfo) {
1659
- var markup = "<div class=\"lg-video-cont \" style=\"" + lgVideoStyle + "\"></div>";
1660
- $currentSlide.prepend(markup);
1661
- }
1662
- else {
1663
- this.setImgMarkup(src, $currentSlide, index);
1664
- if (srcset || sources) {
1665
- var $img = $currentSlide.find('.lg-object');
1666
- this.initPictureFill($img);
1667
- }
1668
- }
1669
- if (poster || videoInfo) {
1670
- this.LGel.trigger(lGEvents.hasVideo, {
1671
- index: index,
1672
- src: src,
1673
- html5Video: _html5Video,
1674
- hasPoster: !!poster,
1675
- });
1676
- }
1677
- this.LGel.trigger(lGEvents.afterAppendSlide, { index: index });
1678
- if (this.lGalleryOn &&
1679
- this.settings.appendSubHtmlTo === '.lg-item') {
1680
- this.addHtml(index);
1681
- }
1682
- }
1683
- // For first time add some delay for displaying the start animation.
1684
- var _speed = 0;
1685
- // Do not change the delay value because it is required for zoom plugin.
1686
- // If gallery opened from direct url (hash) speed value should be 0
1687
- if (delay && !$LG(document.body).hasClass('lg-from-hash')) {
1688
- _speed = delay;
1689
- }
1690
- // Only for first slide and zoomFromOrigin is enabled
1691
- if (this.isFirstSlideWithZoomAnimation()) {
1692
- setTimeout(function () {
1693
- $currentSlide
1694
- .removeClass('lg-start-end-progress lg-start-progress')
1695
- .removeAttr('style');
1696
- }, this.settings.startAnimationDuration + 100);
1697
- if (!$currentSlide.hasClass('lg-loaded')) {
1698
- setTimeout(function () {
1699
- if (_this.getSlideType(currentGalleryItem) === 'image') {
1700
- var alt = currentGalleryItem.alt;
1701
- var altAttr = alt ? 'alt="' + alt + '"' : '';
1702
- $currentSlide
1703
- .find('.lg-img-wrap')
1704
- .append(utils.getImgMarkup(index, src, altAttr, srcset, sizes, currentGalleryItem.sources));
1705
- if (srcset || sources) {
1706
- var $img = $currentSlide.find('.lg-object');
1707
- _this.initPictureFill($img);
1708
- }
1709
- }
1710
- if (_this.getSlideType(currentGalleryItem) === 'image' ||
1711
- (_this.getSlideType(currentGalleryItem) === 'video' &&
1712
- poster)) {
1713
- _this.onLgObjectLoad($currentSlide, index, delay, _speed, true, false);
1714
- // load remaining slides once the slide is completely loaded
1715
- _this.onSlideObjectLoad($currentSlide, !!(videoInfo && videoInfo.html5 && !poster), function () {
1716
- _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
1717
- }, function () {
1718
- _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
1719
- });
1720
- }
1721
- }, this.settings.startAnimationDuration + 100);
1722
- }
1723
- }
1724
- // SLide content has been added to dom
1725
- $currentSlide.addClass('lg-loaded');
1726
- if (!this.isFirstSlideWithZoomAnimation() ||
1727
- (this.getSlideType(currentGalleryItem) === 'video' && !poster)) {
1728
- this.onLgObjectLoad($currentSlide, index, delay, _speed, isFirstSlide, !!(videoInfo && videoInfo.html5 && !poster));
1729
- }
1730
- // When gallery is opened once content is loaded (second time) need to add lg-complete class for css styling
1731
- if ((!this.zoomFromOrigin || !this.currentImageSize) &&
1732
- $currentSlide.hasClass('lg-complete_') &&
1733
- !this.lGalleryOn) {
1734
- setTimeout(function () {
1735
- $currentSlide.addClass('lg-complete');
1736
- }, this.settings.backdropDuration);
1737
- }
1738
- // Content loaded
1739
- // Need to set lGalleryOn before calling preload function
1740
- this.lGalleryOn = true;
1741
- if (rec === true) {
1742
- if (!$currentSlide.hasClass('lg-complete_')) {
1743
- $currentSlide
1744
- .find('.lg-object')
1745
- .first()
1746
- .on('load.lg error.lg', function () {
1747
- _this.preload(index);
1748
- });
1749
- }
1750
- else {
1751
- this.preload(index);
1752
- }
1753
- }
1754
- };
1755
- /**
1756
- * @desc Remove dummy image content and load next slides
1757
- * Called only for the first time if zoomFromOrigin animation is enabled
1758
- * @param index
1759
- * @param $currentSlide
1760
- * @param speed
1761
- */
1762
- LightGallery.prototype.loadContentOnFirstSlideLoad = function (index, $currentSlide, speed) {
1763
- var _this = this;
1764
- setTimeout(function () {
1765
- $currentSlide.find('.lg-dummy-img').remove();
1766
- $currentSlide.removeClass('lg-first-slide');
1767
- _this.outer.removeClass('lg-first-slide-loading');
1768
- _this.isDummyImageRemoved = true;
1769
- _this.preload(index);
1770
- }, speed + 300);
1771
- };
1772
- LightGallery.prototype.getItemsToBeInsertedToDom = function (index, prevIndex, numberOfItems) {
1773
- var _this = this;
1774
- if (numberOfItems === void 0) { numberOfItems = 0; }
1775
- var itemsToBeInsertedToDom = [];
1776
- // Minimum 2 items should be there
1777
- var possibleNumberOfItems = Math.max(numberOfItems, 3);
1778
- possibleNumberOfItems = Math.min(possibleNumberOfItems, this.galleryItems.length);
1779
- var prevIndexItem = "lg-item-" + this.lgId + "-" + prevIndex;
1780
- if (this.galleryItems.length <= 3) {
1781
- this.galleryItems.forEach(function (_element, index) {
1782
- itemsToBeInsertedToDom.push("lg-item-" + _this.lgId + "-" + index);
1783
- });
1784
- return itemsToBeInsertedToDom;
1785
- }
1786
- if (index < (this.galleryItems.length - 1) / 2) {
1787
- for (var idx = index; idx > index - possibleNumberOfItems / 2 && idx >= 0; idx--) {
1788
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + idx);
1789
- }
1790
- var numberOfExistingItems = itemsToBeInsertedToDom.length;
1791
- for (var idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
1792
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (index + idx + 1));
1793
- }
1794
- }
1795
- else {
1796
- for (var idx = index; idx <= this.galleryItems.length - 1 &&
1797
- idx < index + possibleNumberOfItems / 2; idx++) {
1798
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + idx);
1799
- }
1800
- var numberOfExistingItems = itemsToBeInsertedToDom.length;
1801
- for (var idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
1802
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (index - idx - 1));
1803
- }
1804
- }
1805
- if (this.settings.loop) {
1806
- if (index === this.galleryItems.length - 1) {
1807
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + 0);
1808
- }
1809
- else if (index === 0) {
1810
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (this.galleryItems.length - 1));
1811
- }
1812
- }
1813
- if (itemsToBeInsertedToDom.indexOf(prevIndexItem) === -1) {
1814
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + prevIndex);
1815
- }
1816
- return itemsToBeInsertedToDom;
1817
- };
1818
- LightGallery.prototype.organizeSlideItems = function (index, prevIndex) {
1819
- var _this = this;
1820
- var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, prevIndex, this.settings.numberOfSlideItemsInDom);
1821
- itemsToBeInsertedToDom.forEach(function (item) {
1822
- if (_this.currentItemsInDom.indexOf(item) === -1) {
1823
- _this.$inner.append("<div id=\"" + item + "\" class=\"lg-item\"></div>");
1824
- }
1825
- });
1826
- this.currentItemsInDom.forEach(function (item) {
1827
- if (itemsToBeInsertedToDom.indexOf(item) === -1) {
1828
- $LG("#" + item).remove();
1829
- }
1830
- });
1831
- return itemsToBeInsertedToDom;
1832
- };
1833
- /**
1834
- * Get previous index of the slide
1835
- */
1836
- LightGallery.prototype.getPreviousSlideIndex = function () {
1837
- var prevIndex = 0;
1838
- try {
1839
- var currentItemId = this.outer
1840
- .find('.lg-current')
1841
- .first()
1842
- .attr('id');
1843
- prevIndex = parseInt(currentItemId.split('-')[3]) || 0;
1844
- }
1845
- catch (error) {
1846
- prevIndex = 0;
1847
- }
1848
- return prevIndex;
1849
- };
1850
- LightGallery.prototype.setDownloadValue = function (index) {
1851
- if (this.settings.download) {
1852
- var currentGalleryItem = this.galleryItems[index];
1853
- var hideDownloadBtn = currentGalleryItem.downloadUrl === false ||
1854
- currentGalleryItem.downloadUrl === 'false';
1855
- if (hideDownloadBtn) {
1856
- this.outer.addClass('lg-hide-download');
1857
- }
1858
- else {
1859
- var $download = this.getElementById('lg-download');
1860
- this.outer.removeClass('lg-hide-download');
1861
- $download.attr('href', currentGalleryItem.downloadUrl ||
1862
- currentGalleryItem.src);
1863
- if (currentGalleryItem.download) {
1864
- $download.attr('download', currentGalleryItem.download);
1865
- }
1866
- }
1867
- }
1868
- };
1869
- LightGallery.prototype.makeSlideAnimation = function (direction, currentSlideItem, previousSlideItem) {
1870
- var _this = this;
1871
- if (this.lGalleryOn) {
1872
- previousSlideItem.addClass('lg-slide-progress');
1873
- }
1874
- setTimeout(function () {
1875
- // remove all transitions
1876
- _this.outer.addClass('lg-no-trans');
1877
- _this.outer
1878
- .find('.lg-item')
1879
- .removeClass('lg-prev-slide lg-next-slide');
1880
- if (direction === 'prev') {
1881
- //prevslide
1882
- currentSlideItem.addClass('lg-prev-slide');
1883
- previousSlideItem.addClass('lg-next-slide');
1884
- }
1885
- else {
1886
- // next slide
1887
- currentSlideItem.addClass('lg-next-slide');
1888
- previousSlideItem.addClass('lg-prev-slide');
1889
- }
1890
- // give 50 ms for browser to add/remove class
1891
- setTimeout(function () {
1892
- _this.outer.find('.lg-item').removeClass('lg-current');
1893
- currentSlideItem.addClass('lg-current');
1894
- // reset all transitions
1895
- _this.outer.removeClass('lg-no-trans');
1896
- }, 50);
1897
- }, this.lGalleryOn ? this.settings.slideDelay : 0);
1898
- };
1899
- /**
1900
- * Goto a specific slide.
1901
- * @param {Number} index - index of the slide
1902
- * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
1903
- * @param {Boolean} fromThumb - true if slide function called via thumbnail click
1904
- * @param {String} direction - Direction of the slide(next/prev)
1905
- * @category lGPublicMethods
1906
- * @example
1907
- * const plugin = lightGallery();
1908
- * // to go to 3rd slide
1909
- * plugin.slide(2);
1910
- *
1911
- */
1912
- LightGallery.prototype.slide = function (index, fromTouch, fromThumb, direction) {
1913
- var _this = this;
1914
- var prevIndex = this.getPreviousSlideIndex();
1915
- this.currentItemsInDom = this.organizeSlideItems(index, prevIndex);
1916
- // Prevent multiple call, Required for hsh plugin
1917
- if (this.lGalleryOn && prevIndex === index) {
1918
- return;
1919
- }
1920
- var numberOfGalleryItems = this.galleryItems.length;
1921
- if (!this.lgBusy) {
1922
- if (this.settings.counter) {
1923
- this.updateCurrentCounter(index);
1924
- }
1925
- var currentSlideItem = this.getSlideItem(index);
1926
- var previousSlideItem_1 = this.getSlideItem(prevIndex);
1927
- var currentGalleryItem = this.galleryItems[index];
1928
- var videoInfo = currentGalleryItem.__slideVideoInfo;
1929
- this.outer.attr('data-lg-slide-type', this.getSlideType(currentGalleryItem));
1930
- this.setDownloadValue(index);
1931
- if (videoInfo) {
1932
- var _a = this.mediaContainerPosition, top_3 = _a.top, bottom = _a.bottom;
1933
- var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, videoInfo && this.settings.videoMaxSize);
1934
- this.resizeVideoSlide(index, videoSize);
1935
- }
1936
- this.LGel.trigger(lGEvents.beforeSlide, {
1937
- prevIndex: prevIndex,
1938
- index: index,
1939
- fromTouch: !!fromTouch,
1940
- fromThumb: !!fromThumb,
1941
- });
1942
- this.lgBusy = true;
1943
- clearTimeout(this.hideBarTimeout);
1944
- this.arrowDisable(index);
1945
- if (!direction) {
1946
- if (index < prevIndex) {
1947
- direction = 'prev';
1948
- }
1949
- else if (index > prevIndex) {
1950
- direction = 'next';
1951
- }
1952
- }
1953
- if (!fromTouch) {
1954
- this.makeSlideAnimation(direction, currentSlideItem, previousSlideItem_1);
1955
- }
1956
- else {
1957
- this.outer
1958
- .find('.lg-item')
1959
- .removeClass('lg-prev-slide lg-current lg-next-slide');
1960
- var touchPrev = void 0;
1961
- var touchNext = void 0;
1962
- if (numberOfGalleryItems > 2) {
1963
- touchPrev = index - 1;
1964
- touchNext = index + 1;
1965
- if (index === 0 && prevIndex === numberOfGalleryItems - 1) {
1966
- // next slide
1967
- touchNext = 0;
1968
- touchPrev = numberOfGalleryItems - 1;
1969
- }
1970
- else if (index === numberOfGalleryItems - 1 &&
1971
- prevIndex === 0) {
1972
- // prev slide
1973
- touchNext = 0;
1974
- touchPrev = numberOfGalleryItems - 1;
1975
- }
1976
- }
1977
- else {
1978
- touchPrev = 0;
1979
- touchNext = 1;
1980
- }
1981
- if (direction === 'prev') {
1982
- this.getSlideItem(touchNext).addClass('lg-next-slide');
1983
- }
1984
- else {
1985
- this.getSlideItem(touchPrev).addClass('lg-prev-slide');
1986
- }
1987
- currentSlideItem.addClass('lg-current');
1988
- }
1989
- // Do not put load content in set timeout as it needs to load immediately when the gallery is opened
1990
- if (!this.lGalleryOn) {
1991
- this.loadContent(index, true);
1992
- }
1993
- else {
1994
- setTimeout(function () {
1995
- _this.loadContent(index, true);
1996
- // Add title if this.settings.appendSubHtmlTo === lg-sub-html
1997
- if (_this.settings.appendSubHtmlTo !== '.lg-item') {
1998
- _this.addHtml(index);
1999
- }
2000
- }, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
2001
- }
2002
- setTimeout(function () {
2003
- _this.lgBusy = false;
2004
- previousSlideItem_1.removeClass('lg-slide-progress');
2005
- _this.LGel.trigger(lGEvents.afterSlide, {
2006
- prevIndex: prevIndex,
2007
- index: index,
2008
- fromTouch: fromTouch,
2009
- fromThumb: fromThumb,
2010
- });
2011
- }, (this.lGalleryOn ? this.settings.speed + 100 : 100) + (fromTouch ? 0 : this.settings.slideDelay));
2012
- }
2013
- this.index = index;
2014
- };
2015
- LightGallery.prototype.updateCurrentCounter = function (index) {
2016
- this.getElementById('lg-counter-current').html(index + 1 + '');
2017
- };
2018
- LightGallery.prototype.updateCounterTotal = function () {
2019
- this.getElementById('lg-counter-all').html(this.galleryItems.length + '');
2020
- };
2021
- LightGallery.prototype.getSlideType = function (item) {
2022
- if (item.__slideVideoInfo) {
2023
- return 'video';
2024
- }
2025
- else if (item.iframe) {
2026
- return 'iframe';
2027
- }
2028
- else {
2029
- return 'image';
2030
- }
2031
- };
2032
- LightGallery.prototype.touchMove = function (startCoords, endCoords, e) {
2033
- var distanceX = endCoords.pageX - startCoords.pageX;
2034
- var distanceY = endCoords.pageY - startCoords.pageY;
2035
- var allowSwipe = false;
2036
- if (this.swipeDirection) {
2037
- allowSwipe = true;
2038
- }
2039
- else {
2040
- if (Math.abs(distanceX) > 15) {
2041
- this.swipeDirection = 'horizontal';
2042
- allowSwipe = true;
2043
- }
2044
- else if (Math.abs(distanceY) > 15) {
2045
- this.swipeDirection = 'vertical';
2046
- allowSwipe = true;
2047
- }
2048
- }
2049
- if (!allowSwipe) {
2050
- return;
2051
- }
2052
- var $currentSlide = this.getSlideItem(this.index);
2053
- if (this.swipeDirection === 'horizontal') {
2054
- e === null || e === void 0 ? void 0 : e.preventDefault();
2055
- // reset opacity and transition duration
2056
- this.outer.addClass('lg-dragging');
2057
- // move current slide
2058
- this.setTranslate($currentSlide, distanceX, 0);
2059
- // move next and prev slide with current slide
2060
- var width = $currentSlide.get().offsetWidth;
2061
- var slideWidthAmount = (width * 15) / 100;
2062
- var gutter = slideWidthAmount - Math.abs((distanceX * 10) / 100);
2063
- this.setTranslate(this.outer.find('.lg-prev-slide').first(), -width + distanceX - gutter, 0);
2064
- this.setTranslate(this.outer.find('.lg-next-slide').first(), width + distanceX + gutter, 0);
2065
- }
2066
- else if (this.swipeDirection === 'vertical') {
2067
- if (this.settings.swipeToClose) {
2068
- e === null || e === void 0 ? void 0 : e.preventDefault();
2069
- this.$container.addClass('lg-dragging-vertical');
2070
- var opacity = 1 - Math.abs(distanceY) / window.innerHeight;
2071
- this.$backdrop.css('opacity', opacity);
2072
- var scale = 1 - Math.abs(distanceY) / (window.innerWidth * 2);
2073
- this.setTranslate($currentSlide, 0, distanceY, scale, scale);
2074
- if (Math.abs(distanceY) > 100) {
2075
- this.outer
2076
- .addClass('lg-hide-items')
2077
- .removeClass('lg-components-open');
2078
- }
2079
- }
2080
- }
2081
- };
2082
- LightGallery.prototype.touchEnd = function (endCoords, startCoords, event) {
2083
- var _this = this;
2084
- var distance;
2085
- // keep slide animation for any mode while dragg/swipe
2086
- if (this.settings.mode !== 'lg-slide') {
2087
- this.outer.addClass('lg-slide');
2088
- }
2089
- // set transition duration
2090
- setTimeout(function () {
2091
- _this.$container.removeClass('lg-dragging-vertical');
2092
- _this.outer
2093
- .removeClass('lg-dragging lg-hide-items')
2094
- .addClass('lg-components-open');
2095
- var triggerClick = true;
2096
- if (_this.swipeDirection === 'horizontal') {
2097
- distance = endCoords.pageX - startCoords.pageX;
2098
- var distanceAbs = Math.abs(endCoords.pageX - startCoords.pageX);
2099
- if (distance < 0 &&
2100
- distanceAbs > _this.settings.swipeThreshold) {
2101
- _this.goToNextSlide(true);
2102
- triggerClick = false;
2103
- }
2104
- else if (distance > 0 &&
2105
- distanceAbs > _this.settings.swipeThreshold) {
2106
- _this.goToPrevSlide(true);
2107
- triggerClick = false;
2108
- }
2109
- }
2110
- else if (_this.swipeDirection === 'vertical') {
2111
- distance = Math.abs(endCoords.pageY - startCoords.pageY);
2112
- if (_this.settings.closable &&
2113
- _this.settings.swipeToClose &&
2114
- distance > 100) {
2115
- _this.closeGallery();
2116
- return;
2117
- }
2118
- else {
2119
- _this.$backdrop.css('opacity', 1);
2120
- }
2121
- }
2122
- _this.outer.find('.lg-item').removeAttr('style');
2123
- if (triggerClick &&
2124
- Math.abs(endCoords.pageX - startCoords.pageX) < 5) {
2125
- // Trigger click if distance is less than 5 pix
2126
- var target = $LG(event.target);
2127
- if (_this.isPosterElement(target)) {
2128
- _this.LGel.trigger(lGEvents.posterClick);
2129
- }
2130
- }
2131
- _this.swipeDirection = undefined;
2132
- });
2133
- // remove slide class once drag/swipe is completed if mode is not slide
2134
- setTimeout(function () {
2135
- if (!_this.outer.hasClass('lg-dragging') &&
2136
- _this.settings.mode !== 'lg-slide') {
2137
- _this.outer.removeClass('lg-slide');
2138
- }
2139
- }, this.settings.speed + 100);
2140
- };
2141
- LightGallery.prototype.enableSwipe = function () {
2142
- var _this = this;
2143
- var startCoords = {};
2144
- var endCoords = {};
2145
- var isMoved = false;
2146
- var isSwiping = false;
2147
- if (this.settings.enableSwipe) {
2148
- this.$inner.on('touchstart.lg', function (e) {
2149
- _this.dragOrSwipeEnabled = true;
2150
- var $item = _this.getSlideItem(_this.index);
2151
- if (($LG(e.target).hasClass('lg-item') ||
2152
- $item.get().contains(e.target)) &&
2153
- !_this.outer.hasClass('lg-zoomed') &&
2154
- !_this.lgBusy &&
2155
- e.targetTouches.length === 1) {
2156
- isSwiping = true;
2157
- _this.touchAction = 'swipe';
2158
- _this.manageSwipeClass();
2159
- startCoords = {
2160
- pageX: e.targetTouches[0].pageX,
2161
- pageY: e.targetTouches[0].pageY,
2162
- };
2163
- }
2164
- });
2165
- this.$inner.on('touchmove.lg', function (e) {
2166
- if (isSwiping &&
2167
- _this.touchAction === 'swipe' &&
2168
- e.targetTouches.length === 1) {
2169
- endCoords = {
2170
- pageX: e.targetTouches[0].pageX,
2171
- pageY: e.targetTouches[0].pageY,
2172
- };
2173
- _this.touchMove(startCoords, endCoords, e);
2174
- isMoved = true;
2175
- }
2176
- });
2177
- this.$inner.on('touchend.lg', function (event) {
2178
- if (_this.touchAction === 'swipe') {
2179
- if (isMoved) {
2180
- isMoved = false;
2181
- _this.touchEnd(endCoords, startCoords, event);
2182
- }
2183
- else if (isSwiping) {
2184
- var target = $LG(event.target);
2185
- if (_this.isPosterElement(target)) {
2186
- _this.LGel.trigger(lGEvents.posterClick);
2187
- }
2188
- }
2189
- _this.touchAction = undefined;
2190
- isSwiping = false;
2191
- }
2192
- });
2193
- }
2194
- };
2195
- LightGallery.prototype.enableDrag = function () {
2196
- var _this = this;
2197
- var startCoords = {};
2198
- var endCoords = {};
2199
- var isDraging = false;
2200
- var isMoved = false;
2201
- if (this.settings.enableDrag) {
2202
- this.outer.on('mousedown.lg', function (e) {
2203
- _this.dragOrSwipeEnabled = true;
2204
- var $item = _this.getSlideItem(_this.index);
2205
- if ($LG(e.target).hasClass('lg-item') ||
2206
- $item.get().contains(e.target)) {
2207
- if (!_this.outer.hasClass('lg-zoomed') && !_this.lgBusy) {
2208
- e.preventDefault();
2209
- if (!_this.lgBusy) {
2210
- _this.manageSwipeClass();
2211
- startCoords = {
2212
- pageX: e.pageX,
2213
- pageY: e.pageY,
2214
- };
2215
- isDraging = true;
2216
- // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
2217
- _this.outer.get().scrollLeft += 1;
2218
- _this.outer.get().scrollLeft -= 1;
2219
- // *
2220
- _this.outer
2221
- .removeClass('lg-grab')
2222
- .addClass('lg-grabbing');
2223
- _this.LGel.trigger(lGEvents.dragStart);
2224
- }
2225
- }
2226
- }
2227
- });
2228
- $LG(window).on("mousemove.lg.global" + this.lgId, function (e) {
2229
- if (isDraging && _this.lgOpened) {
2230
- isMoved = true;
2231
- endCoords = {
2232
- pageX: e.pageX,
2233
- pageY: e.pageY,
2234
- };
2235
- _this.touchMove(startCoords, endCoords);
2236
- _this.LGel.trigger(lGEvents.dragMove);
2237
- }
2238
- });
2239
- $LG(window).on("mouseup.lg.global" + this.lgId, function (event) {
2240
- if (!_this.lgOpened) {
2241
- return;
2242
- }
2243
- var target = $LG(event.target);
2244
- if (isMoved) {
2245
- isMoved = false;
2246
- _this.touchEnd(endCoords, startCoords, event);
2247
- _this.LGel.trigger(lGEvents.dragEnd);
2248
- }
2249
- else if (_this.isPosterElement(target)) {
2250
- _this.LGel.trigger(lGEvents.posterClick);
2251
- }
2252
- // Prevent execution on click
2253
- if (isDraging) {
2254
- isDraging = false;
2255
- _this.outer.removeClass('lg-grabbing').addClass('lg-grab');
2256
- }
2257
- });
2258
- }
2259
- };
2260
- LightGallery.prototype.triggerPosterClick = function () {
2261
- var _this = this;
2262
- this.$inner.on('click.lg', function (event) {
2263
- if (!_this.dragOrSwipeEnabled &&
2264
- _this.isPosterElement($LG(event.target))) {
2265
- _this.LGel.trigger(lGEvents.posterClick);
2266
- }
2267
- });
2268
- };
2269
- LightGallery.prototype.manageSwipeClass = function () {
2270
- var _touchNext = this.index + 1;
2271
- var _touchPrev = this.index - 1;
2272
- if (this.settings.loop && this.galleryItems.length > 2) {
2273
- if (this.index === 0) {
2274
- _touchPrev = this.galleryItems.length - 1;
2275
- }
2276
- else if (this.index === this.galleryItems.length - 1) {
2277
- _touchNext = 0;
2278
- }
2279
- }
2280
- this.outer.find('.lg-item').removeClass('lg-next-slide lg-prev-slide');
2281
- if (_touchPrev > -1) {
2282
- this.getSlideItem(_touchPrev).addClass('lg-prev-slide');
2283
- }
2284
- this.getSlideItem(_touchNext).addClass('lg-next-slide');
2285
- };
2286
- /**
2287
- * Go to next slide
2288
- * @param {Boolean} fromTouch - true if slide function called via touch event
2289
- * @category lGPublicMethods
2290
- * @example
2291
- * const plugin = lightGallery();
2292
- * plugin.goToNextSlide();
2293
- * @see <a href="/demos/methods/">Demo</a>
2294
- */
2295
- LightGallery.prototype.goToNextSlide = function (fromTouch) {
2296
- var _this = this;
2297
- var _loop = this.settings.loop;
2298
- if (fromTouch && this.galleryItems.length < 3) {
2299
- _loop = false;
2300
- }
2301
- if (!this.lgBusy) {
2302
- if (this.index + 1 < this.galleryItems.length) {
2303
- this.index++;
2304
- this.LGel.trigger(lGEvents.beforeNextSlide, {
2305
- index: this.index,
2306
- });
2307
- this.slide(this.index, !!fromTouch, false, 'next');
2308
- }
2309
- else {
2310
- if (_loop) {
2311
- this.index = 0;
2312
- this.LGel.trigger(lGEvents.beforeNextSlide, {
2313
- index: this.index,
2314
- });
2315
- this.slide(this.index, !!fromTouch, false, 'next');
2316
- }
2317
- else if (this.settings.slideEndAnimation && !fromTouch) {
2318
- this.outer.addClass('lg-right-end');
2319
- setTimeout(function () {
2320
- _this.outer.removeClass('lg-right-end');
2321
- }, 400);
2322
- }
2323
- }
2324
- }
2325
- };
2326
- /**
2327
- * Go to previous slides
2328
- * @param {Boolean} fromTouch - true if slide function called via touch event
2329
- * @category lGPublicMethods
2330
- * @example
2331
- * const plugin = lightGallery({});
2332
- * plugin.goToPrevSlide();
2333
- * @see <a href="/demos/methods/">Demo</a>
2334
- *
2335
- */
2336
- LightGallery.prototype.goToPrevSlide = function (fromTouch) {
2337
- var _this = this;
2338
- var _loop = this.settings.loop;
2339
- if (fromTouch && this.galleryItems.length < 3) {
2340
- _loop = false;
2341
- }
2342
- if (!this.lgBusy) {
2343
- if (this.index > 0) {
2344
- this.index--;
2345
- this.LGel.trigger(lGEvents.beforePrevSlide, {
2346
- index: this.index,
2347
- fromTouch: fromTouch,
2348
- });
2349
- this.slide(this.index, !!fromTouch, false, 'prev');
2350
- }
2351
- else {
2352
- if (_loop) {
2353
- this.index = this.galleryItems.length - 1;
2354
- this.LGel.trigger(lGEvents.beforePrevSlide, {
2355
- index: this.index,
2356
- fromTouch: fromTouch,
2357
- });
2358
- this.slide(this.index, !!fromTouch, false, 'prev');
2359
- }
2360
- else if (this.settings.slideEndAnimation && !fromTouch) {
2361
- this.outer.addClass('lg-left-end');
2362
- setTimeout(function () {
2363
- _this.outer.removeClass('lg-left-end');
2364
- }, 400);
2365
- }
2366
- }
2367
- }
2368
- };
2369
- LightGallery.prototype.keyPress = function () {
2370
- var _this = this;
2371
- $LG(window).on("keydown.lg.global" + this.lgId, function (e) {
2372
- if (_this.lgOpened &&
2373
- _this.settings.escKey === true &&
2374
- e.keyCode === 27) {
2375
- e.preventDefault();
2376
- if (_this.settings.allowMediaOverlap &&
2377
- _this.outer.hasClass('lg-can-toggle') &&
2378
- _this.outer.hasClass('lg-components-open')) {
2379
- _this.outer.removeClass('lg-components-open');
2380
- }
2381
- else {
2382
- _this.closeGallery();
2383
- }
2384
- }
2385
- if (_this.lgOpened && _this.galleryItems.length > 1) {
2386
- if (e.keyCode === 37) {
2387
- e.preventDefault();
2388
- _this.goToPrevSlide();
2389
- }
2390
- if (e.keyCode === 39) {
2391
- e.preventDefault();
2392
- _this.goToNextSlide();
2393
- }
2394
- }
2395
- });
2396
- };
2397
- LightGallery.prototype.arrow = function () {
2398
- var _this = this;
2399
- this.getElementById('lg-prev').on('click.lg', function () {
2400
- _this.goToPrevSlide();
2401
- });
2402
- this.getElementById('lg-next').on('click.lg', function () {
2403
- _this.goToNextSlide();
2404
- });
2405
- };
2406
- LightGallery.prototype.arrowDisable = function (index) {
2407
- // Disable arrows if settings.hideControlOnEnd is true
2408
- if (!this.settings.loop && this.settings.hideControlOnEnd) {
2409
- var $prev = this.getElementById('lg-prev');
2410
- var $next = this.getElementById('lg-next');
2411
- if (index + 1 === this.galleryItems.length) {
2412
- $next.attr('disabled', 'disabled').addClass('disabled');
2413
- }
2414
- else {
2415
- $next.removeAttr('disabled').removeClass('disabled');
2416
- }
2417
- if (index === 0) {
2418
- $prev.attr('disabled', 'disabled').addClass('disabled');
2419
- }
2420
- else {
2421
- $prev.removeAttr('disabled').removeClass('disabled');
2422
- }
2423
- }
2424
- };
2425
- LightGallery.prototype.setTranslate = function ($el, xValue, yValue, scaleX, scaleY) {
2426
- if (scaleX === void 0) { scaleX = 1; }
2427
- if (scaleY === void 0) { scaleY = 1; }
2428
- $el.css('transform', 'translate3d(' +
2429
- xValue +
2430
- 'px, ' +
2431
- yValue +
2432
- 'px, 0px) scale3d(' +
2433
- scaleX +
2434
- ', ' +
2435
- scaleY +
2436
- ', 1)');
2437
- };
2438
- LightGallery.prototype.mousewheel = function () {
2439
- var _this = this;
2440
- var lastCall = 0;
2441
- this.outer.on('wheel.lg', function (e) {
2442
- if (!e.deltaY || _this.galleryItems.length < 2) {
2443
- return;
2444
- }
2445
- e.preventDefault();
2446
- var now = new Date().getTime();
2447
- if (now - lastCall < 1000) {
2448
- return;
2449
- }
2450
- lastCall = now;
2451
- if (e.deltaY > 0) {
2452
- _this.goToNextSlide();
2453
- }
2454
- else if (e.deltaY < 0) {
2455
- _this.goToPrevSlide();
2456
- }
2457
- });
2458
- };
2459
- LightGallery.prototype.isSlideElement = function (target) {
2460
- return (target.hasClass('lg-outer') ||
2461
- target.hasClass('lg-item') ||
2462
- target.hasClass('lg-img-wrap'));
2463
- };
2464
- LightGallery.prototype.isPosterElement = function (target) {
2465
- var playButton = this.getSlideItem(this.index)
2466
- .find('.lg-video-play-button')
2467
- .get();
2468
- return (target.hasClass('lg-video-poster') ||
2469
- target.hasClass('lg-video-play-button') ||
2470
- (playButton && playButton.contains(target.get())));
2471
- };
2472
- /**
2473
- * Maximize minimize inline gallery.
2474
- * @category lGPublicMethods
2475
- */
2476
- LightGallery.prototype.toggleMaximize = function () {
2477
- var _this = this;
2478
- this.getElementById('lg-maximize').on('click.lg', function () {
2479
- _this.$container.toggleClass('lg-inline');
2480
- _this.refreshOnResize();
2481
- });
2482
- };
2483
- LightGallery.prototype.invalidateItems = function () {
2484
- for (var index = 0; index < this.items.length; index++) {
2485
- var element = this.items[index];
2486
- var $element = $LG(element);
2487
- $element.off("click.lgcustom-item-" + $element.attr('data-lg-id'));
2488
- }
2489
- };
2490
- LightGallery.prototype.trapFocus = function () {
2491
- var _this = this;
2492
- this.$container.get().focus({
2493
- preventScroll: true,
2494
- });
2495
- $LG(window).on("keydown.lg.global" + this.lgId, function (e) {
2496
- if (!_this.lgOpened) {
2497
- return;
2498
- }
2499
- var isTabPressed = e.key === 'Tab' || e.keyCode === 9;
2500
- if (!isTabPressed) {
2501
- return;
2502
- }
2503
- var focusableEls = utils.getFocusableElements(_this.$container.get());
2504
- var firstFocusableEl = focusableEls[0];
2505
- var lastFocusableEl = focusableEls[focusableEls.length - 1];
2506
- if (e.shiftKey) {
2507
- if (document.activeElement === firstFocusableEl) {
2508
- lastFocusableEl.focus();
2509
- e.preventDefault();
2510
- }
2511
- }
2512
- else {
2513
- if (document.activeElement === lastFocusableEl) {
2514
- firstFocusableEl.focus();
2515
- e.preventDefault();
2516
- }
2517
- }
2518
- });
2519
- };
2520
- LightGallery.prototype.manageCloseGallery = function () {
2521
- var _this = this;
2522
- if (!this.settings.closable)
2523
- return;
2524
- var mousedown = false;
2525
- this.getElementById('lg-close').on('click.lg', function () {
2526
- _this.closeGallery();
2527
- });
2528
- if (this.settings.closeOnTap) {
2529
- // If you drag the slide and release outside gallery gets close on chrome
2530
- // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer
2531
- this.outer.on('mousedown.lg', function (e) {
2532
- var target = $LG(e.target);
2533
- if (_this.isSlideElement(target)) {
2534
- mousedown = true;
2535
- }
2536
- else {
2537
- mousedown = false;
2538
- }
2539
- });
2540
- this.outer.on('mousemove.lg', function () {
2541
- mousedown = false;
2542
- });
2543
- this.outer.on('mouseup.lg', function (e) {
2544
- var target = $LG(e.target);
2545
- if (_this.isSlideElement(target) && mousedown) {
2546
- if (!_this.outer.hasClass('lg-dragging')) {
2547
- _this.closeGallery();
2548
- }
2549
- }
2550
- });
2551
- }
2552
- };
2553
- /**
2554
- * Close lightGallery if it is opened.
2555
- *
2556
- * @description If closable is false in the settings, you need to pass true via closeGallery method to force close gallery
2557
- * @return returns the estimated time to close gallery completely including the close animation duration
2558
- * @category lGPublicMethods
2559
- * @example
2560
- * const plugin = lightGallery();
2561
- * plugin.closeGallery();
2562
- *
2563
- */
2564
- LightGallery.prototype.closeGallery = function (force) {
2565
- var _this = this;
2566
- if (!this.lgOpened || (!this.settings.closable && !force)) {
2567
- return 0;
2568
- }
2569
- this.LGel.trigger(lGEvents.beforeClose);
2570
- if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
2571
- $LG(window).scrollTop(this.prevScrollTop);
2572
- }
2573
- var currentItem = this.items[this.index];
2574
- var transform;
2575
- if (this.zoomFromOrigin && currentItem) {
2576
- var _a = this.mediaContainerPosition, top_4 = _a.top, bottom = _a.bottom;
2577
- var _b = this.galleryItems[this.index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster;
2578
- var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, __slideVideoInfo && poster && this.settings.videoMaxSize);
2579
- transform = utils.getTransform(currentItem, this.outer, top_4, bottom, imageSize);
2580
- }
2581
- if (this.zoomFromOrigin && transform) {
2582
- this.outer.addClass('lg-closing lg-zoom-from-image');
2583
- this.getSlideItem(this.index)
2584
- .addClass('lg-start-end-progress')
2585
- .css('transition-duration', this.settings.startAnimationDuration + 'ms')
2586
- .css('transform', transform);
2587
- }
2588
- else {
2589
- this.outer.addClass('lg-hide-items');
2590
- // lg-zoom-from-image is used for setting the opacity to 1 if zoomFromOrigin is true
2591
- // If the closing item doesn't have the lg-size attribute, remove this class to avoid the closing css conflicts
2592
- this.outer.removeClass('lg-zoom-from-image');
2593
- }
2594
- // Unbind all events added by lightGallery
2595
- // @todo
2596
- //this.$el.off('.lg.tm');
2597
- this.destroyModules();
2598
- this.lGalleryOn = false;
2599
- this.isDummyImageRemoved = false;
2600
- this.zoomFromOrigin = this.settings.zoomFromOrigin;
2601
- clearTimeout(this.hideBarTimeout);
2602
- this.hideBarTimeout = false;
2603
- $LG('html').removeClass('lg-on');
2604
- this.outer.removeClass('lg-visible lg-components-open');
2605
- // Resetting opacity to 0 isd required as vertical swipe to close function adds inline opacity.
2606
- this.$backdrop.removeClass('in').css('opacity', 0);
2607
- var removeTimeout = this.zoomFromOrigin && transform
2608
- ? Math.max(this.settings.startAnimationDuration, this.settings.backdropDuration)
2609
- : this.settings.backdropDuration;
2610
- this.$container.removeClass('lg-show-in');
2611
- // Once the closign animation is completed and gallery is invisible
2612
- setTimeout(function () {
2613
- if (_this.zoomFromOrigin && transform) {
2614
- _this.outer.removeClass('lg-zoom-from-image');
2615
- }
2616
- _this.$container.removeClass('lg-show');
2617
- // Reset scrollbar
2618
- _this.resetScrollBar();
2619
- // Need to remove inline opacity as it is used in the stylesheet as well
2620
- _this.$backdrop
2621
- .removeAttr('style')
2622
- .css('transition-duration', _this.settings.backdropDuration + 'ms');
2623
- _this.outer.removeClass("lg-closing " + _this.settings.startClass);
2624
- _this.getSlideItem(_this.index).removeClass('lg-start-end-progress');
2625
- _this.$inner.empty();
2626
- if (_this.lgOpened) {
2627
- _this.LGel.trigger(lGEvents.afterClose, {
2628
- instance: _this,
2629
- });
2630
- }
2631
- if (_this.$container.get()) {
2632
- _this.$container.get().blur();
2633
- }
2634
- _this.lgOpened = false;
2635
- }, removeTimeout + 100);
2636
- return removeTimeout + 100;
2637
- };
2638
- LightGallery.prototype.initModules = function () {
2639
- this.plugins.forEach(function (module) {
2640
- try {
2641
- module.init();
2642
- }
2643
- catch (err) {
2644
- console.warn("lightGallery:- make sure lightGallery module is properly initiated");
2645
- }
2646
- });
2647
- };
2648
- LightGallery.prototype.destroyModules = function (destroy) {
2649
- this.plugins.forEach(function (module) {
2650
- try {
2651
- if (destroy) {
2652
- module.destroy();
2653
- }
2654
- else {
2655
- module.closeGallery && module.closeGallery();
2656
- }
2657
- }
2658
- catch (err) {
2659
- console.warn("lightGallery:- make sure lightGallery module is properly destroyed");
2660
- }
2661
- });
2662
- };
2663
- /**
2664
- * Refresh lightGallery with new set of children.
2665
- *
2666
- * @description This is useful to update the gallery when the child elements are changed without calling destroy method.
2667
- *
2668
- * If you are using dynamic mode, you can pass the modified array of dynamicEl as the first parameter to refresh the dynamic gallery
2669
- * @see <a href="/demos/dynamic-mode/">Demo</a>
2670
- * @category lGPublicMethods
2671
- * @example
2672
- * const plugin = lightGallery();
2673
- * // Delete or add children, then call
2674
- * plugin.refresh();
2675
- *
2676
- */
2677
- LightGallery.prototype.refresh = function (galleryItems) {
2678
- if (!this.settings.dynamic) {
2679
- this.invalidateItems();
2680
- }
2681
- if (galleryItems) {
2682
- this.galleryItems = galleryItems;
2683
- }
2684
- else {
2685
- this.galleryItems = this.getItems();
2686
- }
2687
- this.updateControls();
2688
- this.openGalleryOnItemClick();
2689
- this.LGel.trigger(lGEvents.updateSlides);
2690
- };
2691
- LightGallery.prototype.updateControls = function () {
2692
- this.addSlideVideoInfo(this.galleryItems);
2693
- this.updateCounterTotal();
2694
- this.manageSingleSlideClassName();
2695
- };
2696
- /**
2697
- * Destroy lightGallery.
2698
- * Destroy lightGallery and its plugin instances completely
2699
- *
2700
- * @description This method also calls CloseGallery function internally. Returns the time takes to completely close and destroy the instance.
2701
- * In case if you want to re-initialize lightGallery right after destroying it, initialize it only once the destroy process is completed.
2702
- * You can use refresh method most of the times.
2703
- * @category lGPublicMethods
2704
- * @example
2705
- * const plugin = lightGallery();
2706
- * plugin.destroy();
2707
- *
2708
- */
2709
- LightGallery.prototype.destroy = function () {
2710
- var _this = this;
2711
- var closeTimeout = this.closeGallery(true);
2712
- setTimeout(function () {
2713
- _this.destroyModules(true);
2714
- if (!_this.settings.dynamic) {
2715
- _this.invalidateItems();
2716
- }
2717
- $LG(window).off(".lg.global" + _this.lgId);
2718
- _this.LGel.off('.lg');
2719
- _this.$container.remove();
2720
- }, closeTimeout);
2721
- return closeTimeout;
2722
- };
2723
- return LightGallery;
2724
- }());
2725
-
2726
- function lightGallery(el, options) {
2727
- return new LightGallery(el, options);
2728
- }
2729
-
2730
- return lightGallery;
2731
-
2732
- })));
2733
- //# sourceMappingURL=lightgallery.umd.js.map
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
php/slide-anything-admin.php CHANGED
@@ -1,3492 +1,3352 @@
1
- <?php
2
- /**
3
- * #####################################################################
4
- * ### SLIDE ANYTHING PLUGIN - PHP FUNCTIONS FOR WordPress DASHBOARD ###
5
- * #####################################################################
6
- *
7
- * @package WordPress_Slide_Anything
8
- * @author Simon Edge
9
- * @copyright EdgeWebPages
10
- * @license GPLv2 or later
11
- */
12
-
13
- /**
14
- * ##### PLUGIN REGISTRATION HOOK - RUN WHEN THE PLUGIN IS ACTIVATED #####
15
- */
16
- function cpt_slider_plugin_activation() {
17
- // INSERT A 'SAMPLE SLIDER' CUSTOM POST INTO THE DATABASE.
18
- $sample_post_title = 'Sample Slider';
19
-
20
- // check if the 'sample slider' already exists (plugin has been activated before).
21
- $cpt_post = get_page_by_title( $sample_post_title, 'OBJECT', 'sa_slider' );
22
-
23
- if ( is_null( $cpt_post ) ) {
24
- // create the post object.
25
- $sample_post = array(
26
- 'post_title' => $sample_post_title,
27
- 'post_content' => '',
28
- 'post_status' => 'publish',
29
- 'post_type' => 'sa_slider',
30
- );
31
- // insert the post into the database.
32
- $cpt_id = wp_insert_post( $sample_post );
33
-
34
- // insert meta data for the 'sample slider' slides.
35
- for ( $i = 1; $i <= 8; $i++ ) {
36
- if ( 1 === $i ) {
37
- $color = '#f4cccc';
38
- $image = 'sample_logo1.png';
39
- } elseif ( 2 === $i ) {
40
- $color = '#d9ead3';
41
- $image = 'sample_logo2.png';
42
- } elseif ( 3 === $i ) {
43
- $color = '#fce5cd';
44
- $image = 'sample_logo3.png';
45
- } elseif ( 4 === $i ) {
46
- $color = '#d0e0e3';
47
- $image = 'sample_logo4.png';
48
- } elseif ( 5 === $i ) {
49
- $color = '#fff2cc';
50
- $image = 'sample_logo5.png';
51
- } elseif ( 6 === $i ) {
52
- $color = '#cfe2f3';
53
- $image = 'sample_logo6.png';
54
- } elseif ( 7 === $i ) {
55
- $color = '#d9d2e9';
56
- $image = 'sample_logo7.png';
57
- } elseif ( 8 === $i ) {
58
- $color = '#ead1dc';
59
- $image = 'sample_logo8.png';
60
- }
61
- $content = "<div style='text-align: center; padding-bottom: 10px;'>\n";
62
- $content .= "<div><img src='" . plugins_url() . '/slide-anything/images/' . $image . "' alt='Logo " . $i . "' /></div>\n";
63
- $content .= "<h3>Company Name</h3>\n";
64
- $content .= "<p>Lorem ipsum dolor sit amet, cu usu cibo vituperata, id ius probo maiestatis inciderint, sit eu vide volutpat.</p>\n";
65
- $content .= "</div>\n";
66
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_content', $content );
67
- $image_data = '~left top~contain~no-repeat~' . $color;
68
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_image_data', $image_data );
69
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_link_url', '' );
70
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_link_target', '_self' );
71
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_type', 'NONE' );
72
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_imageid', '' );
73
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_imagetitle', '' );
74
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_video_id', '' );
75
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_video_type', '' );
76
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_background', 'no' );
77
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_html', '' );
78
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_shortcode', '0' );
79
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_bgcol', '#ffffff' );
80
- update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_width', '600' );
81
- }
82
- // insert meta data for the 'sample slider' configuration.
83
- update_post_meta( $cpt_id, 'sa_disable_visual_editor', '0' );
84
- update_post_meta( $cpt_id, 'sa_num_slides', 8 );
85
- update_post_meta( $cpt_id, 'sa_slide_duration', 4 );
86
- update_post_meta( $cpt_id, 'sa_slide_transition', 0.3 );
87
- update_post_meta( $cpt_id, 'sa_slide_by', 1 );
88
- update_post_meta( $cpt_id, 'sa_loop_slider', '1' );
89
- update_post_meta( $cpt_id, 'sa_stop_hover', '1' );
90
- update_post_meta( $cpt_id, 'sa_nav_arrows', '1' );
91
- update_post_meta( $cpt_id, 'sa_pagination', '1' );
92
- update_post_meta( $cpt_id, 'sa_shortcodes', '0' );
93
- update_post_meta( $cpt_id, 'sa_random_order', '1' );
94
- update_post_meta( $cpt_id, 'sa_reverse_order', '0' );
95
- update_post_meta( $cpt_id, 'sa_mouse_drag', '0' );
96
- update_post_meta( $cpt_id, 'sa_touch_drag', '1' );
97
- update_post_meta( $cpt_id, 'sa_mousewheel', '0' );
98
- update_post_meta( $cpt_id, 'sa_click_advance', '0' );
99
- update_post_meta( $cpt_id, 'sa_auto_height', '0' );
100
- update_post_meta( $cpt_id, 'sa_vert_center', '0' );
101
- update_post_meta( $cpt_id, 'sa_items_width1', 1 );
102
- update_post_meta( $cpt_id, 'sa_items_width2', 2 );
103
- update_post_meta( $cpt_id, 'sa_items_width3', 3 );
104
- update_post_meta( $cpt_id, 'sa_items_width4', 4 );
105
- update_post_meta( $cpt_id, 'sa_items_width5', 4 );
106
- update_post_meta( $cpt_id, 'sa_items_width6', 4 );
107
- update_post_meta( $cpt_id, 'sa_transition', 'fade' );
108
- update_post_meta( $cpt_id, 'sa_hero_slider', '0' );
109
- update_post_meta( $cpt_id, 'sa_showcase_slider', '0' );
110
- update_post_meta( $cpt_id, 'sa_showcase_width', '120' );
111
- update_post_meta( $cpt_id, 'sa_showcase_tablet', '1' );
112
- update_post_meta( $cpt_id, 'sa_showcase_width_tab', '130' );
113
- update_post_meta( $cpt_id, 'sa_showcase_mobile', '0' );
114
- update_post_meta( $cpt_id, 'sa_showcase_width_mob', '140' );
115
- update_post_meta( $cpt_id, 'sa_css_id', 'sample_slider' );
116
- update_post_meta( $cpt_id, 'sa_background_color', '#fafafa' );
117
- update_post_meta( $cpt_id, 'sa_border_width', 1 );
118
- update_post_meta( $cpt_id, 'sa_border_color', '#f0f0f0' );
119
- update_post_meta( $cpt_id, 'sa_border_radius', 5 );
120
- update_post_meta( $cpt_id, 'sa_wrapper_padd_top', 8 );
121
- update_post_meta( $cpt_id, 'sa_wrapper_padd_right', 8 );
122
- update_post_meta( $cpt_id, 'sa_wrapper_padd_bottom', 8 );
123
- update_post_meta( $cpt_id, 'sa_wrapper_padd_left', 8 );
124
- update_post_meta( $cpt_id, 'sa_slide_min_height_perc', 50 );
125
- update_post_meta( $cpt_id, 'sa_slide_padding_tb', 5 );
126
- update_post_meta( $cpt_id, 'sa_slide_padding_lr', 5 );
127
- update_post_meta( $cpt_id, 'sa_slide_margin_lr', 0 );
128
- update_post_meta( $cpt_id, 'sa_autohide_arrows', '1' );
129
- update_post_meta( $cpt_id, 'sa_dot_per_slide', '0' );
130
- update_post_meta( $cpt_id, 'sa_slide_icons_location', 'Center Center' );
131
- update_post_meta( $cpt_id, 'sa_slide_icons_visible', '0' );
132
- update_post_meta( $cpt_id, 'sa_slide_icons_color', 'white' );
133
- update_post_meta( $cpt_id, 'sa_thumbs_active', '0' );
134
- update_post_meta( $cpt_id, 'sa_thumbs_location', 'Inside Bottom' );
135
- update_post_meta( $cpt_id, 'sa_thumbs_image_size', 'thumbnail' );
136
- update_post_meta( $cpt_id, 'sa_thumbs_padding', 3 );
137
- update_post_meta( $cpt_id, 'sa_thumbs_width', 150 );
138
- update_post_meta( $cpt_id, 'sa_thumbs_height', 85 );
139
- update_post_meta( $cpt_id, 'sa_thumbs_opacity', 50 );
140
- update_post_meta( $cpt_id, 'sa_thumbs_border_width', 0 );
141
- update_post_meta( $cpt_id, 'sa_thumbs_border_color', '#ffffff' );
142
- update_post_meta( $cpt_id, 'sa_thumbs_resp_tablet', 75 );
143
- update_post_meta( $cpt_id, 'sa_thumbs_resp_mobile', 50 );
144
- }
145
- }
146
-
147
- /**
148
- * ##### ADD CHECKBOX OPTION UNDER "Settings -> Writing" CALLED "Disable TinyMCE Button" #####
149
- */
150
- function cpt_slider_disable_tinymce_button_setting() {
151
- // REGISTER WordPress SETTING.
152
- register_setting(
153
- 'writing',
154
- 'sa-disable-tinymce-button',
155
- 'cpt_slider_writing_settings_sanitize'
156
- );
157
- // CREATE SETTINGS SECTION (within "Settings->Writing").
158
- add_settings_section(
159
- 'sa-writing-settings-section',
160
- 'Slide Anything Settings',
161
- 'cpt_slider_writing_settings_section_description',
162
- 'writing'
163
- );
164
- // CREATE SETTINGS INPUT FIELD.
165
- add_settings_field(
166
- 'sa-settings-field1',
167
- 'Disable TinyMCE Button',
168
- 'cpt_slider_writing_settings_field1_callback',
169
- 'writing',
170
- 'sa-writing-settings-section'
171
- );
172
- }
173
-
174
- /**
175
- * ##### SANATIZE SETTINGS CALLBACK FUNCTION #####
176
- *
177
- * @param string $input Disable TinyMCE Button checkbox.
178
- */
179
- function cpt_slider_writing_settings_sanitize( $input ) {
180
- return isset( $input ) ? true : false;
181
- }
182
- /**
183
- * ##### SETTING SECTION DESCRIPTION #####
184
- */
185
- function cpt_slider_writing_settings_section_description() {
186
- echo esc_html( "Disable the 'Slide Anything Sliders' button within the toolbar of the WordPress Classic Editor when editing pages and posts." );
187
- }
188
- /**
189
- * ##### SETTINGS INPUT FIELD CALLBACK #####
190
- */
191
- function cpt_slider_writing_settings_field1_callback() {
192
- ?>
193
- <label for="sa-disable-tinymce-input">
194
- <input id="sa-disable-tinymce-input" type="checkbox" value="1" name="sa-disable-tinymce-button" <?php checked( get_option( 'sa-disable-tinymce-button', false ) ); ?>>
195
- </label>
196
- <?php
197
- }
198
-
199
- /**
200
- * ##### ACTION HOOK - REGISTER SCRIPTS (JS AND CSS) FOR WordPress DASHBOARD ONLY #####
201
- */
202
- function cpt_slider_register_admin_scripts() {
203
- $screen = get_current_screen();
204
- $plugin_path = dirname( __FILE__ ) . '/../slide-anything.php';
205
- $plugin_data = get_plugin_data( $plugin_path, false, false );
206
- $plugin_ver = $plugin_data['Version'];
207
- if ( 'sa_slider' === $screen->post_type ) {
208
- // ONLY LOAD SCRIPTS (JS & CSS) WITHIN 'Slide Anything' SCREENS IN WordPress DASHBOARD.
209
- // enqueues all scripts, styles & settings required in order to use the WordPress Media JS APIs.
210
- wp_enqueue_media();
211
- // load 'WordPress jquery-ui' scripts.
212
- wp_enqueue_script( 'jquery-ui-core' );
213
- wp_enqueue_script( 'jquery-ui-accordion' );
214
- wp_enqueue_script( 'jquery-ui-tabs' );
215
- wp_enqueue_script( 'jquery-ui-slider' );
216
- wp_enqueue_script( 'jquery-ui-sortable' );
217
- wp_enqueue_script( 'jquery-ui-draggable' );
218
- wp_enqueue_script( 'jquery-ui-droppable' );
219
- wp_enqueue_script( 'jquery-ui-resize' );
220
- wp_enqueue_script( 'jquery-ui-dialog' );
221
- wp_enqueue_script( 'jquery-ui-button' );
222
- wp_enqueue_script( 'jquery-ui-tooltip' );
223
- wp_enqueue_script( 'jquery-ui-spinner' );
224
- // load 'spectrum colorpicker' script and css.
225
- wp_register_script( 'spectrum_js', SA_PLUGIN_PATH . 'spectrum/spectrum.js', array( 'jquery' ), '1.8.0', true );
226
- wp_enqueue_script( 'spectrum_js' );
227
- wp_register_style( 'spectrum_css', SA_PLUGIN_PATH . 'spectrum/spectrum.css', array(), '1.8.0' );
228
- wp_enqueue_style( 'spectrum_css' );
229
- // load 'jquery-ui' css.
230
- wp_register_style( 'admin_ui_css', SA_PLUGIN_PATH . 'css/admin-user-interface.min.css', array(), '1.11.4' );
231
- wp_enqueue_style( 'admin_ui_css' );
232
- // load 'slide-anything' custom javasript and css for WordPress admin.
233
- wp_register_script( 'sa-slider-admin-script', SA_PLUGIN_PATH . 'js/slide-anything-admin.js', array( 'jquery' ), $plugin_ver, true );
234
- wp_enqueue_script( 'sa-slider-admin-script' );
235
- wp_register_style( 'sa-slider-admin-css', SA_PLUGIN_PATH . 'css/slide-anything-admin.css', array(), $plugin_ver );
236
- wp_enqueue_style( 'sa-slider-admin-css' );
237
- // load 'magnific popup' script and css.
238
- wp_register_script( 'magnific-popup_js', SA_PLUGIN_PATH . 'magnific-popup/jquery.magnific-popup.min.js', array( 'jquery' ), '1.1.0', true );
239
- wp_enqueue_script( 'magnific-popup_js' );
240
- wp_register_style( 'magnific-popup_css', SA_PLUGIN_PATH . 'magnific-popup/magnific-popup.css', array(), '1.1.0' );
241
- wp_enqueue_style( 'magnific-popup_css' );
242
- // DISABLE AUTOSAVE FOR THIS CUSTOM POST TYPE (causes issues with preview modal popup).
243
- wp_dequeue_script( 'autosave' );
244
- }
245
- if ( 'settings_page_sa-settings-page' === $screen->id ) {
246
- // SLIDE ANYTHING SETTINGS PAGE - load custom css script.
247
- wp_register_style( 'sa-slider-admin-css', SA_PLUGIN_PATH . 'css/slide-anything-admin.css', array(), $plugin_ver );
248
- wp_enqueue_style( 'sa-slider-admin-css' );
249
- }
250
- // style for TINYMCE editor 'Slide Anything sliders' button.
251
- wp_register_style( 'tinymce-css', SA_PLUGIN_PATH . 'css/tinymce_style.css', array(), $plugin_ver );
252
- wp_enqueue_style( 'tinymce-css' );
253
- }
254
-
255
-
256
-
257
- /**
258
- * ##### ACTION HOOK - REGISTER THE 'Slide Anything' CUSTOM POST TYPE #####
259
- */
260
- function cpt_slider_register() {
261
- $labels = array(
262
- 'name' => _x( 'SA Sliders', 'post type general name', 'sa_slider_textdomain' ),
263
- 'singular_name' => _x( 'Slider', 'post type singular name', 'sa_slider_textdomain' ),
264
- 'menu_name' => __( 'SA Sliders', 'sa_slider_textdomain' ),
265
- 'add_new' => __( 'Add New Slider', 'sa_slider_textdomain' ),
266
- 'add_new_item' => __( 'Add New Slider', 'sa_slider_textdomain' ),
267
- 'edit_item' => __( 'Edit Slider', 'sa_slider_textdomain' ),
268
- 'new_item' => __( 'New Slider', 'sa_slider_textdomain' ),
269
- 'view_item' => __( 'View Slider', 'sa_slider_textdomain' ),
270
- 'not_found' => __( 'No sliders found', 'sa_slider_textdomain' ),
271
- 'not_found_in_trash' => __( 'No sliders found in Trash', 'sa_slider_textdomain' ),
272
- );
273
- $args = array(
274
- 'labels' => $labels,
275
- 'description' => __( 'Slide Anything carousel/slider', 'sa_slider_textdomain' ),
276
- 'public' => false,
277
- 'exclude_from_search' => true,
278
- 'publicly_queryable' => false,
279
- 'show_ui' => true,
280
- 'show_in_nav_menus' => false,
281
- 'show_in_menu' => true,
282
- 'menu_position' => 10,
283
- 'menu_icon' => 'dashicons-images-alt2',
284
- 'hierarchical' => false,
285
- 'supports' => array( 'title' ),
286
- 'has_archive' => false,
287
- 'query_var' => false,
288
- 'can_export' => true,
289
- 'rewrite' => true,
290
- 'capability_type' => 'post',
291
- );
292
- register_post_type( 'sa_slider', $args );
293
- }
294
-
295
-
296
-
297
- /**
298
- * ##### WP DASHBOARD - SLIDER LIST PAGE #####
299
- * ACTION HOOK - ADD/REMOVE (HOVER-OVER) ROW ACTIONS WHEN THIS CUSTOM POST TYPE IS LISTED IN DASHBOARD
300
- *
301
- * @param array $actions Row Actions.
302
- * @param array $post Post Type.
303
- */
304
- function cpt_slider_row_actions( $actions, $post ) {
305
- if ( 'sa_slider' === $post->post_type ) {
306
- // REMOVE 'Quick Edit' ROW ACTION.
307
- unset( $actions['inline hide-if-no-js'] );
308
- }
309
- return $actions;
310
- }
311
-
312
- /**
313
- * ##### FILTER TO ADD/REMOVE COLUMNS DISPLAYED FOR THIS CUSTOM POST TYPE IN DASHBOARD #####
314
- *
315
- * @param array $columns Post List Columns.
316
- */
317
- function cpt_slider_modify_columns( $columns ) {
318
- // new columns to be added.
319
- $new_columns = array(
320
- 'slides' => 'Slides',
321
- 'shortcode' => 'Shortcode',
322
- 'css-id' => 'CSS ID',
323
- );
324
- $columns = array_slice( $columns, 0, 2, true ) + $new_columns + array_slice( $columns, 2, null, true );
325
- return $columns;
326
- }
327
-
328
- /**
329
- * ##### DEFINE OUTPUT FOR EACH CUSTOM COLUMN DISPLAYED FOR THIS POST TYPE IN THE DASHBOARD #####
330
- *
331
- * @param array $column Post List Column.
332
- */
333
- function cpt_slider_custom_column_content( $column ) {
334
- // get post object for this row.
335
- global $post;
336
-
337
- // output for the 'Slides' column.
338
- if ( 'slides' === $column ) {
339
- $num_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
340
- if ( '' === $num_slides ) {
341
- $num_slides = '-';
342
- }
343
- echo esc_html( $num_slides );
344
- }
345
-
346
- // output for the 'Shortcode' column.
347
- if ( 'shortcode' === $column ) {
348
- $shortcode = "[slide-anything id='" . $post->ID . "']";
349
- echo esc_html( $shortcode );
350
- }
351
-
352
- // output for the 'CSS ID' column.
353
- if ( 'css-id' === $column ) {
354
- $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
355
- if ( '' === $css_id ) {
356
- $css_id = '-';
357
- } else {
358
- $css_id = '#' . $css_id;
359
- }
360
- echo esc_html( $css_id );
361
- }
362
- }
363
-
364
-
365
-
366
- /**
367
- * ##### ADD A CUSTOM BUTTON TO WordPress TINYMCE EDITOR (ON PAGES AND POSTS ONLY) #####
368
- */
369
- function cpt_slider_add_tinymce_button() {
370
- global $typenow;
371
- // check user permissions.
372
- if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
373
- return;
374
- }
375
- // verify the post type - only display button on posts and pages.
376
- if ( ! in_array( $typenow, array( 'post', 'page' ), true ) ) {
377
- return;
378
- }
379
- // check if WYSIWYG is enabled.
380
- if ( 'true' === get_user_option( 'rich_editing' ) ) {
381
- add_filter( 'mce_external_plugins', 'cpt_slider_add_tinymce_plugin' );
382
- add_filter( 'mce_buttons', 'cpt_slider_register_tinymce_button' );
383
- }
384
- }
385
-
386
- /**
387
- * ##### FILTER HOOK: mce_external_plugins #####
388
- *
389
- * @param array $plugin_array Plugin Array.
390
- */
391
- function cpt_slider_add_tinymce_plugin( $plugin_array ) {
392
- $plugin_array['tinymce_button'] = SA_PLUGIN_PATH . 'js/add_tinymce_button.js';
393
- return $plugin_array;
394
- }
395
-
396
- /**
397
- * ##### FILTER HOOK: mce_buttons #####
398
- *
399
- * @param array $buttons TinyMCE buttons.
400
- */
401
- function cpt_slider_register_tinymce_button( $buttons ) {
402
- array_push( $buttons, 'tinymce_button' );
403
- return $buttons;
404
- }
405
-
406
- /**
407
- * ##### ACTION HOOK: admin_footer #####
408
- */
409
- function cpt_slider_get_tinymce_shortcode_array() {
410
- $screen = get_current_screen();
411
- if ( 'envira' !== $screen->post_type ) { // ### BUG FIX - CLASHING WITH ENVIRA GALLERY (VER 2.0.13) ###.
412
- // display 2 javascript arrays (in footer) containing all the slide anything post titles and post ids.
413
- // these 2 arrays are used to display the shortcode options by the TinyMCE button.
414
- echo "<script type='text/javascript'>\n";
415
- echo "var sa_title_arr = new Array();\n";
416
- echo "var sa_id_arr = new Array();\n";
417
-
418
- $args = array(
419
- 'post_type' => 'sa_slider',
420
- 'post_status' => 'publish',
421
- 'posts_per_page' => -1,
422
- );
423
- $sa_slider_query = new WP_Query( $args );
424
- $count = 0;
425
- foreach ( $sa_slider_query->posts as $sa_post ) {
426
- $title = $sa_post->post_title;
427
- echo 'sa_title_arr[' . esc_js( $count ) . "] = '" . esc_js( $title ) . "';\n";
428
- echo 'sa_id_arr[' . esc_js( $count ) . "] = '" . esc_js( $sa_post->ID ) . "';\n";
429
- $count++;
430
- }
431
- echo "</script>\n";
432
- }
433
- }
434
-
435
-
436
-
437
- /**
438
- * ##### ACTION HOOK - ADD META BOXES TO THE 'Slide Anything' CUSTOM POST TYPE #####
439
- */
440
- function cpt_slider_add_meta_boxes() {
441
- global $post;
442
- global $current_user;
443
- if ( ! is_object( $post ) ) {
444
- return;
445
- }
446
-
447
- $info_added = get_post_meta( $post->ID, 'sa_info_added', true );
448
- $info_deleted = get_post_meta( $post->ID, 'sa_info_deleted', true );
449
- $info_duplicated = get_post_meta( $post->ID, 'sa_info_duplicated', true );
450
- $info_moved = get_post_meta( $post->ID, 'sa_info_moved', true );
451
- if ( '1' === $info_added ) {
452
- add_meta_box( 'cpt_slide_added', __( 'Information' ), 'cpt_slide_added_content', 'sa_slider', 'normal', 'high' );
453
- update_post_meta( $post->ID, 'sa_info_added', '0' );
454
- }
455
- if ( '1' === $info_deleted ) {
456
- add_meta_box( 'cpt_slide_deleted', __( 'Information' ), 'cpt_slide_deleted_content', 'sa_slider', 'normal', 'high' );
457
- update_post_meta( $post->ID, 'sa_info_deleted', '0' );
458
- }
459
- if ( '1' === $info_duplicated ) {
460
- add_meta_box( 'cpt_slide_duplicated', __( 'Information' ), 'cpt_slide_duplicated_content', 'sa_slider', 'normal', 'high' );
461
- update_post_meta( $post->ID, 'sa_info_duplicated', '0' );
462
- }
463
- if ( '1' === $info_moved ) {
464
- add_meta_box( 'cpt_slide_moved', __( 'Information' ), 'cpt_slide_moved_content', 'sa_slider', 'normal', 'high' );
465
- update_post_meta( $post->ID, 'sa_info_moved', '0' );
466
- }
467
- add_meta_box( 'cpt_slider_settings', __( 'Slider Settings' ), 'cpt_slider_settings_content', 'sa_slider', 'normal', 'high' );
468
- add_meta_box( 'cpt_slider_slides', __( 'Slides' ), 'cpt_slider_slides_content', 'sa_slider', 'normal', 'high' );
469
- add_meta_box( 'cpt_slider_shortcode', __( 'Shortcode / Preview' ), 'cpt_slider_shortcode_content', 'sa_slider', 'side', 'high' );
470
- add_meta_box( 'cpt_slider_items', __( 'Items Displayed' ), 'cpt_slider_items_content', 'sa_slider', 'side', 'default' );
471
- add_meta_box( 'cpt_slider_style', __( 'Slider Style' ), 'cpt_slider_style_content', 'sa_slider', 'side', 'default' );
472
- add_meta_box( 'cpt_slider_thumbs', __( 'Thumbnail Pagination' ), 'cpt_slider_thumbs_content', 'sa_slider', 'side', 'default' );
473
- remove_meta_box( 'mymetabox_revslider_0', 'sa_slider', 'normal' ); // remove revolution slider meta box.
474
- }
475
-
476
-
477
-
478
- /**
479
- * ##### META BOX CONTENT - 'Information' (slide added) BOX #####
480
- */
481
- function cpt_slide_added_content() {
482
- echo "<h3 id='sa_slide_added_mess'>A new slide has been added to this slider.</h3>";
483
- }
484
-
485
-
486
-
487
- /**
488
- * ##### META BOX CONTENT - 'Information' (slide deleted) BOX #####
489
- */
490
- function cpt_slide_deleted_content() {
491
- echo "<h3 id='sa_slide_deleted_mess'>A slide has been deleted from this slider.</h3>";
492
- }
493
-
494
-
495
-
496
- /**
497
- * ##### META BOX CONTENT - 'Information' (slide duplicated) BOX #####
498
- */
499
- function cpt_slide_duplicated_content() {
500
- echo "<h3 id='sa_slide_duplicated_mess'>A slide has been duplicated (copied) within this slider.</h3>";
501
- }
502
-
503
-
504
-
505
- /**
506
- * ##### META BOX CONTENT - 'Information' (slide moved) BOX #####
507
- */
508
- function cpt_slide_moved_content() {
509
- echo "<h3 id='sa_slide_moved_mess'>The slide order of this slider has been has changed.</h3>";
510
- }
511
-
512
-
513
-
514
- /**
515
- * // ##### META BOX CONTENT - 'Slider Settings' BOX #####
516
- *
517
- * @param array $post Custom Post 'sa_slider'.
518
- */
519
- function cpt_slider_settings_content( $post ) {
520
- $num_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
521
- echo "<div id='sa_slider_settings'>\n";
522
-
523
- // NONCE TO PREVENT CSRF SECURITY ATTACKS.
524
- wp_nonce_field( basename( __FILE__ ), 'nonce_save_slider' );
525
-
526
- // HIDDEN FIELD - NUMBER OF SLIDES.
527
- if ( '' === $num_slides ) {
528
- // new slider is being created.
529
- echo "<input type='hidden' id='num_slides_id' name='sa_num_slides' value='3'/>\n";
530
- } else {
531
- // existing slider.
532
- $num_slides = intval( $num_slides );
533
- echo "<input type='hidden' id='num_slides_id' name='sa_num_slides' value='" . esc_attr( $num_slides ) . "'/>\n";
534
- }
535
- // HIDDEN FIELD - SLIDE ADDED INDICATOR.
536
- echo "<input type='hidden' id='sa_info_added' name='sa_info_added' value='0'/>\n";
537
- // HIDDEN FIELD - SLIDE DELETED INDICATOR.
538
- echo "<input type='hidden' id='sa_info_deleted' name='sa_info_deleted' value='0'/>\n";
539
- // HIDDEN FIELD - SLIDE DUPLICATED INDICATOR.
540
- echo "<input type='hidden' id='sa_info_duplicated' name='sa_info_duplicated' value='0'/>\n";
541
- // HIDDEN FIELD - SLIDE MOVED UP INDICATOR.
542
- echo "<input type='hidden' id='sa_info_moved' name='sa_info_moved' value='0'/>\n";
543
- // HIDDEN FIELD - DUPLICATE SLIDE NUMBER.
544
- echo "<input type='hidden' id='sa_duplicate_slide' name='sa_duplicate_slide' value='0'/>\n";
545
- // HIDDEN FIELD - MOVE SLIDE UP (SLIDE NUMBER).
546
- echo "<input type='hidden' id='sa_move_slide_up' name='sa_move_slide_up' value='0'/>\n";
547
- // HIDDEN FIELD - PRO VERSION.
548
- echo "<input type='hidden' id='sa_pro_version' name='sa_pro_version' value='1'/>\n";
549
- // SLIDE DURATION.
550
- $slide_duration = get_post_meta( $post->ID, 'sa_slide_duration', true );
551
- if ( '' === $slide_duration ) {
552
- $slide_duration = 5;
553
- }
554
- echo "<div class='sa_slider_value'><span>Slide Duration:</span>";
555
- echo "<input type='text' id='sa_slide_duration' name='sa_slide_duration' readonly value='" . esc_attr( $slide_duration ) . "'><em>seconds (0 = manual navigation)</em>";
556
- echo "<em class='sa_tooltip' href='' title='Set to 0 to disable slider autoplay (manual slider navigation only)'></em></div>\n";
557
- echo "<div class='jquery_ui_slider' id='jq_slider_duration'></div><hr/>\n";
558
- // SLIDE TRANSITION.
559
- $slide_transition = get_post_meta( $post->ID, 'sa_slide_transition', true );
560
- if ( '' === $slide_transition ) {
561
- $slide_transition = 0.2;
562
- }
563
- echo "<div class='sa_slider_value'><span>Slide Transition:</span>";
564
- echo "<input type='text' id='sa_slide_transition' name='sa_slide_transition' readonly value='" . esc_attr( $slide_transition ) . "'><em>seconds</em>\n";
565
- echo "<em class='sa_tooltip' href='' title='The time it takes to change from one slide to the next slide'></em></div>\n";
566
- echo "<div class='jquery_ui_slider' id='jq_slider_transition'></div><hr/>\n";
567
- // SLIDE BY.
568
- $slide_by = get_post_meta( $post->ID, 'sa_slide_by', true );
569
- if ( '' === $slide_by ) {
570
- $slide_by = 1;
571
- }
572
- echo "<div class='sa_slider_value'><span>Slide By:</span>";
573
- echo "<input type='text' id='sa_slide_by' name='sa_slide_by' readonly value='" . esc_attr( $slide_by ) . "'><em>slides (0 = slide by page)</em>";
574
- echo "<em class='sa_tooltip' href='' title='The number of slides to slide per transition. Set to 0 to enable the Slide by Page option.'></em></div>\n";
575
- echo "<div class='jquery_ui_slider' id='jq_slider_by'></div><hr/>\n";
576
- echo "<div class='half_width_column'>\n";
577
- // LOOP SLIDER.
578
- $loop_slider = get_post_meta( $post->ID, 'sa_loop_slider', true );
579
- if ( '' === $loop_slider ) {
580
- $loop_slider = '1';
581
- }
582
- echo "<div class='sa_setting_checkbox'><span>Loop Slider:</span>";
583
- if ( '1' === $loop_slider ) {
584
- echo "<input type='checkbox' id='sa_loop_slider' name='sa_loop_slider' value='1' checked/>";
585
- } else {
586
- echo "<input type='checkbox' id='sa_loop_slider' name='sa_loop_slider' value='1'/>";
587
- }
588
- echo "<em class='sa_tooltip' href='' title='Only applies when slide duration is NOT zero (loops back to first slide after last slide is displayed)'></em>";
589
- echo "</div>\n";
590
- // STOP ON HOVER.
591
- $stop_hover = get_post_meta( $post->ID, 'sa_stop_hover', true );
592
- if ( '' === $stop_hover ) {
593
- $stop_hover = '1';
594
- }
595
- echo "<div class='sa_setting_checkbox'><span>Stop on Hover:</span>";
596
- if ( '1' === $stop_hover ) {
597
- echo "<input type='checkbox' id='sa_stop_hover' name='sa_stop_hover' value='1' checked/>";
598
- } else {
599
- echo "<input type='checkbox' id='sa_stop_hover' name='sa_stop_hover' value='1'/>";
600
- }
601
- echo "<em class='sa_tooltip' href='' title='Only applies when slide duration is NOT zero (slideshow is paused when hovering over a slide)'></em>";
602
- echo "</div>\n";
603
- // RANDOM ORDER.
604
- $random_order = get_post_meta( $post->ID, 'sa_random_order', true );
605
- if ( '' === $random_order ) {
606
- $random_order = '0';
607
- }
608
- echo "<div class='sa_setting_checkbox'><span>Random Order:</span>";
609
- if ( '1' === $random_order ) {
610
- echo "<input type='checkbox' id='sa_random_order' name='sa_random_order' value='1' checked/>";
611
- } else {
612
- echo "<input type='checkbox' id='sa_random_order' name='sa_random_order' value='1'/>";
613
- }
614
- echo "<em class='sa_tooltip' title='When checked slides will be randomly re-ordered whenever the slider is displayed'></em>";
615
- echo "</div>\n";
616
- // REVERSE ORDER.
617
- $reverse_order = get_post_meta( $post->ID, 'sa_reverse_order', true );
618
- if ( '' === $reverse_order ) {
619
- $reverse_order = '0';
620
- }
621
- echo "<div class='sa_setting_checkbox'><span>Reverse Order:</span>";
622
- if ( '1' === $reverse_order ) {
623
- echo "<input type='checkbox' id='sa_reverse_order' name='sa_reverse_order' value='1' checked/>";
624
- } else {
625
- echo "<input type='checkbox' id='sa_reverse_order' name='sa_reverse_order' value='1'/>";
626
- }
627
- echo "<em class='sa_tooltip' title='When checked your slides will be shown in the reverse order (i.e. last slide first)'></em>";
628
- echo "</div>\n";
629
- // ALLOW SHORTCODES.
630
- $shortcodes = get_post_meta( $post->ID, 'sa_shortcodes', true );
631
- if ( '' === $shortcodes ) {
632
- $shortcodes = '0';
633
- }
634
- echo "<div class='sa_setting_checkbox'><span>Allow Shortcodes:</span>";
635
- if ( '1' === $shortcodes ) {
636
- echo "<input type='checkbox' id='sa_shortcodes' name='sa_shortcodes' value='1' checked/>";
637
- } else {
638
- echo "<input type='checkbox' id='sa_shortcodes' name='sa_shortcodes' value='1'/>";
639
- }
640
- echo "<em class='sa_tooltip' href='' title='Include WordPree shorcodes within slide content. NOTE: Running shortcodes in Slide Anything may cause issues with some WordPress Page Builders'></em>\n";
641
- echo "</div>\n";
642
- // VERTICAL CENTER.
643
- $vert_center = get_post_meta( $post->ID, 'sa_vert_center', true );
644
- if ( '' === $vert_center ) {
645
- $vert_center = '0';
646
- }
647
- echo "<div class='sa_setting_checkbox'><span>Vertical Center:</span>";
648
- if ( '1' === $vert_center ) {
649
- echo "<input type='checkbox' id='sa_vert_center' name='sa_vert_center' value='1' checked/>";
650
- } else {
651
- echo "<input type='checkbox' id='sa_vert_center' name='sa_vert_center' value='1'/>";
652
- }
653
- echo "<em class='sa_tooltip' title='Vertically center content within slides. Only use this setting if you have set a Min Height for your slider (which sets a minimum height for each slide).'></em>";
654
- echo "</div>\n";
655
- echo "</div>\n";
656
- echo "<div class='half_width_column'>\n";
657
- // NAVIGATE ARROWS.
658
- $nav_arrows = get_post_meta( $post->ID, 'sa_nav_arrows', true );
659
- if ( '' === $nav_arrows ) {
660
- $nav_arrows = '1';
661
- }
662
- echo "<div class='sa_setting_checkbox'><span>Navigate Arrows:</span>";
663
- if ( '1' === $nav_arrows ) {
664
- echo "<input type='checkbox' id='sa_nav_arrows' name='sa_nav_arrows' value='1' checked/>";
665
- } else {
666
- echo "<input type='checkbox' id='sa_nav_arrows' name='sa_nav_arrows' value='1'/>";
667
- }
668
- echo "<em class='sa_tooltip' href='' title='Display the \"next slide\" amd \"previous slide\" buttons'></em>\n";
669
- echo "</div>\n";
670
- // SHOW PAGINATION.
671
- $pagination = get_post_meta( $post->ID, 'sa_pagination', true );
672
- if ( '' === $pagination ) {
673
- $pagination = '1';
674
- }
675
- echo "<div class='sa_setting_checkbox'><span>Show Pagination:</span>";
676
- if ( '1' === $pagination ) {
677
- echo "<input type='checkbox' id='sa_pagination' name='sa_pagination' value='1' checked/>";
678
- } else {
679
- echo "<input type='checkbox' id='sa_pagination' name='sa_pagination' value='1'/>";
680
- }
681
- echo "<em class='sa_tooltip' href='' title='Display slider pagination below the slider'></em>\n";
682
- echo "</div>\n";
683
-
684
- // MOUSE DRAG.
685
- $mouse_drag = get_post_meta( $post->ID, 'sa_mouse_drag', true );
686
- if ( '' === $mouse_drag ) {
687
- $mouse_drag = '0';
688
- }
689
- echo "<div class='sa_setting_checkbox'><span>Mouse Drag:</span>";
690
- if ( '1' === $mouse_drag ) {
691
- echo "<input type='checkbox' id='sa_mouse_drag' name='sa_mouse_drag' value='1' checked/>";
692
- } else {
693
- echo "<input type='checkbox' id='sa_mouse_drag' name='sa_mouse_drag' value='1'/>";
694
- }
695
- echo "<em class='sa_tooltip' href='' title='Allow navigation to previous/next slides by holding down left mouse button and dragging left/right. (NOTE: Enabling this option will disable vertical touch-drag scrolling on mobile devices)'></em>\n";
696
- echo "</div>\n";
697
- // TOUCH DRAG.
698
- $touch_drag = get_post_meta( $post->ID, 'sa_touch_drag', true );
699
- if ( '' === $touch_drag ) {
700
- $touch_drag = '1';
701
- }
702
- echo "<div class='sa_setting_checkbox'><span>Touch Drag:</span>";
703
- if ( '1' === $touch_drag ) {
704
- echo "<input type='checkbox' id='sa_touch_drag' name='sa_touch_drag' value='1' checked/>";
705
- } else {
706
- echo "<input type='checkbox' id='sa_touch_drag' name='sa_touch_drag' value='1'/>";
707
- }
708
- echo "<em class='sa_tooltip' href='' title='Allow navigation to previous/next slides on mobile devices by touching screen and dragging left/right'></em>\n";
709
- echo "</div>\n";
710
- // MOUSEWHEEL NAV.
711
- $mousewheel = get_post_meta( $post->ID, 'sa_mousewheel', true );
712
- if ( '' === $mousewheel ) {
713
- $mousewheel = '0';
714
- }
715
- echo "<div class='sa_setting_checkbox'><span>Mousewheel Nav:</span>";
716
- if ( '1' === $mousewheel ) {
717
- echo "<input type='checkbox' id='sa_mousewheel' name='sa_mousewheel' value='1' checked/>";
718
- } else {
719
- echo "<input type='checkbox' id='sa_mousewheel' name='sa_mousewheel' value='1'/>";
720
- }
721
- echo "<em class='sa_tooltip' href='' title='Allow previous/next slide navigation using the mousewheel (NOTE: does not work well with the Apple Mac touchpad scroll wheel mimic)'></em>\n";
722
- echo "</div>\n";
723
- // CLICK TO ADVANCE.
724
- $click_advance = get_post_meta( $post->ID, 'sa_click_advance', true );
725
- if ( '' === $click_advance ) {
726
- $click_advance = '0';
727
- }
728
- echo "<div class='sa_setting_checkbox'><span>Click to Advance:</span>";
729
- if ( '1' === $click_advance ) {
730
- echo "<input type='checkbox' id='sa_click_advance' name='sa_click_advance' value='1' checked/>";
731
- } else {
732
- echo "<input type='checkbox' id='sa_click_advance' name='sa_click_advance' value='1'/>";
733
- }
734
- echo "<em class='sa_tooltip' href='' title='Clicking on the slider advances to the next slide. NOTE: Only works when the Mouse Drag and Touch Drag options are NOT checked.'></em>\n";
735
- echo "</div>\n";
736
- // AUTO HEIGHT.
737
- $auto_height = get_post_meta( $post->ID, 'sa_auto_height', true );
738
- if ( '' === $auto_height ) {
739
- $auto_height = '0';
740
- }
741
- echo "<div class='sa_setting_checkbox'><span>Auto Height:</span>";
742
- if ( '1' === $auto_height ) {
743
- echo "<input type='checkbox' id='sa_auto_height' name='sa_auto_height' value='1' checked/>";
744
- } else {
745
- echo "<input type='checkbox' id='sa_auto_height' name='sa_auto_height' value='1'/>";
746
- }
747
- echo "<em class='sa_tooltip' title='Only works with 1 item on the screen. When checked the height of slider is automatically changed to match the height for each slide.'></em>";
748
- echo "</div>\n";
749
- echo "</div>\n";
750
- echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
751
- echo "</div>\n";
752
- }
753
-
754
-
755
-
756
- /**
757
- * ##### META BOX CONTENT - 'Slides' BOX #####
758
- *
759
- * @param array $post Custom Post 'sa_slider'.
760
- */
761
- function cpt_slider_slides_content( $post ) {
762
- $num_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
763
- $slider_css_id = get_post_meta( $post->ID, 'sa_css_id', true );
764
- // DISABLE VISUAL EDITOR CHECKBOX.
765
- $disable_visual_editor = get_post_meta( $post->ID, 'sa_disable_visual_editor', true );
766
- if ( '' === $disable_visual_editor ) {
767
- $disable_visual_editor = '0';
768
- }
769
- echo "<div id='sa_visual_editor_checkbox'><span>Disable Visual Editor:</span>";
770
- if ( '1' === $disable_visual_editor ) {
771
- echo "<input type='checkbox' id='sa_disable_visual_editor' name='sa_disable_visual_editor' value='1' checked/></div>\n";
772
- } else {
773
- echo "<input type='checkbox' id='sa_disable_visual_editor' name='sa_disable_visual_editor' value='1'/></div>\n";
774
- }
775
- // SLIDER EDITOR BOX SETTINGS.
776
- if ( '1' === $disable_visual_editor ) {
777
- $editor_args = array(
778
- 'tinymce' => false,
779
- 'wpautop' => false,
780
- 'media_buttons' => true,
781
- 'editor_class' => 'sa_slide_content',
782
- 'editor_height' => '250',
783
- );
784
- } else {
785
- $editor_args = array(
786
- 'tinymce' => true,
787
- 'wpautop' => false,
788
- 'media_buttons' => true,
789
- 'editor_class' => 'sa_slide_content',
790
- 'editor_height' => '250',
791
- );
792
- }
793
- if ( '' === $num_slides ) {
794
- // A NEW SLIDER IS BEING CREATED - ADD 3 INITIAL SLIDES.
795
- $num_slides = 3;
796
- $slide_data[0]['edit_id'] = 'sa_slide1_content';
797
- $slide_data[0]['content'] = 'Slide content';
798
- $slide_data[0]['del_id'] = 'sa_slide1_delete';
799
- $slide_data[0]['image_data'] = 'sa_slide1_image_data';
800
- $slide_data[0]['image_id'] = 'sa_slide1_image_id';
801
- $slide_data[0]['thumb'] = 'slide1_thumb';
802
- $slide_data[0]['image_del'] = 'slide1_image_del';
803
- $slide_data[0]['image_pos'] = 'sa_slide1_image_pos';
804
- $slide_data[0]['image_size'] = 'sa_slide1_image_size';
805
- $slide_data[0]['image_repeat'] = 'sa_slide1_image_repeat';
806
- $slide_data[0]['image_color'] = 'sa_slide1_image_color';
807
- $slide_data[0]['link_url'] = 'sa_slide1_link_url';
808
- $slide_data[0]['link_target'] = 'sa_slide1_link_target';
809
- $slide_data[0]['slide_no'] = 1;
810
- $slide_data[1]['edit_id'] = 'sa_slide2_content';
811
- $slide_data[1]['content'] = 'Slide content';
812
- $slide_data[1]['del_id'] = 'sa_slide2_delete';
813
- $slide_data[1]['image_data'] = 'sa_slide2_image_data';
814
- $slide_data[1]['image_id'] = 'sa_slide2_image_id';
815
- $slide_data[1]['thumb'] = 'slide2_thumb';
816
- $slide_data[1]['image_del'] = 'slide2_image_del';
817
- $slide_data[1]['image_pos'] = 'sa_slide2_image_pos';
818
- $slide_data[1]['image_size'] = 'sa_slide2_image_size';
819
- $slide_data[1]['image_repeat'] = 'sa_slide2_image_repeat';
820
- $slide_data[1]['image_color'] = 'sa_slide2_image_color';
821
- $slide_data[1]['link_url'] = 'sa_slide2_link_url';
822
- $slide_data[1]['link_target'] = 'sa_slide2_link_target';
823
- $slide_data[1]['slide_no'] = 2;
824
- $slide_data[2]['edit_id'] = 'sa_slide3_content';
825
- $slide_data[2]['content'] = 'Slide content';
826
- $slide_data[2]['del_id'] = 'sa_slide3_delete';
827
- $slide_data[2]['image_data'] = 'sa_slide3_image_data';
828
- $slide_data[2]['image_id'] = 'sa_slide3_image_id';
829
- $slide_data[2]['thumb'] = 'slide3_thumb';
830
- $slide_data[2]['image_del'] = 'slide3_image_del';
831
- $slide_data[2]['image_pos'] = 'sa_slide3_image_pos';
832
- $slide_data[2]['image_size'] = 'sa_slide3_image_size';
833
- $slide_data[2]['image_repeat'] = 'sa_slide3_image_repeat';
834
- $slide_data[2]['image_color'] = 'sa_slide3_image_color';
835
- $slide_data[2]['link_url'] = 'sa_slide3_link_url';
836
- $slide_data[2]['link_target'] = 'sa_slide3_link_target';
837
- $slide_data[2]['slide_no'] = 3;
838
- $slide_data[0]['popup_type'] = 'sa_slide1_popup_type';
839
- $slide_data[0]['popup_imageid'] = 'sa_slide1_popup_imageid';
840
- $slide_data[0]['popup_imagetitle'] = 'sa_slide1_popup_imagetitle';
841
- $slide_data[0]['popup_video_id'] = 'sa_slide1_popup_video_id';
842
- $slide_data[0]['popup_video_type'] = 'sa_slide1_popup_video_type';
843
- $slide_data[0]['popup_background'] = 'sa_slide1_popup_background';
844
- $slide_data[0]['popup_html'] = 'sa_slide1_popup_html';
845
- $slide_data[0]['popup_shortcode'] = 'sa_slide1_popup_shortcode';
846
- $slide_data[0]['popup_bgcol'] = 'sa_slide1_popup_bgcol';
847
- $slide_data[0]['popup_width'] = 'sa_slide1_popup_width';
848
- $slide_data[1]['popup_type'] = 'sa_slide2_popup_type';
849
- $slide_data[1]['popup_imageid'] = 'sa_slide2_popup_imageid';
850
- $slide_data[1]['popup_imagetitle'] = 'sa_slide2_popup_imagetitle';
851
- $slide_data[1]['popup_video_id'] = 'sa_slide2_popup_video_id';
852
- $slide_data[1]['popup_video_type'] = 'sa_slide2_popup_video_type';
853
- $slide_data[1]['popup_background'] = 'sa_slide2_popup_background';
854
- $slide_data[1]['popup_html'] = 'sa_slide2_popup_html';
855
- $slide_data[1]['popup_shortcode'] = 'sa_slide2_popup_shortcode';
856
- $slide_data[1]['popup_bgcol'] = 'sa_slide2_popup_bgcol';
857
- $slide_data[1]['popup_width'] = 'sa_slide2_popup_width';
858
- $slide_data[2]['popup_type'] = 'sa_slide3_popup_type';
859
- $slide_data[2]['popup_imageid'] = 'sa_slide3_popup_imageid';
860
- $slide_data[2]['popup_imagetitle'] = 'sa_slide3_popup_imagetitle';
861
- $slide_data[2]['popup_video_id'] = 'sa_slide3_popup_video_id';
862
- $slide_data[2]['popup_video_type'] = 'sa_slide3_popup_video_type';
863
- $slide_data[2]['popup_background'] = 'sa_slide3_popup_background';
864
- $slide_data[2]['popup_html'] = 'sa_slide3_popup_html';
865
- $slide_data[2]['popup_shortcode'] = 'sa_slide3_popup_shortcode';
866
- $slide_data[2]['popup_bgcol'] = 'sa_slide3_popup_bgcol';
867
- $slide_data[2]['popup_width'] = 'sa_slide3_popup_width';
868
- } else {
869
- // AN EXISTING SLIDER - GET SLIDE DATA FROM THE DATABASE AND SAVE WITHIN AN ARRAY.
870
- $num_slides = intval( $num_slides );
871
- $slide_data = array();
872
- $count = 0;
873
- for ( $i = 1; $i <= $num_slides; $i++ ) {
874
- $slide_edit_id = 'sa_slide' . $i . '_content';
875
- $slide_char_count = 'sa_slide' . $i . '_char_count';
876
- $slide_data[ $count ]['edit_id'] = $slide_edit_id;
877
- $slide_data[ $count ]['content'] = get_post_meta( $post->ID, $slide_edit_id, true );
878
- $slide_data[ $count ]['char_count'] = get_post_meta( $post->ID, $slide_char_count, true );
879
- $slide_data[ $count ]['del_id'] = 'sa_slide' . $i . '_delete';
880
- $slide_data[ $count ]['thumb'] = 'slide' . $i . '_thumb';
881
- $slide_data[ $count ]['image_del'] = 'slide' . $i . '_image_del';
882
- $slide_data[ $count ]['image_data'] = 'sa_slide' . $i . '_image_data';
883
- $slide_data[ $count ]['image_id'] = 'sa_slide' . $i . '_image_id';
884
- $slide_data[ $count ]['image_pos'] = 'sa_slide' . $i . '_image_pos';
885
- $slide_data[ $count ]['image_size'] = 'sa_slide' . $i . '_image_size';
886
- $slide_data[ $count ]['image_repeat'] = 'sa_slide' . $i . '_image_repeat';
887
- $slide_data[ $count ]['image_color'] = 'sa_slide' . $i . '_image_color';
888
- $slide_data[ $count ]['image_data'] = 'sa_slide' . $i . '_image_data';
889
- $slide_data[ $count ]['link_url'] = 'sa_slide' . $i . '_link_url';
890
- $slide_data[ $count ]['link_target'] = 'sa_slide' . $i . '_link_target';
891
- $slide_data[ $count ]['popup_type'] = 'sa_slide' . $i . '_popup_type';
892
- $slide_data[ $count ]['popup_imageid'] = 'sa_slide' . $i . '_popup_imageid';
893
- $slide_data[ $count ]['popup_imagetitle'] = 'sa_slide' . $i . '_popup_imagetitle';
894
- $slide_data[ $count ]['popup_video_id'] = 'sa_slide' . $i . '_popup_video_id';
895
- $slide_data[ $count ]['popup_video_type'] = 'sa_slide' . $i . '_popup_video_type';
896
- $slide_data[ $count ]['popup_background'] = 'sa_slide' . $i . '_popup_background';
897
- $slide_data[ $count ]['popup_html'] = 'sa_slide' . $i . '_popup_html';
898
- $slide_data[ $count ]['popup_shortcode'] = 'sa_slide' . $i . '_popup_shortcode';
899
- $slide_data[ $count ]['popup_bgcol'] = 'sa_slide' . $i . '_popup_bgcol';
900
- $slide_data[ $count ]['popup_width'] = 'sa_slide' . $i . '_popup_width';
901
- $slide_data[ $count ]['slide_no'] = $i;
902
- $count++;
903
- }
904
- }
905
- // GET AVAILABLE WordPress IMAGE SIZES AND SAVE WITHIN AN ARRAY.
906
- global $_wp_additional_image_sizes;
907
- $image_size_arr = array();
908
- $image_size_arr[0]['value'] = 'no';
909
- $image_size_arr[0]['desc'] = 'NO';
910
- $count = 1;
911
- foreach ( get_intermediate_image_sizes() as $image_size ) {
912
- if ( in_array( $image_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
913
- $width = get_option( "{$image_size}_size_w" );
914
- $height = get_option( "{$image_size}_size_h" );
915
- } elseif ( isset( $_wp_additional_image_sizes[ $image_size ] ) ) {
916
- $width = $_wp_additional_image_sizes[ $image_size ]['width'];
917
- $height = $_wp_additional_image_sizes[ $image_size ]['height'];
918
- }
919
- if ( ( 0 !== $width ) && ( 0 !== $height ) ) {
920
- $image_size_arr[ $count ]['value'] = $image_size;
921
- $image_size_arr[ $count ]['desc'] = $image_size . ' (' . $width . '&times;' . $height . ')';
922
- $count++;
923
- }
924
- }
925
- /**
926
- * ###### LOOP TO DISPLAY INPUT ELEMENTS FOR EACH SLIDE ######
927
- */
928
- echo "<div id='slider_accordion'>\n";
929
-
930
- // determine whether to use css classes instead of csss ids.
931
- $use_classes = 0;
932
- $other_settings = get_post_meta( $post->ID, 'sa_other_settings', true );
933
- if ( '' !== $other_settings ) {
934
- $other_settings_arr = explode( '|', $other_settings );
935
- }
936
- if ( isset( $other_settings_arr ) && ( count( $other_settings_arr ) > 7 ) ) {
937
- $disable_slide_ids = $other_settings_arr[7];
938
- } else {
939
- $disable_slide_ids = '0';
940
- }
941
- if ( '1' === $disable_slide_ids ) {
942
- $use_classes = 1;
943
- }
944
-
945
- $tot = count( $slide_data );
946
- for ( $i = 0; $i < $tot; $i++ ) {
947
- // DISPLAY ACCORDION HEADING.
948
- echo '<h3>Slide ' . esc_html( $slide_data[ $i ]['slide_no'] );
949
- $css_id = $slider_css_id . '_slide' . sprintf( '%02d', $slide_data[ $i ]['slide_no'] );
950
- // display CSS ID/CLASS for the current slide.
951
- if ( 1 === $use_classes ) {
952
- echo '<span>.' . esc_html( $css_id ) . '</span>';
953
- } else {
954
- echo '<span>#' . esc_html( $css_id ) . '</span>';
955
- }
956
- echo "</h3>\n";
957
- echo "<div>\n";
958
-
959
- // ### DISPLAY THE SLIDE CONTENT EDITOR (textarea field) ###
960
- wp_editor( $slide_data[ $i ]['content'], $slide_data[ $i ]['edit_id'], $editor_args );
961
-
962
- /**
963
- * ##############################
964
- * ##### SLIDE TABS - START #####
965
- * ##############################
966
- */
967
- $tabs_num = $i + 1;
968
- echo "<div id='slide_" . esc_html( $tabs_num ) . "_tabs' class='sa_slide_tabs'>\n";
969
- echo "<ul>\n";
970
- echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_background_tab'>Slide Background</a></li>\n";
971
- echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_link_tab'>Slide Link</a></li>\n";
972
- echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_popup_tab'>Slide Popup</a></li>\n";
973
- echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_goto_tab'>Slide Goto Link</a></li>\n";
974
- echo "</ul>\n";
975
-
976
- /**
977
- * ####### SLIDE TAB 1 - SLIDE BACKGROUND #######
978
- */
979
- echo "<div id='slide" . esc_html( $tabs_num ) . "_background_tab' class='sa_slide_tab'>\n";
980
-
981
- // GET BACKGROUND IMAGE DATA FOR THIS SLIDE (image id, position, size, repeat and color) FROM DATABASE.
982
- $slide_image_data = get_post_meta( $post->ID, $slide_data[ $i ]['image_data'], true );
983
- if ( isset( $slide_image_data ) && ( '' !== $slide_image_data ) ) {
984
- $data_arr = explode( '~', $slide_image_data );
985
- $slide_image_id = $data_arr[0];
986
- $slide_image_pos = $data_arr[1];
987
- $slide_image_size = $data_arr[2];
988
- $slide_image_repeat = $data_arr[3];
989
- $slide_image_color = $data_arr[4];
990
- } else {
991
- $slide_image_id = get_post_meta( $post->ID, $slide_data[ $i ]['image_id'], true );
992
- $slide_image_pos = get_post_meta( $post->ID, $slide_data[ $i ]['image_pos'], true );
993
- $slide_image_size = get_post_meta( $post->ID, $slide_data[ $i ]['image_size'], true );
994
- $slide_image_repeat = get_post_meta( $post->ID, $slide_data[ $i ]['image_repeat'], true );
995
- $slide_image_color = get_post_meta( $post->ID, $slide_data[ $i ]['image_color'], true );
996
- }
997
- if ( '' === $slide_image_pos ) {
998
- $slide_image_pos = 'left top';
999
- }
1000
- if ( '' === $slide_image_size ) {
1001
- $slide_image_size = 'contain';
1002
- }
1003
- if ( '' === $slide_image_repeat ) {
1004
- $slide_image_repeat = 'no-repeat';
1005
- }
1006
- if ( '' === $slide_image_color ) {
1007
- $slide_image_color = 'rgba(0,0,0,0)';
1008
- }
1009
-
1010
- echo "<div class='sa_slide_bg_wrapper'>\n";
1011
-
1012
- /**
1013
- * ### 'USE POPUP IMAGE AS SLIDE BACKGROUND' SETTING ###
1014
- */
1015
- $slide_popup_background = get_post_meta( $post->ID, $slide_data[ $i ]['popup_background'], true );
1016
- if ( '' === $slide_popup_background ) {
1017
- $slide_popup_background = 'no';
1018
- }
1019
- echo "<div class='popup_background_wrapper'>\n";
1020
- echo '<div>Use Popup Image as Slide Background:';
1021
- $tooltip = 'Allows you to use the same image you defined as the popup image as the slide background image. You can use a smaller version of the popup image.';
1022
- echo "<em class='sa_tooltip' href='' title='" . esc_attr( $tooltip ) . "'></em></div>\n";
1023
- echo "<select id='" . esc_attr( $slide_data[ $i ]['popup_background'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_background'] ) . "' ";
1024
- echo "onChange='change_slide_popup_background(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1025
- $tot_loop = count( $image_size_arr );
1026
- for ( $j = 0; $j < $tot_loop; $j++ ) {
1027
- if ( $slide_popup_background === $image_size_arr[ $j ]['value'] ) {
1028
- echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "' selected>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
1029
- } else {
1030
- echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "'>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
1031
- }
1032
- }
1033
- echo '</select>';
1034
- echo "</div>\n"; // .popup_background_wrapper
1035
- echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
1036
- echo "<div id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_imagebg_popup' class='sa_slide_bg_popup'><div></div></div>\n";
1037
-
1038
- // SLIDE BACKGROUND IMAGE - THUMBNAIL AND 'SET IMAGE' BUTTON.
1039
- // get WordPress media upload frame url.
1040
- $upload_frame_url = esc_url( get_upload_iframe_src( 'image', $post->ID ) . '&slide=' . $slide_data[ $i ]['slide_no'] );
1041
- // Get image src for slide background image.
1042
- $slide_image_src = wp_get_attachment_image_src( $slide_image_id, 'medium' );
1043
- // check if the slide background image id already exists.
1044
- $image_exists = is_array( $slide_image_src );
1045
- // slide backround image - thumbnail (and delete button).
1046
- echo "<div id='" . esc_attr( $slide_data[ $i ]['thumb'] ) . "' class='sa_slide_thumb'>\n";
1047
- if ( $image_exists ) {
1048
- echo "<div style='background-image:url(\"" . esc_attr( $slide_image_src[0] ) . '"); background-size:' . esc_attr( $slide_image_size ) . '; ';
1049
- echo 'background-repeat:' . esc_attr( $slide_image_repeat ) . '; background-color:' . esc_attr( $slide_image_color ) . '; ';
1050
- echo 'background-position:' . esc_attr( $slide_image_pos ) . ";'></div>\n";
1051
- echo "<span id='" . esc_attr( $slide_data[ $i ]['image_del'] ) . "' onClick='remove_slide_bg_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Delete the background image for this slide'>X</span>\n";
1052
- echo "</div>\n";
1053
- } else {
1054
- if ( isset( $slide_data[ $i ]['popup_type'] ) ) {
1055
- $slide_popup_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_type'], true );
1056
- $popup_video_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_type'], true );
1057
- $popup_video_id = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_id'], true );
1058
- } else {
1059
- $slide_popup_type = 'NONE';
1060
- $popup_video_type = '';
1061
- $popup_video_id = '';
1062
- }
1063
- if ( ( '99999999' === $slide_image_id ) && ( 'VIDEO' === $slide_popup_type ) && ( 'youtube' === $popup_video_type ) ) {
1064
- $youtube_thumb = 'https://img.youtube.com/vi/' . $popup_video_id . '/maxresdefault.jpg';
1065
- echo "<div style='background-image:url(\"" . esc_attr( $youtube_thumb ) . '"); background-size:' . esc_attr( $slide_image_size ) . '; ';
1066
- echo 'background-repeat:' . esc_attr( $slide_image_repeat ) . '; background-color:' . esc_attr( $slide_image_color ) . '; ';
1067
- echo 'background-position:' . esc_attr( $slide_image_pos ) . ";'></div>\n";
1068
- echo "<span id='" . esc_attr( $slide_data[ $i ]['image_del'] ) . "' onClick='remove_slide_bg_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Delete the background image for this slide'>X</span>\n";
1069
- echo "</div>\n";
1070
- } else {
1071
- echo "<div style='background-color:#ffffff; background-size:" . esc_attr( $slide_image_size ) . '; ';
1072
- echo 'background-repeat:' . esc_attr( $slide_image_repeat ) . '; background-color:' . esc_attr( $slide_image_color ) . '; ';
1073
- echo 'background-position:' . esc_attr( $slide_image_pos ) . ";'></div>\n";
1074
- echo "<span id='" . esc_attr( $slide_data[ $i ]['image_del'] ) . "' class='sa_hidden' onClick='remove_slide_bg_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Delete the background image for this slide'>X</span>\n";
1075
- echo "</div>\n";
1076
- }
1077
- }
1078
- // slide background image - 'set image' button.
1079
- echo "<a class='button button-secondary slide_image_add' id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_image_add' ";
1080
- echo "href='" . esc_attr( $upload_frame_url ) . "' title='Set the background image for this slide'>Set Image</a>\n";
1081
- // slide background image - image id hidden field.
1082
- echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['image_id'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_id'] ) . "' value='" . esc_attr( $slide_image_id ) . "'/>\n";
1083
-
1084
- // SLIDE BACKGROUND IMAGE - BACKGROUND POSITION (dropdown box).
1085
- echo "<div class='slide_image_settings_line'>";
1086
- echo '<span>Background Position:</span>';
1087
- $option_arr = array();
1088
- $option_arr[0]['desc'] = 'Top Left';
1089
- $option_arr[0]['value'] = 'left top';
1090
- $option_arr[1]['desc'] = 'Top Center';
1091
- $option_arr[1]['value'] = 'center top';
1092
- $option_arr[2]['desc'] = 'Top Right';
1093
- $option_arr[2]['value'] = 'right top';
1094
- $option_arr[3]['desc'] = 'Center Left';
1095
- $option_arr[3]['value'] = 'left center';
1096
- $option_arr[4]['desc'] = 'Center';
1097
- $option_arr[4]['value'] = 'center center';
1098
- $option_arr[5]['desc'] = 'Center Right';
1099
- $option_arr[5]['value'] = 'right center';
1100
- $option_arr[6]['desc'] = 'Bottom Left';
1101
- $option_arr[6]['value'] = 'left bottom';
1102
- $option_arr[7]['desc'] = 'Bottom Center';
1103
- $option_arr[7]['value'] = 'center bottom';
1104
- $option_arr[8]['desc'] = 'Bottom Right';
1105
- $option_arr[8]['value'] = 'right bottom';
1106
- echo "<select id='" . esc_attr( $slide_data[ $i ]['image_pos'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_pos'] ) . "' onChange='change_slide_image_pos(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1107
- $tot_loop = count( $option_arr );
1108
- for ( $j = 0; $j < $tot_loop; $j++ ) {
1109
- if ( $slide_image_pos === $option_arr[ $j ]['value'] ) {
1110
- echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "' selected>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1111
- } else {
1112
- echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "'>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1113
- }
1114
- }
1115
- echo '</select>';
1116
- echo "</div>\n";
1117
-
1118
- // SLIDE BACKGROUND IMAGE - BACKGROUND SIZE (dropdown box).
1119
- echo "<div class='slide_image_settings_line'>";
1120
- echo '<span>Background Size:</span>';
1121
- $option_arr = array();
1122
- $option_arr[0]['value'] = 'auto';
1123
- $option_arr[0]['desc'] = 'no resize';
1124
- $option_arr[1]['value'] = 'contain';
1125
- $option_arr[1]['desc'] = 'contain';
1126
- $option_arr[2]['value'] = 'cover';
1127
- $option_arr[2]['desc'] = 'cover';
1128
- $option_arr[3]['value'] = '100% 100%';
1129
- $option_arr[3]['desc'] = '100%';
1130
- $option_arr[4]['value'] = '100% auto';
1131
- $option_arr[4]['desc'] = '100% width';
1132
- $option_arr[5]['value'] = 'auto 100%';
1133
- $option_arr[5]['desc'] = '100% height';
1134
- echo "<select id='" . esc_attr( $slide_data[ $i ]['image_size'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_size'] ) . "' onChange='change_slide_image_size(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1135
- $tot_loop = count( $option_arr );
1136
- for ( $j = 0; $j < $tot_loop; $j++ ) {
1137
- if ( $slide_image_size === $option_arr[ $j ]['value'] ) {
1138
- echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "' selected>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1139
- } else {
1140
- echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "'>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1141
- }
1142
- }
1143
- echo '</select>';
1144
- echo "</div>\n";
1145
-
1146
- // SLIDER BACKGROUND IMAGE - BACKGROUND REPEAT (dropdown box).
1147
- echo "<div class='slide_image_settings_line'>";
1148
- echo '<span>Background Repeat:</span>';
1149
- $option_arr = array();
1150
- $option_arr[0] = 'no-repeat';
1151
- $option_arr[1] = 'repeat';
1152
- $option_arr[2] = 'repeat-x';
1153
- $option_arr[3] = 'repeat-y';
1154
- echo "<select id='" . esc_attr( $slide_data[ $i ]['image_repeat'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_repeat'] ) . "' ";
1155
- echo "onChange='change_slide_image_repeat(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1156
- $tot_loop = count( $option_arr );
1157
- for ( $j = 0; $j < $tot_loop; $j++ ) {
1158
- if ( $slide_image_repeat === $option_arr[ $j ] ) {
1159
- echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "' selected>" . esc_html( $option_arr[ $j ] ) . '</option>';
1160
- } else {
1161
- echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "'>" . esc_html( $option_arr[ $j ] ) . '</option>';
1162
- }
1163
- }
1164
- echo '</select>';
1165
- echo "</div>\n";
1166
-
1167
- // SLIDER BACKGROUND IMAGE - BACKGROUND COLOR (color picker).
1168
- echo "<div class='slide_image_settings_line'>";
1169
- echo '<span>Background Color:</span>';
1170
- echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['image_color'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_color'] ) . "' value='" . esc_attr( $slide_image_color ) . "' ";
1171
- echo "onChange='change_slide_image_color(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1172
- echo "</div>\n";
1173
-
1174
- echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
1175
- echo "</div>\n";
1176
- echo "</div>\n";
1177
-
1178
- /**
1179
- * ####### SLIDE TAB 2 - SLIDE LINK #######
1180
- */
1181
- echo "<div id='slide" . esc_attr( $tabs_num ) . "_link_tab' class='sa_slide_tab'>\n";
1182
-
1183
- // GET SLIDE LINK DATA FOR THIS SLIDE FROM THE DATABASE.
1184
- $slide_link_url = get_post_meta( $post->ID, $slide_data[ $i ]['link_url'], true );
1185
- $slide_link_target = get_post_meta( $post->ID, $slide_data[ $i ]['link_target'], true );
1186
- if ( '' === $slide_link_target ) {
1187
- $slide_link_target = '_self';
1188
- }
1189
-
1190
- // DISPLAY INPUT FIELDS FOR SLIDE LINK SETTINGS.
1191
- echo "<div class='slide_link_settings_wrapper'>";
1192
- echo '<p>Specify a link URL that this slide opens</h3>';
1193
- // LINK URL.
1194
- echo '<div><span>Link URL:</span>';
1195
- echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['link_url'] ) . "' name='" . esc_attr( $slide_data[ $i ]['link_url'] ) . "' ";
1196
- echo "value='" . esc_attr( $slide_link_url ) . "'/></div>\n";
1197
- // LINK TARGET.
1198
- echo '<div><span>Link Target:</span>';
1199
- echo "<select id='" . esc_attr( $slide_data[ $i ]['link_target'] ) . "' name='" . esc_attr( $slide_data[ $i ]['link_target'] ) . "'>";
1200
- if ( '_blank' === $slide_link_target ) {
1201
- echo "<option value='_self'>Same Tab/Window</option>";
1202
- echo "<option value='_blank' selected>New Tab/Window</option>";
1203
- } else {
1204
- echo "<option value='_self' selected>Same Tab/Window</option>";
1205
- echo "<option value='_blank'>New Tab/Window</option>";
1206
- }
1207
- echo '</select>';
1208
- echo "</div>\n";
1209
-
1210
- echo "</div>\n";
1211
- echo "</div>\n";
1212
-
1213
- /**
1214
- * ####### SLIDE TAB 3 - SLIDE POPUP #######
1215
- */
1216
- echo "<div id='slide" . esc_attr( $tabs_num ) . "_popup_tab' class='sa_slide_tab'>\n";
1217
-
1218
- // GET SLIDE POPUP DATA FOR THIS SLIDE FROM THE DATABASE.
1219
- $slide_popup_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_type'], true );
1220
- if ( '' === $slide_popup_type ) {
1221
- $slide_popup_type = 'NONE';
1222
- }
1223
- $popup_imageid = intval( get_post_meta( $post->ID, $slide_data[ $i ]['popup_imageid'], true ) );
1224
- $popup_video_id = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_id'], true );
1225
- $popup_video_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_type'], true );
1226
- $popup_imagetitle = get_post_meta( $post->ID, $slide_data[ $i ]['popup_imagetitle'], true );
1227
- $popup_html = get_post_meta( $post->ID, $slide_data[ $i ]['popup_html'], true );
1228
- $popup_shortcode = get_post_meta( $post->ID, $slide_data[ $i ]['popup_shortcode'], true );
1229
- $popup_bgcol = get_post_meta( $post->ID, $slide_data[ $i ]['popup_bgcol'], true );
1230
- $popup_width = intval( get_post_meta( $post->ID, $slide_data[ $i ]['popup_width'], true ) );
1231
- $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1232
-
1233
- // POPUP TYPE.
1234
- echo "<div class='slide_popup_settings_line'>";
1235
- echo '<span>SA Popup Type:</span>';
1236
- $option_arr = array();
1237
- $option_arr[0] = 'NONE';
1238
- $option_arr[1] = 'IMAGE';
1239
- $option_arr[2] = 'VIDEO';
1240
- $option_arr[3] = 'HTML';
1241
- echo "<select id='" . esc_attr( $slide_data[ $i ]['popup_type'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_type'] ) . "' ";
1242
- echo "onChange='change_slide_popup_type(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1243
- $tot_loop = count( $option_arr );
1244
- for ( $j = 0; $j < $tot_loop; $j++ ) {
1245
- if ( $slide_popup_type === $option_arr[ $j ] ) {
1246
- echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "' selected>" . esc_html( $option_arr[ $j ] ) . '</option>';
1247
- } else {
1248
- echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "'>" . esc_html( $option_arr[ $j ] ) . '</option>';
1249
- }
1250
- }
1251
- echo '</select>';
1252
- echo "</div>\n";
1253
-
1254
- // A) IMAGE POPUP SETTINGS.
1255
- $sl_num = ( $i + 1 );
1256
- if ( 'IMAGE' === $slide_popup_type ) {
1257
- echo "<div id='slide" . esc_attr( $sl_num ) . "_image_popup_wrapper' class='image_popup_wrapper'>\n";
1258
- } else {
1259
- echo "<div id='slide" . esc_attr( $sl_num ) . "_image_popup_wrapper' class='image_popup_wrapper' style='display:none;'>\n";
1260
- }
1261
- // get WordPress media upload frame url.
1262
- $upload_popup_frame_url = esc_url( get_upload_iframe_src( 'image', $post->ID ) . '&popup=' . $slide_data[ $i ]['slide_no'] );
1263
- // Get image src for slide popup image.
1264
- $popup_image_src = wp_get_attachment_image_src( $popup_imageid, 'medium' );
1265
- // check if the slide background image id already exists.
1266
- $image_exists = is_array( $popup_image_src );
1267
- echo "<div id='slide" . esc_attr( $sl_num ) . "_popup_thumb' class='slide_popup_thumb'>\n";
1268
- $placeholder = SA_PLUGIN_PATH . 'images/image_placeholder.jpg';
1269
- if ( $image_exists ) {
1270
- // media library image id exists - display thumbnail image.
1271
- echo "<div><img src='" . esc_attr( $popup_image_src[0] ) . "'/></div>";
1272
- // display image delete button.
1273
- echo "<span onClick='remove_popup_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . '", "' . esc_attr( $placeholder ) . "\");' ";
1274
- echo "id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_image_del' title='Delete the popup image for this slide'>X</span>\n";
1275
- // get popup image info (size & dimensions).
1276
- $popup_image_meta = wp_get_attachment_metadata( $popup_imageid );
1277
- $image_width = $popup_image_meta['width'];
1278
- $image_height = $popup_image_meta['height'];
1279
- $info_dim = $image_width . ' x ' . $image_height . ' pixels';
1280
- $popup_image_full = wp_get_attachment_image_src( $popup_imageid, 'full' );
1281
- $img_headers = get_headers( $popup_image_full[0], 1 );
1282
- $info_size = $img_headers['Content-Length'];
1283
- if ( '' !== $info_size ) {
1284
- $size_unit = 'bytes';
1285
- if ( $info_size > 1048576 ) {
1286
- if ( ! is_array( $info_size ) ) {
1287
- $info_size = round( $info_size / 1048576 ) . ' MB';
1288
- } else {
1289
- $info_size = '';
1290
- }
1291
- } elseif ( $info_size > 1024 ) {
1292
- if ( ! is_array( $info_size ) ) {
1293
- $info_size = round( $info_size / 1024 ) . ' kb';
1294
- } else {
1295
- $info_size = '';
1296
- }
1297
- }
1298
- }
1299
- } else {
1300
- // no image selected yet - display placeholder image.
1301
- $popup_image_id = 0;
1302
- echo "<div><img src='" . esc_attr( $placeholder ) . "'/></div>";
1303
- // display image delete button (hidden state).
1304
- echo "<span class='sa_hidden' onClick='remove_popup_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . '", "' . esc_attr( $placeholder ) . "\");' ";
1305
- echo "id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_image_del' title='Delete the popup image for this slide'>X</span>\n";
1306
- // reset popup image info (size & dimensions).
1307
- $info_dim = '';
1308
- $info_size = '';
1309
- }
1310
- echo "</div>\n";
1311
- // slide popup image - 'set image' button.
1312
- echo "<a class='button button-secondary popup_image_add' href='" . esc_attr( $upload_popup_frame_url ) . "' ";
1313
- echo "title='Set the background image for this slide'>Set Image</a>\n";
1314
- // slide popup image - 'preview' button.
1315
- $preview_button = 'slide' . esc_attr( $slide_data[ $i ]['slide_no'] ) . '_popup_image_preview';
1316
- echo "<div id='" . esc_attr( $preview_button ) . "' class='slide_popup_image_preview'>";
1317
- if ( $image_exists ) {
1318
- echo "<a class='button button-secondary' href='" . esc_attr( $popup_image_full[0] ) . "' title='" . esc_attr( $popup_imagetitle ) . "'>Preview</a>";
1319
- } else {
1320
- echo "<a class='button button-secondary' href='" . esc_attr( $placeholder ) . "' title='" . esc_attr( $popup_imagetitle ) . "'>Preview</a>";
1321
- }
1322
- echo "</div>\n";
1323
- // slide popup image - jquery code to generate 'magnific popup' preview.
1324
- echo "<script type='text/javascript'>\n";
1325
- echo "jQuery(document).ready(function() {\n";
1326
- echo " jQuery('#" . esc_attr( $preview_button ) . " a').magnificPopup({\n";
1327
- echo " mainClass: 'sa_popup',\n";
1328
- echo " closeBtnInside: true,\n";
1329
- echo " type: 'image'\n";
1330
- echo " });\n";
1331
- echo "});\n";
1332
- echo "</script>\n";
1333
- // slide popup image - popup image id hidden field.
1334
- echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['popup_imageid'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_imageid'] );
1335
- echo "' value='" . esc_attr( $popup_imageid ) . "' />\n";
1336
- // slide popup image - popup image info (title, dimensions & size).
1337
- echo "<div class='slide_popup_info'>\n";
1338
- // popup image title.
1339
- echo "<input class='sa_slide_popup_imagetitle' type='text' id='" . esc_attr( $slide_data[ $i ]['popup_imagetitle'] ) . "' ";
1340
- echo "name='" . esc_attr( $slide_data[ $i ]['popup_imagetitle'] ) . "' value='" . esc_attr( $popup_imagetitle ) . "' ";
1341
- echo "onChange='change_popup_image_title(this.value, \"" . esc_attr( $preview_button ) . "\")' placeholder='Enter popup title'/>\n";
1342
- // popup dimensions.
1343
- echo "<div id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_info_dim' class='slide_popup_info_dim'>";
1344
- echo '<strong>Dimensions:</strong> ' . esc_html( $info_dim ) . "</div>\n";
1345
- // popup file size.
1346
- echo "<div id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_info_size' class='slide_popup_info_size'>";
1347
- if ( '' !== $info_size ) {
1348
- echo '<strong>File Size:</strong> ' . esc_html( $info_size );
1349
- }
1350
- echo "</div>\n";
1351
- echo "</div>\n";
1352
- echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
1353
- echo "</div>\n";
1354
-
1355
- // B) VIDEO POPUP SETTINGS.
1356
- $sl_num = ( $i + 1 );
1357
- if ( 'VIDEO' === $slide_popup_type ) {
1358
- echo "<div id='slide" . esc_attr( $sl_num ) . "_video_popup_wrapper' class='video_popup_wrapper'>\n";
1359
- } else {
1360
- echo "<div id='slide" . esc_attr( $sl_num ) . "_video_popup_wrapper' class='video_popup_wrapper' style='display:none;'>\n";
1361
- }
1362
- // set default video values.
1363
- if ( ( 'youtube' !== $popup_video_type ) && ( 'vimeo' !== $popup_video_type ) ) {
1364
- $popup_video_type = '';
1365
- $popup_video_id = '';
1366
- }
1367
- if ( '' === $popup_video_id ) {
1368
- $popup_video_type = '';
1369
- }
1370
- // video preview.
1371
- echo "<div id='slide" . esc_attr( $sl_num ) . "_video_thumb' class='slide_video_thumb'>\n";
1372
- if ( '' !== $popup_video_id ) {
1373
- if ( 'youtube' === $popup_video_type ) {
1374
- echo "<iframe src='https://www.youtube.com/embed/" . esc_attr( $popup_video_id ) . "' frameborder='0' allowfullscreen></iframe>\n";
1375
- } elseif ( 'vimeo' === $popup_video_type ) {
1376
- echo "<iframe src='https://player.vimeo.com/video/" . esc_attr( $popup_video_id ) . "' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
1377
- } else {
1378
- echo "<img src='" . esc_attr( SA_PLUGIN_PATH ) . "images/video_placeholder.jpg'/>";
1379
- }
1380
- } else {
1381
- echo "<img src='" . esc_attr( SA_PLUGIN_PATH ) . "images/video_placeholder.jpg'/>";
1382
- }
1383
- echo "<div style='float:none; clear:both; width:100%; height:1px;'></div>\n";
1384
- echo "</div>\n";
1385
- // video url (youtube/vimeo) input text box.
1386
- echo "<div class='sa_slide_video_url'>";
1387
- echo "<input type='text' id='sa_slide" . esc_attr( $sl_num ) . "_video_url' name='sa_slide" . esc_attr( $sl_num ) . "_video_url' ";
1388
- echo "placeholder='Enter YouTube or Vimeo URL'/></div>\n";
1389
- // 'update video' button.
1390
- echo "<a class='button button-secondary' title='Update popup video using the above video URL' ";
1391
- echo "onClick='update_popup_video(" . esc_attr( $sl_num ) . ");'>Set Video</a>\n";
1392
-
1393
- // slide popup video - 'preview' button.
1394
- $video_preview_url = SA_PLUGIN_PATH . 'images/video_placeholder_admin.jpg';
1395
- if ( '' !== $popup_video_id ) {
1396
- if ( 'youtube' === $popup_video_type ) {
1397
- $video_preview_url = 'http://www.youtube.com/watch?v=' . $popup_video_id;
1398
- } elseif ( 'vimeo' === $popup_video_type ) {
1399
- $video_preview_url = 'http://vimeo.com/' . $popup_video_id;
1400
- }
1401
- }
1402
- $preview_button = 'slide' . esc_attr( $slide_data[ $i ]['slide_no'] ) . '_popup_video_preview';
1403
- echo "<div id='" . esc_attr( $preview_button ) . "' class='slide_popup_video_preview'>";
1404
- echo "<a class='button button-secondary' href='" . esc_attr( $video_preview_url ) . "'>Preview</a>";
1405
- echo "</div>\n";
1406
- // slide popup image - jquery code to generate 'magnific popup' preview.
1407
- echo "<script type='text/javascript'>\n";
1408
- echo "jQuery(document).ready(function() {\n";
1409
- echo " jQuery('#" . esc_attr( $preview_button ) . " a').magnificPopup({\n";
1410
- echo " mainClass: 'sa_popup',\n";
1411
- echo " closeBtnInside: true,\n";
1412
- echo " type: 'iframe'\n";
1413
- echo " });\n";
1414
- echo "});\n";
1415
- echo "</script>\n";
1416
- // invalid url error message.
1417
- echo "<div id='sa_slide" . esc_attr( $sl_num ) . "_video_invalid_url' class='sa_popup_video_invalid_url'>";
1418
- echo "URL entered is NOT a valid YouTube or Vimeo URL!</div>\n";
1419
- // hidden video id text field.
1420
- echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['popup_video_id'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_video_id'] ) . "' ";
1421
- echo "value='" . esc_attr( $popup_video_id ) . "'/>\n";
1422
- // hidden video type (youtube/vimeo) text field.
1423
- echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['popup_video_type'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_video_type'] ) . "' ";
1424
- echo "value='" . esc_attr( $popup_video_type ) . "'/>\n";
1425
- echo "<div style='float:none; clear:both; width:100%; height:1px;'></div>\n";
1426
- echo "</div>\n";
1427
-
1428
- // C) CONTENT POPUP SETTINGS.
1429
- $sl_num = ( $i + 1 );
1430
- if ( 'HTML' === $slide_popup_type ) {
1431
- echo "<div id='slide" . esc_attr( $sl_num ) . "_html_popup_wrapper' class='html_popup_wrapper'>\n";
1432
- } else {
1433
- echo "<div id='slide" . esc_attr( $sl_num ) . "_html_popup_wrapper' class='html_popup_wrapper' style='display:none;'>\n";
1434
- }
1435
- // content popup - html.
1436
- echo "<textarea id='" . esc_attr( $slide_data[ $i ]['popup_html'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_html'] ) . "' ";
1437
- echo "placeholder='Enter HTML Code or WordPress Shortcode'>" . esc_attr( $popup_html ) . "</textarea>\n";
1438
- // content popup - shortcode.
1439
- if ( '' === $popup_shortcode ) {
1440
- $popup_shortcode = '0';
1441
- }
1442
- echo "<div class='slide_popup_settings_line' style='margin:3px 0px 15px;'><span>Shortcode Content:</span>";
1443
- if ( '1' === $popup_shortcode ) {
1444
- echo "<input type='checkbox' id='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' value='1' checked/>";
1445
- } else {
1446
- echo "<input type='checkbox' id='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' value='1'/>";
1447
- }
1448
- echo "<em class='sa_tooltip' href='' title='Use a WordPress shortcode instead of HTML as your popup content'></em>\n";
1449
- echo "</div>\n";
1450
- // content popup - css id.
1451
- $popup_id = $css_id . '_popup' . ( $i + 1 );
1452
- echo "<div class='slide_popup_settings_line'>";
1453
- echo "<span>Popup CSS ID:</span><div id='sa_slide" . esc_attr( $sl_num ) . "_popup_css' class='slide_popup_css'>#" . esc_html( $popup_id ) . '</div>';
1454
- echo '<strong>(click to copy to clipboard)</strong></div>';
1455
- // content popup - background color.
1456
- if ( '' === $popup_bgcol ) {
1457
- $popup_bgcol = '#ffffff';
1458
- }
1459
- echo "<div class='slide_popup_settings_line'>";
1460
- echo '<span>Background Color:</span>';
1461
- echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['popup_bgcol'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_bgcol'] ) . "' ";
1462
- echo "value='" . esc_attr( $popup_bgcol ) . "'>";
1463
- echo "</div>\n";
1464
- // content popup - width.
1465
- if ( ( '' === $popup_width ) || ( 0 === $popup_width ) ) {
1466
- $popup_width = '600';
1467
- }
1468
- echo "<div class='slide_popup_settings_line'>";
1469
- echo '<span>Popup Width:</span>';
1470
- echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['popup_width'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_width'] ) . "' ";
1471
- echo "value='" . esc_attr( $popup_width ) . "'><em>px</em>";
1472
- echo "</div>\n";
1473
-
1474
- echo "</div>\n";
1475
- echo "</div>\n";
1476
-
1477
- /**
1478
- * ####### SLIDE TAB 4 - SLIDE GOTO LINK #######
1479
- */
1480
- $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1481
- $goto_class = $css_id . '_goto' . ( $i + 1 );
1482
- $eg_link = 'https://edgewebpages.com/slide-goto-links';
1483
- echo "<div id='slide" . esc_attr( $tabs_num ) . "_goto_tab' class='sa_slide_tab'>\n";
1484
- echo "<div class='slide_goto_link_content'>\n";
1485
- echo "<p><strong>Create a link or button to link directly to this slide</strong></p>\n";
1486
- echo "<p>To do this, give your link or button the following <strong>CSS Class:</strong></p>\n";
1487
- echo "<div class='slide_goto_class'><span>" . esc_html( $goto_class ) . "</span></div>\n";
1488
- echo "<p>To see an example of how a '<strong>Slide Goto Link</strong>' works ";
1489
- echo "<a href='" . esc_attr( $eg_link ) . "' target='_blank'>CLICK HERE</a></p>\n";
1490
- echo "</div>\n";
1491
- echo "</div>\n";
1492
-
1493
- /**
1494
- * // ############################
1495
- * // ##### SLIDE TABS - END #####
1496
- * // ############################
1497
- */
1498
- echo "</div>\n";
1499
-
1500
- // 3. DELETE STATUS FIELD (hidden) AND DELETE SLIDE BUTTON.
1501
- echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['del_id'] ) . "' name='" . esc_attr( $slide_data[ $i ]['del_id'] ) . "' value='1'/>\n";
1502
- echo "<div class='button button-secondary' onClick='delete_sa_slide(\"" . esc_attr( $slide_data[ $i ]['del_id'] ) . "\");' title='Delete this slide'>Delete Slide</div>\n";
1503
-
1504
- // 4. DUPLICATE SLIDE BUTTON.
1505
- echo "<div class='button button-secondary' onClick='duplicate_slide(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Duplicate this slide'>Duplicate Slide</div>\n";
1506
-
1507
- // 5. MOVE SLIDE UP BUTTON.
1508
- if ( 1 !== $slide_data[ $i ]['slide_no'] ) {
1509
- echo "<div class='button button-secondary' onClick='move_slide_up(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Move this slide up within the slide order'>Move Slide Up</div>\n";
1510
- }
1511
-
1512
- echo "</div>\n";
1513
- }
1514
- echo "</div>\n";
1515
-
1516
- // ADD SLIDE BUTTON.
1517
- if ( $num_slides < 99 ) {
1518
- // a maximum of 99 slides allowed.
1519
- echo "<div id='sa_add_slide' class='button button-primary button-large' title='Add a new slide'>Add Slide</div>\n";
1520
- }
1521
-
1522
- // JQUERY-UI DIALOG BOX DIV - FOR CONFIRMATION DIALOG BOXES.
1523
- echo "<div id='sa_dialog_box'></div>\n";
1524
- }
1525
-
1526
-
1527
-
1528
- /**
1529
- * ##### META BOX CONTENT - 'Slider Preview/Shortcode' BOX #####
1530
- *
1531
- * @param array $post Custom Post 'sa_slider'.
1532
- */
1533
- function cpt_slider_shortcode_content( $post ) {
1534
- // CHECK IF YOAST SEO PLUGIN IS INSTALLED.
1535
- $yoast = 0;
1536
- if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
1537
- $yoast = 1;
1538
- }
1539
- $post_status = get_post_status( $post->ID );
1540
- $allow_shortcodes = get_post_meta( $post->ID, 'sa_shortcodes', true );
1541
- $shortcode = '[slide-anything id="' . $post->ID . '"]';
1542
- echo "<div id='sa_slider_shortcode'>" . esc_html( $shortcode ) . "</div>\n";
1543
- echo "<div id='sa_shortcode_copy' class='button button-secondary'>Copy to Clipboard</div>\n";
1544
-
1545
- // get value of 'Disable Preview Feature' checkbox.
1546
- $disable_preview = '0';
1547
- $other_settings = get_post_meta( $post->ID, 'sa_other_settings', true );
1548
- if ( '' !== $other_settings ) {
1549
- $other_settings_arr = explode( '|', $other_settings );
1550
- }
1551
- if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[5] ) ) {
1552
- $disable_preview = $other_settings_arr[5];
1553
- }
1554
-
1555
- if ( ( 'publish' === $post_status ) && ( '0' === $disable_preview ) && ( 0 === $yoast ) ) {
1556
- // CHECK IF THE PREVIEW PAGE ALREADY EXISTS.
1557
- // DISABLE THE PREVIEW FEATURE IF 'YOAST SEO' PLUGIN IS INSTALLED.
1558
- $preview_page_created = 1;
1559
- $preview_page = get_page_by_title( 'Slide Anything Popup Preview' );
1560
- $preview_id = $preview_page->ID;
1561
- if ( '' !== $preview_id ) {
1562
- // PREVIEW PAGE EXISTS - UPDATE PAGE CONTENT TO CONTAIN THIS SA SHORTCODE.
1563
- wp_untrash_post( $preview_id ); // remove preview page from trash (if applicable).
1564
- $page_content = "[slide-anything id='" . $post->ID . "']";
1565
- $page_data = array(
1566
- 'ID' => $preview_id,
1567
- 'post_content' => $page_content,
1568
- );
1569
- $page_id = wp_update_post( $page_data );
1570
- if ( is_wp_error( $page_id ) ) {
1571
- $preview_page_created = 0;
1572
- }
1573
- } else {
1574
- // PREVIEW PAGE DOES NOT EXIST - CREATE PREVIEW PAGE WITH SA SHORTCODE CONTENT.
1575
- $page_content = "[slide-anything id='" . $post->ID . "']";
1576
- $curr_user_id = get_current_user_id();
1577
- $page_data = array(
1578
- 'post_title' => 'Slide Anything Popup Preview',
1579
- 'post_content' => $page_content,
1580
- 'post_status' => 'publish',
1581
- 'post_type' => 'page',
1582
- 'post_author' => $curr_user_id,
1583
- 'menu_order' => 9999,
1584
- );
1585
- $page_id = wp_insert_post( $page_data );
1586
- if ( is_wp_error( $page_id ) ) {
1587
- $preview_page_created = 0;
1588
- }
1589
- }
1590
- if ( 1 === $preview_page_created ) {
1591
- // DISPLAY SLIDER PREVIEW BUTTON.
1592
- if ( 'publish' === $post_status ) {
1593
- echo "<div id='sa_preview_slider' class='button button-secondary' ";
1594
- echo "onClick='document.getElementById(\"sa_preview_popup\").style.display = \"block\";'>Preview Slider</div>\n";
1595
- }
1596
- // DISPLAY SLIDER PREVIEW POPUP.
1597
- $preview_page_url = get_page_link( $page_id );
1598
- echo "<div id='sa_preview_popup' style='display:none;'>\n";
1599
- echo "<div id='sa_preview_wrapper'>\n";
1600
- echo "<div id='sa_preview_close' title='Close Slider Preview' ";
1601
- echo "onClick='document.getElementById(\"sa_preview_popup\").style.display = \"none\";'>X</div>\n";
1602
- echo "<div id='sa_preview_content'>";
1603
- echo "<iframe src='" . esc_attr( $preview_page_url ) . "'></iframe>\n";
1604
- echo "</div>\n"; // #sa_preview_content
1605
- echo "</div>\n"; // #sa_preview_wrapper
1606
- echo "</div>\n";
1607
- }
1608
- }
1609
- }
1610
-
1611
-
1612
-
1613
- /**
1614
- * ##### META BOX CONTENT - 'Items Displayed' BOX #####
1615
- *
1616
- * @param array $post Custom Post 'sa_slider'.
1617
- */
1618
- function cpt_slider_items_content( $post ) {
1619
- $items_width1 = intval( get_post_meta( $post->ID, 'sa_items_width1', true ) );
1620
- $items_width2 = intval( get_post_meta( $post->ID, 'sa_items_width2', true ) );
1621
- $items_width3 = intval( get_post_meta( $post->ID, 'sa_items_width3', true ) );
1622
- $items_width4 = intval( get_post_meta( $post->ID, 'sa_items_width4', true ) );
1623
- $items_width5 = intval( get_post_meta( $post->ID, 'sa_items_width5', true ) );
1624
- $items_width6 = intval( get_post_meta( $post->ID, 'sa_items_width6', true ) );
1625
- if ( 0 === $items_width1 ) {
1626
- $items_width1 = 1; }
1627
- if ( 0 === $items_width2 ) {
1628
- $items_width2 = 1; }
1629
- if ( 0 === $items_width3 ) {
1630
- $items_width3 = 1; }
1631
- if ( 0 === $items_width4 ) {
1632
- $items_width4 = 1; }
1633
- if ( 0 === $items_width5 ) {
1634
- $items_width5 = 1; }
1635
- if ( 0 === $items_width6 ) {
1636
- $items_width6 = $items_width5; }
1637
-
1638
- echo "<div id='items_displayed_metabox'>\n";
1639
- echo "<h4>Browser/Device Width:</h4>\n";
1640
- // items for browser width category 1.
1641
- echo "<div><em class='sa_tooltip' href='' title='Up to 479 pixels'></em><span>Mobile Portrait</span><select name='sa_items_width1'>";
1642
- for ( $i = 1; $i <= 12; $i++ ) {
1643
- if ( $i === $items_width1 ) {
1644
- echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1645
- } else {
1646
- echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1647
- }
1648
- }
1649
- echo "</select></div>\n";
1650
- // items for browser width category 2.
1651
- echo "<div><em class='sa_tooltip' href='' title='480 to 767 pixels'></em><span>Mobile Landscape</span><select name='sa_items_width2'>";
1652
- for ( $i = 1; $i <= 12; $i++ ) {
1653
- if ( $i === $items_width2 ) {
1654
- echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1655
- } else {
1656
- echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1657
- }
1658
- }
1659
- echo "</select></div>\n";
1660
- // items for browser width category 3.
1661
- echo "<div><em class='sa_tooltip' href='' title='768 to 979 pixels'></em><span>Tablet Portrait</span><select name='sa_items_width3'>";
1662
- for ( $i = 1; $i <= 12; $i++ ) {
1663
- if ( $i === $items_width3 ) {
1664
- echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1665
- } else {
1666
- echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1667
- }
1668
- }
1669
- echo "</select></div>\n";
1670
- // items for browser width category 4.
1671
- echo "<div><em class='sa_tooltip' href='' title='980 to 1199 pixels'></em><span>Desktop Small</span><select name='sa_items_width4'>";
1672
- for ( $i = 1; $i <= 12; $i++ ) {
1673
- if ( $i === $items_width4 ) {
1674
- echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1675
- } else {
1676
- echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1677
- }
1678
- }
1679
- echo "</select></div>\n";
1680
- // items for browser width category 5.
1681
- echo "<div><em class='sa_tooltip' href='' title='1200 to 1499 pixels'></em><span>Desktop Large</span><select name='sa_items_width5'>";
1682
- for ( $i = 1; $i <= 12; $i++ ) {
1683
- if ( $i === $items_width5 ) {
1684
- echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1685
- } else {
1686
- echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1687
- }
1688
- }
1689
- echo "</select></div>\n";
1690
- // items for browser width category 6.
1691
- echo "<div><em class='sa_tooltip' href='' title='Over 1500 pixels'></em><span>Desktop X-Large</span><select name='sa_items_width6'>";
1692
- for ( $i = 1; $i <= 12; $i++ ) {
1693
- if ( $i === $items_width6 ) {
1694
- echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1695
- } else {
1696
- echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1697
- }
1698
- }
1699
- echo "</select></div>\n";
1700
- // slide transition effect.
1701
- $transition = get_post_meta( $post->ID, 'sa_transition', true );
1702
- if ( '' === $transition ) {
1703
- $transition = 'fade';
1704
- }
1705
- $option_arr = array();
1706
- $option_arr[0] = 'Slide';
1707
- $option_arr[1] = 'Fade';
1708
- $option_arr[2] = 'Zoom In';
1709
- $option_arr[3] = 'Zoom Out';
1710
- $option_arr[4] = 'Flip Out X';
1711
- $option_arr[5] = 'Flip Out Y';
1712
- $option_arr[6] = 'Rotate Left';
1713
- $option_arr[7] = 'Rotate Right';
1714
- $option_arr[8] = 'Bounce Out';
1715
- $option_arr[9] = 'Roll Out';
1716
- $option_arr[10] = 'Slide Down';
1717
- if ( ( 1 === $items_width1 ) && ( 1 === $items_width2 ) && ( 1 === $items_width3 ) && ( 1 === $items_width4 ) && ( 1 === $items_width5 ) && ( 1 === $items_width6 ) ) {
1718
- echo "<div class='sa_items_all_one' style='display:block;'>";
1719
- } else {
1720
- echo "<div class='sa_items_all_one' style='display:none;'>";
1721
- }
1722
- echo "<em class='sa_tooltip' href='' title='NOTE: Slide transitions only work when the above items displayed are ALL SET TO 1'></em>";
1723
- echo "<span style='color:firebrick !important;'>Slide Transition</span><select style='max-width:100px !important;' name='sa_transition'>";
1724
- $tot_opt = count( $option_arr );
1725
- for ( $i = 0; $i < $tot_opt; $i++ ) {
1726
- if ( $transition === $option_arr[ $i ] ) {
1727
- echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "' selected>" . esc_html( $option_arr[ $i ] ) . '</option>';
1728
- } else {
1729
- echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "'>" . esc_html( $option_arr[ $i ] ) . '</option>';
1730
- }
1731
- }
1732
- echo "</select></div>\n";
1733
-
1734
- // HERO SLIDER.
1735
- $hero_slider = get_post_meta( $post->ID, 'sa_hero_slider', true );
1736
- if ( '1' !== $hero_slider ) {
1737
- $hero_slider = '0';
1738
- }
1739
- if ( ( 1 === $items_width1 ) && ( 1 === $items_width2 ) && ( 1 === $items_width3 ) && ( 1 === $items_width4 ) && ( 1 === $items_width5 ) && ( 1 === $items_width6 ) ) {
1740
- echo "<div id='sa_hero_slider_wrapper' class='sa_items_all_one' style='display:block;'>";
1741
- } else {
1742
- echo "<div id='sa_hero_slider_wrapper' class='sa_items_all_one' style='display:none;'>";
1743
- }
1744
- echo '<span>Hero Slider</span>';
1745
- // hero slider checkbox.
1746
- if ( '1' === $hero_slider ) {
1747
- echo "<input type='checkbox' id='sa_hero_slider' name='sa_hero_slider' value='1' checked/>";
1748
- } else {
1749
- echo "<input type='checkbox' id='sa_hero_slider' name='sa_hero_slider' value='1'/>";
1750
- }
1751
- $hs_note1 = 'Most WP Theme &apos;Page Builders&apos; (Visual Composer, Divi, Elementor, SiteOrigin...) allow you create full-width sections in your content. If you are not using a page builder then you will have to manually create a PHP template file to include a full-width container.';
1752
- $hs_note2 = 'The slider height is set to 100% screen/device height using CSS &apos;vh&apos; (viewport height). Just about all browsers now support CSS viewport units, except Opera Mini which was installed on the old &apos;button&apos; phones.';
1753
- if ( '1' === $hero_slider ) {
1754
- echo "<div id='sa_hero_slider_note' style='display:block;'>";
1755
- } else {
1756
- echo "<div id='sa_hero_slider_note' style='display:none;'>";
1757
- }
1758
- echo '<strong>Please Note:</strong>';
1759
- echo "<ol><li>Shortcode should be inserted into a full-width section<em class='sa_tooltip' title='" . esc_attr( $hs_note1 ) . "'></em></li>";
1760
- echo "<li>Only works on browsers that support Viewport units - see <a href='https://caniuse.com/#feat=viewport-units' target='_blank'>here</a>";
1761
- echo "<em class='sa_tooltip' title='" . esc_attr( $hs_note2 ) . "'></em></li></ol></div>";
1762
- echo "</div>\n";
1763
-
1764
- // SHOWCASE SLIDER.
1765
- if ( ( 1 === $items_width1 ) && ( 1 === $items_width2 ) && ( 1 === $items_width3 ) && ( 1 === $items_width4 ) && ( 1 === $items_width5 ) && ( 1 === $items_width6 ) ) {
1766
- echo "<div id='sa_showcase_slider_wrapper' style='display:none;'>";
1767
- } else {
1768
- echo "<div id='sa_showcase_slider_wrapper' style='display:block;'>";
1769
- }
1770
- // showcase slider checkbox.
1771
- $showcase_slider = get_post_meta( $post->ID, 'sa_showcase_slider', true );
1772
- if ( '1' !== $showcase_slider ) {
1773
- $showcase_slider = '0';
1774
- }
1775
- echo "<div class='sa_ss_line'><span><strong>Showcase Carousel</strong></span>";
1776
- echo "<input type='checkbox' id='sa_showcase_slider' name='sa_showcase_slider' value='1'";
1777
- if ( '1' === $showcase_slider ) {
1778
- echo ' checked'; }
1779
- echo ' />';
1780
- echo '</div>';
1781
- if ( '1' === $showcase_slider ) {
1782
- echo "<div id='sa_showcase_slider_pro' style='display:block;'>";
1783
- } else {
1784
- echo "<div id='sa_showcase_slider_pro' style='display:none;'>";
1785
- }
1786
- // showcase slider - desktop width.
1787
- $showcase_width = get_post_meta( $post->ID, 'sa_showcase_width', true );
1788
- if ( '' === $showcase_width ) {
1789
- $showcase_width = '120';
1790
- }
1791
- echo "<div class='sa_ss_line'><span>Desktop Width</span>";
1792
- echo "<input type='text' id='sa_showcase_width' name='sa_showcase_width' value='" . esc_attr( $showcase_width ) . "'>";
1793
- echo "<em>%</em></div>\n";
1794
- // showcase slider - use on tablets.
1795
- $showcase_tablet = get_post_meta( $post->ID, 'sa_showcase_tablet', true );
1796
- if ( ( '0' !== $showcase_tablet ) && ( '1' !== $showcase_tablet ) ) {
1797
- $showcase_tablet = '1';
1798
- }
1799
- echo "<div class='sa_ss_line'><span>Use on Tablets</span>";
1800
- if ( '1' === $showcase_tablet ) {
1801
- echo "<input type='checkbox' id='sa_showcase_tablet' name='sa_showcase_tablet' value='1' checked />";
1802
- } else {
1803
- echo "<input type='checkbox' id='sa_showcase_tablet' name='sa_showcase_tablet' value='1' />";
1804
- }
1805
- echo "</div>\n";
1806
- // showcase slider - tablet width.
1807
- $showcase_width_tab = get_post_meta( $post->ID, 'sa_showcase_width_tab', true );
1808
- if ( '' === $showcase_width_tab ) {
1809
- $showcase_width_tab = '130';
1810
- }
1811
- echo "<div class='sa_ss_line'><span>Tablet Width</span>";
1812
- echo "<input type='text' id='sa_showcase_width_tab' name='sa_showcase_width_tab' value='" . esc_attr( $showcase_width_tab ) . "'>";
1813
- echo "<em>%</em></div>\n";
1814
- // showcase slider - use on mobiles.
1815
- $showcase_mobile = get_post_meta( $post->ID, 'sa_showcase_mobile', true );
1816
- if ( '1' !== $showcase_mobile ) {
1817
- $showcase_mobile = '0';
1818
- }
1819
- echo "<div class='sa_ss_line'><span>Use on Mobiles</span>";
1820
- if ( '1' === $showcase_mobile ) {
1821
- echo "<input type='checkbox' id='sa_showcase_mobile' name='sa_showcase_mobile' value='1' checked />";
1822
- } else {
1823
- echo "<input type='checkbox' id='sa_showcase_mobile' name='sa_showcase_mobile' value='1' />";
1824
- }
1825
- echo "</div>\n";
1826
- // showcase slider - mobile width.
1827
- $showcase_width_mob = get_post_meta( $post->ID, 'sa_showcase_width_mob', true );
1828
- if ( '' === $showcase_width_mob ) {
1829
- $showcase_width_mob = '140';
1830
- }
1831
- echo "<div class='sa_ss_line'><span>Mobile Width</span>";
1832
- echo "<input type='text' id='sa_showcase_width_mob' name='sa_showcase_width_mob' value='" . esc_attr( $showcase_width_mob ) . "'>";
1833
- echo "<em>%</em></div>\n";
1834
- // showcase slider - css to style left/rightmost slides.
1835
- $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1836
- echo "<div class='sa_ss_css_line'>CSS to target left+right partial slides:";
1837
- echo "<div id='ss_css_value'>#" . esc_html( $css_id ) . ' .sc_partial</div>';
1838
- echo "</div>\n";
1839
- echo '</div>'; // #sa_showcase_slider_pro
1840
- echo "</div>\n";
1841
-
1842
- echo "</div>\n";
1843
- }
1844
-
1845
-
1846
-
1847
- /**
1848
- * ##### META BOX CONTENT - 'Slider Style' BOX #####
1849
- *
1850
- * @param array $post Custom Post 'sa_slider'.
1851
- */
1852
- function cpt_slider_style_content( $post ) {
1853
- // CSS ID.
1854
- $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1855
- if ( '' === $css_id ) {
1856
- $css_id = 'slider_' . $post->ID;
1857
- }
1858
- echo "<div id='slider_style_metabox'>\n";
1859
- echo "<h4>CSS <span>#id</span> for Slider:</h4>\n";
1860
- echo "<div style='padding-bottom:10px; color:#909090;'>Must consist of letters (upper/lowercase) or Underscore '_' characters <span style='color:firebrick;'>ONLY!</span></div>\n";
1861
- echo "<input type='text' id='sa_css_id' name='sa_css_id' value='" . esc_attr( $css_id ) . "'/>\n";
1862
- echo "<div id='css_note_text'>To style slides use CSS selector:</div>";
1863
- echo "<div id='css_note_value'>#" . esc_html( $css_id ) . ' .owl-item</div>';
1864
- echo "<div class='ca_style_hr'></div>\n";
1865
-
1866
- // SLIDER PADDING (TOP, RIGHT, BOTTOM, LEFT).
1867
- $wrapper_padd_top = get_post_meta( $post->ID, 'sa_wrapper_padd_top', true );
1868
- if ( '' === $wrapper_padd_top ) {
1869
- $wrapper_padd_top = '0'; }
1870
- $wrapper_padd_right = get_post_meta( $post->ID, 'sa_wrapper_padd_right', true );
1871
- if ( '' === $wrapper_padd_right ) {
1872
- $wrapper_padd_right = '0'; }
1873
- $wrapper_padd_bottom = get_post_meta( $post->ID, 'sa_wrapper_padd_bottom', true );
1874
- if ( '' === $wrapper_padd_bottom ) {
1875
- $wrapper_padd_bottom = '0'; }
1876
- $wrapper_padd_left = get_post_meta( $post->ID, 'sa_wrapper_padd_left', true );
1877
- if ( '' === $wrapper_padd_left ) {
1878
- $wrapper_padd_left = '0'; }
1879
- $tooltip = 'Padding space around the entire carousel/slider';
1880
- echo "<h4>Padding <span>(pixels)</span>:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1881
- echo "<div class='ca_style_padding'>";
1882
- echo "<div id='padd_top'>";
1883
- echo "<input type='text' id='sa_wrapper_padd_top' name='sa_wrapper_padd_top' value='" . esc_attr( $wrapper_padd_top ) . "'></div>";
1884
- echo "<div id='padd_right'>";
1885
- echo "<input type='text' id='sa_wrapper_padd_right' name='sa_wrapper_padd_right' value='" . esc_attr( $wrapper_padd_right ) . "'></div>";
1886
- echo "<div type='text' id='padd_bottom'>";
1887
- echo "<input type='text' id='sa_wrapper_padd_bottom' name='sa_wrapper_padd_bottom' value='" . esc_attr( $wrapper_padd_bottom ) . "'></div>";
1888
- echo "<div id='padd_left'>";
1889
- echo "<input type='text' id='sa_wrapper_padd_left' name='sa_wrapper_padd_left' value='" . esc_attr( $wrapper_padd_left ) . "'></div>";
1890
- echo "</div>\n";
1891
- echo "<div style='clear:both; float:none; width:100%; height:10px;'></div>";
1892
-
1893
- $tooltip = 'Style settings for the slider navigation arrows and slider pagination';
1894
- echo "<h4>Slider Navigation:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1895
-
1896
- // AUTOHIDE ARROWS.
1897
- $autohide_arrows = get_post_meta( $post->ID, 'sa_autohide_arrows', true );
1898
- if ( '' === $autohide_arrows ) {
1899
- $autohide_arrows = '1';
1900
- }
1901
- echo "<div class='ca_style_setting_line'><span style='width:140px;'>Autohide Arrows</span>";
1902
- if ( '1' === $autohide_arrows ) {
1903
- echo "<input type='checkbox' id='sa_autohide_arrows' name='sa_autohide_arrows' value='1' checked/>";
1904
- } else {
1905
- echo "<input type='checkbox' id='sa_autohide_arrows' name='sa_autohide_arrows' value='1'/>";
1906
- }
1907
- echo "</div>\n";
1908
-
1909
- // SHOW DOT PER SLIDE.
1910
- $dot_per_slide = get_post_meta( $post->ID, 'sa_dot_per_slide', true );
1911
- if ( '' === $dot_per_slide ) {
1912
- $dot_per_slide = '0';
1913
- }
1914
- echo "<div class='ca_style_setting_line'><span style='width:140px;'>Show 1 Dot Per Slide</span>";
1915
- if ( '1' === $dot_per_slide ) {
1916
- echo "<input type='checkbox' id='sa_dot_per_slide' name='sa_dot_per_slide' value='1' checked/>";
1917
- } else {
1918
- echo "<input type='checkbox' id='sa_dot_per_slide' name='sa_dot_per_slide' value='1'/>";
1919
- }
1920
- echo "</div>\n";
1921
-
1922
- $tooltip = 'The background color and border around the entire carousel/slider';
1923
- echo "<h4>Background/Border:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1924
-
1925
- // SLIDER BACKGROUND COLOR.
1926
- $background_color = get_post_meta( $post->ID, 'sa_background_color', true );
1927
- if ( '' === $background_color ) {
1928
- $background_color = 'rgba(0,0,0,0)';
1929
- }
1930
- echo "<div class='ca_style_setting_line'><span>Background:</span>";
1931
- echo "<input type='text' id='sa_background_color' name='sa_background_color' value='" . esc_attr( $background_color ) . "'></div>\n";
1932
-
1933
- // SLIDER BORDER (WIDTH & COLOR).
1934
- $border_width = get_post_meta( $post->ID, 'sa_border_width', true );
1935
- if ( '' === $border_width ) {
1936
- $border_width = '0';
1937
- }
1938
- $border_color = get_post_meta( $post->ID, 'sa_border_color', true );
1939
- if ( '' === $border_color ) {
1940
- $border_color = 'rgba(0,0,0,0)';
1941
- }
1942
- echo "<div class='ca_style_setting_line'><span>Border Style:</span>";
1943
- echo "<input type='text' id='sa_border_width' name='sa_border_width' value='" . esc_attr( $border_width ) . "'><em>px</em>";
1944
- echo "<input type='text' id='sa_border_color' name='sa_border_color' value='" . esc_attr( $border_color ) . "'></div>\n";
1945
-
1946
- // SLIDER BORDER RADIUS.
1947
- $border_radius = get_post_meta( $post->ID, 'sa_border_radius', true );
1948
- if ( '' === $border_radius ) {
1949
- $border_radius = '0';
1950
- }
1951
- echo "<div class='ca_style_setting_line'><span>Border Radius:</span>";
1952
- echo "<input type='text' id='sa_border_radius' name='sa_border_radius' value='" . esc_attr( $border_radius ) . "'></div>\n";
1953
-
1954
- echo "<div class='ca_style_hr' style='margin-top:10px;'></div>\n";
1955
-
1956
- $tooltip = 'The style settings for all slides (within the slider/carousel)';
1957
- echo "<h4>Slide Style:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1958
-
1959
- // SLIDE - MINIMUM HEIGHT.
1960
- $slide_min_height = get_post_meta( $post->ID, 'sa_slide_min_height_perc', true );
1961
- if ( '' === $slide_min_height ) {
1962
- $slide_min_height = '50';
1963
- }
1964
- echo "<div style='padding:5px 0px 10px;'>\n";
1965
- $tooltip = 'The minimum height of each slide. Can be set to a percentage of the slide width, or for image sliders set to a 4:3 or 16:9 aspect ratio.';
1966
- echo "<div class='ca_style_setting_line' id='ca_style_min_height' style='padding-bottom:7px !important;'>";
1967
- echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Min Height:</span><br/>";
1968
- if ( 'aspect43' === $slide_min_height ) {
1969
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;'/><em>%</em>";
1970
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px'/><em>px</em>";
1971
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43' checked/><em>4:3</em>";
1972
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169'/><em>16:9</em>";
1973
- } elseif ( 'aspect169' === $slide_min_height ) {
1974
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;'/><em>%</em>";
1975
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px'/><em>px</em>";
1976
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43'/><em>4:3</em>";
1977
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169' checked/><em>16:9</em>";
1978
- } elseif ( strpos( $slide_min_height, 'px' ) !== false ) {
1979
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;'/><em>%</em>";
1980
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px' checked/><em>px</em>";
1981
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43'/><em>4:3</em>";
1982
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169'/><em>16:9</em>";
1983
- } else {
1984
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;' checked/><em>%</em>";
1985
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px'/><em>px</em>";
1986
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43'/><em>4:3</em>";
1987
- echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169'/><em>16:9</em>";
1988
- }
1989
- echo "</div>\n";
1990
- if ( ( 'aspect43' === $slide_min_height ) || ( 'aspect169' === $slide_min_height ) ) {
1991
- $mh_suffix = '';
1992
- echo "<div class='ca_style_setting_line' id='sa_slide_min_height_wrapper' style='display:none;'>";
1993
- echo "<input type='text' id='sa_slide_min_height' name='sa_slide_min_height' value='" . esc_attr( $slide_min_height ) . "'/>";
1994
- echo "<em id='mh_suffix'>" . esc_html( $mh_suffix ) . "</em></div>\n";
1995
- echo "<input type='hidden' id='sa_slide_min_height_hidden' name='sa_slide_min_height_hidden' value='0'/>\n";
1996
- } else {
1997
- if ( strpos( $slide_min_height, 'px' ) !== false ) {
1998
- $mh_value = str_replace( 'px', '', $slide_min_height );
1999
- $mh_suffix = 'px';
2000
- } else {
2001
- $mh_value = $slide_min_height;
2002
- $mh_suffix = '%';
2003
- }
2004
- echo "<div class='ca_style_setting_line' id='sa_slide_min_height_wrapper'><span style='width:20px;'>&nbsp;</span>";
2005
- echo "<input type='text' id='sa_slide_min_height' name='sa_slide_min_height' value='" . esc_attr( $mh_value ) . "'/>";
2006
- echo "<em id='mh_suffix'>" . esc_html( $mh_suffix ) . "</em></div>\n";
2007
- echo "<input type='hidden' id='sa_slide_min_height_hidden' name='sa_slide_min_height_hidden' value='" . esc_attr( $mh_value ) . "'/>\n";
2008
- }
2009
- echo "</div>\n";
2010
-
2011
- // SLIDE - PADDING TOP/BOTTOM.
2012
- $slide_padding_tb = get_post_meta( $post->ID, 'sa_slide_padding_tb', true );
2013
- if ( '' === $slide_padding_tb ) {
2014
- $slide_padding_tb = '5';
2015
- }
2016
- $tooltip = 'Padding space top/bottom for each individual slide';
2017
- echo "<div class='ca_style_setting_line' id='ca_style_padding_top_bottom'><span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Padding:</span>";
2018
- echo "<input type='text' id='sa_slide_padding_tb' name='sa_slide_padding_tb' value='" . esc_attr( $slide_padding_tb ) . "'><em>%</em></div>\n";
2019
-
2020
- // SLIDE - PADDING LEFT/RIGHT.
2021
- $slide_padding_lr = get_post_meta( $post->ID, 'sa_slide_padding_lr', true );
2022
- if ( '' === $slide_padding_lr ) {
2023
- $slide_padding_lr = '5';
2024
- }
2025
- $tooltip = 'Padding space left/right for each individual slide';
2026
- echo "<div class='ca_style_setting_line' id='ca_style_padding_left_right'><span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Padding:</span>";
2027
- echo "<input type='text' id='sa_slide_padding_lr' name='sa_slide_padding_lr' value='" . esc_attr( $slide_padding_lr ) . "'><em>%</em></div>\n";
2028
-
2029
- // SLIDE - MARGIN LEFT/RIGHT.
2030
- $slide_margin_lr = get_post_meta( $post->ID, 'sa_slide_margin_lr', true );
2031
- if ( '' === $slide_margin_lr ) {
2032
- $slide_margin_lr = '0';
2033
- }
2034
- $tooltip = 'Margin space left and right of each slide';
2035
- echo "<div class='ca_style_setting_line' id='ca_style_margin_left_right'><span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Margin:</span>";
2036
- echo "<input type='text' id='sa_slide_margin_lr' name='sa_slide_margin_lr' value='" . esc_attr( $slide_margin_lr ) . "'><em>%</em></div>\n";
2037
-
2038
- $tooltip = 'The link/popup buttons that appear on a slide';
2039
- echo "<h4>Link/Popup Icons:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
2040
-
2041
- // LINK/POPUP ICONS - ICON LOCATION.
2042
- $slide_icons_location = get_post_meta( $post->ID, 'sa_slide_icons_location', true );
2043
- if ( '' === $slide_icons_location ) {
2044
- $slide_icons_location = 'Center Center';
2045
- }
2046
- echo "<div class='ca_style_setting_line'><span>Icon Location</span>";
2047
- echo "<select id='sa_slide_icons_location' name='sa_slide_icons_location'>";
2048
- $option_arr = array();
2049
- $option_arr[0] = 'Center Center';
2050
- $option_arr[1] = 'Top Left';
2051
- $option_arr[2] = 'Top Center';
2052
- $option_arr[3] = 'Top Right';
2053
- $option_arr[4] = 'Bottom Left';
2054
- $option_arr[5] = 'Bottom Center';
2055
- $option_arr[6] = 'Bottom Right';
2056
- $tot_opt = count( $option_arr );
2057
- for ( $i = 0; $i < $tot_opt; $i++ ) {
2058
- if ( $option_arr[ $i ] === $slide_icons_location ) {
2059
- echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "' selected>" . esc_html( $option_arr[ $i ] ) . '</option>';
2060
- } else {
2061
- echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "'>" . esc_html( $option_arr[ $i ] ) . '</option>';
2062
- }
2063
- }
2064
- echo "</select></div>\n";
2065
-
2066
- // LINK/POPUP ICONS - ALWAYS VISIBLE.
2067
- $slide_icons_visible = get_post_meta( $post->ID, 'sa_slide_icons_visible', true );
2068
- if ( '1' !== $slide_icons_visible ) {
2069
- $slide_icons_visible = '0';
2070
- }
2071
- echo "<div class='ca_style_setting_line'><span>Always Visible</span>";
2072
- if ( '1' === $slide_icons_visible ) {
2073
- echo "<input type='checkbox' id='sa_slide_icons_visible' name='sa_slide_icons_visible' value='1' checked/>";
2074
- } else {
2075
- echo "<input type='checkbox' id='sa_slide_icons_visible' name='sa_slide_icons_visible' value='1'/>";
2076
- }
2077
- echo "</div>\n";
2078
-
2079
- // LINK/POPUP ICONS - COLOR SCHEME.
2080
- $slide_icons_color = get_post_meta( $post->ID, 'sa_slide_icons_color', true );
2081
- if ( '' === $slide_icons_color ) {
2082
- $slide_icons_location = 'white';
2083
- }
2084
- echo "<div class='ca_style_setting_line'><span>Color Scheme</span>";
2085
- echo "<select id='sa_slide_icons_color' name='sa_slide_icons_color'>";
2086
- if ( 'black' === $slide_icons_color ) {
2087
- echo "<option value='white'>White</option>";
2088
- echo "<option value='black' selected>Black</option>";
2089
- } else {
2090
- echo "<option value='white selected'>White</option>";
2091
- echo "<option value='black'>Black</option>";
2092
- }
2093
- echo "</select></div>\n";
2094
-
2095
- // LINK/POPUP ICONS - FULL SLIDE LINKS.
2096
- $slide_icons_fullslide = get_post_meta( $post->ID, 'sa_slide_icons_fullslide', true );
2097
- if ( '1' !== $slide_icons_fullslide ) {
2098
- $slide_icons_fullslide = '0';
2099
- }
2100
- echo "<div class='ca_style_setting_line'><span>Full Slide Links</span>";
2101
- if ( '1' === $slide_icons_fullslide ) {
2102
- echo "<input type='checkbox' id='sa_slide_icons_fullslide' name='sa_slide_icons_fullslide' value='1' checked/>";
2103
- } else {
2104
- echo "<input type='checkbox' id='sa_slide_icons_fullslide' name='sa_slide_icons_fullslide' value='1'/>";
2105
- }
2106
- $tooltip = 'This makes the entire slide area a clickable link. NOTE: This feature is ';
2107
- $tooltip .= 'disabled if you have both a slide link AND a popup link for a slide.';
2108
- $tt_style = 'margin:0px 0px -3px 5px; cursor:help;';
2109
- echo "<em class='sa_tooltip' style='" . esc_attr( $tt_style ) . "' title='" . esc_attr( $tooltip ) . "'></em>";
2110
- echo "</div>\n";
2111
-
2112
- // ##### OTHER SETTINGS #####
2113
-
2114
- echo "<h4 style='margin-top:10px !important;'>Other Settings:</h4>";
2115
-
2116
- // FETCH OTHER SETTINGS POST META.
2117
- $other_settings = get_post_meta( $post->ID, 'sa_other_settings', true );
2118
- if ( '' !== $other_settings ) {
2119
- $other_settings_arr = explode( '|', $other_settings );
2120
- }
2121
- // setting 1 - sa_window_onload.
2122
- if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[0] ) ) {
2123
- $window_onload = $other_settings_arr[0];
2124
- } else {
2125
- $window_onload = get_post_meta( $post->ID, 'sa_window_onload', true );
2126
- if ( '' === $window_onload ) {
2127
- $window_onload = '0';
2128
- }
2129
- }
2130
- // setting 2 - sa_strip_javascript.
2131
- if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[1] ) ) {
2132
- $strip_javascript = $other_settings_arr[1];
2133
- } else {
2134
- $strip_javascript = get_post_meta( $post->ID, 'sa_strip_javascript', true );
2135
- if ( '' === $strip_javascript ) {
2136
- $strip_javascript = '0';
2137
- }
2138
- }
2139
- // setting 3 - sa_lazy_load_images.
2140
- if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[2] ) ) {
2141
- $lazy_load_images = $other_settings_arr[2];
2142
- } else {
2143
- $lazy_load_images = get_post_meta( $post->ID, 'sa_lazy_load_images', true );
2144
- if ( '' === $lazy_load_images ) {
2145
- $lazy_load_images = '0';
2146
- }
2147
- }
2148
- // setting 4 - sa_ulli_containers.
2149
- if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[3] ) ) {
2150
- $ulli_containers = $other_settings_arr[3];
2151
- } else {
2152
- $ulli_containers = get_post_meta( $post->ID, 'sa_ulli_containers', true );
2153
- if ( '' === $ulli_containers ) {
2154
- $ulli_containers = '0';
2155
- }
2156
- }
2157
- // setting 5 - sa_rtl_slider.
2158
- if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[4] ) ) {
2159
- $rtl_slider = $other_settings_arr[4];
2160
- } else {
2161
- $rtl_slider = '0';
2162
- }
2163
- // setting 6 - sa_disable_preview.
2164
- if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[5] ) ) {
2165
- $disable_preview = $other_settings_arr[5];
2166
- } else {
2167
- $disable_preview = '0';
2168
- }
2169
- // setting 7 - bg_image_size.
2170
- $bg_image_size = 'full';
2171
- if ( isset( $other_settings_arr ) && ( count( $other_settings_arr ) > 6 ) ) {
2172
- if ( '' !== $other_settings_arr[6] ) {
2173
- $bg_image_size = $other_settings_arr[6];
2174
- }
2175
- }
2176
- // setting 8 - sa_disable_slide_ids.
2177
- if ( isset( $other_settings_arr ) && ( count( $other_settings_arr ) > 7 ) ) {
2178
- $disable_slide_ids = $other_settings_arr[7];
2179
- } else {
2180
- $disable_slide_ids = '0';
2181
- }
2182
-
2183
- // USE 'DOMContentLoaded' EVENT (checkbox).
2184
- $tooltip = 'Load the Slide Anything JavaScript during the DOMContentLoaded event. Use this option if jQuery ';
2185
- $tooltip .= 'is loading in your theme footer and you are getting the JavaScript error message ';
2186
- $tooltip .= '&quot;Uncaught ReferenceError: jQuery is not defined&quot;.';
2187
- echo "<div class='sa_window_onload_line'>";
2188
- echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>DOMContentLoaded event:</span>";
2189
- if ( '1' === $window_onload ) {
2190
- echo "<input type='checkbox' id='sa_window_onload' name='sa_window_onload' value='1' checked/>";
2191
- } else {
2192
- echo "<input type='checkbox' id='sa_window_onload' name='sa_window_onload' value='1'/>";
2193
- }
2194
- echo "</div>\n";
2195
-
2196
- echo "<div style='display:none !important;'>";
2197
- echo "<input type='checkbox' id='sa_lazy_load_images' name='sa_lazy_load_images' value='0'/>";
2198
- echo "</div>\n";
2199
-
2200
- // Use UL and LI Containers.
2201
- $tooltip = 'Use &quot;UL&quot; as the DOM element for &quot;owl-stage&quot; and use &quot;LI&quot; as the DOM elements for &quot;owl-item&quot;.';
2202
- echo "<div class='sa_window_onload_line'>";
2203
- echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Use UL and LI Containers:</span>";
2204
- if ( '1' === $ulli_containers ) {
2205
- echo "<input type='checkbox' id='sa_ulli_containers' name='sa_ulli_containers' value='1' checked/>";
2206
- } else {
2207
- echo "<input type='checkbox' id='sa_ulli_containers' name='sa_ulli_containers' value='1'/>";
2208
- }
2209
- echo "</div>\n";
2210
-
2211
- // Right to Left Slider.
2212
- $tooltip = 'Change the direction of the slider to be right to left.';
2213
- echo "<div class='sa_window_onload_line'>";
2214
- echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Right to Left Slider:</span>";
2215
- if ( '1' === $rtl_slider ) {
2216
- echo "<input type='checkbox' id='sa_rtl_slider' name='sa_rtl_slider' value='1' checked/>";
2217
- } else {
2218
- echo "<input type='checkbox' id='sa_rtl_slider' name='sa_rtl_slider' value='1'/>";
2219
- }
2220
- echo "</div>\n";
2221
-
2222
- // Disable Preview Feature.
2223
- $tooltip = 'Disable the &quot;Preview Slider&quot; feature in this settings page - the &quot;Slide Anything Popup Preview&quot; page will no longer be auto generated.';
2224
- echo "<div class='sa_window_onload_line'>";
2225
- echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Disable Preview Feature:</span>";
2226
- if ( '1' === $disable_preview ) {
2227
- echo "<input type='checkbox' id='sa_disable_preview' name='sa_disable_preview' value='1' checked/>";
2228
- } else {
2229
- echo "<input type='checkbox' id='sa_disable_preview' name='sa_disable_preview' value='1'/>";
2230
- }
2231
- echo "</div>\n";
2232
-
2233
- // Don't use Slide IDs.
2234
- $tooltip = 'Do not use a unique CSS ID to identify each slide container - use a unique CSS Class instead.';
2235
- echo "<div class='sa_window_onload_line'>";
2236
- echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Don't use CSS IDs for slides:</span>";
2237
- if ( '1' === $disable_slide_ids ) {
2238
- echo "<input type='checkbox' id='sa_disable_slide_ids' name='sa_disable_slide_ids' value='1' checked/>";
2239
- } else {
2240
- echo "<input type='checkbox' id='sa_disable_slide_ids' name='sa_disable_slide_ids' value='1'/>";
2241
- }
2242
- echo "</div>\n";
2243
-
2244
- // Start Position.
2245
- $num_slides = intval( get_post_meta( $post->ID, 'sa_num_slides', true ) );
2246
- if ( '' === $num_slides ) {
2247
- $start_pos = 1;
2248
- } else {
2249
- $start_pos = intval( get_post_meta( $post->ID, 'sa_start_pos', true ) );
2250
- if ( '' === $start_pos ) {
2251
- $start_pos = 1;
2252
- }
2253
- $tooltip = 'Which slide number to start display first';
2254
- echo "<div class='sa_window_onload_line'>";
2255
- echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Starting Slide Number:</span>";
2256
- echo "<select name='sa_start_pos'>";
2257
- for ( $i = 1; $i <= $num_slides; $i++ ) {
2258
- if ( $i === $start_pos ) {
2259
- echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
2260
- } else {
2261
- echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
2262
- }
2263
- }
2264
- echo '</select>';
2265
- echo "</div>\n";
2266
- }
2267
-
2268
- // SLIDE BACKGROUND IMAGE SIZE.
2269
- global $_wp_additional_image_sizes;
2270
- $image_size_arr = array();
2271
- // get WordPress image size data and save into and array.
2272
- $image_size_arr[0]['value'] = 'full';
2273
- $image_size_arr[0]['desc'] = 'Full Size';
2274
- $count = 1;
2275
- foreach ( get_intermediate_image_sizes() as $image_size ) {
2276
- if ( in_array( $image_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
2277
- $width = get_option( "{$image_size}_size_w" );
2278
- $height = get_option( "{$image_size}_size_h" );
2279
- } elseif ( isset( $_wp_additional_image_sizes[ $image_size ] ) ) {
2280
- $width = $_wp_additional_image_sizes[ $image_size ]['width'];
2281
- $height = $_wp_additional_image_sizes[ $image_size ]['height'];
2282
- }
2283
- if ( ( 0 !== $width ) && ( 0 !== $height ) ) {
2284
- $image_size_arr[ $count ]['value'] = $image_size;
2285
- $image_size_arr[ $count ]['desc'] = $image_size . ' (' . $width . '&times;' . $height . ')';
2286
- $count++;
2287
- }
2288
- }
2289
- // display the dropdown input box allowing user to select background image size.
2290
- $tooltip = 'Allows you to set the WordPress image size to use for your slide background images.';
2291
- echo "<div class='bg_image_size_wrapper'>\n<div>\n";
2292
- echo "<em class='sa_tooltip' href='' title='" . esc_attr( $tooltip ) . "'></em>";
2293
- echo '<span>Background Image Size:</span>';
2294
- echo "<div style='float:none; clear:both; width:100%; height:1px; padding:0px !important;'></div>\n</div>\n";
2295
- echo "<select name='bg_image_size'>";
2296
- $tot_size_arr = count( $image_size_arr );
2297
- for ( $j = 0; $j < $tot_size_arr; $j++ ) {
2298
- if ( $bg_image_size === $image_size_arr[ $j ]['value'] ) {
2299
- echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "' selected>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
2300
- } else {
2301
- echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "'>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
2302
- }
2303
- }
2304
- echo "</select>\n";
2305
- echo "</div>\n"; // .bg_image_size_wrapper
2306
-
2307
- echo "</div>\n";
2308
- }
2309
-
2310
-
2311
-
2312
- /**
2313
- * ##### META BOX CONTENT - 'Thumbnails (Pagination)' BOX #####
2314
- *
2315
- * @param array $post Custom Post 'sa_slider'.
2316
- */
2317
- function cpt_slider_thumbs_content( $post ) {
2318
- // get WordPress image size data and save into and array.
2319
- global $_wp_additional_image_sizes;
2320
- $image_size_arr = array();
2321
- $count = 0;
2322
- foreach ( get_intermediate_image_sizes() as $image_size ) {
2323
- if ( in_array( $image_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
2324
- $width = get_option( "{$image_size}_size_w" );
2325
- $height = get_option( "{$image_size}_size_h" );
2326
- } elseif ( isset( $_wp_additional_image_sizes[ $image_size ] ) ) {
2327
- $width = $_wp_additional_image_sizes[ $image_size ]['width'];
2328
- $height = $_wp_additional_image_sizes[ $image_size ]['height'];
2329
- }
2330
- if ( ( 0 !== $width ) && ( 0 !== $height ) ) {
2331
- $image_size_arr[ $count ]['value'] = $image_size;
2332
- $image_size_arr[ $count ]['desc'] = $image_size . ' (' . $width . '&times;' . $height . ')';
2333
- $count++;
2334
- }
2335
- }
2336
-
2337
- // Use thumbnail pagination (checkbox).
2338
- $thumbs_active = get_post_meta( $post->ID, 'sa_thumbs_active', true );
2339
- if ( '' === $thumbs_active ) {
2340
- $thumbs_active = '0';
2341
- }
2342
- echo "<div class='sa_thumbs_line'><span>Use Thumbnail Pagination:</span>";
2343
- if ( '1' === $thumbs_active ) {
2344
- echo "<input type='checkbox' id='sa_thumbs_active' name='sa_thumbs_active' value='1' checked/>";
2345
- } else {
2346
- echo "<input type='checkbox' id='sa_thumbs_active' name='sa_thumbs_active' value='1'/>";
2347
- }
2348
- echo "</div>\n";
2349
-
2350
- if ( '1' === $thumbs_active ) {
2351
- echo "<div id='sa_thumbs_settings' style='display:block;'>\n";
2352
- } else {
2353
- echo "<div id='sa_thumbs_settings' style='display:none;'>\n";
2354
- }
2355
-
2356
- // Thumbs Location (dropdown).
2357
- $thumbs_location = get_post_meta( $post->ID, 'sa_thumbs_location', true );
2358
- if ( '' === $thumbs_location ) {
2359
- $thumbs_location = 'inside_bottom';
2360
- }
2361
- echo "<div class='sa_thumbs_line'><span>Thumbs Location:</span>";
2362
- echo "<select id='sa_thumbs_location' name='sa_thumbs_location'>";
2363
- $option_arr = array();
2364
- $option_arr[0] = 'Inside Bottom';
2365
- $option_arr[1] = 'Inside Top';
2366
- $option_arr[2] = 'Inside Left';
2367
- $option_arr[3] = 'Inside Right';
2368
- $option_arr[4] = 'Outside Bottom';
2369
- $tot_opt = count( $option_arr );
2370
- for ( $i = 0; $i < $tot_opt; $i++ ) {
2371
- $value = strtolower( str_replace( ' ', '_', $option_arr[ $i ] ) );
2372
- if ( $value === $thumbs_location ) {
2373
- echo "<option value='" . esc_attr( $value ) . "' selected>" . esc_html( $option_arr[ $i ] ) . '</option>';
2374
- } else {
2375
- echo "<option value='" . esc_attr( $value ) . "'>" . esc_html( $option_arr[ $i ] ) . '</option>';
2376
- }
2377
- }
2378
- echo "</select></div>\n";
2379
-
2380
- // Thumbnail Image Size (dropdown).
2381
- $thumbs_image_size = get_post_meta( $post->ID, 'sa_thumbs_image_size', true );
2382
- if ( '' === $thumbs_image_size ) {
2383
- $thumbs_image_size = 'thumbnail';
2384
- }
2385
- echo "<div class='sa_thumbs_line'><span>Thumbnail Image Size:</span>";
2386
- echo "<select id='sa_thumbs_image_size' name='sa_thumbs_image_size'>";
2387
- $tot_img_arr = count( $image_size_arr );
2388
- for ( $i = 0; $i < $tot_img_arr; $i++ ) {
2389
- if ( $image_size_arr[ $i ]['value'] === $thumbs_image_size ) {
2390
- echo "<option value='" . esc_attr( $image_size_arr[ $i ]['value'] ) . "' selected>" . esc_html( $image_size_arr[ $i ]['desc'] ) . '</option>';
2391
- } else {
2392
- echo "<option value='" . esc_attr( $image_size_arr[ $i ]['value'] ) . "'>" . esc_html( $image_size_arr[ $i ]['desc'] ) . '</option>';
2393
- }
2394
- }
2395
- echo "</select></div>\n";
2396
-
2397
- // Container Padding.
2398
- $thumbs_padding = get_post_meta( $post->ID, 'sa_thumbs_padding', true );
2399
- if ( '' === $thumbs_padding ) {
2400
- $thumbs_padding = '3';
2401
- }
2402
- echo "<div class='sa_thumbs_line'><span>Container Padding:</span>";
2403
- echo "<input type='text' id='sa_thumbs_padding' name='sa_thumbs_padding' value='" . esc_attr( $thumbs_padding ) . "'><em>%</em>";
2404
- echo "</div>\n";
2405
-
2406
- // Thumbs Width.
2407
- $thumbs_width = get_post_meta( $post->ID, 'sa_thumbs_width', true );
2408
- if ( '' === $thumbs_width ) {
2409
- $thumbs_width = '150';
2410
- }
2411
- echo "<div class='sa_thumbs_line'><span>Thumbs Width:</span>";
2412
- echo "<input type='text' id='sa_thumbs_width' name='sa_thumbs_width' value='" . esc_attr( $thumbs_width ) . "'><em>px</em>";
2413
- echo "</div>\n";
2414
-
2415
- // Thumbs Height.
2416
- $thumbs_height = get_post_meta( $post->ID, 'sa_thumbs_height', true );
2417
- if ( '' === $thumbs_height ) {
2418
- $thumbs_height = '85';
2419
- }
2420
- echo "<div class='sa_thumbs_line'><span>Thumbs Height:</span>";
2421
- echo "<input type='text' id='sa_thumbs_height' name='sa_thumbs_height' value='" . esc_attr( $thumbs_height ) . "'><em>px</em>";
2422
- echo "</div>\n";
2423
-
2424
- // Thumbs Opacity.
2425
- $thumbs_opacity = get_post_meta( $post->ID, 'sa_thumbs_opacity', true );
2426
- if ( '' === $thumbs_opacity ) {
2427
- $thumbs_opacity = '50';
2428
- }
2429
- echo "<div class='sa_thumbs_line'><span>Thumbs Opacity:</span>";
2430
- echo "<input type='text' id='sa_thumbs_opacity' name='sa_thumbs_opacity' value='" . esc_attr( $thumbs_opacity ) . "'><em>%</em>";
2431
- echo "</div>\n";
2432
-
2433
- echo '<h4>Active Thumb Border Style</h4>';
2434
-
2435
- // Border Width.
2436
- $thumbs_border_width = get_post_meta( $post->ID, 'sa_thumbs_border_width', true );
2437
- if ( '' === $thumbs_border_width ) {
2438
- $thumbs_border_width = '0';
2439
- }
2440
- echo "<div class='sa_thumbs_line'><span>Border Width:</span>";
2441
- echo "<input type='text' id='sa_thumbs_border_width' name='sa_thumbs_border_width' value='" . esc_attr( $thumbs_border_width ) . "'><em>px</em>";
2442
- echo "</div>\n";
2443
-
2444
- // Border Color.
2445
- $thumbs_border_color = get_post_meta( $post->ID, 'sa_thumbs_border_color', true );
2446
- if ( '' === $thumbs_border_color ) {
2447
- $thumbs_border_color = '#ffffff';
2448
- }
2449
- echo "<div class='sa_thumbs_line'><span>Border Color:</span>";
2450
- echo "<input type='text' id='sa_thumbs_border_color' name='sa_thumbs_border_color' value='" . esc_attr( $thumbs_border_color ) . "'></div>\n";
2451
-
2452
- echo '<h4>Responsive Thumb Sizes</h4>';
2453
-
2454
- // Tablet Thumb Size.
2455
- $thumbs_resp_tablet = get_post_meta( $post->ID, 'sa_thumbs_resp_tablet', true );
2456
- if ( '' === $thumbs_resp_tablet ) {
2457
- $thumbs_resp_tablet = '75';
2458
- }
2459
- echo "<div class='sa_thumbs_line'><span>Tablet Thumb Size:</span>";
2460
- echo "<input type='text' id='sa_thumbs_resp_tablet' name='sa_thumbs_resp_tablet' value='" . esc_attr( $thumbs_resp_tablet ) . "'><em>%</em>";
2461
- echo "</div>\n";
2462
-
2463
- // Mobile Thumb Size.
2464
- $thumbs_resp_mobile = get_post_meta( $post->ID, 'sa_thumbs_resp_mobile', true );
2465
- if ( '' === $thumbs_resp_mobile ) {
2466
- $thumbs_resp_mobile = '50';
2467
- }
2468
- echo "<div class='sa_thumbs_line'><span>Mobile Thumb Size:</span>";
2469
- echo "<input type='text' id='sa_thumbs_resp_mobile' name='sa_thumbs_resp_mobile' value='" . esc_attr( $thumbs_resp_mobile ) . "'><em>%</em>";
2470
- echo "</div>\n";
2471
-
2472
- echo "</div>\n"; // #sa_thumbs_settings
2473
- }
2474
-
2475
-
2476
-
2477
- /**
2478
- * // ##### ACTION HOOK - SAVE CUSTOM POST TYPE ('Slide Anything') DATA #####
2479
- */
2480
- function cpt_slider_save_postdata() {
2481
- global $post;
2482
-
2483
- // ### REMOVE XSS ATTACK VULNERABILITY FROM SLIDER POST TITLES ###
2484
- global $wpdb;
2485
- if ( isset( $post->ID ) && ( '' !== $post->ID ) ) {
2486
- $post_title = get_the_title( $post->ID );
2487
- $sanitize_title = sanitize_text_field( $post_title );
2488
- $where = array( 'ID' => $post->ID );
2489
- $wpdb->update( $wpdb->posts, array( 'post_title' => $sanitize_title ), $where ); // db call ok; no-cache ok.
2490
- }
2491
-
2492
- // ### VERIFY 1) LOGGED-IN USER IS ADMINISTRATOR AND 2) VALID NONCE TO PREVENT CSRF HACKER ATTACKS ###
2493
- if ( current_user_can( 'edit_pages' ) &&
2494
- isset( $_POST['nonce_save_slider'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce_save_slider'] ) ), basename( __FILE__ ) ) ) {
2495
- if ( isset( $_POST['sa_num_slides'] ) ) {
2496
- $total_slides = intval( $_POST['sa_num_slides'] );
2497
- } else {
2498
- $total_slides = 1;
2499
- }
2500
- if ( isset( $_POST['sa_duplicate_slide'] ) ) {
2501
- if ( ( '' === $_POST['sa_duplicate_slide'] ) || ( '0' === $_POST['sa_duplicate_slide'] ) ) {
2502
- $duplicate_slide = 0;
2503
- } else {
2504
- // A SLIDE NEEDS TO BE DUPLICATED.
2505
- $duplicate_slide = intval( $_POST['sa_duplicate_slide'] );
2506
- }
2507
- } else {
2508
- $duplicate_slide = 0;
2509
- }
2510
- if ( isset( $_POST['sa_move_slide_up'] ) ) {
2511
- if ( ( '' === $_POST['sa_move_slide_up'] ) || ( '0' === $_POST['sa_move_slide_up'] ) ) {
2512
- $move_slide_up = 0;
2513
- } else {
2514
- // A SLIDE NEEDS TO BE MOVED.
2515
- $move_slide_up = intval( $_POST['sa_move_slide_up'] );
2516
- }
2517
- } else {
2518
- $move_slide_up = 0;
2519
- }
2520
-
2521
- // UPDATE CONTENT FOR EACH SLIDE.
2522
- $slides_saved = 0;
2523
- for ( $i = 1; $i <= $total_slides; $i++ ) {
2524
- $slide_edit_id = 'sa_slide' . $i . '_content';
2525
- $slide_image_id = 'sa_slide' . $i . '_image_id';
2526
- $slide_image_pos = 'sa_slide' . $i . '_image_pos';
2527
- $slide_image_size = 'sa_slide' . $i . '_image_size';
2528
- $slide_image_repeat = 'sa_slide' . $i . '_image_repeat';
2529
- $slide_image_color = 'sa_slide' . $i . '_image_color';
2530
- $slide_link_url = 'sa_slide' . $i . '_link_url';
2531
- $slide_link_target = 'sa_slide' . $i . '_link_target';
2532
- $slide_popup_type = 'sa_slide' . $i . '_popup_type';
2533
- $slide_popup_imageid = 'sa_slide' . $i . '_popup_imageid';
2534
- $slide_popup_imagetitle = 'sa_slide' . $i . '_popup_imagetitle';
2535
- $slide_popup_video_id = 'sa_slide' . $i . '_popup_video_id';
2536
- $slide_popup_video_type = 'sa_slide' . $i . '_popup_video_type';
2537
- $slide_popup_background = 'sa_slide' . $i . '_popup_background';
2538
- $slide_popup_html = 'sa_slide' . $i . '_popup_html';
2539
- $slide_popup_shortcode = 'sa_slide' . $i . '_popup_shortcode';
2540
- $slide_popup_bgcol = 'sa_slide' . $i . '_popup_bgcol';
2541
- $slide_popup_width = 'sa_slide' . $i . '_popup_width';
2542
- $slide_content = '';
2543
- $slide_image_id_val = 0;
2544
- $slide_image_pos_val = '';
2545
- $slide_image_size_val = '';
2546
- $slide_image_repeat_val = '';
2547
- $slide_image_color_val = '';
2548
- $slide_link_url_val = '';
2549
- $slide_link_target_val = '';
2550
- if ( isset( $_POST[ $slide_edit_id ] ) && ( '' !== $_POST[ $slide_edit_id ] ) ) {
2551
- $slide_content = wp_kses_post( wp_unslash( $_POST[ $slide_edit_id ] ) );
2552
- }
2553
- if ( isset( $_POST[ $slide_image_id ] ) ) {
2554
- $slide_image_id_val = abs( intval( $_POST[ $slide_image_id ] ) );
2555
- }
2556
- if ( isset( $_POST[ $slide_image_pos ] ) ) {
2557
- $slide_image_pos_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_pos ] ) );
2558
- }
2559
- if ( isset( $_POST[ $slide_image_size ] ) ) {
2560
- $slide_image_size_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_size ] ) );
2561
- }
2562
- if ( isset( $_POST[ $slide_image_repeat ] ) ) {
2563
- $slide_image_repeat_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_repeat ] ) );
2564
- }
2565
- if ( isset( $_POST[ $slide_image_color ] ) ) {
2566
- $slide_image_color_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_color ] ) );
2567
- }
2568
- if ( isset( $_POST[ $slide_link_url ] ) ) {
2569
- $slide_link_url_val = sanitize_text_field( wp_unslash( $_POST[ $slide_link_url ] ) );
2570
- }
2571
- if ( isset( $_POST[ $slide_link_target ] ) ) {
2572
- $slide_link_target_val = sanitize_text_field( wp_unslash( $_POST[ $slide_link_target ] ) );
2573
- }
2574
- $slide_popup_type_val = '';
2575
- $slide_popup_imageid_val = 0;
2576
- $slide_popup_imagetitle_val = '';
2577
- $slide_popup_video_id_val = '';
2578
- $slide_popup_video_type_val = '';
2579
- $slide_popup_background_val = '';
2580
- $slide_popup_html_val = '';
2581
- $slide_popup_shortcode_val = '';
2582
- $slide_popup_bgcol_val = '';
2583
- $slide_popup_width_val = 0;
2584
- if ( isset( $_POST[ $slide_popup_type ] ) ) {
2585
- $slide_popup_type_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_type ] ) );
2586
- }
2587
- if ( isset( $_POST[ $slide_popup_imageid ] ) ) {
2588
- $slide_popup_imageid_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_imageid ] ) );
2589
- }
2590
- if ( isset( $_POST[ $slide_popup_imagetitle ] ) ) {
2591
- $slide_popup_imagetitle_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_imagetitle ] ) );
2592
- }
2593
- if ( isset( $_POST[ $slide_popup_video_id ] ) ) {
2594
- $slide_popup_video_id_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_video_id ] ) );
2595
- }
2596
- if ( isset( $_POST[ $slide_popup_video_type ] ) ) {
2597
- $slide_popup_video_type_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_video_type ] ) );
2598
- }
2599
- if ( isset( $_POST[ $slide_popup_background ] ) ) {
2600
- $slide_popup_background_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_background ] ) );
2601
- }
2602
- if ( isset( $_POST[ $slide_popup_html ] ) ) {
2603
- $slide_popup_html_val = balanceTags( wp_kses_post( wp_unslash( $_POST[ $slide_popup_html ] ) ), true );
2604
- }
2605
- if ( isset( $_POST[ $slide_popup_shortcode ] ) ) {
2606
- $slide_popup_shortcode_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_shortcode ] ) );
2607
- }
2608
- if ( isset( $_POST[ $slide_popup_bgcol ] ) ) {
2609
- $slide_popup_bgcol_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_bgcol ] ) );
2610
- }
2611
- if ( isset( $_POST[ $slide_popup_width ] ) ) {
2612
- $slide_popup_width_val = abs( intval( $_POST[ $slide_popup_width ] ) );
2613
- }
2614
- // check delete status for slide.
2615
- $del_status_id = 'sa_slide' . $i . '_delete';
2616
- if ( isset( $_POST[ $del_status_id ] ) && ( '' !== $_POST[ $del_status_id ] ) ) {
2617
- $del_status = sanitize_text_field( wp_unslash( $_POST[ $del_status_id ] ) );
2618
- } else {
2619
- // a new slide has been added.
2620
- $del_status = '1';
2621
- $slide_content = '';
2622
- }
2623
- if ( '1' === $del_status ) {
2624
- // save slide content only if slide has not been marked for deletion.
2625
- $slides_saved++;
2626
- $slide_edit_id_save = 'sa_slide' . $slides_saved . '_content';
2627
- $slide_image_data_saved = 'sa_slide' . $slides_saved . '_image_data';
2628
- $slide_link_url_saved = 'sa_slide' . $slides_saved . '_link_url';
2629
- $slide_link_target_saved = 'sa_slide' . $slides_saved . '_link_target';
2630
- $slide_popup_type_saved = 'sa_slide' . $slides_saved . '_popup_type';
2631
- $slide_popup_imageid_saved = 'sa_slide' . $slides_saved . '_popup_imageid';
2632
- $slide_popup_imagetitle_saved = 'sa_slide' . $slides_saved . '_popup_imagetitle';
2633
- $slide_popup_video_id_saved = 'sa_slide' . $slides_saved . '_popup_video_id';
2634
- $slide_popup_video_type_saved = 'sa_slide' . $slides_saved . '_popup_video_type';
2635
- $slide_popup_background_saved = 'sa_slide' . $slides_saved . '_popup_background';
2636
- $slide_popup_html_saved = 'sa_slide' . $slides_saved . '_popup_html';
2637
- $slide_popup_shortcode_saved = 'sa_slide' . $slides_saved . '_popup_shortcode';
2638
- $slide_popup_bgcol_saved = 'sa_slide' . $slides_saved . '_popup_bgcol';
2639
- $slide_popup_width_saved = 'sa_slide' . $slides_saved . '_popup_width';
2640
- update_post_meta( $post->ID, $slide_edit_id_save, $slide_content );
2641
- $slide_image_data_val = $slide_image_id_val . '~' . $slide_image_pos_val . '~' . $slide_image_size_val . '~' . $slide_image_repeat_val . '~' . $slide_image_color_val;
2642
- update_post_meta( $post->ID, $slide_image_data_saved, $slide_image_data_val );
2643
- update_post_meta( $post->ID, $slide_link_url_saved, $slide_link_url_val );
2644
- update_post_meta( $post->ID, $slide_link_target_saved, $slide_link_target_val );
2645
- update_post_meta( $post->ID, $slide_popup_type_saved, $slide_popup_type_val );
2646
- update_post_meta( $post->ID, $slide_popup_imageid_saved, $slide_popup_imageid_val );
2647
- update_post_meta( $post->ID, $slide_popup_imagetitle_saved, $slide_popup_imagetitle_val );
2648
- update_post_meta( $post->ID, $slide_popup_video_id_saved, $slide_popup_video_id_val );
2649
- update_post_meta( $post->ID, $slide_popup_video_type_saved, $slide_popup_video_type_val );
2650
- update_post_meta( $post->ID, $slide_popup_background_saved, $slide_popup_background_val );
2651
- update_post_meta( $post->ID, $slide_popup_html_saved, $slide_popup_html_val );
2652
- update_post_meta( $post->ID, $slide_popup_shortcode_saved, $slide_popup_shortcode_val );
2653
- update_post_meta( $post->ID, $slide_popup_bgcol_saved, $slide_popup_bgcol_val );
2654
- update_post_meta( $post->ID, $slide_popup_width_saved, $slide_popup_width_val );
2655
- if ( $i === $duplicate_slide ) {
2656
- // the 'duplicate slide' button has been click for this slide - create a new slide that is an exact copy of previous slide.
2657
- $slides_saved++;
2658
- $slide_edit_id_save = 'sa_slide' . $slides_saved . '_content';
2659
- $slide_image_data_saved = 'sa_slide' . $slides_saved . '_image_data';
2660
- $slide_link_url_saved = 'sa_slide' . $slides_saved . '_link_url';
2661
- $slide_link_target_saved = 'sa_slide' . $slides_saved . '_link_target';
2662
- $slide_popup_type_saved = 'sa_slide' . $slides_saved . '_popup_type';
2663
- $slide_popup_imageid_saved = 'sa_slide' . $slides_saved . '_popup_imageid';
2664
- $slide_popup_imagetitle_saved = 'sa_slide' . $slides_saved . '_popup_imagetitle';
2665
- $slide_popup_video_id_saved = 'sa_slide' . $slides_saved . '_popup_video_id';
2666
- $slide_popup_video_type_saved = 'sa_slide' . $slides_saved . '_popup_video_type';
2667
- $slide_popup_background_saved = 'sa_slide' . $slides_saved . '_popup_background';
2668
- $slide_popup_html_saved = 'sa_slide' . $slides_saved . '_popup_html';
2669
- $slide_popup_shortcode_saved = 'sa_slide' . $slides_saved . '_popup_shortcode';
2670
- $slide_popup_bgcol_saved = 'sa_slide' . $slides_saved . '_popup_bgcol';
2671
- $slide_popup_width_saved = 'sa_slide' . $slides_saved . '_popup_width';
2672
- update_post_meta( $post->ID, $slide_edit_id_save, $slide_content );
2673
- $slide_image_data_val = $slide_image_id_val . '~' . $slide_image_pos_val . '~' . $slide_image_size_val . '~' . $slide_image_repeat_val . '~' . $slide_image_color_val;
2674
- update_post_meta( $post->ID, $slide_image_data_saved, $slide_image_data_val );
2675
- update_post_meta( $post->ID, $slide_link_url_saved, $slide_link_url_val );
2676
- update_post_meta( $post->ID, $slide_link_target_saved, $slide_link_target_val );
2677
- update_post_meta( $post->ID, $slide_popup_type_saved, $slide_popup_type_val );
2678
- update_post_meta( $post->ID, $slide_popup_imageid_saved, $slide_popup_imageid_val );
2679
- update_post_meta( $post->ID, $slide_popup_imagetitle_saved, $slide_popup_imagetitle_val );
2680
- update_post_meta( $post->ID, $slide_popup_video_id_saved, $slide_popup_video_id_val );
2681
- update_post_meta( $post->ID, $slide_popup_video_type_saved, $slide_popup_video_type_val );
2682
- update_post_meta( $post->ID, $slide_popup_background_saved, $slide_popup_background_val );
2683
- update_post_meta( $post->ID, $slide_popup_html_saved, $slide_popup_html_val );
2684
- update_post_meta( $post->ID, $slide_popup_shortcode_saved, $slide_popup_shortcode_val );
2685
- update_post_meta( $post->ID, $slide_popup_bgcol_saved, $slide_popup_bgcol_val );
2686
- update_post_meta( $post->ID, $slide_popup_width_saved, $slide_popup_width_val );
2687
- }
2688
- }
2689
- }
2690
-
2691
- if ( 0 !== $move_slide_up ) {
2692
- // A SLIDE NEEDS TO BE MOVED (TWO SLIDES ARE SWAPPED).
2693
- $slide2 = $move_slide_up;
2694
- $slide1 = intval( $move_slide_up ) - 1;
2695
- $slide1_content = '';
2696
- $slide1_image_id = 0;
2697
- $slide1_image_pos = '';
2698
- $slide1_image_size = '';
2699
- $slide1_image_repeat = '';
2700
- $slide1_image_color = '';
2701
- $slide1_link_url = '';
2702
- $slide1_link_target = '';
2703
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_content' ] ) ) {
2704
- $slide1_content = balanceTags( sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_content' ] ) ), true );
2705
- }
2706
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_id' ] ) ) {
2707
- $slide1_image_id = abs( intval( $_POST[ 'sa_slide' . $slide1 . '_image_id' ] ) );
2708
- }
2709
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_pos' ] ) ) {
2710
- $slide1_image_pos = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_pos' ] ) );
2711
- }
2712
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_size' ] ) ) {
2713
- $slide1_image_size = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_size' ] ) );
2714
- }
2715
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_repeat' ] ) ) {
2716
- $slide1_image_repeat = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_repeat' ] ) );
2717
- }
2718
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_color' ] ) ) {
2719
- $slide1_image_color = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_color' ] ) );
2720
- }
2721
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_link_url' ] ) ) {
2722
- $slide1_link_url = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_link_url' ] ) );
2723
- }
2724
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_link_target' ] ) ) {
2725
- $slide1_link_target = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_link_target' ] ) );
2726
- }
2727
- $slide1_popup_type = '';
2728
- $slide1_popup_imageid = '';
2729
- $slide1_popup_imagetitle = '';
2730
- $slide1_popup_video_id = '';
2731
- $slide1_popup_video_type = '';
2732
- $slide1_popup_background = '';
2733
- $slide1_popup_html = '';
2734
- $slide1_popup_shortcode = '';
2735
- $slide1_popup_bgcol = '';
2736
- $slide1_popup_width = 0;
2737
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_type' ] ) ) {
2738
- $slide1_popup_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_type' ] ) );
2739
- }
2740
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_imageid' ] ) ) {
2741
- $slide1_popup_imageid = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_imageid' ] ) );
2742
- }
2743
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_imagetitle' ] ) ) {
2744
- $slide1_popup_imagetitle = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_imagetitle' ] ) );
2745
- }
2746
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_video_id' ] ) ) {
2747
- $slide1_popup_video_id = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_video_id' ] ) );
2748
- }
2749
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_video_type' ] ) ) {
2750
- $slide1_popup_video_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_video_type' ] ) );
2751
- }
2752
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_background' ] ) ) {
2753
- $slide1_popup_background = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_background' ] ) );
2754
- }
2755
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_html' ] ) ) {
2756
- $slide1_popup_html = balanceTags( wp_kses_post( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_html' ] ) ), true );
2757
- }
2758
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_shortcode' ] ) ) {
2759
- $slide1_popup_shortcode = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_shortcode' ] ) );
2760
- }
2761
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_bgcol' ] ) ) {
2762
- $slide1_popup_bgcol = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_bgcol' ] ) );
2763
- }
2764
- if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_width' ] ) ) {
2765
- $slide1_popup_width = abs( intval( $_POST[ 'sa_slide' . $slide1 . '_popup_width' ] ) );
2766
- }
2767
- $slide2_content = '';
2768
- $slide2_image_id = 0;
2769
- $slide2_image_pos = '';
2770
- $slide2_image_size = '';
2771
- $slide2_image_repeat = '';
2772
- $slide2_image_color = '';
2773
- $slide2_link_url = '';
2774
- $slide2_link_target = '';
2775
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_content' ] ) ) {
2776
- $slide2_content = balanceTags( sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_content' ] ) ), true );
2777
- }
2778
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_id' ] ) ) {
2779
- $slide2_image_id = abs( intval( $_POST[ 'sa_slide' . $slide2 . '_image_id' ] ) );
2780
- }
2781
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_pos' ] ) ) {
2782
- $slide2_image_pos = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_pos' ] ) );
2783
- }
2784
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_size' ] ) ) {
2785
- $slide2_image_size = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_size' ] ) );
2786
- }
2787
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_repeat' ] ) ) {
2788
- $slide2_image_repeat = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_repeat' ] ) );
2789
- }
2790
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_color' ] ) ) {
2791
- $slide2_image_color = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_color' ] ) );
2792
- }
2793
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_link_url' ] ) ) {
2794
- $slide2_link_url = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_link_url' ] ) );
2795
- }
2796
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_link_target' ] ) ) {
2797
- $slide2_link_target = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_link_target' ] ) );
2798
- }
2799
- $slide2_popup_type = '';
2800
- $slide2_popup_imageid = '';
2801
- $slide2_popup_imagetitle = '';
2802
- $slide2_popup_video_id = '';
2803
- $slide2_popup_video_type = '';
2804
- $slide2_popup_background = '';
2805
- $slide2_popup_html = '';
2806
- $slide2_popup_shortcode = '';
2807
- $slide2_popup_bgcol = '';
2808
- $slide2_popup_width = 0;
2809
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_type' ] ) ) {
2810
- $slide2_popup_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_type' ] ) );
2811
- }
2812
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_imageid' ] ) ) {
2813
- $slide2_popup_imageid = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_imageid' ] ) );
2814
- }
2815
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_imagetitle' ] ) ) {
2816
- $slide2_popup_imagetitle = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_imagetitle' ] ) );
2817
- }
2818
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_video_id' ] ) ) {
2819
- $slide2_popup_video_id = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_video_id' ] ) );
2820
- }
2821
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_video_type' ] ) ) {
2822
- $slide2_popup_video_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_video_type' ] ) );
2823
- }
2824
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_background' ] ) ) {
2825
- $slide2_popup_background = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_background' ] ) );
2826
- }
2827
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_html' ] ) ) {
2828
- $slide2_popup_html = balanceTags( wp_kses_post( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_html' ] ) ), true );
2829
- }
2830
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_shortcode' ] ) ) {
2831
- $slide2_popup_shortcode = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_shortcode' ] ) );
2832
- }
2833
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_bgcol' ] ) ) {
2834
- $slide2_popup_bgcol = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_bgcol' ] ) );
2835
- }
2836
- if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_width' ] ) ) {
2837
- $slide2_popup_width = abs( intval( $_POST[ 'sa_slide' . $slide2 . '_popup_width' ] ) );
2838
- }
2839
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_content', $slide1_content );
2840
- $slide1_image_data = $slide1_image_id . '~' . $slide1_image_pos . '~' . $slide1_image_size . '~' . $slide1_image_repeat . '~' . $slide1_image_color;
2841
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_image_data', $slide1_image_data );
2842
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_link_url', $slide1_link_url );
2843
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_link_target', $slide1_link_target );
2844
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_type', $slide1_popup_type );
2845
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_imageid', $slide1_popup_imageid );
2846
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_imagetitle', $slide1_popup_imagetitle );
2847
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_video_id', $slide1_popup_video_id );
2848
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_video_type', $slide1_popup_video_type );
2849
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_background', $slide1_popup_background );
2850
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_html', $slide1_popup_html );
2851
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_shortcode', $slide1_popup_shortcode );
2852
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_bgcol', $slide1_popup_bgcol );
2853
- update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_width', $slide1_popup_width );
2854
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_content', $slide2_content );
2855
- $slide2_image_data = $slide2_image_id . '~' . $slide2_image_pos . '~' . $slide2_image_size . '~' . $slide2_image_repeat . '~' . $slide2_image_color;
2856
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_image_data', $slide2_image_data );
2857
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_link_url', $slide2_link_url );
2858
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_link_target', $slide2_link_target );
2859
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_type', $slide2_popup_type );
2860
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_imageid', $slide2_popup_imageid );
2861
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_imagetitle', $slide2_popup_imagetitle );
2862
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_video_id', $slide2_popup_video_id );
2863
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_video_type', $slide2_popup_video_type );
2864
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_background', $slide2_popup_background );
2865
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_html', $slide2_popup_html );
2866
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_shortcode', $slide2_popup_shortcode );
2867
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_bgcol', $slide2_popup_bgcol );
2868
- update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_width', $slide2_popup_width );
2869
- }
2870
-
2871
- // UPDATE SLIDE CONTENT CHARACTER COUNT.
2872
- $total_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
2873
- for ( $i = 1; $i <= $total_slides; $i++ ) {
2874
- $slide_content = get_post_meta( $post->ID, 'sa_slide' . $i . '_content', true );
2875
- $char_count = strlen( $slide_content );
2876
- update_post_meta( $post->ID, 'sa_slide' . $i . '_char_count', $char_count );
2877
- }
2878
-
2879
- // UPDATE SLIDER SETTINGS.
2880
- update_post_meta( $post->ID, 'sa_num_slides', abs( intval( $slides_saved ) ) );
2881
- if ( isset( $_POST['sa_disable_visual_editor'] ) && ( '1' === $_POST['sa_disable_visual_editor'] ) ) {
2882
- update_post_meta( $post->ID, 'sa_disable_visual_editor', '1' );
2883
- } else {
2884
- update_post_meta( $post->ID, 'sa_disable_visual_editor', '0' );
2885
- }
2886
- if ( isset( $_POST['sa_info_added'] ) ) {
2887
- update_post_meta( $post->ID, 'sa_info_added', abs( intval( $_POST['sa_info_added'] ) ) );
2888
- }
2889
- if ( isset( $_POST['sa_info_deleted'] ) ) {
2890
- update_post_meta( $post->ID, 'sa_info_deleted', abs( intval( $_POST['sa_info_deleted'] ) ) );
2891
- }
2892
- if ( isset( $_POST['sa_duplicate_slide'] ) ) {
2893
- update_post_meta( $post->ID, 'sa_duplicate_slide', abs( intval( $_POST['sa_duplicate_slide'] ) ) );
2894
- }
2895
- if ( isset( $_POST['sa_info_duplicated'] ) ) {
2896
- update_post_meta( $post->ID, 'sa_info_duplicated', abs( intval( $_POST['sa_info_duplicated'] ) ) );
2897
- }
2898
- if ( isset( $_POST['sa_move_slide_up'] ) ) {
2899
- update_post_meta( $post->ID, 'sa_move_slide_up', abs( intval( $_POST['sa_move_slide_up'] ) ) );
2900
- }
2901
- if ( isset( $_POST['sa_info_moved'] ) ) {
2902
- update_post_meta( $post->ID, 'sa_info_moved', abs( intval( $_POST['sa_info_moved'] ) ) );
2903
- }
2904
- if ( isset( $_POST['sa_slide_duration'] ) ) {
2905
- update_post_meta( $post->ID, 'sa_slide_duration', abs( floatval( $_POST['sa_slide_duration'] ) ) );
2906
- }
2907
- if ( isset( $_POST['sa_slide_transition'] ) ) {
2908
- update_post_meta( $post->ID, 'sa_slide_transition', abs( floatval( $_POST['sa_slide_transition'] ) ) );
2909
- }
2910
- if ( isset( $_POST['sa_slide_by'] ) ) {
2911
- update_post_meta( $post->ID, 'sa_slide_by', abs( floatval( $_POST['sa_slide_by'] ) ) );
2912
- }
2913
- if ( isset( $_POST['sa_loop_slider'] ) && ( '1' === $_POST['sa_loop_slider'] ) ) {
2914
- update_post_meta( $post->ID, 'sa_loop_slider', '1' );
2915
- } else {
2916
- update_post_meta( $post->ID, 'sa_loop_slider', '0' );
2917
- }
2918
- if ( isset( $_POST['sa_stop_hover'] ) && ( '1' === $_POST['sa_stop_hover'] ) ) {
2919
- update_post_meta( $post->ID, 'sa_stop_hover', '1' );
2920
- } else {
2921
- update_post_meta( $post->ID, 'sa_stop_hover', '0' );
2922
- }
2923
- if ( isset( $_POST['sa_nav_arrows'] ) && ( '1' === $_POST['sa_nav_arrows'] ) ) {
2924
- update_post_meta( $post->ID, 'sa_nav_arrows', '1' );
2925
- } else {
2926
- update_post_meta( $post->ID, 'sa_nav_arrows', '0' );
2927
- }
2928
- if ( isset( $_POST['sa_pagination'] ) && ( '1' === $_POST['sa_pagination'] ) ) {
2929
- update_post_meta( $post->ID, 'sa_pagination', '1' );
2930
- } else {
2931
- update_post_meta( $post->ID, 'sa_pagination', '0' );
2932
- }
2933
- if ( isset( $_POST['sa_random_order'] ) && ( '1' === $_POST['sa_random_order'] ) ) {
2934
- update_post_meta( $post->ID, 'sa_random_order', '1' );
2935
- } else {
2936
- update_post_meta( $post->ID, 'sa_random_order', '0' );
2937
- }
2938
- if ( isset( $_POST['sa_reverse_order'] ) && ( '1' === $_POST['sa_reverse_order'] ) ) {
2939
- update_post_meta( $post->ID, 'sa_reverse_order', '1' );
2940
- } else {
2941
- update_post_meta( $post->ID, 'sa_reverse_order', '0' );
2942
- }
2943
- if ( isset( $_POST['sa_shortcodes'] ) && ( '1' === $_POST['sa_shortcodes'] ) ) {
2944
- update_post_meta( $post->ID, 'sa_shortcodes', '1' );
2945
- } else {
2946
- update_post_meta( $post->ID, 'sa_shortcodes', '0' );
2947
- }
2948
- if ( isset( $_POST['sa_mouse_drag'] ) && ( '1' === $_POST['sa_mouse_drag'] ) ) {
2949
- update_post_meta( $post->ID, 'sa_mouse_drag', '1' );
2950
- } else {
2951
- update_post_meta( $post->ID, 'sa_mouse_drag', '0' );
2952
- }
2953
- if ( isset( $_POST['sa_touch_drag'] ) && ( '1' === $_POST['sa_touch_drag'] ) ) {
2954
- update_post_meta( $post->ID, 'sa_touch_drag', '1' );
2955
- } else {
2956
- update_post_meta( $post->ID, 'sa_touch_drag', '0' );
2957
- }
2958
- if ( isset( $_POST['sa_mousewheel'] ) && ( '1' === $_POST['sa_mousewheel'] ) ) {
2959
- update_post_meta( $post->ID, 'sa_mousewheel', '1' );
2960
- } else {
2961
- update_post_meta( $post->ID, 'sa_mousewheel', '0' );
2962
- }
2963
- if ( isset( $_POST['sa_click_advance'] ) && ( '1' === $_POST['sa_click_advance'] ) ) {
2964
- update_post_meta( $post->ID, 'sa_click_advance', '1' );
2965
- } else {
2966
- update_post_meta( $post->ID, 'sa_click_advance', '0' );
2967
- }
2968
- if ( isset( $_POST['sa_auto_height'] ) && ( '1' === $_POST['sa_auto_height'] ) ) {
2969
- update_post_meta( $post->ID, 'sa_auto_height', '1' );
2970
- } else {
2971
- update_post_meta( $post->ID, 'sa_auto_height', '0' );
2972
- }
2973
- if ( isset( $_POST['sa_vert_center'] ) && ( '1' === $_POST['sa_vert_center'] ) ) {
2974
- update_post_meta( $post->ID, 'sa_vert_center', '1' );
2975
- } else {
2976
- update_post_meta( $post->ID, 'sa_vert_center', '0' );
2977
- }
2978
-
2979
- // UPDATE SLIDER ITEMS DISPLAYED.
2980
- if ( isset( $_POST['sa_items_width1'] ) ) {
2981
- update_post_meta( $post->ID, 'sa_items_width1', abs( intval( $_POST['sa_items_width1'] ) ) );
2982
- }
2983
- if ( isset( $_POST['sa_items_width2'] ) ) {
2984
- update_post_meta( $post->ID, 'sa_items_width2', abs( intval( $_POST['sa_items_width2'] ) ) );
2985
- }
2986
- if ( isset( $_POST['sa_items_width3'] ) ) {
2987
- update_post_meta( $post->ID, 'sa_items_width3', abs( intval( $_POST['sa_items_width3'] ) ) );
2988
- }
2989
- if ( isset( $_POST['sa_items_width4'] ) ) {
2990
- update_post_meta( $post->ID, 'sa_items_width4', abs( intval( $_POST['sa_items_width4'] ) ) );
2991
- }
2992
- if ( isset( $_POST['sa_items_width5'] ) ) {
2993
- update_post_meta( $post->ID, 'sa_items_width5', abs( intval( $_POST['sa_items_width5'] ) ) );
2994
- }
2995
- if ( isset( $_POST['sa_items_width6'] ) ) {
2996
- update_post_meta( $post->ID, 'sa_items_width6', abs( intval( $_POST['sa_items_width6'] ) ) );
2997
- }
2998
- if ( isset( $_POST['sa_transition'] ) ) {
2999
- update_post_meta( $post->ID, 'sa_transition', sanitize_text_field( wp_unslash( $_POST['sa_transition'] ) ) );
3000
- }
3001
- if ( isset( $_POST['sa_hero_slider'] ) && ( '1' === $_POST['sa_hero_slider'] ) ) {
3002
- update_post_meta( $post->ID, 'sa_hero_slider', '1' );
3003
- } else {
3004
- update_post_meta( $post->ID, 'sa_hero_slider', '0' );
3005
- }
3006
- if ( isset( $_POST['sa_showcase_slider'] ) && ( '1' === $_POST['sa_showcase_slider'] ) ) {
3007
- update_post_meta( $post->ID, 'sa_showcase_slider', '1' );
3008
- } else {
3009
- update_post_meta( $post->ID, 'sa_showcase_slider', '0' );
3010
- }
3011
- if ( isset( $_POST['sa_showcase_width'] ) ) {
3012
- update_post_meta( $post->ID, 'sa_showcase_width', abs( intval( $_POST['sa_showcase_width'] ) ) );
3013
- }
3014
- if ( isset( $_POST['sa_showcase_tablet'] ) && ( '1' === $_POST['sa_showcase_tablet'] ) ) {
3015
- update_post_meta( $post->ID, 'sa_showcase_tablet', '1' );
3016
- } else {
3017
- update_post_meta( $post->ID, 'sa_showcase_tablet', '0' );
3018
- }
3019
- if ( isset( $_POST['sa_showcase_width_tab'] ) ) {
3020
- update_post_meta( $post->ID, 'sa_showcase_width_tab', abs( intval( $_POST['sa_showcase_width_tab'] ) ) );
3021
- }
3022
- if ( isset( $_POST['sa_showcase_mobile'] ) && ( '1' === $_POST['sa_showcase_mobile'] ) ) {
3023
- update_post_meta( $post->ID, 'sa_showcase_mobile', '1' );
3024
- } else {
3025
- update_post_meta( $post->ID, 'sa_showcase_mobile', '0' );
3026
- }
3027
- if ( isset( $_POST['sa_showcase_width_mob'] ) ) {
3028
- update_post_meta( $post->ID, 'sa_showcase_width_mob', abs( intval( $_POST['sa_showcase_width_mob'] ) ) );
3029
- }
3030
-
3031
- // UPDATE SLIDER STYLE.
3032
- if ( isset( $_POST['sa_css_id'] ) ) {
3033
- $post_css_id = str_replace( '-', '_', sanitize_text_field( wp_unslash( $_POST['sa_css_id'] ) ) );
3034
- update_post_meta( $post->ID, 'sa_css_id', sanitize_text_field( $post_css_id ) );
3035
- }
3036
- if ( isset( $_POST['sa_background_color'] ) ) {
3037
- update_post_meta( $post->ID, 'sa_background_color', sanitize_text_field( wp_unslash( $_POST['sa_background_color'] ) ) );
3038
- }
3039
- if ( isset( $_POST['sa_border_width'] ) ) {
3040
- update_post_meta( $post->ID, 'sa_border_width', abs( intval( $_POST['sa_border_width'] ) ) );
3041
- }
3042
- if ( isset( $_POST['sa_border_color'] ) ) {
3043
- update_post_meta( $post->ID, 'sa_border_color', sanitize_text_field( wp_unslash( $_POST['sa_border_color'] ) ) );
3044
- }
3045
- if ( isset( $_POST['sa_border_radius'] ) ) {
3046
- update_post_meta( $post->ID, 'sa_border_radius', abs( intval( $_POST['sa_border_radius'] ) ) );
3047
- }
3048
- if ( isset( $_POST['sa_wrapper_padd_top'] ) ) {
3049
- update_post_meta( $post->ID, 'sa_wrapper_padd_top', abs( intval( $_POST['sa_wrapper_padd_top'] ) ) );
3050
- }
3051
- if ( isset( $_POST['sa_wrapper_padd_right'] ) ) {
3052
- update_post_meta( $post->ID, 'sa_wrapper_padd_right', abs( intval( $_POST['sa_wrapper_padd_right'] ) ) );
3053
- }
3054
- if ( isset( $_POST['sa_wrapper_padd_bottom'] ) ) {
3055
- update_post_meta( $post->ID, 'sa_wrapper_padd_bottom', abs( intval( $_POST['sa_wrapper_padd_bottom'] ) ) );
3056
- }
3057
- if ( isset( $_POST['sa_wrapper_padd_left'] ) ) {
3058
- update_post_meta( $post->ID, 'sa_wrapper_padd_left', abs( intval( $_POST['sa_wrapper_padd_left'] ) ) );
3059
- }
3060
- if ( isset( $_POST['sa_slide_min_height_type'] ) && isset( $_POST['sa_slide_min_height'] ) ) {
3061
- if ( 'px' === $_POST['sa_slide_min_height_type'] ) {
3062
- update_post_meta( $post->ID, 'sa_slide_min_height_perc', sanitize_text_field( wp_unslash( $_POST['sa_slide_min_height'] ) ) . 'px' );
3063
- } else {
3064
- update_post_meta( $post->ID, 'sa_slide_min_height_perc', sanitize_text_field( wp_unslash( $_POST['sa_slide_min_height'] ) ) );
3065
- }
3066
- }
3067
- if ( isset( $_POST['sa_slide_padding_tb'] ) ) {
3068
- update_post_meta( $post->ID, 'sa_slide_padding_tb', abs( floatval( $_POST['sa_slide_padding_tb'] ) ) );
3069
- }
3070
- if ( isset( $_POST['sa_slide_padding_lr'] ) ) {
3071
- update_post_meta( $post->ID, 'sa_slide_padding_lr', abs( floatval( $_POST['sa_slide_padding_lr'] ) ) );
3072
- }
3073
- if ( isset( $_POST['sa_slide_margin_lr'] ) ) {
3074
- update_post_meta( $post->ID, 'sa_slide_margin_lr', abs( floatval( $_POST['sa_slide_margin_lr'] ) ) );
3075
- }
3076
- if ( isset( $_POST['sa_slide_icons_location'] ) ) {
3077
- update_post_meta( $post->ID, 'sa_slide_icons_location', sanitize_text_field( wp_unslash( $_POST['sa_slide_icons_location'] ) ) );
3078
- }
3079
- if ( isset( $_POST['sa_slide_icons_color'] ) ) {
3080
- update_post_meta( $post->ID, 'sa_slide_icons_color', sanitize_text_field( wp_unslash( $_POST['sa_slide_icons_color'] ) ) );
3081
- }
3082
- if ( isset( $_POST['sa_autohide_arrows'] ) && ( '1' === $_POST['sa_autohide_arrows'] ) ) {
3083
- update_post_meta( $post->ID, 'sa_autohide_arrows', '1' );
3084
- } else {
3085
- update_post_meta( $post->ID, 'sa_autohide_arrows', '0' );
3086
- }
3087
- if ( isset( $_POST['sa_dot_per_slide'] ) && ( '1' === $_POST['sa_dot_per_slide'] ) ) {
3088
- update_post_meta( $post->ID, 'sa_dot_per_slide', '1' );
3089
- } else {
3090
- update_post_meta( $post->ID, 'sa_dot_per_slide', '0' );
3091
- }
3092
- if ( isset( $_POST['sa_slide_icons_visible'] ) && ( '1' === $_POST['sa_slide_icons_visible'] ) ) {
3093
- update_post_meta( $post->ID, 'sa_slide_icons_visible', '1' );
3094
- } else {
3095
- update_post_meta( $post->ID, 'sa_slide_icons_visible', '0' );
3096
- }
3097
- if ( isset( $_POST['sa_slide_icons_fullslide'] ) && ( '1' === $_POST['sa_slide_icons_fullslide'] ) ) {
3098
- update_post_meta( $post->ID, 'sa_slide_icons_fullslide', '1' );
3099
- } else {
3100
- update_post_meta( $post->ID, 'sa_slide_icons_fullslide', '0' );
3101
- }
3102
-
3103
- // OTHER SETTINGS.
3104
- $other_settings = '';
3105
- if ( isset( $_POST['sa_window_onload'] ) && ( '1' === $_POST['sa_window_onload'] ) ) {
3106
- $other_settings .= '1';
3107
- } else {
3108
- $other_settings .= '0';
3109
- }
3110
- $_POST['sa_strip_javascript'] = 0;
3111
- if ( isset( $_POST['sa_strip_javascript'] ) && ( '1' === $_POST['sa_strip_javascript'] ) ) {
3112
- $other_settings .= '|1';
3113
- } else {
3114
- $other_settings .= '|0';
3115
- }
3116
- if ( isset( $_POST['sa_lazy_load_images'] ) && ( '1' === $_POST['sa_lazy_load_images'] ) ) {
3117
- $other_settings .= '|1';
3118
- } else {
3119
- $other_settings .= '|0';
3120
- }
3121
- if ( isset( $_POST['sa_ulli_containers'] ) && ( '1' === $_POST['sa_ulli_containers'] ) ) {
3122
- $other_settings .= '|1';
3123
- } else {
3124
- $other_settings .= '|0';
3125
- }
3126
- if ( isset( $_POST['sa_rtl_slider'] ) && ( '1' === $_POST['sa_rtl_slider'] ) ) {
3127
- $other_settings .= '|1';
3128
- } else {
3129
- $other_settings .= '|0';
3130
- }
3131
- if ( isset( $_POST['sa_disable_preview'] ) && ( '1' === $_POST['sa_disable_preview'] ) ) {
3132
- $other_settings .= '|1';
3133
- } else {
3134
- $other_settings .= '|0';
3135
- }
3136
- if ( isset( $_POST['bg_image_size'] ) && ( '' !== $_POST['bg_image_size'] ) ) {
3137
- $other_settings .= '|' . sanitize_text_field( wp_unslash( $_POST['bg_image_size'] ) );
3138
- } else {
3139
- $other_settings .= '|full';
3140
- }
3141
- if ( isset( $_POST['sa_disable_slide_ids'] ) && ( '1' === $_POST['sa_disable_slide_ids'] ) ) {
3142
- $other_settings .= '|1';
3143
- } else {
3144
- $other_settings .= '|0';
3145
- }
3146
- update_post_meta( $post->ID, 'sa_other_settings', $other_settings );
3147
- // starting slide number.
3148
- if ( isset( $_POST['sa_start_pos'] ) ) {
3149
- update_post_meta( $post->ID, 'sa_start_pos', abs( intval( $_POST['sa_start_pos'] ) ) );
3150
- }
3151
-
3152
- // THUMBNAIL PAGINATION.
3153
- if ( isset( $_POST['sa_thumbs_active'] ) && ( '1' === $_POST['sa_thumbs_active'] ) ) {
3154
- update_post_meta( $post->ID, 'sa_thumbs_active', '1' );
3155
- } else {
3156
- update_post_meta( $post->ID, 'sa_thumbs_active', '0' );
3157
- }
3158
- if ( isset( $_POST['sa_thumbs_location'] ) ) {
3159
- update_post_meta( $post->ID, 'sa_thumbs_location', sanitize_text_field( wp_unslash( $_POST['sa_thumbs_location'] ) ) );
3160
- }
3161
- if ( isset( $_POST['sa_thumbs_image_size'] ) ) {
3162
- update_post_meta( $post->ID, 'sa_thumbs_image_size', sanitize_text_field( wp_unslash( $_POST['sa_thumbs_image_size'] ) ) );
3163
- }
3164
- if ( isset( $_POST['sa_thumbs_padding'] ) ) {
3165
- update_post_meta( $post->ID, 'sa_thumbs_padding', abs( floatval( $_POST['sa_thumbs_padding'] ) ) );
3166
- }
3167
- if ( isset( $_POST['sa_thumbs_width'] ) ) {
3168
- update_post_meta( $post->ID, 'sa_thumbs_width', abs( intval( $_POST['sa_thumbs_width'] ) ) );
3169
- }
3170
- if ( isset( $_POST['sa_thumbs_height'] ) ) {
3171
- update_post_meta( $post->ID, 'sa_thumbs_height', abs( intval( $_POST['sa_thumbs_height'] ) ) );
3172
- }
3173
- if ( isset( $_POST['sa_thumbs_opacity'] ) ) {
3174
- update_post_meta( $post->ID, 'sa_thumbs_opacity', abs( intval( $_POST['sa_thumbs_opacity'] ) ) );
3175
- }
3176
- if ( isset( $_POST['sa_thumbs_border_width'] ) ) {
3177
- update_post_meta( $post->ID, 'sa_thumbs_border_width', abs( intval( $_POST['sa_thumbs_border_width'] ) ) );
3178
- }
3179
- if ( isset( $_POST['sa_thumbs_border_color'] ) ) {
3180
- update_post_meta( $post->ID, 'sa_thumbs_border_color', sanitize_text_field( wp_unslash( $_POST['sa_thumbs_border_color'] ) ) );
3181
- }
3182
- if ( isset( $_POST['sa_thumbs_resp_tablet'] ) ) {
3183
- update_post_meta( $post->ID, 'sa_thumbs_resp_tablet', abs( intval( $_POST['sa_thumbs_resp_tablet'] ) ) );
3184
- }
3185
- if ( isset( $_POST['sa_thumbs_resp_mobile'] ) ) {
3186
- update_post_meta( $post->ID, 'sa_thumbs_resp_mobile', abs( intval( $_POST['sa_thumbs_resp_mobile'] ) ) );
3187
- }
3188
- }
3189
- }
3190
-
3191
-
3192
-
3193
- /**
3194
- * ###################################################################################
3195
- * ### FUNCTION DISPLAYS THE 'RE-ORDER SLIDES' SUB-PAGE IN THE WordPress DASHBOARD ###
3196
- * ###################################################################################
3197
- */
3198
- function cpt_slider_extra_sa_menu_pages() {
3199
- add_submenu_page(
3200
- 'edit.php?post_type=sa_slider',
3201
- __( 'Re-Order Slides', 'menu-sa-order' ),
3202
- __( 'Re-Order Slides', 'menu-sa-order' ),
3203
- 'manage_options',
3204
- 'reorderslides',
3205
- 'cpt_slider_sa_reorder_slides_page'
3206
- );
3207
- }
3208
-
3209
- /**
3210
- * ### FUNCTION CONTAINING THE 'RE-ORDER' SLIDES FUNCTIONALITY ###
3211
- */
3212
- function cpt_slider_sa_reorder_slides_page() {
3213
- $page_url = get_admin_url() . 'edit.php?post_type=sa_slider&page=reorderslides';
3214
- $placeholder_image = get_site_url() . '/wp-content/plugins/slide-anything/images/bg_placeholder.png';
3215
-
3216
- echo "<div id='sa_reorder_slides'>\n";
3217
- echo '<h1>Slide Anything - Re-Order Slides</h1>';
3218
-
3219
- if ( isset( $_SERVER['REQUEST_METHOD'] ) && ( 'POST' === $_SERVER['REQUEST_METHOD'] )
3220
- && isset( $_POST['reorder_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['reorder_nonce'] ) ), 'reorder_action' ) ) {
3221
- // A POST VARIABLE FOR 'SLIDER ID' HAS BEEN PASSED.
3222
- if ( isset( $_POST['sar_slider_id'] ) ) {
3223
- $slider_id = sanitize_text_field( wp_unslash( $_POST['sar_slider_id'] ) );
3224
- $slider_title = get_the_title( $slider_id );
3225
- } else {
3226
- exit();
3227
- }
3228
-
3229
- if ( isset( $_POST['sar_sort_order'] ) && ( '' !== $_POST['sar_sort_order'] ) ) {
3230
- // CHANGE THE ORDER OF SLIDE DATA FOR THE SLIDER AND RE-SAVE METADATA.
3231
- $sort_order = sanitize_text_field( wp_unslash( $_POST['sar_sort_order'] ) );
3232
- $data_in_arr = array();
3233
- $data_out_arr = array();
3234
-
3235
- // 1) SAVE SLIDES METADATA TO AN 'IN' ARRAY (ONLY SLIDES MEATDATA AND NO SETTINGS DATA SAVED!).
3236
- $metadata = get_metadata( 'post', $slider_id );
3237
- $num_slides = $metadata['sa_num_slides'][0];
3238
- foreach ( $metadata as $key => $value_arr ) {
3239
- $value = $value_arr[0];
3240
- for ( $i = 1; $i <= $num_slides; $i++ ) {
3241
- $key_prefix = 'sa_slide' . $i . '_';
3242
- if ( strpos( $key, $key_prefix ) === 0 ) {
3243
- // metadata key starts with the key prefix ('sa_slide??').
3244
- $data_in_arr[ $key ] = $value;
3245
- }
3246
- }
3247
- }
3248
-
3249
- // 2) CREATE THE NEW SLIDES 'OUT' ARRAY (WITH THE NEW SLIDE ORDER).
3250
- $sort_order_arr = explode( ',', $sort_order );
3251
- $count_order_arr = count( $sort_order_arr );
3252
- for ( $i = 0; $i < $count_order_arr; $i++ ) {
3253
- $loop_prefix = 'sa_slide' . ( $i + 1 ) . '_'; // ascending loop order (1, 2, 3...).
3254
- $order_prefix = 'sa_slide' . $sort_order_arr[ $i ] . '_'; // slide number to be stored in this slot.
3255
- foreach ( $data_in_arr as $key => $value ) {
3256
- if ( strpos( $key, $order_prefix ) === 0 ) {
3257
- // metakey key value starts with the order prefix.
3258
- $new_key = str_replace( $order_prefix, $loop_prefix, $key );
3259
- $data_out_arr[ $new_key ] = $value;
3260
- }
3261
- }
3262
- }
3263
-
3264
- // 3) LOOP THROUGH SLIDES 'OUT' ARRAY UPDATING POST METADATA.
3265
- foreach ( $data_out_arr as $key => $value ) {
3266
- update_post_meta( $slider_id, $key, $value );
3267
- }
3268
-
3269
- echo "<h3 id='sar_success_message'>SLIDE ORDER HAS BEEN UPDATED</h3>";
3270
- } else {
3271
- if ( isset( $_POST['sar_del_slides'] ) && ( '' !== $_POST['sar_del_slides'] ) ) {
3272
- // DELETE ALL SLIDES WITH THE 'DELETE SLIDE' CHECKBOX CHECKED.
3273
- $del_slides = sanitize_text_field( wp_unslash( $_POST['sar_del_slides'] ) );
3274
- $del_slides_arr = explode( ',', $del_slides );
3275
- $data_in_arr = array();
3276
- $data_out_arr = array();
3277
-
3278
- // 1) SAVE SLIDES METADATA TO AN 'IN' ARRAY (ONLY SLIDES MEATDATA AND NO SETTINGS DATA SAVED!).
3279
- $metadata = get_metadata( 'post', $slider_id );
3280
- $num_slides = $metadata['sa_num_slides'][0];
3281
- foreach ( $metadata as $key => $value_arr ) {
3282
- $value = $value_arr[0];
3283
- for ( $i = 1; $i <= $num_slides; $i++ ) {
3284
- $key_prefix = 'sa_slide' . $i . '_';
3285
- if ( strpos( $key, $key_prefix ) === 0 ) {
3286
- // metadata key starts with the key prefix ('sa_slide??').
3287
- $data_in_arr[ $i ][ $key ] = $value;
3288
- }
3289
- }
3290
- }
3291
-
3292
- // 2) CREATE THE NEW SLIDES 'OUT' ARRAY (WITH THE DELETED SLIDES REMOVED)
3293
- $curr_index = 0;
3294
- $tot_del = 0;
3295
- for ( $i = 1; $i <= $num_slides; $i++ ) {
3296
- $loop_prefix = 'sa_slide' . $i . '_';
3297
- $delete_yn = 0;
3298
- $count_del_arr = count( $del_slides_arr );
3299
- for ( $j = 0; $j < $count_del_arr; $j++ ) {
3300
- if ( $i === $del_slides_arr[ $j ] ) {
3301
- $delete_yn = 1;
3302
- }
3303
- }
3304
- if ( 0 === $delete_yn ) {
3305
- // current slide is NOT to be deleted - copy to 'out' array.
3306
- $curr_index++;
3307
- $curr_prefix = 'sa_slide' . $curr_index . '_';
3308
- foreach ( $data_in_arr[ $i ] as $key => $value ) {
3309
- $new_key = str_replace( $loop_prefix, $curr_prefix, $key );
3310
- $data_out_arr[ $new_key ] = $value;
3311
- }
3312
- } else {
3313
- $tot_del++;
3314
- }
3315
- }
3316
-
3317
- // 3) LOOP THROUGH SLIDES 'OUT' ARRAY UPDATING POST METADATA.
3318
- update_post_meta( $slider_id, 'sa_num_slides', $curr_index );
3319
- foreach ( $data_out_arr as $key => $value ) {
3320
- update_post_meta( $slider_id, $key, $value );
3321
- }
3322
-
3323
- if ( 1 === $tot_del ) {
3324
- echo "<h3 id='sar_success_message'>" . esc_html( $tot_del ) . ' SLIDE HAS BEEN DELETED</h3>';
3325
- } else {
3326
- echo "<h3 id='sar_success_message'>" . esc_html( $tot_del ) . ' SLIDES HAVE BEEN DELETED</h3>';
3327
- }
3328
- }
3329
- }
3330
-
3331
- // GET REQUIRED SLIDER METADATA AND SAVE WITHIN AN ARRAY.
3332
- $num_slides = 0;
3333
- $slide_arr = array();
3334
- $metadata = get_metadata( 'post', $slider_id );
3335
- if ( count( $metadata ) > 0 ) {
3336
- $num_slides = $metadata['sa_num_slides'][0];
3337
- }
3338
- if ( 0 !== $num_slides ) {
3339
- // SLIDER CONTAINS SLIDES - DISPLAY SORTABLE LIST OF SLIDES.
3340
- for ( $i = 1; $i <= $num_slides; $i++ ) {
3341
- $image_data = $metadata[ 'sa_slide' . $i . '_image_data' ][0];
3342
- $image_data_arr = explode( '~', $image_data );
3343
- $slide_arr[ $i ]['image_id'] = $image_data_arr[0];
3344
- $slide_arr[ $i ]['content'] = $metadata[ 'sa_slide' . $i . '_content' ][0];
3345
- // cater for popup images used as the slide background.
3346
- $popup_type = '';
3347
- $popup_background = '';
3348
- if ( isset( $metadata[ 'sa_slide' . $i . '_popup_type' ][0] ) ) {
3349
- $popup_type = $metadata[ 'sa_slide' . $i . '_popup_type' ][0];
3350
- }
3351
- if ( isset( $metadata[ 'sa_slide' . $i . '_popup_background' ][0] ) ) {
3352
- $popup_background = $metadata[ 'sa_slide' . $i . '_popup_background' ][0];
3353
- }
3354
- if ( 'IMAGE' === $popup_type ) {
3355
- if ( ( '' !== $popup_background ) && ( 'no' !== $popup_background ) ) {
3356
- $slide_arr[ $i ]['image_id'] = $metadata[ 'sa_slide' . $i . '_popup_imageid' ][0];
3357
- }
3358
- }
3359
- }
3360
-
3361
- // DISPLAY THE SORTABLE GRID OF SLIDES.
3362
- echo "<h2 id='sar_slider_title'>" . esc_html( $slider_title ) . "</h2>\n";
3363
- echo "<h3 id='sar_drag_message'>Drag slides to re-order...</h3>\n";
3364
- echo "<ul id='sar_sortable'>\n";
3365
- for ( $i = 1; $i <= $num_slides; $i++ ) {
3366
- $bg_image = $placeholder_image;
3367
- $slide_image_src = wp_get_attachment_image_src( $slide_arr[ $i ]['image_id'], 'thumbnail' );
3368
- if ( ! empty( $slide_image_src[0] ) ) {
3369
- $bg_image = $slide_image_src[0];
3370
- }
3371
- echo "<li id='sar" . esc_attr( $i ) . "' class='ui-state-default'>\n";
3372
- echo "<div class='sar_image' style='background-image:url(\"" . esc_url( $bg_image ) . "\");'></div>\n";
3373
- echo "<div class='sar_content'>\n";
3374
- echo "<h4 class='sar_slide_num'>SLIDE " . esc_html( $i ) . "</h4>\n";
3375
- echo "<div class='sar_del_slide'>DELETE <span>SLIDE</span>";
3376
- echo "<input type='checkbox' id='sar_del" . esc_attr( $i ) . "' name='sar_del" . esc_attr( $i ) . "' class='sar_del_checkbox'/>";
3377
- echo "</div>\n";
3378
- echo "<div class='sar_slide_html'>" . esc_html( nl2br( htmlentities( $slide_arr[ $i ]['content'] ) ) ) . "</div>\n";
3379
- echo '</div>';
3380
- echo "</li>\n";
3381
- }
3382
- echo "</ul>\n";
3383
-
3384
- // DISPLAY THE HTML FORM CONTAINING THE SORT ORDER INPUT ELEMENT.
3385
- echo "<form method='post' id='sar_order_form'>\n";
3386
- wp_nonce_field( 'reorder_action', 'reorder_nonce' );
3387
- echo "<input type='hidden' name='sar_slider_id' value='" . esc_attr( $slider_id ) . "'/>";
3388
- echo "<input type='hidden' id='sar_sort_order' name='sar_sort_order'/>";
3389
- echo "<input type='hidden' id='sar_del_slides' name='sar_del_slides'/>";
3390
- echo "<input type='submit' id='sar_update_but' value='UPDATE ORDER'/>";
3391
- echo "<input type='submit' id='sar_delete_but' value='DELETE SLIDES'/>";
3392
- echo "</form>\n";
3393
-
3394
- } else {
3395
- // SLIDER CONTAINS NO SLIDES - DISPLAY MESSAGE.
3396
- echo "<h3 id='sar_no_slides_found'>This slider contains NO slides!</h3>\n";
3397
- echo "<a class='sar_back_button' href='" . esc_url( $page_url ) . "'>BACK</a>";
3398
- }
3399
- } else {
3400
- // ##### NO POST VARIABLE FOR 'SLIDER ID' HAS BEEN PASSED #####
3401
- // WP QUERY TO GET ARRAY OF SA SLIDERS (ID & TITLE) THAT EXIST.
3402
- $slider_arr = array();
3403
- $count = 0;
3404
- $args = array(
3405
- 'post_type' => 'sa_slider',
3406
- 'post_status' => array( 'publish', 'draft' ),
3407
- 'orderby' => 'menu_order',
3408
- 'order' => 'ASC',
3409
- 'posts_per_page' => -1,
3410
- );
3411
- $sliders = new WP_Query( $args );
3412
- if ( $sliders->have_posts() ) {
3413
- while ( $sliders->have_posts() ) {
3414
- $sliders->the_post();
3415
- $slider_arr[ $count ]['id'] = get_the_ID();
3416
- $slider_arr[ $count ]['title'] = get_the_title();
3417
- $count++;
3418
- }
3419
- }
3420
- wp_reset_postdata();
3421
-
3422
- if ( count( $slider_arr ) > 0 ) {
3423
- // DISPLAY FORM CONTAINING SA SLIDER SELECT DROPDOWN.
3424
- echo "<form method='post' id='sar_slider_form'>\n";
3425
- wp_nonce_field( 'reorder_action', 'reorder_nonce' );
3426
- echo "<p>This tool allows you to change the order of slides within a Slide Anything slider.</p>\n";
3427
- echo "<p>Select the slider you would like to re-order, then just drag-and-drop slides for your new slide order.</p>\n";
3428
- echo "<div style='padding-top:10px;'>Select Slider to Re-Order:<br/>";
3429
- echo "<select id='sar_slider_id' name='sar_slider_id'>\n";
3430
- $count_slider_arr = count( $slider_arr );
3431
- for ( $i = 0; $i < $count_slider_arr; $i++ ) {
3432
- echo '<h4>|' . esc_html( $slider_arr[ $i ]['id'] ) . '|' . esc_html( $slider_arr[ $i ]['title'] ) . '|</h4>';
3433
- echo "<option value='" . esc_attr( $slider_arr[ $i ]['id'] ) . "'>" . esc_html( $slider_arr[ $i ]['title'] ) . ' (#' . esc_html( $slider_arr[ $i ]['id'] ) . ")</option>\n";
3434
- }
3435
- echo "<select></div>\n";
3436
- echo "<div><input type='submit' value='Select Slider'/></div>\n";
3437
- echo "</form>\n";
3438
- } else {
3439
- // NO SA SLIDERS FOUND - DISPLAY MESSAGE.
3440
- echo "<h3 id='sar_no_sliders_found'>No Slide Anything sliders found!</h3>\n";
3441
- }
3442
- }
3443
-
3444
- echo "</div>\n";
3445
- }
3446
-
3447
-
3448
- /**
3449
- * ### FUNCTION CALLED BY 'template_include' FILTER TO USE A CUSTOM PAGE TERMPLATE FOR SA PREVIEW PAGE ###
3450
- *
3451
- * @param string $template Page Template.
3452
- */
3453
- function cpt_slider_sa_preview_page_template( $template ) {
3454
- if ( is_page( 'Slide Anything Popup Preview' ) ) {
3455
- $template = dirname( __FILE__ ) . '/single-page.php';
3456
- }
3457
- return $template;
3458
- }
3459
-
3460
-
3461
- /**
3462
- * ### FILTER TO ALLOW IFRAMES WITHIN SLIDE CONTENT ###
3463
- *
3464
- * @param array $allowedposttags Allowed Post Tags.
3465
- */
3466
- function cpt_slider_allow_iframes_filter( $allowedposttags ) {
3467
- // Only change for users who can publish posts.
3468
- if ( ! current_user_can( 'publish_posts' ) ) {
3469
- return $allowedposttags;
3470
- }
3471
-
3472
- // Allow iframes and the following attributes.
3473
- $allowedposttags['iframe'] = array(
3474
- 'align' => true,
3475
- 'width' => true,
3476
- 'height' => true,
3477
- 'frameborder' => true,
3478
- 'name' => true,
3479
- 'src' => true,
3480
- 'title' => true,
3481
- 'allow' => true,
3482
- 'allowfullscreen' => true,
3483
- 'id' => true,
3484
- 'class' => true,
3485
- 'style' => true,
3486
- 'scrolling' => true,
3487
- 'marginwidth' => true,
3488
- 'marginheight' => true,
3489
- );
3490
- return $allowedposttags;
3491
- }
3492
- ?>
1
+ <?php
2
+ /**
3
+ * #####################################################################
4
+ * ### SLIDE ANYTHING PLUGIN - PHP FUNCTIONS FOR WordPress DASHBOARD ###
5
+ * #####################################################################
6
+ *
7
+ * @package WordPress_Slide_Anything
8
+ * @author Simon Edge
9
+ * @copyright EdgeWebPages
10
+ * @license GPLv2 or later
11
+ */
12
+
13
+ /**
14
+ * ##### PLUGIN REGISTRATION HOOK - RUN WHEN THE PLUGIN IS ACTIVATED #####
15
+ */
16
+ function cpt_slider_plugin_activation() {
17
+ // INSERT A 'SAMPLE SLIDER' CUSTOM POST INTO THE DATABASE.
18
+ $sample_post_title = 'Sample Slider';
19
+
20
+ // check if the 'sample slider' already exists (plugin has been activated before).
21
+ $cpt_post = get_page_by_title( $sample_post_title, 'OBJECT', 'sa_slider' );
22
+
23
+ if ( is_null( $cpt_post ) ) {
24
+ // create the post object.
25
+ $sample_post = array(
26
+ 'post_title' => $sample_post_title,
27
+ 'post_content' => '',
28
+ 'post_status' => 'publish',
29
+ 'post_type' => 'sa_slider',
30
+ );
31
+ // insert the post into the database.
32
+ $cpt_id = wp_insert_post( $sample_post );
33
+
34
+ // insert meta data for the 'sample slider' slides.
35
+ for ( $i = 1; $i <= 8; $i++ ) {
36
+ if ( 1 === $i ) {
37
+ $color = '#f4cccc';
38
+ $image = 'sample_logo1.png';
39
+ } elseif ( 2 === $i ) {
40
+ $color = '#d9ead3';
41
+ $image = 'sample_logo2.png';
42
+ } elseif ( 3 === $i ) {
43
+ $color = '#fce5cd';
44
+ $image = 'sample_logo3.png';
45
+ } elseif ( 4 === $i ) {
46
+ $color = '#d0e0e3';
47
+ $image = 'sample_logo4.png';
48
+ } elseif ( 5 === $i ) {
49
+ $color = '#fff2cc';
50
+ $image = 'sample_logo5.png';
51
+ } elseif ( 6 === $i ) {
52
+ $color = '#cfe2f3';
53
+ $image = 'sample_logo6.png';
54
+ } elseif ( 7 === $i ) {
55
+ $color = '#d9d2e9';
56
+ $image = 'sample_logo7.png';
57
+ } elseif ( 8 === $i ) {
58
+ $color = '#ead1dc';
59
+ $image = 'sample_logo8.png';
60
+ }
61
+ $content = "<div style='text-align: center; padding-bottom: 10px;'>\n";
62
+ $content .= "<div><img src='" . plugins_url() . '/slide-anything/images/' . $image . "' alt='Logo " . $i . "' /></div>\n";
63
+ $content .= "<h3>Company Name</h3>\n";
64
+ $content .= "<p>Lorem ipsum dolor sit amet, cu usu cibo vituperata, id ius probo maiestatis inciderint, sit eu vide volutpat.</p>\n";
65
+ $content .= "</div>\n";
66
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_content', $content );
67
+ $image_data = '~left top~contain~no-repeat~' . $color;
68
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_image_data', $image_data );
69
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_link_url', '' );
70
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_link_target', '_self' );
71
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_type', 'NONE' );
72
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_imageid', '' );
73
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_imagetitle', '' );
74
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_video_id', '' );
75
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_video_type', '' );
76
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_background', 'no' );
77
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_html', '' );
78
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_shortcode', '0' );
79
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_bgcol', '#ffffff' );
80
+ update_post_meta( $cpt_id, 'sa_slide' . $i . '_popup_width', '600' );
81
+ }
82
+ // insert meta data for the 'sample slider' configuration.
83
+ update_post_meta( $cpt_id, 'sa_disable_visual_editor', '0' );
84
+ update_post_meta( $cpt_id, 'sa_num_slides', 8 );
85
+ update_post_meta( $cpt_id, 'sa_slide_duration', 4 );
86
+ update_post_meta( $cpt_id, 'sa_slide_transition', 0.3 );
87
+ update_post_meta( $cpt_id, 'sa_slide_by', 1 );
88
+ update_post_meta( $cpt_id, 'sa_loop_slider', '1' );
89
+ update_post_meta( $cpt_id, 'sa_stop_hover', '1' );
90
+ update_post_meta( $cpt_id, 'sa_nav_arrows', '1' );
91
+ update_post_meta( $cpt_id, 'sa_pagination', '1' );
92
+ update_post_meta( $cpt_id, 'sa_shortcodes', '0' );
93
+ update_post_meta( $cpt_id, 'sa_random_order', '1' );
94
+ update_post_meta( $cpt_id, 'sa_reverse_order', '0' );
95
+ update_post_meta( $cpt_id, 'sa_mouse_drag', '0' );
96
+ update_post_meta( $cpt_id, 'sa_touch_drag', '1' );
97
+ update_post_meta( $cpt_id, 'sa_mousewheel', '0' );
98
+ update_post_meta( $cpt_id, 'sa_click_advance', '0' );
99
+ update_post_meta( $cpt_id, 'sa_auto_height', '0' );
100
+ update_post_meta( $cpt_id, 'sa_vert_center', '0' );
101
+ update_post_meta( $cpt_id, 'sa_items_width1', 1 );
102
+ update_post_meta( $cpt_id, 'sa_items_width2', 2 );
103
+ update_post_meta( $cpt_id, 'sa_items_width3', 3 );
104
+ update_post_meta( $cpt_id, 'sa_items_width4', 4 );
105
+ update_post_meta( $cpt_id, 'sa_items_width5', 4 );
106
+ update_post_meta( $cpt_id, 'sa_items_width6', 4 );
107
+ update_post_meta( $cpt_id, 'sa_transition', 'fade' );
108
+ update_post_meta( $cpt_id, 'sa_hero_slider', '0' );
109
+ update_post_meta( $cpt_id, 'sa_showcase_slider', '0' );
110
+ update_post_meta( $cpt_id, 'sa_showcase_width', '120' );
111
+ update_post_meta( $cpt_id, 'sa_showcase_tablet', '1' );
112
+ update_post_meta( $cpt_id, 'sa_showcase_width_tab', '130' );
113
+ update_post_meta( $cpt_id, 'sa_showcase_mobile', '0' );
114
+ update_post_meta( $cpt_id, 'sa_showcase_width_mob', '140' );
115
+ update_post_meta( $cpt_id, 'sa_css_id', 'sample_slider' );
116
+ update_post_meta( $cpt_id, 'sa_background_color', '#fafafa' );
117
+ update_post_meta( $cpt_id, 'sa_border_width', 1 );
118
+ update_post_meta( $cpt_id, 'sa_border_color', '#f0f0f0' );
119
+ update_post_meta( $cpt_id, 'sa_border_radius', 5 );
120
+ update_post_meta( $cpt_id, 'sa_wrapper_padd_top', 8 );
121
+ update_post_meta( $cpt_id, 'sa_wrapper_padd_right', 8 );
122
+ update_post_meta( $cpt_id, 'sa_wrapper_padd_bottom', 8 );
123
+ update_post_meta( $cpt_id, 'sa_wrapper_padd_left', 8 );
124
+ update_post_meta( $cpt_id, 'sa_slide_min_height_perc', 50 );
125
+ update_post_meta( $cpt_id, 'sa_slide_padding_tb', 5 );
126
+ update_post_meta( $cpt_id, 'sa_slide_padding_lr', 5 );
127
+ update_post_meta( $cpt_id, 'sa_slide_margin_lr', 0 );
128
+ update_post_meta( $cpt_id, 'sa_autohide_arrows', '1' );
129
+ update_post_meta( $cpt_id, 'sa_dot_per_slide', '0' );
130
+ update_post_meta( $cpt_id, 'sa_slide_icons_location', 'Center Center' );
131
+ update_post_meta( $cpt_id, 'sa_slide_icons_visible', '0' );
132
+ update_post_meta( $cpt_id, 'sa_slide_icons_color', 'white' );
133
+ update_post_meta( $cpt_id, 'sa_thumbs_active', '0' );
134
+ update_post_meta( $cpt_id, 'sa_thumbs_location', 'Inside Bottom' );
135
+ update_post_meta( $cpt_id, 'sa_thumbs_image_size', 'thumbnail' );
136
+ update_post_meta( $cpt_id, 'sa_thumbs_padding', 3 );
137
+ update_post_meta( $cpt_id, 'sa_thumbs_width', 150 );
138
+ update_post_meta( $cpt_id, 'sa_thumbs_height', 85 );
139
+ update_post_meta( $cpt_id, 'sa_thumbs_opacity', 50 );
140
+ update_post_meta( $cpt_id, 'sa_thumbs_border_width', 0 );
141
+ update_post_meta( $cpt_id, 'sa_thumbs_border_color', '#ffffff' );
142
+ update_post_meta( $cpt_id, 'sa_thumbs_resp_tablet', 75 );
143
+ update_post_meta( $cpt_id, 'sa_thumbs_resp_mobile', 50 );
144
+ }
145
+ }
146
+
147
+ /**
148
+ * ##### ADD CHECKBOX OPTION UNDER "Settings -> Writing" CALLED "Disable TinyMCE Button" #####
149
+ */
150
+ function cpt_slider_disable_tinymce_button_setting() {
151
+ // REGISTER WordPress SETTING.
152
+ register_setting(
153
+ 'writing',
154
+ 'sa-disable-tinymce-button',
155
+ 'cpt_slider_writing_settings_sanitize'
156
+ );
157
+ // CREATE SETTINGS SECTION (within "Settings->Writing").
158
+ add_settings_section(
159
+ 'sa-writing-settings-section',
160
+ 'Slide Anything Settings',
161
+ 'cpt_slider_writing_settings_section_description',
162
+ 'writing'
163
+ );
164
+ // CREATE SETTINGS INPUT FIELD.
165
+ add_settings_field(
166
+ 'sa-settings-field1',
167
+ 'Disable TinyMCE Button',
168
+ 'cpt_slider_writing_settings_field1_callback',
169
+ 'writing',
170
+ 'sa-writing-settings-section'
171
+ );
172
+ }
173
+
174
+ /**
175
+ * ##### SANATIZE SETTINGS CALLBACK FUNCTION #####
176
+ *
177
+ * @param string $input Disable TinyMCE Button checkbox.
178
+ */
179
+ function cpt_slider_writing_settings_sanitize( $input ) {
180
+ return isset( $input ) ? true : false;
181
+ }
182
+ /**
183
+ * ##### SETTING SECTION DESCRIPTION #####
184
+ */
185
+ function cpt_slider_writing_settings_section_description() {
186
+ echo esc_html( "Disable the 'Slide Anything Sliders' button within the toolbar of the WordPress Classic Editor when editing pages and posts." );
187
+ }
188
+ /**
189
+ * ##### SETTINGS INPUT FIELD CALLBACK #####
190
+ */
191
+ function cpt_slider_writing_settings_field1_callback() {
192
+ ?>
193
+ <label for="sa-disable-tinymce-input">
194
+ <input id="sa-disable-tinymce-input" type="checkbox" value="1" name="sa-disable-tinymce-button" <?php checked( get_option( 'sa-disable-tinymce-button', false ) ); ?>>
195
+ </label>
196
+ <?php
197
+ }
198
+
199
+ /**
200
+ * ##### ACTION HOOK - REGISTER SCRIPTS (JS AND CSS) FOR WordPress DASHBOARD ONLY #####
201
+ */
202
+ function cpt_slider_register_admin_scripts() {
203
+ $screen = get_current_screen();
204
+ $plugin_path = dirname( __FILE__ ) . '/../slide-anything.php';
205
+ $plugin_data = get_plugin_data( $plugin_path, false, false );
206
+ $plugin_ver = $plugin_data['Version'];
207
+ if ( 'sa_slider' === $screen->post_type ) {
208
+ // ONLY LOAD SCRIPTS (JS & CSS) WITHIN 'Slide Anything' SCREENS IN WordPress DASHBOARD.
209
+ // enqueues all scripts, styles & settings required in order to use the WordPress Media JS APIs.
210
+ wp_enqueue_media();
211
+ // load 'WordPress jquery-ui' scripts.
212
+ wp_enqueue_script( 'jquery-ui-core' );
213
+ wp_enqueue_script( 'jquery-ui-accordion' );
214
+ wp_enqueue_script( 'jquery-ui-tabs' );
215
+ wp_enqueue_script( 'jquery-ui-slider' );
216
+ wp_enqueue_script( 'jquery-ui-sortable' );
217
+ wp_enqueue_script( 'jquery-ui-draggable' );
218
+ wp_enqueue_script( 'jquery-ui-droppable' );
219
+ wp_enqueue_script( 'jquery-ui-resize' );
220
+ wp_enqueue_script( 'jquery-ui-dialog' );
221
+ wp_enqueue_script( 'jquery-ui-button' );
222
+ wp_enqueue_script( 'jquery-ui-tooltip' );
223
+ wp_enqueue_script( 'jquery-ui-spinner' );
224
+ // load 'spectrum colorpicker' script and css.
225
+ wp_register_script( 'spectrum_js', SA_PLUGIN_PATH . 'spectrum/spectrum.js', array( 'jquery' ), '1.8.0', true );
226
+ wp_enqueue_script( 'spectrum_js' );
227
+ wp_register_style( 'spectrum_css', SA_PLUGIN_PATH . 'spectrum/spectrum.css', array(), '1.8.0' );
228
+ wp_enqueue_style( 'spectrum_css' );
229
+ // load 'jquery-ui' css.
230
+ wp_register_style( 'admin_ui_css', SA_PLUGIN_PATH . 'css/admin-user-interface.min.css', array(), '1.11.4' );
231
+ wp_enqueue_style( 'admin_ui_css' );
232
+ // load 'slide-anything' custom javasript and css for WordPress admin.
233
+ wp_register_script( 'sa-slider-admin-script', SA_PLUGIN_PATH . 'js/slide-anything-admin.js', array( 'jquery' ), $plugin_ver, true );
234
+ wp_enqueue_script( 'sa-slider-admin-script' );
235
+ wp_register_style( 'sa-slider-admin-css', SA_PLUGIN_PATH . 'css/slide-anything-admin.css', array(), $plugin_ver );
236
+ wp_enqueue_style( 'sa-slider-admin-css' );
237
+ }
238
+ if ( 'settings_page_sa-settings-page' === $screen->id ) {
239
+ // SLIDE ANYTHING SETTINGS PAGE - load custom css script.
240
+ wp_register_style( 'sa-slider-admin-css', SA_PLUGIN_PATH . 'css/slide-anything-admin.css', array(), $plugin_ver );
241
+ wp_enqueue_style( 'sa-slider-admin-css' );
242
+ }
243
+ // style for TINYMCE editor 'Slide Anything sliders' button.
244
+ wp_register_style( 'tinymce-css', SA_PLUGIN_PATH . 'css/tinymce_style.css', array(), $plugin_ver );
245
+ wp_enqueue_style( 'tinymce-css' );
246
+ }
247
+
248
+
249
+
250
+ /**
251
+ * ##### ACTION HOOK - REGISTER THE 'Slide Anything' CUSTOM POST TYPE #####
252
+ */
253
+ function cpt_slider_register() {
254
+ $labels = array(
255
+ 'name' => _x( 'SA Sliders', 'post type general name', 'sa_slider_textdomain' ),
256
+ 'singular_name' => _x( 'Slider', 'post type singular name', 'sa_slider_textdomain' ),
257
+ 'menu_name' => __( 'SA Sliders', 'sa_slider_textdomain' ),
258
+ 'add_new' => __( 'Add New Slider', 'sa_slider_textdomain' ),
259
+ 'add_new_item' => __( 'Add New Slider', 'sa_slider_textdomain' ),
260
+ 'edit_item' => __( 'Edit Slider', 'sa_slider_textdomain' ),
261
+ 'new_item' => __( 'New Slider', 'sa_slider_textdomain' ),
262
+ 'view_item' => __( 'View Slider', 'sa_slider_textdomain' ),
263
+ 'not_found' => __( 'No sliders found', 'sa_slider_textdomain' ),
264
+ 'not_found_in_trash' => __( 'No sliders found in Trash', 'sa_slider_textdomain' ),
265
+ );
266
+ $args = array(
267
+ 'labels' => $labels,
268
+ 'description' => __( 'Slide Anything carousel/slider', 'sa_slider_textdomain' ),
269
+ 'public' => false,
270
+ 'exclude_from_search' => true,
271
+ 'publicly_queryable' => false,
272
+ 'show_ui' => true,
273
+ 'show_in_nav_menus' => false,
274
+ 'show_in_menu' => true,
275
+ 'menu_position' => 10,
276
+ 'menu_icon' => 'dashicons-images-alt2',
277
+ 'hierarchical' => false,
278
+ 'supports' => array( 'title' ),
279
+ 'has_archive' => false,
280
+ 'query_var' => false,
281
+ 'can_export' => true,
282
+ 'rewrite' => true,
283
+ 'capability_type' => 'post',
284
+ );
285
+ register_post_type( 'sa_slider', $args );
286
+ }
287
+
288
+
289
+
290
+ /**
291
+ * ##### WP DASHBOARD - SLIDER LIST PAGE #####
292
+ * ACTION HOOK - ADD/REMOVE (HOVER-OVER) ROW ACTIONS WHEN THIS CUSTOM POST TYPE IS LISTED IN DASHBOARD
293
+ *
294
+ * @param array $actions Row Actions.
295
+ * @param array $post Post Type.
296
+ */
297
+ function cpt_slider_row_actions( $actions, $post ) {
298
+ if ( 'sa_slider' === $post->post_type ) {
299
+ // REMOVE 'Quick Edit' ROW ACTION.
300
+ unset( $actions['inline hide-if-no-js'] );
301
+ }
302
+ return $actions;
303
+ }
304
+
305
+ /**
306
+ * ##### FILTER TO ADD/REMOVE COLUMNS DISPLAYED FOR THIS CUSTOM POST TYPE IN DASHBOARD #####
307
+ *
308
+ * @param array $columns Post List Columns.
309
+ */
310
+ function cpt_slider_modify_columns( $columns ) {
311
+ // new columns to be added.
312
+ $new_columns = array(
313
+ 'slides' => 'Slides',
314
+ 'shortcode' => 'Shortcode',
315
+ 'css-id' => 'CSS ID',
316
+ );
317
+ $columns = array_slice( $columns, 0, 2, true ) + $new_columns + array_slice( $columns, 2, null, true );
318
+ return $columns;
319
+ }
320
+
321
+ /**
322
+ * ##### DEFINE OUTPUT FOR EACH CUSTOM COLUMN DISPLAYED FOR THIS POST TYPE IN THE DASHBOARD #####
323
+ *
324
+ * @param array $column Post List Column.
325
+ */
326
+ function cpt_slider_custom_column_content( $column ) {
327
+ // get post object for this row.
328
+ global $post;
329
+
330
+ // output for the 'Slides' column.
331
+ if ( 'slides' === $column ) {
332
+ $num_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
333
+ if ( '' === $num_slides ) {
334
+ $num_slides = '-';
335
+ }
336
+ echo esc_html( $num_slides );
337
+ }
338
+
339
+ // output for the 'Shortcode' column.
340
+ if ( 'shortcode' === $column ) {
341
+ $shortcode = "[slide-anything id='" . $post->ID . "']";
342
+ echo esc_html( $shortcode );
343
+ }
344
+
345
+ // output for the 'CSS ID' column.
346
+ if ( 'css-id' === $column ) {
347
+ $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
348
+ if ( '' === $css_id ) {
349
+ $css_id = '-';
350
+ } else {
351
+ $css_id = '#' . $css_id;
352
+ }
353
+ echo esc_html( $css_id );
354
+ }
355
+ }
356
+
357
+
358
+
359
+ /**
360
+ * ##### ADD A CUSTOM BUTTON TO WordPress TINYMCE EDITOR (ON PAGES AND POSTS ONLY) #####
361
+ */
362
+ function cpt_slider_add_tinymce_button() {
363
+ global $typenow;
364
+ // check user permissions.
365
+ if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
366
+ return;
367
+ }
368
+ // verify the post type - only display button on posts and pages.
369
+ if ( ! in_array( $typenow, array( 'post', 'page' ), true ) ) {
370
+ return;
371
+ }
372
+ // check if WYSIWYG is enabled.
373
+ if ( 'true' === get_user_option( 'rich_editing' ) ) {
374
+ add_filter( 'mce_external_plugins', 'cpt_slider_add_tinymce_plugin' );
375
+ add_filter( 'mce_buttons', 'cpt_slider_register_tinymce_button' );
376
+ }
377
+ }
378
+
379
+ /**
380
+ * ##### FILTER HOOK: mce_external_plugins #####
381
+ *
382
+ * @param array $plugin_array Plugin Array.
383
+ */
384
+ function cpt_slider_add_tinymce_plugin( $plugin_array ) {
385
+ $plugin_array['tinymce_button'] = SA_PLUGIN_PATH . 'js/add_tinymce_button.js';
386
+ return $plugin_array;
387
+ }
388
+
389
+ /**
390
+ * ##### FILTER HOOK: mce_buttons #####
391
+ *
392
+ * @param array $buttons TinyMCE buttons.
393
+ */
394
+ function cpt_slider_register_tinymce_button( $buttons ) {
395
+ array_push( $buttons, 'tinymce_button' );
396
+ return $buttons;
397
+ }
398
+
399
+ /**
400
+ * ##### ACTION HOOK: admin_footer #####
401
+ */
402
+ function cpt_slider_get_tinymce_shortcode_array() {
403
+ $screen = get_current_screen();
404
+ if ( 'envira' !== $screen->post_type ) { // ### BUG FIX - CLASHING WITH ENVIRA GALLERY (VER 2.0.13) ###.
405
+ // display 2 javascript arrays (in footer) containing all the slide anything post titles and post ids.
406
+ // these 2 arrays are used to display the shortcode options by the TinyMCE button.
407
+ echo "<script type='text/javascript'>\n";
408
+ echo "var sa_title_arr = new Array();\n";
409
+ echo "var sa_id_arr = new Array();\n";
410
+
411
+ $args = array(
412
+ 'post_type' => 'sa_slider',
413
+ 'post_status' => 'publish',
414
+ 'posts_per_page' => -1,
415
+ );
416
+ $sa_slider_query = new WP_Query( $args );
417
+ $count = 0;
418
+ foreach ( $sa_slider_query->posts as $sa_post ) {
419
+ $title = $sa_post->post_title;
420
+ echo 'sa_title_arr[' . esc_js( $count ) . "] = '" . esc_js( $title ) . "';\n";
421
+ echo 'sa_id_arr[' . esc_js( $count ) . "] = '" . esc_js( $sa_post->ID ) . "';\n";
422
+ $count++;
423
+ }
424
+ echo "</script>\n";
425
+ }
426
+ }
427
+
428
+
429
+
430
+ /**
431
+ * ##### ACTION HOOK - ADD META BOXES TO THE 'Slide Anything' CUSTOM POST TYPE #####
432
+ */
433
+ function cpt_slider_add_meta_boxes() {
434
+ global $post;
435
+ global $current_user;
436
+ if ( ! is_object( $post ) ) {
437
+ return;
438
+ }
439
+
440
+ $info_added = get_post_meta( $post->ID, 'sa_info_added', true );
441
+ $info_deleted = get_post_meta( $post->ID, 'sa_info_deleted', true );
442
+ $info_duplicated = get_post_meta( $post->ID, 'sa_info_duplicated', true );
443
+ $info_moved = get_post_meta( $post->ID, 'sa_info_moved', true );
444
+ if ( '1' === $info_added ) {
445
+ add_meta_box( 'cpt_slide_added', __( 'Information' ), 'cpt_slide_added_content', 'sa_slider', 'normal', 'high' );
446
+ update_post_meta( $post->ID, 'sa_info_added', '0' );
447
+ }
448
+ if ( '1' === $info_deleted ) {
449
+ add_meta_box( 'cpt_slide_deleted', __( 'Information' ), 'cpt_slide_deleted_content', 'sa_slider', 'normal', 'high' );
450
+ update_post_meta( $post->ID, 'sa_info_deleted', '0' );
451
+ }
452
+ if ( '1' === $info_duplicated ) {
453
+ add_meta_box( 'cpt_slide_duplicated', __( 'Information' ), 'cpt_slide_duplicated_content', 'sa_slider', 'normal', 'high' );
454
+ update_post_meta( $post->ID, 'sa_info_duplicated', '0' );
455
+ }
456
+ if ( '1' === $info_moved ) {
457
+ add_meta_box( 'cpt_slide_moved', __( 'Information' ), 'cpt_slide_moved_content', 'sa_slider', 'normal', 'high' );
458
+ update_post_meta( $post->ID, 'sa_info_moved', '0' );
459
+ }
460
+ add_meta_box( 'cpt_slider_settings', __( 'Slider Settings' ), 'cpt_slider_settings_content', 'sa_slider', 'normal', 'high' );
461
+ add_meta_box( 'cpt_slider_slides', __( 'Slides' ), 'cpt_slider_slides_content', 'sa_slider', 'normal', 'high' );
462
+ add_meta_box( 'cpt_slider_shortcode', __( 'Shortcode / Preview' ), 'cpt_slider_shortcode_content', 'sa_slider', 'side', 'high' );
463
+ add_meta_box( 'cpt_slider_items', __( 'Items Displayed' ), 'cpt_slider_items_content', 'sa_slider', 'side', 'default' );
464
+ add_meta_box( 'cpt_slider_style', __( 'Slider Style' ), 'cpt_slider_style_content', 'sa_slider', 'side', 'default' );
465
+ add_meta_box( 'cpt_slider_thumbs', __( 'Thumbnail Pagination' ), 'cpt_slider_thumbs_content', 'sa_slider', 'side', 'default' );
466
+ remove_meta_box( 'mymetabox_revslider_0', 'sa_slider', 'normal' ); // remove revolution slider meta box.
467
+ }
468
+
469
+
470
+
471
+ /**
472
+ * ##### META BOX CONTENT - 'Information' (slide added) BOX #####
473
+ */
474
+ function cpt_slide_added_content() {
475
+ echo "<h3 id='sa_slide_added_mess'>A new slide has been added to this slider.</h3>";
476
+ }
477
+
478
+
479
+
480
+ /**
481
+ * ##### META BOX CONTENT - 'Information' (slide deleted) BOX #####
482
+ */
483
+ function cpt_slide_deleted_content() {
484
+ echo "<h3 id='sa_slide_deleted_mess'>A slide has been deleted from this slider.</h3>";
485
+ }
486
+
487
+
488
+
489
+ /**
490
+ * ##### META BOX CONTENT - 'Information' (slide duplicated) BOX #####
491
+ */
492
+ function cpt_slide_duplicated_content() {
493
+ echo "<h3 id='sa_slide_duplicated_mess'>A slide has been duplicated (copied) within this slider.</h3>";
494
+ }
495
+
496
+
497
+
498
+ /**
499
+ * ##### META BOX CONTENT - 'Information' (slide moved) BOX #####
500
+ */
501
+ function cpt_slide_moved_content() {
502
+ echo "<h3 id='sa_slide_moved_mess'>The slide order of this slider has been has changed.</h3>";
503
+ }
504
+
505
+
506
+
507
+ /**
508
+ * // ##### META BOX CONTENT - 'Slider Settings' BOX #####
509
+ *
510
+ * @param array $post Custom Post 'sa_slider'.
511
+ */
512
+ function cpt_slider_settings_content( $post ) {
513
+ $num_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
514
+ echo "<div id='sa_slider_settings'>\n";
515
+
516
+ // NONCE TO PREVENT CSRF SECURITY ATTACKS.
517
+ wp_nonce_field( basename( __FILE__ ), 'nonce_save_slider' );
518
+
519
+ // HIDDEN FIELD - NUMBER OF SLIDES.
520
+ if ( '' === $num_slides ) {
521
+ // new slider is being created.
522
+ echo "<input type='hidden' id='num_slides_id' name='sa_num_slides' value='3'/>\n";
523
+ } else {
524
+ // existing slider.
525
+ $num_slides = intval( $num_slides );
526
+ echo "<input type='hidden' id='num_slides_id' name='sa_num_slides' value='" . esc_attr( $num_slides ) . "'/>\n";
527
+ }
528
+ // HIDDEN FIELD - SLIDE ADDED INDICATOR.
529
+ echo "<input type='hidden' id='sa_info_added' name='sa_info_added' value='0'/>\n";
530
+ // HIDDEN FIELD - SLIDE DELETED INDICATOR.
531
+ echo "<input type='hidden' id='sa_info_deleted' name='sa_info_deleted' value='0'/>\n";
532
+ // HIDDEN FIELD - SLIDE DUPLICATED INDICATOR.
533
+ echo "<input type='hidden' id='sa_info_duplicated' name='sa_info_duplicated' value='0'/>\n";
534
+ // HIDDEN FIELD - SLIDE MOVED UP INDICATOR.
535
+ echo "<input type='hidden' id='sa_info_moved' name='sa_info_moved' value='0'/>\n";
536
+ // HIDDEN FIELD - DUPLICATE SLIDE NUMBER.
537
+ echo "<input type='hidden' id='sa_duplicate_slide' name='sa_duplicate_slide' value='0'/>\n";
538
+ // HIDDEN FIELD - MOVE SLIDE UP (SLIDE NUMBER).
539
+ echo "<input type='hidden' id='sa_move_slide_up' name='sa_move_slide_up' value='0'/>\n";
540
+ // HIDDEN FIELD - PRO VERSION.
541
+ echo "<input type='hidden' id='sa_pro_version' name='sa_pro_version' value='1'/>\n";
542
+ // SLIDE DURATION.
543
+ $slide_duration = get_post_meta( $post->ID, 'sa_slide_duration', true );
544
+ if ( '' === $slide_duration ) {
545
+ $slide_duration = 5;
546
+ }
547
+ echo "<div class='sa_slider_value'><span>Slide Duration:</span>";
548
+ echo "<input type='text' id='sa_slide_duration' name='sa_slide_duration' readonly value='" . esc_attr( $slide_duration ) . "'><em>seconds (0 = manual navigation)</em>";
549
+ echo "<em class='sa_tooltip' href='' title='Set to 0 to disable slider autoplay (manual slider navigation only)'></em></div>\n";
550
+ echo "<div class='jquery_ui_slider' id='jq_slider_duration'></div><hr/>\n";
551
+ // SLIDE TRANSITION.
552
+ $slide_transition = get_post_meta( $post->ID, 'sa_slide_transition', true );
553
+ if ( '' === $slide_transition ) {
554
+ $slide_transition = 0.2;
555
+ }
556
+ echo "<div class='sa_slider_value'><span>Slide Transition:</span>";
557
+ echo "<input type='text' id='sa_slide_transition' name='sa_slide_transition' readonly value='" . esc_attr( $slide_transition ) . "'><em>seconds</em>\n";
558
+ echo "<em class='sa_tooltip' href='' title='The time it takes to change from one slide to the next slide'></em></div>\n";
559
+ echo "<div class='jquery_ui_slider' id='jq_slider_transition'></div><hr/>\n";
560
+ // SLIDE BY.
561
+ $slide_by = get_post_meta( $post->ID, 'sa_slide_by', true );
562
+ if ( '' === $slide_by ) {
563
+ $slide_by = 1;
564
+ }
565
+ echo "<div class='sa_slider_value'><span>Slide By:</span>";
566
+ echo "<input type='text' id='sa_slide_by' name='sa_slide_by' readonly value='" . esc_attr( $slide_by ) . "'><em>slides (0 = slide by page)</em>";
567
+ echo "<em class='sa_tooltip' href='' title='The number of slides to slide per transition. Set to 0 to enable the Slide by Page option.'></em></div>\n";
568
+ echo "<div class='jquery_ui_slider' id='jq_slider_by'></div><hr/>\n";
569
+ echo "<div class='half_width_column'>\n";
570
+ // LOOP SLIDER.
571
+ $loop_slider = get_post_meta( $post->ID, 'sa_loop_slider', true );
572
+ if ( '' === $loop_slider ) {
573
+ $loop_slider = '1';
574
+ }
575
+ echo "<div class='sa_setting_checkbox'><span>Loop Slider:</span>";
576
+ if ( '1' === $loop_slider ) {
577
+ echo "<input type='checkbox' id='sa_loop_slider' name='sa_loop_slider' value='1' checked/>";
578
+ } else {
579
+ echo "<input type='checkbox' id='sa_loop_slider' name='sa_loop_slider' value='1'/>";
580
+ }
581
+ echo "<em class='sa_tooltip' href='' title='Only applies when slide duration is NOT zero (loops back to first slide after last slide is displayed)'></em>";
582
+ echo "</div>\n";
583
+ // STOP ON HOVER.
584
+ $stop_hover = get_post_meta( $post->ID, 'sa_stop_hover', true );
585
+ if ( '' === $stop_hover ) {
586
+ $stop_hover = '1';
587
+ }
588
+ echo "<div class='sa_setting_checkbox'><span>Stop on Hover:</span>";
589
+ if ( '1' === $stop_hover ) {
590
+ echo "<input type='checkbox' id='sa_stop_hover' name='sa_stop_hover' value='1' checked/>";
591
+ } else {
592
+ echo "<input type='checkbox' id='sa_stop_hover' name='sa_stop_hover' value='1'/>";
593
+ }
594
+ echo "<em class='sa_tooltip' href='' title='Only applies when slide duration is NOT zero (slideshow is paused when hovering over a slide)'></em>";
595
+ echo "</div>\n";
596
+ // RANDOM ORDER.
597
+ $random_order = get_post_meta( $post->ID, 'sa_random_order', true );
598
+ if ( '' === $random_order ) {
599
+ $random_order = '0';
600
+ }
601
+ echo "<div class='sa_setting_checkbox'><span>Random Order:</span>";
602
+ if ( '1' === $random_order ) {
603
+ echo "<input type='checkbox' id='sa_random_order' name='sa_random_order' value='1' checked/>";
604
+ } else {
605
+ echo "<input type='checkbox' id='sa_random_order' name='sa_random_order' value='1'/>";
606
+ }
607
+ echo "<em class='sa_tooltip' title='When checked slides will be randomly re-ordered whenever the slider is displayed'></em>";
608
+ echo "</div>\n";
609
+ // REVERSE ORDER.
610
+ $reverse_order = get_post_meta( $post->ID, 'sa_reverse_order', true );
611
+ if ( '' === $reverse_order ) {
612
+ $reverse_order = '0';
613
+ }
614
+ echo "<div class='sa_setting_checkbox'><span>Reverse Order:</span>";
615
+ if ( '1' === $reverse_order ) {
616
+ echo "<input type='checkbox' id='sa_reverse_order' name='sa_reverse_order' value='1' checked/>";
617
+ } else {
618
+ echo "<input type='checkbox' id='sa_reverse_order' name='sa_reverse_order' value='1'/>";
619
+ }
620
+ echo "<em class='sa_tooltip' title='When checked your slides will be shown in the reverse order (i.e. last slide first)'></em>";
621
+ echo "</div>\n";
622
+ // ALLOW SHORTCODES.
623
+ $shortcodes = get_post_meta( $post->ID, 'sa_shortcodes', true );
624
+ if ( '' === $shortcodes ) {
625
+ $shortcodes = '0';
626
+ }
627
+ echo "<div class='sa_setting_checkbox'><span>Allow Shortcodes:</span>";
628
+ if ( '1' === $shortcodes ) {
629
+ echo "<input type='checkbox' id='sa_shortcodes' name='sa_shortcodes' value='1' checked/>";
630
+ } else {
631
+ echo "<input type='checkbox' id='sa_shortcodes' name='sa_shortcodes' value='1'/>";
632
+ }
633
+ echo "<em class='sa_tooltip' href='' title='Include WordPree shorcodes within slide content. NOTE: Running shortcodes in Slide Anything may cause issues with some WordPress Page Builders'></em>\n";
634
+ echo "</div>\n";
635
+ // VERTICAL CENTER.
636
+ $vert_center = get_post_meta( $post->ID, 'sa_vert_center', true );
637
+ if ( '' === $vert_center ) {
638
+ $vert_center = '0';
639
+ }
640
+ echo "<div class='sa_setting_checkbox'><span>Vertical Center:</span>";
641
+ if ( '1' === $vert_center ) {
642
+ echo "<input type='checkbox' id='sa_vert_center' name='sa_vert_center' value='1' checked/>";
643
+ } else {
644
+ echo "<input type='checkbox' id='sa_vert_center' name='sa_vert_center' value='1'/>";
645
+ }
646
+ echo "<em class='sa_tooltip' title='Vertically center content within slides. Only use this setting if you have set a Min Height for your slider (which sets a minimum height for each slide).'></em>";
647
+ echo "</div>\n";
648
+ echo "</div>\n";
649
+ echo "<div class='half_width_column'>\n";
650
+ // NAVIGATE ARROWS.
651
+ $nav_arrows = get_post_meta( $post->ID, 'sa_nav_arrows', true );
652
+ if ( '' === $nav_arrows ) {
653
+ $nav_arrows = '1';
654
+ }
655
+ echo "<div class='sa_setting_checkbox'><span>Navigate Arrows:</span>";
656
+ if ( '1' === $nav_arrows ) {
657
+ echo "<input type='checkbox' id='sa_nav_arrows' name='sa_nav_arrows' value='1' checked/>";
658
+ } else {
659
+ echo "<input type='checkbox' id='sa_nav_arrows' name='sa_nav_arrows' value='1'/>";
660
+ }
661
+ echo "<em class='sa_tooltip' href='' title='Display the \"next slide\" amd \"previous slide\" buttons'></em>\n";
662
+ echo "</div>\n";
663
+ // SHOW PAGINATION.
664
+ $pagination = get_post_meta( $post->ID, 'sa_pagination', true );
665
+ if ( '' === $pagination ) {
666
+ $pagination = '1';
667
+ }
668
+ echo "<div class='sa_setting_checkbox'><span>Show Pagination:</span>";
669
+ if ( '1' === $pagination ) {
670
+ echo "<input type='checkbox' id='sa_pagination' name='sa_pagination' value='1' checked/>";
671
+ } else {
672
+ echo "<input type='checkbox' id='sa_pagination' name='sa_pagination' value='1'/>";
673
+ }
674
+ echo "<em class='sa_tooltip' href='' title='Display slider pagination below the slider'></em>\n";
675
+ echo "</div>\n";
676
+
677
+ // MOUSE DRAG.
678
+ $mouse_drag = get_post_meta( $post->ID, 'sa_mouse_drag', true );
679
+ if ( '' === $mouse_drag ) {
680
+ $mouse_drag = '0';
681
+ }
682
+ echo "<div class='sa_setting_checkbox'><span>Mouse Drag:</span>";
683
+ if ( '1' === $mouse_drag ) {
684
+ echo "<input type='checkbox' id='sa_mouse_drag' name='sa_mouse_drag' value='1' checked/>";
685
+ } else {
686
+ echo "<input type='checkbox' id='sa_mouse_drag' name='sa_mouse_drag' value='1'/>";
687
+ }
688
+ echo "<em class='sa_tooltip' href='' title='Allow navigation to previous/next slides by holding down left mouse button and dragging left/right. (NOTE: Enabling this option will disable vertical touch-drag scrolling on mobile devices)'></em>\n";
689
+ echo "</div>\n";
690
+ // TOUCH DRAG.
691
+ $touch_drag = get_post_meta( $post->ID, 'sa_touch_drag', true );
692
+ if ( '' === $touch_drag ) {
693
+ $touch_drag = '1';
694
+ }
695
+ echo "<div class='sa_setting_checkbox'><span>Touch Drag:</span>";
696
+ if ( '1' === $touch_drag ) {
697
+ echo "<input type='checkbox' id='sa_touch_drag' name='sa_touch_drag' value='1' checked/>";
698
+ } else {
699
+ echo "<input type='checkbox' id='sa_touch_drag' name='sa_touch_drag' value='1'/>";
700
+ }
701
+ echo "<em class='sa_tooltip' href='' title='Allow navigation to previous/next slides on mobile devices by touching screen and dragging left/right'></em>\n";
702
+ echo "</div>\n";
703
+ // MOUSEWHEEL NAV.
704
+ $mousewheel = get_post_meta( $post->ID, 'sa_mousewheel', true );
705
+ if ( '' === $mousewheel ) {
706
+ $mousewheel = '0';
707
+ }
708
+ echo "<div class='sa_setting_checkbox'><span>Mousewheel Nav:</span>";
709
+ if ( '1' === $mousewheel ) {
710
+ echo "<input type='checkbox' id='sa_mousewheel' name='sa_mousewheel' value='1' checked/>";
711
+ } else {
712
+ echo "<input type='checkbox' id='sa_mousewheel' name='sa_mousewheel' value='1'/>";
713
+ }
714
+ echo "<em class='sa_tooltip' href='' title='Allow previous/next slide navigation using the mousewheel (NOTE: does not work well with the Apple Mac touchpad scroll wheel mimic)'></em>\n";
715
+ echo "</div>\n";
716
+ // CLICK TO ADVANCE.
717
+ $click_advance = get_post_meta( $post->ID, 'sa_click_advance', true );
718
+ if ( '' === $click_advance ) {
719
+ $click_advance = '0';
720
+ }
721
+ echo "<div class='sa_setting_checkbox'><span>Click to Advance:</span>";
722
+ if ( '1' === $click_advance ) {
723
+ echo "<input type='checkbox' id='sa_click_advance' name='sa_click_advance' value='1' checked/>";
724
+ } else {
725
+ echo "<input type='checkbox' id='sa_click_advance' name='sa_click_advance' value='1'/>";
726
+ }
727
+ echo "<em class='sa_tooltip' href='' title='Clicking on the slider advances to the next slide. NOTE: Only works when the Mouse Drag and Touch Drag options are NOT checked.'></em>\n";
728
+ echo "</div>\n";
729
+ // AUTO HEIGHT.
730
+ $auto_height = get_post_meta( $post->ID, 'sa_auto_height', true );
731
+ if ( '' === $auto_height ) {
732
+ $auto_height = '0';
733
+ }
734
+ echo "<div class='sa_setting_checkbox'><span>Auto Height:</span>";
735
+ if ( '1' === $auto_height ) {
736
+ echo "<input type='checkbox' id='sa_auto_height' name='sa_auto_height' value='1' checked/>";
737
+ } else {
738
+ echo "<input type='checkbox' id='sa_auto_height' name='sa_auto_height' value='1'/>";
739
+ }
740
+ echo "<em class='sa_tooltip' title='Only works with 1 item on the screen. When checked the height of slider is automatically changed to match the height for each slide.'></em>";
741
+ echo "</div>\n";
742
+ echo "</div>\n";
743
+ echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
744
+ echo "</div>\n";
745
+ }
746
+
747
+
748
+
749
+ /**
750
+ * ##### META BOX CONTENT - 'Slides' BOX #####
751
+ *
752
+ * @param array $post Custom Post 'sa_slider'.
753
+ */
754
+ function cpt_slider_slides_content( $post ) {
755
+ $num_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
756
+ $slider_css_id = get_post_meta( $post->ID, 'sa_css_id', true );
757
+ // DISABLE VISUAL EDITOR CHECKBOX.
758
+ $disable_visual_editor = get_post_meta( $post->ID, 'sa_disable_visual_editor', true );
759
+ if ( '' === $disable_visual_editor ) {
760
+ $disable_visual_editor = '0';
761
+ }
762
+ echo "<div id='sa_visual_editor_checkbox'><span>Disable Visual Editor:</span>";
763
+ if ( '1' === $disable_visual_editor ) {
764
+ echo "<input type='checkbox' id='sa_disable_visual_editor' name='sa_disable_visual_editor' value='1' checked/></div>\n";
765
+ } else {
766
+ echo "<input type='checkbox' id='sa_disable_visual_editor' name='sa_disable_visual_editor' value='1'/></div>\n";
767
+ }
768
+ // SLIDER EDITOR BOX SETTINGS.
769
+ if ( '1' === $disable_visual_editor ) {
770
+ $editor_args = array(
771
+ 'tinymce' => false,
772
+ 'wpautop' => false,
773
+ 'media_buttons' => true,
774
+ 'editor_class' => 'sa_slide_content',
775
+ 'editor_height' => '250',
776
+ );
777
+ } else {
778
+ $editor_args = array(
779
+ 'tinymce' => true,
780
+ 'wpautop' => false,
781
+ 'media_buttons' => true,
782
+ 'editor_class' => 'sa_slide_content',
783
+ 'editor_height' => '250',
784
+ );
785
+ }
786
+ if ( '' === $num_slides ) {
787
+ // A NEW SLIDER IS BEING CREATED - ADD 3 INITIAL SLIDES.
788
+ $num_slides = 3;
789
+ $slide_data[0]['edit_id'] = 'sa_slide1_content';
790
+ $slide_data[0]['content'] = 'Slide content';
791
+ $slide_data[0]['del_id'] = 'sa_slide1_delete';
792
+ $slide_data[0]['image_data'] = 'sa_slide1_image_data';
793
+ $slide_data[0]['image_id'] = 'sa_slide1_image_id';
794
+ $slide_data[0]['thumb'] = 'slide1_thumb';
795
+ $slide_data[0]['image_del'] = 'slide1_image_del';
796
+ $slide_data[0]['image_pos'] = 'sa_slide1_image_pos';
797
+ $slide_data[0]['image_size'] = 'sa_slide1_image_size';
798
+ $slide_data[0]['image_repeat'] = 'sa_slide1_image_repeat';
799
+ $slide_data[0]['image_color'] = 'sa_slide1_image_color';
800
+ $slide_data[0]['link_url'] = 'sa_slide1_link_url';
801
+ $slide_data[0]['link_target'] = 'sa_slide1_link_target';
802
+ $slide_data[0]['slide_no'] = 1;
803
+ $slide_data[1]['edit_id'] = 'sa_slide2_content';
804
+ $slide_data[1]['content'] = 'Slide content';
805
+ $slide_data[1]['del_id'] = 'sa_slide2_delete';
806
+ $slide_data[1]['image_data'] = 'sa_slide2_image_data';
807
+ $slide_data[1]['image_id'] = 'sa_slide2_image_id';
808
+ $slide_data[1]['thumb'] = 'slide2_thumb';
809
+ $slide_data[1]['image_del'] = 'slide2_image_del';
810
+ $slide_data[1]['image_pos'] = 'sa_slide2_image_pos';
811
+ $slide_data[1]['image_size'] = 'sa_slide2_image_size';
812
+ $slide_data[1]['image_repeat'] = 'sa_slide2_image_repeat';
813
+ $slide_data[1]['image_color'] = 'sa_slide2_image_color';
814
+ $slide_data[1]['link_url'] = 'sa_slide2_link_url';
815
+ $slide_data[1]['link_target'] = 'sa_slide2_link_target';
816
+ $slide_data[1]['slide_no'] = 2;
817
+ $slide_data[2]['edit_id'] = 'sa_slide3_content';
818
+ $slide_data[2]['content'] = 'Slide content';
819
+ $slide_data[2]['del_id'] = 'sa_slide3_delete';
820
+ $slide_data[2]['image_data'] = 'sa_slide3_image_data';
821
+ $slide_data[2]['image_id'] = 'sa_slide3_image_id';
822
+ $slide_data[2]['thumb'] = 'slide3_thumb';
823
+ $slide_data[2]['image_del'] = 'slide3_image_del';
824
+ $slide_data[2]['image_pos'] = 'sa_slide3_image_pos';
825
+ $slide_data[2]['image_size'] = 'sa_slide3_image_size';
826
+ $slide_data[2]['image_repeat'] = 'sa_slide3_image_repeat';
827
+ $slide_data[2]['image_color'] = 'sa_slide3_image_color';
828
+ $slide_data[2]['link_url'] = 'sa_slide3_link_url';
829
+ $slide_data[2]['link_target'] = 'sa_slide3_link_target';
830
+ $slide_data[2]['slide_no'] = 3;
831
+ $slide_data[0]['popup_type'] = 'sa_slide1_popup_type';
832
+ $slide_data[0]['popup_imageid'] = 'sa_slide1_popup_imageid';
833
+ $slide_data[0]['popup_imagetitle'] = 'sa_slide1_popup_imagetitle';
834
+ $slide_data[0]['popup_video_id'] = 'sa_slide1_popup_video_id';
835
+ $slide_data[0]['popup_video_type'] = 'sa_slide1_popup_video_type';
836
+ $slide_data[0]['popup_background'] = 'sa_slide1_popup_background';
837
+ $slide_data[0]['popup_html'] = 'sa_slide1_popup_html';
838
+ $slide_data[0]['popup_shortcode'] = 'sa_slide1_popup_shortcode';
839
+ $slide_data[0]['popup_bgcol'] = 'sa_slide1_popup_bgcol';
840
+ $slide_data[0]['popup_width'] = 'sa_slide1_popup_width';
841
+ $slide_data[1]['popup_type'] = 'sa_slide2_popup_type';
842
+ $slide_data[1]['popup_imageid'] = 'sa_slide2_popup_imageid';
843
+ $slide_data[1]['popup_imagetitle'] = 'sa_slide2_popup_imagetitle';
844
+ $slide_data[1]['popup_video_id'] = 'sa_slide2_popup_video_id';
845
+ $slide_data[1]['popup_video_type'] = 'sa_slide2_popup_video_type';
846
+ $slide_data[1]['popup_background'] = 'sa_slide2_popup_background';
847
+ $slide_data[1]['popup_html'] = 'sa_slide2_popup_html';
848
+ $slide_data[1]['popup_shortcode'] = 'sa_slide2_popup_shortcode';
849
+ $slide_data[1]['popup_bgcol'] = 'sa_slide2_popup_bgcol';
850
+ $slide_data[1]['popup_width'] = 'sa_slide2_popup_width';
851
+ $slide_data[2]['popup_type'] = 'sa_slide3_popup_type';
852
+ $slide_data[2]['popup_imageid'] = 'sa_slide3_popup_imageid';
853
+ $slide_data[2]['popup_imagetitle'] = 'sa_slide3_popup_imagetitle';
854
+ $slide_data[2]['popup_video_id'] = 'sa_slide3_popup_video_id';
855
+ $slide_data[2]['popup_video_type'] = 'sa_slide3_popup_video_type';
856
+ $slide_data[2]['popup_background'] = 'sa_slide3_popup_background';
857
+ $slide_data[2]['popup_html'] = 'sa_slide3_popup_html';
858
+ $slide_data[2]['popup_shortcode'] = 'sa_slide3_popup_shortcode';
859
+ $slide_data[2]['popup_bgcol'] = 'sa_slide3_popup_bgcol';
860
+ $slide_data[2]['popup_width'] = 'sa_slide3_popup_width';
861
+ } else {
862
+ // AN EXISTING SLIDER - GET SLIDE DATA FROM THE DATABASE AND SAVE WITHIN AN ARRAY.
863
+ $num_slides = intval( $num_slides );
864
+ $slide_data = array();
865
+ $count = 0;
866
+ for ( $i = 1; $i <= $num_slides; $i++ ) {
867
+ $slide_edit_id = 'sa_slide' . $i . '_content';
868
+ $slide_char_count = 'sa_slide' . $i . '_char_count';
869
+ $slide_data[ $count ]['edit_id'] = $slide_edit_id;
870
+ $slide_data[ $count ]['content'] = get_post_meta( $post->ID, $slide_edit_id, true );
871
+ $slide_data[ $count ]['char_count'] = get_post_meta( $post->ID, $slide_char_count, true );
872
+ $slide_data[ $count ]['del_id'] = 'sa_slide' . $i . '_delete';
873
+ $slide_data[ $count ]['thumb'] = 'slide' . $i . '_thumb';
874
+ $slide_data[ $count ]['image_del'] = 'slide' . $i . '_image_del';
875
+ $slide_data[ $count ]['image_data'] = 'sa_slide' . $i . '_image_data';
876
+ $slide_data[ $count ]['image_id'] = 'sa_slide' . $i . '_image_id';
877
+ $slide_data[ $count ]['image_pos'] = 'sa_slide' . $i . '_image_pos';
878
+ $slide_data[ $count ]['image_size'] = 'sa_slide' . $i . '_image_size';
879
+ $slide_data[ $count ]['image_repeat'] = 'sa_slide' . $i . '_image_repeat';
880
+ $slide_data[ $count ]['image_color'] = 'sa_slide' . $i . '_image_color';
881
+ $slide_data[ $count ]['image_data'] = 'sa_slide' . $i . '_image_data';
882
+ $slide_data[ $count ]['link_url'] = 'sa_slide' . $i . '_link_url';
883
+ $slide_data[ $count ]['link_target'] = 'sa_slide' . $i . '_link_target';
884
+ $slide_data[ $count ]['popup_type'] = 'sa_slide' . $i . '_popup_type';
885
+ $slide_data[ $count ]['popup_imageid'] = 'sa_slide' . $i . '_popup_imageid';
886
+ $slide_data[ $count ]['popup_imagetitle'] = 'sa_slide' . $i . '_popup_imagetitle';
887
+ $slide_data[ $count ]['popup_video_id'] = 'sa_slide' . $i . '_popup_video_id';
888
+ $slide_data[ $count ]['popup_video_type'] = 'sa_slide' . $i . '_popup_video_type';
889
+ $slide_data[ $count ]['popup_background'] = 'sa_slide' . $i . '_popup_background';
890
+ $slide_data[ $count ]['popup_html'] = 'sa_slide' . $i . '_popup_html';
891
+ $slide_data[ $count ]['popup_shortcode'] = 'sa_slide' . $i . '_popup_shortcode';
892
+ $slide_data[ $count ]['popup_bgcol'] = 'sa_slide' . $i . '_popup_bgcol';
893
+ $slide_data[ $count ]['popup_width'] = 'sa_slide' . $i . '_popup_width';
894
+ $slide_data[ $count ]['slide_no'] = $i;
895
+ $count++;
896
+ }
897
+ }
898
+ // GET AVAILABLE WordPress IMAGE SIZES AND SAVE WITHIN AN ARRAY.
899
+ global $_wp_additional_image_sizes;
900
+ $image_size_arr = array();
901
+ $image_size_arr[0]['value'] = 'no';
902
+ $image_size_arr[0]['desc'] = 'NO';
903
+ $count = 1;
904
+ foreach ( get_intermediate_image_sizes() as $image_size ) {
905
+ if ( in_array( $image_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
906
+ $width = get_option( "{$image_size}_size_w" );
907
+ $height = get_option( "{$image_size}_size_h" );
908
+ } elseif ( isset( $_wp_additional_image_sizes[ $image_size ] ) ) {
909
+ $width = $_wp_additional_image_sizes[ $image_size ]['width'];
910
+ $height = $_wp_additional_image_sizes[ $image_size ]['height'];
911
+ }
912
+ if ( ( 0 !== $width ) && ( 0 !== $height ) ) {
913
+ $image_size_arr[ $count ]['value'] = $image_size;
914
+ $image_size_arr[ $count ]['desc'] = $image_size . ' (' . $width . '&times;' . $height . ')';
915
+ $count++;
916
+ }
917
+ }
918
+ /**
919
+ * ###### LOOP TO DISPLAY INPUT ELEMENTS FOR EACH SLIDE ######
920
+ */
921
+ echo "<div id='slider_accordion'>\n";
922
+
923
+ // determine whether to use css classes instead of csss ids.
924
+ $use_classes = 0;
925
+ $other_settings = get_post_meta( $post->ID, 'sa_other_settings', true );
926
+ if ( '' !== $other_settings ) {
927
+ $other_settings_arr = explode( '|', $other_settings );
928
+ }
929
+ if ( isset( $other_settings_arr ) && ( count( $other_settings_arr ) > 7 ) ) {
930
+ $disable_slide_ids = $other_settings_arr[7];
931
+ } else {
932
+ $disable_slide_ids = '0';
933
+ }
934
+ if ( '1' === $disable_slide_ids ) {
935
+ $use_classes = 1;
936
+ }
937
+
938
+ $tot = count( $slide_data );
939
+ for ( $i = 0; $i < $tot; $i++ ) {
940
+ // DISPLAY ACCORDION HEADING.
941
+ echo '<h3>Slide ' . esc_html( $slide_data[ $i ]['slide_no'] );
942
+ $css_id = $slider_css_id . '_slide' . sprintf( '%02d', $slide_data[ $i ]['slide_no'] );
943
+ // display CSS ID/CLASS for the current slide.
944
+ if ( 1 === $use_classes ) {
945
+ echo '<span>.' . esc_html( $css_id ) . '</span>';
946
+ } else {
947
+ echo '<span>#' . esc_html( $css_id ) . '</span>';
948
+ }
949
+ echo "</h3>\n";
950
+ echo "<div>\n";
951
+
952
+ // ### DISPLAY THE SLIDE CONTENT EDITOR (textarea field) ###
953
+ wp_editor( $slide_data[ $i ]['content'], $slide_data[ $i ]['edit_id'], $editor_args );
954
+
955
+ /**
956
+ * ##############################
957
+ * ##### SLIDE TABS - START #####
958
+ * ##############################
959
+ */
960
+ $tabs_num = $i + 1;
961
+ echo "<div id='slide_" . esc_html( $tabs_num ) . "_tabs' class='sa_slide_tabs'>\n";
962
+ echo "<ul>\n";
963
+ echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_background_tab'>Slide Background</a></li>\n";
964
+ echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_link_tab'>Slide Link</a></li>\n";
965
+ echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_popup_tab'>Slide Popup</a></li>\n";
966
+ echo "<li><a href='#slide" . esc_html( $tabs_num ) . "_goto_tab'>Slide Goto Link</a></li>\n";
967
+ echo "</ul>\n";
968
+
969
+ /**
970
+ * ####### SLIDE TAB 1 - SLIDE BACKGROUND #######
971
+ */
972
+ echo "<div id='slide" . esc_html( $tabs_num ) . "_background_tab' class='sa_slide_tab'>\n";
973
+
974
+ // GET BACKGROUND IMAGE DATA FOR THIS SLIDE (image id, position, size, repeat and color) FROM DATABASE.
975
+ $slide_image_data = get_post_meta( $post->ID, $slide_data[ $i ]['image_data'], true );
976
+ if ( isset( $slide_image_data ) && ( '' !== $slide_image_data ) ) {
977
+ $data_arr = explode( '~', $slide_image_data );
978
+ $slide_image_id = $data_arr[0];
979
+ $slide_image_pos = $data_arr[1];
980
+ $slide_image_size = $data_arr[2];
981
+ $slide_image_repeat = $data_arr[3];
982
+ $slide_image_color = $data_arr[4];
983
+ } else {
984
+ $slide_image_id = get_post_meta( $post->ID, $slide_data[ $i ]['image_id'], true );
985
+ $slide_image_pos = get_post_meta( $post->ID, $slide_data[ $i ]['image_pos'], true );
986
+ $slide_image_size = get_post_meta( $post->ID, $slide_data[ $i ]['image_size'], true );
987
+ $slide_image_repeat = get_post_meta( $post->ID, $slide_data[ $i ]['image_repeat'], true );
988
+ $slide_image_color = get_post_meta( $post->ID, $slide_data[ $i ]['image_color'], true );
989
+ }
990
+ if ( '' === $slide_image_pos ) {
991
+ $slide_image_pos = 'left top';
992
+ }
993
+ if ( '' === $slide_image_size ) {
994
+ $slide_image_size = 'contain';
995
+ }
996
+ if ( '' === $slide_image_repeat ) {
997
+ $slide_image_repeat = 'no-repeat';
998
+ }
999
+ if ( '' === $slide_image_color ) {
1000
+ $slide_image_color = 'rgba(0,0,0,0)';
1001
+ }
1002
+
1003
+ echo "<div class='sa_slide_bg_wrapper'>\n";
1004
+
1005
+ /**
1006
+ * ### 'USE POPUP IMAGE AS SLIDE BACKGROUND' SETTING ###
1007
+ */
1008
+ $slide_popup_background = get_post_meta( $post->ID, $slide_data[ $i ]['popup_background'], true );
1009
+ if ( '' === $slide_popup_background ) {
1010
+ $slide_popup_background = 'no';
1011
+ }
1012
+ echo "<div class='popup_background_wrapper'>\n";
1013
+ echo '<div>Use Popup Image as Slide Background:';
1014
+ $tooltip = 'Allows you to use the same image you defined as the popup image as the slide background image. You can use a smaller version of the popup image.';
1015
+ echo "<em class='sa_tooltip' href='' title='" . esc_attr( $tooltip ) . "'></em></div>\n";
1016
+ echo "<select id='" . esc_attr( $slide_data[ $i ]['popup_background'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_background'] ) . "' ";
1017
+ echo "onChange='change_slide_popup_background(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1018
+ $tot_loop = count( $image_size_arr );
1019
+ for ( $j = 0; $j < $tot_loop; $j++ ) {
1020
+ if ( $slide_popup_background === $image_size_arr[ $j ]['value'] ) {
1021
+ echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "' selected>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
1022
+ } else {
1023
+ echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "'>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
1024
+ }
1025
+ }
1026
+ echo '</select>';
1027
+ echo "</div>\n"; // .popup_background_wrapper
1028
+ echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
1029
+ echo "<div id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_imagebg_popup' class='sa_slide_bg_popup'><div></div></div>\n";
1030
+
1031
+ // SLIDE BACKGROUND IMAGE - THUMBNAIL AND 'SET IMAGE' BUTTON.
1032
+ // get WordPress media upload frame url.
1033
+ $upload_frame_url = esc_url( get_upload_iframe_src( 'image', $post->ID ) . '&slide=' . $slide_data[ $i ]['slide_no'] );
1034
+ // Get image src for slide background image.
1035
+ $slide_image_src = wp_get_attachment_image_src( $slide_image_id, 'medium' );
1036
+ // check if the slide background image id already exists.
1037
+ $image_exists = is_array( $slide_image_src );
1038
+ // slide backround image - thumbnail (and delete button).
1039
+ echo "<div id='" . esc_attr( $slide_data[ $i ]['thumb'] ) . "' class='sa_slide_thumb'>\n";
1040
+ if ( $image_exists ) {
1041
+ echo "<div style='background-image:url(\"" . esc_attr( $slide_image_src[0] ) . '"); background-size:' . esc_attr( $slide_image_size ) . '; ';
1042
+ echo 'background-repeat:' . esc_attr( $slide_image_repeat ) . '; background-color:' . esc_attr( $slide_image_color ) . '; ';
1043
+ echo 'background-position:' . esc_attr( $slide_image_pos ) . ";'></div>\n";
1044
+ echo "<span id='" . esc_attr( $slide_data[ $i ]['image_del'] ) . "' onClick='remove_slide_bg_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Delete the background image for this slide'>X</span>\n";
1045
+ echo "</div>\n";
1046
+ } else {
1047
+ if ( isset( $slide_data[ $i ]['popup_type'] ) ) {
1048
+ $slide_popup_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_type'], true );
1049
+ $popup_video_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_type'], true );
1050
+ $popup_video_id = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_id'], true );
1051
+ } else {
1052
+ $slide_popup_type = 'NONE';
1053
+ $popup_video_type = '';
1054
+ $popup_video_id = '';
1055
+ }
1056
+ if ( ( '99999999' === $slide_image_id ) && ( 'VIDEO' === $slide_popup_type ) && ( 'youtube' === $popup_video_type ) ) {
1057
+ $youtube_thumb = 'https://img.youtube.com/vi/' . $popup_video_id . '/maxresdefault.jpg';
1058
+ echo "<div style='background-image:url(\"" . esc_attr( $youtube_thumb ) . '"); background-size:' . esc_attr( $slide_image_size ) . '; ';
1059
+ echo 'background-repeat:' . esc_attr( $slide_image_repeat ) . '; background-color:' . esc_attr( $slide_image_color ) . '; ';
1060
+ echo 'background-position:' . esc_attr( $slide_image_pos ) . ";'></div>\n";
1061
+ echo "<span id='" . esc_attr( $slide_data[ $i ]['image_del'] ) . "' onClick='remove_slide_bg_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Delete the background image for this slide'>X</span>\n";
1062
+ echo "</div>\n";
1063
+ } else {
1064
+ echo "<div style='background-color:#ffffff; background-size:" . esc_attr( $slide_image_size ) . '; ';
1065
+ echo 'background-repeat:' . esc_attr( $slide_image_repeat ) . '; background-color:' . esc_attr( $slide_image_color ) . '; ';
1066
+ echo 'background-position:' . esc_attr( $slide_image_pos ) . ";'></div>\n";
1067
+ echo "<span id='" . esc_attr( $slide_data[ $i ]['image_del'] ) . "' class='sa_hidden' onClick='remove_slide_bg_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Delete the background image for this slide'>X</span>\n";
1068
+ echo "</div>\n";
1069
+ }
1070
+ }
1071
+ // slide background image - 'set image' button.
1072
+ echo "<a class='button button-secondary slide_image_add' id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_image_add' ";
1073
+ echo "href='" . esc_attr( $upload_frame_url ) . "' title='Set the background image for this slide'>Set Image</a>\n";
1074
+ // slide background image - image id hidden field.
1075
+ echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['image_id'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_id'] ) . "' value='" . esc_attr( $slide_image_id ) . "'/>\n";
1076
+
1077
+ // SLIDE BACKGROUND IMAGE - BACKGROUND POSITION (dropdown box).
1078
+ echo "<div class='slide_image_settings_line'>";
1079
+ echo '<span>Background Position:</span>';
1080
+ $option_arr = array();
1081
+ $option_arr[0]['desc'] = 'Top Left';
1082
+ $option_arr[0]['value'] = 'left top';
1083
+ $option_arr[1]['desc'] = 'Top Center';
1084
+ $option_arr[1]['value'] = 'center top';
1085
+ $option_arr[2]['desc'] = 'Top Right';
1086
+ $option_arr[2]['value'] = 'right top';
1087
+ $option_arr[3]['desc'] = 'Center Left';
1088
+ $option_arr[3]['value'] = 'left center';
1089
+ $option_arr[4]['desc'] = 'Center';
1090
+ $option_arr[4]['value'] = 'center center';
1091
+ $option_arr[5]['desc'] = 'Center Right';
1092
+ $option_arr[5]['value'] = 'right center';
1093
+ $option_arr[6]['desc'] = 'Bottom Left';
1094
+ $option_arr[6]['value'] = 'left bottom';
1095
+ $option_arr[7]['desc'] = 'Bottom Center';
1096
+ $option_arr[7]['value'] = 'center bottom';
1097
+ $option_arr[8]['desc'] = 'Bottom Right';
1098
+ $option_arr[8]['value'] = 'right bottom';
1099
+ echo "<select id='" . esc_attr( $slide_data[ $i ]['image_pos'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_pos'] ) . "' onChange='change_slide_image_pos(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1100
+ $tot_loop = count( $option_arr );
1101
+ for ( $j = 0; $j < $tot_loop; $j++ ) {
1102
+ if ( $slide_image_pos === $option_arr[ $j ]['value'] ) {
1103
+ echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "' selected>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1104
+ } else {
1105
+ echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "'>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1106
+ }
1107
+ }
1108
+ echo '</select>';
1109
+ echo "</div>\n";
1110
+
1111
+ // SLIDE BACKGROUND IMAGE - BACKGROUND SIZE (dropdown box).
1112
+ echo "<div class='slide_image_settings_line'>";
1113
+ echo '<span>Background Size:</span>';
1114
+ $option_arr = array();
1115
+ $option_arr[0]['value'] = 'auto';
1116
+ $option_arr[0]['desc'] = 'no resize';
1117
+ $option_arr[1]['value'] = 'contain';
1118
+ $option_arr[1]['desc'] = 'contain';
1119
+ $option_arr[2]['value'] = 'cover';
1120
+ $option_arr[2]['desc'] = 'cover';
1121
+ $option_arr[3]['value'] = '100% 100%';
1122
+ $option_arr[3]['desc'] = '100%';
1123
+ $option_arr[4]['value'] = '100% auto';
1124
+ $option_arr[4]['desc'] = '100% width';
1125
+ $option_arr[5]['value'] = 'auto 100%';
1126
+ $option_arr[5]['desc'] = '100% height';
1127
+ echo "<select id='" . esc_attr( $slide_data[ $i ]['image_size'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_size'] ) . "' onChange='change_slide_image_size(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1128
+ $tot_loop = count( $option_arr );
1129
+ for ( $j = 0; $j < $tot_loop; $j++ ) {
1130
+ if ( $slide_image_size === $option_arr[ $j ]['value'] ) {
1131
+ echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "' selected>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1132
+ } else {
1133
+ echo "<option value='" . esc_attr( $option_arr[ $j ]['value'] ) . "'>" . esc_html( $option_arr[ $j ]['desc'] ) . '</option>';
1134
+ }
1135
+ }
1136
+ echo '</select>';
1137
+ echo "</div>\n";
1138
+
1139
+ // SLIDER BACKGROUND IMAGE - BACKGROUND REPEAT (dropdown box).
1140
+ echo "<div class='slide_image_settings_line'>";
1141
+ echo '<span>Background Repeat:</span>';
1142
+ $option_arr = array();
1143
+ $option_arr[0] = 'no-repeat';
1144
+ $option_arr[1] = 'repeat';
1145
+ $option_arr[2] = 'repeat-x';
1146
+ $option_arr[3] = 'repeat-y';
1147
+ echo "<select id='" . esc_attr( $slide_data[ $i ]['image_repeat'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_repeat'] ) . "' ";
1148
+ echo "onChange='change_slide_image_repeat(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1149
+ $tot_loop = count( $option_arr );
1150
+ for ( $j = 0; $j < $tot_loop; $j++ ) {
1151
+ if ( $slide_image_repeat === $option_arr[ $j ] ) {
1152
+ echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "' selected>" . esc_html( $option_arr[ $j ] ) . '</option>';
1153
+ } else {
1154
+ echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "'>" . esc_html( $option_arr[ $j ] ) . '</option>';
1155
+ }
1156
+ }
1157
+ echo '</select>';
1158
+ echo "</div>\n";
1159
+
1160
+ // SLIDER BACKGROUND IMAGE - BACKGROUND COLOR (color picker).
1161
+ echo "<div class='slide_image_settings_line'>";
1162
+ echo '<span>Background Color:</span>';
1163
+ echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['image_color'] ) . "' name='" . esc_attr( $slide_data[ $i ]['image_color'] ) . "' value='" . esc_attr( $slide_image_color ) . "' ";
1164
+ echo "onChange='change_slide_image_color(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1165
+ echo "</div>\n";
1166
+
1167
+ echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
1168
+ echo "</div>\n";
1169
+ echo "</div>\n";
1170
+
1171
+ /**
1172
+ * ####### SLIDE TAB 2 - SLIDE LINK #######
1173
+ */
1174
+ echo "<div id='slide" . esc_attr( $tabs_num ) . "_link_tab' class='sa_slide_tab'>\n";
1175
+
1176
+ // GET SLIDE LINK DATA FOR THIS SLIDE FROM THE DATABASE.
1177
+ $slide_link_url = get_post_meta( $post->ID, $slide_data[ $i ]['link_url'], true );
1178
+ $slide_link_target = get_post_meta( $post->ID, $slide_data[ $i ]['link_target'], true );
1179
+ if ( '' === $slide_link_target ) {
1180
+ $slide_link_target = '_self';
1181
+ }
1182
+
1183
+ // DISPLAY INPUT FIELDS FOR SLIDE LINK SETTINGS.
1184
+ echo "<div class='slide_link_settings_wrapper'>";
1185
+ echo '<p>Specify a link URL that this slide opens</h3>';
1186
+ // LINK URL.
1187
+ echo '<div><span>Link URL:</span>';
1188
+ echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['link_url'] ) . "' name='" . esc_attr( $slide_data[ $i ]['link_url'] ) . "' ";
1189
+ echo "value='" . esc_attr( $slide_link_url ) . "'/></div>\n";
1190
+ // LINK TARGET.
1191
+ echo '<div><span>Link Target:</span>';
1192
+ echo "<select id='" . esc_attr( $slide_data[ $i ]['link_target'] ) . "' name='" . esc_attr( $slide_data[ $i ]['link_target'] ) . "'>";
1193
+ if ( '_blank' === $slide_link_target ) {
1194
+ echo "<option value='_self'>Same Tab/Window</option>";
1195
+ echo "<option value='_blank' selected>New Tab/Window</option>";
1196
+ } else {
1197
+ echo "<option value='_self' selected>Same Tab/Window</option>";
1198
+ echo "<option value='_blank'>New Tab/Window</option>";
1199
+ }
1200
+ echo '</select>';
1201
+ echo "</div>\n";
1202
+
1203
+ echo "</div>\n";
1204
+ echo "</div>\n";
1205
+
1206
+ /**
1207
+ * ####### SLIDE TAB 3 - SLIDE POPUP #######
1208
+ */
1209
+ echo "<div id='slide" . esc_attr( $tabs_num ) . "_popup_tab' class='sa_slide_tab'>\n";
1210
+
1211
+ // GET SLIDE POPUP DATA FOR THIS SLIDE FROM THE DATABASE.
1212
+ $slide_popup_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_type'], true );
1213
+ if ( '' === $slide_popup_type ) {
1214
+ $slide_popup_type = 'NONE';
1215
+ }
1216
+ $popup_imageid = intval( get_post_meta( $post->ID, $slide_data[ $i ]['popup_imageid'], true ) );
1217
+ $popup_video_id = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_id'], true );
1218
+ $popup_video_type = get_post_meta( $post->ID, $slide_data[ $i ]['popup_video_type'], true );
1219
+ $popup_imagetitle = get_post_meta( $post->ID, $slide_data[ $i ]['popup_imagetitle'], true );
1220
+ $popup_html = get_post_meta( $post->ID, $slide_data[ $i ]['popup_html'], true );
1221
+ $popup_shortcode = get_post_meta( $post->ID, $slide_data[ $i ]['popup_shortcode'], true );
1222
+ $popup_bgcol = get_post_meta( $post->ID, $slide_data[ $i ]['popup_bgcol'], true );
1223
+ $popup_width = intval( get_post_meta( $post->ID, $slide_data[ $i ]['popup_width'], true ) );
1224
+ $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1225
+
1226
+ // POPUP TYPE.
1227
+ echo "<div class='slide_popup_settings_line'>";
1228
+ echo '<span>SA Popup Type:</span>';
1229
+ $option_arr = array();
1230
+ $option_arr[0] = 'NONE';
1231
+ $option_arr[1] = 'IMAGE';
1232
+ $option_arr[2] = 'VIDEO';
1233
+ $option_arr[3] = 'HTML';
1234
+ echo "<select id='" . esc_attr( $slide_data[ $i ]['popup_type'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_type'] ) . "' ";
1235
+ echo "onChange='change_slide_popup_type(" . esc_attr( $slide_data[ $i ]['slide_no'] ) . ");'>";
1236
+ $tot_loop = count( $option_arr );
1237
+ for ( $j = 0; $j < $tot_loop; $j++ ) {
1238
+ if ( $slide_popup_type === $option_arr[ $j ] ) {
1239
+ echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "' selected>" . esc_html( $option_arr[ $j ] ) . '</option>';
1240
+ } else {
1241
+ echo "<option value='" . esc_attr( $option_arr[ $j ] ) . "'>" . esc_html( $option_arr[ $j ] ) . '</option>';
1242
+ }
1243
+ }
1244
+ echo '</select>';
1245
+ echo "</div>\n";
1246
+
1247
+ // A) IMAGE POPUP SETTINGS.
1248
+ $sl_num = ( $i + 1 );
1249
+ if ( 'IMAGE' === $slide_popup_type ) {
1250
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_image_popup_wrapper' class='image_popup_wrapper'>\n";
1251
+ } else {
1252
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_image_popup_wrapper' class='image_popup_wrapper' style='display:none;'>\n";
1253
+ }
1254
+ // get WordPress media upload frame url.
1255
+ $upload_popup_frame_url = esc_url( get_upload_iframe_src( 'image', $post->ID ) . '&popup=' . $slide_data[ $i ]['slide_no'] );
1256
+ // Get image src for slide popup image.
1257
+ $popup_image_src = wp_get_attachment_image_src( $popup_imageid, 'medium' );
1258
+ // check if the slide background image id already exists.
1259
+ $image_exists = is_array( $popup_image_src );
1260
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_popup_thumb' class='slide_popup_thumb'>\n";
1261
+ $placeholder = SA_PLUGIN_PATH . 'images/image_placeholder.jpg';
1262
+ if ( $image_exists ) {
1263
+ // media library image id exists - display thumbnail image.
1264
+ echo "<div><img src='" . esc_attr( $popup_image_src[0] ) . "'/></div>";
1265
+ // display image delete button.
1266
+ echo "<span onClick='remove_popup_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . '", "' . esc_attr( $placeholder ) . "\");' ";
1267
+ echo "id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_image_del' title='Delete the popup image for this slide'>X</span>\n";
1268
+ // get popup image info (size & dimensions).
1269
+ $popup_image_meta = wp_get_attachment_metadata( $popup_imageid );
1270
+ $image_width = $popup_image_meta['width'];
1271
+ $image_height = $popup_image_meta['height'];
1272
+ $info_dim = $image_width . ' x ' . $image_height . ' pixels';
1273
+ $popup_image_full = wp_get_attachment_image_src( $popup_imageid, 'full' );
1274
+ $img_headers = get_headers( $popup_image_full[0], 1 );
1275
+ $info_size = $img_headers['Content-Length'];
1276
+ if ( '' !== $info_size ) {
1277
+ $size_unit = 'bytes';
1278
+ if ( $info_size > 1048576 ) {
1279
+ if ( ! is_array( $info_size ) ) {
1280
+ $info_size = round( $info_size / 1048576 ) . ' MB';
1281
+ } else {
1282
+ $info_size = '';
1283
+ }
1284
+ } elseif ( $info_size > 1024 ) {
1285
+ if ( ! is_array( $info_size ) ) {
1286
+ $info_size = round( $info_size / 1024 ) . ' kb';
1287
+ } else {
1288
+ $info_size = '';
1289
+ }
1290
+ }
1291
+ }
1292
+ } else {
1293
+ // no image selected yet - display placeholder image.
1294
+ $popup_image_id = 0;
1295
+ echo "<div><img src='" . esc_attr( $placeholder ) . "'/></div>";
1296
+ // display image delete button (hidden state).
1297
+ echo "<span class='sa_hidden' onClick='remove_popup_image(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . '", "' . esc_attr( $placeholder ) . "\");' ";
1298
+ echo "id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_image_del' title='Delete the popup image for this slide'>X</span>\n";
1299
+ // reset popup image info (size & dimensions).
1300
+ $info_dim = '';
1301
+ $info_size = '';
1302
+ }
1303
+ echo "</div>\n";
1304
+ // slide popup image - 'set image' button.
1305
+ echo "<a class='button button-secondary popup_image_add' href='" . esc_attr( $upload_popup_frame_url ) . "' ";
1306
+ echo "title='Set the background image for this slide'>Set Image</a>\n";
1307
+ // slide popup image - popup image id hidden field.
1308
+ echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['popup_imageid'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_imageid'] );
1309
+ echo "' value='" . esc_attr( $popup_imageid ) . "' />\n";
1310
+ // slide popup image - popup image info (title, dimensions & size).
1311
+ echo "<div class='slide_popup_info'>\n";
1312
+ // popup image title.
1313
+ echo "<input class='sa_slide_popup_imagetitle' type='text' id='" . esc_attr( $slide_data[ $i ]['popup_imagetitle'] ) . "' ";
1314
+ echo "name='" . esc_attr( $slide_data[ $i ]['popup_imagetitle'] ) . "' value='" . esc_attr( $popup_imagetitle ) . "' ";
1315
+ echo "onChange='change_popup_image_title(this.value, \"" . esc_attr( $preview_button ) . "\")' placeholder='Enter popup title'/>\n";
1316
+ // popup dimensions.
1317
+ echo "<div id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_info_dim' class='slide_popup_info_dim'>";
1318
+ echo '<strong>Dimensions:</strong> ' . esc_html( $info_dim ) . "</div>\n";
1319
+ // popup file size.
1320
+ echo "<div id='slide" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "_popup_info_size' class='slide_popup_info_size'>";
1321
+ if ( '' !== $info_size ) {
1322
+ echo '<strong>File Size:</strong> ' . esc_html( $info_size );
1323
+ }
1324
+ echo "</div>\n";
1325
+ echo "</div>\n";
1326
+ echo "<div style='clear:both; float:none; width:100%; height:1px;'></div>\n";
1327
+ echo "</div>\n";
1328
+
1329
+ // B) VIDEO POPUP SETTINGS.
1330
+ $sl_num = ( $i + 1 );
1331
+ if ( 'VIDEO' === $slide_popup_type ) {
1332
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_video_popup_wrapper' class='video_popup_wrapper'>\n";
1333
+ } else {
1334
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_video_popup_wrapper' class='video_popup_wrapper' style='display:none;'>\n";
1335
+ }
1336
+ // set default video values.
1337
+ if ( ( 'youtube' !== $popup_video_type ) && ( 'vimeo' !== $popup_video_type ) ) {
1338
+ $popup_video_type = '';
1339
+ $popup_video_id = '';
1340
+ }
1341
+ if ( '' === $popup_video_id ) {
1342
+ $popup_video_type = '';
1343
+ }
1344
+ // video preview.
1345
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_video_thumb' class='slide_video_thumb'>\n";
1346
+ if ( '' !== $popup_video_id ) {
1347
+ if ( 'youtube' === $popup_video_type ) {
1348
+ echo "<iframe src='https://www.youtube.com/embed/" . esc_attr( $popup_video_id ) . "' frameborder='0' allowfullscreen></iframe>\n";
1349
+ } elseif ( 'vimeo' === $popup_video_type ) {
1350
+ echo "<iframe src='https://player.vimeo.com/video/" . esc_attr( $popup_video_id ) . "' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
1351
+ } else {
1352
+ echo "<img src='" . esc_attr( SA_PLUGIN_PATH ) . "images/video_placeholder.jpg'/>";
1353
+ }
1354
+ } else {
1355
+ echo "<img src='" . esc_attr( SA_PLUGIN_PATH ) . "images/video_placeholder.jpg'/>";
1356
+ }
1357
+ echo "<div style='float:none; clear:both; width:100%; height:1px;'></div>\n";
1358
+ echo "</div>\n";
1359
+ // video url (youtube/vimeo) input text box.
1360
+ echo "<div class='sa_slide_video_url'>";
1361
+ echo "<input type='text' id='sa_slide" . esc_attr( $sl_num ) . "_video_url' name='sa_slide" . esc_attr( $sl_num ) . "_video_url' ";
1362
+ echo "placeholder='Enter YouTube or Vimeo URL'/></div>\n";
1363
+ // 'update video' button.
1364
+ echo "<a class='button button-secondary' title='Update popup video using the above video URL' ";
1365
+ echo "onClick='update_popup_video(" . esc_attr( $sl_num ) . ");'>Set Video</a>\n";
1366
+ // invalid url error message.
1367
+ echo "<div id='sa_slide" . esc_attr( $sl_num ) . "_video_invalid_url' class='sa_popup_video_invalid_url'>";
1368
+ echo "URL entered is NOT a valid YouTube or Vimeo URL!</div>\n";
1369
+ // hidden video id text field.
1370
+ echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['popup_video_id'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_video_id'] ) . "' ";
1371
+ echo "value='" . esc_attr( $popup_video_id ) . "'/>\n";
1372
+ // hidden video type (youtube/vimeo) text field.
1373
+ echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['popup_video_type'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_video_type'] ) . "' ";
1374
+ echo "value='" . esc_attr( $popup_video_type ) . "'/>\n";
1375
+ echo "<div style='float:none; clear:both; width:100%; height:1px;'></div>\n";
1376
+ echo "</div>\n";
1377
+
1378
+ // C) CONTENT POPUP SETTINGS.
1379
+ $sl_num = ( $i + 1 );
1380
+ if ( 'HTML' === $slide_popup_type ) {
1381
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_html_popup_wrapper' class='html_popup_wrapper'>\n";
1382
+ } else {
1383
+ echo "<div id='slide" . esc_attr( $sl_num ) . "_html_popup_wrapper' class='html_popup_wrapper' style='display:none;'>\n";
1384
+ }
1385
+ // content popup - html.
1386
+ echo "<textarea id='" . esc_attr( $slide_data[ $i ]['popup_html'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_html'] ) . "' ";
1387
+ echo "placeholder='Enter HTML Code or WordPress Shortcode'>" . esc_attr( $popup_html ) . "</textarea>\n";
1388
+ // content popup - shortcode.
1389
+ if ( '' === $popup_shortcode ) {
1390
+ $popup_shortcode = '0';
1391
+ }
1392
+ echo "<div class='slide_popup_settings_line' style='margin:3px 0px 15px;'><span>Shortcode Content:</span>";
1393
+ if ( '1' === $popup_shortcode ) {
1394
+ echo "<input type='checkbox' id='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' value='1' checked/>";
1395
+ } else {
1396
+ echo "<input type='checkbox' id='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_shortcode'] ) . "' value='1'/>";
1397
+ }
1398
+ echo "<em class='sa_tooltip' href='' title='Use a WordPress shortcode instead of HTML as your popup content'></em>\n";
1399
+ echo "</div>\n";
1400
+ // content popup - css id.
1401
+ $popup_id = $css_id . '_popup' . ( $i + 1 );
1402
+ echo "<div class='slide_popup_settings_line'>";
1403
+ echo "<span>Popup CSS ID:</span><div id='sa_slide" . esc_attr( $sl_num ) . "_popup_css' class='slide_popup_css'>#" . esc_html( $popup_id ) . '</div>';
1404
+ echo '<strong>(click to copy to clipboard)</strong></div>';
1405
+ // content popup - background color.
1406
+ if ( '' === $popup_bgcol ) {
1407
+ $popup_bgcol = '#ffffff';
1408
+ }
1409
+ echo "<div class='slide_popup_settings_line'>";
1410
+ echo '<span>Background Color:</span>';
1411
+ echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['popup_bgcol'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_bgcol'] ) . "' ";
1412
+ echo "value='" . esc_attr( $popup_bgcol ) . "'>";
1413
+ echo "</div>\n";
1414
+ // content popup - width.
1415
+ if ( ( '' === $popup_width ) || ( 0 === $popup_width ) ) {
1416
+ $popup_width = '600';
1417
+ }
1418
+ echo "<div class='slide_popup_settings_line'>";
1419
+ echo '<span>Popup Width:</span>';
1420
+ echo "<input type='text' id='" . esc_attr( $slide_data[ $i ]['popup_width'] ) . "' name='" . esc_attr( $slide_data[ $i ]['popup_width'] ) . "' ";
1421
+ echo "value='" . esc_attr( $popup_width ) . "'><em>px</em>";
1422
+ echo "</div>\n";
1423
+
1424
+ echo "</div>\n";
1425
+ echo "</div>\n";
1426
+
1427
+ /**
1428
+ * ####### SLIDE TAB 4 - SLIDE GOTO LINK #######
1429
+ */
1430
+ $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1431
+ $goto_class = $css_id . '_goto' . ( $i + 1 );
1432
+ $eg_link = 'https://edgewebpages.com/slide-goto-links';
1433
+ echo "<div id='slide" . esc_attr( $tabs_num ) . "_goto_tab' class='sa_slide_tab'>\n";
1434
+ echo "<div class='slide_goto_link_content'>\n";
1435
+ echo "<p><strong>Create a link or button to link directly to this slide</strong></p>\n";
1436
+ echo "<p>To do this, give your link or button the following <strong>CSS Class:</strong></p>\n";
1437
+ echo "<div class='slide_goto_class'><span>" . esc_html( $goto_class ) . "</span></div>\n";
1438
+ echo "<p>To see an example of how a '<strong>Slide Goto Link</strong>' works ";
1439
+ echo "<a href='" . esc_attr( $eg_link ) . "' target='_blank'>CLICK HERE</a></p>\n";
1440
+ echo "</div>\n";
1441
+ echo "</div>\n";
1442
+
1443
+ /**
1444
+ * // ############################
1445
+ * // ##### SLIDE TABS - END #####
1446
+ * // ############################
1447
+ */
1448
+ echo "</div>\n";
1449
+
1450
+ // 3. DELETE STATUS FIELD (hidden) AND DELETE SLIDE BUTTON.
1451
+ echo "<input type='hidden' id='" . esc_attr( $slide_data[ $i ]['del_id'] ) . "' name='" . esc_attr( $slide_data[ $i ]['del_id'] ) . "' value='1'/>\n";
1452
+ echo "<div class='button button-secondary' onClick='delete_sa_slide(\"" . esc_attr( $slide_data[ $i ]['del_id'] ) . "\");' title='Delete this slide'>Delete Slide</div>\n";
1453
+
1454
+ // 4. DUPLICATE SLIDE BUTTON.
1455
+ echo "<div class='button button-secondary' onClick='duplicate_slide(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Duplicate this slide'>Duplicate Slide</div>\n";
1456
+
1457
+ // 5. MOVE SLIDE UP BUTTON.
1458
+ if ( 1 !== $slide_data[ $i ]['slide_no'] ) {
1459
+ echo "<div class='button button-secondary' onClick='move_slide_up(\"" . esc_attr( $slide_data[ $i ]['slide_no'] ) . "\");' title='Move this slide up within the slide order'>Move Slide Up</div>\n";
1460
+ }
1461
+
1462
+ echo "</div>\n";
1463
+ }
1464
+ echo "</div>\n";
1465
+
1466
+ // ADD SLIDE BUTTON.
1467
+ if ( $num_slides < 99 ) {
1468
+ // a maximum of 99 slides allowed.
1469
+ echo "<div id='sa_add_slide' class='button button-primary button-large' title='Add a new slide'>Add Slide</div>\n";
1470
+ }
1471
+
1472
+ // JQUERY-UI DIALOG BOX DIV - FOR CONFIRMATION DIALOG BOXES.
1473
+ echo "<div id='sa_dialog_box'></div>\n";
1474
+ }
1475
+
1476
+
1477
+
1478
+ /**
1479
+ * ##### META BOX CONTENT - 'Slider Preview/Shortcode' BOX #####
1480
+ *
1481
+ * @param array $post Custom Post 'sa_slider'.
1482
+ */
1483
+ function cpt_slider_shortcode_content( $post ) {
1484
+ $post_status = get_post_status( $post->ID );
1485
+ $allow_shortcodes = get_post_meta( $post->ID, 'sa_shortcodes', true );
1486
+ $shortcode = '[slide-anything id="' . $post->ID . '"]';
1487
+ echo "<div id='sa_slider_shortcode'>" . esc_html( $shortcode ) . "</div>\n";
1488
+ echo "<div id='sa_shortcode_copy' class='button button-secondary'>Copy to Clipboard</div>\n";
1489
+ }
1490
+
1491
+
1492
+
1493
+ /**
1494
+ * ##### META BOX CONTENT - 'Items Displayed' BOX #####
1495
+ *
1496
+ * @param array $post Custom Post 'sa_slider'.
1497
+ */
1498
+ function cpt_slider_items_content( $post ) {
1499
+ $items_width1 = intval( get_post_meta( $post->ID, 'sa_items_width1', true ) );
1500
+ $items_width2 = intval( get_post_meta( $post->ID, 'sa_items_width2', true ) );
1501
+ $items_width3 = intval( get_post_meta( $post->ID, 'sa_items_width3', true ) );
1502
+ $items_width4 = intval( get_post_meta( $post->ID, 'sa_items_width4', true ) );
1503
+ $items_width5 = intval( get_post_meta( $post->ID, 'sa_items_width5', true ) );
1504
+ $items_width6 = intval( get_post_meta( $post->ID, 'sa_items_width6', true ) );
1505
+ if ( 0 === $items_width1 ) {
1506
+ $items_width1 = 1; }
1507
+ if ( 0 === $items_width2 ) {
1508
+ $items_width2 = 1; }
1509
+ if ( 0 === $items_width3 ) {
1510
+ $items_width3 = 1; }
1511
+ if ( 0 === $items_width4 ) {
1512
+ $items_width4 = 1; }
1513
+ if ( 0 === $items_width5 ) {
1514
+ $items_width5 = 1; }
1515
+ if ( 0 === $items_width6 ) {
1516
+ $items_width6 = $items_width5; }
1517
+
1518
+ echo "<div id='items_displayed_metabox'>\n";
1519
+ echo "<h4>Browser/Device Width:</h4>\n";
1520
+ // items for browser width category 1.
1521
+ echo "<div><em class='sa_tooltip' href='' title='Up to 479 pixels'></em><span>Mobile Portrait</span><select name='sa_items_width1'>";
1522
+ for ( $i = 1; $i <= 12; $i++ ) {
1523
+ if ( $i === $items_width1 ) {
1524
+ echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1525
+ } else {
1526
+ echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1527
+ }
1528
+ }
1529
+ echo "</select></div>\n";
1530
+ // items for browser width category 2.
1531
+ echo "<div><em class='sa_tooltip' href='' title='480 to 767 pixels'></em><span>Mobile Landscape</span><select name='sa_items_width2'>";
1532
+ for ( $i = 1; $i <= 12; $i++ ) {
1533
+ if ( $i === $items_width2 ) {
1534
+ echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1535
+ } else {
1536
+ echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1537
+ }
1538
+ }
1539
+ echo "</select></div>\n";
1540
+ // items for browser width category 3.
1541
+ echo "<div><em class='sa_tooltip' href='' title='768 to 979 pixels'></em><span>Tablet Portrait</span><select name='sa_items_width3'>";
1542
+ for ( $i = 1; $i <= 12; $i++ ) {
1543
+ if ( $i === $items_width3 ) {
1544
+ echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1545
+ } else {
1546
+ echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1547
+ }
1548
+ }
1549
+ echo "</select></div>\n";
1550
+ // items for browser width category 4.
1551
+ echo "<div><em class='sa_tooltip' href='' title='980 to 1199 pixels'></em><span>Desktop Small</span><select name='sa_items_width4'>";
1552
+ for ( $i = 1; $i <= 12; $i++ ) {
1553
+ if ( $i === $items_width4 ) {
1554
+ echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1555
+ } else {
1556
+ echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1557
+ }
1558
+ }
1559
+ echo "</select></div>\n";
1560
+ // items for browser width category 5.
1561
+ echo "<div><em class='sa_tooltip' href='' title='1200 to 1499 pixels'></em><span>Desktop Large</span><select name='sa_items_width5'>";
1562
+ for ( $i = 1; $i <= 12; $i++ ) {
1563
+ if ( $i === $items_width5 ) {
1564
+ echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1565
+ } else {
1566
+ echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1567
+ }
1568
+ }
1569
+ echo "</select></div>\n";
1570
+ // items for browser width category 6.
1571
+ echo "<div><em class='sa_tooltip' href='' title='Over 1500 pixels'></em><span>Desktop X-Large</span><select name='sa_items_width6'>";
1572
+ for ( $i = 1; $i <= 12; $i++ ) {
1573
+ if ( $i === $items_width6 ) {
1574
+ echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
1575
+ } else {
1576
+ echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
1577
+ }
1578
+ }
1579
+ echo "</select></div>\n";
1580
+ // slide transition effect.
1581
+ $transition = get_post_meta( $post->ID, 'sa_transition', true );
1582
+ if ( '' === $transition ) {
1583
+ $transition = 'fade';
1584
+ }
1585
+ $option_arr = array();
1586
+ $option_arr[0] = 'Slide';
1587
+ $option_arr[1] = 'Fade';
1588
+ $option_arr[2] = 'Zoom In';
1589
+ $option_arr[3] = 'Zoom Out';
1590
+ $option_arr[4] = 'Flip Out X';
1591
+ $option_arr[5] = 'Flip Out Y';
1592
+ $option_arr[6] = 'Rotate Left';
1593
+ $option_arr[7] = 'Rotate Right';
1594
+ $option_arr[8] = 'Bounce Out';
1595
+ $option_arr[9] = 'Roll Out';
1596
+ $option_arr[10] = 'Slide Down';
1597
+ if ( ( 1 === $items_width1 ) && ( 1 === $items_width2 ) && ( 1 === $items_width3 ) && ( 1 === $items_width4 ) && ( 1 === $items_width5 ) && ( 1 === $items_width6 ) ) {
1598
+ echo "<div class='sa_items_all_one' style='display:block;'>";
1599
+ } else {
1600
+ echo "<div class='sa_items_all_one' style='display:none;'>";
1601
+ }
1602
+ echo "<em class='sa_tooltip' href='' title='NOTE: Slide transitions only work when the above items displayed are ALL SET TO 1'></em>";
1603
+ echo "<span style='color:firebrick !important;'>Slide Transition</span><select style='max-width:100px !important;' name='sa_transition'>";
1604
+ $tot_opt = count( $option_arr );
1605
+ for ( $i = 0; $i < $tot_opt; $i++ ) {
1606
+ if ( $transition === $option_arr[ $i ] ) {
1607
+ echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "' selected>" . esc_html( $option_arr[ $i ] ) . '</option>';
1608
+ } else {
1609
+ echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "'>" . esc_html( $option_arr[ $i ] ) . '</option>';
1610
+ }
1611
+ }
1612
+ echo "</select></div>\n";
1613
+
1614
+ // HERO SLIDER.
1615
+ $hero_slider = get_post_meta( $post->ID, 'sa_hero_slider', true );
1616
+ if ( '1' !== $hero_slider ) {
1617
+ $hero_slider = '0';
1618
+ }
1619
+ if ( ( 1 === $items_width1 ) && ( 1 === $items_width2 ) && ( 1 === $items_width3 ) && ( 1 === $items_width4 ) && ( 1 === $items_width5 ) && ( 1 === $items_width6 ) ) {
1620
+ echo "<div id='sa_hero_slider_wrapper' class='sa_items_all_one' style='display:block;'>";
1621
+ } else {
1622
+ echo "<div id='sa_hero_slider_wrapper' class='sa_items_all_one' style='display:none;'>";
1623
+ }
1624
+ echo '<span>Hero Slider</span>';
1625
+ // hero slider checkbox.
1626
+ if ( '1' === $hero_slider ) {
1627
+ echo "<input type='checkbox' id='sa_hero_slider' name='sa_hero_slider' value='1' checked/>";
1628
+ } else {
1629
+ echo "<input type='checkbox' id='sa_hero_slider' name='sa_hero_slider' value='1'/>";
1630
+ }
1631
+ $hs_note1 = 'Most WP Theme &apos;Page Builders&apos; (Visual Composer, Divi, Elementor, SiteOrigin...) allow you create full-width sections in your content. If you are not using a page builder then you will have to manually create a PHP template file to include a full-width container.';
1632
+ $hs_note2 = 'The slider height is set to 100% screen/device height using CSS &apos;vh&apos; (viewport height). Just about all browsers now support CSS viewport units, except Opera Mini which was installed on the old &apos;button&apos; phones.';
1633
+ if ( '1' === $hero_slider ) {
1634
+ echo "<div id='sa_hero_slider_note' style='display:block;'>";
1635
+ } else {
1636
+ echo "<div id='sa_hero_slider_note' style='display:none;'>";
1637
+ }
1638
+ echo '<strong>Please Note:</strong>';
1639
+ echo "<ol><li>Shortcode should be inserted into a full-width section<em class='sa_tooltip' title='" . esc_attr( $hs_note1 ) . "'></em></li>";
1640
+ echo "<li>Only works on browsers that support Viewport units - see <a href='https://caniuse.com/#feat=viewport-units' target='_blank'>here</a>";
1641
+ echo "<em class='sa_tooltip' title='" . esc_attr( $hs_note2 ) . "'></em></li></ol></div>";
1642
+ echo "</div>\n";
1643
+
1644
+ // SHOWCASE SLIDER.
1645
+ if ( ( 1 === $items_width1 ) && ( 1 === $items_width2 ) && ( 1 === $items_width3 ) && ( 1 === $items_width4 ) && ( 1 === $items_width5 ) && ( 1 === $items_width6 ) ) {
1646
+ echo "<div id='sa_showcase_slider_wrapper' style='display:none;'>";
1647
+ } else {
1648
+ echo "<div id='sa_showcase_slider_wrapper' style='display:block;'>";
1649
+ }
1650
+ // showcase slider checkbox.
1651
+ $showcase_slider = get_post_meta( $post->ID, 'sa_showcase_slider', true );
1652
+ if ( '1' !== $showcase_slider ) {
1653
+ $showcase_slider = '0';
1654
+ }
1655
+ echo "<div class='sa_ss_line'><span><strong>Showcase Carousel</strong></span>";
1656
+ echo "<input type='checkbox' id='sa_showcase_slider' name='sa_showcase_slider' value='1'";
1657
+ if ( '1' === $showcase_slider ) {
1658
+ echo ' checked'; }
1659
+ echo ' />';
1660
+ echo '</div>';
1661
+ if ( '1' === $showcase_slider ) {
1662
+ echo "<div id='sa_showcase_slider_pro' style='display:block;'>";
1663
+ } else {
1664
+ echo "<div id='sa_showcase_slider_pro' style='display:none;'>";
1665
+ }
1666
+ // showcase slider - desktop width.
1667
+ $showcase_width = get_post_meta( $post->ID, 'sa_showcase_width', true );
1668
+ if ( '' === $showcase_width ) {
1669
+ $showcase_width = '120';
1670
+ }
1671
+ echo "<div class='sa_ss_line'><span>Desktop Width</span>";
1672
+ echo "<input type='text' id='sa_showcase_width' name='sa_showcase_width' value='" . esc_attr( $showcase_width ) . "'>";
1673
+ echo "<em>%</em></div>\n";
1674
+ // showcase slider - use on tablets.
1675
+ $showcase_tablet = get_post_meta( $post->ID, 'sa_showcase_tablet', true );
1676
+ if ( ( '0' !== $showcase_tablet ) && ( '1' !== $showcase_tablet ) ) {
1677
+ $showcase_tablet = '1';
1678
+ }
1679
+ echo "<div class='sa_ss_line'><span>Use on Tablets</span>";
1680
+ if ( '1' === $showcase_tablet ) {
1681
+ echo "<input type='checkbox' id='sa_showcase_tablet' name='sa_showcase_tablet' value='1' checked />";
1682
+ } else {
1683
+ echo "<input type='checkbox' id='sa_showcase_tablet' name='sa_showcase_tablet' value='1' />";
1684
+ }
1685
+ echo "</div>\n";
1686
+ // showcase slider - tablet width.
1687
+ $showcase_width_tab = get_post_meta( $post->ID, 'sa_showcase_width_tab', true );
1688
+ if ( '' === $showcase_width_tab ) {
1689
+ $showcase_width_tab = '130';
1690
+ }
1691
+ echo "<div class='sa_ss_line'><span>Tablet Width</span>";
1692
+ echo "<input type='text' id='sa_showcase_width_tab' name='sa_showcase_width_tab' value='" . esc_attr( $showcase_width_tab ) . "'>";
1693
+ echo "<em>%</em></div>\n";
1694
+ // showcase slider - use on mobiles.
1695
+ $showcase_mobile = get_post_meta( $post->ID, 'sa_showcase_mobile', true );
1696
+ if ( '1' !== $showcase_mobile ) {
1697
+ $showcase_mobile = '0';
1698
+ }
1699
+ echo "<div class='sa_ss_line'><span>Use on Mobiles</span>";
1700
+ if ( '1' === $showcase_mobile ) {
1701
+ echo "<input type='checkbox' id='sa_showcase_mobile' name='sa_showcase_mobile' value='1' checked />";
1702
+ } else {
1703
+ echo "<input type='checkbox' id='sa_showcase_mobile' name='sa_showcase_mobile' value='1' />";
1704
+ }
1705
+ echo "</div>\n";
1706
+ // showcase slider - mobile width.
1707
+ $showcase_width_mob = get_post_meta( $post->ID, 'sa_showcase_width_mob', true );
1708
+ if ( '' === $showcase_width_mob ) {
1709
+ $showcase_width_mob = '140';
1710
+ }
1711
+ echo "<div class='sa_ss_line'><span>Mobile Width</span>";
1712
+ echo "<input type='text' id='sa_showcase_width_mob' name='sa_showcase_width_mob' value='" . esc_attr( $showcase_width_mob ) . "'>";
1713
+ echo "<em>%</em></div>\n";
1714
+ // showcase slider - css to style left/rightmost slides.
1715
+ $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1716
+ echo "<div class='sa_ss_css_line'>CSS to target left+right partial slides:";
1717
+ echo "<div id='ss_css_value'>#" . esc_html( $css_id ) . ' .sc_partial</div>';
1718
+ echo "</div>\n";
1719
+ echo '</div>'; // #sa_showcase_slider_pro
1720
+ echo "</div>\n";
1721
+
1722
+ echo "</div>\n";
1723
+ }
1724
+
1725
+
1726
+
1727
+ /**
1728
+ * ##### META BOX CONTENT - 'Slider Style' BOX #####
1729
+ *
1730
+ * @param array $post Custom Post 'sa_slider'.
1731
+ */
1732
+ function cpt_slider_style_content( $post ) {
1733
+ // CSS ID.
1734
+ $css_id = get_post_meta( $post->ID, 'sa_css_id', true );
1735
+ if ( '' === $css_id ) {
1736
+ $css_id = 'slider_' . $post->ID;
1737
+ }
1738
+ echo "<div id='slider_style_metabox'>\n";
1739
+ echo "<h4>CSS <span>#id</span> for Slider:</h4>\n";
1740
+ echo "<div style='padding-bottom:10px; color:#909090;'>Must consist of letters (upper/lowercase) or Underscore '_' characters <span style='color:firebrick;'>ONLY!</span></div>\n";
1741
+ echo "<input type='text' id='sa_css_id' name='sa_css_id' value='" . esc_attr( $css_id ) . "'/>\n";
1742
+ echo "<div id='css_note_text'>To style slides use CSS selector:</div>";
1743
+ echo "<div id='css_note_value'>#" . esc_html( $css_id ) . ' .owl-item</div>';
1744
+ echo "<div class='ca_style_hr'></div>\n";
1745
+
1746
+ // SLIDER PADDING (TOP, RIGHT, BOTTOM, LEFT).
1747
+ $wrapper_padd_top = get_post_meta( $post->ID, 'sa_wrapper_padd_top', true );
1748
+ if ( '' === $wrapper_padd_top ) {
1749
+ $wrapper_padd_top = '0'; }
1750
+ $wrapper_padd_right = get_post_meta( $post->ID, 'sa_wrapper_padd_right', true );
1751
+ if ( '' === $wrapper_padd_right ) {
1752
+ $wrapper_padd_right = '0'; }
1753
+ $wrapper_padd_bottom = get_post_meta( $post->ID, 'sa_wrapper_padd_bottom', true );
1754
+ if ( '' === $wrapper_padd_bottom ) {
1755
+ $wrapper_padd_bottom = '0'; }
1756
+ $wrapper_padd_left = get_post_meta( $post->ID, 'sa_wrapper_padd_left', true );
1757
+ if ( '' === $wrapper_padd_left ) {
1758
+ $wrapper_padd_left = '0'; }
1759
+ $tooltip = 'Padding space around the entire carousel/slider';
1760
+ echo "<h4>Padding <span>(pixels)</span>:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1761
+ echo "<div class='ca_style_padding'>";
1762
+ echo "<div id='padd_top'>";
1763
+ echo "<input type='text' id='sa_wrapper_padd_top' name='sa_wrapper_padd_top' value='" . esc_attr( $wrapper_padd_top ) . "'></div>";
1764
+ echo "<div id='padd_right'>";
1765
+ echo "<input type='text' id='sa_wrapper_padd_right' name='sa_wrapper_padd_right' value='" . esc_attr( $wrapper_padd_right ) . "'></div>";
1766
+ echo "<div type='text' id='padd_bottom'>";
1767
+ echo "<input type='text' id='sa_wrapper_padd_bottom' name='sa_wrapper_padd_bottom' value='" . esc_attr( $wrapper_padd_bottom ) . "'></div>";
1768
+ echo "<div id='padd_left'>";
1769
+ echo "<input type='text' id='sa_wrapper_padd_left' name='sa_wrapper_padd_left' value='" . esc_attr( $wrapper_padd_left ) . "'></div>";
1770
+ echo "</div>\n";
1771
+ echo "<div style='clear:both; float:none; width:100%; height:10px;'></div>";
1772
+
1773
+ $tooltip = 'Style settings for the slider navigation arrows and slider pagination';
1774
+ echo "<h4>Slider Navigation:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1775
+
1776
+ // AUTOHIDE ARROWS.
1777
+ $autohide_arrows = get_post_meta( $post->ID, 'sa_autohide_arrows', true );
1778
+ if ( '' === $autohide_arrows ) {
1779
+ $autohide_arrows = '1';
1780
+ }
1781
+ echo "<div class='ca_style_setting_line'><span style='width:140px;'>Autohide Arrows</span>";
1782
+ if ( '1' === $autohide_arrows ) {
1783
+ echo "<input type='checkbox' id='sa_autohide_arrows' name='sa_autohide_arrows' value='1' checked/>";
1784
+ } else {
1785
+ echo "<input type='checkbox' id='sa_autohide_arrows' name='sa_autohide_arrows' value='1'/>";
1786
+ }
1787
+ echo "</div>\n";
1788
+
1789
+ // SHOW DOT PER SLIDE.
1790
+ $dot_per_slide = get_post_meta( $post->ID, 'sa_dot_per_slide', true );
1791
+ if ( '' === $dot_per_slide ) {
1792
+ $dot_per_slide = '0';
1793
+ }
1794
+ echo "<div class='ca_style_setting_line'><span style='width:140px;'>Show 1 Dot Per Slide</span>";
1795
+ if ( '1' === $dot_per_slide ) {
1796
+ echo "<input type='checkbox' id='sa_dot_per_slide' name='sa_dot_per_slide' value='1' checked/>";
1797
+ } else {
1798
+ echo "<input type='checkbox' id='sa_dot_per_slide' name='sa_dot_per_slide' value='1'/>";
1799
+ }
1800
+ echo "</div>\n";
1801
+
1802
+ $tooltip = 'The background color and border around the entire carousel/slider';
1803
+ echo "<h4>Background/Border:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1804
+
1805
+ // SLIDER BACKGROUND COLOR.
1806
+ $background_color = get_post_meta( $post->ID, 'sa_background_color', true );
1807
+ if ( '' === $background_color ) {
1808
+ $background_color = 'rgba(0,0,0,0)';
1809
+ }
1810
+ echo "<div class='ca_style_setting_line'><span>Background:</span>";
1811
+ echo "<input type='text' id='sa_background_color' name='sa_background_color' value='" . esc_attr( $background_color ) . "'></div>\n";
1812
+
1813
+ // SLIDER BORDER (WIDTH & COLOR).
1814
+ $border_width = get_post_meta( $post->ID, 'sa_border_width', true );
1815
+ if ( '' === $border_width ) {
1816
+ $border_width = '0';
1817
+ }
1818
+ $border_color = get_post_meta( $post->ID, 'sa_border_color', true );
1819
+ if ( '' === $border_color ) {
1820
+ $border_color = 'rgba(0,0,0,0)';
1821
+ }
1822
+ echo "<div class='ca_style_setting_line'><span>Border Style:</span>";
1823
+ echo "<input type='text' id='sa_border_width' name='sa_border_width' value='" . esc_attr( $border_width ) . "'><em>px</em>";
1824
+ echo "<input type='text' id='sa_border_color' name='sa_border_color' value='" . esc_attr( $border_color ) . "'></div>\n";
1825
+
1826
+ // SLIDER BORDER RADIUS.
1827
+ $border_radius = get_post_meta( $post->ID, 'sa_border_radius', true );
1828
+ if ( '' === $border_radius ) {
1829
+ $border_radius = '0';
1830
+ }
1831
+ echo "<div class='ca_style_setting_line'><span>Border Radius:</span>";
1832
+ echo "<input type='text' id='sa_border_radius' name='sa_border_radius' value='" . esc_attr( $border_radius ) . "'></div>\n";
1833
+
1834
+ echo "<div class='ca_style_hr' style='margin-top:10px;'></div>\n";
1835
+
1836
+ $tooltip = 'The style settings for all slides (within the slider/carousel)';
1837
+ echo "<h4>Slide Style:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1838
+
1839
+ // SLIDE - MINIMUM HEIGHT.
1840
+ $slide_min_height = get_post_meta( $post->ID, 'sa_slide_min_height_perc', true );
1841
+ if ( '' === $slide_min_height ) {
1842
+ $slide_min_height = '50';
1843
+ }
1844
+ echo "<div style='padding:5px 0px 10px;'>\n";
1845
+ $tooltip = 'The minimum height of each slide. Can be set to a percentage of the slide width, or for image sliders set to a 4:3 or 16:9 aspect ratio.';
1846
+ echo "<div class='ca_style_setting_line' id='ca_style_min_height' style='padding-bottom:7px !important;'>";
1847
+ echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Min Height:</span><br/>";
1848
+ if ( 'aspect43' === $slide_min_height ) {
1849
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;'/><em>%</em>";
1850
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px'/><em>px</em>";
1851
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43' checked/><em>4:3</em>";
1852
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169'/><em>16:9</em>";
1853
+ } elseif ( 'aspect169' === $slide_min_height ) {
1854
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;'/><em>%</em>";
1855
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px'/><em>px</em>";
1856
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43'/><em>4:3</em>";
1857
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169' checked/><em>16:9</em>";
1858
+ } elseif ( strpos( $slide_min_height, 'px' ) !== false ) {
1859
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;'/><em>%</em>";
1860
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px' checked/><em>px</em>";
1861
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43'/><em>4:3</em>";
1862
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169'/><em>16:9</em>";
1863
+ } else {
1864
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='percent' style='margin-left:20px !important;' checked/><em>%</em>";
1865
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='px'/><em>px</em>";
1866
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='43'/><em>4:3</em>";
1867
+ echo "<input type='radio' name='sa_slide_min_height_type' class='sa_slide_min_height_type' value='169'/><em>16:9</em>";
1868
+ }
1869
+ echo "</div>\n";
1870
+ if ( ( 'aspect43' === $slide_min_height ) || ( 'aspect169' === $slide_min_height ) ) {
1871
+ $mh_suffix = '';
1872
+ echo "<div class='ca_style_setting_line' id='sa_slide_min_height_wrapper' style='display:none;'>";
1873
+ echo "<input type='text' id='sa_slide_min_height' name='sa_slide_min_height' value='" . esc_attr( $slide_min_height ) . "'/>";
1874
+ echo "<em id='mh_suffix'>" . esc_html( $mh_suffix ) . "</em></div>\n";
1875
+ echo "<input type='hidden' id='sa_slide_min_height_hidden' name='sa_slide_min_height_hidden' value='0'/>\n";
1876
+ } else {
1877
+ if ( strpos( $slide_min_height, 'px' ) !== false ) {
1878
+ $mh_value = str_replace( 'px', '', $slide_min_height );
1879
+ $mh_suffix = 'px';
1880
+ } else {
1881
+ $mh_value = $slide_min_height;
1882
+ $mh_suffix = '%';
1883
+ }
1884
+ echo "<div class='ca_style_setting_line' id='sa_slide_min_height_wrapper'><span style='width:20px;'>&nbsp;</span>";
1885
+ echo "<input type='text' id='sa_slide_min_height' name='sa_slide_min_height' value='" . esc_attr( $mh_value ) . "'/>";
1886
+ echo "<em id='mh_suffix'>" . esc_html( $mh_suffix ) . "</em></div>\n";
1887
+ echo "<input type='hidden' id='sa_slide_min_height_hidden' name='sa_slide_min_height_hidden' value='" . esc_attr( $mh_value ) . "'/>\n";
1888
+ }
1889
+ echo "</div>\n";
1890
+
1891
+ // SLIDE - PADDING TOP/BOTTOM.
1892
+ $slide_padding_tb = get_post_meta( $post->ID, 'sa_slide_padding_tb', true );
1893
+ if ( '' === $slide_padding_tb ) {
1894
+ $slide_padding_tb = '5';
1895
+ }
1896
+ $tooltip = 'Padding space top/bottom for each individual slide';
1897
+ echo "<div class='ca_style_setting_line' id='ca_style_padding_top_bottom'><span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Padding:</span>";
1898
+ echo "<input type='text' id='sa_slide_padding_tb' name='sa_slide_padding_tb' value='" . esc_attr( $slide_padding_tb ) . "'><em>%</em></div>\n";
1899
+
1900
+ // SLIDE - PADDING LEFT/RIGHT.
1901
+ $slide_padding_lr = get_post_meta( $post->ID, 'sa_slide_padding_lr', true );
1902
+ if ( '' === $slide_padding_lr ) {
1903
+ $slide_padding_lr = '5';
1904
+ }
1905
+ $tooltip = 'Padding space left/right for each individual slide';
1906
+ echo "<div class='ca_style_setting_line' id='ca_style_padding_left_right'><span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Padding:</span>";
1907
+ echo "<input type='text' id='sa_slide_padding_lr' name='sa_slide_padding_lr' value='" . esc_attr( $slide_padding_lr ) . "'><em>%</em></div>\n";
1908
+
1909
+ // SLIDE - MARGIN LEFT/RIGHT.
1910
+ $slide_margin_lr = get_post_meta( $post->ID, 'sa_slide_margin_lr', true );
1911
+ if ( '' === $slide_margin_lr ) {
1912
+ $slide_margin_lr = '0';
1913
+ }
1914
+ $tooltip = 'Margin space left and right of each slide';
1915
+ echo "<div class='ca_style_setting_line' id='ca_style_margin_left_right'><span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'>Margin:</span>";
1916
+ echo "<input type='text' id='sa_slide_margin_lr' name='sa_slide_margin_lr' value='" . esc_attr( $slide_margin_lr ) . "'><em>%</em></div>\n";
1917
+
1918
+ $tooltip = 'The link/popup buttons that appear on a slide';
1919
+ echo "<h4>Link/Popup Icons:<em class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></em></h4>";
1920
+
1921
+ // LINK/POPUP ICONS - ICON LOCATION.
1922
+ $slide_icons_location = get_post_meta( $post->ID, 'sa_slide_icons_location', true );
1923
+ if ( '' === $slide_icons_location ) {
1924
+ $slide_icons_location = 'Center Center';
1925
+ }
1926
+ echo "<div class='ca_style_setting_line'><span>Icon Location</span>";
1927
+ echo "<select id='sa_slide_icons_location' name='sa_slide_icons_location'>";
1928
+ $option_arr = array();
1929
+ $option_arr[0] = 'Center Center';
1930
+ $option_arr[1] = 'Top Left';
1931
+ $option_arr[2] = 'Top Center';
1932
+ $option_arr[3] = 'Top Right';
1933
+ $option_arr[4] = 'Bottom Left';
1934
+ $option_arr[5] = 'Bottom Center';
1935
+ $option_arr[6] = 'Bottom Right';
1936
+ $tot_opt = count( $option_arr );
1937
+ for ( $i = 0; $i < $tot_opt; $i++ ) {
1938
+ if ( $option_arr[ $i ] === $slide_icons_location ) {
1939
+ echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "' selected>" . esc_html( $option_arr[ $i ] ) . '</option>';
1940
+ } else {
1941
+ echo "<option value='" . esc_attr( $option_arr[ $i ] ) . "'>" . esc_html( $option_arr[ $i ] ) . '</option>';
1942
+ }
1943
+ }
1944
+ echo "</select></div>\n";
1945
+
1946
+ // LINK/POPUP ICONS - ALWAYS VISIBLE.
1947
+ $slide_icons_visible = get_post_meta( $post->ID, 'sa_slide_icons_visible', true );
1948
+ if ( '1' !== $slide_icons_visible ) {
1949
+ $slide_icons_visible = '0';
1950
+ }
1951
+ echo "<div class='ca_style_setting_line'><span>Always Visible</span>";
1952
+ if ( '1' === $slide_icons_visible ) {
1953
+ echo "<input type='checkbox' id='sa_slide_icons_visible' name='sa_slide_icons_visible' value='1' checked/>";
1954
+ } else {
1955
+ echo "<input type='checkbox' id='sa_slide_icons_visible' name='sa_slide_icons_visible' value='1'/>";
1956
+ }
1957
+ echo "</div>\n";
1958
+
1959
+ // LINK/POPUP ICONS - COLOR SCHEME.
1960
+ $slide_icons_color = get_post_meta( $post->ID, 'sa_slide_icons_color', true );
1961
+ if ( '' === $slide_icons_color ) {
1962
+ $slide_icons_location = 'white';
1963
+ }
1964
+ echo "<div class='ca_style_setting_line'><span>Color Scheme</span>";
1965
+ echo "<select id='sa_slide_icons_color' name='sa_slide_icons_color'>";
1966
+ if ( 'black' === $slide_icons_color ) {
1967
+ echo "<option value='white'>White</option>";
1968
+ echo "<option value='black' selected>Black</option>";
1969
+ } else {
1970
+ echo "<option value='white selected'>White</option>";
1971
+ echo "<option value='black'>Black</option>";
1972
+ }
1973
+ echo "</select></div>\n";
1974
+
1975
+ // LINK/POPUP ICONS - FULL SLIDE LINKS.
1976
+ $slide_icons_fullslide = get_post_meta( $post->ID, 'sa_slide_icons_fullslide', true );
1977
+ if ( '1' !== $slide_icons_fullslide ) {
1978
+ $slide_icons_fullslide = '0';
1979
+ }
1980
+ echo "<div class='ca_style_setting_line'><span>Full Slide Links</span>";
1981
+ if ( '1' === $slide_icons_fullslide ) {
1982
+ echo "<input type='checkbox' id='sa_slide_icons_fullslide' name='sa_slide_icons_fullslide' value='1' checked/>";
1983
+ } else {
1984
+ echo "<input type='checkbox' id='sa_slide_icons_fullslide' name='sa_slide_icons_fullslide' value='1'/>";
1985
+ }
1986
+ $tooltip = 'This makes the entire slide area a clickable link. NOTE: This feature is ';
1987
+ $tooltip .= 'disabled if you have both a slide link AND a popup link for a slide.';
1988
+ $tt_style = 'margin:0px 0px -3px 5px; cursor:help;';
1989
+ echo "<em class='sa_tooltip' style='" . esc_attr( $tt_style ) . "' title='" . esc_attr( $tooltip ) . "'></em>";
1990
+ echo "</div>\n";
1991
+
1992
+ // ##### OTHER SETTINGS #####
1993
+
1994
+ echo "<h4 style='margin-top:10px !important;'>Other Settings:</h4>";
1995
+
1996
+ // FETCH OTHER SETTINGS POST META.
1997
+ $other_settings = get_post_meta( $post->ID, 'sa_other_settings', true );
1998
+ if ( '' !== $other_settings ) {
1999
+ $other_settings_arr = explode( '|', $other_settings );
2000
+ }
2001
+ // setting 1 - sa_window_onload.
2002
+ if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[0] ) ) {
2003
+ $window_onload = $other_settings_arr[0];
2004
+ } else {
2005
+ $window_onload = get_post_meta( $post->ID, 'sa_window_onload', true );
2006
+ if ( '' === $window_onload ) {
2007
+ $window_onload = '0';
2008
+ }
2009
+ }
2010
+ // setting 2 - sa_strip_javascript.
2011
+ if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[1] ) ) {
2012
+ $strip_javascript = $other_settings_arr[1];
2013
+ } else {
2014
+ $strip_javascript = get_post_meta( $post->ID, 'sa_strip_javascript', true );
2015
+ if ( '' === $strip_javascript ) {
2016
+ $strip_javascript = '0';
2017
+ }
2018
+ }
2019
+ // setting 3 - sa_lazy_load_images.
2020
+ if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[2] ) ) {
2021
+ $lazy_load_images = $other_settings_arr[2];
2022
+ } else {
2023
+ $lazy_load_images = get_post_meta( $post->ID, 'sa_lazy_load_images', true );
2024
+ if ( '' === $lazy_load_images ) {
2025
+ $lazy_load_images = '0';
2026
+ }
2027
+ }
2028
+ // setting 4 - sa_ulli_containers.
2029
+ if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[3] ) ) {
2030
+ $ulli_containers = $other_settings_arr[3];
2031
+ } else {
2032
+ $ulli_containers = get_post_meta( $post->ID, 'sa_ulli_containers', true );
2033
+ if ( '' === $ulli_containers ) {
2034
+ $ulli_containers = '0';
2035
+ }
2036
+ }
2037
+ // setting 5 - sa_rtl_slider.
2038
+ if ( isset( $other_settings_arr ) && ( '' !== $other_settings_arr[4] ) ) {
2039
+ $rtl_slider = $other_settings_arr[4];
2040
+ } else {
2041
+ $rtl_slider = '0';
2042
+ }
2043
+ // setting 7 - bg_image_size.
2044
+ $bg_image_size = 'full';
2045
+ if ( isset( $other_settings_arr ) && ( count( $other_settings_arr ) > 6 ) ) {
2046
+ if ( '' !== $other_settings_arr[6] ) {
2047
+ $bg_image_size = $other_settings_arr[6];
2048
+ }
2049
+ }
2050
+ // setting 8 - sa_disable_slide_ids.
2051
+ if ( isset( $other_settings_arr ) && ( count( $other_settings_arr ) > 7 ) ) {
2052
+ $disable_slide_ids = $other_settings_arr[7];
2053
+ } else {
2054
+ $disable_slide_ids = '0';
2055
+ }
2056
+
2057
+ // USE 'DOMContentLoaded' EVENT (checkbox).
2058
+ $tooltip = 'Load the Slide Anything JavaScript during the DOMContentLoaded event. Use this option if jQuery ';
2059
+ $tooltip .= 'is loading in your theme footer and you are getting the JavaScript error message ';
2060
+ $tooltip .= '&quot;Uncaught ReferenceError: jQuery is not defined&quot;.';
2061
+ echo "<div class='sa_window_onload_line'>";
2062
+ echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>DOMContentLoaded event:</span>";
2063
+ if ( '1' === $window_onload ) {
2064
+ echo "<input type='checkbox' id='sa_window_onload' name='sa_window_onload' value='1' checked/>";
2065
+ } else {
2066
+ echo "<input type='checkbox' id='sa_window_onload' name='sa_window_onload' value='1'/>";
2067
+ }
2068
+ echo "</div>\n";
2069
+
2070
+ echo "<div style='display:none !important;'>";
2071
+ echo "<input type='checkbox' id='sa_lazy_load_images' name='sa_lazy_load_images' value='0'/>";
2072
+ echo "</div>\n";
2073
+
2074
+ // Use UL and LI Containers.
2075
+ $tooltip = 'Use &quot;UL&quot; as the DOM element for &quot;owl-stage&quot; and use &quot;LI&quot; as the DOM elements for &quot;owl-item&quot;.';
2076
+ echo "<div class='sa_window_onload_line'>";
2077
+ echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Use UL and LI Containers:</span>";
2078
+ if ( '1' === $ulli_containers ) {
2079
+ echo "<input type='checkbox' id='sa_ulli_containers' name='sa_ulli_containers' value='1' checked/>";
2080
+ } else {
2081
+ echo "<input type='checkbox' id='sa_ulli_containers' name='sa_ulli_containers' value='1'/>";
2082
+ }
2083
+ echo "</div>\n";
2084
+
2085
+ // Right to Left Slider.
2086
+ $tooltip = 'Change the direction of the slider to be right to left.';
2087
+ echo "<div class='sa_window_onload_line'>";
2088
+ echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Right to Left Slider:</span>";
2089
+ if ( '1' === $rtl_slider ) {
2090
+ echo "<input type='checkbox' id='sa_rtl_slider' name='sa_rtl_slider' value='1' checked/>";
2091
+ } else {
2092
+ echo "<input type='checkbox' id='sa_rtl_slider' name='sa_rtl_slider' value='1'/>";
2093
+ }
2094
+ echo "</div>\n";
2095
+
2096
+ // Don't use Slide IDs.
2097
+ $tooltip = 'Do not use a unique CSS ID to identify each slide container - use a unique CSS Class instead.';
2098
+ echo "<div class='sa_window_onload_line'>";
2099
+ echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Don't use CSS IDs for slides:</span>";
2100
+ if ( '1' === $disable_slide_ids ) {
2101
+ echo "<input type='checkbox' id='sa_disable_slide_ids' name='sa_disable_slide_ids' value='1' checked/>";
2102
+ } else {
2103
+ echo "<input type='checkbox' id='sa_disable_slide_ids' name='sa_disable_slide_ids' value='1'/>";
2104
+ }
2105
+ echo "</div>\n";
2106
+
2107
+ // Start Position.
2108
+ $num_slides = intval( get_post_meta( $post->ID, 'sa_num_slides', true ) );
2109
+ if ( '' === $num_slides ) {
2110
+ $start_pos = 1;
2111
+ } else {
2112
+ $start_pos = intval( get_post_meta( $post->ID, 'sa_start_pos', true ) );
2113
+ if ( '' === $start_pos ) {
2114
+ $start_pos = 1;
2115
+ }
2116
+ $tooltip = 'Which slide number to start display first';
2117
+ echo "<div class='sa_window_onload_line'>";
2118
+ echo "<span class='sa_tooltip' title='" . esc_attr( $tooltip ) . "'></span><span style='min-width:160px;'>Starting Slide Number:</span>";
2119
+ echo "<select name='sa_start_pos'>";
2120
+ for ( $i = 1; $i <= $num_slides; $i++ ) {
2121
+ if ( $i === $start_pos ) {
2122
+ echo "<option value='" . esc_attr( $i ) . "' selected>" . esc_html( $i ) . '</option>';
2123
+ } else {
2124
+ echo "<option value='" . esc_attr( $i ) . "'>" . esc_html( $i ) . '</option>';
2125
+ }
2126
+ }
2127
+ echo '</select>';
2128
+ echo "</div>\n";
2129
+ }
2130
+
2131
+ // SLIDE BACKGROUND IMAGE SIZE.
2132
+ global $_wp_additional_image_sizes;
2133
+ $image_size_arr = array();
2134
+ // get WordPress image size data and save into and array.
2135
+ $image_size_arr[0]['value'] = 'full';
2136
+ $image_size_arr[0]['desc'] = 'Full Size';
2137
+ $count = 1;
2138
+ foreach ( get_intermediate_image_sizes() as $image_size ) {
2139
+ if ( in_array( $image_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
2140
+ $width = get_option( "{$image_size}_size_w" );
2141
+ $height = get_option( "{$image_size}_size_h" );
2142
+ } elseif ( isset( $_wp_additional_image_sizes[ $image_size ] ) ) {
2143
+ $width = $_wp_additional_image_sizes[ $image_size ]['width'];
2144
+ $height = $_wp_additional_image_sizes[ $image_size ]['height'];
2145
+ }
2146
+ if ( ( 0 !== $width ) && ( 0 !== $height ) ) {
2147
+ $image_size_arr[ $count ]['value'] = $image_size;
2148
+ $image_size_arr[ $count ]['desc'] = $image_size . ' (' . $width . '&times;' . $height . ')';
2149
+ $count++;
2150
+ }
2151
+ }
2152
+ // display the dropdown input box allowing user to select background image size.
2153
+ $tooltip = 'Allows you to set the WordPress image size to use for your slide background images.';
2154
+ echo "<div class='bg_image_size_wrapper'>\n<div>\n";
2155
+ echo "<em class='sa_tooltip' href='' title='" . esc_attr( $tooltip ) . "'></em>";
2156
+ echo '<span>Background Image Size:</span>';
2157
+ echo "<div style='float:none; clear:both; width:100%; height:1px; padding:0px !important;'></div>\n</div>\n";
2158
+ echo "<select name='bg_image_size'>";
2159
+ $tot_size_arr = count( $image_size_arr );
2160
+ for ( $j = 0; $j < $tot_size_arr; $j++ ) {
2161
+ if ( $bg_image_size === $image_size_arr[ $j ]['value'] ) {
2162
+ echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "' selected>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
2163
+ } else {
2164
+ echo "<option value='" . esc_attr( $image_size_arr[ $j ]['value'] ) . "'>" . esc_html( $image_size_arr[ $j ]['desc'] ) . '</option>';
2165
+ }
2166
+ }
2167
+ echo "</select>\n";
2168
+ echo "</div>\n"; // .bg_image_size_wrapper
2169
+
2170
+ echo "</div>\n";
2171
+ }
2172
+
2173
+
2174
+
2175
+ /**
2176
+ * ##### META BOX CONTENT - 'Thumbnails (Pagination)' BOX #####
2177
+ *
2178
+ * @param array $post Custom Post 'sa_slider'.
2179
+ */
2180
+ function cpt_slider_thumbs_content( $post ) {
2181
+ // get WordPress image size data and save into and array.
2182
+ global $_wp_additional_image_sizes;
2183
+ $image_size_arr = array();
2184
+ $count = 0;
2185
+ foreach ( get_intermediate_image_sizes() as $image_size ) {
2186
+ if ( in_array( $image_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
2187
+ $width = get_option( "{$image_size}_size_w" );
2188
+ $height = get_option( "{$image_size}_size_h" );
2189
+ } elseif ( isset( $_wp_additional_image_sizes[ $image_size ] ) ) {
2190
+ $width = $_wp_additional_image_sizes[ $image_size ]['width'];
2191
+ $height = $_wp_additional_image_sizes[ $image_size ]['height'];
2192
+ }
2193
+ if ( ( 0 !== $width ) && ( 0 !== $height ) ) {
2194
+ $image_size_arr[ $count ]['value'] = $image_size;
2195
+ $image_size_arr[ $count ]['desc'] = $image_size . ' (' . $width . '&times;' . $height . ')';
2196
+ $count++;
2197
+ }
2198
+ }
2199
+
2200
+ // Use thumbnail pagination (checkbox).
2201
+ $thumbs_active = get_post_meta( $post->ID, 'sa_thumbs_active', true );
2202
+ if ( '' === $thumbs_active ) {
2203
+ $thumbs_active = '0';
2204
+ }
2205
+ echo "<div class='sa_thumbs_line'><span>Use Thumbnail Pagination:</span>";
2206
+ if ( '1' === $thumbs_active ) {
2207
+ echo "<input type='checkbox' id='sa_thumbs_active' name='sa_thumbs_active' value='1' checked/>";
2208
+ } else {
2209
+ echo "<input type='checkbox' id='sa_thumbs_active' name='sa_thumbs_active' value='1'/>";
2210
+ }
2211
+ echo "</div>\n";
2212
+
2213
+ if ( '1' === $thumbs_active ) {
2214
+ echo "<div id='sa_thumbs_settings' style='display:block;'>\n";
2215
+ } else {
2216
+ echo "<div id='sa_thumbs_settings' style='display:none;'>\n";
2217
+ }
2218
+
2219
+ // Thumbs Location (dropdown).
2220
+ $thumbs_location = get_post_meta( $post->ID, 'sa_thumbs_location', true );
2221
+ if ( '' === $thumbs_location ) {
2222
+ $thumbs_location = 'inside_bottom';
2223
+ }
2224
+ echo "<div class='sa_thumbs_line'><span>Thumbs Location:</span>";
2225
+ echo "<select id='sa_thumbs_location' name='sa_thumbs_location'>";
2226
+ $option_arr = array();
2227
+ $option_arr[0] = 'Inside Bottom';
2228
+ $option_arr[1] = 'Inside Top';
2229
+ $option_arr[2] = 'Inside Left';
2230
+ $option_arr[3] = 'Inside Right';
2231
+ $option_arr[4] = 'Outside Bottom';
2232
+ $tot_opt = count( $option_arr );
2233
+ for ( $i = 0; $i < $tot_opt; $i++ ) {
2234
+ $value = strtolower( str_replace( ' ', '_', $option_arr[ $i ] ) );
2235
+ if ( $value === $thumbs_location ) {
2236
+ echo "<option value='" . esc_attr( $value ) . "' selected>" . esc_html( $option_arr[ $i ] ) . '</option>';
2237
+ } else {
2238
+ echo "<option value='" . esc_attr( $value ) . "'>" . esc_html( $option_arr[ $i ] ) . '</option>';
2239
+ }
2240
+ }
2241
+ echo "</select></div>\n";
2242
+
2243
+ // Thumbnail Image Size (dropdown).
2244
+ $thumbs_image_size = get_post_meta( $post->ID, 'sa_thumbs_image_size', true );
2245
+ if ( '' === $thumbs_image_size ) {
2246
+ $thumbs_image_size = 'thumbnail';
2247
+ }
2248
+ echo "<div class='sa_thumbs_line'><span>Thumbnail Image Size:</span>";
2249
+ echo "<select id='sa_thumbs_image_size' name='sa_thumbs_image_size'>";
2250
+ $tot_img_arr = count( $image_size_arr );
2251
+ for ( $i = 0; $i < $tot_img_arr; $i++ ) {
2252
+ if ( $image_size_arr[ $i ]['value'] === $thumbs_image_size ) {
2253
+ echo "<option value='" . esc_attr( $image_size_arr[ $i ]['value'] ) . "' selected>" . esc_html( $image_size_arr[ $i ]['desc'] ) . '</option>';
2254
+ } else {
2255
+ echo "<option value='" . esc_attr( $image_size_arr[ $i ]['value'] ) . "'>" . esc_html( $image_size_arr[ $i ]['desc'] ) . '</option>';
2256
+ }
2257
+ }
2258
+ echo "</select></div>\n";
2259
+
2260
+ // Container Padding.
2261
+ $thumbs_padding = get_post_meta( $post->ID, 'sa_thumbs_padding', true );
2262
+ if ( '' === $thumbs_padding ) {
2263
+ $thumbs_padding = '3';
2264
+ }
2265
+ echo "<div class='sa_thumbs_line'><span>Container Padding:</span>";
2266
+ echo "<input type='text' id='sa_thumbs_padding' name='sa_thumbs_padding' value='" . esc_attr( $thumbs_padding ) . "'><em>%</em>";
2267
+ echo "</div>\n";
2268
+
2269
+ // Thumbs Width.
2270
+ $thumbs_width = get_post_meta( $post->ID, 'sa_thumbs_width', true );
2271
+ if ( '' === $thumbs_width ) {
2272
+ $thumbs_width = '150';
2273
+ }
2274
+ echo "<div class='sa_thumbs_line'><span>Thumbs Width:</span>";
2275
+ echo "<input type='text' id='sa_thumbs_width' name='sa_thumbs_width' value='" . esc_attr( $thumbs_width ) . "'><em>px</em>";
2276
+ echo "</div>\n";
2277
+
2278
+ // Thumbs Height.
2279
+ $thumbs_height = get_post_meta( $post->ID, 'sa_thumbs_height', true );
2280
+ if ( '' === $thumbs_height ) {
2281
+ $thumbs_height = '85';
2282
+ }
2283
+ echo "<div class='sa_thumbs_line'><span>Thumbs Height:</span>";
2284
+ echo "<input type='text' id='sa_thumbs_height' name='sa_thumbs_height' value='" . esc_attr( $thumbs_height ) . "'><em>px</em>";
2285
+ echo "</div>\n";
2286
+
2287
+ // Thumbs Opacity.
2288
+ $thumbs_opacity = get_post_meta( $post->ID, 'sa_thumbs_opacity', true );
2289
+ if ( '' === $thumbs_opacity ) {
2290
+ $thumbs_opacity = '50';
2291
+ }
2292
+ echo "<div class='sa_thumbs_line'><span>Thumbs Opacity:</span>";
2293
+ echo "<input type='text' id='sa_thumbs_opacity' name='sa_thumbs_opacity' value='" . esc_attr( $thumbs_opacity ) . "'><em>%</em>";
2294
+ echo "</div>\n";
2295
+
2296
+ echo '<h4>Active Thumb Border Style</h4>';
2297
+
2298
+ // Border Width.
2299
+ $thumbs_border_width = get_post_meta( $post->ID, 'sa_thumbs_border_width', true );
2300
+ if ( '' === $thumbs_border_width ) {
2301
+ $thumbs_border_width = '0';
2302
+ }
2303
+ echo "<div class='sa_thumbs_line'><span>Border Width:</span>";
2304
+ echo "<input type='text' id='sa_thumbs_border_width' name='sa_thumbs_border_width' value='" . esc_attr( $thumbs_border_width ) . "'><em>px</em>";
2305
+ echo "</div>\n";
2306
+
2307
+ // Border Color.
2308
+ $thumbs_border_color = get_post_meta( $post->ID, 'sa_thumbs_border_color', true );
2309
+ if ( '' === $thumbs_border_color ) {
2310
+ $thumbs_border_color = '#ffffff';
2311
+ }
2312
+ echo "<div class='sa_thumbs_line'><span>Border Color:</span>";
2313
+ echo "<input type='text' id='sa_thumbs_border_color' name='sa_thumbs_border_color' value='" . esc_attr( $thumbs_border_color ) . "'></div>\n";
2314
+
2315
+ echo '<h4>Responsive Thumb Sizes</h4>';
2316
+
2317
+ // Tablet Thumb Size.
2318
+ $thumbs_resp_tablet = get_post_meta( $post->ID, 'sa_thumbs_resp_tablet', true );
2319
+ if ( '' === $thumbs_resp_tablet ) {
2320
+ $thumbs_resp_tablet = '75';
2321
+ }
2322
+ echo "<div class='sa_thumbs_line'><span>Tablet Thumb Size:</span>";
2323
+ echo "<input type='text' id='sa_thumbs_resp_tablet' name='sa_thumbs_resp_tablet' value='" . esc_attr( $thumbs_resp_tablet ) . "'><em>%</em>";
2324
+ echo "</div>\n";
2325
+
2326
+ // Mobile Thumb Size.
2327
+ $thumbs_resp_mobile = get_post_meta( $post->ID, 'sa_thumbs_resp_mobile', true );
2328
+ if ( '' === $thumbs_resp_mobile ) {
2329
+ $thumbs_resp_mobile = '50';
2330
+ }
2331
+ echo "<div class='sa_thumbs_line'><span>Mobile Thumb Size:</span>";
2332
+ echo "<input type='text' id='sa_thumbs_resp_mobile' name='sa_thumbs_resp_mobile' value='" . esc_attr( $thumbs_resp_mobile ) . "'><em>%</em>";
2333
+ echo "</div>\n";
2334
+
2335
+ echo "</div>\n"; // #sa_thumbs_settings
2336
+ }
2337
+
2338
+
2339
+
2340
+ /**
2341
+ * // ##### ACTION HOOK - SAVE CUSTOM POST TYPE ('Slide Anything') DATA #####
2342
+ */
2343
+ function cpt_slider_save_postdata() {
2344
+ global $post;
2345
+
2346
+ // ### REMOVE XSS ATTACK VULNERABILITY FROM SLIDER POST TITLES ###
2347
+ global $wpdb;
2348
+ if ( isset( $post->ID ) && ( '' !== $post->ID ) ) {
2349
+ $post_title = get_the_title( $post->ID );
2350
+ $sanitize_title = sanitize_text_field( $post_title );
2351
+ $where = array( 'ID' => $post->ID );
2352
+ $wpdb->update( $wpdb->posts, array( 'post_title' => $sanitize_title ), $where ); // db call ok; no-cache ok.
2353
+ }
2354
+
2355
+ // ### VERIFY 1) LOGGED-IN USER IS ADMINISTRATOR AND 2) VALID NONCE TO PREVENT CSRF HACKER ATTACKS ###
2356
+ if ( current_user_can( 'edit_pages' ) &&
2357
+ isset( $_POST['nonce_save_slider'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce_save_slider'] ) ), basename( __FILE__ ) ) ) {
2358
+ if ( isset( $_POST['sa_num_slides'] ) ) {
2359
+ $total_slides = intval( $_POST['sa_num_slides'] );
2360
+ } else {
2361
+ $total_slides = 1;
2362
+ }
2363
+ if ( isset( $_POST['sa_duplicate_slide'] ) ) {
2364
+ if ( ( '' === $_POST['sa_duplicate_slide'] ) || ( '0' === $_POST['sa_duplicate_slide'] ) ) {
2365
+ $duplicate_slide = 0;
2366
+ } else {
2367
+ // A SLIDE NEEDS TO BE DUPLICATED.
2368
+ $duplicate_slide = intval( $_POST['sa_duplicate_slide'] );
2369
+ }
2370
+ } else {
2371
+ $duplicate_slide = 0;
2372
+ }
2373
+ if ( isset( $_POST['sa_move_slide_up'] ) ) {
2374
+ if ( ( '' === $_POST['sa_move_slide_up'] ) || ( '0' === $_POST['sa_move_slide_up'] ) ) {
2375
+ $move_slide_up = 0;
2376
+ } else {
2377
+ // A SLIDE NEEDS TO BE MOVED.
2378
+ $move_slide_up = intval( $_POST['sa_move_slide_up'] );
2379
+ }
2380
+ } else {
2381
+ $move_slide_up = 0;
2382
+ }
2383
+
2384
+ // UPDATE CONTENT FOR EACH SLIDE.
2385
+ $slides_saved = 0;
2386
+ for ( $i = 1; $i <= $total_slides; $i++ ) {
2387
+ $slide_edit_id = 'sa_slide' . $i . '_content';
2388
+ $slide_image_id = 'sa_slide' . $i . '_image_id';
2389
+ $slide_image_pos = 'sa_slide' . $i . '_image_pos';
2390
+ $slide_image_size = 'sa_slide' . $i . '_image_size';
2391
+ $slide_image_repeat = 'sa_slide' . $i . '_image_repeat';
2392
+ $slide_image_color = 'sa_slide' . $i . '_image_color';
2393
+ $slide_link_url = 'sa_slide' . $i . '_link_url';
2394
+ $slide_link_target = 'sa_slide' . $i . '_link_target';
2395
+ $slide_popup_type = 'sa_slide' . $i . '_popup_type';
2396
+ $slide_popup_imageid = 'sa_slide' . $i . '_popup_imageid';
2397
+ $slide_popup_imagetitle = 'sa_slide' . $i . '_popup_imagetitle';
2398
+ $slide_popup_video_id = 'sa_slide' . $i . '_popup_video_id';
2399
+ $slide_popup_video_type = 'sa_slide' . $i . '_popup_video_type';
2400
+ $slide_popup_background = 'sa_slide' . $i . '_popup_background';
2401
+ $slide_popup_html = 'sa_slide' . $i . '_popup_html';
2402
+ $slide_popup_shortcode = 'sa_slide' . $i . '_popup_shortcode';
2403
+ $slide_popup_bgcol = 'sa_slide' . $i . '_popup_bgcol';
2404
+ $slide_popup_width = 'sa_slide' . $i . '_popup_width';
2405
+ $slide_content = '';
2406
+ $slide_image_id_val = 0;
2407
+ $slide_image_pos_val = '';
2408
+ $slide_image_size_val = '';
2409
+ $slide_image_repeat_val = '';
2410
+ $slide_image_color_val = '';
2411
+ $slide_link_url_val = '';
2412
+ $slide_link_target_val = '';
2413
+ if ( isset( $_POST[ $slide_edit_id ] ) && ( '' !== $_POST[ $slide_edit_id ] ) ) {
2414
+ $slide_content = wp_kses_post( wp_unslash( $_POST[ $slide_edit_id ] ) );
2415
+ }
2416
+ if ( isset( $_POST[ $slide_image_id ] ) ) {
2417
+ $slide_image_id_val = abs( intval( $_POST[ $slide_image_id ] ) );
2418
+ }
2419
+ if ( isset( $_POST[ $slide_image_pos ] ) ) {
2420
+ $slide_image_pos_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_pos ] ) );
2421
+ }
2422
+ if ( isset( $_POST[ $slide_image_size ] ) ) {
2423
+ $slide_image_size_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_size ] ) );
2424
+ }
2425
+ if ( isset( $_POST[ $slide_image_repeat ] ) ) {
2426
+ $slide_image_repeat_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_repeat ] ) );
2427
+ }
2428
+ if ( isset( $_POST[ $slide_image_color ] ) ) {
2429
+ $slide_image_color_val = sanitize_text_field( wp_unslash( $_POST[ $slide_image_color ] ) );
2430
+ }
2431
+ if ( isset( $_POST[ $slide_link_url ] ) ) {
2432
+ $slide_link_url_val = sanitize_text_field( wp_unslash( $_POST[ $slide_link_url ] ) );
2433
+ }
2434
+ if ( isset( $_POST[ $slide_link_target ] ) ) {
2435
+ $slide_link_target_val = sanitize_text_field( wp_unslash( $_POST[ $slide_link_target ] ) );
2436
+ }
2437
+ $slide_popup_type_val = '';
2438
+ $slide_popup_imageid_val = 0;
2439
+ $slide_popup_imagetitle_val = '';
2440
+ $slide_popup_video_id_val = '';
2441
+ $slide_popup_video_type_val = '';
2442
+ $slide_popup_background_val = '';
2443
+ $slide_popup_html_val = '';
2444
+ $slide_popup_shortcode_val = '';
2445
+ $slide_popup_bgcol_val = '';
2446
+ $slide_popup_width_val = 0;
2447
+ if ( isset( $_POST[ $slide_popup_type ] ) ) {
2448
+ $slide_popup_type_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_type ] ) );
2449
+ }
2450
+ if ( isset( $_POST[ $slide_popup_imageid ] ) ) {
2451
+ $slide_popup_imageid_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_imageid ] ) );
2452
+ }
2453
+ if ( isset( $_POST[ $slide_popup_imagetitle ] ) ) {
2454
+ $slide_popup_imagetitle_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_imagetitle ] ) );
2455
+ }
2456
+ if ( isset( $_POST[ $slide_popup_video_id ] ) ) {
2457
+ $slide_popup_video_id_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_video_id ] ) );
2458
+ }
2459
+ if ( isset( $_POST[ $slide_popup_video_type ] ) ) {
2460
+ $slide_popup_video_type_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_video_type ] ) );
2461
+ }
2462
+ if ( isset( $_POST[ $slide_popup_background ] ) ) {
2463
+ $slide_popup_background_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_background ] ) );
2464
+ }
2465
+ if ( isset( $_POST[ $slide_popup_html ] ) ) {
2466
+ $slide_popup_html_val = balanceTags( wp_kses_post( wp_unslash( $_POST[ $slide_popup_html ] ) ), true );
2467
+ }
2468
+ if ( isset( $_POST[ $slide_popup_shortcode ] ) ) {
2469
+ $slide_popup_shortcode_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_shortcode ] ) );
2470
+ }
2471
+ if ( isset( $_POST[ $slide_popup_bgcol ] ) ) {
2472
+ $slide_popup_bgcol_val = sanitize_text_field( wp_unslash( $_POST[ $slide_popup_bgcol ] ) );
2473
+ }
2474
+ if ( isset( $_POST[ $slide_popup_width ] ) ) {
2475
+ $slide_popup_width_val = abs( intval( $_POST[ $slide_popup_width ] ) );
2476
+ }
2477
+ // check delete status for slide.
2478
+ $del_status_id = 'sa_slide' . $i . '_delete';
2479
+ if ( isset( $_POST[ $del_status_id ] ) && ( '' !== $_POST[ $del_status_id ] ) ) {
2480
+ $del_status = sanitize_text_field( wp_unslash( $_POST[ $del_status_id ] ) );
2481
+ } else {
2482
+ // a new slide has been added.
2483
+ $del_status = '1';
2484
+ $slide_content = '';
2485
+ }
2486
+ if ( '1' === $del_status ) {
2487
+ // save slide content only if slide has not been marked for deletion.
2488
+ $slides_saved++;
2489
+ $slide_edit_id_save = 'sa_slide' . $slides_saved . '_content';
2490
+ $slide_image_data_saved = 'sa_slide' . $slides_saved . '_image_data';
2491
+ $slide_link_url_saved = 'sa_slide' . $slides_saved . '_link_url';
2492
+ $slide_link_target_saved = 'sa_slide' . $slides_saved . '_link_target';
2493
+ $slide_popup_type_saved = 'sa_slide' . $slides_saved . '_popup_type';
2494
+ $slide_popup_imageid_saved = 'sa_slide' . $slides_saved . '_popup_imageid';
2495
+ $slide_popup_imagetitle_saved = 'sa_slide' . $slides_saved . '_popup_imagetitle';
2496
+ $slide_popup_video_id_saved = 'sa_slide' . $slides_saved . '_popup_video_id';
2497
+ $slide_popup_video_type_saved = 'sa_slide' . $slides_saved . '_popup_video_type';
2498
+ $slide_popup_background_saved = 'sa_slide' . $slides_saved . '_popup_background';
2499
+ $slide_popup_html_saved = 'sa_slide' . $slides_saved . '_popup_html';
2500
+ $slide_popup_shortcode_saved = 'sa_slide' . $slides_saved . '_popup_shortcode';
2501
+ $slide_popup_bgcol_saved = 'sa_slide' . $slides_saved . '_popup_bgcol';
2502
+ $slide_popup_width_saved = 'sa_slide' . $slides_saved . '_popup_width';
2503
+ update_post_meta( $post->ID, $slide_edit_id_save, $slide_content );
2504
+ $slide_image_data_val = $slide_image_id_val . '~' . $slide_image_pos_val . '~' . $slide_image_size_val . '~' . $slide_image_repeat_val . '~' . $slide_image_color_val;
2505
+ update_post_meta( $post->ID, $slide_image_data_saved, $slide_image_data_val );
2506
+ update_post_meta( $post->ID, $slide_link_url_saved, $slide_link_url_val );
2507
+ update_post_meta( $post->ID, $slide_link_target_saved, $slide_link_target_val );
2508
+ update_post_meta( $post->ID, $slide_popup_type_saved, $slide_popup_type_val );
2509
+ update_post_meta( $post->ID, $slide_popup_imageid_saved, $slide_popup_imageid_val );
2510
+ update_post_meta( $post->ID, $slide_popup_imagetitle_saved, $slide_popup_imagetitle_val );
2511
+ update_post_meta( $post->ID, $slide_popup_video_id_saved, $slide_popup_video_id_val );
2512
+ update_post_meta( $post->ID, $slide_popup_video_type_saved, $slide_popup_video_type_val );
2513
+ update_post_meta( $post->ID, $slide_popup_background_saved, $slide_popup_background_val );
2514
+ update_post_meta( $post->ID, $slide_popup_html_saved, $slide_popup_html_val );
2515
+ update_post_meta( $post->ID, $slide_popup_shortcode_saved, $slide_popup_shortcode_val );
2516
+ update_post_meta( $post->ID, $slide_popup_bgcol_saved, $slide_popup_bgcol_val );
2517
+ update_post_meta( $post->ID, $slide_popup_width_saved, $slide_popup_width_val );
2518
+ if ( $i === $duplicate_slide ) {
2519
+ // the 'duplicate slide' button has been click for this slide - create a new slide that is an exact copy of previous slide.
2520
+ $slides_saved++;
2521
+ $slide_edit_id_save = 'sa_slide' . $slides_saved . '_content';
2522
+ $slide_image_data_saved = 'sa_slide' . $slides_saved . '_image_data';
2523
+ $slide_link_url_saved = 'sa_slide' . $slides_saved . '_link_url';
2524
+ $slide_link_target_saved = 'sa_slide' . $slides_saved . '_link_target';
2525
+ $slide_popup_type_saved = 'sa_slide' . $slides_saved . '_popup_type';
2526
+ $slide_popup_imageid_saved = 'sa_slide' . $slides_saved . '_popup_imageid';
2527
+ $slide_popup_imagetitle_saved = 'sa_slide' . $slides_saved . '_popup_imagetitle';
2528
+ $slide_popup_video_id_saved = 'sa_slide' . $slides_saved . '_popup_video_id';
2529
+ $slide_popup_video_type_saved = 'sa_slide' . $slides_saved . '_popup_video_type';
2530
+ $slide_popup_background_saved = 'sa_slide' . $slides_saved . '_popup_background';
2531
+ $slide_popup_html_saved = 'sa_slide' . $slides_saved . '_popup_html';
2532
+ $slide_popup_shortcode_saved = 'sa_slide' . $slides_saved . '_popup_shortcode';
2533
+ $slide_popup_bgcol_saved = 'sa_slide' . $slides_saved . '_popup_bgcol';
2534
+ $slide_popup_width_saved = 'sa_slide' . $slides_saved . '_popup_width';
2535
+ update_post_meta( $post->ID, $slide_edit_id_save, $slide_content );
2536
+ $slide_image_data_val = $slide_image_id_val . '~' . $slide_image_pos_val . '~' . $slide_image_size_val . '~' . $slide_image_repeat_val . '~' . $slide_image_color_val;
2537
+ update_post_meta( $post->ID, $slide_image_data_saved, $slide_image_data_val );
2538
+ update_post_meta( $post->ID, $slide_link_url_saved, $slide_link_url_val );
2539
+ update_post_meta( $post->ID, $slide_link_target_saved, $slide_link_target_val );
2540
+ update_post_meta( $post->ID, $slide_popup_type_saved, $slide_popup_type_val );
2541
+ update_post_meta( $post->ID, $slide_popup_imageid_saved, $slide_popup_imageid_val );
2542
+ update_post_meta( $post->ID, $slide_popup_imagetitle_saved, $slide_popup_imagetitle_val );
2543
+ update_post_meta( $post->ID, $slide_popup_video_id_saved, $slide_popup_video_id_val );
2544
+ update_post_meta( $post->ID, $slide_popup_video_type_saved, $slide_popup_video_type_val );
2545
+ update_post_meta( $post->ID, $slide_popup_background_saved, $slide_popup_background_val );
2546
+ update_post_meta( $post->ID, $slide_popup_html_saved, $slide_popup_html_val );
2547
+ update_post_meta( $post->ID, $slide_popup_shortcode_saved, $slide_popup_shortcode_val );
2548
+ update_post_meta( $post->ID, $slide_popup_bgcol_saved, $slide_popup_bgcol_val );
2549
+ update_post_meta( $post->ID, $slide_popup_width_saved, $slide_popup_width_val );
2550
+ }
2551
+ }
2552
+ }
2553
+
2554
+ if ( 0 !== $move_slide_up ) {
2555
+ // A SLIDE NEEDS TO BE MOVED (TWO SLIDES ARE SWAPPED).
2556
+ $slide2 = $move_slide_up;
2557
+ $slide1 = intval( $move_slide_up ) - 1;
2558
+ $slide1_content = '';
2559
+ $slide1_image_id = 0;
2560
+ $slide1_image_pos = '';
2561
+ $slide1_image_size = '';
2562
+ $slide1_image_repeat = '';
2563
+ $slide1_image_color = '';
2564
+ $slide1_link_url = '';
2565
+ $slide1_link_target = '';
2566
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_content' ] ) ) {
2567
+ $slide1_content = balanceTags( sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_content' ] ) ), true );
2568
+ }
2569
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_id' ] ) ) {
2570
+ $slide1_image_id = abs( intval( $_POST[ 'sa_slide' . $slide1 . '_image_id' ] ) );
2571
+ }
2572
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_pos' ] ) ) {
2573
+ $slide1_image_pos = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_pos' ] ) );
2574
+ }
2575
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_size' ] ) ) {
2576
+ $slide1_image_size = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_size' ] ) );
2577
+ }
2578
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_repeat' ] ) ) {
2579
+ $slide1_image_repeat = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_repeat' ] ) );
2580
+ }
2581
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_image_color' ] ) ) {
2582
+ $slide1_image_color = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_image_color' ] ) );
2583
+ }
2584
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_link_url' ] ) ) {
2585
+ $slide1_link_url = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_link_url' ] ) );
2586
+ }
2587
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_link_target' ] ) ) {
2588
+ $slide1_link_target = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_link_target' ] ) );
2589
+ }
2590
+ $slide1_popup_type = '';
2591
+ $slide1_popup_imageid = '';
2592
+ $slide1_popup_imagetitle = '';
2593
+ $slide1_popup_video_id = '';
2594
+ $slide1_popup_video_type = '';
2595
+ $slide1_popup_background = '';
2596
+ $slide1_popup_html = '';
2597
+ $slide1_popup_shortcode = '';
2598
+ $slide1_popup_bgcol = '';
2599
+ $slide1_popup_width = 0;
2600
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_type' ] ) ) {
2601
+ $slide1_popup_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_type' ] ) );
2602
+ }
2603
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_imageid' ] ) ) {
2604
+ $slide1_popup_imageid = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_imageid' ] ) );
2605
+ }
2606
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_imagetitle' ] ) ) {
2607
+ $slide1_popup_imagetitle = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_imagetitle' ] ) );
2608
+ }
2609
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_video_id' ] ) ) {
2610
+ $slide1_popup_video_id = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_video_id' ] ) );
2611
+ }
2612
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_video_type' ] ) ) {
2613
+ $slide1_popup_video_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_video_type' ] ) );
2614
+ }
2615
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_background' ] ) ) {
2616
+ $slide1_popup_background = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_background' ] ) );
2617
+ }
2618
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_html' ] ) ) {
2619
+ $slide1_popup_html = balanceTags( wp_kses_post( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_html' ] ) ), true );
2620
+ }
2621
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_shortcode' ] ) ) {
2622
+ $slide1_popup_shortcode = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_shortcode' ] ) );
2623
+ }
2624
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_bgcol' ] ) ) {
2625
+ $slide1_popup_bgcol = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide1 . '_popup_bgcol' ] ) );
2626
+ }
2627
+ if ( isset( $_POST[ 'sa_slide' . $slide1 . '_popup_width' ] ) ) {
2628
+ $slide1_popup_width = abs( intval( $_POST[ 'sa_slide' . $slide1 . '_popup_width' ] ) );
2629
+ }
2630
+ $slide2_content = '';
2631
+ $slide2_image_id = 0;
2632
+ $slide2_image_pos = '';
2633
+ $slide2_image_size = '';
2634
+ $slide2_image_repeat = '';
2635
+ $slide2_image_color = '';
2636
+ $slide2_link_url = '';
2637
+ $slide2_link_target = '';
2638
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_content' ] ) ) {
2639
+ $slide2_content = balanceTags( sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_content' ] ) ), true );
2640
+ }
2641
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_id' ] ) ) {
2642
+ $slide2_image_id = abs( intval( $_POST[ 'sa_slide' . $slide2 . '_image_id' ] ) );
2643
+ }
2644
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_pos' ] ) ) {
2645
+ $slide2_image_pos = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_pos' ] ) );
2646
+ }
2647
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_size' ] ) ) {
2648
+ $slide2_image_size = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_size' ] ) );
2649
+ }
2650
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_repeat' ] ) ) {
2651
+ $slide2_image_repeat = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_repeat' ] ) );
2652
+ }
2653
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_image_color' ] ) ) {
2654
+ $slide2_image_color = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_image_color' ] ) );
2655
+ }
2656
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_link_url' ] ) ) {
2657
+ $slide2_link_url = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_link_url' ] ) );
2658
+ }
2659
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_link_target' ] ) ) {
2660
+ $slide2_link_target = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_link_target' ] ) );
2661
+ }
2662
+ $slide2_popup_type = '';
2663
+ $slide2_popup_imageid = '';
2664
+ $slide2_popup_imagetitle = '';
2665
+ $slide2_popup_video_id = '';
2666
+ $slide2_popup_video_type = '';
2667
+ $slide2_popup_background = '';
2668
+ $slide2_popup_html = '';
2669
+ $slide2_popup_shortcode = '';
2670
+ $slide2_popup_bgcol = '';
2671
+ $slide2_popup_width = 0;
2672
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_type' ] ) ) {
2673
+ $slide2_popup_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_type' ] ) );
2674
+ }
2675
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_imageid' ] ) ) {
2676
+ $slide2_popup_imageid = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_imageid' ] ) );
2677
+ }
2678
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_imagetitle' ] ) ) {
2679
+ $slide2_popup_imagetitle = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_imagetitle' ] ) );
2680
+ }
2681
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_video_id' ] ) ) {
2682
+ $slide2_popup_video_id = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_video_id' ] ) );
2683
+ }
2684
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_video_type' ] ) ) {
2685
+ $slide2_popup_video_type = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_video_type' ] ) );
2686
+ }
2687
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_background' ] ) ) {
2688
+ $slide2_popup_background = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_background' ] ) );
2689
+ }
2690
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_html' ] ) ) {
2691
+ $slide2_popup_html = balanceTags( wp_kses_post( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_html' ] ) ), true );
2692
+ }
2693
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_shortcode' ] ) ) {
2694
+ $slide2_popup_shortcode = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_shortcode' ] ) );
2695
+ }
2696
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_bgcol' ] ) ) {
2697
+ $slide2_popup_bgcol = sanitize_text_field( wp_unslash( $_POST[ 'sa_slide' . $slide2 . '_popup_bgcol' ] ) );
2698
+ }
2699
+ if ( isset( $_POST[ 'sa_slide' . $slide2 . '_popup_width' ] ) ) {
2700
+ $slide2_popup_width = abs( intval( $_POST[ 'sa_slide' . $slide2 . '_popup_width' ] ) );
2701
+ }
2702
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_content', $slide1_content );
2703
+ $slide1_image_data = $slide1_image_id . '~' . $slide1_image_pos . '~' . $slide1_image_size . '~' . $slide1_image_repeat . '~' . $slide1_image_color;
2704
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_image_data', $slide1_image_data );
2705
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_link_url', $slide1_link_url );
2706
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_link_target', $slide1_link_target );
2707
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_type', $slide1_popup_type );
2708
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_imageid', $slide1_popup_imageid );
2709
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_imagetitle', $slide1_popup_imagetitle );
2710
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_video_id', $slide1_popup_video_id );
2711
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_video_type', $slide1_popup_video_type );
2712
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_background', $slide1_popup_background );
2713
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_html', $slide1_popup_html );
2714
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_shortcode', $slide1_popup_shortcode );
2715
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_bgcol', $slide1_popup_bgcol );
2716
+ update_post_meta( $post->ID, 'sa_slide' . $slide2 . '_popup_width', $slide1_popup_width );
2717
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_content', $slide2_content );
2718
+ $slide2_image_data = $slide2_image_id . '~' . $slide2_image_pos . '~' . $slide2_image_size . '~' . $slide2_image_repeat . '~' . $slide2_image_color;
2719
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_image_data', $slide2_image_data );
2720
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_link_url', $slide2_link_url );
2721
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_link_target', $slide2_link_target );
2722
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_type', $slide2_popup_type );
2723
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_imageid', $slide2_popup_imageid );
2724
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_imagetitle', $slide2_popup_imagetitle );
2725
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_video_id', $slide2_popup_video_id );
2726
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_video_type', $slide2_popup_video_type );
2727
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_background', $slide2_popup_background );
2728
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_html', $slide2_popup_html );
2729
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_shortcode', $slide2_popup_shortcode );
2730
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_bgcol', $slide2_popup_bgcol );
2731
+ update_post_meta( $post->ID, 'sa_slide' . $slide1 . '_popup_width', $slide2_popup_width );
2732
+ }
2733
+
2734
+ // UPDATE SLIDE CONTENT CHARACTER COUNT.
2735
+ $total_slides = get_post_meta( $post->ID, 'sa_num_slides', true );
2736
+ for ( $i = 1; $i <= $total_slides; $i++ ) {
2737
+ $slide_content = get_post_meta( $post->ID, 'sa_slide' . $i . '_content', true );
2738
+ $char_count = strlen( $slide_content );
2739
+ update_post_meta( $post->ID, 'sa_slide' . $i . '_char_count', $char_count );
2740
+ }
2741
+
2742
+ // UPDATE SLIDER SETTINGS.
2743
+ update_post_meta( $post->ID, 'sa_num_slides', abs( intval( $slides_saved ) ) );
2744
+ if ( isset( $_POST['sa_disable_visual_editor'] ) && ( '1' === $_POST['sa_disable_visual_editor'] ) ) {
2745
+ update_post_meta( $post->ID, 'sa_disable_visual_editor', '1' );
2746
+ } else {
2747
+ update_post_meta( $post->ID, 'sa_disable_visual_editor', '0' );
2748
+ }
2749
+ if ( isset( $_POST['sa_info_added'] ) ) {
2750
+ update_post_meta( $post->ID, 'sa_info_added', abs( intval( $_POST['sa_info_added'] ) ) );
2751
+ }
2752
+ if ( isset( $_POST['sa_info_deleted'] ) ) {
2753
+ update_post_meta( $post->ID, 'sa_info_deleted', abs( intval( $_POST['sa_info_deleted'] ) ) );
2754
+ }
2755
+ if ( isset( $_POST['sa_duplicate_slide'] ) ) {
2756
+ update_post_meta( $post->ID, 'sa_duplicate_slide', abs( intval( $_POST['sa_duplicate_slide'] ) ) );
2757
+ }
2758
+ if ( isset( $_POST['sa_info_duplicated'] ) ) {
2759
+ update_post_meta( $post->ID, 'sa_info_duplicated', abs( intval( $_POST['sa_info_duplicated'] ) ) );
2760
+ }
2761
+ if ( isset( $_POST['sa_move_slide_up'] ) ) {
2762
+ update_post_meta( $post->ID, 'sa_move_slide_up', abs( intval( $_POST['sa_move_slide_up'] ) ) );
2763
+ }
2764
+ if ( isset( $_POST['sa_info_moved'] ) ) {
2765
+ update_post_meta( $post->ID, 'sa_info_moved', abs( intval( $_POST['sa_info_moved'] ) ) );
2766
+ }
2767
+ if ( isset( $_POST['sa_slide_duration'] ) ) {
2768
+ update_post_meta( $post->ID, 'sa_slide_duration', abs( floatval( $_POST['sa_slide_duration'] ) ) );
2769
+ }
2770
+ if ( isset( $_POST['sa_slide_transition'] ) ) {
2771
+ update_post_meta( $post->ID, 'sa_slide_transition', abs( floatval( $_POST['sa_slide_transition'] ) ) );
2772
+ }
2773
+ if ( isset( $_POST['sa_slide_by'] ) ) {
2774
+ update_post_meta( $post->ID, 'sa_slide_by', abs( floatval( $_POST['sa_slide_by'] ) ) );
2775
+ }
2776
+ if ( isset( $_POST['sa_loop_slider'] ) && ( '1' === $_POST['sa_loop_slider'] ) ) {
2777
+ update_post_meta( $post->ID, 'sa_loop_slider', '1' );
2778
+ } else {
2779
+ update_post_meta( $post->ID, 'sa_loop_slider', '0' );
2780
+ }
2781
+ if ( isset( $_POST['sa_stop_hover'] ) && ( '1' === $_POST['sa_stop_hover'] ) ) {
2782
+ update_post_meta( $post->ID, 'sa_stop_hover', '1' );
2783
+ } else {
2784
+ update_post_meta( $post->ID, 'sa_stop_hover', '0' );
2785
+ }
2786
+ if ( isset( $_POST['sa_nav_arrows'] ) && ( '1' === $_POST['sa_nav_arrows'] ) ) {
2787
+ update_post_meta( $post->ID, 'sa_nav_arrows', '1' );
2788
+ } else {
2789
+ update_post_meta( $post->ID, 'sa_nav_arrows', '0' );
2790
+ }
2791
+ if ( isset( $_POST['sa_pagination'] ) && ( '1' === $_POST['sa_pagination'] ) ) {
2792
+ update_post_meta( $post->ID, 'sa_pagination', '1' );
2793
+ } else {
2794
+ update_post_meta( $post->ID, 'sa_pagination', '0' );
2795
+ }
2796
+ if ( isset( $_POST['sa_random_order'] ) && ( '1' === $_POST['sa_random_order'] ) ) {
2797
+ update_post_meta( $post->ID, 'sa_random_order', '1' );
2798
+ } else {
2799
+ update_post_meta( $post->ID, 'sa_random_order', '0' );
2800
+ }
2801
+ if ( isset( $_POST['sa_reverse_order'] ) && ( '1' === $_POST['sa_reverse_order'] ) ) {
2802
+ update_post_meta( $post->ID, 'sa_reverse_order', '1' );
2803
+ } else {
2804
+ update_post_meta( $post->ID, 'sa_reverse_order', '0' );
2805
+ }
2806
+ if ( isset( $_POST['sa_shortcodes'] ) && ( '1' === $_POST['sa_shortcodes'] ) ) {
2807
+ update_post_meta( $post->ID, 'sa_shortcodes', '1' );
2808
+ } else {
2809
+ update_post_meta( $post->ID, 'sa_shortcodes', '0' );
2810
+ }
2811
+ if ( isset( $_POST['sa_mouse_drag'] ) && ( '1' === $_POST['sa_mouse_drag'] ) ) {
2812
+ update_post_meta( $post->ID, 'sa_mouse_drag', '1' );
2813
+ } else {
2814
+ update_post_meta( $post->ID, 'sa_mouse_drag', '0' );
2815
+ }
2816
+ if ( isset( $_POST['sa_touch_drag'] ) && ( '1' === $_POST['sa_touch_drag'] ) ) {
2817
+ update_post_meta( $post->ID, 'sa_touch_drag', '1' );
2818
+ } else {
2819
+ update_post_meta( $post->ID, 'sa_touch_drag', '0' );
2820
+ }
2821
+ if ( isset( $_POST['sa_mousewheel'] ) && ( '1' === $_POST['sa_mousewheel'] ) ) {
2822
+ update_post_meta( $post->ID, 'sa_mousewheel', '1' );
2823
+ } else {
2824
+ update_post_meta( $post->ID, 'sa_mousewheel', '0' );
2825
+ }
2826
+ if ( isset( $_POST['sa_click_advance'] ) && ( '1' === $_POST['sa_click_advance'] ) ) {
2827
+ update_post_meta( $post->ID, 'sa_click_advance', '1' );
2828
+ } else {
2829
+ update_post_meta( $post->ID, 'sa_click_advance', '0' );
2830
+ }
2831
+ if ( isset( $_POST['sa_auto_height'] ) && ( '1' === $_POST['sa_auto_height'] ) ) {
2832
+ update_post_meta( $post->ID, 'sa_auto_height', '1' );
2833
+ } else {
2834
+ update_post_meta( $post->ID, 'sa_auto_height', '0' );
2835
+ }
2836
+ if ( isset( $_POST['sa_vert_center'] ) && ( '1' === $_POST['sa_vert_center'] ) ) {
2837
+ update_post_meta( $post->ID, 'sa_vert_center', '1' );
2838
+ } else {
2839
+ update_post_meta( $post->ID, 'sa_vert_center', '0' );
2840
+ }
2841
+
2842
+ // UPDATE SLIDER ITEMS DISPLAYED.
2843
+ if ( isset( $_POST['sa_items_width1'] ) ) {
2844
+ update_post_meta( $post->ID, 'sa_items_width1', abs( intval( $_POST['sa_items_width1'] ) ) );
2845
+ }
2846
+ if ( isset( $_POST['sa_items_width2'] ) ) {
2847
+ update_post_meta( $post->ID, 'sa_items_width2', abs( intval( $_POST['sa_items_width2'] ) ) );
2848
+ }
2849
+ if ( isset( $_POST['sa_items_width3'] ) ) {
2850
+ update_post_meta( $post->ID, 'sa_items_width3', abs( intval( $_POST['sa_items_width3'] ) ) );
2851
+ }
2852
+ if ( isset( $_POST['sa_items_width4'] ) ) {
2853
+ update_post_meta( $post->ID, 'sa_items_width4', abs( intval( $_POST['sa_items_width4'] ) ) );
2854
+ }
2855
+ if ( isset( $_POST['sa_items_width5'] ) ) {
2856
+ update_post_meta( $post->ID, 'sa_items_width5', abs( intval( $_POST['sa_items_width5'] ) ) );
2857
+ }
2858
+ if ( isset( $_POST['sa_items_width6'] ) ) {
2859
+ update_post_meta( $post->ID, 'sa_items_width6', abs( intval( $_POST['sa_items_width6'] ) ) );
2860
+ }
2861
+ if ( isset( $_POST['sa_transition'] ) ) {
2862
+ update_post_meta( $post->ID, 'sa_transition', sanitize_text_field( wp_unslash( $_POST['sa_transition'] ) ) );
2863
+ }
2864
+ if ( isset( $_POST['sa_hero_slider'] ) && ( '1' === $_POST['sa_hero_slider'] ) ) {
2865
+ update_post_meta( $post->ID, 'sa_hero_slider', '1' );
2866
+ } else {
2867
+ update_post_meta( $post->ID, 'sa_hero_slider', '0' );
2868
+ }
2869
+ if ( isset( $_POST['sa_showcase_slider'] ) && ( '1' === $_POST['sa_showcase_slider'] ) ) {
2870
+ update_post_meta( $post->ID, 'sa_showcase_slider', '1' );
2871
+ } else {
2872
+ update_post_meta( $post->ID, 'sa_showcase_slider', '0' );
2873
+ }
2874
+ if ( isset( $_POST['sa_showcase_width'] ) ) {
2875
+ update_post_meta( $post->ID, 'sa_showcase_width', abs( intval( $_POST['sa_showcase_width'] ) ) );
2876
+ }
2877
+ if ( isset( $_POST['sa_showcase_tablet'] ) && ( '1' === $_POST['sa_showcase_tablet'] ) ) {
2878
+ update_post_meta( $post->ID, 'sa_showcase_tablet', '1' );
2879
+ } else {
2880
+ update_post_meta( $post->ID, 'sa_showcase_tablet', '0' );
2881
+ }
2882
+ if ( isset( $_POST['sa_showcase_width_tab'] ) ) {
2883
+ update_post_meta( $post->ID, 'sa_showcase_width_tab', abs( intval( $_POST['sa_showcase_width_tab'] ) ) );
2884
+ }
2885
+ if ( isset( $_POST['sa_showcase_mobile'] ) && ( '1' === $_POST['sa_showcase_mobile'] ) ) {
2886
+ update_post_meta( $post->ID, 'sa_showcase_mobile', '1' );
2887
+ } else {
2888
+ update_post_meta( $post->ID, 'sa_showcase_mobile', '0' );
2889
+ }
2890
+ if ( isset( $_POST['sa_showcase_width_mob'] ) ) {
2891
+ update_post_meta( $post->ID, 'sa_showcase_width_mob', abs( intval( $_POST['sa_showcase_width_mob'] ) ) );
2892
+ }
2893
+
2894
+ // UPDATE SLIDER STYLE.
2895
+ if ( isset( $_POST['sa_css_id'] ) ) {
2896
+ $post_css_id = str_replace( '-', '_', sanitize_text_field( wp_unslash( $_POST['sa_css_id'] ) ) );
2897
+ update_post_meta( $post->ID, 'sa_css_id', sanitize_text_field( $post_css_id ) );
2898
+ }
2899
+ if ( isset( $_POST['sa_background_color'] ) ) {
2900
+ update_post_meta( $post->ID, 'sa_background_color', sanitize_text_field( wp_unslash( $_POST['sa_background_color'] ) ) );
2901
+ }
2902
+ if ( isset( $_POST['sa_border_width'] ) ) {
2903
+ update_post_meta( $post->ID, 'sa_border_width', abs( intval( $_POST['sa_border_width'] ) ) );
2904
+ }
2905
+ if ( isset( $_POST['sa_border_color'] ) ) {
2906
+ update_post_meta( $post->ID, 'sa_border_color', sanitize_text_field( wp_unslash( $_POST['sa_border_color'] ) ) );
2907
+ }
2908
+ if ( isset( $_POST['sa_border_radius'] ) ) {
2909
+ update_post_meta( $post->ID, 'sa_border_radius', abs( intval( $_POST['sa_border_radius'] ) ) );
2910
+ }
2911
+ if ( isset( $_POST['sa_wrapper_padd_top'] ) ) {
2912
+ update_post_meta( $post->ID, 'sa_wrapper_padd_top', abs( intval( $_POST['sa_wrapper_padd_top'] ) ) );
2913
+ }
2914
+ if ( isset( $_POST['sa_wrapper_padd_right'] ) ) {
2915
+ update_post_meta( $post->ID, 'sa_wrapper_padd_right', abs( intval( $_POST['sa_wrapper_padd_right'] ) ) );
2916
+ }
2917
+ if ( isset( $_POST['sa_wrapper_padd_bottom'] ) ) {
2918
+ update_post_meta( $post->ID, 'sa_wrapper_padd_bottom', abs( intval( $_POST['sa_wrapper_padd_bottom'] ) ) );
2919
+ }
2920
+ if ( isset( $_POST['sa_wrapper_padd_left'] ) ) {
2921
+ update_post_meta( $post->ID, 'sa_wrapper_padd_left', abs( intval( $_POST['sa_wrapper_padd_left'] ) ) );
2922
+ }
2923
+ if ( isset( $_POST['sa_slide_min_height_type'] ) && isset( $_POST['sa_slide_min_height'] ) ) {
2924
+ if ( 'px' === $_POST['sa_slide_min_height_type'] ) {
2925
+ update_post_meta( $post->ID, 'sa_slide_min_height_perc', sanitize_text_field( wp_unslash( $_POST['sa_slide_min_height'] ) ) . 'px' );
2926
+ } else {
2927
+ update_post_meta( $post->ID, 'sa_slide_min_height_perc', sanitize_text_field( wp_unslash( $_POST['sa_slide_min_height'] ) ) );
2928
+ }
2929
+ }
2930
+ if ( isset( $_POST['sa_slide_padding_tb'] ) ) {
2931
+ update_post_meta( $post->ID, 'sa_slide_padding_tb', abs( floatval( $_POST['sa_slide_padding_tb'] ) ) );
2932
+ }
2933
+ if ( isset( $_POST['sa_slide_padding_lr'] ) ) {
2934
+ update_post_meta( $post->ID, 'sa_slide_padding_lr', abs( floatval( $_POST['sa_slide_padding_lr'] ) ) );
2935
+ }
2936
+ if ( isset( $_POST['sa_slide_margin_lr'] ) ) {
2937
+ update_post_meta( $post->ID, 'sa_slide_margin_lr', abs( floatval( $_POST['sa_slide_margin_lr'] ) ) );
2938
+ }
2939
+ if ( isset( $_POST['sa_slide_icons_location'] ) ) {
2940
+ update_post_meta( $post->ID, 'sa_slide_icons_location', sanitize_text_field( wp_unslash( $_POST['sa_slide_icons_location'] ) ) );
2941
+ }
2942
+ if ( isset( $_POST['sa_slide_icons_color'] ) ) {
2943
+ update_post_meta( $post->ID, 'sa_slide_icons_color', sanitize_text_field( wp_unslash( $_POST['sa_slide_icons_color'] ) ) );
2944
+ }
2945
+ if ( isset( $_POST['sa_autohide_arrows'] ) && ( '1' === $_POST['sa_autohide_arrows'] ) ) {
2946
+ update_post_meta( $post->ID, 'sa_autohide_arrows', '1' );
2947
+ } else {
2948
+ update_post_meta( $post->ID, 'sa_autohide_arrows', '0' );
2949
+ }
2950
+ if ( isset( $_POST['sa_dot_per_slide'] ) && ( '1' === $_POST['sa_dot_per_slide'] ) ) {
2951
+ update_post_meta( $post->ID, 'sa_dot_per_slide', '1' );
2952
+ } else {
2953
+ update_post_meta( $post->ID, 'sa_dot_per_slide', '0' );
2954
+ }
2955
+ if ( isset( $_POST['sa_slide_icons_visible'] ) && ( '1' === $_POST['sa_slide_icons_visible'] ) ) {
2956
+ update_post_meta( $post->ID, 'sa_slide_icons_visible', '1' );
2957
+ } else {
2958
+ update_post_meta( $post->ID, 'sa_slide_icons_visible', '0' );
2959
+ }
2960
+ if ( isset( $_POST['sa_slide_icons_fullslide'] ) && ( '1' === $_POST['sa_slide_icons_fullslide'] ) ) {
2961
+ update_post_meta( $post->ID, 'sa_slide_icons_fullslide', '1' );
2962
+ } else {
2963
+ update_post_meta( $post->ID, 'sa_slide_icons_fullslide', '0' );
2964
+ }
2965
+
2966
+ // OTHER SETTINGS.
2967
+ $other_settings = '';
2968
+ if ( isset( $_POST['sa_window_onload'] ) && ( '1' === $_POST['sa_window_onload'] ) ) {
2969
+ $other_settings .= '1';
2970
+ } else {
2971
+ $other_settings .= '0';
2972
+ }
2973
+ $_POST['sa_strip_javascript'] = 0;
2974
+ if ( isset( $_POST['sa_strip_javascript'] ) && ( '1' === $_POST['sa_strip_javascript'] ) ) {
2975
+ $other_settings .= '|1';
2976
+ } else {
2977
+ $other_settings .= '|0';
2978
+ }
2979
+ if ( isset( $_POST['sa_lazy_load_images'] ) && ( '1' === $_POST['sa_lazy_load_images'] ) ) {
2980
+ $other_settings .= '|1';
2981
+ } else {
2982
+ $other_settings .= '|0';
2983
+ }
2984
+ if ( isset( $_POST['sa_ulli_containers'] ) && ( '1' === $_POST['sa_ulli_containers'] ) ) {
2985
+ $other_settings .= '|1';
2986
+ } else {
2987
+ $other_settings .= '|0';
2988
+ }
2989
+ if ( isset( $_POST['sa_rtl_slider'] ) && ( '1' === $_POST['sa_rtl_slider'] ) ) {
2990
+ $other_settings .= '|1';
2991
+ } else {
2992
+ $other_settings .= '|0';
2993
+ }
2994
+ // disable preview setting (now removed & permanently disabled).
2995
+ $other_settings .= '|1';
2996
+ if ( isset( $_POST['bg_image_size'] ) && ( '' !== $_POST['bg_image_size'] ) ) {
2997
+ $other_settings .= '|' . sanitize_text_field( wp_unslash( $_POST['bg_image_size'] ) );
2998
+ } else {
2999
+ $other_settings .= '|full';
3000
+ }
3001
+ if ( isset( $_POST['sa_disable_slide_ids'] ) && ( '1' === $_POST['sa_disable_slide_ids'] ) ) {
3002
+ $other_settings .= '|1';
3003
+ } else {
3004
+ $other_settings .= '|0';
3005
+ }
3006
+ update_post_meta( $post->ID, 'sa_other_settings', $other_settings );
3007
+ // starting slide number.
3008
+ if ( isset( $_POST['sa_start_pos'] ) ) {
3009
+ update_post_meta( $post->ID, 'sa_start_pos', abs( intval( $_POST['sa_start_pos'] ) ) );
3010
+ }
3011
+
3012
+ // THUMBNAIL PAGINATION.
3013
+ if ( isset( $_POST['sa_thumbs_active'] ) && ( '1' === $_POST['sa_thumbs_active'] ) ) {
3014
+ update_post_meta( $post->ID, 'sa_thumbs_active', '1' );
3015
+ } else {
3016
+ update_post_meta( $post->ID, 'sa_thumbs_active', '0' );
3017
+ }
3018
+ if ( isset( $_POST['sa_thumbs_location'] ) ) {
3019
+ update_post_meta( $post->ID, 'sa_thumbs_location', sanitize_text_field( wp_unslash( $_POST['sa_thumbs_location'] ) ) );
3020
+ }
3021
+ if ( isset( $_POST['sa_thumbs_image_size'] ) ) {
3022
+ update_post_meta( $post->ID, 'sa_thumbs_image_size', sanitize_text_field( wp_unslash( $_POST['sa_thumbs_image_size'] ) ) );
3023
+ }
3024
+ if ( isset( $_POST['sa_thumbs_padding'] ) ) {
3025
+ update_post_meta( $post->ID, 'sa_thumbs_padding', abs( floatval( $_POST['sa_thumbs_padding'] ) ) );
3026
+ }
3027
+ if ( isset( $_POST['sa_thumbs_width'] ) ) {
3028
+ update_post_meta( $post->ID, 'sa_thumbs_width', abs( intval( $_POST['sa_thumbs_width'] ) ) );
3029
+ }
3030
+ if ( isset( $_POST['sa_thumbs_height'] ) ) {
3031
+ update_post_meta( $post->ID, 'sa_thumbs_height', abs( intval( $_POST['sa_thumbs_height'] ) ) );
3032
+ }
3033
+ if ( isset( $_POST['sa_thumbs_opacity'] ) ) {
3034
+ update_post_meta( $post->ID, 'sa_thumbs_opacity', abs( intval( $_POST['sa_thumbs_opacity'] ) ) );
3035
+ }
3036
+ if ( isset( $_POST['sa_thumbs_border_width'] ) ) {
3037
+ update_post_meta( $post->ID, 'sa_thumbs_border_width', abs( intval( $_POST['sa_thumbs_border_width'] ) ) );
3038
+ }
3039
+ if ( isset( $_POST['sa_thumbs_border_color'] ) ) {
3040
+ update_post_meta( $post->ID, 'sa_thumbs_border_color', sanitize_text_field( wp_unslash( $_POST['sa_thumbs_border_color'] ) ) );
3041
+ }
3042
+ if ( isset( $_POST['sa_thumbs_resp_tablet'] ) ) {
3043
+ update_post_meta( $post->ID, 'sa_thumbs_resp_tablet', abs( intval( $_POST['sa_thumbs_resp_tablet'] ) ) );
3044
+ }
3045
+ if ( isset( $_POST['sa_thumbs_resp_mobile'] ) ) {
3046
+ update_post_meta( $post->ID, 'sa_thumbs_resp_mobile', abs( intval( $_POST['sa_thumbs_resp_mobile'] ) ) );
3047
+ }
3048
+ }
3049
+ }
3050
+
3051
+
3052
+
3053
+ /**
3054
+ * ###################################################################################
3055
+ * ### FUNCTION DISPLAYS THE 'RE-ORDER SLIDES' SUB-PAGE IN THE WordPress DASHBOARD ###
3056
+ * ###################################################################################
3057
+ */
3058
+ function cpt_slider_extra_sa_menu_pages() {
3059
+ add_submenu_page(
3060
+ 'edit.php?post_type=sa_slider',
3061
+ __( 'Re-Order Slides', 'menu-sa-order' ),
3062
+ __( 'Re-Order Slides', 'menu-sa-order' ),
3063
+ 'manage_options',
3064
+ 'reorderslides',
3065
+ 'cpt_slider_sa_reorder_slides_page'
3066
+ );
3067
+ }
3068
+
3069
+ /**
3070
+ * ### FUNCTION CONTAINING THE 'RE-ORDER' SLIDES FUNCTIONALITY ###
3071
+ */
3072
+ function cpt_slider_sa_reorder_slides_page() {
3073
+ $page_url = get_admin_url() . 'edit.php?post_type=sa_slider&page=reorderslides';
3074
+ $placeholder_image = get_site_url() . '/wp-content/plugins/slide-anything/images/bg_placeholder.png';
3075
+
3076
+ echo "<div id='sa_reorder_slides'>\n";
3077
+ echo '<h1>Slide Anything - Re-Order Slides</h1>';
3078
+
3079
+ if ( isset( $_SERVER['REQUEST_METHOD'] ) && ( 'POST' === $_SERVER['REQUEST_METHOD'] )
3080
+ && isset( $_POST['reorder_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['reorder_nonce'] ) ), 'reorder_action' ) ) {
3081
+ // A POST VARIABLE FOR 'SLIDER ID' HAS BEEN PASSED.
3082
+ if ( isset( $_POST['sar_slider_id'] ) ) {
3083
+ $slider_id = sanitize_text_field( wp_unslash( $_POST['sar_slider_id'] ) );
3084
+ $slider_title = get_the_title( $slider_id );
3085
+ } else {
3086
+ exit();
3087
+ }
3088
+
3089
+ if ( isset( $_POST['sar_sort_order'] ) && ( '' !== $_POST['sar_sort_order'] ) ) {
3090
+ // CHANGE THE ORDER OF SLIDE DATA FOR THE SLIDER AND RE-SAVE METADATA.
3091
+ $sort_order = sanitize_text_field( wp_unslash( $_POST['sar_sort_order'] ) );
3092
+ $data_in_arr = array();
3093
+ $data_out_arr = array();
3094
+
3095
+ // 1) SAVE SLIDES METADATA TO AN 'IN' ARRAY (ONLY SLIDES MEATDATA AND NO SETTINGS DATA SAVED!).
3096
+ $metadata = get_metadata( 'post', $slider_id );
3097
+ $num_slides = $metadata['sa_num_slides'][0];
3098
+ foreach ( $metadata as $key => $value_arr ) {
3099
+ $value = $value_arr[0];
3100
+ for ( $i = 1; $i <= $num_slides; $i++ ) {
3101
+ $key_prefix = 'sa_slide' . $i . '_';
3102
+ if ( strpos( $key, $key_prefix ) === 0 ) {
3103
+ // metadata key starts with the key prefix ('sa_slide??').
3104
+ $data_in_arr[ $key ] = $value;
3105
+ }
3106
+ }
3107
+ }
3108
+
3109
+ // 2) CREATE THE NEW SLIDES 'OUT' ARRAY (WITH THE NEW SLIDE ORDER).
3110
+ $sort_order_arr = explode( ',', $sort_order );
3111
+ $count_order_arr = count( $sort_order_arr );
3112
+ for ( $i = 0; $i < $count_order_arr; $i++ ) {
3113
+ $loop_prefix = 'sa_slide' . ( $i + 1 ) . '_'; // ascending loop order (1, 2, 3...).
3114
+ $order_prefix = 'sa_slide' . $sort_order_arr[ $i ] . '_'; // slide number to be stored in this slot.
3115
+ foreach ( $data_in_arr as $key => $value ) {
3116
+ if ( strpos( $key, $order_prefix ) === 0 ) {
3117
+ // metakey key value starts with the order prefix.
3118
+ $new_key = str_replace( $order_prefix, $loop_prefix, $key );
3119
+ $data_out_arr[ $new_key ] = $value;
3120
+ }
3121
+ }
3122
+ }
3123
+
3124
+ // 3) LOOP THROUGH SLIDES 'OUT' ARRAY UPDATING POST METADATA.
3125
+ foreach ( $data_out_arr as $key => $value ) {
3126
+ update_post_meta( $slider_id, $key, $value );
3127
+ }
3128
+
3129
+ echo "<h3 id='sar_success_message'>SLIDE ORDER HAS BEEN UPDATED</h3>";
3130
+ } else {
3131
+ if ( isset( $_POST['sar_del_slides'] ) && ( '' !== $_POST['sar_del_slides'] ) ) {
3132
+ // DELETE ALL SLIDES WITH THE 'DELETE SLIDE' CHECKBOX CHECKED.
3133
+ $del_slides = sanitize_text_field( wp_unslash( $_POST['sar_del_slides'] ) );
3134
+ $del_slides_arr = explode( ',', $del_slides );
3135
+ $data_in_arr = array();
3136
+ $data_out_arr = array();
3137
+
3138
+ // 1) SAVE SLIDES METADATA TO AN 'IN' ARRAY (ONLY SLIDES MEATDATA AND NO SETTINGS DATA SAVED!).
3139
+ $metadata = get_metadata( 'post', $slider_id );
3140
+ $num_slides = $metadata['sa_num_slides'][0];
3141
+ foreach ( $metadata as $key => $value_arr ) {
3142
+ $value = $value_arr[0];
3143
+ for ( $i = 1; $i <= $num_slides; $i++ ) {
3144
+ $key_prefix = 'sa_slide' . $i . '_';
3145
+ if ( strpos( $key, $key_prefix ) === 0 ) {
3146
+ // metadata key starts with the key prefix ('sa_slide??').
3147
+ $data_in_arr[ $i ][ $key ] = $value;
3148
+ }
3149
+ }
3150
+ }
3151
+
3152
+ // 2) CREATE THE NEW SLIDES 'OUT' ARRAY (WITH THE DELETED SLIDES REMOVED)
3153
+ $curr_index = 0;
3154
+ $tot_del = 0;
3155
+ for ( $i = 1; $i <= $num_slides; $i++ ) {
3156
+ $loop_prefix = 'sa_slide' . $i . '_';
3157
+ $delete_yn = 0;
3158
+ $count_del_arr = count( $del_slides_arr );
3159
+ for ( $j = 0; $j < $count_del_arr; $j++ ) {
3160
+ if ( $i === $del_slides_arr[ $j ] ) {
3161
+ $delete_yn = 1;
3162
+ }
3163
+ }
3164
+ if ( 0 === $delete_yn ) {
3165
+ // current slide is NOT to be deleted - copy to 'out' array.
3166
+ $curr_index++;
3167
+ $curr_prefix = 'sa_slide' . $curr_index . '_';
3168
+ foreach ( $data_in_arr[ $i ] as $key => $value ) {
3169
+ $new_key = str_replace( $loop_prefix, $curr_prefix, $key );
3170
+ $data_out_arr[ $new_key ] = $value;
3171
+ }
3172
+ } else {
3173
+ $tot_del++;
3174
+ }
3175
+ }
3176
+
3177
+ // 3) LOOP THROUGH SLIDES 'OUT' ARRAY UPDATING POST METADATA.
3178
+ update_post_meta( $slider_id, 'sa_num_slides', $curr_index );
3179
+ foreach ( $data_out_arr as $key => $value ) {
3180
+ update_post_meta( $slider_id, $key, $value );
3181
+ }
3182
+
3183
+ if ( 1 === $tot_del ) {
3184
+ echo "<h3 id='sar_success_message'>" . esc_html( $tot_del ) . ' SLIDE HAS BEEN DELETED</h3>';
3185
+ } else {
3186
+ echo "<h3 id='sar_success_message'>" . esc_html( $tot_del ) . ' SLIDES HAVE BEEN DELETED</h3>';
3187
+ }
3188
+ }
3189
+ }
3190
+
3191
+ // GET REQUIRED SLIDER METADATA AND SAVE WITHIN AN ARRAY.
3192
+ $num_slides = 0;
3193
+ $slide_arr = array();
3194
+ $metadata = get_metadata( 'post', $slider_id );
3195
+ if ( count( $metadata ) > 0 ) {
3196
+ $num_slides = $metadata['sa_num_slides'][0];
3197
+ }
3198
+ if ( 0 !== $num_slides ) {
3199
+ // SLIDER CONTAINS SLIDES - DISPLAY SORTABLE LIST OF SLIDES.
3200
+ for ( $i = 1; $i <= $num_slides; $i++ ) {
3201
+ $image_data = $metadata[ 'sa_slide' . $i . '_image_data' ][0];
3202
+ $image_data_arr = explode( '~', $image_data );
3203
+ $slide_arr[ $i ]['image_id'] = $image_data_arr[0];
3204
+ $slide_arr[ $i ]['content'] = $metadata[ 'sa_slide' . $i . '_content' ][0];
3205
+ // cater for popup images used as the slide background.
3206
+ $popup_type = '';
3207
+ $popup_background = '';
3208
+ if ( isset( $metadata[ 'sa_slide' . $i . '_popup_type' ][0] ) ) {
3209
+ $popup_type = $metadata[ 'sa_slide' . $i . '_popup_type' ][0];
3210
+ }
3211
+ if ( isset( $metadata[ 'sa_slide' . $i . '_popup_background' ][0] ) ) {
3212
+ $popup_background = $metadata[ 'sa_slide' . $i . '_popup_background' ][0];
3213
+ }
3214
+ if ( 'IMAGE' === $popup_type ) {
3215
+ if ( ( '' !== $popup_background ) && ( 'no' !== $popup_background ) ) {
3216
+ $slide_arr[ $i ]['image_id'] = $metadata[ 'sa_slide' . $i . '_popup_imageid' ][0];
3217
+ }
3218
+ }
3219
+ }
3220
+
3221
+ // DISPLAY THE SORTABLE GRID OF SLIDES.
3222
+ echo "<h2 id='sar_slider_title'>" . esc_html( $slider_title ) . "</h2>\n";
3223
+ echo "<h3 id='sar_drag_message'>Drag slides to re-order...</h3>\n";
3224
+ echo "<ul id='sar_sortable'>\n";
3225
+ for ( $i = 1; $i <= $num_slides; $i++ ) {
3226
+ $bg_image = $placeholder_image;
3227
+ $slide_image_src = wp_get_attachment_image_src( $slide_arr[ $i ]['image_id'], 'thumbnail' );
3228
+ if ( ! empty( $slide_image_src[0] ) ) {
3229
+ $bg_image = $slide_image_src[0];
3230
+ }
3231
+ echo "<li id='sar" . esc_attr( $i ) . "' class='ui-state-default'>\n";
3232
+ echo "<div class='sar_image' style='background-image:url(\"" . esc_url( $bg_image ) . "\");'></div>\n";
3233
+ echo "<div class='sar_content'>\n";
3234
+ echo "<h4 class='sar_slide_num'>SLIDE " . esc_html( $i ) . "</h4>\n";
3235
+ echo "<div class='sar_del_slide'>DELETE <span>SLIDE</span>";
3236
+ echo "<input type='checkbox' id='sar_del" . esc_attr( $i ) . "' name='sar_del" . esc_attr( $i ) . "' class='sar_del_checkbox'/>";
3237
+ echo "</div>\n";
3238
+ echo "<div class='sar_slide_html'>" . esc_html( nl2br( htmlentities( $slide_arr[ $i ]['content'] ) ) ) . "</div>\n";
3239
+ echo '</div>';
3240
+ echo "</li>\n";
3241
+ }
3242
+ echo "</ul>\n";
3243
+
3244
+ // DISPLAY THE HTML FORM CONTAINING THE SORT ORDER INPUT ELEMENT.
3245
+ echo "<form method='post' id='sar_order_form'>\n";
3246
+ wp_nonce_field( 'reorder_action', 'reorder_nonce' );
3247
+ echo "<input type='hidden' name='sar_slider_id' value='" . esc_attr( $slider_id ) . "'/>";
3248
+ echo "<input type='hidden' id='sar_sort_order' name='sar_sort_order'/>";
3249
+ echo "<input type='hidden' id='sar_del_slides' name='sar_del_slides'/>";
3250
+ echo "<input type='submit' id='sar_update_but' value='UPDATE ORDER'/>";
3251
+ echo "<input type='submit' id='sar_delete_but' value='DELETE SLIDES'/>";
3252
+ echo "</form>\n";
3253
+
3254
+ } else {
3255
+ // SLIDER CONTAINS NO SLIDES - DISPLAY MESSAGE.
3256
+ echo "<h3 id='sar_no_slides_found'>This slider contains NO slides!</h3>\n";
3257
+ echo "<a class='sar_back_button' href='" . esc_url( $page_url ) . "'>BACK</a>";
3258
+ }
3259
+ } else {
3260
+ // ##### NO POST VARIABLE FOR 'SLIDER ID' HAS BEEN PASSED #####
3261
+ // WP QUERY TO GET ARRAY OF SA SLIDERS (ID & TITLE) THAT EXIST.
3262
+ $slider_arr = array();
3263
+ $count = 0;
3264
+ $args = array(
3265
+ 'post_type' => 'sa_slider',
3266
+ 'post_status' => array( 'publish', 'draft' ),
3267
+ 'orderby' => 'menu_order',
3268
+ 'order' => 'ASC',
3269
+ 'posts_per_page' => -1,
3270
+ );
3271
+ $sliders = new WP_Query( $args );
3272
+ if ( $sliders->have_posts() ) {
3273
+ while ( $sliders->have_posts() ) {
3274
+ $sliders->the_post();
3275
+ $slider_arr[ $count ]['id'] = get_the_ID();
3276
+ $slider_arr[ $count ]['title'] = get_the_title();
3277
+ $count++;
3278
+ }
3279
+ }
3280
+ wp_reset_postdata();
3281
+
3282
+ if ( count( $slider_arr ) > 0 ) {
3283
+ // DISPLAY FORM CONTAINING SA SLIDER SELECT DROPDOWN.
3284
+ echo "<form method='post' id='sar_slider_form'>\n";
3285
+ wp_nonce_field( 'reorder_action', 'reorder_nonce' );
3286
+ echo "<p>This tool allows you to change the order of slides within a Slide Anything slider.</p>\n";
3287
+ echo "<p>Select the slider you would like to re-order, then just drag-and-drop slides for your new slide order.</p>\n";
3288
+ echo "<div style='padding-top:10px;'>Select Slider to Re-Order:<br/>";
3289
+ echo "<select id='sar_slider_id' name='sar_slider_id'>\n";
3290
+ $count_slider_arr = count( $slider_arr );
3291
+ for ( $i = 0; $i < $count_slider_arr; $i++ ) {
3292
+ echo '<h4>|' . esc_html( $slider_arr[ $i ]['id'] ) . '|' . esc_html( $slider_arr[ $i ]['title'] ) . '|</h4>';
3293
+ echo "<option value='" . esc_attr( $slider_arr[ $i ]['id'] ) . "'>" . esc_html( $slider_arr[ $i ]['title'] ) . ' (#' . esc_html( $slider_arr[ $i ]['id'] ) . ")</option>\n";
3294
+ }
3295
+ echo "<select></div>\n";
3296
+ echo "<div><input type='submit' value='Select Slider'/></div>\n";
3297
+ echo "</form>\n";
3298
+ } else {
3299
+ // NO SA SLIDERS FOUND - DISPLAY MESSAGE.
3300
+ echo "<h3 id='sar_no_sliders_found'>No Slide Anything sliders found!</h3>\n";
3301
+ }
3302
+ }
3303
+
3304
+ echo "</div>\n";
3305
+ }
3306
+
3307
+
3308
+ /**
3309
+ * ### FUNCTION CALLED BY 'template_include' FILTER TO USE A CUSTOM PAGE TERMPLATE FOR SA PREVIEW PAGE ###
3310
+ *
3311
+ * @param string $template Page Template.
3312
+ */
3313
+ function cpt_slider_sa_preview_page_template( $template ) {
3314
+ if ( is_page( 'Slide Anything Popup Preview' ) ) {
3315
+ $template = dirname( __FILE__ ) . '/single-page.php';
3316
+ }
3317
+ return $template;
3318
+ }
3319
+
3320
+
3321
+ /**
3322
+ * ### FILTER TO ALLOW IFRAMES WITHIN SLIDE CONTENT ###
3323
+ *
3324
+ * @param array $allowedposttags Allowed Post Tags.
3325
+ */
3326
+ function cpt_slider_allow_iframes_filter( $allowedposttags ) {
3327
+ // Only change for users who can publish posts.
3328
+ if ( ! current_user_can( 'publish_posts' ) ) {
3329
+ return $allowedposttags;
3330
+ }
3331
+
3332
+ // Allow iframes and the following attributes.
3333
+ $allowedposttags['iframe'] = array(
3334
+ 'align' => true,
3335
+ 'width' => true,
3336
+ 'height' => true,
3337
+ 'frameborder' => true,
3338
+ 'name' => true,
3339
+ 'src' => true,
3340
+ 'title' => true,
3341
+ 'allow' => true,
3342
+ 'allowfullscreen' => true,
3343
+ 'id' => true,
3344
+ 'class' => true,
3345
+ 'style' => true,
3346
+ 'scrolling' => true,
3347
+ 'marginwidth' => true,
3348
+ 'marginheight' => true,
3349
+ );
3350
+ return $allowedposttags;
3351
+ }
3352
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: slider, carousel, content slider, responsive slider, html slider, owl carousel
5
  Requires at least: 4.0
6
  Tested up to: 6.0
7
- Stable tag: 2.4.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -90,6 +90,9 @@ Adding a SLIDE ANYTHING slider using the WordPress 5.0 'Block Editor' is pretty
90
 
91
  == Changelog ==
92
 
 
 
 
93
  = 2.4.5 =
94
  * Lets try this again. The SVN commit process keeps corrupting the key 'lightGallery' JavaScript (minified) files. So I've re-minified the source code for 'lightGallery' and hopefully this will work.
95
 
@@ -804,3 +807,6 @@ Adding a SLIDE ANYTHING slider using the WordPress 5.0 'Block Editor' is pretty
804
 
805
  = 2.4.5 =
806
  * Lets try this again. The SVN commit process keeps corrupting the key 'lightGallery' JavaScript (minified) files. So I've re-minified the source code for 'lightGallery' and hopefully this will work.
 
 
 
4
  Tags: slider, carousel, content slider, responsive slider, html slider, owl carousel
5
  Requires at least: 4.0
6
  Tested up to: 6.0
7
+ Stable tag: 2.4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
90
 
91
  == Changelog ==
92
 
93
+ = 2.4.6 =
94
+ * Removed the 'Slider Preview' feature as it was causing issues on some installations of WordPress.
95
+
96
  = 2.4.5 =
97
  * Lets try this again. The SVN commit process keeps corrupting the key 'lightGallery' JavaScript (minified) files. So I've re-minified the source code for 'lightGallery' and hopefully this will work.
98
 
807
 
808
  = 2.4.5 =
809
  * Lets try this again. The SVN commit process keeps corrupting the key 'lightGallery' JavaScript (minified) files. So I've re-minified the source code for 'lightGallery' and hopefully this will work.
810
+
811
+ = 2.4.6 =
812
+ * Removed the 'Slider Preview' feature as it was causing issues on some installations of WordPress.
slide-anything.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Slide Anything - Responsive Content / HTML Slider and Carousel
4
  * Plugin URI: https://wordpress.org/plugins/slide-anything/
5
  * Description: Slide Anything allows you to create a carousel/slider where the content for each slide can be anything you want - images, text, HTML, and even shortcodes. This plugin uses the Owl Carousel jQuery plugin, and lets you create beautiful, touch enabled, responsive carousels and sliders.
6
- * Version: 2.4.5
7
  *
8
  * @package WordPress_Slide_Anything
9
  * @author Simon Edge
3
  * Plugin Name: Slide Anything - Responsive Content / HTML Slider and Carousel
4
  * Plugin URI: https://wordpress.org/plugins/slide-anything/
5
  * Description: Slide Anything allows you to create a carousel/slider where the content for each slide can be anything you want - images, text, HTML, and even shortcodes. This plugin uses the Owl Carousel jQuery plugin, and lets you create beautiful, touch enabled, responsive carousels and sliders.
6
+ * Version: 2.4.6
7
  *
8
  * @package WordPress_Slide_Anything
9
  * @author Simon Edge