Version Description
- Fixed: Copy/Paste element styling not working after Elementor v3.7.1.
Download this release
Release Info
Developer | leap13 |
Plugin | Premium Addons for Elementor |
Version | 4.9.25 |
Comparing to | |
See all releases |
Code changes from version 4.9.24 to 4.9.25
- admin/assets/js/admin.js +537 -537
- admin/includes/templates/modules-settings.php +173 -173
- assets/editor/templates/js/editor.js +1061 -1061
- assets/frontend/js/premium-dis-conditions.js +17 -17
- assets/frontend/js/premium-woo-products.js +673 -646
- assets/frontend/min-js/premium-woo-products.min.js +1 -1
- includes/addons-integration.php +1126 -1126
- modules/pa-display-conditions/module.php +1 -1
- premium-addons-for-elementor.php +4 -4
- readme.txt +5 -1
admin/assets/js/admin.js
CHANGED
@@ -1,537 +1,537 @@
|
|
1 |
-
(function ($) {
|
2 |
-
|
3 |
-
"use strict";
|
4 |
-
|
5 |
-
var redHadfontLink = document.createElement('link');
|
6 |
-
redHadfontLink.rel = 'stylesheet';
|
7 |
-
redHadfontLink.href = 'https://fonts.googleapis.com/css?family=Red Hat Display:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
|
8 |
-
redHadfontLink.type = 'text/css';
|
9 |
-
document.head.appendChild(redHadfontLink);
|
10 |
-
|
11 |
-
var poppinsfontLink = document.createElement('link');
|
12 |
-
poppinsfontLink.rel = 'stylesheet';
|
13 |
-
poppinsfontLink.href = 'https://fonts.googleapis.com/css?family=Poppins:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
|
14 |
-
poppinsfontLink.type = 'text/css';
|
15 |
-
document.head.appendChild(poppinsfontLink);
|
16 |
-
|
17 |
-
var settings = premiumAddonsSettings.settings;
|
18 |
-
|
19 |
-
window.PremiumAddonsNavigation = function () {
|
20 |
-
|
21 |
-
var self = this,
|
22 |
-
$tabs = $(".pa-settings-tab"),
|
23 |
-
$elementsTabs = $(".pa-elements-tab");
|
24 |
-
|
25 |
-
self.init = function () {
|
26 |
-
|
27 |
-
if (!$tabs.length) {
|
28 |
-
return;
|
29 |
-
}
|
30 |
-
|
31 |
-
self.genButtonDisplay();
|
32 |
-
|
33 |
-
self.initNavTabs($tabs);
|
34 |
-
|
35 |
-
self.initElementsTabs($elementsTabs);
|
36 |
-
|
37 |
-
if (settings.isTrackerAllowed) {
|
38 |
-
self.getUnusedWidget();
|
39 |
-
}
|
40 |
-
|
41 |
-
self.handleElementsActions();
|
42 |
-
|
43 |
-
self.handleSettingsSave();
|
44 |
-
|
45 |
-
self.handleRollBack();
|
46 |
-
|
47 |
-
self.handleNewsLetterForm();
|
48 |
-
|
49 |
-
self.handlePaproActions();
|
50 |
-
|
51 |
-
};
|
52 |
-
|
53 |
-
// Handle settings form submission
|
54 |
-
self.handleSettingsSave = function () {
|
55 |
-
|
56 |
-
$("#pa-features .pa-section-info-cta input, #pa-modules .pa-switcher input, #pa-modules .pa-section-info-cta input").on(
|
57 |
-
'change',
|
58 |
-
function () {
|
59 |
-
self.saveElementsSettings('elements');
|
60 |
-
}
|
61 |
-
)
|
62 |
-
|
63 |
-
$("#pa-ver-control input, #pa-integrations input, #pa-ver-control input, #pa-integrations select").change(
|
64 |
-
function () {
|
65 |
-
self.saveElementsSettings('additional');
|
66 |
-
}
|
67 |
-
);
|
68 |
-
|
69 |
-
$("#pa-integrations input[type=text]").on(
|
70 |
-
'keyup',
|
71 |
-
function () {
|
72 |
-
self.saveElementsSettings('additional');
|
73 |
-
}
|
74 |
-
)
|
75 |
-
|
76 |
-
};
|
77 |
-
|
78 |
-
//get unused widgets.
|
79 |
-
self.getUnusedWidget = function () {
|
80 |
-
|
81 |
-
if ($(".pa-btn-group .pa-btn-disable").hasClass("active")) {
|
82 |
-
$(".pa-btn-group .pa-btn-unused").addClass("dimmed");
|
83 |
-
}
|
84 |
-
|
85 |
-
$.ajax(
|
86 |
-
{
|
87 |
-
url: settings.ajaxurl,
|
88 |
-
type: 'POST',
|
89 |
-
data: {
|
90 |
-
action: 'pa_get_unused_widgets',
|
91 |
-
security: settings.nonce,
|
92 |
-
},
|
93 |
-
success: function (response) {
|
94 |
-
console.log('unused widgets retrieved');
|
95 |
-
self.unusedElements = response.data;
|
96 |
-
},
|
97 |
-
error: function (err) {
|
98 |
-
console.log(err);
|
99 |
-
}
|
100 |
-
}
|
101 |
-
);
|
102 |
-
};
|
103 |
-
|
104 |
-
// Handle global enable/disable buttons
|
105 |
-
self.handleElementsActions = function () {
|
106 |
-
|
107 |
-
$(".pa-elements-filter select").on(
|
108 |
-
'change',
|
109 |
-
function () {
|
110 |
-
var filter = $(this).val(),
|
111 |
-
$activeTab = $(".pa-switchers-container").not(".hidden");
|
112 |
-
|
113 |
-
$activeTab.find(".pa-switcher").removeClass("hidden");
|
114 |
-
|
115 |
-
if ('free' === filter) {
|
116 |
-
$activeTab.find(".pro-element").addClass("hidden");
|
117 |
-
} else if ('pro' === filter) {
|
118 |
-
$activeTab.find(".pa-switcher").not(".pro-element").addClass("hidden");
|
119 |
-
}
|
120 |
-
}
|
121 |
-
);
|
122 |
-
|
123 |
-
$(".pa-elements-filter input").on(
|
124 |
-
'keyup',
|
125 |
-
function () {
|
126 |
-
var filter = $(this).val(),
|
127 |
-
$activeTab = $(".pa-switchers-container").not(".hidden"),
|
128 |
-
currentQuerySwitchers = $activeTab.find(".pa-switcher");
|
129 |
-
|
130 |
-
currentQuerySwitchers.addClass("hidden");
|
131 |
-
var searchResults = currentQuerySwitchers.filter(function (index, switcher) {
|
132 |
-
var elementName = $(switcher).find(".pa-element-name").text().toLowerCase();
|
133 |
-
|
134 |
-
return -1 != elementName.indexOf(filter.toLowerCase()) ? $(switcher) : '';
|
135 |
-
});
|
136 |
-
|
137 |
-
searchResults.removeClass("hidden");
|
138 |
-
}
|
139 |
-
);
|
140 |
-
|
141 |
-
// Enable/Disable all widgets
|
142 |
-
$(".pa-btn-group").on(
|
143 |
-
"click",
|
144 |
-
'.pa-btn',
|
145 |
-
function () {
|
146 |
-
|
147 |
-
var $btn = $(this),
|
148 |
-
isChecked = $btn.hasClass("pa-btn-enable");
|
149 |
-
|
150 |
-
if (!$btn.hasClass("active")) {
|
151 |
-
$(".pa-btn-group .pa-btn").removeClass("active");
|
152 |
-
$btn.addClass("active");
|
153 |
-
|
154 |
-
$.ajax(
|
155 |
-
{
|
156 |
-
url: settings.ajaxurl,
|
157 |
-
type: 'POST',
|
158 |
-
data: {
|
159 |
-
action: 'pa_save_global_btn',
|
160 |
-
security: settings.nonce,
|
161 |
-
isGlobalOn: isChecked
|
162 |
-
}
|
163 |
-
}
|
164 |
-
);
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
if (isChecked) {
|
169 |
-
$(".pa-btn-group .pa-btn-unused").removeClass("dimmed");
|
170 |
-
} else {
|
171 |
-
$(".pa-btn-group .pa-btn-unused").addClass("dimmed");
|
172 |
-
}
|
173 |
-
|
174 |
-
$("#pa-modules .pa-switcher input").prop("checked", isChecked);
|
175 |
-
|
176 |
-
self.saveElementsSettings('elements');
|
177 |
-
|
178 |
-
}
|
179 |
-
);
|
180 |
-
|
181 |
-
//Disable unused widgets.
|
182 |
-
$(".pa-btn-group").on(
|
183 |
-
"click",
|
184 |
-
'.pa-btn-unused',
|
185 |
-
function () {
|
186 |
-
|
187 |
-
$.each(self.unusedElements, function (index, selector) {
|
188 |
-
$('#pa-modules .pa-switcher.' + selector).find('input').prop('checked', false);
|
189 |
-
});
|
190 |
-
|
191 |
-
$(this).addClass('dimmed');
|
192 |
-
|
193 |
-
self.saveElementsSettings('elements');
|
194 |
-
}
|
195 |
-
);
|
196 |
-
|
197 |
-
$("#pa-modules .pa-switcher input").on(
|
198 |
-
'change',
|
199 |
-
function () {
|
200 |
-
var $this = $(this),
|
201 |
-
id = $this.attr('id'),
|
202 |
-
isChecked = $this.prop('checked');
|
203 |
-
|
204 |
-
$("input[name='" + id + "']").prop('checked', isChecked);
|
205 |
-
}
|
206 |
-
)
|
207 |
-
|
208 |
-
//Disable unused widgets.
|
209 |
-
$(".pa-section-info-cta").on(
|
210 |
-
"click",
|
211 |
-
'.pa-btn-regenerate',
|
212 |
-
function () {
|
213 |
-
|
214 |
-
var _this = $(this);
|
215 |
-
_this.addClass("loading");
|
216 |
-
|
217 |
-
$.ajax(
|
218 |
-
{
|
219 |
-
url: settings.ajaxurl,
|
220 |
-
type: 'POST',
|
221 |
-
data: {
|
222 |
-
action: 'pa_clear_cached_assets',
|
223 |
-
security: settings.generate_nonce,
|
224 |
-
},
|
225 |
-
success: function (response) {
|
226 |
-
|
227 |
-
swal.fire({
|
228 |
-
title: 'Generated Assets Cleared!',
|
229 |
-
text: 'Click OK to continue',
|
230 |
-
type: 'success',
|
231 |
-
timer: 1500
|
232 |
-
});
|
233 |
-
|
234 |
-
_this.removeClass("loading");
|
235 |
-
|
236 |
-
},
|
237 |
-
}
|
238 |
-
);
|
239 |
-
}
|
240 |
-
);
|
241 |
-
|
242 |
-
};
|
243 |
-
|
244 |
-
// Handle Tabs Elements
|
245 |
-
self.initElementsTabs = function ($elem) {
|
246 |
-
|
247 |
-
var $links = $elem.find('a'),
|
248 |
-
$sections = $(".pa-switchers-container");
|
249 |
-
|
250 |
-
$sections.eq(0).removeClass("hidden");
|
251 |
-
$links.eq(0).addClass("active");
|
252 |
-
|
253 |
-
$links.on(
|
254 |
-
'click',
|
255 |
-
function (e) {
|
256 |
-
|
257 |
-
e.preventDefault();
|
258 |
-
|
259 |
-
var $link = $(this),
|
260 |
-
href = $link.attr('href');
|
261 |
-
|
262 |
-
// Set this tab to active
|
263 |
-
$links.removeClass("active");
|
264 |
-
$link.addClass("active");
|
265 |
-
|
266 |
-
// Navigate to tab section
|
267 |
-
$sections.addClass("hidden");
|
268 |
-
$("#" + href).removeClass("hidden");
|
269 |
-
|
270 |
-
}
|
271 |
-
);
|
272 |
-
};
|
273 |
-
|
274 |
-
// Handle settings tabs
|
275 |
-
self.initNavTabs = function ($elem) {
|
276 |
-
|
277 |
-
var $links = $elem.find('a'),
|
278 |
-
$lastSection = null;
|
279 |
-
|
280 |
-
$(window).on(
|
281 |
-
'hashchange',
|
282 |
-
function () {
|
283 |
-
|
284 |
-
var hash = window.location.hash.match(new RegExp('tab=([^&]*)')),
|
285 |
-
slug = hash ? hash[1] : $links.first().attr('href').replace('#tab=', ''),
|
286 |
-
$link = $('#pa-tab-link-' + slug);
|
287 |
-
|
288 |
-
if (!$link.length) {
|
289 |
-
return
|
290 |
-
|
291 |
-
}
|
292 |
-
$links.removeClass('pa-section-active');
|
293 |
-
$link.addClass('pa-section-active');
|
294 |
-
|
295 |
-
// Hide the last active section
|
296 |
-
if ($lastSection) {
|
297 |
-
$lastSection.hide();
|
298 |
-
}
|
299 |
-
|
300 |
-
var $section = $('#pa-section-' + slug);
|
301 |
-
$section.css(
|
302 |
-
{
|
303 |
-
display: 'block'
|
304 |
-
}
|
305 |
-
);
|
306 |
-
|
307 |
-
$lastSection = $section;
|
308 |
-
|
309 |
-
}
|
310 |
-
).trigger('hashchange');
|
311 |
-
|
312 |
-
};
|
313 |
-
|
314 |
-
self.handleRollBack = function () {
|
315 |
-
|
316 |
-
// Rollback button
|
317 |
-
$('.pa-rollback-button').on(
|
318 |
-
'click',
|
319 |
-
function (event) {
|
320 |
-
|
321 |
-
event.preventDefault();
|
322 |
-
|
323 |
-
var $this = $(this),
|
324 |
-
href = $this.attr('href');
|
325 |
-
|
326 |
-
if (!href) {
|
327 |
-
return;
|
328 |
-
}
|
329 |
-
|
330 |
-
// Show PAPRO stable version if PAPRO Rollback is clicked
|
331 |
-
var isPAPRO = '';
|
332 |
-
if (-1 !== href.indexOf('papro_rollback')) {
|
333 |
-
isPAPRO = 'papro_';
|
334 |
-
}
|
335 |
-
|
336 |
-
var premiumRollBackConfirm = premiumAddonsSettings.premiumRollBackConfirm;
|
337 |
-
|
338 |
-
var dialogsManager = new DialogsManager.Instance();
|
339 |
-
|
340 |
-
dialogsManager.createWidget(
|
341 |
-
'confirm',
|
342 |
-
{
|
343 |
-
headerMessage: premiumRollBackConfirm.i18n.rollback_to_previous_version,
|
344 |
-
message: premiumRollBackConfirm['i18n'][isPAPRO + 'rollback_confirm'],
|
345 |
-
strings: {
|
346 |
-
cancel: premiumRollBackConfirm.i18n.cancel,
|
347 |
-
confirm: premiumRollBackConfirm.i18n.yes,
|
348 |
-
},
|
349 |
-
onConfirm: function () {
|
350 |
-
|
351 |
-
$this.addClass('loading');
|
352 |
-
|
353 |
-
location.href = $this.attr('href');
|
354 |
-
|
355 |
-
}
|
356 |
-
}
|
357 |
-
).show();
|
358 |
-
}
|
359 |
-
);
|
360 |
-
|
361 |
-
};
|
362 |
-
|
363 |
-
self.saveElementsSettings = function (action) { //save elements settings changes
|
364 |
-
|
365 |
-
var $form = null;
|
366 |
-
|
367 |
-
if ('elements' === action) {
|
368 |
-
$form = $('form#pa-settings, form#pa-features');
|
369 |
-
action = 'pa_elements_settings';
|
370 |
-
} else {
|
371 |
-
$form = $('form#pa-ver-control, form#pa-integrations');
|
372 |
-
action = 'pa_additional_settings';
|
373 |
-
}
|
374 |
-
|
375 |
-
$.ajax(
|
376 |
-
{
|
377 |
-
url: settings.ajaxurl,
|
378 |
-
type: 'POST',
|
379 |
-
data: {
|
380 |
-
action: action,
|
381 |
-
security: settings.nonce,
|
382 |
-
fields: $form.serialize(),
|
383 |
-
},
|
384 |
-
success: function (response) {
|
385 |
-
console.log('settings saved');
|
386 |
-
|
387 |
-
self.genButtonDisplay();
|
388 |
-
},
|
389 |
-
error: function (err) {
|
390 |
-
console.log(err);
|
391 |
-
}
|
392 |
-
}
|
393 |
-
);
|
394 |
-
}
|
395 |
-
|
396 |
-
self.genButtonDisplay = function () {
|
397 |
-
var $form = $('form#pa-settings'),
|
398 |
-
searchTerm = 'premium-assets-generator=on',
|
399 |
-
indexOfFirst = $form.serialize().indexOf(searchTerm);
|
400 |
-
|
401 |
-
if (indexOfFirst !== -1) {
|
402 |
-
$('.pa-btn-generate').show();
|
403 |
-
} else {
|
404 |
-
$('.pa-btn-generate').hide();
|
405 |
-
}
|
406 |
-
};
|
407 |
-
|
408 |
-
self.handlePaproActions = function () {
|
409 |
-
|
410 |
-
// Trigger SWAL for PRO elements
|
411 |
-
$(".pro-slider").on(
|
412 |
-
'click',
|
413 |
-
function () {
|
414 |
-
|
415 |
-
var redirectionLink = " https://premiumaddons.com/pro/?utm_source=wp-menu&utm_medium=wp-dash&utm_campaign=get-pro&utm_term=";
|
416 |
-
|
417 |
-
Swal.fire(
|
418 |
-
{
|
419 |
-
title: '<span class="pa-swal-head">Get PRO Widgets & Addons<span>',
|
420 |
-
html: 'Supercharge your Elementor with PRO widgets and addons that you won’t find anywhere else.',
|
421 |
-
type: 'warning',
|
422 |
-
showCloseButton: true,
|
423 |
-
showCancelButton: true,
|
424 |
-
cancelButtonText: "More Info",
|
425 |
-
focusConfirm: true,
|
426 |
-
customClass: 'pa-swal',
|
427 |
-
}
|
428 |
-
).then(
|
429 |
-
function (res) {
|
430 |
-
// Handle More Info button
|
431 |
-
if (res.dismiss === 'cancel') {
|
432 |
-
window.open(redirectionLink + settings.theme, '_blank');
|
433 |
-
}
|
434 |
-
|
435 |
-
}
|
436 |
-
);
|
437 |
-
}
|
438 |
-
);
|
439 |
-
|
440 |
-
// Trigger SWAL for White Labeling
|
441 |
-
$(".premium-white-label-form.pro-inactive").on(
|
442 |
-
'submit',
|
443 |
-
function (e) {
|
444 |
-
|
445 |
-
e.preventDefault();
|
446 |
-
|
447 |
-
var redirectionLink = " https://premiumaddons.com/pro/?utm_source=wp-menu&utm_medium=wp-dash&utm_campaign=get-pro&utm_term=";
|
448 |
-
|
449 |
-
Swal.fire(
|
450 |
-
{
|
451 |
-
title: '<span class="pa-swal-head">Enable White Labeling Options<span>',
|
452 |
-
html: 'Premium Addons can be completely re-branded with your own brand name and author details. Your clients will never know what tools you are using to build their website and will think that this is your own tool set. White-labeling works as long as your license is active.',
|
453 |
-
type: 'warning',
|
454 |
-
showCloseButton: true,
|
455 |
-
showCancelButton: true,
|
456 |
-
cancelButtonText: "More Info",
|
457 |
-
focusConfirm: true
|
458 |
-
}
|
459 |
-
).then(
|
460 |
-
function (res) {
|
461 |
-
// Handle More Info button
|
462 |
-
if (res.dismiss === 'cancel') {
|
463 |
-
window.open(redirectionLink + settings.theme, '_blank');
|
464 |
-
}
|
465 |
-
|
466 |
-
}
|
467 |
-
);
|
468 |
-
}
|
469 |
-
);
|
470 |
-
|
471 |
-
};
|
472 |
-
|
473 |
-
self.handleNewsLetterForm = function () {
|
474 |
-
|
475 |
-
$('.pa-newsletter-form').on('submit', function (e) {
|
476 |
-
e.preventDefault();
|
477 |
-
|
478 |
-
var email = $("#pa_news_email").val();
|
479 |
-
|
480 |
-
if (checkEmail(email)) {
|
481 |
-
$.ajax(
|
482 |
-
{
|
483 |
-
url: settings.ajaxurl,
|
484 |
-
type: 'POST',
|
485 |
-
data: {
|
486 |
-
action: 'subscribe_newsletter',
|
487 |
-
security: settings.nonce,
|
488 |
-
email: email
|
489 |
-
},
|
490 |
-
beforeSend: function () {
|
491 |
-
console.log("Adding user to subscribers list");
|
492 |
-
},
|
493 |
-
success: function (response) {
|
494 |
-
if (response.data) {
|
495 |
-
var status = response.data.status;
|
496 |
-
if (status) {
|
497 |
-
console.log("User added to subscribers list");
|
498 |
-
swal.fire({
|
499 |
-
title: 'Thanks for subscribing!',
|
500 |
-
text: 'Click OK to continue',
|
501 |
-
type: 'success',
|
502 |
-
timer: 1000
|
503 |
-
});
|
504 |
-
}
|
505 |
-
|
506 |
-
}
|
507 |
-
|
508 |
-
},
|
509 |
-
error: function (err) {
|
510 |
-
console.log(err);
|
511 |
-
}
|
512 |
-
}
|
513 |
-
);
|
514 |
-
} else {
|
515 |
-
Swal.fire({
|
516 |
-
type: 'error',
|
517 |
-
title: 'Invalid Email Address...',
|
518 |
-
text: 'Please enter a valid email address!'
|
519 |
-
});
|
520 |
-
}
|
521 |
-
|
522 |
-
})
|
523 |
-
|
524 |
-
};
|
525 |
-
|
526 |
-
function checkEmail(emailAddress) {
|
527 |
-
var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
|
528 |
-
return pattern.test(emailAddress);
|
529 |
-
}
|
530 |
-
|
531 |
-
};
|
532 |
-
|
533 |
-
var instance = new PremiumAddonsNavigation();
|
534 |
-
|
535 |
-
instance.init();
|
536 |
-
|
537 |
-
})(jQuery);
|
1 |
+
(function ($) {
|
2 |
+
|
3 |
+
"use strict";
|
4 |
+
|
5 |
+
var redHadfontLink = document.createElement('link');
|
6 |
+
redHadfontLink.rel = 'stylesheet';
|
7 |
+
redHadfontLink.href = 'https://fonts.googleapis.com/css?family=Red Hat Display:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
|
8 |
+
redHadfontLink.type = 'text/css';
|
9 |
+
document.head.appendChild(redHadfontLink);
|
10 |
+
|
11 |
+
var poppinsfontLink = document.createElement('link');
|
12 |
+
poppinsfontLink.rel = 'stylesheet';
|
13 |
+
poppinsfontLink.href = 'https://fonts.googleapis.com/css?family=Poppins:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
|
14 |
+
poppinsfontLink.type = 'text/css';
|
15 |
+
document.head.appendChild(poppinsfontLink);
|
16 |
+
|
17 |
+
var settings = premiumAddonsSettings.settings;
|
18 |
+
|
19 |
+
window.PremiumAddonsNavigation = function () {
|
20 |
+
|
21 |
+
var self = this,
|
22 |
+
$tabs = $(".pa-settings-tab"),
|
23 |
+
$elementsTabs = $(".pa-elements-tab");
|
24 |
+
|
25 |
+
self.init = function () {
|
26 |
+
|
27 |
+
if (!$tabs.length) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
self.genButtonDisplay();
|
32 |
+
|
33 |
+
self.initNavTabs($tabs);
|
34 |
+
|
35 |
+
self.initElementsTabs($elementsTabs);
|
36 |
+
|
37 |
+
if (settings.isTrackerAllowed) {
|
38 |
+
self.getUnusedWidget();
|
39 |
+
}
|
40 |
+
|
41 |
+
self.handleElementsActions();
|
42 |
+
|
43 |
+
self.handleSettingsSave();
|
44 |
+
|
45 |
+
self.handleRollBack();
|
46 |
+
|
47 |
+
self.handleNewsLetterForm();
|
48 |
+
|
49 |
+
self.handlePaproActions();
|
50 |
+
|
51 |
+
};
|
52 |
+
|
53 |
+
// Handle settings form submission
|
54 |
+
self.handleSettingsSave = function () {
|
55 |
+
|
56 |
+
$("#pa-features .pa-section-info-cta input, #pa-modules .pa-switcher input, #pa-modules .pa-section-info-cta input").on(
|
57 |
+
'change',
|
58 |
+
function () {
|
59 |
+
self.saveElementsSettings('elements');
|
60 |
+
}
|
61 |
+
)
|
62 |
+
|
63 |
+
$("#pa-ver-control input, #pa-integrations input, #pa-ver-control input, #pa-integrations select").change(
|
64 |
+
function () {
|
65 |
+
self.saveElementsSettings('additional');
|
66 |
+
}
|
67 |
+
);
|
68 |
+
|
69 |
+
$("#pa-integrations input[type=text]").on(
|
70 |
+
'keyup',
|
71 |
+
function () {
|
72 |
+
self.saveElementsSettings('additional');
|
73 |
+
}
|
74 |
+
)
|
75 |
+
|
76 |
+
};
|
77 |
+
|
78 |
+
//get unused widgets.
|
79 |
+
self.getUnusedWidget = function () {
|
80 |
+
|
81 |
+
if ($(".pa-btn-group .pa-btn-disable").hasClass("active")) {
|
82 |
+
$(".pa-btn-group .pa-btn-unused").addClass("dimmed");
|
83 |
+
}
|
84 |
+
|
85 |
+
$.ajax(
|
86 |
+
{
|
87 |
+
url: settings.ajaxurl,
|
88 |
+
type: 'POST',
|
89 |
+
data: {
|
90 |
+
action: 'pa_get_unused_widgets',
|
91 |
+
security: settings.nonce,
|
92 |
+
},
|
93 |
+
success: function (response) {
|
94 |
+
console.log('unused widgets retrieved');
|
95 |
+
self.unusedElements = response.data;
|
96 |
+
},
|
97 |
+
error: function (err) {
|
98 |
+
console.log(err);
|
99 |
+
}
|
100 |
+
}
|
101 |
+
);
|
102 |
+
};
|
103 |
+
|
104 |
+
// Handle global enable/disable buttons
|
105 |
+
self.handleElementsActions = function () {
|
106 |
+
|
107 |
+
$(".pa-elements-filter select").on(
|
108 |
+
'change',
|
109 |
+
function () {
|
110 |
+
var filter = $(this).val(),
|
111 |
+
$activeTab = $(".pa-switchers-container").not(".hidden");
|
112 |
+
|
113 |
+
$activeTab.find(".pa-switcher").removeClass("hidden");
|
114 |
+
|
115 |
+
if ('free' === filter) {
|
116 |
+
$activeTab.find(".pro-element").addClass("hidden");
|
117 |
+
} else if ('pro' === filter) {
|
118 |
+
$activeTab.find(".pa-switcher").not(".pro-element").addClass("hidden");
|
119 |
+
}
|
120 |
+
}
|
121 |
+
);
|
122 |
+
|
123 |
+
$(".pa-elements-filter input").on(
|
124 |
+
'keyup',
|
125 |
+
function () {
|
126 |
+
var filter = $(this).val(),
|
127 |
+
$activeTab = $(".pa-switchers-container").not(".hidden"),
|
128 |
+
currentQuerySwitchers = $activeTab.find(".pa-switcher");
|
129 |
+
|
130 |
+
currentQuerySwitchers.addClass("hidden");
|
131 |
+
var searchResults = currentQuerySwitchers.filter(function (index, switcher) {
|
132 |
+
var elementName = $(switcher).find(".pa-element-name").text().toLowerCase();
|
133 |
+
|
134 |
+
return -1 != elementName.indexOf(filter.toLowerCase()) ? $(switcher) : '';
|
135 |
+
});
|
136 |
+
|
137 |
+
searchResults.removeClass("hidden");
|
138 |
+
}
|
139 |
+
);
|
140 |
+
|
141 |
+
// Enable/Disable all widgets
|
142 |
+
$(".pa-btn-group").on(
|
143 |
+
"click",
|
144 |
+
'.pa-btn',
|
145 |
+
function () {
|
146 |
+
|
147 |
+
var $btn = $(this),
|
148 |
+
isChecked = $btn.hasClass("pa-btn-enable");
|
149 |
+
|
150 |
+
if (!$btn.hasClass("active")) {
|
151 |
+
$(".pa-btn-group .pa-btn").removeClass("active");
|
152 |
+
$btn.addClass("active");
|
153 |
+
|
154 |
+
$.ajax(
|
155 |
+
{
|
156 |
+
url: settings.ajaxurl,
|
157 |
+
type: 'POST',
|
158 |
+
data: {
|
159 |
+
action: 'pa_save_global_btn',
|
160 |
+
security: settings.nonce,
|
161 |
+
isGlobalOn: isChecked
|
162 |
+
}
|
163 |
+
}
|
164 |
+
);
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
if (isChecked) {
|
169 |
+
$(".pa-btn-group .pa-btn-unused").removeClass("dimmed");
|
170 |
+
} else {
|
171 |
+
$(".pa-btn-group .pa-btn-unused").addClass("dimmed");
|
172 |
+
}
|
173 |
+
|
174 |
+
$("#pa-modules .pa-switcher input").prop("checked", isChecked);
|
175 |
+
|
176 |
+
self.saveElementsSettings('elements');
|
177 |
+
|
178 |
+
}
|
179 |
+
);
|
180 |
+
|
181 |
+
//Disable unused widgets.
|
182 |
+
$(".pa-btn-group").on(
|
183 |
+
"click",
|
184 |
+
'.pa-btn-unused',
|
185 |
+
function () {
|
186 |
+
|
187 |
+
$.each(self.unusedElements, function (index, selector) {
|
188 |
+
$('#pa-modules .pa-switcher.' + selector).find('input').prop('checked', false);
|
189 |
+
});
|
190 |
+
|
191 |
+
$(this).addClass('dimmed');
|
192 |
+
|
193 |
+
self.saveElementsSettings('elements');
|
194 |
+
}
|
195 |
+
);
|
196 |
+
|
197 |
+
$("#pa-modules .pa-switcher input").on(
|
198 |
+
'change',
|
199 |
+
function () {
|
200 |
+
var $this = $(this),
|
201 |
+
id = $this.attr('id'),
|
202 |
+
isChecked = $this.prop('checked');
|
203 |
+
|
204 |
+
$("input[name='" + id + "']").prop('checked', isChecked);
|
205 |
+
}
|
206 |
+
)
|
207 |
+
|
208 |
+
//Disable unused widgets.
|
209 |
+
$(".pa-section-info-cta").on(
|
210 |
+
"click",
|
211 |
+
'.pa-btn-regenerate',
|
212 |
+
function () {
|
213 |
+
|
214 |
+
var _this = $(this);
|
215 |
+
_this.addClass("loading");
|
216 |
+
|
217 |
+
$.ajax(
|
218 |
+
{
|
219 |
+
url: settings.ajaxurl,
|
220 |
+
type: 'POST',
|
221 |
+
data: {
|
222 |
+
action: 'pa_clear_cached_assets',
|
223 |
+
security: settings.generate_nonce,
|
224 |
+
},
|
225 |
+
success: function (response) {
|
226 |
+
|
227 |
+
swal.fire({
|
228 |
+
title: 'Generated Assets Cleared!',
|
229 |
+
text: 'Click OK to continue',
|
230 |
+
type: 'success',
|
231 |
+
timer: 1500
|
232 |
+
});
|
233 |
+
|
234 |
+
_this.removeClass("loading");
|
235 |
+
|
236 |
+
},
|
237 |
+
}
|
238 |
+
);
|
239 |
+
}
|
240 |
+
);
|
241 |
+
|
242 |
+
};
|
243 |
+
|
244 |
+
// Handle Tabs Elements
|
245 |
+
self.initElementsTabs = function ($elem) {
|
246 |
+
|
247 |
+
var $links = $elem.find('a'),
|
248 |
+
$sections = $(".pa-switchers-container");
|
249 |
+
|
250 |
+
$sections.eq(0).removeClass("hidden");
|
251 |
+
$links.eq(0).addClass("active");
|
252 |
+
|
253 |
+
$links.on(
|
254 |
+
'click',
|
255 |
+
function (e) {
|
256 |
+
|
257 |
+
e.preventDefault();
|
258 |
+
|
259 |
+
var $link = $(this),
|
260 |
+
href = $link.attr('href');
|
261 |
+
|
262 |
+
// Set this tab to active
|
263 |
+
$links.removeClass("active");
|
264 |
+
$link.addClass("active");
|
265 |
+
|
266 |
+
// Navigate to tab section
|
267 |
+
$sections.addClass("hidden");
|
268 |
+
$("#" + href).removeClass("hidden");
|
269 |
+
|
270 |
+
}
|
271 |
+
);
|
272 |
+
};
|
273 |
+
|
274 |
+
// Handle settings tabs
|
275 |
+
self.initNavTabs = function ($elem) {
|
276 |
+
|
277 |
+
var $links = $elem.find('a'),
|
278 |
+
$lastSection = null;
|
279 |
+
|
280 |
+
$(window).on(
|
281 |
+
'hashchange',
|
282 |
+
function () {
|
283 |
+
|
284 |
+
var hash = window.location.hash.match(new RegExp('tab=([^&]*)')),
|
285 |
+
slug = hash ? hash[1] : $links.first().attr('href').replace('#tab=', ''),
|
286 |
+
$link = $('#pa-tab-link-' + slug);
|
287 |
+
|
288 |
+
if (!$link.length) {
|
289 |
+
return
|
290 |
+
|
291 |
+
}
|
292 |
+
$links.removeClass('pa-section-active');
|
293 |
+
$link.addClass('pa-section-active');
|
294 |
+
|
295 |
+
// Hide the last active section
|
296 |
+
if ($lastSection) {
|
297 |
+
$lastSection.hide();
|
298 |
+
}
|
299 |
+
|
300 |
+
var $section = $('#pa-section-' + slug);
|
301 |
+
$section.css(
|
302 |
+
{
|
303 |
+
display: 'block'
|
304 |
+
}
|
305 |
+
);
|
306 |
+
|
307 |
+
$lastSection = $section;
|
308 |
+
|
309 |
+
}
|
310 |
+
).trigger('hashchange');
|
311 |
+
|
312 |
+
};
|
313 |
+
|
314 |
+
self.handleRollBack = function () {
|
315 |
+
|
316 |
+
// Rollback button
|
317 |
+
$('.pa-rollback-button').on(
|
318 |
+
'click',
|
319 |
+
function (event) {
|
320 |
+
|
321 |
+
event.preventDefault();
|
322 |
+
|
323 |
+
var $this = $(this),
|
324 |
+
href = $this.attr('href');
|
325 |
+
|
326 |
+
if (!href) {
|
327 |
+
return;
|
328 |
+
}
|
329 |
+
|
330 |
+
// Show PAPRO stable version if PAPRO Rollback is clicked
|
331 |
+
var isPAPRO = '';
|
332 |
+
if (-1 !== href.indexOf('papro_rollback')) {
|
333 |
+
isPAPRO = 'papro_';
|
334 |
+
}
|
335 |
+
|
336 |
+
var premiumRollBackConfirm = premiumAddonsSettings.premiumRollBackConfirm;
|
337 |
+
|
338 |
+
var dialogsManager = new DialogsManager.Instance();
|
339 |
+
|
340 |
+
dialogsManager.createWidget(
|
341 |
+
'confirm',
|
342 |
+
{
|
343 |
+
headerMessage: premiumRollBackConfirm.i18n.rollback_to_previous_version,
|
344 |
+
message: premiumRollBackConfirm['i18n'][isPAPRO + 'rollback_confirm'],
|
345 |
+
strings: {
|
346 |
+
cancel: premiumRollBackConfirm.i18n.cancel,
|
347 |
+
confirm: premiumRollBackConfirm.i18n.yes,
|
348 |
+
},
|
349 |
+
onConfirm: function () {
|
350 |
+
|
351 |
+
$this.addClass('loading');
|
352 |
+
|
353 |
+
location.href = $this.attr('href');
|
354 |
+
|
355 |
+
}
|
356 |
+
}
|
357 |
+
).show();
|
358 |
+
}
|
359 |
+
);
|
360 |
+
|
361 |
+
};
|
362 |
+
|
363 |
+
self.saveElementsSettings = function (action) { //save elements settings changes
|
364 |
+
|
365 |
+
var $form = null;
|
366 |
+
|
367 |
+
if ('elements' === action) {
|
368 |
+
$form = $('form#pa-settings, form#pa-features');
|
369 |
+
action = 'pa_elements_settings';
|
370 |
+
} else {
|
371 |
+
$form = $('form#pa-ver-control, form#pa-integrations');
|
372 |
+
action = 'pa_additional_settings';
|
373 |
+
}
|
374 |
+
|
375 |
+
$.ajax(
|
376 |
+
{
|
377 |
+
url: settings.ajaxurl,
|
378 |
+
type: 'POST',
|
379 |
+
data: {
|
380 |
+
action: action,
|
381 |
+
security: settings.nonce,
|
382 |
+
fields: $form.serialize(),
|
383 |
+
},
|
384 |
+
success: function (response) {
|
385 |
+
console.log('settings saved');
|
386 |
+
|
387 |
+
self.genButtonDisplay();
|
388 |
+
},
|
389 |
+
error: function (err) {
|
390 |
+
console.log(err);
|
391 |
+
}
|
392 |
+
}
|
393 |
+
);
|
394 |
+
}
|
395 |
+
|
396 |
+
self.genButtonDisplay = function () {
|
397 |
+
var $form = $('form#pa-settings'),
|
398 |
+
searchTerm = 'premium-assets-generator=on',
|
399 |
+
indexOfFirst = $form.serialize().indexOf(searchTerm);
|
400 |
+
|
401 |
+
if (indexOfFirst !== -1) {
|
402 |
+
$('.pa-btn-generate').show();
|
403 |
+
} else {
|
404 |
+
$('.pa-btn-generate').hide();
|
405 |
+
}
|
406 |
+
};
|
407 |
+
|
408 |
+
self.handlePaproActions = function () {
|
409 |
+
|
410 |
+
// Trigger SWAL for PRO elements
|
411 |
+
$(".pro-slider").on(
|
412 |
+
'click',
|
413 |
+
function () {
|
414 |
+
|
415 |
+
var redirectionLink = " https://premiumaddons.com/pro/?utm_source=wp-menu&utm_medium=wp-dash&utm_campaign=get-pro&utm_term=";
|
416 |
+
|
417 |
+
Swal.fire(
|
418 |
+
{
|
419 |
+
title: '<span class="pa-swal-head">Get PRO Widgets & Addons<span>',
|
420 |
+
html: 'Supercharge your Elementor with PRO widgets and addons that you won’t find anywhere else.',
|
421 |
+
type: 'warning',
|
422 |
+
showCloseButton: true,
|
423 |
+
showCancelButton: true,
|
424 |
+
cancelButtonText: "More Info",
|
425 |
+
focusConfirm: true,
|
426 |
+
customClass: 'pa-swal',
|
427 |
+
}
|
428 |
+
).then(
|
429 |
+
function (res) {
|
430 |
+
// Handle More Info button
|
431 |
+
if (res.dismiss === 'cancel') {
|
432 |
+
window.open(redirectionLink + settings.theme, '_blank');
|
433 |
+
}
|
434 |
+
|
435 |
+
}
|
436 |
+
);
|
437 |
+
}
|
438 |
+
);
|
439 |
+
|
440 |
+
// Trigger SWAL for White Labeling
|
441 |
+
$(".premium-white-label-form.pro-inactive").on(
|
442 |
+
'submit',
|
443 |
+
function (e) {
|
444 |
+
|
445 |
+
e.preventDefault();
|
446 |
+
|
447 |
+
var redirectionLink = " https://premiumaddons.com/pro/?utm_source=wp-menu&utm_medium=wp-dash&utm_campaign=get-pro&utm_term=";
|
448 |
+
|
449 |
+
Swal.fire(
|
450 |
+
{
|
451 |
+
title: '<span class="pa-swal-head">Enable White Labeling Options<span>',
|
452 |
+
html: 'Premium Addons can be completely re-branded with your own brand name and author details. Your clients will never know what tools you are using to build their website and will think that this is your own tool set. White-labeling works as long as your license is active.',
|
453 |
+
type: 'warning',
|
454 |
+
showCloseButton: true,
|
455 |
+
showCancelButton: true,
|
456 |
+
cancelButtonText: "More Info",
|
457 |
+
focusConfirm: true
|
458 |
+
}
|
459 |
+
).then(
|
460 |
+
function (res) {
|
461 |
+
// Handle More Info button
|
462 |
+
if (res.dismiss === 'cancel') {
|
463 |
+
window.open(redirectionLink + settings.theme, '_blank');
|
464 |
+
}
|
465 |
+
|
466 |
+
}
|
467 |
+
);
|
468 |
+
}
|
469 |
+
);
|
470 |
+
|
471 |
+
};
|
472 |
+
|
473 |
+
self.handleNewsLetterForm = function () {
|
474 |
+
|
475 |
+
$('.pa-newsletter-form').on('submit', function (e) {
|
476 |
+
e.preventDefault();
|
477 |
+
|
478 |
+
var email = $("#pa_news_email").val();
|
479 |
+
|
480 |
+
if (checkEmail(email)) {
|
481 |
+
$.ajax(
|
482 |
+
{
|
483 |
+
url: settings.ajaxurl,
|
484 |
+
type: 'POST',
|
485 |
+
data: {
|
486 |
+
action: 'subscribe_newsletter',
|
487 |
+
security: settings.nonce,
|
488 |
+
email: email
|
489 |
+
},
|
490 |
+
beforeSend: function () {
|
491 |
+
console.log("Adding user to subscribers list");
|
492 |
+
},
|
493 |
+
success: function (response) {
|
494 |
+
if (response.data) {
|
495 |
+
var status = response.data.status;
|
496 |
+
if (status) {
|
497 |
+
console.log("User added to subscribers list");
|
498 |
+
swal.fire({
|
499 |
+
title: 'Thanks for subscribing!',
|
500 |
+
text: 'Click OK to continue',
|
501 |
+
type: 'success',
|
502 |
+
timer: 1000
|
503 |
+
});
|
504 |
+
}
|
505 |
+
|
506 |
+
}
|
507 |
+
|
508 |
+
},
|
509 |
+
error: function (err) {
|
510 |
+
console.log(err);
|
511 |
+
}
|
512 |
+
}
|
513 |
+
);
|
514 |
+
} else {
|
515 |
+
Swal.fire({
|
516 |
+
type: 'error',
|
517 |
+
title: 'Invalid Email Address...',
|
518 |
+
text: 'Please enter a valid email address!'
|
519 |
+
});
|
520 |
+
}
|
521 |
+
|
522 |
+
})
|
523 |
+
|
524 |
+
};
|
525 |
+
|
526 |
+
function checkEmail(emailAddress) {
|
527 |
+
var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
|
528 |
+
return pattern.test(emailAddress);
|
529 |
+
}
|
530 |
+
|
531 |
+
};
|
532 |
+
|
533 |
+
var instance = new PremiumAddonsNavigation();
|
534 |
+
|
535 |
+
instance.init();
|
536 |
+
|
537 |
+
})(jQuery);
|
admin/includes/templates/modules-settings.php
CHANGED
@@ -1,173 +1,173 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
use PremiumAddons\Includes\Helper_Functions;
|
8 |
-
|
9 |
-
$elements = self::get_elements_list();
|
10 |
-
|
11 |
-
$used_widgets = self::get_used_widgets();
|
12 |
-
|
13 |
-
// Get elements settings
|
14 |
-
$enabled_elements = self::get_enabled_elements();
|
15 |
-
|
16 |
-
$global_btn = get_option( 'pa_global_btn_value', 'true' );
|
17 |
-
$enable_btn = 'true' === $global_btn ? 'active' : '';
|
18 |
-
$disable_btn = 'true' === $global_btn ? '' : 'active';
|
19 |
-
|
20 |
-
$row_meta = Helper_Functions::is_hide_row_meta();
|
21 |
-
|
22 |
-
?>
|
23 |
-
|
24 |
-
<div class="pa-section-content">
|
25 |
-
<div class="row">
|
26 |
-
<div class="col-full">
|
27 |
-
<form action="" method="POST" id="pa-settings" name="pa-settings" class="pa-settings-form">
|
28 |
-
<div id="pa-modules" class="pa-settings-tab">
|
29 |
-
|
30 |
-
<div class="pa-section-outer-wrap">
|
31 |
-
<div class="pa-section-info-wrap">
|
32 |
-
<div class="pa-section-info">
|
33 |
-
<h4><?php echo __( 'Dynamic Assets Generate', 'premium-addons-for-elementor' ); ?></h4>
|
34 |
-
<p><?php echo __( 'Generates CSS/JS files dynamically for each page based on the elements in it. Enable this setting for better performance (recommended).', 'premium-addons-for-elementor' ); ?></p>
|
35 |
-
</div>
|
36 |
-
|
37 |
-
<div class="pa-section-info-cta">
|
38 |
-
<label class="switch">
|
39 |
-
<input type="checkbox" id="premium-assets-generator" name="premium-assets-generator" <?php echo checked( 1, $enabled_elements['premium-assets-generator'], false ); ?>>
|
40 |
-
<span class="slider round"></span>
|
41 |
-
</label>
|
42 |
-
<?php if ( $enabled_elements['premium-assets-generator'] ) : ?>
|
43 |
-
<button type="button" class="pa-btn-regenerate" title="<?php esc_html_e( 'Clear Generated Assets', 'premium-addons-for-elementor' ); ?>">
|
44 |
-
<i class="dashicons dashicons-image-rotate"></i>
|
45 |
-
</button>
|
46 |
-
<?php endif; ?>
|
47 |
-
</div>
|
48 |
-
|
49 |
-
</div>
|
50 |
-
</div>
|
51 |
-
|
52 |
-
<div class="pa-section-info-wrap">
|
53 |
-
<div class="pa-section-info">
|
54 |
-
<h4><?php echo __( 'Master Switch', 'premium-addons-for-elementor' ); ?></h4>
|
55 |
-
<p><?php echo __( 'Use this to switch on or off ALL Widgets & Add-ons at once.', 'premium-addons-for-elementor' ); ?></p>
|
56 |
-
</div>
|
57 |
-
|
58 |
-
<div class="pa-btn-group">
|
59 |
-
<button type="button" class="pa-btn pa-btn-enable <?php echo esc_attr( $enable_btn ); ?>"><?php echo __( 'Switch On', 'premium-addons-for-elementor' ); ?></button>
|
60 |
-
<button type="button" class="pa-btn pa-btn-disable <?php echo esc_attr( $disable_btn ); ?>"><?php echo __( 'Switch Off', 'premium-addons-for-elementor' ); ?></button>
|
61 |
-
<?php if ( false !== $used_widgets ) { ?>
|
62 |
-
<button type="button" class="pa-btn-unused"><?php echo __( 'Disable Unused Widgets', 'premium-addons-for-elementor' ); ?></button>
|
63 |
-
<?php } ?>
|
64 |
-
</div>
|
65 |
-
</div>
|
66 |
-
|
67 |
-
<div class="pa-elements-settings">
|
68 |
-
|
69 |
-
<div class="pa-elements-filter">
|
70 |
-
<label for="premium-elements-filter"><?php _e( 'Filter Widgets', 'premium-addons-for-elementor' ); ?></label>
|
71 |
-
<input type="text" placeholder="<?php _e( 'Search by name...', 'premium-addons-for-elementor' ); ?>">
|
72 |
-
<select name="premium-elements-filter" id="premium-elements-filter" class="placeholder placeholder-active">
|
73 |
-
<option value=""><?php _e( 'All Widgets', 'premium-addons-for-elementor' ); ?></option>
|
74 |
-
<option value="free"><?php _e( 'Free Widgets', 'premium-addons-for-elementor' ); ?></option>
|
75 |
-
<option value="pro"><?php _e( 'PRO Widgets', 'premium-addons-for-elementor' ); ?></option>
|
76 |
-
</select>
|
77 |
-
</div>
|
78 |
-
|
79 |
-
<div class="pa-elements-tabs">
|
80 |
-
<ul class="pa-elements-tabs-list">
|
81 |
-
<?php
|
82 |
-
foreach ( $elements as $index => $cat ) :
|
83 |
-
if ( 'cat-11' !== $index ) :
|
84 |
-
?>
|
85 |
-
<li class="pa-elements-tab">
|
86 |
-
<a class="pa-elements-tab-link" href="pa-elements-tab-<?php echo $index; ?>">
|
87 |
-
<i class="<?php echo esc_attr( 'pa-dash-cat-' . $cat['icon'] ); ?>"></i>
|
88 |
-
</a>
|
89 |
-
<span class="pa-element-tab-tooltip"><?php echo esc_html( $cat['title'] ); ?></span>
|
90 |
-
</li>
|
91 |
-
<?php endif; ?>
|
92 |
-
<?php endforeach; ?>
|
93 |
-
</ul>
|
94 |
-
</div>
|
95 |
-
|
96 |
-
<?php
|
97 |
-
foreach ( $elements as $index => $cat ) :
|
98 |
-
if ( 'cat-11' !== $index ) :
|
99 |
-
?>
|
100 |
-
<div id="pa-elements-tab-<?php echo $index; ?>" class="pa-switchers-container hidden">
|
101 |
-
<h3 class="pa-elements-tab-title"><?php echo __( $cat['title'] ); ?></h3>
|
102 |
-
<div class="pa-switchers">
|
103 |
-
<?php
|
104 |
-
foreach ( $cat['elements'] as $index => $elem ) :
|
105 |
-
$status = ( isset( $elem['is_pro'] ) && ! Helper_Functions::check_papro_version() ) ? 'disabled' : checked( 1, $enabled_elements[ $elem['key'] ], false );
|
106 |
-
$class = ( isset( $elem['is_pro'] ) && ! Helper_Functions::check_papro_version() ) ? 'pro-' : '';
|
107 |
-
$switcher_class = $class . 'slider round';
|
108 |
-
?>
|
109 |
-
<div class="pa-switcher
|
110 |
-
<?php
|
111 |
-
echo isset( $elem['is_pro'] ) ? 'pro-element' : '';
|
112 |
-
echo isset( $elem['name'] ) ? ' ' . $elem['name'] : '';
|
113 |
-
?>
|
114 |
-
">
|
115 |
-
<div class="pa-element-info">
|
116 |
-
<div class="pa-element-icon-wrap">
|
117 |
-
<i class="pa-dash-<?php echo esc_attr( $elem['key'] ); ?> pa-element-icon"></i>
|
118 |
-
</div>
|
119 |
-
<div class="pa-element-meta-wrap">
|
120 |
-
<p class="pa-element-name">
|
121 |
-
<?php echo $elem['title']; ?>
|
122 |
-
<span class="pa-total-use" title="Total Use">
|
123 |
-
<?php
|
124 |
-
if ( ! isset( $elem['is_global'] ) && is_array( $used_widgets ) ) {
|
125 |
-
echo esc_html__( in_array( $elem['name'], array_keys( $used_widgets ) ) ? '(' . $used_widgets[ $elem['name'] ] . ')' : '(0)' );}
|
126 |
-
?>
|
127 |
-
</span>
|
128 |
-
<?php if ( isset( $elem['is_pro'] ) ) : ?>
|
129 |
-
<span><?php echo __( 'pro', 'premium-addons-for-elementor' ); ?></span>
|
130 |
-
<?php endif; ?>
|
131 |
-
</p>
|
132 |
-
<?php if ( ! $row_meta ) : ?>
|
133 |
-
<div>
|
134 |
-
<?php if ( isset( $elem['demo'] ) ) : ?>
|
135 |
-
<a class="pa-element-link" href="<?php echo esc_url( $elem['demo'] ); ?>" target="_blank">
|
136 |
-
<?php echo __( 'Live Demo', 'premium-addons-for-elementor' ); ?>
|
137 |
-
<span class="pa-element-link-separator"></span>
|
138 |
-
</a>
|
139 |
-
<?php endif; ?>
|
140 |
-
<?php if ( isset( $elem['doc'] ) ) : ?>
|
141 |
-
<a class="pa-element-link" href="<?php echo esc_url( $elem['doc'] ); ?>" target="_blank">
|
142 |
-
<?php echo __( 'Docs', 'premium-addons-for-elementor' ); ?>
|
143 |
-
<?php if ( isset( $elem['tutorial'] ) ) : ?>
|
144 |
-
<span class="pa-element-link-separator"></span>
|
145 |
-
<?php endif; ?>
|
146 |
-
</a>
|
147 |
-
<?php endif; ?>
|
148 |
-
<?php if ( isset( $elem['tutorial'] ) ) : ?>
|
149 |
-
<a class="pa-element-link" href="<?php echo esc_url( $elem['tutorial'] ); ?>" target="_blank">
|
150 |
-
<?php echo __( 'Video Tutorial', 'premium-addons-for-elementor' ); ?>
|
151 |
-
</a>
|
152 |
-
<?php endif; ?>
|
153 |
-
</div>
|
154 |
-
<?php endif; ?>
|
155 |
-
</div>
|
156 |
-
</div>
|
157 |
-
<label class="switch">
|
158 |
-
<input type="checkbox" id="<?php echo esc_attr( $elem['key'] ); ?>" name="<?php echo esc_attr( $elem['key'] ); ?>" <?php echo $status; ?>>
|
159 |
-
<span class="<?php echo esc_attr( $switcher_class ); ?>"></span>
|
160 |
-
</label>
|
161 |
-
</div>
|
162 |
-
<?php endforeach; ?>
|
163 |
-
</div>
|
164 |
-
</div>
|
165 |
-
<?php endif; ?>
|
166 |
-
<?php endforeach; ?>
|
167 |
-
</div>
|
168 |
-
|
169 |
-
</div>
|
170 |
-
</form> <!-- End Form -->
|
171 |
-
</div>
|
172 |
-
</div>
|
173 |
-
</div> <!-- End Section Content -->
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
use PremiumAddons\Includes\Helper_Functions;
|
8 |
+
|
9 |
+
$elements = self::get_elements_list();
|
10 |
+
|
11 |
+
$used_widgets = self::get_used_widgets();
|
12 |
+
|
13 |
+
// Get elements settings
|
14 |
+
$enabled_elements = self::get_enabled_elements();
|
15 |
+
|
16 |
+
$global_btn = get_option( 'pa_global_btn_value', 'true' );
|
17 |
+
$enable_btn = 'true' === $global_btn ? 'active' : '';
|
18 |
+
$disable_btn = 'true' === $global_btn ? '' : 'active';
|
19 |
+
|
20 |
+
$row_meta = Helper_Functions::is_hide_row_meta();
|
21 |
+
|
22 |
+
?>
|
23 |
+
|
24 |
+
<div class="pa-section-content">
|
25 |
+
<div class="row">
|
26 |
+
<div class="col-full">
|
27 |
+
<form action="" method="POST" id="pa-settings" name="pa-settings" class="pa-settings-form">
|
28 |
+
<div id="pa-modules" class="pa-settings-tab">
|
29 |
+
|
30 |
+
<div class="pa-section-outer-wrap">
|
31 |
+
<div class="pa-section-info-wrap">
|
32 |
+
<div class="pa-section-info">
|
33 |
+
<h4><?php echo __( 'Dynamic Assets Generate', 'premium-addons-for-elementor' ); ?></h4>
|
34 |
+
<p><?php echo __( 'Generates CSS/JS files dynamically for each page based on the elements in it. Enable this setting for better performance (recommended).', 'premium-addons-for-elementor' ); ?></p>
|
35 |
+
</div>
|
36 |
+
|
37 |
+
<div class="pa-section-info-cta">
|
38 |
+
<label class="switch">
|
39 |
+
<input type="checkbox" id="premium-assets-generator" name="premium-assets-generator" <?php echo checked( 1, $enabled_elements['premium-assets-generator'], false ); ?>>
|
40 |
+
<span class="slider round"></span>
|
41 |
+
</label>
|
42 |
+
<?php if ( $enabled_elements['premium-assets-generator'] ) : ?>
|
43 |
+
<button type="button" class="pa-btn-regenerate" title="<?php esc_html_e( 'Clear Generated Assets', 'premium-addons-for-elementor' ); ?>">
|
44 |
+
<i class="dashicons dashicons-image-rotate"></i>
|
45 |
+
</button>
|
46 |
+
<?php endif; ?>
|
47 |
+
</div>
|
48 |
+
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<div class="pa-section-info-wrap">
|
53 |
+
<div class="pa-section-info">
|
54 |
+
<h4><?php echo __( 'Master Switch', 'premium-addons-for-elementor' ); ?></h4>
|
55 |
+
<p><?php echo __( 'Use this to switch on or off ALL Widgets & Add-ons at once.', 'premium-addons-for-elementor' ); ?></p>
|
56 |
+
</div>
|
57 |
+
|
58 |
+
<div class="pa-btn-group">
|
59 |
+
<button type="button" class="pa-btn pa-btn-enable <?php echo esc_attr( $enable_btn ); ?>"><?php echo __( 'Switch On', 'premium-addons-for-elementor' ); ?></button>
|
60 |
+
<button type="button" class="pa-btn pa-btn-disable <?php echo esc_attr( $disable_btn ); ?>"><?php echo __( 'Switch Off', 'premium-addons-for-elementor' ); ?></button>
|
61 |
+
<?php if ( false !== $used_widgets ) { ?>
|
62 |
+
<button type="button" class="pa-btn-unused"><?php echo __( 'Disable Unused Widgets', 'premium-addons-for-elementor' ); ?></button>
|
63 |
+
<?php } ?>
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
<div class="pa-elements-settings">
|
68 |
+
|
69 |
+
<div class="pa-elements-filter">
|
70 |
+
<label for="premium-elements-filter"><?php _e( 'Filter Widgets', 'premium-addons-for-elementor' ); ?></label>
|
71 |
+
<input type="text" placeholder="<?php _e( 'Search by name...', 'premium-addons-for-elementor' ); ?>">
|
72 |
+
<select name="premium-elements-filter" id="premium-elements-filter" class="placeholder placeholder-active">
|
73 |
+
<option value=""><?php _e( 'All Widgets', 'premium-addons-for-elementor' ); ?></option>
|
74 |
+
<option value="free"><?php _e( 'Free Widgets', 'premium-addons-for-elementor' ); ?></option>
|
75 |
+
<option value="pro"><?php _e( 'PRO Widgets', 'premium-addons-for-elementor' ); ?></option>
|
76 |
+
</select>
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<div class="pa-elements-tabs">
|
80 |
+
<ul class="pa-elements-tabs-list">
|
81 |
+
<?php
|
82 |
+
foreach ( $elements as $index => $cat ) :
|
83 |
+
if ( 'cat-11' !== $index ) :
|
84 |
+
?>
|
85 |
+
<li class="pa-elements-tab">
|
86 |
+
<a class="pa-elements-tab-link" href="pa-elements-tab-<?php echo $index; ?>">
|
87 |
+
<i class="<?php echo esc_attr( 'pa-dash-cat-' . $cat['icon'] ); ?>"></i>
|
88 |
+
</a>
|
89 |
+
<span class="pa-element-tab-tooltip"><?php echo esc_html( $cat['title'] ); ?></span>
|
90 |
+
</li>
|
91 |
+
<?php endif; ?>
|
92 |
+
<?php endforeach; ?>
|
93 |
+
</ul>
|
94 |
+
</div>
|
95 |
+
|
96 |
+
<?php
|
97 |
+
foreach ( $elements as $index => $cat ) :
|
98 |
+
if ( 'cat-11' !== $index ) :
|
99 |
+
?>
|
100 |
+
<div id="pa-elements-tab-<?php echo $index; ?>" class="pa-switchers-container hidden">
|
101 |
+
<h3 class="pa-elements-tab-title"><?php echo __( $cat['title'] ); ?></h3>
|
102 |
+
<div class="pa-switchers">
|
103 |
+
<?php
|
104 |
+
foreach ( $cat['elements'] as $index => $elem ) :
|
105 |
+
$status = ( isset( $elem['is_pro'] ) && ! Helper_Functions::check_papro_version() ) ? 'disabled' : checked( 1, $enabled_elements[ $elem['key'] ], false );
|
106 |
+
$class = ( isset( $elem['is_pro'] ) && ! Helper_Functions::check_papro_version() ) ? 'pro-' : '';
|
107 |
+
$switcher_class = $class . 'slider round';
|
108 |
+
?>
|
109 |
+
<div class="pa-switcher
|
110 |
+
<?php
|
111 |
+
echo isset( $elem['is_pro'] ) ? 'pro-element' : '';
|
112 |
+
echo isset( $elem['name'] ) ? ' ' . $elem['name'] : '';
|
113 |
+
?>
|
114 |
+
">
|
115 |
+
<div class="pa-element-info">
|
116 |
+
<div class="pa-element-icon-wrap">
|
117 |
+
<i class="pa-dash-<?php echo esc_attr( $elem['key'] ); ?> pa-element-icon"></i>
|
118 |
+
</div>
|
119 |
+
<div class="pa-element-meta-wrap">
|
120 |
+
<p class="pa-element-name">
|
121 |
+
<?php echo $elem['title']; ?>
|
122 |
+
<span class="pa-total-use" title="Total Use">
|
123 |
+
<?php
|
124 |
+
if ( ! isset( $elem['is_global'] ) && is_array( $used_widgets ) ) {
|
125 |
+
echo esc_html__( in_array( $elem['name'], array_keys( $used_widgets ) ) ? '(' . $used_widgets[ $elem['name'] ] . ')' : '(0)' );}
|
126 |
+
?>
|
127 |
+
</span>
|
128 |
+
<?php if ( isset( $elem['is_pro'] ) ) : ?>
|
129 |
+
<span><?php echo __( 'pro', 'premium-addons-for-elementor' ); ?></span>
|
130 |
+
<?php endif; ?>
|
131 |
+
</p>
|
132 |
+
<?php if ( ! $row_meta ) : ?>
|
133 |
+
<div>
|
134 |
+
<?php if ( isset( $elem['demo'] ) ) : ?>
|
135 |
+
<a class="pa-element-link" href="<?php echo esc_url( $elem['demo'] ); ?>" target="_blank">
|
136 |
+
<?php echo __( 'Live Demo', 'premium-addons-for-elementor' ); ?>
|
137 |
+
<span class="pa-element-link-separator"></span>
|
138 |
+
</a>
|
139 |
+
<?php endif; ?>
|
140 |
+
<?php if ( isset( $elem['doc'] ) ) : ?>
|
141 |
+
<a class="pa-element-link" href="<?php echo esc_url( $elem['doc'] ); ?>" target="_blank">
|
142 |
+
<?php echo __( 'Docs', 'premium-addons-for-elementor' ); ?>
|
143 |
+
<?php if ( isset( $elem['tutorial'] ) ) : ?>
|
144 |
+
<span class="pa-element-link-separator"></span>
|
145 |
+
<?php endif; ?>
|
146 |
+
</a>
|
147 |
+
<?php endif; ?>
|
148 |
+
<?php if ( isset( $elem['tutorial'] ) ) : ?>
|
149 |
+
<a class="pa-element-link" href="<?php echo esc_url( $elem['tutorial'] ); ?>" target="_blank">
|
150 |
+
<?php echo __( 'Video Tutorial', 'premium-addons-for-elementor' ); ?>
|
151 |
+
</a>
|
152 |
+
<?php endif; ?>
|
153 |
+
</div>
|
154 |
+
<?php endif; ?>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
<label class="switch">
|
158 |
+
<input type="checkbox" id="<?php echo esc_attr( $elem['key'] ); ?>" name="<?php echo esc_attr( $elem['key'] ); ?>" <?php echo $status; ?>>
|
159 |
+
<span class="<?php echo esc_attr( $switcher_class ); ?>"></span>
|
160 |
+
</label>
|
161 |
+
</div>
|
162 |
+
<?php endforeach; ?>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
<?php endif; ?>
|
166 |
+
<?php endforeach; ?>
|
167 |
+
</div>
|
168 |
+
|
169 |
+
</div>
|
170 |
+
</form> <!-- End Form -->
|
171 |
+
</div>
|
172 |
+
</div>
|
173 |
+
</div> <!-- End Section Content -->
|
assets/editor/templates/js/editor.js
CHANGED
@@ -1,1062 +1,1062 @@
|
|
1 |
-
(function ($) {
|
2 |
-
|
3 |
-
'use strict';
|
4 |
-
|
5 |
-
var PremiumTempsData = window.PremiumTempsData || {},
|
6 |
-
PremiumEditor,
|
7 |
-
PremiumEditorViews,
|
8 |
-
PremiumControlsViews,
|
9 |
-
PremiumModules;
|
10 |
-
|
11 |
-
PremiumEditorViews = {
|
12 |
-
|
13 |
-
ModalLayoutView: null,
|
14 |
-
ModalHeaderView: null,
|
15 |
-
ModalHeaderInsertButton: null,
|
16 |
-
ModalLoadingView: null,
|
17 |
-
ModalBodyView: null,
|
18 |
-
ModalErrorView: null,
|
19 |
-
LibraryCollection: null,
|
20 |
-
KeywordsModel: null,
|
21 |
-
ModalCollectionView: null,
|
22 |
-
ModalTabsCollection: null,
|
23 |
-
ModalTabsCollectionView: null,
|
24 |
-
FiltersCollectionView: null,
|
25 |
-
FiltersItemView: null,
|
26 |
-
ModalTabsItemView: null,
|
27 |
-
ModalTemplateItemView: null,
|
28 |
-
ModalInsertTemplateBehavior: null,
|
29 |
-
ModalTemplateModel: null,
|
30 |
-
CategoriesCollection: null,
|
31 |
-
ModalPreviewView: null,
|
32 |
-
ModalHeaderBack: null,
|
33 |
-
ModalHeaderLogo: null,
|
34 |
-
KeywordsView: null,
|
35 |
-
TabModel: null,
|
36 |
-
CategoryModel: null,
|
37 |
-
|
38 |
-
init: function () {
|
39 |
-
var self = this;
|
40 |
-
|
41 |
-
self.ModalTemplateModel = Backbone.Model.extend({
|
42 |
-
defaults: {
|
43 |
-
template_id: 0,
|
44 |
-
name: '',
|
45 |
-
title: '',
|
46 |
-
thumbnail: '',
|
47 |
-
preview: '',
|
48 |
-
source: '',
|
49 |
-
categories: [],
|
50 |
-
keywords: []
|
51 |
-
}
|
52 |
-
});
|
53 |
-
|
54 |
-
self.ModalHeaderView = Marionette.LayoutView.extend({
|
55 |
-
|
56 |
-
id: 'premium-template-modal-header',
|
57 |
-
template: '#tmpl-premium-template-modal-header',
|
58 |
-
|
59 |
-
ui: {
|
60 |
-
closeModal: '#premium-template-modal-header-close-modal'
|
61 |
-
},
|
62 |
-
|
63 |
-
events: {
|
64 |
-
'click @ui.closeModal': 'onCloseModalClick'
|
65 |
-
},
|
66 |
-
|
67 |
-
regions: {
|
68 |
-
headerLogo: '#premium-template-modal-header-logo-area',
|
69 |
-
headerTabs: '#premium-template-modal-header-tabs',
|
70 |
-
headerActions: '#premium-template-modal-header-actions'
|
71 |
-
},
|
72 |
-
|
73 |
-
onCloseModalClick: function () {
|
74 |
-
PremiumEditor.closeModal();
|
75 |
-
}
|
76 |
-
|
77 |
-
});
|
78 |
-
|
79 |
-
self.TabModel = Backbone.Model.extend({
|
80 |
-
defaults: {
|
81 |
-
slug: '',
|
82 |
-
title: ''
|
83 |
-
}
|
84 |
-
});
|
85 |
-
|
86 |
-
self.LibraryCollection = Backbone.Collection.extend({
|
87 |
-
model: self.ModalTemplateModel
|
88 |
-
});
|
89 |
-
|
90 |
-
self.ModalTabsCollection = Backbone.Collection.extend({
|
91 |
-
model: self.TabModel
|
92 |
-
});
|
93 |
-
|
94 |
-
self.CategoryModel = Backbone.Model.extend({
|
95 |
-
defaults: {
|
96 |
-
slug: '',
|
97 |
-
title: ''
|
98 |
-
}
|
99 |
-
});
|
100 |
-
|
101 |
-
self.KeywordsModel = Backbone.Model.extend({
|
102 |
-
defaults: {
|
103 |
-
keywords: {}
|
104 |
-
}
|
105 |
-
});
|
106 |
-
|
107 |
-
self.CategoriesCollection = Backbone.Collection.extend({
|
108 |
-
model: self.CategoryModel
|
109 |
-
});
|
110 |
-
|
111 |
-
self.KeywordsView = Marionette.ItemView.extend({
|
112 |
-
id: 'elementor-template-library-filter',
|
113 |
-
template: '#tmpl-premium-template-modal-keywords',
|
114 |
-
ui: {
|
115 |
-
keywords: '.premium-library-keywords'
|
116 |
-
},
|
117 |
-
|
118 |
-
events: {
|
119 |
-
'change @ui.keywords': 'onSelectKeyword'
|
120 |
-
},
|
121 |
-
|
122 |
-
onSelectKeyword: function (event) {
|
123 |
-
var selected = event.currentTarget.selectedOptions[0].value;
|
124 |
-
PremiumEditor.setFilter('keyword', selected);
|
125 |
-
},
|
126 |
-
|
127 |
-
onRender: function () {
|
128 |
-
var $filters = this.$('.premium-library-keywords');
|
129 |
-
$filters.select2({
|
130 |
-
placeholder: 'Choose Widget',
|
131 |
-
allowClear: true,
|
132 |
-
width: 250,
|
133 |
-
dropdownParent: this.$el
|
134 |
-
});
|
135 |
-
}
|
136 |
-
});
|
137 |
-
|
138 |
-
self.ModalPreviewView = Marionette.ItemView.extend({
|
139 |
-
|
140 |
-
template: '#tmpl-premium-template-modal-preview',
|
141 |
-
|
142 |
-
id: 'premium-templatate-item-preview-wrap',
|
143 |
-
|
144 |
-
ui: {
|
145 |
-
iframe: 'iframe',
|
146 |
-
notice: '.premium-template-item-notice'
|
147 |
-
},
|
148 |
-
|
149 |
-
|
150 |
-
onRender: function () {
|
151 |
-
|
152 |
-
if (null !== this.getOption('notice')) {
|
153 |
-
if (this.getOption('notice').length) {
|
154 |
-
var message = "";
|
155 |
-
if (-1 !== this.getOption('notice').indexOf("facebook")) {
|
156 |
-
message += "<p>Please login with your Facebook account in order to get your Facebook Reviews.</p>";
|
157 |
-
} else if (-1 !== this.getOption('notice').indexOf("google")) {
|
158 |
-
message += "<p>You need to add your Google API key from Dashboard -> Premium Add-ons for Elementor -> Google Maps</p>";
|
159 |
-
} else if (-1 !== this.getOption('notice').indexOf("form")) {
|
160 |
-
message += "<p>You need to have <a href='https://wordpress.org/plugins/contact-form-7/' target='_blank'>Contact Form 7 plugin</a> installed and active.</p>";
|
161 |
-
}
|
162 |
-
|
163 |
-
this.ui.notice.html('<div><p><strong>Important!</strong></p>' + message + '</div>');
|
164 |
-
}
|
165 |
-
}
|
166 |
-
|
167 |
-
this.ui.iframe.attr('src', this.getOption('url'));
|
168 |
-
|
169 |
-
}
|
170 |
-
});
|
171 |
-
|
172 |
-
self.ModalHeaderBack = Marionette.ItemView.extend({
|
173 |
-
|
174 |
-
template: '#tmpl-premium-template-modal-header-back',
|
175 |
-
|
176 |
-
id: 'premium-template-modal-header-back',
|
177 |
-
|
178 |
-
ui: {
|
179 |
-
button: 'button'
|
180 |
-
},
|
181 |
-
|
182 |
-
events: {
|
183 |
-
'click @ui.button': 'onBackClick',
|
184 |
-
},
|
185 |
-
|
186 |
-
onBackClick: function () {
|
187 |
-
PremiumEditor.setPreview('back');
|
188 |
-
}
|
189 |
-
|
190 |
-
});
|
191 |
-
|
192 |
-
self.ModalHeaderLogo = Marionette.ItemView.extend({
|
193 |
-
|
194 |
-
template: '#tmpl-premium-template-modal-header-logo',
|
195 |
-
|
196 |
-
id: 'premium-template-modal-header-logo'
|
197 |
-
|
198 |
-
});
|
199 |
-
|
200 |
-
self.ModalBodyView = Marionette.LayoutView.extend({
|
201 |
-
|
202 |
-
id: 'premium-template-library-content',
|
203 |
-
|
204 |
-
className: function () {
|
205 |
-
return 'library-tab-' + PremiumEditor.getTab();
|
206 |
-
},
|
207 |
-
|
208 |
-
template: '#tmpl-premium-template-modal-content',
|
209 |
-
|
210 |
-
regions: {
|
211 |
-
contentTemplates: '.premium-templates-list',
|
212 |
-
contentFilters: '.premium-filters-list',
|
213 |
-
contentKeywords: '.premium-keywords-list'
|
214 |
-
}
|
215 |
-
|
216 |
-
});
|
217 |
-
|
218 |
-
self.ModalInsertTemplateBehavior = Marionette.Behavior.extend({
|
219 |
-
ui: {
|
220 |
-
insertButtons: ['.premium-template-insert', '.premium-template-insert-no-media'],
|
221 |
-
},
|
222 |
-
|
223 |
-
events: {
|
224 |
-
'click @ui.insertButtons': 'onInsertButtonClick'
|
225 |
-
},
|
226 |
-
|
227 |
-
onInsertButtonClick: function (event) {
|
228 |
-
|
229 |
-
var templateModel = this.view.model,
|
230 |
-
innerTemplates = templateModel.attributes.dependencies,
|
231 |
-
isPro = templateModel.attributes.pro,
|
232 |
-
innerTemplatesLength = Object.keys(innerTemplates).length,
|
233 |
-
options = {},
|
234 |
-
insertMedia = !$(event.currentTarget).hasClass("premium-template-insert-no-media");
|
235 |
-
|
236 |
-
// console.log(insertMedia);
|
237 |
-
|
238 |
-
PremiumEditor.layout.showLoadingView();
|
239 |
-
if (innerTemplatesLength > 0) {
|
240 |
-
for (var key in innerTemplates) {
|
241 |
-
$.ajax({
|
242 |
-
url: ajaxurl,
|
243 |
-
type: 'post',
|
244 |
-
dataType: 'json',
|
245 |
-
data: {
|
246 |
-
action: 'premium_inner_template',
|
247 |
-
template: innerTemplates[key],
|
248 |
-
tab: PremiumEditor.getTab(),
|
249 |
-
withMedia: insertMedia
|
250 |
-
}
|
251 |
-
});
|
252 |
-
}
|
253 |
-
}
|
254 |
-
|
255 |
-
if ("valid" === PremiumTempsData.license.status || !isPro) {
|
256 |
-
|
257 |
-
elementor.templates.requestTemplateContent(
|
258 |
-
templateModel.get('source'),
|
259 |
-
templateModel.get('template_id'), {
|
260 |
-
data: {
|
261 |
-
tab: PremiumEditor.getTab(),
|
262 |
-
page_settings: false,
|
263 |
-
withMedia: insertMedia
|
264 |
-
},
|
265 |
-
success: function (data) {
|
266 |
-
|
267 |
-
if (!data.license) {
|
268 |
-
PremiumEditor.layout.showLicenseError();
|
269 |
-
return;
|
270 |
-
}
|
271 |
-
|
272 |
-
console.log("%c Template Inserted Successfully!!", "color: #7a7a7a; background-color: #eee;");
|
273 |
-
|
274 |
-
PremiumEditor.closeModal();
|
275 |
-
|
276 |
-
elementor.channels.data.trigger('template:before:insert', templateModel);
|
277 |
-
|
278 |
-
if (null !== PremiumEditor.atIndex) {
|
279 |
-
options.at = PremiumEditor.atIndex;
|
280 |
-
}
|
281 |
-
|
282 |
-
elementor.previewView.addChildModel(data.content, options);
|
283 |
-
|
284 |
-
elementor.channels.data.trigger('template:after:insert', templateModel);
|
285 |
-
jQuery("#elementor-panel-saver-button-save-options, #elementor-panel-saver-button-publish").removeClass("elementor-disabled");
|
286 |
-
PremiumEditor.atIndex = null;
|
287 |
-
|
288 |
-
},
|
289 |
-
error: function (err) {
|
290 |
-
console.log(err);
|
291 |
-
}
|
292 |
-
}
|
293 |
-
);
|
294 |
-
} else {
|
295 |
-
PremiumEditor.layout.showLicenseError();
|
296 |
-
}
|
297 |
-
}
|
298 |
-
});
|
299 |
-
|
300 |
-
self.ModalHeaderInsertButton = Marionette.ItemView.extend({
|
301 |
-
|
302 |
-
template: '#tmpl-premium-template-modal-insert-button',
|
303 |
-
|
304 |
-
id: 'premium-template-modal-insert-button',
|
305 |
-
|
306 |
-
behaviors: {
|
307 |
-
insertTemplate: {
|
308 |
-
behaviorClass: self.ModalInsertTemplateBehavior
|
309 |
-
}
|
310 |
-
}
|
311 |
-
|
312 |
-
});
|
313 |
-
|
314 |
-
self.FiltersItemView = Marionette.ItemView.extend({
|
315 |
-
|
316 |
-
template: '#tmpl-premium-template-modal-filters-item',
|
317 |
-
|
318 |
-
className: function () {
|
319 |
-
return 'premium-template-filter-item';
|
320 |
-
},
|
321 |
-
|
322 |
-
ui: function () {
|
323 |
-
return {
|
324 |
-
filterLabels: '.premium-template-filter-label'
|
325 |
-
};
|
326 |
-
},
|
327 |
-
|
328 |
-
events: function () {
|
329 |
-
return {
|
330 |
-
'click @ui.filterLabels': 'onFilterClick'
|
331 |
-
};
|
332 |
-
},
|
333 |
-
|
334 |
-
onFilterClick: function (event) {
|
335 |
-
|
336 |
-
var $clickedInput = jQuery(event.target);
|
337 |
-
jQuery('.premium-library-keywords').val('');
|
338 |
-
PremiumEditor.setFilter('category', $clickedInput.val());
|
339 |
-
PremiumEditor.setFilter('keyword', '');
|
340 |
-
}
|
341 |
-
|
342 |
-
});
|
343 |
-
|
344 |
-
self.ModalTabsItemView = Marionette.ItemView.extend({
|
345 |
-
|
346 |
-
template: '#tmpl-premium-template-modal-tabs-item',
|
347 |
-
|
348 |
-
className: function () {
|
349 |
-
return 'elementor-template-library-menu-item';
|
350 |
-
},
|
351 |
-
|
352 |
-
ui: function () {
|
353 |
-
return {
|
354 |
-
tabsLabels: 'label',
|
355 |
-
tabsInput: 'input'
|
356 |
-
};
|
357 |
-
},
|
358 |
-
|
359 |
-
events: function () {
|
360 |
-
return {
|
361 |
-
'click @ui.tabsLabels': 'onTabClick'
|
362 |
-
};
|
363 |
-
},
|
364 |
-
|
365 |
-
onRender: function () {
|
366 |
-
if (this.model.get('slug') === PremiumEditor.getTab()) {
|
367 |
-
this.ui.tabsInput.attr('checked', 'checked');
|
368 |
-
}
|
369 |
-
},
|
370 |
-
|
371 |
-
onTabClick: function (event) {
|
372 |
-
|
373 |
-
var $clickedInput = jQuery(event.target);
|
374 |
-
PremiumEditor.setTab($clickedInput.val());
|
375 |
-
PremiumEditor.setFilter('keyword', '');
|
376 |
-
}
|
377 |
-
|
378 |
-
});
|
379 |
-
|
380 |
-
self.FiltersCollectionView = Marionette.CompositeView.extend({
|
381 |
-
|
382 |
-
id: 'premium-template-library-filters',
|
383 |
-
|
384 |
-
template: '#tmpl-premium-template-modal-filters',
|
385 |
-
|
386 |
-
childViewContainer: '#premium-modal-filters-container',
|
387 |
-
|
388 |
-
getChildView: function (childModel) {
|
389 |
-
return self.FiltersItemView;
|
390 |
-
}
|
391 |
-
|
392 |
-
});
|
393 |
-
|
394 |
-
self.ModalTabsCollectionView = Marionette.CompositeView.extend({
|
395 |
-
|
396 |
-
template: '#tmpl-premium-template-modal-tabs',
|
397 |
-
|
398 |
-
childViewContainer: '#premium-modal-tabs-items',
|
399 |
-
|
400 |
-
initialize: function () {
|
401 |
-
this.listenTo(PremiumEditor.channels.layout, 'tamplate:cloned', this._renderChildren);
|
402 |
-
},
|
403 |
-
|
404 |
-
getChildView: function (childModel) {
|
405 |
-
return self.ModalTabsItemView;
|
406 |
-
}
|
407 |
-
|
408 |
-
});
|
409 |
-
|
410 |
-
self.ModalTemplateItemView = Marionette.ItemView.extend({
|
411 |
-
|
412 |
-
template: '#tmpl-premium-template-modal-item',
|
413 |
-
|
414 |
-
className: function () {
|
415 |
-
|
416 |
-
var urlClass = ' premium-template-has-url',
|
417 |
-
sourceClass = ' elementor-template-library-template-',
|
418 |
-
proTemplate = '';
|
419 |
-
|
420 |
-
if ('' === this.model.get('preview')) {
|
421 |
-
urlClass = ' premium-template-no-url';
|
422 |
-
}
|
423 |
-
|
424 |
-
sourceClass += 'remote';
|
425 |
-
|
426 |
-
if (this.model.get('pro')) {
|
427 |
-
proTemplate = ' premium-template-pro';
|
428 |
-
}
|
429 |
-
|
430 |
-
return 'elementor-template-library-template' + sourceClass + urlClass + proTemplate;
|
431 |
-
},
|
432 |
-
|
433 |
-
ui: function () {
|
434 |
-
return {
|
435 |
-
previewButton: '.elementor-template-library-template-preview',
|
436 |
-
};
|
437 |
-
},
|
438 |
-
|
439 |
-
events: function () {
|
440 |
-
return {
|
441 |
-
'click @ui.previewButton': 'onPreviewButtonClick',
|
442 |
-
};
|
443 |
-
},
|
444 |
-
|
445 |
-
onPreviewButtonClick: function () {
|
446 |
-
|
447 |
-
if ('' === this.model.get('url')) {
|
448 |
-
return;
|
449 |
-
}
|
450 |
-
|
451 |
-
PremiumEditor.setPreview(this.model);
|
452 |
-
},
|
453 |
-
|
454 |
-
behaviors: {
|
455 |
-
insertTemplate: {
|
456 |
-
behaviorClass: self.ModalInsertTemplateBehavior
|
457 |
-
}
|
458 |
-
}
|
459 |
-
});
|
460 |
-
|
461 |
-
self.ModalCollectionView = Marionette.CompositeView.extend({
|
462 |
-
|
463 |
-
template: '#tmpl-premium-template-modal-templates',
|
464 |
-
|
465 |
-
id: 'premium-template-library-templates',
|
466 |
-
|
467 |
-
childViewContainer: '#premium-modal-templates-container',
|
468 |
-
|
469 |
-
initialize: function () {
|
470 |
-
|
471 |
-
this.listenTo(PremiumEditor.channels.templates, 'filter:change', this._renderChildren);
|
472 |
-
},
|
473 |
-
|
474 |
-
filter: function (childModel) {
|
475 |
-
|
476 |
-
var filter = PremiumEditor.getFilter('category'),
|
477 |
-
keyword = PremiumEditor.getFilter('keyword');
|
478 |
-
|
479 |
-
if (!filter && !keyword) {
|
480 |
-
return true;
|
481 |
-
}
|
482 |
-
|
483 |
-
if (keyword && !filter) {
|
484 |
-
return _.contains(childModel.get('keywords'), keyword);
|
485 |
-
}
|
486 |
-
|
487 |
-
if (filter && !keyword) {
|
488 |
-
return _.contains(childModel.get('categories'), filter);
|
489 |
-
}
|
490 |
-
|
491 |
-
return _.contains(childModel.get('categories'), filter) && _.contains(childModel.get('keywords'), keyword);
|
492 |
-
|
493 |
-
},
|
494 |
-
|
495 |
-
getChildView: function (childModel) {
|
496 |
-
return self.ModalTemplateItemView;
|
497 |
-
},
|
498 |
-
|
499 |
-
onRenderCollection: function () {
|
500 |
-
|
501 |
-
var container = this.$childViewContainer,
|
502 |
-
items = this.$childViewContainer.children(),
|
503 |
-
tab = PremiumEditor.getTab();
|
504 |
-
|
505 |
-
if ('premium_page' === tab || 'local' === tab) {
|
506 |
-
return;
|
507 |
-
}
|
508 |
-
|
509 |
-
// Wait for thumbnails to be loaded
|
510 |
-
container.imagesLoaded(function () { }).done(function () {
|
511 |
-
self.masonry.init({
|
512 |
-
container: container,
|
513 |
-
items: items
|
514 |
-
});
|
515 |
-
});
|
516 |
-
}
|
517 |
-
|
518 |
-
});
|
519 |
-
|
520 |
-
self.ModalLayoutView = Marionette.LayoutView.extend({
|
521 |
-
|
522 |
-
el: '#premium-template-modal',
|
523 |
-
|
524 |
-
regions: PremiumTempsData.modalRegions,
|
525 |
-
|
526 |
-
initialize: function () {
|
527 |
-
|
528 |
-
this.getRegion('modalHeader').show(new self.ModalHeaderView());
|
529 |
-
this.listenTo(PremiumEditor.channels.tabs, 'filter:change', this.switchTabs);
|
530 |
-
this.listenTo(PremiumEditor.channels.layout, 'preview:change', this.switchPreview);
|
531 |
-
|
532 |
-
},
|
533 |
-
|
534 |
-
switchTabs: function () {
|
535 |
-
this.showLoadingView();
|
536 |
-
PremiumEditor.setFilter('keyword', '');
|
537 |
-
PremiumEditor.requestTemplates(PremiumEditor.getTab());
|
538 |
-
},
|
539 |
-
|
540 |
-
switchPreview: function () {
|
541 |
-
|
542 |
-
var header = this.getHeaderView(),
|
543 |
-
preview = PremiumEditor.getPreview();
|
544 |
-
|
545 |
-
var filter = PremiumEditor.getFilter('category'),
|
546 |
-
keyword = PremiumEditor.getFilter('keyword');
|
547 |
-
|
548 |
-
if ('back' === preview) {
|
549 |
-
header.headerLogo.show(new self.ModalHeaderLogo());
|
550 |
-
header.headerTabs.show(new self.ModalTabsCollectionView({
|
551 |
-
collection: PremiumEditor.collections.tabs
|
552 |
-
}));
|
553 |
-
|
554 |
-
header.headerActions.empty();
|
555 |
-
PremiumEditor.setTab(PremiumEditor.getTab());
|
556 |
-
|
557 |
-
if ('' != filter) {
|
558 |
-
PremiumEditor.setFilter('category', filter);
|
559 |
-
jQuery('#premium-modal-filters-container').find("input[value='" + filter + "']").prop('checked', true);
|
560 |
-
|
561 |
-
}
|
562 |
-
|
563 |
-
if ('' != keyword) {
|
564 |
-
PremiumEditor.setFilter('keyword', keyword);
|
565 |
-
}
|
566 |
-
|
567 |
-
return;
|
568 |
-
}
|
569 |
-
|
570 |
-
if ('initial' === preview) {
|
571 |
-
header.headerActions.empty();
|
572 |
-
header.headerLogo.show(new self.ModalHeaderLogo());
|
573 |
-
return;
|
574 |
-
}
|
575 |
-
|
576 |
-
this.getRegion('modalContent').show(new self.ModalPreviewView({
|
577 |
-
'preview': preview.get('preview'),
|
578 |
-
'url': preview.get('url'),
|
579 |
-
'notice': preview.get('notice')
|
580 |
-
}));
|
581 |
-
|
582 |
-
header.headerLogo.empty();
|
583 |
-
header.headerTabs.show(new self.ModalHeaderBack());
|
584 |
-
header.headerActions.show(new self.ModalHeaderInsertButton({
|
585 |
-
model: preview
|
586 |
-
}));
|
587 |
-
|
588 |
-
},
|
589 |
-
|
590 |
-
getHeaderView: function () {
|
591 |
-
return this.getRegion('modalHeader').currentView;
|
592 |
-
},
|
593 |
-
|
594 |
-
getContentView: function () {
|
595 |
-
return this.getRegion('modalContent').currentView;
|
596 |
-
},
|
597 |
-
|
598 |
-
showLoadingView: function () {
|
599 |
-
this.modalContent.show(new self.ModalLoadingView());
|
600 |
-
},
|
601 |
-
|
602 |
-
showLicenseError: function () {
|
603 |
-
this.modalContent.show(new self.ModalErrorView());
|
604 |
-
},
|
605 |
-
|
606 |
-
showTemplatesView: function (templatesCollection, categoriesCollection, keywords) {
|
607 |
-
|
608 |
-
this.getRegion('modalContent').show(new self.ModalBodyView());
|
609 |
-
|
610 |
-
var contentView = this.getContentView(),
|
611 |
-
header = this.getHeaderView(),
|
612 |
-
keywordsModel = new self.KeywordsModel({
|
613 |
-
keywords: keywords
|
614 |
-
});
|
615 |
-
|
616 |
-
PremiumEditor.collections.tabs = new self.ModalTabsCollection(PremiumEditor.getTabs());
|
617 |
-
|
618 |
-
header.headerTabs.show(new self.ModalTabsCollectionView({
|
619 |
-
collection: PremiumEditor.collections.tabs
|
620 |
-
}));
|
621 |
-
|
622 |
-
contentView.contentTemplates.show(new self.ModalCollectionView({
|
623 |
-
collection: templatesCollection
|
624 |
-
}));
|
625 |
-
|
626 |
-
contentView.contentFilters.show(new self.FiltersCollectionView({
|
627 |
-
collection: categoriesCollection
|
628 |
-
}));
|
629 |
-
|
630 |
-
contentView.contentKeywords.show(new self.KeywordsView({
|
631 |
-
model: keywordsModel
|
632 |
-
}));
|
633 |
-
|
634 |
-
}
|
635 |
-
|
636 |
-
});
|
637 |
-
|
638 |
-
self.ModalLoadingView = Marionette.ItemView.extend({
|
639 |
-
id: 'premium-template-modal-loading',
|
640 |
-
template: '#tmpl-premium-template-modal-loading'
|
641 |
-
});
|
642 |
-
|
643 |
-
self.ModalErrorView = Marionette.ItemView.extend({
|
644 |
-
id: 'premium-template-modal-loading',
|
645 |
-
template: '#tmpl-premium-template-modal-error'
|
646 |
-
});
|
647 |
-
|
648 |
-
},
|
649 |
-
|
650 |
-
masonry: {
|
651 |
-
|
652 |
-
self: {},
|
653 |
-
elements: {},
|
654 |
-
|
655 |
-
init: function (settings) {
|
656 |
-
|
657 |
-
var self = this;
|
658 |
-
self.settings = $.extend(self.getDefaultSettings(), settings);
|
659 |
-
self.elements = self.getDefaultElements();
|
660 |
-
|
661 |
-
self.run();
|
662 |
-
},
|
663 |
-
|
664 |
-
getSettings: function (key) {
|
665 |
-
if (key) {
|
666 |
-
return this.settings[key];
|
667 |
-
} else {
|
668 |
-
return this.settings;
|
669 |
-
}
|
670 |
-
},
|
671 |
-
|
672 |
-
getDefaultSettings: function () {
|
673 |
-
return {
|
674 |
-
container: null,
|
675 |
-
items: null,
|
676 |
-
columnsCount: 3,
|
677 |
-
verticalSpaceBetween: 30
|
678 |
-
};
|
679 |
-
},
|
680 |
-
|
681 |
-
getDefaultElements: function () {
|
682 |
-
return {
|
683 |
-
$container: jQuery(this.getSettings('container')),
|
684 |
-
$items: jQuery(this.getSettings('items'))
|
685 |
-
};
|
686 |
-
},
|
687 |
-
|
688 |
-
run: function () {
|
689 |
-
var heights = [],
|
690 |
-
distanceFromTop = this.elements.$container.position().top,
|
691 |
-
settings = this.getSettings(),
|
692 |
-
columnsCount = settings.columnsCount;
|
693 |
-
|
694 |
-
distanceFromTop += parseInt(this.elements.$container.css('margin-top'), 10);
|
695 |
-
|
696 |
-
this.elements.$container.height('');
|
697 |
-
|
698 |
-
this.elements.$items.each(function (index) {
|
699 |
-
var row = Math.floor(index / columnsCount),
|
700 |
-
indexAtRow = index % columnsCount,
|
701 |
-
$item = jQuery(this),
|
702 |
-
itemPosition = $item.position(),
|
703 |
-
itemHeight = $item[0].getBoundingClientRect().height + settings.verticalSpaceBetween;
|
704 |
-
|
705 |
-
if (row) {
|
706 |
-
var pullHeight = itemPosition.top - distanceFromTop - heights[indexAtRow];
|
707 |
-
pullHeight -= parseInt($item.css('margin-top'), 10);
|
708 |
-
pullHeight *= -1;
|
709 |
-
$item.css('margin-top', pullHeight + 'px');
|
710 |
-
heights[indexAtRow] += itemHeight;
|
711 |
-
} else {
|
712 |
-
heights.push(itemHeight);
|
713 |
-
}
|
714 |
-
});
|
715 |
-
|
716 |
-
this.elements.$container.height(Math.max.apply(Math, heights));
|
717 |
-
}
|
718 |
-
}
|
719 |
-
|
720 |
-
};
|
721 |
-
|
722 |
-
PremiumControlsViews = {
|
723 |
-
|
724 |
-
PremiumSearchView: null,
|
725 |
-
|
726 |
-
init: function () {
|
727 |
-
|
728 |
-
var self = this;
|
729 |
-
|
730 |
-
self.PremiumSearchView = window.elementor.modules.controls.BaseData.extend({
|
731 |
-
|
732 |
-
onReady: function () {
|
733 |
-
|
734 |
-
var action = this.model.attributes.action,
|
735 |
-
queryParams = this.model.attributes.query_params;
|
736 |
-
|
737 |
-
this.ui.select.find('option').each(function (index, el) {
|
738 |
-
$(this).attr('selected', true);
|
739 |
-
});
|
740 |
-
|
741 |
-
this.ui.select.select2({
|
742 |
-
ajax: {
|
743 |
-
url: function () {
|
744 |
-
|
745 |
-
var query = '';
|
746 |
-
|
747 |
-
if (queryParams.length > 0) {
|
748 |
-
$.each(queryParams, function (index, param) {
|
749 |
-
|
750 |
-
if (window.elementor.settings.page.model.attributes[param]) {
|
751 |
-
query += '&' + param + '=' + window.elementor.settings.page.model.attributes[param];
|
752 |
-
}
|
753 |
-
});
|
754 |
-
}
|
755 |
-
|
756 |
-
return ajaxurl + '?action=' + action + query;
|
757 |
-
},
|
758 |
-
dataType: 'json'
|
759 |
-
},
|
760 |
-
placeholder: 'Please enter 3 or more characters',
|
761 |
-
minimumInputLength: 3
|
762 |
-
});
|
763 |
-
|
764 |
-
},
|
765 |
-
|
766 |
-
onBeforeDestroy: function () {
|
767 |
-
|
768 |
-
if (this.ui.select.data('select2')) {
|
769 |
-
this.ui.select.select2('destroy');
|
770 |
-
}
|
771 |
-
|
772 |
-
this.$el.remove();
|
773 |
-
}
|
774 |
-
|
775 |
-
});
|
776 |
-
|
777 |
-
window.elementor.addControlView('premium_search', self.PremiumSearchView);
|
778 |
-
|
779 |
-
}
|
780 |
-
|
781 |
-
};
|
782 |
-
|
783 |
-
|
784 |
-
PremiumModules = {
|
785 |
-
|
786 |
-
getDataToSave: function (data) {
|
787 |
-
data.id = window.elementor.config.post_id;
|
788 |
-
return data;
|
789 |
-
},
|
790 |
-
|
791 |
-
init: function () {
|
792 |
-
if (window.elementor.settings.premium_template) {
|
793 |
-
window.elementor.settings.premium_template.getDataToSave = this.getDataToSave;
|
794 |
-
}
|
795 |
-
|
796 |
-
if (window.elementor.settings.premium_page) {
|
797 |
-
window.elementor.settings.premium_page.getDataToSave = this.getDataToSave;
|
798 |
-
window.elementor.settings.premium_page.changeCallbacks = {
|
799 |
-
custom_header: function () {
|
800 |
-
this.save(function () {
|
801 |
-
elementor.reloadPreview();
|
802 |
-
|
803 |
-
elementor.once('preview:loaded', function () {
|
804 |
-
elementor.getPanelView().setPage('premium_page_settings');
|
805 |
-
});
|
806 |
-
});
|
807 |
-
},
|
808 |
-
custom_footer: function () {
|
809 |
-
this.save(function () {
|
810 |
-
elementor.reloadPreview();
|
811 |
-
|
812 |
-
elementor.once('preview:loaded', function () {
|
813 |
-
elementor.getPanelView().setPage('premium_page_settings');
|
814 |
-
});
|
815 |
-
});
|
816 |
-
}
|
817 |
-
};
|
818 |
-
}
|
819 |
-
|
820 |
-
}
|
821 |
-
|
822 |
-
};
|
823 |
-
|
824 |
-
PremiumEditor = {
|
825 |
-
|
826 |
-
modal: false,
|
827 |
-
layout: false,
|
828 |
-
collections: {},
|
829 |
-
tabs: {},
|
830 |
-
defaultTab: '',
|
831 |
-
channels: {},
|
832 |
-
atIndex: null,
|
833 |
-
|
834 |
-
init: function () {
|
835 |
-
|
836 |
-
$(document).ready(function () {
|
837 |
-
PremiumEditor.initPremTempsButton();
|
838 |
-
});
|
839 |
-
|
840 |
-
window.elementor.on(
|
841 |
-
'document:loaded',
|
842 |
-
window._.bind(PremiumEditor.onPreviewLoaded, PremiumEditor)
|
843 |
-
);
|
844 |
-
|
845 |
-
PremiumEditorViews.init();
|
846 |
-
PremiumControlsViews.init();
|
847 |
-
PremiumModules.init();
|
848 |
-
|
849 |
-
},
|
850 |
-
|
851 |
-
onPreviewLoaded: function () {
|
852 |
-
|
853 |
-
window.elementor.$previewContents.on(
|
854 |
-
'click.addPremiumTemplate',
|
855 |
-
'.pa-add-section-btn',
|
856 |
-
_.bind(this.showTemplatesModal, this)
|
857 |
-
);
|
858 |
-
|
859 |
-
this.channels = {
|
860 |
-
templates: Backbone.Radio.channel('PREMIUM_EDITOR:templates'),
|
861 |
-
tabs: Backbone.Radio.channel('PREMIUM_EDITOR:tabs'),
|
862 |
-
layout: Backbone.Radio.channel('PREMIUM_EDITOR:layout'),
|
863 |
-
};
|
864 |
-
|
865 |
-
this.tabs = PremiumTempsData.tabs;
|
866 |
-
this.defaultTab = PremiumTempsData.defaultTab;
|
867 |
-
|
868 |
-
},
|
869 |
-
|
870 |
-
initPremTempsButton: function () {
|
871 |
-
|
872 |
-
var addPremiumTemplate = '<div class="elementor-add-section-area-button pa-add-section-btn" title="Add Premium Template"><i class="eicon-star"></i></div>',
|
873 |
-
addSectionTmpl = $("#tmpl-elementor-add-section");
|
874 |
-
|
875 |
-
if (addSectionTmpl.length < 1)
|
876 |
-
return;
|
877 |
-
|
878 |
-
var addSectionTmplHTML = addSectionTmpl.html();
|
879 |
-
|
880 |
-
addSectionTmplHTML = addSectionTmplHTML.replace('<div class="elementor-add-section-area-button', addPremiumTemplate + '<div class="elementor-add-section-area-button');
|
881 |
-
|
882 |
-
addSectionTmpl.html(addSectionTmplHTML);
|
883 |
-
|
884 |
-
// if ($addNewSection.length && PremiumTempsData.PremiumTemplatesBtn) {
|
885 |
-
// $addPremiumTemplate = $(addPremiumTemplate).prependTo($addNewSection);
|
886 |
-
// }
|
887 |
-
|
888 |
-
|
889 |
-
// window.elementor.$previewContents.on(
|
890 |
-
// 'click.addPremiumTemplate',
|
891 |
-
// '.elementor-editor-section-settings .elementor-editor-element-add',
|
892 |
-
// function () {
|
893 |
-
|
894 |
-
// var $this = $(this),
|
895 |
-
// $section = $this.closest('.elementor-top-section'),
|
896 |
-
// modelID = $section.data('model-cid');
|
897 |
-
|
898 |
-
// if (elementor.previewView.collection.length) {
|
899 |
-
// $.each(elementor.previewView.collection.models, function (index, model) {
|
900 |
-
// if (modelID === model.cid) {
|
901 |
-
// PremiumEditor.atIndex = index;
|
902 |
-
// }
|
903 |
-
// });
|
904 |
-
// }
|
905 |
-
|
906 |
-
// if (PremiumTempsData.PremiumTemplatesBtn) {
|
907 |
-
// setTimeout(function () {
|
908 |
-
// var $addNew = $section.prev('.elementor-add-section').find('.elementor-add-new-section');
|
909 |
-
// $addNew.prepend(addPremiumTemplate);
|
910 |
-
// }, 100);
|
911 |
-
// }
|
912 |
-
|
913 |
-
// }
|
914 |
-
// );
|
915 |
-
|
916 |
-
},
|
917 |
-
|
918 |
-
getFilter: function (name) {
|
919 |
-
|
920 |
-
return this.channels.templates.request('filter:' + name);
|
921 |
-
},
|
922 |
-
|
923 |
-
setFilter: function (name, value) {
|
924 |
-
this.channels.templates.reply('filter:' + name, value);
|
925 |
-
this.channels.templates.trigger('filter:change');
|
926 |
-
},
|
927 |
-
|
928 |
-
getTab: function () {
|
929 |
-
return this.channels.tabs.request('filter:tabs');
|
930 |
-
},
|
931 |
-
|
932 |
-
setTab: function (value, silent) {
|
933 |
-
|
934 |
-
this.channels.tabs.reply('filter:tabs', value);
|
935 |
-
|
936 |
-
if (!silent) {
|
937 |
-
this.channels.tabs.trigger('filter:change');
|
938 |
-
}
|
939 |
-
|
940 |
-
},
|
941 |
-
|
942 |
-
getTabs: function () {
|
943 |
-
|
944 |
-
var tabs = [];
|
945 |
-
|
946 |
-
_.each(this.tabs, function (item, slug) {
|
947 |
-
tabs.push({
|
948 |
-
slug: slug,
|
949 |
-
title: item.title
|
950 |
-
});
|
951 |
-
});
|
952 |
-
|
953 |
-
return tabs;
|
954 |
-
},
|
955 |
-
|
956 |
-
getPreview: function (name) {
|
957 |
-
return this.channels.layout.request('preview');
|
958 |
-
},
|
959 |
-
|
960 |
-
setPreview: function (value, silent) {
|
961 |
-
|
962 |
-
this.channels.layout.reply('preview', value);
|
963 |
-
|
964 |
-
if (!silent) {
|
965 |
-
this.channels.layout.trigger('preview:change');
|
966 |
-
}
|
967 |
-
},
|
968 |
-
|
969 |
-
getKeywords: function () {
|
970 |
-
|
971 |
-
var keywords = [];
|
972 |
-
|
973 |
-
_.each(this.keywords, function (title, slug) {
|
974 |
-
tabs.push({
|
975 |
-
slug: slug,
|
976 |
-
title: title
|
977 |
-
});
|
978 |
-
});
|
979 |
-
|
980 |
-
return keywords;
|
981 |
-
},
|
982 |
-
|
983 |
-
showTemplatesModal: function () {
|
984 |
-
|
985 |
-
this.getModal().show();
|
986 |
-
|
987 |
-
if (!this.layout) {
|
988 |
-
this.layout = new PremiumEditorViews.ModalLayoutView();
|
989 |
-
this.layout.showLoadingView();
|
990 |
-
}
|
991 |
-
|
992 |
-
this.setTab(this.defaultTab, true);
|
993 |
-
this.requestTemplates(this.defaultTab);
|
994 |
-
this.setPreview('initial');
|
995 |
-
|
996 |
-
},
|
997 |
-
|
998 |
-
requestTemplates: function (tabName) {
|
999 |
-
|
1000 |
-
var self = this,
|
1001 |
-
tab = self.tabs[tabName];
|
1002 |
-
|
1003 |
-
self.setFilter('category', false);
|
1004 |
-
|
1005 |
-
if (tab.data.templates && tab.data.categories) {
|
1006 |
-
self.layout.showTemplatesView(tab.data.templates, tab.data.categories, tab.data.keywords);
|
1007 |
-
} else {
|
1008 |
-
$.ajax({
|
1009 |
-
url: ajaxurl,
|
1010 |
-
type: 'get',
|
1011 |
-
dataType: 'json',
|
1012 |
-
data: {
|
1013 |
-
action: 'premium_get_templates',
|
1014 |
-
tab: tabName
|
1015 |
-
},
|
1016 |
-
success: function (response) {
|
1017 |
-
|
1018 |
-
console.log("%c Templates Retrieved Successfully!!", "color: #7a7a7a; background-color: #eee;");
|
1019 |
-
|
1020 |
-
var templates = new PremiumEditorViews.LibraryCollection(response.data.templates),
|
1021 |
-
categories = new PremiumEditorViews.CategoriesCollection(response.data.categories);
|
1022 |
-
|
1023 |
-
self.tabs[tabName].data = {
|
1024 |
-
templates: templates,
|
1025 |
-
categories: categories,
|
1026 |
-
keywords: response.data.keywords
|
1027 |
-
};
|
1028 |
-
|
1029 |
-
self.layout.showTemplatesView(templates, categories, response.data.keywords);
|
1030 |
-
|
1031 |
-
},
|
1032 |
-
error: function (err) {
|
1033 |
-
console.log(err);
|
1034 |
-
}
|
1035 |
-
});
|
1036 |
-
}
|
1037 |
-
|
1038 |
-
},
|
1039 |
-
|
1040 |
-
closeModal: function () {
|
1041 |
-
this.getModal().hide();
|
1042 |
-
},
|
1043 |
-
|
1044 |
-
getModal: function () {
|
1045 |
-
|
1046 |
-
if (!this.modal) {
|
1047 |
-
this.modal = elementor.dialogsManager.createWidget('lightbox', {
|
1048 |
-
id: 'premium-template-modal',
|
1049 |
-
className: 'elementor-templates-modal',
|
1050 |
-
closeButton: false
|
1051 |
-
});
|
1052 |
-
}
|
1053 |
-
|
1054 |
-
return this.modal;
|
1055 |
-
|
1056 |
-
}
|
1057 |
-
|
1058 |
-
};
|
1059 |
-
|
1060 |
-
$(window).on('elementor:init', PremiumEditor.init);
|
1061 |
-
|
1062 |
})(jQuery);
|
1 |
+
(function ($) {
|
2 |
+
|
3 |
+
'use strict';
|
4 |
+
|
5 |
+
var PremiumTempsData = window.PremiumTempsData || {},
|
6 |
+
PremiumEditor,
|
7 |
+
PremiumEditorViews,
|
8 |
+
PremiumControlsViews,
|
9 |
+
PremiumModules;
|
10 |
+
|
11 |
+
PremiumEditorViews = {
|
12 |
+
|
13 |
+
ModalLayoutView: null,
|
14 |
+
ModalHeaderView: null,
|
15 |
+
ModalHeaderInsertButton: null,
|
16 |
+
ModalLoadingView: null,
|
17 |
+
ModalBodyView: null,
|
18 |
+
ModalErrorView: null,
|
19 |
+
LibraryCollection: null,
|
20 |
+
KeywordsModel: null,
|
21 |
+
ModalCollectionView: null,
|
22 |
+
ModalTabsCollection: null,
|
23 |
+
ModalTabsCollectionView: null,
|
24 |
+
FiltersCollectionView: null,
|
25 |
+
FiltersItemView: null,
|
26 |
+
ModalTabsItemView: null,
|
27 |
+
ModalTemplateItemView: null,
|
28 |
+
ModalInsertTemplateBehavior: null,
|
29 |
+
ModalTemplateModel: null,
|
30 |
+
CategoriesCollection: null,
|
31 |
+
ModalPreviewView: null,
|
32 |
+
ModalHeaderBack: null,
|
33 |
+
ModalHeaderLogo: null,
|
34 |
+
KeywordsView: null,
|
35 |
+
TabModel: null,
|
36 |
+
CategoryModel: null,
|
37 |
+
|
38 |
+
init: function () {
|
39 |
+
var self = this;
|
40 |
+
|
41 |
+
self.ModalTemplateModel = Backbone.Model.extend({
|
42 |
+
defaults: {
|
43 |
+
template_id: 0,
|
44 |
+
name: '',
|
45 |
+
title: '',
|
46 |
+
thumbnail: '',
|
47 |
+
preview: '',
|
48 |
+
source: '',
|
49 |
+
categories: [],
|
50 |
+
keywords: []
|
51 |
+
}
|
52 |
+
});
|
53 |
+
|
54 |
+
self.ModalHeaderView = Marionette.LayoutView.extend({
|
55 |
+
|
56 |
+
id: 'premium-template-modal-header',
|
57 |
+
template: '#tmpl-premium-template-modal-header',
|
58 |
+
|
59 |
+
ui: {
|
60 |
+
closeModal: '#premium-template-modal-header-close-modal'
|
61 |
+
},
|
62 |
+
|
63 |
+
events: {
|
64 |
+
'click @ui.closeModal': 'onCloseModalClick'
|
65 |
+
},
|
66 |
+
|
67 |
+
regions: {
|
68 |
+
headerLogo: '#premium-template-modal-header-logo-area',
|
69 |
+
headerTabs: '#premium-template-modal-header-tabs',
|
70 |
+
headerActions: '#premium-template-modal-header-actions'
|
71 |
+
},
|
72 |
+
|
73 |
+
onCloseModalClick: function () {
|
74 |
+
PremiumEditor.closeModal();
|
75 |
+
}
|
76 |
+
|
77 |
+
});
|
78 |
+
|
79 |
+
self.TabModel = Backbone.Model.extend({
|
80 |
+
defaults: {
|
81 |
+
slug: '',
|
82 |
+
title: ''
|
83 |
+
}
|
84 |
+
});
|
85 |
+
|
86 |
+
self.LibraryCollection = Backbone.Collection.extend({
|
87 |
+
model: self.ModalTemplateModel
|
88 |
+
});
|
89 |
+
|
90 |
+
self.ModalTabsCollection = Backbone.Collection.extend({
|
91 |
+
model: self.TabModel
|
92 |
+
});
|
93 |
+
|
94 |
+
self.CategoryModel = Backbone.Model.extend({
|
95 |
+
defaults: {
|
96 |
+
slug: '',
|
97 |
+
title: ''
|
98 |
+
}
|
99 |
+
});
|
100 |
+
|
101 |
+
self.KeywordsModel = Backbone.Model.extend({
|
102 |
+
defaults: {
|
103 |
+
keywords: {}
|
104 |
+
}
|
105 |
+
});
|
106 |
+
|
107 |
+
self.CategoriesCollection = Backbone.Collection.extend({
|
108 |
+
model: self.CategoryModel
|
109 |
+
});
|
110 |
+
|
111 |
+
self.KeywordsView = Marionette.ItemView.extend({
|
112 |
+
id: 'elementor-template-library-filter',
|
113 |
+
template: '#tmpl-premium-template-modal-keywords',
|
114 |
+
ui: {
|
115 |
+
keywords: '.premium-library-keywords'
|
116 |
+
},
|
117 |
+
|
118 |
+
events: {
|
119 |
+
'change @ui.keywords': 'onSelectKeyword'
|
120 |
+
},
|
121 |
+
|
122 |
+
onSelectKeyword: function (event) {
|
123 |
+
var selected = event.currentTarget.selectedOptions[0].value;
|
124 |
+
PremiumEditor.setFilter('keyword', selected);
|
125 |
+
},
|
126 |
+
|
127 |
+
onRender: function () {
|
128 |
+
var $filters = this.$('.premium-library-keywords');
|
129 |
+
$filters.select2({
|
130 |
+
placeholder: 'Choose Widget',
|
131 |
+
allowClear: true,
|
132 |
+
width: 250,
|
133 |
+
dropdownParent: this.$el
|
134 |
+
});
|
135 |
+
}
|
136 |
+
});
|
137 |
+
|
138 |
+
self.ModalPreviewView = Marionette.ItemView.extend({
|
139 |
+
|
140 |
+
template: '#tmpl-premium-template-modal-preview',
|
141 |
+
|
142 |
+
id: 'premium-templatate-item-preview-wrap',
|
143 |
+
|
144 |
+
ui: {
|
145 |
+
iframe: 'iframe',
|
146 |
+
notice: '.premium-template-item-notice'
|
147 |
+
},
|
148 |
+
|
149 |
+
|
150 |
+
onRender: function () {
|
151 |
+
|
152 |
+
if (null !== this.getOption('notice')) {
|
153 |
+
if (this.getOption('notice').length) {
|
154 |
+
var message = "";
|
155 |
+
if (-1 !== this.getOption('notice').indexOf("facebook")) {
|
156 |
+
message += "<p>Please login with your Facebook account in order to get your Facebook Reviews.</p>";
|
157 |
+
} else if (-1 !== this.getOption('notice').indexOf("google")) {
|
158 |
+
message += "<p>You need to add your Google API key from Dashboard -> Premium Add-ons for Elementor -> Google Maps</p>";
|
159 |
+
} else if (-1 !== this.getOption('notice').indexOf("form")) {
|
160 |
+
message += "<p>You need to have <a href='https://wordpress.org/plugins/contact-form-7/' target='_blank'>Contact Form 7 plugin</a> installed and active.</p>";
|
161 |
+
}
|
162 |
+
|
163 |
+
this.ui.notice.html('<div><p><strong>Important!</strong></p>' + message + '</div>');
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
this.ui.iframe.attr('src', this.getOption('url'));
|
168 |
+
|
169 |
+
}
|
170 |
+
});
|
171 |
+
|
172 |
+
self.ModalHeaderBack = Marionette.ItemView.extend({
|
173 |
+
|
174 |
+
template: '#tmpl-premium-template-modal-header-back',
|
175 |
+
|
176 |
+
id: 'premium-template-modal-header-back',
|
177 |
+
|
178 |
+
ui: {
|
179 |
+
button: 'button'
|
180 |
+
},
|
181 |
+
|
182 |
+
events: {
|
183 |
+
'click @ui.button': 'onBackClick',
|
184 |
+
},
|
185 |
+
|
186 |
+
onBackClick: function () {
|
187 |
+
PremiumEditor.setPreview('back');
|
188 |
+
}
|
189 |
+
|
190 |
+
});
|
191 |
+
|
192 |
+
self.ModalHeaderLogo = Marionette.ItemView.extend({
|
193 |
+
|
194 |
+
template: '#tmpl-premium-template-modal-header-logo',
|
195 |
+
|
196 |
+
id: 'premium-template-modal-header-logo'
|
197 |
+
|
198 |
+
});
|
199 |
+
|
200 |
+
self.ModalBodyView = Marionette.LayoutView.extend({
|
201 |
+
|
202 |
+
id: 'premium-template-library-content',
|
203 |
+
|
204 |
+
className: function () {
|
205 |
+
return 'library-tab-' + PremiumEditor.getTab();
|
206 |
+
},
|
207 |
+
|
208 |
+
template: '#tmpl-premium-template-modal-content',
|
209 |
+
|
210 |
+
regions: {
|
211 |
+
contentTemplates: '.premium-templates-list',
|
212 |
+
contentFilters: '.premium-filters-list',
|
213 |
+
contentKeywords: '.premium-keywords-list'
|
214 |
+
}
|
215 |
+
|
216 |
+
});
|
217 |
+
|
218 |
+
self.ModalInsertTemplateBehavior = Marionette.Behavior.extend({
|
219 |
+
ui: {
|
220 |
+
insertButtons: ['.premium-template-insert', '.premium-template-insert-no-media'],
|
221 |
+
},
|
222 |
+
|
223 |
+
events: {
|
224 |
+
'click @ui.insertButtons': 'onInsertButtonClick'
|
225 |
+
},
|
226 |
+
|
227 |
+
onInsertButtonClick: function (event) {
|
228 |
+
|
229 |
+
var templateModel = this.view.model,
|
230 |
+
innerTemplates = templateModel.attributes.dependencies,
|
231 |
+
isPro = templateModel.attributes.pro,
|
232 |
+
innerTemplatesLength = Object.keys(innerTemplates).length,
|
233 |
+
options = {},
|
234 |
+
insertMedia = !$(event.currentTarget).hasClass("premium-template-insert-no-media");
|
235 |
+
|
236 |
+
// console.log(insertMedia);
|
237 |
+
|
238 |
+
PremiumEditor.layout.showLoadingView();
|
239 |
+
if (innerTemplatesLength > 0) {
|
240 |
+
for (var key in innerTemplates) {
|
241 |
+
$.ajax({
|
242 |
+
url: ajaxurl,
|
243 |
+
type: 'post',
|
244 |
+
dataType: 'json',
|
245 |
+
data: {
|
246 |
+
action: 'premium_inner_template',
|
247 |
+
template: innerTemplates[key],
|
248 |
+
tab: PremiumEditor.getTab(),
|
249 |
+
withMedia: insertMedia
|
250 |
+
}
|
251 |
+
});
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
if ("valid" === PremiumTempsData.license.status || !isPro) {
|
256 |
+
|
257 |
+
elementor.templates.requestTemplateContent(
|
258 |
+
templateModel.get('source'),
|
259 |
+
templateModel.get('template_id'), {
|
260 |
+
data: {
|
261 |
+
tab: PremiumEditor.getTab(),
|
262 |
+
page_settings: false,
|
263 |
+
withMedia: insertMedia
|
264 |
+
},
|
265 |
+
success: function (data) {
|
266 |
+
|
267 |
+
if (!data.license) {
|
268 |
+
PremiumEditor.layout.showLicenseError();
|
269 |
+
return;
|
270 |
+
}
|
271 |
+
|
272 |
+
console.log("%c Template Inserted Successfully!!", "color: #7a7a7a; background-color: #eee;");
|
273 |
+
|
274 |
+
PremiumEditor.closeModal();
|
275 |
+
|
276 |
+
elementor.channels.data.trigger('template:before:insert', templateModel);
|
277 |
+
|
278 |
+
if (null !== PremiumEditor.atIndex) {
|
279 |
+
options.at = PremiumEditor.atIndex;
|
280 |
+
}
|
281 |
+
|
282 |
+
elementor.previewView.addChildModel(data.content, options);
|
283 |
+
|
284 |
+
elementor.channels.data.trigger('template:after:insert', templateModel);
|
285 |
+
jQuery("#elementor-panel-saver-button-save-options, #elementor-panel-saver-button-publish").removeClass("elementor-disabled");
|
286 |
+
PremiumEditor.atIndex = null;
|
287 |
+
|
288 |
+
},
|
289 |
+
error: function (err) {
|
290 |
+
console.log(err);
|
291 |
+
}
|
292 |
+
}
|
293 |
+
);
|
294 |
+
} else {
|
295 |
+
PremiumEditor.layout.showLicenseError();
|
296 |
+
}
|
297 |
+
}
|
298 |
+
});
|
299 |
+
|
300 |
+
self.ModalHeaderInsertButton = Marionette.ItemView.extend({
|
301 |
+
|
302 |
+
template: '#tmpl-premium-template-modal-insert-button',
|
303 |
+
|
304 |
+
id: 'premium-template-modal-insert-button',
|
305 |
+
|
306 |
+
behaviors: {
|
307 |
+
insertTemplate: {
|
308 |
+
behaviorClass: self.ModalInsertTemplateBehavior
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
});
|
313 |
+
|
314 |
+
self.FiltersItemView = Marionette.ItemView.extend({
|
315 |
+
|
316 |
+
template: '#tmpl-premium-template-modal-filters-item',
|
317 |
+
|
318 |
+
className: function () {
|
319 |
+
return 'premium-template-filter-item';
|
320 |
+
},
|
321 |
+
|
322 |
+
ui: function () {
|
323 |
+
return {
|
324 |
+
filterLabels: '.premium-template-filter-label'
|
325 |
+
};
|
326 |
+
},
|
327 |
+
|
328 |
+
events: function () {
|
329 |
+
return {
|
330 |
+
'click @ui.filterLabels': 'onFilterClick'
|
331 |
+
};
|
332 |
+
},
|
333 |
+
|
334 |
+
onFilterClick: function (event) {
|
335 |
+
|
336 |
+
var $clickedInput = jQuery(event.target);
|
337 |
+
jQuery('.premium-library-keywords').val('');
|
338 |
+
PremiumEditor.setFilter('category', $clickedInput.val());
|
339 |
+
PremiumEditor.setFilter('keyword', '');
|
340 |
+
}
|
341 |
+
|
342 |
+
});
|
343 |
+
|
344 |
+
self.ModalTabsItemView = Marionette.ItemView.extend({
|
345 |
+
|
346 |
+
template: '#tmpl-premium-template-modal-tabs-item',
|
347 |
+
|
348 |
+
className: function () {
|
349 |
+
return 'elementor-template-library-menu-item';
|
350 |
+
},
|
351 |
+
|
352 |
+
ui: function () {
|
353 |
+
return {
|
354 |
+
tabsLabels: 'label',
|
355 |
+
tabsInput: 'input'
|
356 |
+
};
|
357 |
+
},
|
358 |
+
|
359 |
+
events: function () {
|
360 |
+
return {
|
361 |
+
'click @ui.tabsLabels': 'onTabClick'
|
362 |
+
};
|
363 |
+
},
|
364 |
+
|
365 |
+
onRender: function () {
|
366 |
+
if (this.model.get('slug') === PremiumEditor.getTab()) {
|
367 |
+
this.ui.tabsInput.attr('checked', 'checked');
|
368 |
+
}
|
369 |
+
},
|
370 |
+
|
371 |
+
onTabClick: function (event) {
|
372 |
+
|
373 |
+
var $clickedInput = jQuery(event.target);
|
374 |
+
PremiumEditor.setTab($clickedInput.val());
|
375 |
+
PremiumEditor.setFilter('keyword', '');
|
376 |
+
}
|
377 |
+
|
378 |
+
});
|
379 |
+
|
380 |
+
self.FiltersCollectionView = Marionette.CompositeView.extend({
|
381 |
+
|
382 |
+
id: 'premium-template-library-filters',
|
383 |
+
|
384 |
+
template: '#tmpl-premium-template-modal-filters',
|
385 |
+
|
386 |
+
childViewContainer: '#premium-modal-filters-container',
|
387 |
+
|
388 |
+
getChildView: function (childModel) {
|
389 |
+
return self.FiltersItemView;
|
390 |
+
}
|
391 |
+
|
392 |
+
});
|
393 |
+
|
394 |
+
self.ModalTabsCollectionView = Marionette.CompositeView.extend({
|
395 |
+
|
396 |
+
template: '#tmpl-premium-template-modal-tabs',
|
397 |
+
|
398 |
+
childViewContainer: '#premium-modal-tabs-items',
|
399 |
+
|
400 |
+
initialize: function () {
|
401 |
+
this.listenTo(PremiumEditor.channels.layout, 'tamplate:cloned', this._renderChildren);
|
402 |
+
},
|
403 |
+
|
404 |
+
getChildView: function (childModel) {
|
405 |
+
return self.ModalTabsItemView;
|
406 |
+
}
|
407 |
+
|
408 |
+
});
|
409 |
+
|
410 |
+
self.ModalTemplateItemView = Marionette.ItemView.extend({
|
411 |
+
|
412 |
+
template: '#tmpl-premium-template-modal-item',
|
413 |
+
|
414 |
+
className: function () {
|
415 |
+
|
416 |
+
var urlClass = ' premium-template-has-url',
|
417 |
+
sourceClass = ' elementor-template-library-template-',
|
418 |
+
proTemplate = '';
|
419 |
+
|
420 |
+
if ('' === this.model.get('preview')) {
|
421 |
+
urlClass = ' premium-template-no-url';
|
422 |
+
}
|
423 |
+
|
424 |
+
sourceClass += 'remote';
|
425 |
+
|
426 |
+
if (this.model.get('pro')) {
|
427 |
+
proTemplate = ' premium-template-pro';
|
428 |
+
}
|
429 |
+
|
430 |
+
return 'elementor-template-library-template' + sourceClass + urlClass + proTemplate;
|
431 |
+
},
|
432 |
+
|
433 |
+
ui: function () {
|
434 |
+
return {
|
435 |
+
previewButton: '.elementor-template-library-template-preview',
|
436 |
+
};
|
437 |
+
},
|
438 |
+
|
439 |
+
events: function () {
|
440 |
+
return {
|
441 |
+
'click @ui.previewButton': 'onPreviewButtonClick',
|
442 |
+
};
|
443 |
+
},
|
444 |
+
|
445 |
+
onPreviewButtonClick: function () {
|
446 |
+
|
447 |
+
if ('' === this.model.get('url')) {
|
448 |
+
return;
|
449 |
+
}
|
450 |
+
|
451 |
+
PremiumEditor.setPreview(this.model);
|
452 |
+
},
|
453 |
+
|
454 |
+
behaviors: {
|
455 |
+
insertTemplate: {
|
456 |
+
behaviorClass: self.ModalInsertTemplateBehavior
|
457 |
+
}
|
458 |
+
}
|
459 |
+
});
|
460 |
+
|
461 |
+
self.ModalCollectionView = Marionette.CompositeView.extend({
|
462 |
+
|
463 |
+
template: '#tmpl-premium-template-modal-templates',
|
464 |
+
|
465 |
+
id: 'premium-template-library-templates',
|
466 |
+
|
467 |
+
childViewContainer: '#premium-modal-templates-container',
|
468 |
+
|
469 |
+
initialize: function () {
|
470 |
+
|
471 |
+
this.listenTo(PremiumEditor.channels.templates, 'filter:change', this._renderChildren);
|
472 |
+
},
|
473 |
+
|
474 |
+
filter: function (childModel) {
|
475 |
+
|
476 |
+
var filter = PremiumEditor.getFilter('category'),
|
477 |
+
keyword = PremiumEditor.getFilter('keyword');
|
478 |
+
|
479 |
+
if (!filter && !keyword) {
|
480 |
+
return true;
|
481 |
+
}
|
482 |
+
|
483 |
+
if (keyword && !filter) {
|
484 |
+
return _.contains(childModel.get('keywords'), keyword);
|
485 |
+
}
|
486 |
+
|
487 |
+
if (filter && !keyword) {
|
488 |
+
return _.contains(childModel.get('categories'), filter);
|
489 |
+
}
|
490 |
+
|
491 |
+
return _.contains(childModel.get('categories'), filter) && _.contains(childModel.get('keywords'), keyword);
|
492 |
+
|
493 |
+
},
|
494 |
+
|
495 |
+
getChildView: function (childModel) {
|
496 |
+
return self.ModalTemplateItemView;
|
497 |
+
},
|
498 |
+
|
499 |
+
onRenderCollection: function () {
|
500 |
+
|
501 |
+
var container = this.$childViewContainer,
|
502 |
+
items = this.$childViewContainer.children(),
|
503 |
+
tab = PremiumEditor.getTab();
|
504 |
+
|
505 |
+
if ('premium_page' === tab || 'local' === tab) {
|
506 |
+
return;
|
507 |
+
}
|
508 |
+
|
509 |
+
// Wait for thumbnails to be loaded
|
510 |
+
container.imagesLoaded(function () { }).done(function () {
|
511 |
+
self.masonry.init({
|
512 |
+
container: container,
|
513 |
+
items: items
|
514 |
+
});
|
515 |
+
});
|
516 |
+
}
|
517 |
+
|
518 |
+
});
|
519 |
+
|
520 |
+
self.ModalLayoutView = Marionette.LayoutView.extend({
|
521 |
+
|
522 |
+
el: '#premium-template-modal',
|
523 |
+
|
524 |
+
regions: PremiumTempsData.modalRegions,
|
525 |
+
|
526 |
+
initialize: function () {
|
527 |
+
|
528 |
+
this.getRegion('modalHeader').show(new self.ModalHeaderView());
|
529 |
+
this.listenTo(PremiumEditor.channels.tabs, 'filter:change', this.switchTabs);
|
530 |
+
this.listenTo(PremiumEditor.channels.layout, 'preview:change', this.switchPreview);
|
531 |
+
|
532 |
+
},
|
533 |
+
|
534 |
+
switchTabs: function () {
|
535 |
+
this.showLoadingView();
|
536 |
+
PremiumEditor.setFilter('keyword', '');
|
537 |
+
PremiumEditor.requestTemplates(PremiumEditor.getTab());
|
538 |
+
},
|
539 |
+
|
540 |
+
switchPreview: function () {
|
541 |
+
|
542 |
+
var header = this.getHeaderView(),
|
543 |
+
preview = PremiumEditor.getPreview();
|
544 |
+
|
545 |
+
var filter = PremiumEditor.getFilter('category'),
|
546 |
+
keyword = PremiumEditor.getFilter('keyword');
|
547 |
+
|
548 |
+
if ('back' === preview) {
|
549 |
+
header.headerLogo.show(new self.ModalHeaderLogo());
|
550 |
+
header.headerTabs.show(new self.ModalTabsCollectionView({
|
551 |
+
collection: PremiumEditor.collections.tabs
|
552 |
+
}));
|
553 |
+
|
554 |
+
header.headerActions.empty();
|
555 |
+
PremiumEditor.setTab(PremiumEditor.getTab());
|
556 |
+
|
557 |
+
if ('' != filter) {
|
558 |
+
PremiumEditor.setFilter('category', filter);
|
559 |
+
jQuery('#premium-modal-filters-container').find("input[value='" + filter + "']").prop('checked', true);
|
560 |
+
|
561 |
+
}
|
562 |
+
|
563 |
+
if ('' != keyword) {
|
564 |
+
PremiumEditor.setFilter('keyword', keyword);
|
565 |
+
}
|
566 |
+
|
567 |
+
return;
|
568 |
+
}
|
569 |
+
|
570 |
+
if ('initial' === preview) {
|
571 |
+
header.headerActions.empty();
|
572 |
+
header.headerLogo.show(new self.ModalHeaderLogo());
|
573 |
+
return;
|
574 |
+
}
|
575 |
+
|
576 |
+
this.getRegion('modalContent').show(new self.ModalPreviewView({
|
577 |
+
'preview': preview.get('preview'),
|
578 |
+
'url': preview.get('url'),
|
579 |
+
'notice': preview.get('notice')
|
580 |
+
}));
|
581 |
+
|
582 |
+
header.headerLogo.empty();
|
583 |
+
header.headerTabs.show(new self.ModalHeaderBack());
|
584 |
+
header.headerActions.show(new self.ModalHeaderInsertButton({
|
585 |
+
model: preview
|
586 |
+
}));
|
587 |
+
|
588 |
+
},
|
589 |
+
|
590 |
+
getHeaderView: function () {
|
591 |
+
return this.getRegion('modalHeader').currentView;
|
592 |
+
},
|
593 |
+
|
594 |
+
getContentView: function () {
|
595 |
+
return this.getRegion('modalContent').currentView;
|
596 |
+
},
|
597 |
+
|
598 |
+
showLoadingView: function () {
|
599 |
+
this.modalContent.show(new self.ModalLoadingView());
|
600 |
+
},
|
601 |
+
|
602 |
+
showLicenseError: function () {
|
603 |
+
this.modalContent.show(new self.ModalErrorView());
|
604 |
+
},
|
605 |
+
|
606 |
+
showTemplatesView: function (templatesCollection, categoriesCollection, keywords) {
|
607 |
+
|
608 |
+
this.getRegion('modalContent').show(new self.ModalBodyView());
|
609 |
+
|
610 |
+
var contentView = this.getContentView(),
|
611 |
+
header = this.getHeaderView(),
|
612 |
+
keywordsModel = new self.KeywordsModel({
|
613 |
+
keywords: keywords
|
614 |
+
});
|
615 |
+
|
616 |
+
PremiumEditor.collections.tabs = new self.ModalTabsCollection(PremiumEditor.getTabs());
|
617 |
+
|
618 |
+
header.headerTabs.show(new self.ModalTabsCollectionView({
|
619 |
+
collection: PremiumEditor.collections.tabs
|
620 |
+
}));
|
621 |
+
|
622 |
+
contentView.contentTemplates.show(new self.ModalCollectionView({
|
623 |
+
collection: templatesCollection
|
624 |
+
}));
|
625 |
+
|
626 |
+
contentView.contentFilters.show(new self.FiltersCollectionView({
|
627 |
+
collection: categoriesCollection
|
628 |
+
}));
|
629 |
+
|
630 |
+
contentView.contentKeywords.show(new self.KeywordsView({
|
631 |
+
model: keywordsModel
|
632 |
+
}));
|
633 |
+
|
634 |
+
}
|
635 |
+
|
636 |
+
});
|
637 |
+
|
638 |
+
self.ModalLoadingView = Marionette.ItemView.extend({
|
639 |
+
id: 'premium-template-modal-loading',
|
640 |
+
template: '#tmpl-premium-template-modal-loading'
|
641 |
+
});
|
642 |
+
|
643 |
+
self.ModalErrorView = Marionette.ItemView.extend({
|
644 |
+
id: 'premium-template-modal-loading',
|
645 |
+
template: '#tmpl-premium-template-modal-error'
|
646 |
+
});
|
647 |
+
|
648 |
+
},
|
649 |
+
|
650 |
+
masonry: {
|
651 |
+
|
652 |
+
self: {},
|
653 |
+
elements: {},
|
654 |
+
|
655 |
+
init: function (settings) {
|
656 |
+
|
657 |
+
var self = this;
|
658 |
+
self.settings = $.extend(self.getDefaultSettings(), settings);
|
659 |
+
self.elements = self.getDefaultElements();
|
660 |
+
|
661 |
+
self.run();
|
662 |
+
},
|
663 |
+
|
664 |
+
getSettings: function (key) {
|
665 |
+
if (key) {
|
666 |
+
return this.settings[key];
|
667 |
+
} else {
|
668 |
+
return this.settings;
|
669 |
+
}
|
670 |
+
},
|
671 |
+
|
672 |
+
getDefaultSettings: function () {
|
673 |
+
return {
|
674 |
+
container: null,
|
675 |
+
items: null,
|
676 |
+
columnsCount: 3,
|
677 |
+
verticalSpaceBetween: 30
|
678 |
+
};
|
679 |
+
},
|
680 |
+
|
681 |
+
getDefaultElements: function () {
|
682 |
+
return {
|
683 |
+
$container: jQuery(this.getSettings('container')),
|
684 |
+
$items: jQuery(this.getSettings('items'))
|
685 |
+
};
|
686 |
+
},
|
687 |
+
|
688 |
+
run: function () {
|
689 |
+
var heights = [],
|
690 |
+
distanceFromTop = this.elements.$container.position().top,
|
691 |
+
settings = this.getSettings(),
|
692 |
+
columnsCount = settings.columnsCount;
|
693 |
+
|
694 |
+
distanceFromTop += parseInt(this.elements.$container.css('margin-top'), 10);
|
695 |
+
|
696 |
+
this.elements.$container.height('');
|
697 |
+
|
698 |
+
this.elements.$items.each(function (index) {
|
699 |
+
var row = Math.floor(index / columnsCount),
|
700 |
+
indexAtRow = index % columnsCount,
|
701 |
+
$item = jQuery(this),
|
702 |
+
itemPosition = $item.position(),
|
703 |
+
itemHeight = $item[0].getBoundingClientRect().height + settings.verticalSpaceBetween;
|
704 |
+
|
705 |
+
if (row) {
|
706 |
+
var pullHeight = itemPosition.top - distanceFromTop - heights[indexAtRow];
|
707 |
+
pullHeight -= parseInt($item.css('margin-top'), 10);
|
708 |
+
pullHeight *= -1;
|
709 |
+
$item.css('margin-top', pullHeight + 'px');
|
710 |
+
heights[indexAtRow] += itemHeight;
|
711 |
+
} else {
|
712 |
+
heights.push(itemHeight);
|
713 |
+
}
|
714 |
+
});
|
715 |
+
|
716 |
+
this.elements.$container.height(Math.max.apply(Math, heights));
|
717 |
+
}
|
718 |
+
}
|
719 |
+
|
720 |
+
};
|
721 |
+
|
722 |
+
PremiumControlsViews = {
|
723 |
+
|
724 |
+
PremiumSearchView: null,
|
725 |
+
|
726 |
+
init: function () {
|
727 |
+
|
728 |
+
var self = this;
|
729 |
+
|
730 |
+
self.PremiumSearchView = window.elementor.modules.controls.BaseData.extend({
|
731 |
+
|
732 |
+
onReady: function () {
|
733 |
+
|
734 |
+
var action = this.model.attributes.action,
|
735 |
+
queryParams = this.model.attributes.query_params;
|
736 |
+
|
737 |
+
this.ui.select.find('option').each(function (index, el) {
|
738 |
+
$(this).attr('selected', true);
|
739 |
+
});
|
740 |
+
|
741 |
+
this.ui.select.select2({
|
742 |
+
ajax: {
|
743 |
+
url: function () {
|
744 |
+
|
745 |
+
var query = '';
|
746 |
+
|
747 |
+
if (queryParams.length > 0) {
|
748 |
+
$.each(queryParams, function (index, param) {
|
749 |
+
|
750 |
+
if (window.elementor.settings.page.model.attributes[param]) {
|
751 |
+
query += '&' + param + '=' + window.elementor.settings.page.model.attributes[param];
|
752 |
+
}
|
753 |
+
});
|
754 |
+
}
|
755 |
+
|
756 |
+
return ajaxurl + '?action=' + action + query;
|
757 |
+
},
|
758 |
+
dataType: 'json'
|
759 |
+
},
|
760 |
+
placeholder: 'Please enter 3 or more characters',
|
761 |
+
minimumInputLength: 3
|
762 |
+
});
|
763 |
+
|
764 |
+
},
|
765 |
+
|
766 |
+
onBeforeDestroy: function () {
|
767 |
+
|
768 |
+
if (this.ui.select.data('select2')) {
|
769 |
+
this.ui.select.select2('destroy');
|
770 |
+
}
|
771 |
+
|
772 |
+
this.$el.remove();
|
773 |
+
}
|
774 |
+
|
775 |
+
});
|
776 |
+
|
777 |
+
window.elementor.addControlView('premium_search', self.PremiumSearchView);
|
778 |
+
|
779 |
+
}
|
780 |
+
|
781 |
+
};
|
782 |
+
|
783 |
+
|
784 |
+
PremiumModules = {
|
785 |
+
|
786 |
+
getDataToSave: function (data) {
|
787 |
+
data.id = window.elementor.config.post_id;
|
788 |
+
return data;
|
789 |
+
},
|
790 |
+
|
791 |
+
init: function () {
|
792 |
+
if (window.elementor.settings.premium_template) {
|
793 |
+
window.elementor.settings.premium_template.getDataToSave = this.getDataToSave;
|
794 |
+
}
|
795 |
+
|
796 |
+
if (window.elementor.settings.premium_page) {
|
797 |
+
window.elementor.settings.premium_page.getDataToSave = this.getDataToSave;
|
798 |
+
window.elementor.settings.premium_page.changeCallbacks = {
|
799 |
+
custom_header: function () {
|
800 |
+
this.save(function () {
|
801 |
+
elementor.reloadPreview();
|
802 |
+
|
803 |
+
elementor.once('preview:loaded', function () {
|
804 |
+
elementor.getPanelView().setPage('premium_page_settings');
|
805 |
+
});
|
806 |
+
});
|
807 |
+
},
|
808 |
+
custom_footer: function () {
|
809 |
+
this.save(function () {
|
810 |
+
elementor.reloadPreview();
|
811 |
+
|
812 |
+
elementor.once('preview:loaded', function () {
|
813 |
+
elementor.getPanelView().setPage('premium_page_settings');
|
814 |
+
});
|
815 |
+
});
|
816 |
+
}
|
817 |
+
};
|
818 |
+
}
|
819 |
+
|
820 |
+
}
|
821 |
+
|
822 |
+
};
|
823 |
+
|
824 |
+
PremiumEditor = {
|
825 |
+
|
826 |
+
modal: false,
|
827 |
+
layout: false,
|
828 |
+
collections: {},
|
829 |
+
tabs: {},
|
830 |
+
defaultTab: '',
|
831 |
+
channels: {},
|
832 |
+
atIndex: null,
|
833 |
+
|
834 |
+
init: function () {
|
835 |
+
|
836 |
+
$(document).ready(function () {
|
837 |
+
PremiumEditor.initPremTempsButton();
|
838 |
+
});
|
839 |
+
|
840 |
+
window.elementor.on(
|
841 |
+
'document:loaded',
|
842 |
+
window._.bind(PremiumEditor.onPreviewLoaded, PremiumEditor)
|
843 |
+
);
|
844 |
+
|
845 |
+
PremiumEditorViews.init();
|
846 |
+
PremiumControlsViews.init();
|
847 |
+
PremiumModules.init();
|
848 |
+
|
849 |
+
},
|
850 |
+
|
851 |
+
onPreviewLoaded: function () {
|
852 |
+
|
853 |
+
window.elementor.$previewContents.on(
|
854 |
+
'click.addPremiumTemplate',
|
855 |
+
'.pa-add-section-btn',
|
856 |
+
_.bind(this.showTemplatesModal, this)
|
857 |
+
);
|
858 |
+
|
859 |
+
this.channels = {
|
860 |
+
templates: Backbone.Radio.channel('PREMIUM_EDITOR:templates'),
|
861 |
+
tabs: Backbone.Radio.channel('PREMIUM_EDITOR:tabs'),
|
862 |
+
layout: Backbone.Radio.channel('PREMIUM_EDITOR:layout'),
|
863 |
+
};
|
864 |
+
|
865 |
+
this.tabs = PremiumTempsData.tabs;
|
866 |
+
this.defaultTab = PremiumTempsData.defaultTab;
|
867 |
+
|
868 |
+
},
|
869 |
+
|
870 |
+
initPremTempsButton: function () {
|
871 |
+
|
872 |
+
var addPremiumTemplate = '<div class="elementor-add-section-area-button pa-add-section-btn" title="Add Premium Template"><i class="eicon-star"></i></div>',
|
873 |
+
addSectionTmpl = $("#tmpl-elementor-add-section");
|
874 |
+
|
875 |
+
if (addSectionTmpl.length < 1)
|
876 |
+
return;
|
877 |
+
|
878 |
+
var addSectionTmplHTML = addSectionTmpl.html();
|
879 |
+
|
880 |
+
addSectionTmplHTML = addSectionTmplHTML.replace('<div class="elementor-add-section-area-button', addPremiumTemplate + '<div class="elementor-add-section-area-button');
|
881 |
+
|
882 |
+
addSectionTmpl.html(addSectionTmplHTML);
|
883 |
+
|
884 |
+
// if ($addNewSection.length && PremiumTempsData.PremiumTemplatesBtn) {
|
885 |
+
// $addPremiumTemplate = $(addPremiumTemplate).prependTo($addNewSection);
|
886 |
+
// }
|
887 |
+
|
888 |
+
|
889 |
+
// window.elementor.$previewContents.on(
|
890 |
+
// 'click.addPremiumTemplate',
|
891 |
+
// '.elementor-editor-section-settings .elementor-editor-element-add',
|
892 |
+
// function () {
|
893 |
+
|
894 |
+
// var $this = $(this),
|
895 |
+
// $section = $this.closest('.elementor-top-section'),
|
896 |
+
// modelID = $section.data('model-cid');
|
897 |
+
|
898 |
+
// if (elementor.previewView.collection.length) {
|
899 |
+
// $.each(elementor.previewView.collection.models, function (index, model) {
|
900 |
+
// if (modelID === model.cid) {
|
901 |
+
// PremiumEditor.atIndex = index;
|
902 |
+
// }
|
903 |
+
// });
|
904 |
+
// }
|
905 |
+
|
906 |
+
// if (PremiumTempsData.PremiumTemplatesBtn) {
|
907 |
+
// setTimeout(function () {
|
908 |
+
// var $addNew = $section.prev('.elementor-add-section').find('.elementor-add-new-section');
|
909 |
+
// $addNew.prepend(addPremiumTemplate);
|
910 |
+
// }, 100);
|
911 |
+
// }
|
912 |
+
|
913 |
+
// }
|
914 |
+
// );
|
915 |
+
|
916 |
+
},
|
917 |
+
|
918 |
+
getFilter: function (name) {
|
919 |
+
|
920 |
+
return this.channels.templates.request('filter:' + name);
|
921 |
+
},
|
922 |
+
|
923 |
+
setFilter: function (name, value) {
|
924 |
+
this.channels.templates.reply('filter:' + name, value);
|
925 |
+
this.channels.templates.trigger('filter:change');
|
926 |
+
},
|
927 |
+
|
928 |
+
getTab: function () {
|
929 |
+
return this.channels.tabs.request('filter:tabs');
|
930 |
+
},
|
931 |
+
|
932 |
+
setTab: function (value, silent) {
|
933 |
+
|
934 |
+
this.channels.tabs.reply('filter:tabs', value);
|
935 |
+
|
936 |
+
if (!silent) {
|
937 |
+
this.channels.tabs.trigger('filter:change');
|
938 |
+
}
|
939 |
+
|
940 |
+
},
|
941 |
+
|
942 |
+
getTabs: function () {
|
943 |
+
|
944 |
+
var tabs = [];
|
945 |
+
|
946 |
+
_.each(this.tabs, function (item, slug) {
|
947 |
+
tabs.push({
|
948 |
+
slug: slug,
|
949 |
+
title: item.title
|
950 |
+
});
|
951 |
+
});
|
952 |
+
|
953 |
+
return tabs;
|
954 |
+
},
|
955 |
+
|
956 |
+
getPreview: function (name) {
|
957 |
+
return this.channels.layout.request('preview');
|
958 |
+
},
|
959 |
+
|
960 |
+
setPreview: function (value, silent) {
|
961 |
+
|
962 |
+
this.channels.layout.reply('preview', value);
|
963 |
+
|
964 |
+
if (!silent) {
|
965 |
+
this.channels.layout.trigger('preview:change');
|
966 |
+
}
|
967 |
+
},
|
968 |
+
|
969 |
+
getKeywords: function () {
|
970 |
+
|
971 |
+
var keywords = [];
|
972 |
+
|
973 |
+
_.each(this.keywords, function (title, slug) {
|
974 |
+
tabs.push({
|
975 |
+
slug: slug,
|
976 |
+
title: title
|
977 |
+
});
|
978 |
+
});
|
979 |
+
|
980 |
+
return keywords;
|
981 |
+
},
|
982 |
+
|
983 |
+
showTemplatesModal: function () {
|
984 |
+
|
985 |
+
this.getModal().show();
|
986 |
+
|
987 |
+
if (!this.layout) {
|
988 |
+
this.layout = new PremiumEditorViews.ModalLayoutView();
|
989 |
+
this.layout.showLoadingView();
|
990 |
+
}
|
991 |
+
|
992 |
+
this.setTab(this.defaultTab, true);
|
993 |
+
this.requestTemplates(this.defaultTab);
|
994 |
+
this.setPreview('initial');
|
995 |
+
|
996 |
+
},
|
997 |
+
|
998 |
+
requestTemplates: function (tabName) {
|
999 |
+
|
1000 |
+
var self = this,
|
1001 |
+
tab = self.tabs[tabName];
|
1002 |
+
|
1003 |
+
self.setFilter('category', false);
|
1004 |
+
|
1005 |
+
if (tab.data.templates && tab.data.categories) {
|
1006 |
+
self.layout.showTemplatesView(tab.data.templates, tab.data.categories, tab.data.keywords);
|
1007 |
+
} else {
|
1008 |
+
$.ajax({
|
1009 |
+
url: ajaxurl,
|
1010 |
+
type: 'get',
|
1011 |
+
dataType: 'json',
|
1012 |
+
data: {
|
1013 |
+
action: 'premium_get_templates',
|
1014 |
+
tab: tabName
|
1015 |
+
},
|
1016 |
+
success: function (response) {
|
1017 |
+
|
1018 |
+
console.log("%c Templates Retrieved Successfully!!", "color: #7a7a7a; background-color: #eee;");
|
1019 |
+
|
1020 |
+
var templates = new PremiumEditorViews.LibraryCollection(response.data.templates),
|
1021 |
+
categories = new PremiumEditorViews.CategoriesCollection(response.data.categories);
|
1022 |
+
|
1023 |
+
self.tabs[tabName].data = {
|
1024 |
+
templates: templates,
|
1025 |
+
categories: categories,
|
1026 |
+
keywords: response.data.keywords
|
1027 |
+
};
|
1028 |
+
|
1029 |
+
self.layout.showTemplatesView(templates, categories, response.data.keywords);
|
1030 |
+
|
1031 |
+
},
|
1032 |
+
error: function (err) {
|
1033 |
+
console.log(err);
|
1034 |
+
}
|
1035 |
+
});
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
},
|
1039 |
+
|
1040 |
+
closeModal: function () {
|
1041 |
+
this.getModal().hide();
|
1042 |
+
},
|
1043 |
+
|
1044 |
+
getModal: function () {
|
1045 |
+
|
1046 |
+
if (!this.modal) {
|
1047 |
+
this.modal = elementor.dialogsManager.createWidget('lightbox', {
|
1048 |
+
id: 'premium-template-modal',
|
1049 |
+
className: 'elementor-templates-modal',
|
1050 |
+
closeButton: false
|
1051 |
+
});
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
return this.modal;
|
1055 |
+
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
};
|
1059 |
+
|
1060 |
+
$(window).on('elementor:init', PremiumEditor.init);
|
1061 |
+
|
1062 |
})(jQuery);
|
assets/frontend/js/premium-dis-conditions.js
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
(function ($) {
|
2 |
-
|
3 |
-
$(window).on('elementor/frontend/init', function () {
|
4 |
-
|
5 |
-
//Time range condition cookie.
|
6 |
-
var localTimeZone = new Date().toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1],
|
7 |
-
isSecured = (document.location.protocol === 'https:') ? 'secure' : '';
|
8 |
-
|
9 |
-
document.cookie = "localTimeZone=" + localTimeZone + ";SameSite=Strict;" + isSecured;
|
10 |
-
|
11 |
-
//Returning User condition cookie.
|
12 |
-
if (elementorFrontend.config.post.id)
|
13 |
-
document.cookie = "isReturningVisitor" + elementorFrontend.config.post.id + "=true;SameSite=Strict;" + isSecured;
|
14 |
-
|
15 |
-
});
|
16 |
-
|
17 |
-
})(jQuery);
|
1 |
+
(function ($) {
|
2 |
+
|
3 |
+
$(window).on('elementor/frontend/init', function () {
|
4 |
+
|
5 |
+
//Time range condition cookie.
|
6 |
+
var localTimeZone = new Date().toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1],
|
7 |
+
isSecured = (document.location.protocol === 'https:') ? 'secure' : '';
|
8 |
+
|
9 |
+
document.cookie = "localTimeZone=" + localTimeZone + ";SameSite=Strict;" + isSecured;
|
10 |
+
|
11 |
+
//Returning User condition cookie.
|
12 |
+
if (elementorFrontend.config.post.id)
|
13 |
+
document.cookie = "isReturningVisitor" + elementorFrontend.config.post.id + "=true;SameSite=Strict;" + isSecured;
|
14 |
+
|
15 |
+
});
|
16 |
+
|
17 |
+
})(jQuery);
|
assets/frontend/js/premium-woo-products.js
CHANGED
@@ -1,647 +1,674 @@
|
|
1 |
-
(function ($) {
|
2 |
-
|
3 |
-
var PremiumWooProductsHandler = function ($scope, $) {
|
4 |
-
var instance = null;
|
5 |
-
|
6 |
-
instance = new premiumWooProducts($scope);
|
7 |
-
instance.init();
|
8 |
-
};
|
9 |
-
|
10 |
-
window.premiumWooProducts = function ($scope) {
|
11 |
-
|
12 |
-
var self = this,
|
13 |
-
$elem = $scope.find(".premium-woocommerce"),
|
14 |
-
skin = $scope.find('.premium-woocommerce').data('skin'),
|
15 |
-
html = null,
|
16 |
-
canLoadMore = true;
|
17 |
-
|
18 |
-
//Check Quick View
|
19 |
-
var isQuickView = $elem.data("quick-view");
|
20 |
-
|
21 |
-
if ("yes" === isQuickView) {
|
22 |
-
|
23 |
-
var widgetID = $scope.data("id"),
|
24 |
-
$modal = $elem.siblings(".premium-woo-quick-view-" + widgetID),
|
25 |
-
$qvModal = $modal.find('#premium-woo-quick-view-modal'),
|
26 |
-
$contentWrap = $qvModal.find('#premium-woo-quick-view-content'),
|
27 |
-
$wrapper = $qvModal.find('.premium-woo-content-main-wrapper'),
|
28 |
-
$backWrap = $modal.find('.premium-woo-quick-view-back'),
|
29 |
-
$qvLoader = $modal.find('.premium-woo-quick-view-loader');
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
self.init = function () {
|
34 |
-
|
35 |
-
self.handleProductsCarousel();
|
36 |
-
|
37 |
-
if ("yes" === isQuickView) {
|
38 |
-
self.handleProductQuickView();
|
39 |
-
}
|
40 |
-
|
41 |
-
self.handleProductPagination();
|
42 |
-
|
43 |
-
self.handleLoadMore();
|
44 |
-
|
45 |
-
self.handleAddToCart();
|
46 |
-
|
47 |
-
if ("grid_6" === skin) {
|
48 |
-
self.handleGalleryImages();
|
49 |
-
}
|
50 |
-
|
51 |
-
if (["grid_7", "grid_11"].includes(skin)) {
|
52 |
-
|
53 |
-
self.handleGalleryCarousel(skin);
|
54 |
-
|
55 |
-
if ("grid_11" === skin) {
|
56 |
-
self.handleGalleryNav();
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
if ($elem.hasClass("premium-woo-products-metro")) {
|
61 |
-
|
62 |
-
self.handleGridMetro();
|
63 |
-
|
64 |
-
$(window).on("resize", self.handleGridMetro);
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
var
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
}
|
322 |
-
|
323 |
-
if (
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
.
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
}
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
647 |
})(jQuery);
|
1 |
+
(function ($) {
|
2 |
+
|
3 |
+
var PremiumWooProductsHandler = function ($scope, $) {
|
4 |
+
var instance = null;
|
5 |
+
|
6 |
+
instance = new premiumWooProducts($scope);
|
7 |
+
instance.init();
|
8 |
+
};
|
9 |
+
|
10 |
+
window.premiumWooProducts = function ($scope) {
|
11 |
+
|
12 |
+
var self = this,
|
13 |
+
$elem = $scope.find(".premium-woocommerce"),
|
14 |
+
skin = $scope.find('.premium-woocommerce').data('skin'),
|
15 |
+
html = null,
|
16 |
+
canLoadMore = true;
|
17 |
+
|
18 |
+
//Check Quick View
|
19 |
+
var isQuickView = $elem.data("quick-view");
|
20 |
+
|
21 |
+
if ("yes" === isQuickView) {
|
22 |
+
|
23 |
+
var widgetID = $scope.data("id"),
|
24 |
+
$modal = $elem.siblings(".premium-woo-quick-view-" + widgetID),
|
25 |
+
$qvModal = $modal.find('#premium-woo-quick-view-modal'),
|
26 |
+
$contentWrap = $qvModal.find('#premium-woo-quick-view-content'),
|
27 |
+
$wrapper = $qvModal.find('.premium-woo-content-main-wrapper'),
|
28 |
+
$backWrap = $modal.find('.premium-woo-quick-view-back'),
|
29 |
+
$qvLoader = $modal.find('.premium-woo-quick-view-loader');
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
self.init = function () {
|
34 |
+
|
35 |
+
self.handleProductsCarousel();
|
36 |
+
|
37 |
+
if ("yes" === isQuickView) {
|
38 |
+
self.handleProductQuickView();
|
39 |
+
}
|
40 |
+
|
41 |
+
self.handleProductPagination();
|
42 |
+
|
43 |
+
self.handleLoadMore();
|
44 |
+
|
45 |
+
self.handleAddToCart();
|
46 |
+
|
47 |
+
if ("grid_6" === skin) {
|
48 |
+
self.handleGalleryImages();
|
49 |
+
}
|
50 |
+
|
51 |
+
if (["grid_7", "grid_11"].includes(skin)) {
|
52 |
+
|
53 |
+
self.handleGalleryCarousel(skin);
|
54 |
+
|
55 |
+
if ("grid_11" === skin) {
|
56 |
+
self.handleGalleryNav();
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
if ($elem.hasClass("premium-woo-products-metro")) {
|
61 |
+
|
62 |
+
self.handleGridMetro();
|
63 |
+
|
64 |
+
$(window).on("resize", self.handleGridMetro);
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
// place product title above thumbnail.
|
69 |
+
if ($scope.hasClass('premium-woo-title-above-yes')) {
|
70 |
+
self.handleTitlePos();
|
71 |
+
}
|
72 |
+
|
73 |
+
};
|
74 |
+
|
75 |
+
self.handleTitlePos = function () {
|
76 |
+
|
77 |
+
var hasTitle = $elem.find('.woocommerce-loop-product__title').length > 0 ? true : false,
|
78 |
+
hasImg = $elem.find('.premium-woo-product-thumbnail .woocommerce-loop-product__link img').length > 0 ? true : false;
|
79 |
+
|
80 |
+
if (!hasTitle || !hasImg) {
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
var $products = $elem.find('li.product');
|
85 |
+
|
86 |
+
$products.each(function (index, product) {
|
87 |
+
|
88 |
+
var $title = $(product).find('.woocommerce-loop-product__title').parent(),
|
89 |
+
$thumbnail = $(product).find('.premium-woo-product-thumbnail');
|
90 |
+
|
91 |
+
$title.insertBefore($thumbnail);
|
92 |
+
|
93 |
+
});
|
94 |
+
|
95 |
+
};
|
96 |
+
|
97 |
+
self.handleProductsCarousel = function () {
|
98 |
+
|
99 |
+
var carousel = $elem.data("woo_carousel");
|
100 |
+
|
101 |
+
if (!carousel)
|
102 |
+
return;
|
103 |
+
|
104 |
+
var $products = $elem.find('ul.products');
|
105 |
+
|
106 |
+
carousel['customPaging'] = function () {
|
107 |
+
return '<i class="fas fa-circle"></i>';
|
108 |
+
};
|
109 |
+
|
110 |
+
$products.on("init", function (event) {
|
111 |
+
setTimeout(function () {
|
112 |
+
$elem.removeClass("premium-carousel-hidden");
|
113 |
+
}, 100);
|
114 |
+
|
115 |
+
});
|
116 |
+
|
117 |
+
$products.slick(carousel);
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
};
|
122 |
+
|
123 |
+
self.handleGridMetro = function () {
|
124 |
+
|
125 |
+
var $products = $elem.find("ul.products"),
|
126 |
+
currentDevice = elementorFrontend.getCurrentDeviceMode(),
|
127 |
+
suffix = "";
|
128 |
+
|
129 |
+
//Grid Parameters
|
130 |
+
var gridWidth = $products.width(),
|
131 |
+
cellSize = Math.floor(gridWidth / 12);
|
132 |
+
|
133 |
+
|
134 |
+
var metroStyle = $elem.data("metro-style");
|
135 |
+
|
136 |
+
if ("tablet" === currentDevice) {
|
137 |
+
suffix = "_tablet";
|
138 |
+
} else if ("mobile" === currentDevice) {
|
139 |
+
suffix = "_mobile";
|
140 |
+
}
|
141 |
+
|
142 |
+
if ('custom' === metroStyle) {
|
143 |
+
|
144 |
+
var wPatternLength = 0,
|
145 |
+
hPatternLength = 0;
|
146 |
+
|
147 |
+
var settings = $elem.data("metro");
|
148 |
+
|
149 |
+
//Get Products Width/Height Pattern
|
150 |
+
var wPattern = settings['wPattern' + suffix],
|
151 |
+
hPattern = settings['hPattern' + suffix];
|
152 |
+
|
153 |
+
if ("" === wPattern)
|
154 |
+
wPattern = "12";
|
155 |
+
|
156 |
+
if ("" === hPattern)
|
157 |
+
hPattern = "12";
|
158 |
+
|
159 |
+
wPattern = wPattern.split(',');
|
160 |
+
hPattern = hPattern.split(',');
|
161 |
+
|
162 |
+
wPatternLength = wPatternLength + wPattern.length;
|
163 |
+
hPatternLength = hPatternLength + hPattern.length;
|
164 |
+
|
165 |
+
$products.find("li.product").each(function (index, product) {
|
166 |
+
|
167 |
+
var wIndex = index % wPatternLength,
|
168 |
+
hIndex = index % hPatternLength;
|
169 |
+
|
170 |
+
var wCell = (parseInt(wPattern[wIndex])),
|
171 |
+
hCell = (parseInt(hPattern[hIndex]));
|
172 |
+
|
173 |
+
$(product).css({
|
174 |
+
width: Math.floor(wCell) * cellSize,
|
175 |
+
height: Math.floor(hCell) * cellSize
|
176 |
+
});
|
177 |
+
});
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
$products
|
182 |
+
.imagesLoaded(function () { })
|
183 |
+
.done(
|
184 |
+
function () {
|
185 |
+
$products.isotope({
|
186 |
+
itemSelector: "li.product",
|
187 |
+
percentPosition: true,
|
188 |
+
animationOptions: {
|
189 |
+
duration: 750,
|
190 |
+
easing: "linear"
|
191 |
+
},
|
192 |
+
layoutMode: "masonry",
|
193 |
+
masonry: {
|
194 |
+
columnWidth: cellSize
|
195 |
+
}
|
196 |
+
});
|
197 |
+
});
|
198 |
+
};
|
199 |
+
|
200 |
+
self.handleProductQuickView = function () {
|
201 |
+
$modal.appendTo(document.body);
|
202 |
+
|
203 |
+
$elem.on('click', '.premium-woo-qv-btn, .premium-woo-qv-data', self.triggerQuickViewModal);
|
204 |
+
|
205 |
+
window.addEventListener("resize", function () {
|
206 |
+
self.updateQuickViewHeight();
|
207 |
+
});
|
208 |
+
|
209 |
+
};
|
210 |
+
|
211 |
+
self.triggerQuickViewModal = function (event) {
|
212 |
+
event.preventDefault();
|
213 |
+
|
214 |
+
var $this = $(this),
|
215 |
+
productID = $this.data('product-id');
|
216 |
+
|
217 |
+
if (!$qvModal.hasClass('loading'))
|
218 |
+
$qvModal.addClass('loading');
|
219 |
+
|
220 |
+
if (!$backWrap.hasClass('premium-woo-quick-view-active'))
|
221 |
+
$backWrap.addClass('premium-woo-quick-view-active');
|
222 |
+
|
223 |
+
self.getProductByAjax(productID);
|
224 |
+
|
225 |
+
self.addCloseEvents();
|
226 |
+
};
|
227 |
+
|
228 |
+
self.getProductByAjax = function (itemID) {
|
229 |
+
|
230 |
+
$.ajax({
|
231 |
+
url: PremiumWooSettings.ajaxurl,
|
232 |
+
data: {
|
233 |
+
action: 'get_woo_product_qv',
|
234 |
+
product_id: itemID,
|
235 |
+
security: PremiumWooSettings.qv_nonce
|
236 |
+
},
|
237 |
+
dataType: 'html',
|
238 |
+
type: 'GET',
|
239 |
+
beforeSend: function () {
|
240 |
+
|
241 |
+
$qvLoader.append('<div class="premium-loading-feed"><div class="premium-loader"></div></div>');
|
242 |
+
|
243 |
+
},
|
244 |
+
success: function (data) {
|
245 |
+
|
246 |
+
$qvLoader.find('.premium-loading-feed').remove();
|
247 |
+
|
248 |
+
//Insert the product content in the quick view modal.
|
249 |
+
$contentWrap.html(data);
|
250 |
+
self.handleQuickViewModal();
|
251 |
+
},
|
252 |
+
error: function (err) {
|
253 |
+
console.log(err);
|
254 |
+
}
|
255 |
+
});
|
256 |
+
|
257 |
+
};
|
258 |
+
|
259 |
+
self.addCloseEvents = function () {
|
260 |
+
|
261 |
+
var $closeBtn = $qvModal.find('#premium-woo-quick-view-close');
|
262 |
+
|
263 |
+
$(document).keyup(function (e) {
|
264 |
+
if (e.keyCode === 27)
|
265 |
+
self.closeModal();
|
266 |
+
});
|
267 |
+
|
268 |
+
$closeBtn.on('click', function (e) {
|
269 |
+
e.preventDefault();
|
270 |
+
self.closeModal();
|
271 |
+
});
|
272 |
+
|
273 |
+
$wrapper.on('click', function (e) {
|
274 |
+
|
275 |
+
if (this === e.target)
|
276 |
+
self.closeModal();
|
277 |
+
|
278 |
+
});
|
279 |
+
};
|
280 |
+
|
281 |
+
self.handleQuickViewModal = function () {
|
282 |
+
|
283 |
+
$contentWrap.imagesLoaded(function () {
|
284 |
+
self.handleQuickViewSlider();
|
285 |
+
});
|
286 |
+
|
287 |
+
};
|
288 |
+
|
289 |
+
self.getBarWidth = function () {
|
290 |
+
|
291 |
+
var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
|
292 |
+
// Append our div, do our calculation and then remove it
|
293 |
+
$('body').append(div);
|
294 |
+
var w1 = $('div', div).innerWidth();
|
295 |
+
div.css('overflow-y', 'scroll');
|
296 |
+
var w2 = $('div', div).innerWidth();
|
297 |
+
$(div).remove();
|
298 |
+
|
299 |
+
return (w1 - w2);
|
300 |
+
};
|
301 |
+
|
302 |
+
self.handleQuickViewSlider = function () {
|
303 |
+
|
304 |
+
var $productSlider = $qvModal.find('.premium-woo-qv-image-slider');
|
305 |
+
|
306 |
+
if ($productSlider.find('li').length > 1) {
|
307 |
+
|
308 |
+
$productSlider.flexslider({
|
309 |
+
animation: "slide",
|
310 |
+
start: function (slider) {
|
311 |
+
setTimeout(function () {
|
312 |
+
self.updateQuickViewHeight(true, true);
|
313 |
+
}, 300);
|
314 |
+
},
|
315 |
+
});
|
316 |
+
|
317 |
+
} else {
|
318 |
+
setTimeout(function () {
|
319 |
+
self.updateQuickViewHeight(true);
|
320 |
+
}, 300);
|
321 |
+
}
|
322 |
+
|
323 |
+
if (!$qvModal.hasClass('active')) {
|
324 |
+
|
325 |
+
setTimeout(function () {
|
326 |
+
$qvModal.removeClass('loading').addClass('active');
|
327 |
+
|
328 |
+
var barWidth = self.getBarWidth();
|
329 |
+
|
330 |
+
$("html").css('margin-right', barWidth);
|
331 |
+
$("html").addClass('premium-woo-qv-opened');
|
332 |
+
}, 350);
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
};
|
337 |
+
|
338 |
+
self.updateQuickViewHeight = function (update_css, isCarousel) {
|
339 |
+
var $quickView = $contentWrap,
|
340 |
+
imgHeight = $quickView.find('.product .premium-woo-qv-image-slider').first().height(),
|
341 |
+
summary = $quickView.find('.product .summary.entry-summary'),
|
342 |
+
content = summary.css('content');
|
343 |
+
|
344 |
+
if ('undefined' != typeof content && 544 == content.replace(/[^0-9]/g, '') && 0 != imgHeight && null !== imgHeight) {
|
345 |
+
summary.css('height', imgHeight);
|
346 |
+
} else {
|
347 |
+
summary.css('height', '');
|
348 |
+
}
|
349 |
+
|
350 |
+
if (true === update_css)
|
351 |
+
$qvModal.css('opacity', 1);
|
352 |
+
|
353 |
+
//Make sure slider images have same height as summary.
|
354 |
+
if (isCarousel)
|
355 |
+
$quickView.find('.product .premium-woo-qv-image-slider img').height(summary.outerHeight());
|
356 |
+
|
357 |
+
};
|
358 |
+
|
359 |
+
self.closeModal = function () {
|
360 |
+
|
361 |
+
$backWrap.removeClass('premium-woo-quick-view-active');
|
362 |
+
|
363 |
+
$qvModal.removeClass('active').removeClass('loading');
|
364 |
+
|
365 |
+
$('html').removeClass('premium-woo-qv-opened');
|
366 |
+
|
367 |
+
$('html').css('margin-right', '');
|
368 |
+
|
369 |
+
setTimeout(function () {
|
370 |
+
$contentWrap.html('');
|
371 |
+
}, 600);
|
372 |
+
|
373 |
+
};
|
374 |
+
|
375 |
+
self.handleAddToCart = function () {
|
376 |
+
|
377 |
+
$elem
|
378 |
+
.on('click', '.instock .premium-woo-cart-btn.product_type_simple', self.onAddCartBtnClick).on('premium_product_add_to_cart', self.handleAddCartBtnClick)
|
379 |
+
.on('click', '.instock .premium-woo-atc-button .button.product_type_simple', self.onAddCartBtnClick).on('premium_product_add_to_cart', self.handleAddCartBtnClick);
|
380 |
+
|
381 |
+
};
|
382 |
+
|
383 |
+
self.onAddCartBtnClick = function (event) {
|
384 |
+
|
385 |
+
var $this = $(this);
|
386 |
+
|
387 |
+
var productID = $this.data('product_id'),
|
388 |
+
quantity = 1;
|
389 |
+
|
390 |
+
|
391 |
+
//If current product has no defined ID.
|
392 |
+
if (!productID)
|
393 |
+
return;
|
394 |
+
|
395 |
+
if (!$this.data("added-to-cart")) {
|
396 |
+
event.preventDefault();
|
397 |
+
} else {
|
398 |
+
return;
|
399 |
+
}
|
400 |
+
|
401 |
+
$this.removeClass('added').addClass('adding');
|
402 |
+
|
403 |
+
if (!$this.hasClass('premium-woo-cart-btn')) {
|
404 |
+
$this.append('<span class="premium-woo-cart-loader fas fa-cog"></span>')
|
405 |
+
}
|
406 |
+
|
407 |
+
$.ajax({
|
408 |
+
url: PremiumWooSettings.ajaxurl,
|
409 |
+
type: 'POST',
|
410 |
+
data: {
|
411 |
+
action: 'premium_woo_add_cart_product',
|
412 |
+
nonce: PremiumWooSettings.cta_nonce,
|
413 |
+
product_id: productID,
|
414 |
+
quantity: quantity,
|
415 |
+
},
|
416 |
+
success: function () {
|
417 |
+
$(document.body).trigger('wc_fragment_refresh');
|
418 |
+
$elem.trigger('premium_product_add_to_cart', [$this]);
|
419 |
+
|
420 |
+
if ('grid_10' === skin || !$this.hasClass('premium-woo-cart-btn')) {
|
421 |
+
setTimeout(function () {
|
422 |
+
|
423 |
+
var viewCartTxt = $this.siblings('.added_to_cart').text();
|
424 |
+
|
425 |
+
if ('' == viewCartTxt)
|
426 |
+
viewCartTxt = 'View Cart';
|
427 |
+
|
428 |
+
$this.removeClass('add_to_cart_button').attr('href', PremiumWooSettings.woo_cart_url).text(viewCartTxt);
|
429 |
+
|
430 |
+
$this.attr('data-added-to-cart', true);
|
431 |
+
}, 200);
|
432 |
+
|
433 |
+
}
|
434 |
+
|
435 |
+
}
|
436 |
+
});
|
437 |
+
|
438 |
+
};
|
439 |
+
|
440 |
+
self.handleAddCartBtnClick = function (event, $btn) {
|
441 |
+
|
442 |
+
if (!$btn)
|
443 |
+
return;
|
444 |
+
|
445 |
+
$btn.removeClass('adding').addClass('added');
|
446 |
+
|
447 |
+
};
|
448 |
+
|
449 |
+
self.handleGalleryImages = function () {
|
450 |
+
|
451 |
+
$elem.on('click', '.premium-woo-product__gallery_image', function () {
|
452 |
+
var $thisImg = $(this),
|
453 |
+
$closestThumb = $thisImg.closest(".premium-woo-product-thumbnail"),
|
454 |
+
imgSrc = $thisImg.attr('src');
|
455 |
+
|
456 |
+
if ($closestThumb.find(".premium-woo-product__on_hover").length < 1) {
|
457 |
+
$closestThumb.find(".woocommerce-loop-product__link img").replaceWith($thisImg.clone(true));
|
458 |
+
} else {
|
459 |
+
$closestThumb.find(".premium-woo-product__on_hover").attr('src', imgSrc);
|
460 |
+
}
|
461 |
+
|
462 |
+
});
|
463 |
+
|
464 |
+
};
|
465 |
+
|
466 |
+
self.handleGalleryNav = function () {
|
467 |
+
|
468 |
+
$elem.on('click', '.premium-woo-product-gallery-images .premium-woo-product__gallery_image', function () {
|
469 |
+
var imgParent = $(this).parentsUntil(".premium-woo-product-wrapper")[2],
|
470 |
+
slickContainer = $(imgParent).siblings('.premium-woo-product-thumbnail'),
|
471 |
+
imgIndex = $(this).index() + 1;
|
472 |
+
|
473 |
+
slickContainer.slick('slickGoTo', imgIndex);
|
474 |
+
});
|
475 |
+
};
|
476 |
+
|
477 |
+
self.handleGalleryCarousel = function (skin) {
|
478 |
+
|
479 |
+
var products = $elem.find('.premium-woo-product-thumbnail'),
|
480 |
+
prevArrow = '<a type="button" data-role="none" class="carousel-arrow carousel-prev" aria-label="Previous" role="button" style=""><i class="fas fa-angle-left" aria-hidden="true"></i></a>',
|
481 |
+
nextArrow = '<a type="button" data-role="none" class="carousel-arrow carousel-next" aria-label="Next" role="button" style=""><i class="fas fa-angle-right" aria-hidden="true"></i></a>',
|
482 |
+
infinite = 'grid_11' === skin ? false : true,
|
483 |
+
slickSettings = {
|
484 |
+
infinite: infinite,
|
485 |
+
slidesToShow: 1,
|
486 |
+
slidesToScroll: 1,
|
487 |
+
draggable: true,
|
488 |
+
autoplay: false,
|
489 |
+
rtl: elementorFrontend.config.is_rtl,
|
490 |
+
};
|
491 |
+
|
492 |
+
if ('grid_11' !== skin) {
|
493 |
+
slickSettings.nextArrow = nextArrow;
|
494 |
+
slickSettings.prevArrow = prevArrow;
|
495 |
+
} else {
|
496 |
+
slickSettings.arrows = false;
|
497 |
+
}
|
498 |
+
|
499 |
+
products.each(function (index, product) {
|
500 |
+
$imgs = $(product).find('a').length;
|
501 |
+
|
502 |
+
if ($imgs > 1) {
|
503 |
+
$(product).not('.slick-initialized').slick(slickSettings);
|
504 |
+
}
|
505 |
+
});
|
506 |
+
}
|
507 |
+
|
508 |
+
self.handleLoadMore = function () {
|
509 |
+
|
510 |
+
var $loadMoreBtn = $elem.find(".premium-woo-load-more-btn"),
|
511 |
+
page_number = 2,
|
512 |
+
pageID = $elem.data('page-id');
|
513 |
+
|
514 |
+
if ($loadMoreBtn.length < 1)
|
515 |
+
return;
|
516 |
+
|
517 |
+
$loadMoreBtn.on('click', function (e) {
|
518 |
+
|
519 |
+
if (!canLoadMore)
|
520 |
+
return;
|
521 |
+
|
522 |
+
canLoadMore = false;
|
523 |
+
|
524 |
+
$elem.find('ul.products').after('<div class="premium-loading-feed"><div class="premium-loader"></div></div>');
|
525 |
+
|
526 |
+
$loadMoreBtn.css("opacity", 0.3);
|
527 |
+
|
528 |
+
$.ajax({
|
529 |
+
url: PremiumWooSettings.ajaxurl,
|
530 |
+
data: {
|
531 |
+
action: 'get_woo_products',
|
532 |
+
pageID: pageID,
|
533 |
+
elemID: $scope.data('id'),
|
534 |
+
category: $loadMoreBtn.data("tax"),
|
535 |
+
skin: skin,
|
536 |
+
page_number: page_number,
|
537 |
+
nonce: PremiumWooSettings.products_nonce,
|
538 |
+
},
|
539 |
+
dataType: 'json',
|
540 |
+
type: 'POST',
|
541 |
+
success: function (data) {
|
542 |
+
|
543 |
+
html = data.data.html;
|
544 |
+
|
545 |
+
//If the number of coming products is 0, then remove the button.
|
546 |
+
var newProductsLength = $loadMoreBtn.data("products") - html.match(/<li/g).length;
|
547 |
+
if (newProductsLength < 1)
|
548 |
+
$loadMoreBtn.remove();
|
549 |
+
|
550 |
+
canLoadMore = true;
|
551 |
+
|
552 |
+
$elem.find('.premium-loading-feed').remove();
|
553 |
+
$loadMoreBtn.css("opacity", 1);
|
554 |
+
|
555 |
+
var $currentProducts = $elem.find('ul.products');
|
556 |
+
|
557 |
+
//Remove the wrapper <ul>
|
558 |
+
html = html.replace(html.substring(0, html.indexOf('>') + 1), '');
|
559 |
+
html = html.replace("</ul>", "");
|
560 |
+
|
561 |
+
|
562 |
+
$loadMoreBtn.find(".premium-woo-products-num").text("(" + newProductsLength + ")");
|
563 |
+
|
564 |
+
$loadMoreBtn.data("products", newProductsLength);
|
565 |
+
|
566 |
+
$currentProducts.append(html);
|
567 |
+
|
568 |
+
// //Trigger carousel for products in the next pages.
|
569 |
+
if ("grid_7" === skin || "grid_11" === skin) {
|
570 |
+
self.handleGalleryCarousel(skin);
|
571 |
+
}
|
572 |
+
|
573 |
+
page_number++;
|
574 |
+
|
575 |
+
|
576 |
+
},
|
577 |
+
error: function (err) {
|
578 |
+
console.log(err);
|
579 |
+
}
|
580 |
+
});
|
581 |
+
|
582 |
+
|
583 |
+
});
|
584 |
+
}
|
585 |
+
|
586 |
+
self.handleProductPagination = function () {
|
587 |
+
|
588 |
+
$elem.on('click', '.premium-woo-products-pagination a.page-numbers', function (e) {
|
589 |
+
|
590 |
+
var $targetPage = $(this);
|
591 |
+
|
592 |
+
if ($elem.hasClass('premium-woo-query-main'))
|
593 |
+
return;
|
594 |
+
|
595 |
+
e.preventDefault();
|
596 |
+
|
597 |
+
$elem.find('ul.products').after('<div class="premium-loading-feed"><div class="premium-loader"></div></div>');
|
598 |
+
|
599 |
+
var pageID = $elem.data('page-id'),
|
600 |
+
currentPage = parseInt($elem.find('.page-numbers.current').html()),
|
601 |
+
page_number = 1;
|
602 |
+
|
603 |
+
if ($targetPage.hasClass('next')) {
|
604 |
+
page_number = currentPage + 1;
|
605 |
+
} else if ($targetPage.hasClass('prev')) {
|
606 |
+
page_number = currentPage - 1;
|
607 |
+
} else {
|
608 |
+
page_number = $targetPage.html();
|
609 |
+
}
|
610 |
+
|
611 |
+
$.ajax({
|
612 |
+
url: PremiumWooSettings.ajaxurl,
|
613 |
+
data: {
|
614 |
+
action: 'get_woo_products',
|
615 |
+
pageID: pageID,
|
616 |
+
elemID: $scope.data('id'),
|
617 |
+
category: '',
|
618 |
+
skin: skin,
|
619 |
+
page_number: page_number,
|
620 |
+
nonce: PremiumWooSettings.products_nonce,
|
621 |
+
},
|
622 |
+
dataType: 'json',
|
623 |
+
type: 'POST',
|
624 |
+
success: function (data) {
|
625 |
+
|
626 |
+
$elem.find('.premium-loading-feed').remove();
|
627 |
+
|
628 |
+
$('html, body').animate({
|
629 |
+
scrollTop: (($scope.find('.premium-woocommerce').offset().top) - 100)
|
630 |
+
}, 'slow');
|
631 |
+
|
632 |
+
var $currentProducts = $elem.find('ul.products');
|
633 |
+
|
634 |
+
$currentProducts.replaceWith(data.data.html);
|
635 |
+
|
636 |
+
$elem.find('.premium-woo-products-pagination').replaceWith(data.data.pagination);
|
637 |
+
|
638 |
+
//Trigger carousel for products in the next pages.
|
639 |
+
if ("grid_7" === skin || "grid_11" === skin) {
|
640 |
+
self.handleGalleryCarousel(skin);
|
641 |
+
}
|
642 |
+
|
643 |
+
if ($elem.hasClass("premium-woo-products-metro"))
|
644 |
+
self.handleGridMetro();
|
645 |
+
|
646 |
+
},
|
647 |
+
error: function (err) {
|
648 |
+
console.log(err);
|
649 |
+
}
|
650 |
+
});
|
651 |
+
|
652 |
+
});
|
653 |
+
|
654 |
+
};
|
655 |
+
|
656 |
+
|
657 |
+
};
|
658 |
+
|
659 |
+
|
660 |
+
//Elementor JS Hooks.
|
661 |
+
$(window).on("elementor/frontend/init", function () {
|
662 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-1", PremiumWooProductsHandler);
|
663 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-2", PremiumWooProductsHandler);
|
664 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-3", PremiumWooProductsHandler);
|
665 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-4", PremiumWooProductsHandler);
|
666 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-5", PremiumWooProductsHandler);
|
667 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-6", PremiumWooProductsHandler);
|
668 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-7", PremiumWooProductsHandler);
|
669 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-8", PremiumWooProductsHandler);
|
670 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-9", PremiumWooProductsHandler);
|
671 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-10", PremiumWooProductsHandler);
|
672 |
+
elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-11", PremiumWooProductsHandler);
|
673 |
+
});
|
674 |
})(jQuery);
|
assets/frontend/min-js/premium-woo-products.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(f){function e(e,o){new premiumWooProducts(e).init()}window.premiumWooProducts=function(n){var e,o,a,d,t,i,r,c=this,l=n.find(".premium-woocommerce"),u=n.find(".premium-woocommerce").data("skin"),s=null,m=!0,p=l.data("quick-view");"yes"===p&&(e=n.data("id"),o=l.siblings(".premium-woo-quick-view-"+e),a=o.find("#premium-woo-quick-view-modal"),d=a.find("#premium-woo-quick-view-content"),t=a.find(".premium-woo-content-main-wrapper"),i=o.find(".premium-woo-quick-view-back"),r=o.find(".premium-woo-quick-view-loader")),c.init=function(){c.handleProductsCarousel(),"yes"===p&&c.handleProductQuickView(),c.handleProductPagination(),c.handleLoadMore(),c.handleAddToCart(),"grid_6"===u&&c.handleGalleryImages(),["grid_7","grid_11"].includes(u)&&(c.handleGalleryCarousel(u),"grid_11"===u&&c.handleGalleryNav()),l.hasClass("premium-woo-products-metro")&&(c.handleGridMetro(),f(window).on("resize",c.handleGridMetro))},c.handleProductsCarousel=function(){var e,o=l.data("woo_carousel");o&&(e=l.find("ul.products"),o.customPaging=function(){return'<i class="fas fa-circle"></i>'},e.on("init",function(e){setTimeout(function(){l.removeClass("premium-carousel-hidden")},100)}),e.slick(o))},c.handleGridMetro=function(){var i,n,r,a,e=l.find("ul.products"),o=elementorFrontend.getCurrentDeviceMode(),t="",d=e.width(),c=Math.floor(d/12);"tablet"===o?t="_tablet":"mobile"===o&&(t="_mobile"),"custom"===l.data("metro-style")&&(n=i=0,d=l.data("metro"),r=d["wPattern"+t],""===(a=d["hPattern"+t])&&(a="12"),r=(r=""===r?"12":r).split(","),a=a.split(","),i=0+r.length,n=0+a.length,e.find("li.product").each(function(e,o){var t=e%n,e=parseInt(r[e%i]),t=parseInt(a[t]);f(o).css({width:Math.floor(e)*c,height:Math.floor(t)*c})})),e.imagesLoaded(function(){}).done(function(){e.isotope({itemSelector:"li.product",percentPosition:!0,animationOptions:{duration:750,easing:"linear"},layoutMode:"masonry",masonry:{columnWidth:c}})})},c.handleProductQuickView=function(){o.appendTo(document.body),l.on("click",".premium-woo-qv-btn, .premium-woo-qv-data",c.triggerQuickViewModal),window.addEventListener("resize",function(){c.updateQuickViewHeight()})},c.triggerQuickViewModal=function(e){e.preventDefault();e=f(this).data("product-id");a.hasClass("loading")||a.addClass("loading"),i.hasClass("premium-woo-quick-view-active")||i.addClass("premium-woo-quick-view-active"),c.getProductByAjax(e),c.addCloseEvents()},c.getProductByAjax=function(e){f.ajax({url:PremiumWooSettings.ajaxurl,data:{action:"get_woo_product_qv",product_id:e,security:PremiumWooSettings.qv_nonce},dataType:"html",type:"GET",beforeSend:function(){r.append('<div class="premium-loading-feed"><div class="premium-loader"></div></div>')},success:function(e){r.find(".premium-loading-feed").remove(),d.html(e),c.handleQuickViewModal()},error:function(e){console.log(e)}})},c.addCloseEvents=function(){var e=a.find("#premium-woo-quick-view-close");f(document).keyup(function(e){27===e.keyCode&&c.closeModal()}),e.on("click",function(e){e.preventDefault(),c.closeModal()}),t.on("click",function(e){this===e.target&&c.closeModal()})},c.handleQuickViewModal=function(){d.imagesLoaded(function(){c.handleQuickViewSlider()})},c.getBarWidth=function(){var e=f('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>'),o=(f("body").append(e),f("div",e).innerWidth()),t=(e.css("overflow-y","scroll"),f("div",e).innerWidth());return f(e).remove(),o-t},c.handleQuickViewSlider=function(){var e=a.find(".premium-woo-qv-image-slider");1<e.find("li").length?e.flexslider({animation:"slide",start:function(e){setTimeout(function(){c.updateQuickViewHeight(!0,!0)},300)}}):setTimeout(function(){c.updateQuickViewHeight(!0)},300),a.hasClass("active")||setTimeout(function(){a.removeClass("loading").addClass("active");var e=c.getBarWidth();f("html").css("margin-right",e),f("html").addClass("premium-woo-qv-opened")},350)},c.updateQuickViewHeight=function(e,o){var t=d,i=t.find(".product .premium-woo-qv-image-slider").first().height(),n=t.find(".product .summary.entry-summary"),r=n.css("content");void 0!==r&&544==r.replace(/[^0-9]/g,"")&&0!=i&&null!==i?n.css("height",i):n.css("height",""),!0===e&&a.css("opacity",1),o&&t.find(".product .premium-woo-qv-image-slider img").height(n.outerHeight())},c.closeModal=function(){i.removeClass("premium-woo-quick-view-active"),a.removeClass("active").removeClass("loading"),f("html").removeClass("premium-woo-qv-opened"),f("html").css("margin-right",""),setTimeout(function(){d.html("")},600)},c.handleAddToCart=function(){l.on("click",".instock .premium-woo-cart-btn.product_type_simple",c.onAddCartBtnClick).on("premium_product_add_to_cart",c.handleAddCartBtnClick).on("click",".instock .premium-woo-atc-button .button.product_type_simple",c.onAddCartBtnClick).on("premium_product_add_to_cart",c.handleAddCartBtnClick)},c.onAddCartBtnClick=function(e){var o=f(this),t=o.data("product_id");t&&!o.data("added-to-cart")&&(e.preventDefault(),o.removeClass("added").addClass("adding"),o.hasClass("premium-woo-cart-btn")||o.append('<span class="premium-woo-cart-loader fas fa-cog"></span>'),f.ajax({url:PremiumWooSettings.ajaxurl,type:"POST",data:{action:"premium_woo_add_cart_product",nonce:PremiumWooSettings.cta_nonce,product_id:t,quantity:1},success:function(){f(document.body).trigger("wc_fragment_refresh"),l.trigger("premium_product_add_to_cart",[o]),"grid_10"!==u&&o.hasClass("premium-woo-cart-btn")||setTimeout(function(){var e=o.siblings(".added_to_cart").text();""==e&&(e="View Cart"),o.removeClass("add_to_cart_button").attr("href",PremiumWooSettings.woo_cart_url).text(e),o.attr("data-added-to-cart",!0)},200)}}))},c.handleAddCartBtnClick=function(e,o){o&&o.removeClass("adding").addClass("added")},c.handleGalleryImages=function(){l.on("click",".premium-woo-product__gallery_image",function(){var e=f(this),o=e.closest(".premium-woo-product-thumbnail"),t=e.attr("src");o.find(".premium-woo-product__on_hover").length<1?o.find(".woocommerce-loop-product__link img").replaceWith(e.clone(!0)):o.find(".premium-woo-product__on_hover").attr("src",t)})},c.handleGalleryNav=function(){l.on("click",".premium-woo-product-gallery-images .premium-woo-product__gallery_image",function(){var e=f(this).parentsUntil(".premium-woo-product-wrapper")[2],e=f(e).siblings(".premium-woo-product-thumbnail"),o=f(this).index()+1;e.slick("slickGoTo",o)})},c.handleGalleryCarousel=function(e){var o=l.find(".premium-woo-product-thumbnail"),t={infinite:"grid_11"!==e,slidesToShow:1,slidesToScroll:1,draggable:!0,autoplay:!1,rtl:elementorFrontend.config.is_rtl};"grid_11"!==e?(t.nextArrow='<a type="button" data-role="none" class="carousel-arrow carousel-next" aria-label="Next" role="button" style=""><i class="fas fa-angle-right" aria-hidden="true"></i></a>',t.prevArrow='<a type="button" data-role="none" class="carousel-arrow carousel-prev" aria-label="Previous" role="button" style=""><i class="fas fa-angle-left" aria-hidden="true"></i></a>'):t.arrows=!1,o.each(function(e,o){1<($imgs=f(o).find("a").length)&&f(o).not(".slick-initialized").slick(t)})},c.handleLoadMore=function(){var t=l.find(".premium-woo-load-more-btn"),i=2,o=l.data("page-id");t.length<1||t.on("click",function(e){m&&(m=!1,l.find("ul.products").after('<div class="premium-loading-feed"><div class="premium-loader"></div></div>'),t.css("opacity",.3),f.ajax({url:PremiumWooSettings.ajaxurl,data:{action:"get_woo_products",pageID:o,elemID:n.data("id"),category:t.data("tax"),skin:u,page_number:i,nonce:PremiumWooSettings.products_nonce},dataType:"json",type:"POST",success:function(e){s=e.data.html;var e=t.data("products")-s.match(/<li/g).length,o=(e<1&&t.remove(),m=!0,l.find(".premium-loading-feed").remove(),t.css("opacity",1),l.find("ul.products"));s=(s=s.replace(s.substring(0,s.indexOf(">")+1),"")).replace("</ul>",""),t.find(".premium-woo-products-num").text("("+e+")"),t.data("products",e),o.append(s),"grid_7"!==u&&"grid_11"!==u||c.handleGalleryCarousel(u),i++},error:function(e){console.log(e)}}))})},c.handleProductPagination=function(){l.on("click",".premium-woo-products-pagination a.page-numbers",function(e){var o,t,i=f(this);l.hasClass("premium-woo-query-main")||(e.preventDefault(),l.find("ul.products").after('<div class="premium-loading-feed"><div class="premium-loader"></div></div>'),e=l.data("page-id"),o=parseInt(l.find(".page-numbers.current").html()),t=1,t=i.hasClass("next")?o+1:i.hasClass("prev")?o-1:i.html(),f.ajax({url:PremiumWooSettings.ajaxurl,data:{action:"get_woo_products",pageID:e,elemID:n.data("id"),category:"",skin:u,page_number:t,nonce:PremiumWooSettings.products_nonce},dataType:"json",type:"POST",success:function(e){l.find(".premium-loading-feed").remove(),f("html, body").animate({scrollTop:n.find(".premium-woocommerce").offset().top-100},"slow"),l.find("ul.products").replaceWith(e.data.html),l.find(".premium-woo-products-pagination").replaceWith(e.data.pagination),"grid_7"!==u&&"grid_11"!==u||c.handleGalleryCarousel(u),l.hasClass("premium-woo-products-metro")&&c.handleGridMetro()},error:function(e){console.log(e)}}))})}},f(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-1",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-2",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-3",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-4",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-5",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-6",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-7",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-8",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-9",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-10",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-11",e)})}(jQuery);
|
1 |
+
!function(f){function e(e,o){new premiumWooProducts(e).init()}window.premiumWooProducts=function(n){var e,o,a,d,t,i,r,l=this,c=n.find(".premium-woocommerce"),u=n.find(".premium-woocommerce").data("skin"),s=null,m=!0,p=c.data("quick-view");"yes"===p&&(e=n.data("id"),o=c.siblings(".premium-woo-quick-view-"+e),a=o.find("#premium-woo-quick-view-modal"),d=a.find("#premium-woo-quick-view-content"),t=a.find(".premium-woo-content-main-wrapper"),i=o.find(".premium-woo-quick-view-back"),r=o.find(".premium-woo-quick-view-loader")),l.init=function(){l.handleProductsCarousel(),"yes"===p&&l.handleProductQuickView(),l.handleProductPagination(),l.handleLoadMore(),l.handleAddToCart(),"grid_6"===u&&l.handleGalleryImages(),["grid_7","grid_11"].includes(u)&&(l.handleGalleryCarousel(u),"grid_11"===u&&l.handleGalleryNav()),c.hasClass("premium-woo-products-metro")&&(l.handleGridMetro(),f(window).on("resize",l.handleGridMetro)),n.hasClass("premium-woo-title-above-yes")&&l.handleTitlePos()},l.handleTitlePos=function(){var e=0<c.find(".woocommerce-loop-product__title").length,o=0<c.find(".premium-woo-product-thumbnail .woocommerce-loop-product__link img").length;e&&o&&c.find("li.product").each(function(e,o){var t=f(o).find(".woocommerce-loop-product__title").parent(),o=f(o).find(".premium-woo-product-thumbnail");t.insertBefore(o)})},l.handleProductsCarousel=function(){var e,o=c.data("woo_carousel");o&&(e=c.find("ul.products"),o.customPaging=function(){return'<i class="fas fa-circle"></i>'},e.on("init",function(e){setTimeout(function(){c.removeClass("premium-carousel-hidden")},100)}),e.slick(o))},l.handleGridMetro=function(){var i,n,r,a,e=c.find("ul.products"),o=elementorFrontend.getCurrentDeviceMode(),t="",d=e.width(),l=Math.floor(d/12);"tablet"===o?t="_tablet":"mobile"===o&&(t="_mobile"),"custom"===c.data("metro-style")&&(n=i=0,d=c.data("metro"),r=d["wPattern"+t],""===(a=d["hPattern"+t])&&(a="12"),r=(r=""===r?"12":r).split(","),a=a.split(","),i=0+r.length,n=0+a.length,e.find("li.product").each(function(e,o){var t=e%n,e=parseInt(r[e%i]),t=parseInt(a[t]);f(o).css({width:Math.floor(e)*l,height:Math.floor(t)*l})})),e.imagesLoaded(function(){}).done(function(){e.isotope({itemSelector:"li.product",percentPosition:!0,animationOptions:{duration:750,easing:"linear"},layoutMode:"masonry",masonry:{columnWidth:l}})})},l.handleProductQuickView=function(){o.appendTo(document.body),c.on("click",".premium-woo-qv-btn, .premium-woo-qv-data",l.triggerQuickViewModal),window.addEventListener("resize",function(){l.updateQuickViewHeight()})},l.triggerQuickViewModal=function(e){e.preventDefault();e=f(this).data("product-id");a.hasClass("loading")||a.addClass("loading"),i.hasClass("premium-woo-quick-view-active")||i.addClass("premium-woo-quick-view-active"),l.getProductByAjax(e),l.addCloseEvents()},l.getProductByAjax=function(e){f.ajax({url:PremiumWooSettings.ajaxurl,data:{action:"get_woo_product_qv",product_id:e,security:PremiumWooSettings.qv_nonce},dataType:"html",type:"GET",beforeSend:function(){r.append('<div class="premium-loading-feed"><div class="premium-loader"></div></div>')},success:function(e){r.find(".premium-loading-feed").remove(),d.html(e),l.handleQuickViewModal()},error:function(e){console.log(e)}})},l.addCloseEvents=function(){var e=a.find("#premium-woo-quick-view-close");f(document).keyup(function(e){27===e.keyCode&&l.closeModal()}),e.on("click",function(e){e.preventDefault(),l.closeModal()}),t.on("click",function(e){this===e.target&&l.closeModal()})},l.handleQuickViewModal=function(){d.imagesLoaded(function(){l.handleQuickViewSlider()})},l.getBarWidth=function(){var e=f('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>'),o=(f("body").append(e),f("div",e).innerWidth()),t=(e.css("overflow-y","scroll"),f("div",e).innerWidth());return f(e).remove(),o-t},l.handleQuickViewSlider=function(){var e=a.find(".premium-woo-qv-image-slider");1<e.find("li").length?e.flexslider({animation:"slide",start:function(e){setTimeout(function(){l.updateQuickViewHeight(!0,!0)},300)}}):setTimeout(function(){l.updateQuickViewHeight(!0)},300),a.hasClass("active")||setTimeout(function(){a.removeClass("loading").addClass("active");var e=l.getBarWidth();f("html").css("margin-right",e),f("html").addClass("premium-woo-qv-opened")},350)},l.updateQuickViewHeight=function(e,o){var t=d,i=t.find(".product .premium-woo-qv-image-slider").first().height(),n=t.find(".product .summary.entry-summary"),r=n.css("content");void 0!==r&&544==r.replace(/[^0-9]/g,"")&&0!=i&&null!==i?n.css("height",i):n.css("height",""),!0===e&&a.css("opacity",1),o&&t.find(".product .premium-woo-qv-image-slider img").height(n.outerHeight())},l.closeModal=function(){i.removeClass("premium-woo-quick-view-active"),a.removeClass("active").removeClass("loading"),f("html").removeClass("premium-woo-qv-opened"),f("html").css("margin-right",""),setTimeout(function(){d.html("")},600)},l.handleAddToCart=function(){c.on("click",".instock .premium-woo-cart-btn.product_type_simple",l.onAddCartBtnClick).on("premium_product_add_to_cart",l.handleAddCartBtnClick).on("click",".instock .premium-woo-atc-button .button.product_type_simple",l.onAddCartBtnClick).on("premium_product_add_to_cart",l.handleAddCartBtnClick)},l.onAddCartBtnClick=function(e){var o=f(this),t=o.data("product_id");t&&!o.data("added-to-cart")&&(e.preventDefault(),o.removeClass("added").addClass("adding"),o.hasClass("premium-woo-cart-btn")||o.append('<span class="premium-woo-cart-loader fas fa-cog"></span>'),f.ajax({url:PremiumWooSettings.ajaxurl,type:"POST",data:{action:"premium_woo_add_cart_product",nonce:PremiumWooSettings.cta_nonce,product_id:t,quantity:1},success:function(){f(document.body).trigger("wc_fragment_refresh"),c.trigger("premium_product_add_to_cart",[o]),"grid_10"!==u&&o.hasClass("premium-woo-cart-btn")||setTimeout(function(){var e=o.siblings(".added_to_cart").text();""==e&&(e="View Cart"),o.removeClass("add_to_cart_button").attr("href",PremiumWooSettings.woo_cart_url).text(e),o.attr("data-added-to-cart",!0)},200)}}))},l.handleAddCartBtnClick=function(e,o){o&&o.removeClass("adding").addClass("added")},l.handleGalleryImages=function(){c.on("click",".premium-woo-product__gallery_image",function(){var e=f(this),o=e.closest(".premium-woo-product-thumbnail"),t=e.attr("src");o.find(".premium-woo-product__on_hover").length<1?o.find(".woocommerce-loop-product__link img").replaceWith(e.clone(!0)):o.find(".premium-woo-product__on_hover").attr("src",t)})},l.handleGalleryNav=function(){c.on("click",".premium-woo-product-gallery-images .premium-woo-product__gallery_image",function(){var e=f(this).parentsUntil(".premium-woo-product-wrapper")[2],e=f(e).siblings(".premium-woo-product-thumbnail"),o=f(this).index()+1;e.slick("slickGoTo",o)})},l.handleGalleryCarousel=function(e){var o=c.find(".premium-woo-product-thumbnail"),t={infinite:"grid_11"!==e,slidesToShow:1,slidesToScroll:1,draggable:!0,autoplay:!1,rtl:elementorFrontend.config.is_rtl};"grid_11"!==e?(t.nextArrow='<a type="button" data-role="none" class="carousel-arrow carousel-next" aria-label="Next" role="button" style=""><i class="fas fa-angle-right" aria-hidden="true"></i></a>',t.prevArrow='<a type="button" data-role="none" class="carousel-arrow carousel-prev" aria-label="Previous" role="button" style=""><i class="fas fa-angle-left" aria-hidden="true"></i></a>'):t.arrows=!1,o.each(function(e,o){1<($imgs=f(o).find("a").length)&&f(o).not(".slick-initialized").slick(t)})},l.handleLoadMore=function(){var t=c.find(".premium-woo-load-more-btn"),i=2,o=c.data("page-id");t.length<1||t.on("click",function(e){m&&(m=!1,c.find("ul.products").after('<div class="premium-loading-feed"><div class="premium-loader"></div></div>'),t.css("opacity",.3),f.ajax({url:PremiumWooSettings.ajaxurl,data:{action:"get_woo_products",pageID:o,elemID:n.data("id"),category:t.data("tax"),skin:u,page_number:i,nonce:PremiumWooSettings.products_nonce},dataType:"json",type:"POST",success:function(e){s=e.data.html;var e=t.data("products")-s.match(/<li/g).length,o=(e<1&&t.remove(),m=!0,c.find(".premium-loading-feed").remove(),t.css("opacity",1),c.find("ul.products"));s=(s=s.replace(s.substring(0,s.indexOf(">")+1),"")).replace("</ul>",""),t.find(".premium-woo-products-num").text("("+e+")"),t.data("products",e),o.append(s),"grid_7"!==u&&"grid_11"!==u||l.handleGalleryCarousel(u),i++},error:function(e){console.log(e)}}))})},l.handleProductPagination=function(){c.on("click",".premium-woo-products-pagination a.page-numbers",function(e){var o,t,i=f(this);c.hasClass("premium-woo-query-main")||(e.preventDefault(),c.find("ul.products").after('<div class="premium-loading-feed"><div class="premium-loader"></div></div>'),e=c.data("page-id"),o=parseInt(c.find(".page-numbers.current").html()),t=1,t=i.hasClass("next")?o+1:i.hasClass("prev")?o-1:i.html(),f.ajax({url:PremiumWooSettings.ajaxurl,data:{action:"get_woo_products",pageID:e,elemID:n.data("id"),category:"",skin:u,page_number:t,nonce:PremiumWooSettings.products_nonce},dataType:"json",type:"POST",success:function(e){c.find(".premium-loading-feed").remove(),f("html, body").animate({scrollTop:n.find(".premium-woocommerce").offset().top-100},"slow"),c.find("ul.products").replaceWith(e.data.html),c.find(".premium-woo-products-pagination").replaceWith(e.data.pagination),"grid_7"!==u&&"grid_11"!==u||l.handleGalleryCarousel(u),c.hasClass("premium-woo-products-metro")&&l.handleGridMetro()},error:function(e){console.log(e)}}))})}},f(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-1",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-2",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-3",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-4",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-5",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-6",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-7",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-8",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-9",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-10",e),elementorFrontend.hooks.addAction("frontend/element_ready/premium-woo-products.grid-11",e)})}(jQuery);
|
includes/addons-integration.php
CHANGED
@@ -1,1126 +1,1126 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Addons Integration.
|
4 |
-
*/
|
5 |
-
|
6 |
-
namespace PremiumAddons\Includes;
|
7 |
-
|
8 |
-
use PremiumAddons\Includes\Helper_Functions;
|
9 |
-
use PremiumAddons\Admin\Includes\Admin_Helper;
|
10 |
-
use PremiumAddons\Modules\Premium_Equal_Height\Module as Equal_Height;
|
11 |
-
use PremiumAddons\Modules\PA_Display_Conditions\Module as Display_Conditions;
|
12 |
-
use PremiumAddons\Modules\PremiumSectionFloatingEffects\Module as Floating_Effects;
|
13 |
-
use PremiumAddons\Modules\Woocommerce\Module as Woocommerce;
|
14 |
-
use PremiumAddons\Includes\Assets_Manager;
|
15 |
-
use PremiumAddons\Includes\Premium_Template_Tags;
|
16 |
-
|
17 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
18 |
-
exit();
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Class Addons_Integration.
|
23 |
-
*/
|
24 |
-
class Addons_Integration {
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Class instance
|
28 |
-
*
|
29 |
-
* @var instance
|
30 |
-
*/
|
31 |
-
private static $instance = null;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Modules
|
35 |
-
*
|
36 |
-
* @var modules
|
37 |
-
*/
|
38 |
-
private static $modules = null;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Maps Keys
|
42 |
-
*
|
43 |
-
* @var maps
|
44 |
-
*/
|
45 |
-
private static $maps = null;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Template Instance
|
49 |
-
*
|
50 |
-
* @var template_instance
|
51 |
-
*/
|
52 |
-
protected $template_instance;
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Cross-Site CDN URL.
|
56 |
-
*
|
57 |
-
* @since 4.0.0
|
58 |
-
* @var (String) URL
|
59 |
-
*/
|
60 |
-
public $cdn_url;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Initialize integration hooks
|
64 |
-
*
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
public function __construct() {
|
68 |
-
|
69 |
-
self::$modules = Admin_Helper::get_enabled_elements();
|
70 |
-
|
71 |
-
self::$maps = Admin_Helper::get_integrations_settings();
|
72 |
-
|
73 |
-
$this->template_instance = Premium_Template_Tags::getInstance();
|
74 |
-
|
75 |
-
add_action( 'elementor/editor/before_enqueue_styles', array( $this, 'enqueue_editor_styles' ) );
|
76 |
-
|
77 |
-
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'load_live_editor_modal' ) );
|
78 |
-
|
79 |
-
add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'live_editor_enqueue' ) );
|
80 |
-
|
81 |
-
add_action( 'wp_ajax_handle_live_editor', array( $this, 'handle_live_editor' ) );
|
82 |
-
|
83 |
-
add_action( 'wp_ajax_check_temp_validity', array( $this, 'check_temp_validity' ) );
|
84 |
-
|
85 |
-
add_action( 'wp_ajax_update_template_title', array( $this, 'update_template_title' ) );
|
86 |
-
|
87 |
-
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_editor_scripts' ) );
|
88 |
-
|
89 |
-
add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_preview_styles' ) );
|
90 |
-
|
91 |
-
add_action( 'elementor/frontend/after_register_styles', array( $this, 'register_frontend_styles' ) );
|
92 |
-
|
93 |
-
add_action( 'elementor/frontend/after_register_scripts', array( $this, 'register_frontend_scripts' ) );
|
94 |
-
|
95 |
-
add_action( 'wp_ajax_get_elementor_template_content', array( $this, 'get_template_content' ) );
|
96 |
-
|
97 |
-
if ( defined( 'ELEMENTOR_VERSION' ) ) {
|
98 |
-
if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
|
99 |
-
add_action( 'elementor/controls/register', array( $this, 'init_pa_controls' ) );
|
100 |
-
add_action( 'elementor/widgets/register', array( $this, 'widgets_area' ) );
|
101 |
-
} else {
|
102 |
-
add_action( 'elementor/controls/controls_registered', array( $this, 'init_pa_controls' ) );
|
103 |
-
add_action( 'elementor/widgets/widgets_registered', array( $this, 'widgets_area' ) );
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'after_enqueue_scripts' ) );
|
108 |
-
|
109 |
-
$this->load_pa_extensions();
|
110 |
-
|
111 |
-
$cross_enabled = isset( self::$modules['premium-cross-domain'] ) ? self::$modules['premium-cross-domain'] : 1;
|
112 |
-
|
113 |
-
if ( $cross_enabled ) {
|
114 |
-
|
115 |
-
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_editor_cp_scripts' ), 99 );
|
116 |
-
|
117 |
-
Addons_Cross_CP::get_instance();
|
118 |
-
|
119 |
-
}
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Live Editor Enqueue.
|
125 |
-
*
|
126 |
-
* @access public
|
127 |
-
* @since 4.8.10
|
128 |
-
*/
|
129 |
-
public function live_editor_enqueue() {
|
130 |
-
|
131 |
-
wp_enqueue_script(
|
132 |
-
'live-editor-js',
|
133 |
-
PREMIUM_ADDONS_URL . 'assets/editor/js/live-editor.js',
|
134 |
-
array( 'elementor-editor', 'jquery' ),
|
135 |
-
PREMIUM_ADDONS_VERSION,
|
136 |
-
true
|
137 |
-
);
|
138 |
-
|
139 |
-
$live_editor_data = array(
|
140 |
-
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
141 |
-
'nonce' => wp_create_nonce( 'pa-live-editor' ),
|
142 |
-
);
|
143 |
-
|
144 |
-
wp_localize_script( 'live-editor-js', 'liveEditor', $live_editor_data );
|
145 |
-
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Update Template Title.
|
150 |
-
*
|
151 |
-
* @access public
|
152 |
-
* @since 4.8.10
|
153 |
-
*/
|
154 |
-
public function update_template_title() {
|
155 |
-
check_ajax_referer( 'pa-live-editor', 'security' );
|
156 |
-
|
157 |
-
if ( ! isset( $_POST['title'] ) || ! isset( $_POST['id'] ) ) {
|
158 |
-
wp_send_json_error();
|
159 |
-
}
|
160 |
-
|
161 |
-
$res = wp_update_post(
|
162 |
-
array(
|
163 |
-
'ID' => sanitize_text_field( wp_unslash( $_POST['id'] ) ),
|
164 |
-
'post_title' => sanitize_text_field( wp_unslash( $_POST['title'] ) ),
|
165 |
-
)
|
166 |
-
);
|
167 |
-
|
168 |
-
wp_send_json_success( $res );
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Check Temp Validity.
|
173 |
-
* Checks if the template is valid ( has content) or not,
|
174 |
-
* And DELETE the post if it's invalid.
|
175 |
-
*
|
176 |
-
* @access public
|
177 |
-
* @since 4.9.1
|
178 |
-
*/
|
179 |
-
public function check_temp_validity() {
|
180 |
-
|
181 |
-
check_ajax_referer( 'pa-live-editor', 'security' );
|
182 |
-
|
183 |
-
if ( ! isset( $_POST['templateID'] ) ) {
|
184 |
-
wp_send_json_error( 'template ID is not set' );
|
185 |
-
}
|
186 |
-
|
187 |
-
$temp_id = sanitize_text_field( wp_unslash( $_POST['templateID'] ) );
|
188 |
-
|
189 |
-
$template_content = $this->template_instance->get_template_content( $temp_id, true );
|
190 |
-
|
191 |
-
if ( empty( $template_content ) || ! isset( $template_content ) ) {
|
192 |
-
|
193 |
-
$res = wp_delete_post( $temp_id, true );
|
194 |
-
|
195 |
-
if ( ! is_wp_error( $res ) ) {
|
196 |
-
$res = 'Template Deleted.';
|
197 |
-
}
|
198 |
-
} else {
|
199 |
-
$res = 'Template Has Content.';
|
200 |
-
}
|
201 |
-
|
202 |
-
wp_send_json_success( $res );
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Handle Live Editor Modal.
|
207 |
-
*
|
208 |
-
* @access public
|
209 |
-
* @since 4.8.10
|
210 |
-
*/
|
211 |
-
public function handle_live_editor() {
|
212 |
-
|
213 |
-
check_ajax_referer( 'pa-live-editor', 'security' );
|
214 |
-
|
215 |
-
if ( ! isset( $_POST['key'] ) ) {
|
216 |
-
wp_send_json_error();
|
217 |
-
}
|
218 |
-
|
219 |
-
$post_name = 'pa-dynamic-temp-' . sanitize_text_field( wp_unslash( $_POST['key'] ) );
|
220 |
-
$post_title = '';
|
221 |
-
$args = array(
|
222 |
-
'post_type' => 'elementor_library',
|
223 |
-
'name' => $post_name,
|
224 |
-
'post_status' => 'publish',
|
225 |
-
'update_post_term_cache' => false,
|
226 |
-
'update_post_meta_cache' => false,
|
227 |
-
'posts_per_page' => 1,
|
228 |
-
);
|
229 |
-
|
230 |
-
$post = get_posts( $args );
|
231 |
-
|
232 |
-
if ( empty( $post ) ) { // create a new one.
|
233 |
-
|
234 |
-
$key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
|
235 |
-
$post_title = 'PA Template | #' . substr( md5( $key ), 0, 4 );
|
236 |
-
|
237 |
-
$params = array(
|
238 |
-
'post_content' => '',
|
239 |
-
'post_type' => 'elementor_library',
|
240 |
-
'post_title' => $post_title,
|
241 |
-
'post_name' => $post_name,
|
242 |
-
'post_status' => 'publish',
|
243 |
-
'meta_input' => array(
|
244 |
-
'_elementor_edit_mode' => 'builder',
|
245 |
-
'_elementor_template_type' => 'page',
|
246 |
-
'_wp_page_template' => 'elementor_canvas',
|
247 |
-
),
|
248 |
-
);
|
249 |
-
|
250 |
-
$post_id = wp_insert_post( $params );
|
251 |
-
|
252 |
-
} else { // edit post.
|
253 |
-
$post_id = $post[0]->ID;
|
254 |
-
$post_title = $post[0]->post_title;
|
255 |
-
}
|
256 |
-
|
257 |
-
$edit_url = get_admin_url() . '/post.php?post=' . $post_id . '&action=elementor';
|
258 |
-
|
259 |
-
$result = array(
|
260 |
-
'url' => $edit_url,
|
261 |
-
'id' => $post_id,
|
262 |
-
'title' => $post_title,
|
263 |
-
);
|
264 |
-
|
265 |
-
wp_send_json_success( $result );
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Load Live Editor Modal.
|
270 |
-
* Puts live editor popup html into the editor.
|
271 |
-
*
|
272 |
-
* @access public
|
273 |
-
* @since 4.8.10
|
274 |
-
*/
|
275 |
-
public function load_live_editor_modal() {
|
276 |
-
ob_start();
|
277 |
-
include_once PREMIUM_ADDONS_PATH . 'includes/live-editor-modal.php';
|
278 |
-
$output = ob_get_contents();
|
279 |
-
ob_end_clean();
|
280 |
-
echo $output;
|
281 |
-
}
|
282 |
-
|
283 |
-
|
284 |
-
/**
|
285 |
-
* After Enquque Scripts
|
286 |
-
*
|
287 |
-
* Loads editor scripts for our controls.
|
288 |
-
*
|
289 |
-
* @access public
|
290 |
-
* @return void
|
291 |
-
*/
|
292 |
-
public function after_enqueue_scripts() {
|
293 |
-
|
294 |
-
wp_enqueue_script(
|
295 |
-
'pa-eq-editor',
|
296 |
-
PREMIUM_ADDONS_URL . 'assets/editor/js/editor.js',
|
297 |
-
array( 'elementor-editor', 'jquery' ),
|
298 |
-
PREMIUM_ADDONS_VERSION,
|
299 |
-
true
|
300 |
-
);
|
301 |
-
|
302 |
-
if ( self::$modules['premium-blog'] || self::$modules['pa-display-conditions'] ) {
|
303 |
-
wp_localize_script(
|
304 |
-
'pa-eq-editor',
|
305 |
-
'PremiumSettings',
|
306 |
-
array(
|
307 |
-
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
308 |
-
'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
|
309 |
-
)
|
310 |
-
);
|
311 |
-
}
|
312 |
-
|
313 |
-
wp_localize_script(
|
314 |
-
'pa-eq-editor',
|
315 |
-
'PremiumPanelSettings',
|
316 |
-
array(
|
317 |
-
'papro_installed' => Helper_Functions::check_papro_version(),
|
318 |
-
'papro_widgets' => Admin_Helper::get_pro_elements(),
|
319 |
-
)
|
320 |
-
);
|
321 |
-
|
322 |
-
}
|
323 |
-
|
324 |
-
/**
|
325 |
-
* Loads plugin icons font
|
326 |
-
*
|
327 |
-
* @since 1.0.0
|
328 |
-
* @access public
|
329 |
-
* @return void
|
330 |
-
*/
|
331 |
-
public function enqueue_editor_styles() {
|
332 |
-
|
333 |
-
$theme = Helper_Functions::get_elementor_ui_theme();
|
334 |
-
|
335 |
-
wp_enqueue_style(
|
336 |
-
'pa-editor',
|
337 |
-
PREMIUM_ADDONS_URL . 'assets/editor/css/style.css',
|
338 |
-
array(),
|
339 |
-
PREMIUM_ADDONS_VERSION
|
340 |
-
);
|
341 |
-
|
342 |
-
// Enqueue required style for Elementor dark UI Theme.
|
343 |
-
if ( 'dark' === $theme ) {
|
344 |
-
|
345 |
-
wp_add_inline_style(
|
346 |
-
'pa-editor',
|
347 |
-
'.elementor-panel .elementor-control-section_pa_docs .elementor-panel-heading-title.elementor-panel-heading-title,
|
348 |
-
.elementor-control-raw-html.editor-pa-doc a {
|
349 |
-
color: #e0e1e3 !important;
|
350 |
-
}
|
351 |
-
[class^="pa-"]::after,
|
352 |
-
[class*=" pa-"]::after {
|
353 |
-
color: #aaa;
|
354 |
-
opacity: 1 !important;
|
355 |
-
}
|
356 |
-
.premium-promotion-dialog .premium-promotion-btn {
|
357 |
-
background-color: #202124 !important
|
358 |
-
}'
|
359 |
-
);
|
360 |
-
|
361 |
-
}
|
362 |
-
|
363 |
-
$badge_text = Helper_Functions::get_badge();
|
364 |
-
|
365 |
-
$dynamic_css = sprintf( '#elementor-panel [class^="pa-"]::after, #elementor-panel [class*=" pa-"]::after { content: "%s"; }', $badge_text );
|
366 |
-
|
367 |
-
wp_add_inline_style( 'pa-editor', $dynamic_css );
|
368 |
-
|
369 |
-
}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Register Frontend CSS files
|
373 |
-
*
|
374 |
-
* @since 2.9.0
|
375 |
-
* @access public
|
376 |
-
*/
|
377 |
-
public function register_frontend_styles() {
|
378 |
-
|
379 |
-
$dir = Helper_Functions::get_styles_dir();
|
380 |
-
$suffix = Helper_Functions::get_assets_suffix();
|
381 |
-
|
382 |
-
$is_rtl = is_rtl() ? '-rtl' : '';
|
383 |
-
|
384 |
-
wp_register_style(
|
385 |
-
'font-awesome-5-all',
|
386 |
-
ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/all.min.css',
|
387 |
-
false,
|
388 |
-
PREMIUM_ADDONS_VERSION
|
389 |
-
);
|
390 |
-
|
391 |
-
wp_register_style(
|
392 |
-
'pa-prettyphoto',
|
393 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyphoto' . $is_rtl . $suffix . '.css',
|
394 |
-
array(),
|
395 |
-
PREMIUM_ADDONS_VERSION,
|
396 |
-
'all'
|
397 |
-
);
|
398 |
-
|
399 |
-
wp_register_style(
|
400 |
-
'pa-slick',
|
401 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $is_rtl . $suffix . '.css',
|
402 |
-
array(),
|
403 |
-
PREMIUM_ADDONS_VERSION,
|
404 |
-
'all'
|
405 |
-
);
|
406 |
-
|
407 |
-
$assets_gen_enabled = self::$modules['premium-assets-generator'] ? true : false;
|
408 |
-
|
409 |
-
$type = get_post_type();
|
410 |
-
|
411 |
-
if ( $assets_gen_enabled && ( 'page' === $type || 'post' === $type ) ) {
|
412 |
-
|
413 |
-
$css_path = '/pa-frontend' . $is_rtl . '-' . Assets_Manager::$post_id . $suffix . '.css';
|
414 |
-
|
415 |
-
if ( Assets_Manager::$is_updated && file_exists( PREMIUM_ASSETS_PATH . $css_path ) ) {
|
416 |
-
wp_enqueue_style(
|
417 |
-
'pa-frontend',
|
418 |
-
PREMIUM_ASSETS_URL . $css_path,
|
419 |
-
array(),
|
420 |
-
time(),
|
421 |
-
'all'
|
422 |
-
);
|
423 |
-
}
|
424 |
-
}
|
425 |
-
|
426 |
-
// If the assets are not ready, or file does not exist for any reson.
|
427 |
-
if ( ! wp_style_is( 'pa-frontend', 'enqueued' ) ) {
|
428 |
-
$this->register_old_styles( $dir, $is_rtl, $suffix );
|
429 |
-
}
|
430 |
-
|
431 |
-
}
|
432 |
-
|
433 |
-
/**
|
434 |
-
* Register Old Styles
|
435 |
-
*
|
436 |
-
* @since 4.9.0
|
437 |
-
* @access public
|
438 |
-
*
|
439 |
-
* @param string $directory style directory.
|
440 |
-
* @param string $is_rtl page direction.
|
441 |
-
* @param string $suffix file suffix.
|
442 |
-
*/
|
443 |
-
public function register_old_styles( $directory, $is_rtl, $suffix ) {
|
444 |
-
|
445 |
-
wp_register_style(
|
446 |
-
'premium-addons',
|
447 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $is_rtl . $suffix . '.css',
|
448 |
-
array(),
|
449 |
-
PREMIUM_ADDONS_VERSION,
|
450 |
-
'all'
|
451 |
-
);
|
452 |
-
|
453 |
-
}
|
454 |
-
|
455 |
-
/**
|
456 |
-
* Registers required JS files
|
457 |
-
*
|
458 |
-
* @since 1.0.0
|
459 |
-
* @access public
|
460 |
-
*/
|
461 |
-
public function register_frontend_scripts() {
|
462 |
-
|
463 |
-
$maps_settings = self::$maps;
|
464 |
-
|
465 |
-
$dir = Helper_Functions::get_scripts_dir();
|
466 |
-
$suffix = Helper_Functions::get_assets_suffix();
|
467 |
-
|
468 |
-
$locale = isset( $maps_settings['premium-map-locale'] ) ? $maps_settings['premium-map-locale'] : 'en';
|
469 |
-
$assets_gen_enabled = self::$modules['premium-assets-generator'] ? true : false;
|
470 |
-
|
471 |
-
$type = get_post_type();
|
472 |
-
|
473 |
-
if ( $assets_gen_enabled && ( 'page' === $type || 'post' === $type ) ) {
|
474 |
-
|
475 |
-
// If the elemens are cached and ready to generate.
|
476 |
-
if ( Assets_Manager::$is_updated ) {
|
477 |
-
Assets_Manager::generate_asset_file( 'js' );
|
478 |
-
Assets_Manager::generate_asset_file( 'css' );
|
479 |
-
}
|
480 |
-
|
481 |
-
$js_path = '/pa-frontend-' . Assets_Manager::$post_id . $suffix . '.js';
|
482 |
-
|
483 |
-
if ( file_exists( PREMIUM_ASSETS_PATH . $js_path ) ) {
|
484 |
-
|
485 |
-
wp_enqueue_script(
|
486 |
-
'pa-frontend',
|
487 |
-
PREMIUM_ASSETS_URL . $js_path,
|
488 |
-
array( 'jquery' ),
|
489 |
-
time(),
|
490 |
-
true
|
491 |
-
);
|
492 |
-
|
493 |
-
wp_localize_script(
|
494 |
-
'pa-frontend',
|
495 |
-
'PremiumSettings',
|
496 |
-
array(
|
497 |
-
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
498 |
-
'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
|
499 |
-
)
|
500 |
-
);
|
501 |
-
|
502 |
-
if ( class_exists( 'woocommerce' ) ) {
|
503 |
-
wp_localize_script(
|
504 |
-
'pa-frontend',
|
505 |
-
'PremiumWooSettings',
|
506 |
-
array(
|
507 |
-
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
508 |
-
'products_nonce' => wp_create_nonce( 'pa-woo-products-nonce' ),
|
509 |
-
'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ),
|
510 |
-
'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ),
|
511 |
-
'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) ),
|
512 |
-
)
|
513 |
-
);
|
514 |
-
}
|
515 |
-
}
|
516 |
-
}
|
517 |
-
|
518 |
-
// If the assets are not ready, or file does not exist for any reson.
|
519 |
-
if ( ! wp_script_is( 'pa-frontend', 'enqueued' ) ) {
|
520 |
-
$this->register_old_scripts( $dir, $suffix );
|
521 |
-
}
|
522 |
-
|
523 |
-
wp_register_script(
|
524 |
-
'prettyPhoto-js',
|
525 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyPhoto' . $suffix . '.js',
|
526 |
-
array( 'jquery' ),
|
527 |
-
PREMIUM_ADDONS_VERSION,
|
528 |
-
true
|
529 |
-
);
|
530 |
-
|
531 |
-
wp_register_script(
|
532 |
-
'pa-vticker',
|
533 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/vticker' . $suffix . '.js',
|
534 |
-
array( 'jquery' ),
|
535 |
-
PREMIUM_ADDONS_VERSION,
|
536 |
-
true
|
537 |
-
);
|
538 |
-
|
539 |
-
wp_register_script(
|
540 |
-
'pa-typed',
|
541 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/typed' . $suffix . '.js',
|
542 |
-
array( 'jquery' ),
|
543 |
-
PREMIUM_ADDONS_VERSION,
|
544 |
-
true
|
545 |
-
);
|
546 |
-
|
547 |
-
wp_register_script(
|
548 |
-
'pa-countdown',
|
549 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-countdown' . $suffix . '.js',
|
550 |
-
array( 'jquery' ),
|
551 |
-
PREMIUM_ADDONS_VERSION,
|
552 |
-
true
|
553 |
-
);
|
554 |
-
|
555 |
-
wp_register_script(
|
556 |
-
'isotope-js',
|
557 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/isotope' . $suffix . '.js',
|
558 |
-
array( 'jquery' ),
|
559 |
-
PREMIUM_ADDONS_VERSION,
|
560 |
-
true
|
561 |
-
);
|
562 |
-
|
563 |
-
wp_register_script(
|
564 |
-
'pa-modal',
|
565 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/modal' . $suffix . '.js',
|
566 |
-
array( 'jquery' ),
|
567 |
-
PREMIUM_ADDONS_VERSION,
|
568 |
-
true
|
569 |
-
);
|
570 |
-
|
571 |
-
wp_register_script(
|
572 |
-
'pa-maps',
|
573 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-maps' . $suffix . '.js',
|
574 |
-
array( 'jquery', 'pa-maps-api' ),
|
575 |
-
PREMIUM_ADDONS_VERSION,
|
576 |
-
true
|
577 |
-
);
|
578 |
-
|
579 |
-
wp_register_script(
|
580 |
-
'pa-vscroll',
|
581 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-vscroll' . $suffix . '.js',
|
582 |
-
array( 'jquery' ),
|
583 |
-
PREMIUM_ADDONS_VERSION,
|
584 |
-
true
|
585 |
-
);
|
586 |
-
|
587 |
-
wp_register_script(
|
588 |
-
'pa-slimscroll',
|
589 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-slimscroll' . $suffix . '.js',
|
590 |
-
array( 'jquery' ),
|
591 |
-
PREMIUM_ADDONS_VERSION,
|
592 |
-
true
|
593 |
-
);
|
594 |
-
|
595 |
-
wp_register_script(
|
596 |
-
'pa-iscroll',
|
597 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/iscroll' . $suffix . '.js',
|
598 |
-
array( 'jquery' ),
|
599 |
-
PREMIUM_ADDONS_VERSION,
|
600 |
-
true
|
601 |
-
);
|
602 |
-
|
603 |
-
wp_register_script(
|
604 |
-
'tilt-js',
|
605 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/universal-tilt' . $suffix . '.js',
|
606 |
-
array( 'jquery' ),
|
607 |
-
PREMIUM_ADDONS_VERSION,
|
608 |
-
true
|
609 |
-
);
|
610 |
-
|
611 |
-
wp_register_script(
|
612 |
-
'lottie-js',
|
613 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/lottie' . $suffix . '.js',
|
614 |
-
array(
|
615 |
-
'jquery',
|
616 |
-
'elementor-waypoints',
|
617 |
-
),
|
618 |
-
PREMIUM_ADDONS_VERSION,
|
619 |
-
true
|
620 |
-
);
|
621 |
-
|
622 |
-
wp_register_script(
|
623 |
-
'pa-tweenmax',
|
624 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/TweenMax' . $suffix . '.js',
|
625 |
-
array( 'jquery' ),
|
626 |
-
PREMIUM_ADDONS_VERSION,
|
627 |
-
true
|
628 |
-
);
|
629 |
-
|
630 |
-
wp_register_script(
|
631 |
-
'pa-headroom',
|
632 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/headroom' . $suffix . '.js',
|
633 |
-
array( 'jquery' ),
|
634 |
-
PREMIUM_ADDONS_VERSION
|
635 |
-
// true
|
636 |
-
);
|
637 |
-
|
638 |
-
if ( $maps_settings['premium-map-cluster'] ) {
|
639 |
-
wp_register_script(
|
640 |
-
'google-maps-cluster',
|
641 |
-
'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js',
|
642 |
-
array(),
|
643 |
-
PREMIUM_ADDONS_VERSION,
|
644 |
-
false
|
645 |
-
);
|
646 |
-
}
|
647 |
-
|
648 |
-
if ( $maps_settings['premium-map-disable-api'] && '1' !== $maps_settings['premium-map-api'] ) {
|
649 |
-
$api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&language=%2$s', $maps_settings['premium-map-api'], $locale );
|
650 |
-
wp_register_script(
|
651 |
-
'pa-maps-api',
|
652 |
-
$api,
|
653 |
-
array(),
|
654 |
-
PREMIUM_ADDONS_VERSION,
|
655 |
-
false
|
656 |
-
);
|
657 |
-
}
|
658 |
-
|
659 |
-
wp_register_script(
|
660 |
-
'pa-slick',
|
661 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $suffix . '.js',
|
662 |
-
array( 'jquery' ),
|
663 |
-
PREMIUM_ADDONS_VERSION,
|
664 |
-
true
|
665 |
-
);
|
666 |
-
|
667 |
-
wp_register_script(
|
668 |
-
'pa-anime',
|
669 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/anime' . $suffix . '.js',
|
670 |
-
array( 'jquery' ),
|
671 |
-
PREMIUM_ADDONS_VERSION,
|
672 |
-
true
|
673 |
-
);
|
674 |
-
|
675 |
-
wp_register_script(
|
676 |
-
'pa-feffects',
|
677 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-floating-effects' . $suffix . '.js',
|
678 |
-
array( 'jquery' ),
|
679 |
-
PREMIUM_ADDONS_VERSION,
|
680 |
-
true
|
681 |
-
);
|
682 |
-
|
683 |
-
wp_localize_script(
|
684 |
-
'premium-addons',
|
685 |
-
'PremiumSettings',
|
686 |
-
array(
|
687 |
-
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
688 |
-
'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
|
689 |
-
)
|
690 |
-
);
|
691 |
-
|
692 |
-
wp_register_script(
|
693 |
-
'pa-eq-height',
|
694 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-eq-height' . $suffix . '.js',
|
695 |
-
array( 'jquery' ),
|
696 |
-
PREMIUM_ADDONS_VERSION,
|
697 |
-
true
|
698 |
-
);
|
699 |
-
|
700 |
-
wp_register_script(
|
701 |
-
'pa-dis-conditions',
|
702 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-dis-conditions' . $suffix . '.js',
|
703 |
-
array( 'jquery' ),
|
704 |
-
PREMIUM_ADDONS_VERSION,
|
705 |
-
true
|
706 |
-
);
|
707 |
-
|
708 |
-
// Localize jQuery with required data for Global Add-ons.
|
709 |
-
if ( self::$modules['premium-floating-effects'] ) {
|
710 |
-
wp_localize_script(
|
711 |
-
'pa-feffects',
|
712 |
-
'PremiumFESettings',
|
713 |
-
array(
|
714 |
-
'papro_installed' => Helper_Functions::check_papro_version(),
|
715 |
-
)
|
716 |
-
);
|
717 |
-
}
|
718 |
-
|
719 |
-
}
|
720 |
-
|
721 |
-
/**
|
722 |
-
* Register Old Scripts
|
723 |
-
*
|
724 |
-
* @since 4.9.0
|
725 |
-
* @access public
|
726 |
-
*
|
727 |
-
* @param string $directory script directory.
|
728 |
-
* @param string $suffix file suffix.
|
729 |
-
*/
|
730 |
-
public function register_old_scripts( $directory, $suffix ) {
|
731 |
-
|
732 |
-
wp_register_script(
|
733 |
-
'premium-addons',
|
734 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $suffix . '.js',
|
735 |
-
array( 'jquery' ),
|
736 |
-
PREMIUM_ADDONS_VERSION,
|
737 |
-
true
|
738 |
-
);
|
739 |
-
|
740 |
-
// We need to make sure premium-woocommerce.js will not be loaded twice if assets are generated.
|
741 |
-
if ( class_exists( 'woocommerce' ) ) {
|
742 |
-
wp_register_script(
|
743 |
-
'premium-woocommerce',
|
744 |
-
PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-woo-products' . $suffix . '.js',
|
745 |
-
array( 'jquery' ),
|
746 |
-
PREMIUM_ADDONS_VERSION,
|
747 |
-
true
|
748 |
-
);
|
749 |
-
|
750 |
-
wp_localize_script(
|
751 |
-
'premium-woocommerce',
|
752 |
-
'PremiumWooSettings',
|
753 |
-
array(
|
754 |
-
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
755 |
-
'products_nonce' => wp_create_nonce( 'pa-woo-products-nonce' ),
|
756 |
-
'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ),
|
757 |
-
'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ),
|
758 |
-
'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) ),
|
759 |
-
)
|
760 |
-
);
|
761 |
-
}
|
762 |
-
|
763 |
-
}
|
764 |
-
|
765 |
-
/**
|
766 |
-
* Enqueue Preview CSS files
|
767 |
-
*
|
768 |
-
* @since 2.9.0
|
769 |
-
* @access public
|
770 |
-
*/
|
771 |
-
public function enqueue_preview_styles() {
|
772 |
-
|
773 |
-
wp_enqueue_style( 'pa-prettyphoto' );
|
774 |
-
|
775 |
-
wp_enqueue_style( 'premium-addons' );
|
776 |
-
|
777 |
-
wp_enqueue_style( 'pa-slick' );
|
778 |
-
|
779 |
-
}
|
780 |
-
|
781 |
-
/**
|
782 |
-
* Load widgets require function
|
783 |
-
*
|
784 |
-
* @since 1.0.0
|
785 |
-
* @access public
|
786 |
-
*/
|
787 |
-
public function widgets_area() {
|
788 |
-
$this->widgets_register();
|
789 |
-
}
|
790 |
-
|
791 |
-
/**
|
792 |
-
* Requires widgets files
|
793 |
-
*
|
794 |
-
* @since 1.0.0
|
795 |
-
* @access private
|
796 |
-
*/
|
797 |
-
private function widgets_register() {
|
798 |
-
|
799 |
-
$enabled_elements = self::$modules;
|
800 |
-
|
801 |
-
foreach ( glob( PREMIUM_ADDONS_PATH . 'widgets/*.php' ) as $file ) {
|
802 |
-
|
803 |
-
$slug = basename( $file, '.php' );
|
804 |
-
|
805 |
-
// Fixes the conflict between Lottie widget/addon keys.
|
806 |
-
if ( 'premium-lottie' === $slug ) {
|
807 |
-
|
808 |
-
// Check if Lottie widget switcher value was saved before.
|
809 |
-
$saved_options = get_option( 'pa_save_settings' );
|
810 |
-
|
811 |
-
$slug = 'premium-lottie-widget';
|
812 |
-
|
813 |
-
}
|
814 |
-
|
815 |
-
$enabled = isset( $enabled_elements[ $slug ] ) ? $enabled_elements[ $slug ] : '';
|
816 |
-
|
817 |
-
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $enabled_elements ) {
|
818 |
-
$this->register_addon( $file );
|
819 |
-
}
|
820 |
-
}
|
821 |
-
|
822 |
-
}
|
823 |
-
|
824 |
-
/**
|
825 |
-
* Register Woocommerce Widgets.
|
826 |
-
*
|
827 |
-
* @since 4.0.0
|
828 |
-
* @access private
|
829 |
-
*/
|
830 |
-
private function woo_widgets_register() {
|
831 |
-
|
832 |
-
$enabled_elements = self::$modules;
|
833 |
-
|
834 |
-
foreach ( glob( PREMIUM_ADDONS_PATH . 'modules/woocommerce/widgets/*.php' ) as $file ) {
|
835 |
-
|
836 |
-
$slug = basename( $file, '.php' );
|
837 |
-
|
838 |
-
$enabled = isset( $enabled_elements[ $slug ] ) ? $enabled_elements[ $slug ] : '';
|
839 |
-
|
840 |
-
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $enabled_elements ) {
|
841 |
-
|
842 |
-
$this->register_addon( $file );
|
843 |
-
}
|
844 |
-
}
|
845 |
-
}
|
846 |
-
|
847 |
-
/**
|
848 |
-
* Enqueue editor scripts
|
849 |
-
*
|
850 |
-
* @since 3.2.5
|
851 |
-
* @access public
|
852 |
-
*/
|
853 |
-
public function enqueue_editor_scripts() {
|
854 |
-
|
855 |
-
$map_enabled = isset( self::$modules['premium-maps'] ) ? self::$modules['premium-maps'] : 1;
|
856 |
-
|
857 |
-
if ( $map_enabled ) {
|
858 |
-
|
859 |
-
$premium_maps_api = self::$maps['premium-map-api'];
|
860 |
-
|
861 |
-
$locale = isset( self::$maps['premium-map-locale'] ) ? self::$maps['premium-map-locale'] : 'en';
|
862 |
-
|
863 |
-
$disable_api = self::$maps['premium-map-disable-api'];
|
864 |
-
|
865 |
-
if ( $disable_api && '1' !== $premium_maps_api ) {
|
866 |
-
|
867 |
-
$api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&language=%2$s', $premium_maps_api, $locale );
|
868 |
-
wp_enqueue_script(
|
869 |
-
'pa-maps-api',
|
870 |
-
$api,
|
871 |
-
array(),
|
872 |
-
PREMIUM_ADDONS_VERSION,
|
873 |
-
false
|
874 |
-
);
|
875 |
-
|
876 |
-
}
|
877 |
-
|
878 |
-
wp_enqueue_script(
|
879 |
-
'pa-maps-finder',
|
880 |
-
PREMIUM_ADDONS_URL . 'assets/editor/js/pa-maps-finder.js',
|
881 |
-
array( 'jquery' ),
|
882 |
-
PREMIUM_ADDONS_VERSION,
|
883 |
-
true
|
884 |
-
);
|
885 |
-
|
886 |
-
}
|
887 |
-
|
888 |
-
}
|
889 |
-
|
890 |
-
/**
|
891 |
-
* Load Cross Domain Copy Paste JS Files.
|
892 |
-
*
|
893 |
-
* @since 3.21.1
|
894 |
-
*/
|
895 |
-
public function enqueue_editor_cp_scripts() {
|
896 |
-
|
897 |
-
wp_enqueue_script(
|
898 |
-
'premium-xdlocalstorage-js',
|
899 |
-
PREMIUM_ADDONS_URL . 'assets/editor/js/xdlocalstorage.js',
|
900 |
-
null,
|
901 |
-
PREMIUM_ADDONS_VERSION,
|
902 |
-
true
|
903 |
-
);
|
904 |
-
|
905 |
-
wp_enqueue_script(
|
906 |
-
'premium-cross-cp',
|
907 |
-
PREMIUM_ADDONS_URL . 'assets/editor/js/premium-cross-cp.js',
|
908 |
-
array( 'jquery', 'elementor-editor', 'premium-xdlocalstorage-js' ),
|
909 |
-
PREMIUM_ADDONS_VERSION,
|
910 |
-
true
|
911 |
-
);
|
912 |
-
|
913 |
-
// Check for required Compatible Elementor version.
|
914 |
-
if ( ! version_compare( ELEMENTOR_VERSION, '3.1.0', '>=' ) ) {
|
915 |
-
$elementor_old = true;
|
916 |
-
} else {
|
917 |
-
$elementor_old = false;
|
918 |
-
}
|
919 |
-
|
920 |
-
wp_localize_script(
|
921 |
-
'jquery',
|
922 |
-
'premium_cross_cp',
|
923 |
-
array(
|
924 |
-
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
925 |
-
'nonce' => wp_create_nonce( 'premium_cross_cp_import' ),
|
926 |
-
'elementorCompatible' => $elementor_old,
|
927 |
-
)
|
928 |
-
);
|
929 |
-
}
|
930 |
-
|
931 |
-
/**
|
932 |
-
* Get Template Content
|
933 |
-
*
|
934 |
-
* Get Elementor template HTML content.
|
935 |
-
*
|
936 |
-
* @since 3.2.6
|
937 |
-
* @access public
|
938 |
-
*/
|
939 |
-
public function get_template_content() {
|
940 |
-
|
941 |
-
$template = isset( $_GET['templateID'] ) ? sanitize_text_field( wp_unslash( $_GET['templateID'] ) ) : '';
|
942 |
-
|
943 |
-
if ( empty( $template ) ) {
|
944 |
-
wp_send_json_error( '' );
|
945 |
-
}
|
946 |
-
|
947 |
-
$template_content = $this->template_instance->get_template_content( $template );
|
948 |
-
|
949 |
-
if ( empty( $template_content ) || ! isset( $template_content ) ) {
|
950 |
-
wp_send_json_error( '' );
|
951 |
-
}
|
952 |
-
|
953 |
-
$data = array(
|
954 |
-
'template_content' => $template_content,
|
955 |
-
);
|
956 |
-
|
957 |
-
wp_send_json_success( $data );
|
958 |
-
}
|
959 |
-
|
960 |
-
/**
|
961 |
-
*
|
962 |
-
* Register addon by file name.
|
963 |
-
*
|
964 |
-
* @access public
|
965 |
-
*
|
966 |
-
* @param string $file File name.
|
967 |
-
*
|
968 |
-
* @return void
|
969 |
-
*/
|
970 |
-
public function register_addon( $file ) {
|
971 |
-
|
972 |
-
$widgets_manager = \Elementor\Plugin::instance()->widgets_manager;
|
973 |
-
|
974 |
-
$base = basename( str_replace( '.php', '', $file ) );
|
975 |
-
$class = ucwords( str_replace( '-', ' ', $base ) );
|
976 |
-
$class = str_replace( ' ', '_', $class );
|
977 |
-
$class = sprintf( 'PremiumAddons\Widgets\%s', $class );
|
978 |
-
|
979 |
-
if ( 'PremiumAddons\Widgets\Premium_Contactform' !== $class ) {
|
980 |
-
require $file;
|
981 |
-
} else {
|
982 |
-
if ( function_exists( 'wpcf7' ) ) {
|
983 |
-
require $file;
|
984 |
-
}
|
985 |
-
}
|
986 |
-
|
987 |
-
if ( 'PremiumAddons\Widgets\Premium_Videobox' === $class ) {
|
988 |
-
require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php';
|
989 |
-
}
|
990 |
-
|
991 |
-
if ( class_exists( $class, false ) ) {
|
992 |
-
if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
|
993 |
-
$widgets_manager->register( new $class() );
|
994 |
-
} else {
|
995 |
-
$widgets_manager->register_widget_type( new $class() );
|
996 |
-
}
|
997 |
-
}
|
998 |
-
|
999 |
-
}
|
1000 |
-
|
1001 |
-
/**
|
1002 |
-
* Registers Premium Addons Custom Controls.
|
1003 |
-
*
|
1004 |
-
* @since 4.2.5
|
1005 |
-
* @access public
|
1006 |
-
*
|
1007 |
-
* @return void
|
1008 |
-
*/
|
1009 |
-
public function init_pa_controls() {
|
1010 |
-
|
1011 |
-
if ( self::$modules['premium-equal-height'] || self::$modules['premium-blog'] || self::$modules['pa-display-conditions'] ) {
|
1012 |
-
|
1013 |
-
$control_manager = \Elementor\Plugin::instance();
|
1014 |
-
|
1015 |
-
if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
|
1016 |
-
|
1017 |
-
// TODO: NEEDS TO BE DYNAMIC.
|
1018 |
-
if ( self::$modules['premium-equal-height'] ) {
|
1019 |
-
|
1020 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-select.php';
|
1021 |
-
$premium_select = __NAMESPACE__ . '\Controls\Premium_Select';
|
1022 |
-
$control_manager->controls_manager->register( new $premium_select() );
|
1023 |
-
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
if ( self::$modules['premium-blog'] ) {
|
1027 |
-
|
1028 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-post-filter.php';
|
1029 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-tax-filter.php';
|
1030 |
-
|
1031 |
-
$premium_post_filter = __NAMESPACE__ . '\Controls\Premium_Post_Filter';
|
1032 |
-
$premium_tax_filter = __NAMESPACE__ . '\Controls\Premium_Tax_Filter';
|
1033 |
-
|
1034 |
-
$control_manager->controls_manager->register( new $premium_post_filter() );
|
1035 |
-
$control_manager->controls_manager->register( new $premium_tax_filter() );
|
1036 |
-
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
if ( self::$modules['pa-display-conditions'] ) {
|
1040 |
-
|
1041 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-acf-selector.php';
|
1042 |
-
$premium_acf_selector = __NAMESPACE__ . '\Controls\Premium_Acf_Selector';
|
1043 |
-
$control_manager->controls_manager->register( new $premium_acf_selector() );
|
1044 |
-
|
1045 |
-
}
|
1046 |
-
} else {
|
1047 |
-
if ( self::$modules['premium-equal-height'] ) {
|
1048 |
-
|
1049 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-select.php';
|
1050 |
-
$premium_select = __NAMESPACE__ . '\Controls\Premium_Select';
|
1051 |
-
$control_manager->controls_manager->register_control( $premium_select::TYPE, new $premium_select() );
|
1052 |
-
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
if ( self::$modules['premium-blog'] ) {
|
1056 |
-
|
1057 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-post-filter.php';
|
1058 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-tax-filter.php';
|
1059 |
-
|
1060 |
-
$premium_post_filter = __NAMESPACE__ . '\Controls\Premium_Post_Filter';
|
1061 |
-
$premium_tax_filter = __NAMESPACE__ . '\Controls\Premium_Tax_Filter';
|
1062 |
-
|
1063 |
-
$control_manager->controls_manager->register_control( $premium_post_filter::TYPE, new $premium_post_filter() );
|
1064 |
-
$control_manager->controls_manager->register_control( $premium_tax_filter::TYPE, new $premium_tax_filter() );
|
1065 |
-
|
1066 |
-
}
|
1067 |
-
|
1068 |
-
if ( self::$modules['pa-display-conditions'] ) {
|
1069 |
-
|
1070 |
-
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-acf-selector.php';
|
1071 |
-
$premium_acf_selector = __NAMESPACE__ . '\Controls\Premium_Acf_Selector';
|
1072 |
-
$control_manager->controls_manager->register_control( $premium_acf_selector::TYPE, new $premium_acf_selector() );
|
1073 |
-
|
1074 |
-
}
|
1075 |
-
}
|
1076 |
-
}
|
1077 |
-
|
1078 |
-
}
|
1079 |
-
|
1080 |
-
/**
|
1081 |
-
* Load PA Extensions
|
1082 |
-
*
|
1083 |
-
* @since 4.7.0
|
1084 |
-
* @access public
|
1085 |
-
*/
|
1086 |
-
public function load_pa_extensions() {
|
1087 |
-
|
1088 |
-
if ( self::$modules['premium-equal-height'] ) {
|
1089 |
-
Equal_Height::get_instance();
|
1090 |
-
}
|
1091 |
-
|
1092 |
-
if ( self::$modules['pa-display-conditions'] ) {
|
1093 |
-
require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php';
|
1094 |
-
Display_Conditions::get_instance();
|
1095 |
-
}
|
1096 |
-
|
1097 |
-
if ( self::$modules['premium-floating-effects'] ) {
|
1098 |
-
Floating_Effects::get_instance();
|
1099 |
-
}
|
1100 |
-
|
1101 |
-
if ( class_exists( 'woocommerce' ) && self::$modules['woo-products'] ) {
|
1102 |
-
Woocommerce::get_instance();
|
1103 |
-
}
|
1104 |
-
|
1105 |
-
}
|
1106 |
-
|
1107 |
-
/**
|
1108 |
-
*
|
1109 |
-
* Creates and returns an instance of the class
|
1110 |
-
*
|
1111 |
-
* @since 1.0.0
|
1112 |
-
* @access public
|
1113 |
-
*
|
1114 |
-
* @return object
|
1115 |
-
*/
|
1116 |
-
public static function get_instance() {
|
1117 |
-
|
1118 |
-
if ( ! isset( self::$instance ) ) {
|
1119 |
-
|
1120 |
-
self::$instance = new self();
|
1121 |
-
|
1122 |
-
}
|
1123 |
-
|
1124 |
-
return self::$instance;
|
1125 |
-
}
|
1126 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Addons Integration.
|
4 |
+
*/
|
5 |
+
|
6 |
+
namespace PremiumAddons\Includes;
|
7 |
+
|
8 |
+
use PremiumAddons\Includes\Helper_Functions;
|
9 |
+
use PremiumAddons\Admin\Includes\Admin_Helper;
|
10 |
+
use PremiumAddons\Modules\Premium_Equal_Height\Module as Equal_Height;
|
11 |
+
use PremiumAddons\Modules\PA_Display_Conditions\Module as Display_Conditions;
|
12 |
+
use PremiumAddons\Modules\PremiumSectionFloatingEffects\Module as Floating_Effects;
|
13 |
+
use PremiumAddons\Modules\Woocommerce\Module as Woocommerce;
|
14 |
+
use PremiumAddons\Includes\Assets_Manager;
|
15 |
+
use PremiumAddons\Includes\Premium_Template_Tags;
|
16 |
+
|
17 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
18 |
+
exit();
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class Addons_Integration.
|
23 |
+
*/
|
24 |
+
class Addons_Integration {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Class instance
|
28 |
+
*
|
29 |
+
* @var instance
|
30 |
+
*/
|
31 |
+
private static $instance = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Modules
|
35 |
+
*
|
36 |
+
* @var modules
|
37 |
+
*/
|
38 |
+
private static $modules = null;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Maps Keys
|
42 |
+
*
|
43 |
+
* @var maps
|
44 |
+
*/
|
45 |
+
private static $maps = null;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Template Instance
|
49 |
+
*
|
50 |
+
* @var template_instance
|
51 |
+
*/
|
52 |
+
protected $template_instance;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Cross-Site CDN URL.
|
56 |
+
*
|
57 |
+
* @since 4.0.0
|
58 |
+
* @var (String) URL
|
59 |
+
*/
|
60 |
+
public $cdn_url;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Initialize integration hooks
|
64 |
+
*
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
public function __construct() {
|
68 |
+
|
69 |
+
self::$modules = Admin_Helper::get_enabled_elements();
|
70 |
+
|
71 |
+
self::$maps = Admin_Helper::get_integrations_settings();
|
72 |
+
|
73 |
+
$this->template_instance = Premium_Template_Tags::getInstance();
|
74 |
+
|
75 |
+
add_action( 'elementor/editor/before_enqueue_styles', array( $this, 'enqueue_editor_styles' ) );
|
76 |
+
|
77 |
+
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'load_live_editor_modal' ) );
|
78 |
+
|
79 |
+
add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'live_editor_enqueue' ) );
|
80 |
+
|
81 |
+
add_action( 'wp_ajax_handle_live_editor', array( $this, 'handle_live_editor' ) );
|
82 |
+
|
83 |
+
add_action( 'wp_ajax_check_temp_validity', array( $this, 'check_temp_validity' ) );
|
84 |
+
|
85 |
+
add_action( 'wp_ajax_update_template_title', array( $this, 'update_template_title' ) );
|
86 |
+
|
87 |
+
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_editor_scripts' ) );
|
88 |
+
|
89 |
+
add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_preview_styles' ) );
|
90 |
+
|
91 |
+
add_action( 'elementor/frontend/after_register_styles', array( $this, 'register_frontend_styles' ) );
|
92 |
+
|
93 |
+
add_action( 'elementor/frontend/after_register_scripts', array( $this, 'register_frontend_scripts' ) );
|
94 |
+
|
95 |
+
add_action( 'wp_ajax_get_elementor_template_content', array( $this, 'get_template_content' ) );
|
96 |
+
|
97 |
+
if ( defined( 'ELEMENTOR_VERSION' ) ) {
|
98 |
+
if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
|
99 |
+
add_action( 'elementor/controls/register', array( $this, 'init_pa_controls' ) );
|
100 |
+
add_action( 'elementor/widgets/register', array( $this, 'widgets_area' ) );
|
101 |
+
} else {
|
102 |
+
add_action( 'elementor/controls/controls_registered', array( $this, 'init_pa_controls' ) );
|
103 |
+
add_action( 'elementor/widgets/widgets_registered', array( $this, 'widgets_area' ) );
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'after_enqueue_scripts' ) );
|
108 |
+
|
109 |
+
$this->load_pa_extensions();
|
110 |
+
|
111 |
+
$cross_enabled = isset( self::$modules['premium-cross-domain'] ) ? self::$modules['premium-cross-domain'] : 1;
|
112 |
+
|
113 |
+
if ( $cross_enabled ) {
|
114 |
+
|
115 |
+
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_editor_cp_scripts' ), 99 );
|
116 |
+
|
117 |
+
Addons_Cross_CP::get_instance();
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Live Editor Enqueue.
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @since 4.8.10
|
128 |
+
*/
|
129 |
+
public function live_editor_enqueue() {
|
130 |
+
|
131 |
+
wp_enqueue_script(
|
132 |
+
'live-editor-js',
|
133 |
+
PREMIUM_ADDONS_URL . 'assets/editor/js/live-editor.js',
|
134 |
+
array( 'elementor-editor', 'jquery' ),
|
135 |
+
PREMIUM_ADDONS_VERSION,
|
136 |
+
true
|
137 |
+
);
|
138 |
+
|
139 |
+
$live_editor_data = array(
|
140 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
141 |
+
'nonce' => wp_create_nonce( 'pa-live-editor' ),
|
142 |
+
);
|
143 |
+
|
144 |
+
wp_localize_script( 'live-editor-js', 'liveEditor', $live_editor_data );
|
145 |
+
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Update Template Title.
|
150 |
+
*
|
151 |
+
* @access public
|
152 |
+
* @since 4.8.10
|
153 |
+
*/
|
154 |
+
public function update_template_title() {
|
155 |
+
check_ajax_referer( 'pa-live-editor', 'security' );
|
156 |
+
|
157 |
+
if ( ! isset( $_POST['title'] ) || ! isset( $_POST['id'] ) ) {
|
158 |
+
wp_send_json_error();
|
159 |
+
}
|
160 |
+
|
161 |
+
$res = wp_update_post(
|
162 |
+
array(
|
163 |
+
'ID' => sanitize_text_field( wp_unslash( $_POST['id'] ) ),
|
164 |
+
'post_title' => sanitize_text_field( wp_unslash( $_POST['title'] ) ),
|
165 |
+
)
|
166 |
+
);
|
167 |
+
|
168 |
+
wp_send_json_success( $res );
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Check Temp Validity.
|
173 |
+
* Checks if the template is valid ( has content) or not,
|
174 |
+
* And DELETE the post if it's invalid.
|
175 |
+
*
|
176 |
+
* @access public
|
177 |
+
* @since 4.9.1
|
178 |
+
*/
|
179 |
+
public function check_temp_validity() {
|
180 |
+
|
181 |
+
check_ajax_referer( 'pa-live-editor', 'security' );
|
182 |
+
|
183 |
+
if ( ! isset( $_POST['templateID'] ) ) {
|
184 |
+
wp_send_json_error( 'template ID is not set' );
|
185 |
+
}
|
186 |
+
|
187 |
+
$temp_id = sanitize_text_field( wp_unslash( $_POST['templateID'] ) );
|
188 |
+
|
189 |
+
$template_content = $this->template_instance->get_template_content( $temp_id, true );
|
190 |
+
|
191 |
+
if ( empty( $template_content ) || ! isset( $template_content ) ) {
|
192 |
+
|
193 |
+
$res = wp_delete_post( $temp_id, true );
|
194 |
+
|
195 |
+
if ( ! is_wp_error( $res ) ) {
|
196 |
+
$res = 'Template Deleted.';
|
197 |
+
}
|
198 |
+
} else {
|
199 |
+
$res = 'Template Has Content.';
|
200 |
+
}
|
201 |
+
|
202 |
+
wp_send_json_success( $res );
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Handle Live Editor Modal.
|
207 |
+
*
|
208 |
+
* @access public
|
209 |
+
* @since 4.8.10
|
210 |
+
*/
|
211 |
+
public function handle_live_editor() {
|
212 |
+
|
213 |
+
check_ajax_referer( 'pa-live-editor', 'security' );
|
214 |
+
|
215 |
+
if ( ! isset( $_POST['key'] ) ) {
|
216 |
+
wp_send_json_error();
|
217 |
+
}
|
218 |
+
|
219 |
+
$post_name = 'pa-dynamic-temp-' . sanitize_text_field( wp_unslash( $_POST['key'] ) );
|
220 |
+
$post_title = '';
|
221 |
+
$args = array(
|
222 |
+
'post_type' => 'elementor_library',
|
223 |
+
'name' => $post_name,
|
224 |
+
'post_status' => 'publish',
|
225 |
+
'update_post_term_cache' => false,
|
226 |
+
'update_post_meta_cache' => false,
|
227 |
+
'posts_per_page' => 1,
|
228 |
+
);
|
229 |
+
|
230 |
+
$post = get_posts( $args );
|
231 |
+
|
232 |
+
if ( empty( $post ) ) { // create a new one.
|
233 |
+
|
234 |
+
$key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
|
235 |
+
$post_title = 'PA Template | #' . substr( md5( $key ), 0, 4 );
|
236 |
+
|
237 |
+
$params = array(
|
238 |
+
'post_content' => '',
|
239 |
+
'post_type' => 'elementor_library',
|
240 |
+
'post_title' => $post_title,
|
241 |
+
'post_name' => $post_name,
|
242 |
+
'post_status' => 'publish',
|
243 |
+
'meta_input' => array(
|
244 |
+
'_elementor_edit_mode' => 'builder',
|
245 |
+
'_elementor_template_type' => 'page',
|
246 |
+
'_wp_page_template' => 'elementor_canvas',
|
247 |
+
),
|
248 |
+
);
|
249 |
+
|
250 |
+
$post_id = wp_insert_post( $params );
|
251 |
+
|
252 |
+
} else { // edit post.
|
253 |
+
$post_id = $post[0]->ID;
|
254 |
+
$post_title = $post[0]->post_title;
|
255 |
+
}
|
256 |
+
|
257 |
+
$edit_url = get_admin_url() . '/post.php?post=' . $post_id . '&action=elementor';
|
258 |
+
|
259 |
+
$result = array(
|
260 |
+
'url' => $edit_url,
|
261 |
+
'id' => $post_id,
|
262 |
+
'title' => $post_title,
|
263 |
+
);
|
264 |
+
|
265 |
+
wp_send_json_success( $result );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Load Live Editor Modal.
|
270 |
+
* Puts live editor popup html into the editor.
|
271 |
+
*
|
272 |
+
* @access public
|
273 |
+
* @since 4.8.10
|
274 |
+
*/
|
275 |
+
public function load_live_editor_modal() {
|
276 |
+
ob_start();
|
277 |
+
include_once PREMIUM_ADDONS_PATH . 'includes/live-editor-modal.php';
|
278 |
+
$output = ob_get_contents();
|
279 |
+
ob_end_clean();
|
280 |
+
echo $output;
|
281 |
+
}
|
282 |
+
|
283 |
+
|
284 |
+
/**
|
285 |
+
* After Enquque Scripts
|
286 |
+
*
|
287 |
+
* Loads editor scripts for our controls.
|
288 |
+
*
|
289 |
+
* @access public
|
290 |
+
* @return void
|
291 |
+
*/
|
292 |
+
public function after_enqueue_scripts() {
|
293 |
+
|
294 |
+
wp_enqueue_script(
|
295 |
+
'pa-eq-editor',
|
296 |
+
PREMIUM_ADDONS_URL . 'assets/editor/js/editor.js',
|
297 |
+
array( 'elementor-editor', 'jquery' ),
|
298 |
+
PREMIUM_ADDONS_VERSION,
|
299 |
+
true
|
300 |
+
);
|
301 |
+
|
302 |
+
if ( self::$modules['premium-blog'] || self::$modules['pa-display-conditions'] ) {
|
303 |
+
wp_localize_script(
|
304 |
+
'pa-eq-editor',
|
305 |
+
'PremiumSettings',
|
306 |
+
array(
|
307 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
308 |
+
'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
|
309 |
+
)
|
310 |
+
);
|
311 |
+
}
|
312 |
+
|
313 |
+
wp_localize_script(
|
314 |
+
'pa-eq-editor',
|
315 |
+
'PremiumPanelSettings',
|
316 |
+
array(
|
317 |
+
'papro_installed' => Helper_Functions::check_papro_version(),
|
318 |
+
'papro_widgets' => Admin_Helper::get_pro_elements(),
|
319 |
+
)
|
320 |
+
);
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Loads plugin icons font
|
326 |
+
*
|
327 |
+
* @since 1.0.0
|
328 |
+
* @access public
|
329 |
+
* @return void
|
330 |
+
*/
|
331 |
+
public function enqueue_editor_styles() {
|
332 |
+
|
333 |
+
$theme = Helper_Functions::get_elementor_ui_theme();
|
334 |
+
|
335 |
+
wp_enqueue_style(
|
336 |
+
'pa-editor',
|
337 |
+
PREMIUM_ADDONS_URL . 'assets/editor/css/style.css',
|
338 |
+
array(),
|
339 |
+
PREMIUM_ADDONS_VERSION
|
340 |
+
);
|
341 |
+
|
342 |
+
// Enqueue required style for Elementor dark UI Theme.
|
343 |
+
if ( 'dark' === $theme ) {
|
344 |
+
|
345 |
+
wp_add_inline_style(
|
346 |
+
'pa-editor',
|
347 |
+
'.elementor-panel .elementor-control-section_pa_docs .elementor-panel-heading-title.elementor-panel-heading-title,
|
348 |
+
.elementor-control-raw-html.editor-pa-doc a {
|
349 |
+
color: #e0e1e3 !important;
|
350 |
+
}
|
351 |
+
[class^="pa-"]::after,
|
352 |
+
[class*=" pa-"]::after {
|
353 |
+
color: #aaa;
|
354 |
+
opacity: 1 !important;
|
355 |
+
}
|
356 |
+
.premium-promotion-dialog .premium-promotion-btn {
|
357 |
+
background-color: #202124 !important
|
358 |
+
}'
|
359 |
+
);
|
360 |
+
|
361 |
+
}
|
362 |
+
|
363 |
+
$badge_text = Helper_Functions::get_badge();
|
364 |
+
|
365 |
+
$dynamic_css = sprintf( '#elementor-panel [class^="pa-"]::after, #elementor-panel [class*=" pa-"]::after { content: "%s"; }', $badge_text );
|
366 |
+
|
367 |
+
wp_add_inline_style( 'pa-editor', $dynamic_css );
|
368 |
+
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Register Frontend CSS files
|
373 |
+
*
|
374 |
+
* @since 2.9.0
|
375 |
+
* @access public
|
376 |
+
*/
|
377 |
+
public function register_frontend_styles() {
|
378 |
+
|
379 |
+
$dir = Helper_Functions::get_styles_dir();
|
380 |
+
$suffix = Helper_Functions::get_assets_suffix();
|
381 |
+
|
382 |
+
$is_rtl = is_rtl() ? '-rtl' : '';
|
383 |
+
|
384 |
+
wp_register_style(
|
385 |
+
'font-awesome-5-all',
|
386 |
+
ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/all.min.css',
|
387 |
+
false,
|
388 |
+
PREMIUM_ADDONS_VERSION
|
389 |
+
);
|
390 |
+
|
391 |
+
wp_register_style(
|
392 |
+
'pa-prettyphoto',
|
393 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyphoto' . $is_rtl . $suffix . '.css',
|
394 |
+
array(),
|
395 |
+
PREMIUM_ADDONS_VERSION,
|
396 |
+
'all'
|
397 |
+
);
|
398 |
+
|
399 |
+
wp_register_style(
|
400 |
+
'pa-slick',
|
401 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $is_rtl . $suffix . '.css',
|
402 |
+
array(),
|
403 |
+
PREMIUM_ADDONS_VERSION,
|
404 |
+
'all'
|
405 |
+
);
|
406 |
+
|
407 |
+
$assets_gen_enabled = self::$modules['premium-assets-generator'] ? true : false;
|
408 |
+
|
409 |
+
$type = get_post_type();
|
410 |
+
|
411 |
+
if ( $assets_gen_enabled && ( 'page' === $type || 'post' === $type ) ) {
|
412 |
+
|
413 |
+
$css_path = '/pa-frontend' . $is_rtl . '-' . Assets_Manager::$post_id . $suffix . '.css';
|
414 |
+
|
415 |
+
if ( Assets_Manager::$is_updated && file_exists( PREMIUM_ASSETS_PATH . $css_path ) ) {
|
416 |
+
wp_enqueue_style(
|
417 |
+
'pa-frontend',
|
418 |
+
PREMIUM_ASSETS_URL . $css_path,
|
419 |
+
array(),
|
420 |
+
time(),
|
421 |
+
'all'
|
422 |
+
);
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
// If the assets are not ready, or file does not exist for any reson.
|
427 |
+
if ( ! wp_style_is( 'pa-frontend', 'enqueued' ) ) {
|
428 |
+
$this->register_old_styles( $dir, $is_rtl, $suffix );
|
429 |
+
}
|
430 |
+
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Register Old Styles
|
435 |
+
*
|
436 |
+
* @since 4.9.0
|
437 |
+
* @access public
|
438 |
+
*
|
439 |
+
* @param string $directory style directory.
|
440 |
+
* @param string $is_rtl page direction.
|
441 |
+
* @param string $suffix file suffix.
|
442 |
+
*/
|
443 |
+
public function register_old_styles( $directory, $is_rtl, $suffix ) {
|
444 |
+
|
445 |
+
wp_register_style(
|
446 |
+
'premium-addons',
|
447 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $is_rtl . $suffix . '.css',
|
448 |
+
array(),
|
449 |
+
PREMIUM_ADDONS_VERSION,
|
450 |
+
'all'
|
451 |
+
);
|
452 |
+
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Registers required JS files
|
457 |
+
*
|
458 |
+
* @since 1.0.0
|
459 |
+
* @access public
|
460 |
+
*/
|
461 |
+
public function register_frontend_scripts() {
|
462 |
+
|
463 |
+
$maps_settings = self::$maps;
|
464 |
+
|
465 |
+
$dir = Helper_Functions::get_scripts_dir();
|
466 |
+
$suffix = Helper_Functions::get_assets_suffix();
|
467 |
+
|
468 |
+
$locale = isset( $maps_settings['premium-map-locale'] ) ? $maps_settings['premium-map-locale'] : 'en';
|
469 |
+
$assets_gen_enabled = self::$modules['premium-assets-generator'] ? true : false;
|
470 |
+
|
471 |
+
$type = get_post_type();
|
472 |
+
|
473 |
+
if ( $assets_gen_enabled && ( 'page' === $type || 'post' === $type ) ) {
|
474 |
+
|
475 |
+
// If the elemens are cached and ready to generate.
|
476 |
+
if ( Assets_Manager::$is_updated ) {
|
477 |
+
Assets_Manager::generate_asset_file( 'js' );
|
478 |
+
Assets_Manager::generate_asset_file( 'css' );
|
479 |
+
}
|
480 |
+
|
481 |
+
$js_path = '/pa-frontend-' . Assets_Manager::$post_id . $suffix . '.js';
|
482 |
+
|
483 |
+
if ( file_exists( PREMIUM_ASSETS_PATH . $js_path ) ) {
|
484 |
+
|
485 |
+
wp_enqueue_script(
|
486 |
+
'pa-frontend',
|
487 |
+
PREMIUM_ASSETS_URL . $js_path,
|
488 |
+
array( 'jquery' ),
|
489 |
+
time(),
|
490 |
+
true
|
491 |
+
);
|
492 |
+
|
493 |
+
wp_localize_script(
|
494 |
+
'pa-frontend',
|
495 |
+
'PremiumSettings',
|
496 |
+
array(
|
497 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
498 |
+
'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
|
499 |
+
)
|
500 |
+
);
|
501 |
+
|
502 |
+
if ( class_exists( 'woocommerce' ) ) {
|
503 |
+
wp_localize_script(
|
504 |
+
'pa-frontend',
|
505 |
+
'PremiumWooSettings',
|
506 |
+
array(
|
507 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
508 |
+
'products_nonce' => wp_create_nonce( 'pa-woo-products-nonce' ),
|
509 |
+
'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ),
|
510 |
+
'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ),
|
511 |
+
'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) ),
|
512 |
+
)
|
513 |
+
);
|
514 |
+
}
|
515 |
+
}
|
516 |
+
}
|
517 |
+
|
518 |
+
// If the assets are not ready, or file does not exist for any reson.
|
519 |
+
if ( ! wp_script_is( 'pa-frontend', 'enqueued' ) ) {
|
520 |
+
$this->register_old_scripts( $dir, $suffix );
|
521 |
+
}
|
522 |
+
|
523 |
+
wp_register_script(
|
524 |
+
'prettyPhoto-js',
|
525 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyPhoto' . $suffix . '.js',
|
526 |
+
array( 'jquery' ),
|
527 |
+
PREMIUM_ADDONS_VERSION,
|
528 |
+
true
|
529 |
+
);
|
530 |
+
|
531 |
+
wp_register_script(
|
532 |
+
'pa-vticker',
|
533 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/vticker' . $suffix . '.js',
|
534 |
+
array( 'jquery' ),
|
535 |
+
PREMIUM_ADDONS_VERSION,
|
536 |
+
true
|
537 |
+
);
|
538 |
+
|
539 |
+
wp_register_script(
|
540 |
+
'pa-typed',
|
541 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/typed' . $suffix . '.js',
|
542 |
+
array( 'jquery' ),
|
543 |
+
PREMIUM_ADDONS_VERSION,
|
544 |
+
true
|
545 |
+
);
|
546 |
+
|
547 |
+
wp_register_script(
|
548 |
+
'pa-countdown',
|
549 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-countdown' . $suffix . '.js',
|
550 |
+
array( 'jquery' ),
|
551 |
+
PREMIUM_ADDONS_VERSION,
|
552 |
+
true
|
553 |
+
);
|
554 |
+
|
555 |
+
wp_register_script(
|
556 |
+
'isotope-js',
|
557 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/isotope' . $suffix . '.js',
|
558 |
+
array( 'jquery' ),
|
559 |
+
PREMIUM_ADDONS_VERSION,
|
560 |
+
true
|
561 |
+
);
|
562 |
+
|
563 |
+
wp_register_script(
|
564 |
+
'pa-modal',
|
565 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/modal' . $suffix . '.js',
|
566 |
+
array( 'jquery' ),
|
567 |
+
PREMIUM_ADDONS_VERSION,
|
568 |
+
true
|
569 |
+
);
|
570 |
+
|
571 |
+
wp_register_script(
|
572 |
+
'pa-maps',
|
573 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-maps' . $suffix . '.js',
|
574 |
+
array( 'jquery', 'pa-maps-api' ),
|
575 |
+
PREMIUM_ADDONS_VERSION,
|
576 |
+
true
|
577 |
+
);
|
578 |
+
|
579 |
+
wp_register_script(
|
580 |
+
'pa-vscroll',
|
581 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-vscroll' . $suffix . '.js',
|
582 |
+
array( 'jquery' ),
|
583 |
+
PREMIUM_ADDONS_VERSION,
|
584 |
+
true
|
585 |
+
);
|
586 |
+
|
587 |
+
wp_register_script(
|
588 |
+
'pa-slimscroll',
|
589 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-slimscroll' . $suffix . '.js',
|
590 |
+
array( 'jquery' ),
|
591 |
+
PREMIUM_ADDONS_VERSION,
|
592 |
+
true
|
593 |
+
);
|
594 |
+
|
595 |
+
wp_register_script(
|
596 |
+
'pa-iscroll',
|
597 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/iscroll' . $suffix . '.js',
|
598 |
+
array( 'jquery' ),
|
599 |
+
PREMIUM_ADDONS_VERSION,
|
600 |
+
true
|
601 |
+
);
|
602 |
+
|
603 |
+
wp_register_script(
|
604 |
+
'tilt-js',
|
605 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/universal-tilt' . $suffix . '.js',
|
606 |
+
array( 'jquery' ),
|
607 |
+
PREMIUM_ADDONS_VERSION,
|
608 |
+
true
|
609 |
+
);
|
610 |
+
|
611 |
+
wp_register_script(
|
612 |
+
'lottie-js',
|
613 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/lottie' . $suffix . '.js',
|
614 |
+
array(
|
615 |
+
'jquery',
|
616 |
+
'elementor-waypoints',
|
617 |
+
),
|
618 |
+
PREMIUM_ADDONS_VERSION,
|
619 |
+
true
|
620 |
+
);
|
621 |
+
|
622 |
+
wp_register_script(
|
623 |
+
'pa-tweenmax',
|
624 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/TweenMax' . $suffix . '.js',
|
625 |
+
array( 'jquery' ),
|
626 |
+
PREMIUM_ADDONS_VERSION,
|
627 |
+
true
|
628 |
+
);
|
629 |
+
|
630 |
+
wp_register_script(
|
631 |
+
'pa-headroom',
|
632 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/headroom' . $suffix . '.js',
|
633 |
+
array( 'jquery' ),
|
634 |
+
PREMIUM_ADDONS_VERSION
|
635 |
+
// true
|
636 |
+
);
|
637 |
+
|
638 |
+
if ( $maps_settings['premium-map-cluster'] ) {
|
639 |
+
wp_register_script(
|
640 |
+
'google-maps-cluster',
|
641 |
+
'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js',
|
642 |
+
array(),
|
643 |
+
PREMIUM_ADDONS_VERSION,
|
644 |
+
false
|
645 |
+
);
|
646 |
+
}
|
647 |
+
|
648 |
+
if ( $maps_settings['premium-map-disable-api'] && '1' !== $maps_settings['premium-map-api'] ) {
|
649 |
+
$api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&language=%2$s', $maps_settings['premium-map-api'], $locale );
|
650 |
+
wp_register_script(
|
651 |
+
'pa-maps-api',
|
652 |
+
$api,
|
653 |
+
array(),
|
654 |
+
PREMIUM_ADDONS_VERSION,
|
655 |
+
false
|
656 |
+
);
|
657 |
+
}
|
658 |
+
|
659 |
+
wp_register_script(
|
660 |
+
'pa-slick',
|
661 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $suffix . '.js',
|
662 |
+
array( 'jquery' ),
|
663 |
+
PREMIUM_ADDONS_VERSION,
|
664 |
+
true
|
665 |
+
);
|
666 |
+
|
667 |
+
wp_register_script(
|
668 |
+
'pa-anime',
|
669 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/anime' . $suffix . '.js',
|
670 |
+
array( 'jquery' ),
|
671 |
+
PREMIUM_ADDONS_VERSION,
|
672 |
+
true
|
673 |
+
);
|
674 |
+
|
675 |
+
wp_register_script(
|
676 |
+
'pa-feffects',
|
677 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-floating-effects' . $suffix . '.js',
|
678 |
+
array( 'jquery' ),
|
679 |
+
PREMIUM_ADDONS_VERSION,
|
680 |
+
true
|
681 |
+
);
|
682 |
+
|
683 |
+
wp_localize_script(
|
684 |
+
'premium-addons',
|
685 |
+
'PremiumSettings',
|
686 |
+
array(
|
687 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
688 |
+
'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
|
689 |
+
)
|
690 |
+
);
|
691 |
+
|
692 |
+
wp_register_script(
|
693 |
+
'pa-eq-height',
|
694 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-eq-height' . $suffix . '.js',
|
695 |
+
array( 'jquery' ),
|
696 |
+
PREMIUM_ADDONS_VERSION,
|
697 |
+
true
|
698 |
+
);
|
699 |
+
|
700 |
+
wp_register_script(
|
701 |
+
'pa-dis-conditions',
|
702 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-dis-conditions' . $suffix . '.js',
|
703 |
+
array( 'jquery' ),
|
704 |
+
PREMIUM_ADDONS_VERSION,
|
705 |
+
true
|
706 |
+
);
|
707 |
+
|
708 |
+
// Localize jQuery with required data for Global Add-ons.
|
709 |
+
if ( self::$modules['premium-floating-effects'] ) {
|
710 |
+
wp_localize_script(
|
711 |
+
'pa-feffects',
|
712 |
+
'PremiumFESettings',
|
713 |
+
array(
|
714 |
+
'papro_installed' => Helper_Functions::check_papro_version(),
|
715 |
+
)
|
716 |
+
);
|
717 |
+
}
|
718 |
+
|
719 |
+
}
|
720 |
+
|
721 |
+
/**
|
722 |
+
* Register Old Scripts
|
723 |
+
*
|
724 |
+
* @since 4.9.0
|
725 |
+
* @access public
|
726 |
+
*
|
727 |
+
* @param string $directory script directory.
|
728 |
+
* @param string $suffix file suffix.
|
729 |
+
*/
|
730 |
+
public function register_old_scripts( $directory, $suffix ) {
|
731 |
+
|
732 |
+
wp_register_script(
|
733 |
+
'premium-addons',
|
734 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $suffix . '.js',
|
735 |
+
array( 'jquery' ),
|
736 |
+
PREMIUM_ADDONS_VERSION,
|
737 |
+
true
|
738 |
+
);
|
739 |
+
|
740 |
+
// We need to make sure premium-woocommerce.js will not be loaded twice if assets are generated.
|
741 |
+
if ( class_exists( 'woocommerce' ) ) {
|
742 |
+
wp_register_script(
|
743 |
+
'premium-woocommerce',
|
744 |
+
PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-woo-products' . $suffix . '.js',
|
745 |
+
array( 'jquery' ),
|
746 |
+
PREMIUM_ADDONS_VERSION,
|
747 |
+
true
|
748 |
+
);
|
749 |
+
|
750 |
+
wp_localize_script(
|
751 |
+
'premium-woocommerce',
|
752 |
+
'PremiumWooSettings',
|
753 |
+
array(
|
754 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
755 |
+
'products_nonce' => wp_create_nonce( 'pa-woo-products-nonce' ),
|
756 |
+
'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ),
|
757 |
+
'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ),
|
758 |
+
'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) ),
|
759 |
+
)
|
760 |
+
);
|
761 |
+
}
|
762 |
+
|
763 |
+
}
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Enqueue Preview CSS files
|
767 |
+
*
|
768 |
+
* @since 2.9.0
|
769 |
+
* @access public
|
770 |
+
*/
|
771 |
+
public function enqueue_preview_styles() {
|
772 |
+
|
773 |
+
wp_enqueue_style( 'pa-prettyphoto' );
|
774 |
+
|
775 |
+
wp_enqueue_style( 'premium-addons' );
|
776 |
+
|
777 |
+
wp_enqueue_style( 'pa-slick' );
|
778 |
+
|
779 |
+
}
|
780 |
+
|
781 |
+
/**
|
782 |
+
* Load widgets require function
|
783 |
+
*
|
784 |
+
* @since 1.0.0
|
785 |
+
* @access public
|
786 |
+
*/
|
787 |
+
public function widgets_area() {
|
788 |
+
$this->widgets_register();
|
789 |
+
}
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Requires widgets files
|
793 |
+
*
|
794 |
+
* @since 1.0.0
|
795 |
+
* @access private
|
796 |
+
*/
|
797 |
+
private function widgets_register() {
|
798 |
+
|
799 |
+
$enabled_elements = self::$modules;
|
800 |
+
|
801 |
+
foreach ( glob( PREMIUM_ADDONS_PATH . 'widgets/*.php' ) as $file ) {
|
802 |
+
|
803 |
+
$slug = basename( $file, '.php' );
|
804 |
+
|
805 |
+
// Fixes the conflict between Lottie widget/addon keys.
|
806 |
+
if ( 'premium-lottie' === $slug ) {
|
807 |
+
|
808 |
+
// Check if Lottie widget switcher value was saved before.
|
809 |
+
$saved_options = get_option( 'pa_save_settings' );
|
810 |
+
|
811 |
+
$slug = 'premium-lottie-widget';
|
812 |
+
|
813 |
+
}
|
814 |
+
|
815 |
+
$enabled = isset( $enabled_elements[ $slug ] ) ? $enabled_elements[ $slug ] : '';
|
816 |
+
|
817 |
+
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $enabled_elements ) {
|
818 |
+
$this->register_addon( $file );
|
819 |
+
}
|
820 |
+
}
|
821 |
+
|
822 |
+
}
|
823 |
+
|
824 |
+
/**
|
825 |
+
* Register Woocommerce Widgets.
|
826 |
+
*
|
827 |
+
* @since 4.0.0
|
828 |
+
* @access private
|
829 |
+
*/
|
830 |
+
private function woo_widgets_register() {
|
831 |
+
|
832 |
+
$enabled_elements = self::$modules;
|
833 |
+
|
834 |
+
foreach ( glob( PREMIUM_ADDONS_PATH . 'modules/woocommerce/widgets/*.php' ) as $file ) {
|
835 |
+
|
836 |
+
$slug = basename( $file, '.php' );
|
837 |
+
|
838 |
+
$enabled = isset( $enabled_elements[ $slug ] ) ? $enabled_elements[ $slug ] : '';
|
839 |
+
|
840 |
+
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $enabled_elements ) {
|
841 |
+
|
842 |
+
$this->register_addon( $file );
|
843 |
+
}
|
844 |
+
}
|
845 |
+
}
|
846 |
+
|
847 |
+
/**
|
848 |
+
* Enqueue editor scripts
|
849 |
+
*
|
850 |
+
* @since 3.2.5
|
851 |
+
* @access public
|
852 |
+
*/
|
853 |
+
public function enqueue_editor_scripts() {
|
854 |
+
|
855 |
+
$map_enabled = isset( self::$modules['premium-maps'] ) ? self::$modules['premium-maps'] : 1;
|
856 |
+
|
857 |
+
if ( $map_enabled ) {
|
858 |
+
|
859 |
+
$premium_maps_api = self::$maps['premium-map-api'];
|
860 |
+
|
861 |
+
$locale = isset( self::$maps['premium-map-locale'] ) ? self::$maps['premium-map-locale'] : 'en';
|
862 |
+
|
863 |
+
$disable_api = self::$maps['premium-map-disable-api'];
|
864 |
+
|
865 |
+
if ( $disable_api && '1' !== $premium_maps_api ) {
|
866 |
+
|
867 |
+
$api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&language=%2$s', $premium_maps_api, $locale );
|
868 |
+
wp_enqueue_script(
|
869 |
+
'pa-maps-api',
|
870 |
+
$api,
|
871 |
+
array(),
|
872 |
+
PREMIUM_ADDONS_VERSION,
|
873 |
+
false
|
874 |
+
);
|
875 |
+
|
876 |
+
}
|
877 |
+
|
878 |
+
wp_enqueue_script(
|
879 |
+
'pa-maps-finder',
|
880 |
+
PREMIUM_ADDONS_URL . 'assets/editor/js/pa-maps-finder.js',
|
881 |
+
array( 'jquery' ),
|
882 |
+
PREMIUM_ADDONS_VERSION,
|
883 |
+
true
|
884 |
+
);
|
885 |
+
|
886 |
+
}
|
887 |
+
|
888 |
+
}
|
889 |
+
|
890 |
+
/**
|
891 |
+
* Load Cross Domain Copy Paste JS Files.
|
892 |
+
*
|
893 |
+
* @since 3.21.1
|
894 |
+
*/
|
895 |
+
public function enqueue_editor_cp_scripts() {
|
896 |
+
|
897 |
+
wp_enqueue_script(
|
898 |
+
'premium-xdlocalstorage-js',
|
899 |
+
PREMIUM_ADDONS_URL . 'assets/editor/js/xdlocalstorage.js',
|
900 |
+
null,
|
901 |
+
PREMIUM_ADDONS_VERSION,
|
902 |
+
true
|
903 |
+
);
|
904 |
+
|
905 |
+
wp_enqueue_script(
|
906 |
+
'premium-cross-cp',
|
907 |
+
PREMIUM_ADDONS_URL . 'assets/editor/js/premium-cross-cp.js',
|
908 |
+
array( 'jquery', 'elementor-editor', 'premium-xdlocalstorage-js' ),
|
909 |
+
PREMIUM_ADDONS_VERSION,
|
910 |
+
true
|
911 |
+
);
|
912 |
+
|
913 |
+
// Check for required Compatible Elementor version.
|
914 |
+
if ( ! version_compare( ELEMENTOR_VERSION, '3.1.0', '>=' ) ) {
|
915 |
+
$elementor_old = true;
|
916 |
+
} else {
|
917 |
+
$elementor_old = false;
|
918 |
+
}
|
919 |
+
|
920 |
+
wp_localize_script(
|
921 |
+
'jquery',
|
922 |
+
'premium_cross_cp',
|
923 |
+
array(
|
924 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
925 |
+
'nonce' => wp_create_nonce( 'premium_cross_cp_import' ),
|
926 |
+
'elementorCompatible' => $elementor_old,
|
927 |
+
)
|
928 |
+
);
|
929 |
+
}
|
930 |
+
|
931 |
+
/**
|
932 |
+
* Get Template Content
|
933 |
+
*
|
934 |
+
* Get Elementor template HTML content.
|
935 |
+
*
|
936 |
+
* @since 3.2.6
|
937 |
+
* @access public
|
938 |
+
*/
|
939 |
+
public function get_template_content() {
|
940 |
+
|
941 |
+
$template = isset( $_GET['templateID'] ) ? sanitize_text_field( wp_unslash( $_GET['templateID'] ) ) : '';
|
942 |
+
|
943 |
+
if ( empty( $template ) ) {
|
944 |
+
wp_send_json_error( '' );
|
945 |
+
}
|
946 |
+
|
947 |
+
$template_content = $this->template_instance->get_template_content( $template );
|
948 |
+
|
949 |
+
if ( empty( $template_content ) || ! isset( $template_content ) ) {
|
950 |
+
wp_send_json_error( '' );
|
951 |
+
}
|
952 |
+
|
953 |
+
$data = array(
|
954 |
+
'template_content' => $template_content,
|
955 |
+
);
|
956 |
+
|
957 |
+
wp_send_json_success( $data );
|
958 |
+
}
|
959 |
+
|
960 |
+
/**
|
961 |
+
*
|
962 |
+
* Register addon by file name.
|
963 |
+
*
|
964 |
+
* @access public
|
965 |
+
*
|
966 |
+
* @param string $file File name.
|
967 |
+
*
|
968 |
+
* @return void
|
969 |
+
*/
|
970 |
+
public function register_addon( $file ) {
|
971 |
+
|
972 |
+
$widgets_manager = \Elementor\Plugin::instance()->widgets_manager;
|
973 |
+
|
974 |
+
$base = basename( str_replace( '.php', '', $file ) );
|
975 |
+
$class = ucwords( str_replace( '-', ' ', $base ) );
|
976 |
+
$class = str_replace( ' ', '_', $class );
|
977 |
+
$class = sprintf( 'PremiumAddons\Widgets\%s', $class );
|
978 |
+
|
979 |
+
if ( 'PremiumAddons\Widgets\Premium_Contactform' !== $class ) {
|
980 |
+
require $file;
|
981 |
+
} else {
|
982 |
+
if ( function_exists( 'wpcf7' ) ) {
|
983 |
+
require $file;
|
984 |
+
}
|
985 |
+
}
|
986 |
+
|
987 |
+
if ( 'PremiumAddons\Widgets\Premium_Videobox' === $class ) {
|
988 |
+
require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php';
|
989 |
+
}
|
990 |
+
|
991 |
+
if ( class_exists( $class, false ) ) {
|
992 |
+
if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
|
993 |
+
$widgets_manager->register( new $class() );
|
994 |
+
} else {
|
995 |
+
$widgets_manager->register_widget_type( new $class() );
|
996 |
+
}
|
997 |
+
}
|
998 |
+
|
999 |
+
}
|
1000 |
+
|
1001 |
+
/**
|
1002 |
+
* Registers Premium Addons Custom Controls.
|
1003 |
+
*
|
1004 |
+
* @since 4.2.5
|
1005 |
+
* @access public
|
1006 |
+
*
|
1007 |
+
* @return void
|
1008 |
+
*/
|
1009 |
+
public function init_pa_controls() {
|
1010 |
+
|
1011 |
+
if ( self::$modules['premium-equal-height'] || self::$modules['premium-blog'] || self::$modules['pa-display-conditions'] ) {
|
1012 |
+
|
1013 |
+
$control_manager = \Elementor\Plugin::instance();
|
1014 |
+
|
1015 |
+
if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
|
1016 |
+
|
1017 |
+
// TODO: NEEDS TO BE DYNAMIC.
|
1018 |
+
if ( self::$modules['premium-equal-height'] ) {
|
1019 |
+
|
1020 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-select.php';
|
1021 |
+
$premium_select = __NAMESPACE__ . '\Controls\Premium_Select';
|
1022 |
+
$control_manager->controls_manager->register( new $premium_select() );
|
1023 |
+
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
if ( self::$modules['premium-blog'] ) {
|
1027 |
+
|
1028 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-post-filter.php';
|
1029 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-tax-filter.php';
|
1030 |
+
|
1031 |
+
$premium_post_filter = __NAMESPACE__ . '\Controls\Premium_Post_Filter';
|
1032 |
+
$premium_tax_filter = __NAMESPACE__ . '\Controls\Premium_Tax_Filter';
|
1033 |
+
|
1034 |
+
$control_manager->controls_manager->register( new $premium_post_filter() );
|
1035 |
+
$control_manager->controls_manager->register( new $premium_tax_filter() );
|
1036 |
+
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
if ( self::$modules['pa-display-conditions'] ) {
|
1040 |
+
|
1041 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-acf-selector.php';
|
1042 |
+
$premium_acf_selector = __NAMESPACE__ . '\Controls\Premium_Acf_Selector';
|
1043 |
+
$control_manager->controls_manager->register( new $premium_acf_selector() );
|
1044 |
+
|
1045 |
+
}
|
1046 |
+
} else {
|
1047 |
+
if ( self::$modules['premium-equal-height'] ) {
|
1048 |
+
|
1049 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-select.php';
|
1050 |
+
$premium_select = __NAMESPACE__ . '\Controls\Premium_Select';
|
1051 |
+
$control_manager->controls_manager->register_control( $premium_select::TYPE, new $premium_select() );
|
1052 |
+
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
if ( self::$modules['premium-blog'] ) {
|
1056 |
+
|
1057 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-post-filter.php';
|
1058 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-tax-filter.php';
|
1059 |
+
|
1060 |
+
$premium_post_filter = __NAMESPACE__ . '\Controls\Premium_Post_Filter';
|
1061 |
+
$premium_tax_filter = __NAMESPACE__ . '\Controls\Premium_Tax_Filter';
|
1062 |
+
|
1063 |
+
$control_manager->controls_manager->register_control( $premium_post_filter::TYPE, new $premium_post_filter() );
|
1064 |
+
$control_manager->controls_manager->register_control( $premium_tax_filter::TYPE, new $premium_tax_filter() );
|
1065 |
+
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
if ( self::$modules['pa-display-conditions'] ) {
|
1069 |
+
|
1070 |
+
require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-acf-selector.php';
|
1071 |
+
$premium_acf_selector = __NAMESPACE__ . '\Controls\Premium_Acf_Selector';
|
1072 |
+
$control_manager->controls_manager->register_control( $premium_acf_selector::TYPE, new $premium_acf_selector() );
|
1073 |
+
|
1074 |
+
}
|
1075 |
+
}
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
/**
|
1081 |
+
* Load PA Extensions
|
1082 |
+
*
|
1083 |
+
* @since 4.7.0
|
1084 |
+
* @access public
|
1085 |
+
*/
|
1086 |
+
public function load_pa_extensions() {
|
1087 |
+
|
1088 |
+
if ( self::$modules['premium-equal-height'] ) {
|
1089 |
+
Equal_Height::get_instance();
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
if ( self::$modules['pa-display-conditions'] ) {
|
1093 |
+
require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php';
|
1094 |
+
Display_Conditions::get_instance();
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
if ( self::$modules['premium-floating-effects'] ) {
|
1098 |
+
Floating_Effects::get_instance();
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
if ( class_exists( 'woocommerce' ) && self::$modules['woo-products'] ) {
|
1102 |
+
Woocommerce::get_instance();
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
/**
|
1108 |
+
*
|
1109 |
+
* Creates and returns an instance of the class
|
1110 |
+
*
|
1111 |
+
* @since 1.0.0
|
1112 |
+
* @access public
|
1113 |
+
*
|
1114 |
+
* @return object
|
1115 |
+
*/
|
1116 |
+
public static function get_instance() {
|
1117 |
+
|
1118 |
+
if ( ! isset( self::$instance ) ) {
|
1119 |
+
|
1120 |
+
self::$instance = new self();
|
1121 |
+
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
return self::$instance;
|
1125 |
+
}
|
1126 |
+
}
|
modules/pa-display-conditions/module.php
CHANGED
@@ -288,7 +288,7 @@ class Module {
|
|
288 |
'label' => __( 'Conditions', 'premium-addons-for-elementor' ),
|
289 |
'type' => Controls_Manager::REPEATER,
|
290 |
'label_block' => true,
|
291 |
-
'fields' => $repeater->get_controls(),
|
292 |
'title_field' => '<# print( pa_condition_key.replace(/_/g, " ").split(" ").map((s) => s.charAt(0).toUpperCase() + s.substring(1)).join(" ")) #>',
|
293 |
'condition' => array(
|
294 |
'pa_display_conditions_switcher' => 'yes',
|
288 |
'label' => __( 'Conditions', 'premium-addons-for-elementor' ),
|
289 |
'type' => Controls_Manager::REPEATER,
|
290 |
'label_block' => true,
|
291 |
+
'fields' => array_values( $repeater->get_controls() ),
|
292 |
'title_field' => '<# print( pa_condition_key.replace(/_/g, " ").split(" ").map((s) => s.charAt(0).toUpperCase() + s.substring(1)).join(" ")) #>',
|
293 |
'condition' => array(
|
294 |
'pa_display_conditions_switcher' => 'yes',
|
premium-addons-for-elementor.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
Plugin Name: Premium Addons for Elementor
|
4 |
Description: Premium Addons for Elementor plugin includes widgets and addons like Blog Post Grid, Gallery, Post Carousel, Advanced Slider, Modal Popup, Google Maps, Pricing Tables, Lottie Animations, Countdown, Testimonials.
|
5 |
Plugin URI: https://premiumaddons.com
|
6 |
-
Version: 4.9.
|
7 |
-
Elementor tested up to: 3.7.
|
8 |
Elementor Pro tested up to: 3.7.3
|
9 |
Author: Leap13
|
10 |
Author URI: https://leap13.com/
|
@@ -18,14 +18,14 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
18 |
}
|
19 |
|
20 |
// Define Constants.
|
21 |
-
define( 'PREMIUM_ADDONS_VERSION', '4.9.
|
22 |
define( 'PREMIUM_ADDONS_URL', plugins_url( '/', __FILE__ ) );
|
23 |
define( 'PREMIUM_ADDONS_PATH', plugin_dir_path( __FILE__ ) );
|
24 |
define( 'PREMIUM_ASSETS_PATH', set_url_scheme( wp_upload_dir()['basedir'] . '/premium-addons-elementor' ) );
|
25 |
define( 'PREMIUM_ASSETS_URL', set_url_scheme( wp_upload_dir()['baseurl'] . '/premium-addons-elementor' ) );
|
26 |
define( 'PREMIUM_ADDONS_FILE', __FILE__ );
|
27 |
define( 'PREMIUM_ADDONS_BASENAME', plugin_basename( PREMIUM_ADDONS_FILE ) );
|
28 |
-
define( 'PREMIUM_ADDONS_STABLE_VERSION', '4.9.
|
29 |
|
30 |
/*
|
31 |
* Load plugin core file
|
3 |
Plugin Name: Premium Addons for Elementor
|
4 |
Description: Premium Addons for Elementor plugin includes widgets and addons like Blog Post Grid, Gallery, Post Carousel, Advanced Slider, Modal Popup, Google Maps, Pricing Tables, Lottie Animations, Countdown, Testimonials.
|
5 |
Plugin URI: https://premiumaddons.com
|
6 |
+
Version: 4.9.25
|
7 |
+
Elementor tested up to: 3.7.1
|
8 |
Elementor Pro tested up to: 3.7.3
|
9 |
Author: Leap13
|
10 |
Author URI: https://leap13.com/
|
18 |
}
|
19 |
|
20 |
// Define Constants.
|
21 |
+
define( 'PREMIUM_ADDONS_VERSION', '4.9.25' );
|
22 |
define( 'PREMIUM_ADDONS_URL', plugins_url( '/', __FILE__ ) );
|
23 |
define( 'PREMIUM_ADDONS_PATH', plugin_dir_path( __FILE__ ) );
|
24 |
define( 'PREMIUM_ASSETS_PATH', set_url_scheme( wp_upload_dir()['basedir'] . '/premium-addons-elementor' ) );
|
25 |
define( 'PREMIUM_ASSETS_URL', set_url_scheme( wp_upload_dir()['baseurl'] . '/premium-addons-elementor' ) );
|
26 |
define( 'PREMIUM_ADDONS_FILE', __FILE__ );
|
27 |
define( 'PREMIUM_ADDONS_BASENAME', plugin_basename( PREMIUM_ADDONS_FILE ) );
|
28 |
+
define( 'PREMIUM_ADDONS_STABLE_VERSION', '4.9.24' );
|
29 |
|
30 |
/*
|
31 |
* Load plugin core file
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate Link: https://premiumaddons.com/?utm_source=wp-repo&utm_medium=link&utm_c
|
|
5 |
Requires at least: 5.0
|
6 |
Tested Up To: 6.0.1
|
7 |
Requires PHP: 5.4
|
8 |
-
Stable Tag: 4.9.
|
9 |
License: GPL v3.0
|
10 |
License URI: https://opensource.org/licenses/GPL-3.0
|
11 |
|
@@ -215,6 +215,10 @@ Premium Addons for Elementor is 100% Ads Free, Ads can only be detected from You
|
|
215 |
|
216 |
== Changelog ==
|
217 |
|
|
|
|
|
|
|
|
|
218 |
= 4.9.24 =
|
219 |
|
220 |
- Fixed: Comatibility issues with Elementor v3.7.0.
|
5 |
Requires at least: 5.0
|
6 |
Tested Up To: 6.0.1
|
7 |
Requires PHP: 5.4
|
8 |
+
Stable Tag: 4.9.25
|
9 |
License: GPL v3.0
|
10 |
License URI: https://opensource.org/licenses/GPL-3.0
|
11 |
|
215 |
|
216 |
== Changelog ==
|
217 |
|
218 |
+
= 4.9.25 =
|
219 |
+
|
220 |
+
- Fixed: Copy/Paste element styling not working after Elementor v3.7.1.
|
221 |
+
|
222 |
= 4.9.24 =
|
223 |
|
224 |
- Fixed: Comatibility issues with Elementor v3.7.0.
|