Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Astra Starter Sites |
Version | 1.0.13 |
Comparing to | |
See all releases |
Code changes from version 1.0.12 to 1.0.13
- astra-sites.php +2 -2
- inc/assets/css/admin.css +22 -7
- inc/assets/js/admin-page.js +893 -0
- inc/assets/js/astra-sites-api.js +59 -0
- inc/assets/js/render-grid.js +502 -0
- inc/assets/vendor/js/jquery.lazy.js +830 -0
- inc/assets/vendor/js/jquery.lazy.min.js +2 -0
- inc/classes/class-astra-sites-importer.php +290 -0
- inc/classes/class-astra-sites-page.php +270 -0
- inc/classes/class-astra-sites.php +80 -552
- inc/includes/admin-page.php +241 -0
- languages/astra-sites.pot +106 -102
- readme.txt +7 -14
astra-sites.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Astra Sites - Lite
|
4 |
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
* Description: Import free sites build with Astra theme.
|
6 |
-
* Version: 1.0.
|
7 |
* Author: Brainstorm Force
|
8 |
* Author URI: http://www.brainstormforce.com
|
9 |
* Text Domain: astra-sites
|
@@ -19,7 +19,7 @@ if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
|
|
19 |
}
|
20 |
|
21 |
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
22 |
-
define( 'ASTRA_SITES_VER', '1.0.
|
23 |
}
|
24 |
|
25 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
3 |
* Plugin Name: Astra Sites - Lite
|
4 |
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
* Description: Import free sites build with Astra theme.
|
6 |
+
* Version: 1.0.13
|
7 |
* Author: Brainstorm Force
|
8 |
* Author URI: http://www.brainstormforce.com
|
9 |
* Text Domain: astra-sites
|
19 |
}
|
20 |
|
21 |
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
22 |
+
define( 'ASTRA_SITES_VER', '1.0.13' );
|
23 |
}
|
24 |
|
25 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
inc/assets/css/admin.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
.wrap .status,
|
2 |
-
.wrap .
|
3 |
position: absolute;
|
4 |
z-index: 1;
|
5 |
color: #fff;
|
@@ -8,29 +8,29 @@
|
|
8 |
text-transform: uppercase;
|
9 |
}
|
10 |
.wrap .status,
|
11 |
-
.wrap .
|
12 |
background: #0073aa;
|
13 |
}
|
14 |
.wrap .status {
|
15 |
left: -0.5em;
|
16 |
}
|
17 |
-
.wrap .
|
18 |
right: -0.5em;
|
19 |
}
|
20 |
|
21 |
.wrap .status.publish,
|
22 |
-
.wrap .
|
23 |
display: none;
|
24 |
}
|
25 |
|
26 |
-
.install-theme-info .
|
27 |
display: none;
|
28 |
}
|
29 |
|
30 |
.theme {
|
31 |
position: relative;
|
32 |
}
|
33 |
-
.wrap .astra-sites-preview .
|
34 |
display: block;
|
35 |
display: none;
|
36 |
position: relative;
|
@@ -48,7 +48,7 @@
|
|
48 |
width: 100%;
|
49 |
}
|
50 |
|
51 |
-
.install-theme-info .
|
52 |
display: none;
|
53 |
}
|
54 |
|
@@ -220,4 +220,19 @@
|
|
220 |
margin-left: 0;
|
221 |
width: auto;
|
222 |
float: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
1 |
.wrap .status,
|
2 |
+
.wrap .site-type {
|
3 |
position: absolute;
|
4 |
z-index: 1;
|
5 |
color: #fff;
|
8 |
text-transform: uppercase;
|
9 |
}
|
10 |
.wrap .status,
|
11 |
+
.wrap .site-type.premium {
|
12 |
background: #0073aa;
|
13 |
}
|
14 |
.wrap .status {
|
15 |
left: -0.5em;
|
16 |
}
|
17 |
+
.wrap .site-type.premium {
|
18 |
right: -0.5em;
|
19 |
}
|
20 |
|
21 |
.wrap .status.publish,
|
22 |
+
.wrap .site-type.free {
|
23 |
display: none;
|
24 |
}
|
25 |
|
26 |
+
.install-theme-info .site-type {
|
27 |
display: none;
|
28 |
}
|
29 |
|
30 |
.theme {
|
31 |
position: relative;
|
32 |
}
|
33 |
+
.wrap .astra-sites-preview .site-type.premium {
|
34 |
display: block;
|
35 |
display: none;
|
36 |
position: relative;
|
48 |
width: 100%;
|
49 |
}
|
50 |
|
51 |
+
.install-theme-info .site-type.premium {
|
52 |
display: none;
|
53 |
}
|
54 |
|
220 |
margin-left: 0;
|
221 |
width: auto;
|
222 |
float: none;
|
223 |
+
}
|
224 |
+
.filters-wrap {
|
225 |
+
display: inline-block;
|
226 |
+
}
|
227 |
+
.spinner-wrap {
|
228 |
+
text-align: center;
|
229 |
+
}
|
230 |
+
.spinner-wrap .spinner {
|
231 |
+
float: none;
|
232 |
+
}
|
233 |
+
.hide-me {
|
234 |
+
display: none !important;
|
235 |
+
}
|
236 |
+
#astra-sites-admin {
|
237 |
+
height: 100vh;
|
238 |
}
|
inc/assets/js/admin-page.js
ADDED
@@ -0,0 +1,893 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* AJAX Request Queue
|
3 |
+
*
|
4 |
+
* - add()
|
5 |
+
* - remove()
|
6 |
+
* - run()
|
7 |
+
* - stop()
|
8 |
+
*
|
9 |
+
* @since 1.0.0
|
10 |
+
*/
|
11 |
+
var AstraSitesAjaxQueue = (function() {
|
12 |
+
|
13 |
+
var requests = [];
|
14 |
+
|
15 |
+
return {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Add AJAX request
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
*/
|
22 |
+
add: function(opt) {
|
23 |
+
requests.push(opt);
|
24 |
+
},
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Remove AJAX request
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
*/
|
31 |
+
remove: function(opt) {
|
32 |
+
if( jQuery.inArray(opt, requests) > -1 )
|
33 |
+
requests.splice($.inArray(opt, requests), 1);
|
34 |
+
},
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Run / Process AJAX request
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
+
*/
|
41 |
+
run: function() {
|
42 |
+
var self = this,
|
43 |
+
oriSuc;
|
44 |
+
|
45 |
+
if( requests.length ) {
|
46 |
+
oriSuc = requests[0].complete;
|
47 |
+
|
48 |
+
requests[0].complete = function() {
|
49 |
+
if( typeof(oriSuc) === 'function' ) oriSuc();
|
50 |
+
requests.shift();
|
51 |
+
self.run.apply(self, []);
|
52 |
+
};
|
53 |
+
|
54 |
+
jQuery.ajax(requests[0]);
|
55 |
+
|
56 |
+
} else {
|
57 |
+
|
58 |
+
self.tid = setTimeout(function() {
|
59 |
+
self.run.apply(self, []);
|
60 |
+
}, 1000);
|
61 |
+
}
|
62 |
+
},
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Stop AJAX request
|
66 |
+
*
|
67 |
+
* @since 1.0.0
|
68 |
+
*/
|
69 |
+
stop: function() {
|
70 |
+
|
71 |
+
requests = [];
|
72 |
+
clearTimeout(this.tid);
|
73 |
+
}
|
74 |
+
};
|
75 |
+
|
76 |
+
}());
|
77 |
+
(function($){
|
78 |
+
|
79 |
+
AstraSitesAdmin = {
|
80 |
+
|
81 |
+
init: function()
|
82 |
+
{
|
83 |
+
this._resetPagedCount();
|
84 |
+
this._bind();
|
85 |
+
},
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Binds events for the Astra Sites.
|
89 |
+
*
|
90 |
+
* @since 1.0.0
|
91 |
+
* @access private
|
92 |
+
* @method _bind
|
93 |
+
*/
|
94 |
+
_bind: function()
|
95 |
+
{
|
96 |
+
$( document ).on('click' , '.theme-browser .theme-screenshot, .theme-browser .more-details, .theme-browser .install-theme-preview', AstraSitesAdmin._preview);
|
97 |
+
$( document ).on('click' , '.next-theme', AstraSitesAdmin._nextTheme);
|
98 |
+
$( document ).on('click' , '.previous-theme', AstraSitesAdmin._previousTheme);
|
99 |
+
$( document ).on('click' , '.collapse-sidebar', AstraSitesAdmin._collapse);
|
100 |
+
$( document ).on('click' , '.astra-demo-import', AstraSitesAdmin._importDemo);
|
101 |
+
$( document ).on('click' , '.install-now', AstraSitesAdmin._installNow);
|
102 |
+
$( document ).on('click' , '.close-full-overlay', AstraSitesAdmin._fullOverlay);
|
103 |
+
$( document ).on('click' , '.activate-now', AstraSitesAdmin._activateNow);
|
104 |
+
$( document ).on('wp-plugin-installing' , AstraSitesAdmin._pluginInstalling);
|
105 |
+
$( document ).on('wp-plugin-install-error' , AstraSitesAdmin._installError);
|
106 |
+
$( document ).on('wp-plugin-install-success' , AstraSitesAdmin._installSuccess);
|
107 |
+
|
108 |
+
},
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Install Now
|
112 |
+
*/
|
113 |
+
_installNow: function(event)
|
114 |
+
{
|
115 |
+
event.preventDefault();
|
116 |
+
|
117 |
+
var $button = jQuery( event.target ),
|
118 |
+
$document = jQuery(document);
|
119 |
+
|
120 |
+
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
|
125 |
+
wp.updates.requestFilesystemCredentials( event );
|
126 |
+
|
127 |
+
$document.on( 'credential-modal-cancel', function() {
|
128 |
+
var $message = $( '.install-now.updating-message' );
|
129 |
+
|
130 |
+
$message
|
131 |
+
.removeClass( 'updating-message' )
|
132 |
+
.text( wp.updates.l10n.installNow );
|
133 |
+
|
134 |
+
wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
|
135 |
+
} );
|
136 |
+
}
|
137 |
+
|
138 |
+
wp.updates.installPlugin( {
|
139 |
+
slug: $button.data( 'slug' )
|
140 |
+
} );
|
141 |
+
},
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Install Success
|
145 |
+
*/
|
146 |
+
_installSuccess: function( event, response ) {
|
147 |
+
|
148 |
+
event.preventDefault();
|
149 |
+
|
150 |
+
var $message = jQuery( '.plugin-card-' + response.slug ).find( '.button' );
|
151 |
+
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
152 |
+
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
153 |
+
|
154 |
+
// Transform the 'Install' button into an 'Activate' button.
|
155 |
+
var $init = $message.data('init');
|
156 |
+
|
157 |
+
$message.removeClass( 'install-now installed button-disabled updated-message' )
|
158 |
+
.addClass('updating-message')
|
159 |
+
.html( astraSitesAdmin.strings.btnActivating );
|
160 |
+
|
161 |
+
// Reset not installed plugins list.
|
162 |
+
var pluginsList = astraSitesAdmin.requiredPlugins.notinstalled;
|
163 |
+
astraSitesAdmin.requiredPlugins.notinstalled = AstraSitesAdmin._removePluginFromQueue( response.slug, pluginsList );
|
164 |
+
|
165 |
+
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
|
166 |
+
setTimeout( function() {
|
167 |
+
|
168 |
+
jQuery.ajax({
|
169 |
+
url: astraSitesAdmin.ajaxurl,
|
170 |
+
type: 'POST',
|
171 |
+
data: {
|
172 |
+
'action' : 'astra-required-plugin-activate',
|
173 |
+
'init' : $init,
|
174 |
+
'options' : $siteOptions,
|
175 |
+
'enabledExtensions' : $enabledExtensions,
|
176 |
+
},
|
177 |
+
})
|
178 |
+
.done(function (result) {
|
179 |
+
|
180 |
+
if( result.success ) {
|
181 |
+
|
182 |
+
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
|
183 |
+
|
184 |
+
// Reset not installed plugins list.
|
185 |
+
astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( response.slug, pluginsList );
|
186 |
+
|
187 |
+
$message.removeClass( 'button-primary install-now activate-now updating-message' )
|
188 |
+
.attr('disabled', 'disabled')
|
189 |
+
.addClass('disabled')
|
190 |
+
.text( astraSitesAdmin.strings.btnActive );
|
191 |
+
|
192 |
+
// Enable Demo Import Button
|
193 |
+
AstraSitesAdmin._enable_demo_import_button();
|
194 |
+
|
195 |
+
} else {
|
196 |
+
|
197 |
+
$message.removeClass( 'updating-message' );
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
});
|
202 |
+
|
203 |
+
}, 1200 );
|
204 |
+
|
205 |
+
},
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Plugin Installation Error.
|
209 |
+
*/
|
210 |
+
_installError: function( event, response ) {
|
211 |
+
|
212 |
+
var $card = jQuery( '.plugin-card-' + response.slug );
|
213 |
+
|
214 |
+
$card
|
215 |
+
.addClass( 'button-primary' )
|
216 |
+
.html( wp.updates.l10n.installNow );
|
217 |
+
},
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Installing Plugin
|
221 |
+
*/
|
222 |
+
_pluginInstalling: function(event, args) {
|
223 |
+
event.preventDefault();
|
224 |
+
|
225 |
+
var $card = jQuery( '.plugin-card-' + args.slug );
|
226 |
+
var $button = $card.find( '.button' );
|
227 |
+
|
228 |
+
$card.addClass('updating-message');
|
229 |
+
$button.addClass('already-started');
|
230 |
+
|
231 |
+
},
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Render Demo Preview
|
235 |
+
*/
|
236 |
+
_activateNow: function( eventn ) {
|
237 |
+
|
238 |
+
event.preventDefault();
|
239 |
+
|
240 |
+
var $button = jQuery( event.target ),
|
241 |
+
$init = $button.data( 'init' ),
|
242 |
+
$slug = $button.data( 'slug' );
|
243 |
+
|
244 |
+
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
245 |
+
return;
|
246 |
+
}
|
247 |
+
|
248 |
+
$button.addClass('updating-message button-primary')
|
249 |
+
.html( astraSitesAdmin.strings.btnActivating );
|
250 |
+
|
251 |
+
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
252 |
+
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
253 |
+
|
254 |
+
jQuery.ajax({
|
255 |
+
url: astraSitesAdmin.ajaxurl,
|
256 |
+
type: 'POST',
|
257 |
+
data: {
|
258 |
+
'action' : 'astra-required-plugin-activate',
|
259 |
+
'init' : $init,
|
260 |
+
'options' : $siteOptions,
|
261 |
+
'enabledExtensions' : $enabledExtensions,
|
262 |
+
},
|
263 |
+
})
|
264 |
+
.done(function (result) {
|
265 |
+
|
266 |
+
if( result.success ) {
|
267 |
+
|
268 |
+
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
|
269 |
+
|
270 |
+
// Reset not installed plugins list.
|
271 |
+
astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( $slug, pluginsList );
|
272 |
+
|
273 |
+
$button.removeClass( 'button-primary install-now activate-now updating-message' )
|
274 |
+
.attr('disabled', 'disabled')
|
275 |
+
.addClass('disabled')
|
276 |
+
.text( astraSitesAdmin.strings.btnActive );
|
277 |
+
|
278 |
+
// Enable Demo Import Button
|
279 |
+
AstraSitesAdmin._enable_demo_import_button();
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
})
|
284 |
+
.fail(function () {
|
285 |
+
});
|
286 |
+
|
287 |
+
},
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Full Overlay
|
291 |
+
*/
|
292 |
+
_fullOverlay: function (event) {
|
293 |
+
event.preventDefault();
|
294 |
+
|
295 |
+
jQuery('.theme-install-overlay').css('display', 'none');
|
296 |
+
jQuery('.theme-install-overlay').remove();
|
297 |
+
jQuery('.theme-preview-on').removeClass('theme-preview-on');
|
298 |
+
jQuery('html').removeClass('astra-site-preview-on');
|
299 |
+
},
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Bulk Plugin Active & Install
|
303 |
+
*/
|
304 |
+
_bulkPluginInstallActivate: function()
|
305 |
+
{
|
306 |
+
if( 0 === astraSitesAdmin.requiredPlugins.length ) {
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
+
jQuery('.required-plugins')
|
311 |
+
.find('.install-now')
|
312 |
+
.addClass( 'updating-message' )
|
313 |
+
.removeClass( 'install-now' )
|
314 |
+
.text( wp.updates.l10n.installing );
|
315 |
+
|
316 |
+
jQuery('.required-plugins')
|
317 |
+
.find('.activate-now')
|
318 |
+
.addClass('updating-message')
|
319 |
+
.removeClass( 'activate-now' )
|
320 |
+
.html( astraSitesAdmin.strings.btnActivating );
|
321 |
+
|
322 |
+
var not_installed = astraSitesAdmin.requiredPlugins.notinstalled || '';
|
323 |
+
var activate_plugins = astraSitesAdmin.requiredPlugins.inactive || '';
|
324 |
+
|
325 |
+
// First Install Bulk.
|
326 |
+
if( not_installed.length > 0 ) {
|
327 |
+
AstraSitesAdmin._installAllPlugins( not_installed );
|
328 |
+
}
|
329 |
+
|
330 |
+
// Second Activate Bulk.
|
331 |
+
if( activate_plugins.length > 0 ) {
|
332 |
+
AstraSitesAdmin._activateAllPlugins( activate_plugins );
|
333 |
+
}
|
334 |
+
|
335 |
+
},
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Activate All Plugins.
|
339 |
+
*/
|
340 |
+
_activateAllPlugins: function( activate_plugins ) {
|
341 |
+
|
342 |
+
// Process of cloud templates - (download, remove & fetch).
|
343 |
+
AstraSitesAjaxQueue.run();
|
344 |
+
|
345 |
+
jQuery.each( activate_plugins, function(index, single_plugin) {
|
346 |
+
|
347 |
+
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
348 |
+
$button = $card.find('.button'),
|
349 |
+
$siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val(),
|
350 |
+
$enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
351 |
+
|
352 |
+
$button.addClass('updating-message');
|
353 |
+
|
354 |
+
AstraSitesAjaxQueue.add({
|
355 |
+
url: astraSitesAdmin.ajaxurl,
|
356 |
+
type: 'POST',
|
357 |
+
data: {
|
358 |
+
'action' : 'astra-required-plugin-activate',
|
359 |
+
'init' : single_plugin.init,
|
360 |
+
'options' : $siteOptions,
|
361 |
+
'enabledExtensions' : $enabledExtensions,
|
362 |
+
},
|
363 |
+
success: function( result ){
|
364 |
+
|
365 |
+
if( result.success ) {
|
366 |
+
|
367 |
+
var $card = jQuery( '.plugin-card-' + single_plugin.slug );
|
368 |
+
var $button = $card.find( '.button' );
|
369 |
+
if( ! $button.hasClass('already-started') ) {
|
370 |
+
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
|
371 |
+
|
372 |
+
// Reset not installed plugins list.
|
373 |
+
astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( single_plugin.slug, pluginsList );
|
374 |
+
}
|
375 |
+
|
376 |
+
$button.removeClass( 'button-primary install-now activate-now updating-message' )
|
377 |
+
.attr('disabled', 'disabled')
|
378 |
+
.addClass('disabled')
|
379 |
+
.text( astraSitesAdmin.strings.btnActive );
|
380 |
+
|
381 |
+
// Enable Demo Import Button
|
382 |
+
AstraSitesAdmin._enable_demo_import_button();
|
383 |
+
}
|
384 |
+
}
|
385 |
+
});
|
386 |
+
});
|
387 |
+
},
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Install All Plugins.
|
391 |
+
*/
|
392 |
+
_installAllPlugins: function( not_installed ) {
|
393 |
+
|
394 |
+
jQuery.each( not_installed, function(index, single_plugin) {
|
395 |
+
|
396 |
+
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
397 |
+
$button = $card.find('.button');
|
398 |
+
|
399 |
+
if( ! $button.hasClass('already-started') ) {
|
400 |
+
|
401 |
+
// Add each plugin activate request in Ajax queue.
|
402 |
+
// @see wp-admin/js/updates.js
|
403 |
+
wp.updates.queue.push( {
|
404 |
+
action: 'install-plugin', // Required action.
|
405 |
+
data: {
|
406 |
+
slug: single_plugin.slug
|
407 |
+
}
|
408 |
+
} );
|
409 |
+
}
|
410 |
+
});
|
411 |
+
|
412 |
+
// Required to set queue.
|
413 |
+
wp.updates.queueChecker();
|
414 |
+
},
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Fires when a nav item is clicked.
|
418 |
+
*
|
419 |
+
* @since 1.0
|
420 |
+
* @access private
|
421 |
+
* @method _importDemo
|
422 |
+
*/
|
423 |
+
_importDemo: function()
|
424 |
+
{
|
425 |
+
var $this = jQuery(this),
|
426 |
+
$theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header'),
|
427 |
+
apiURL = $theme.data('demo-api') || '',
|
428 |
+
plugins = $theme.data('required-plugins');
|
429 |
+
|
430 |
+
var disabled = $this.attr('data-import');
|
431 |
+
|
432 |
+
if ( typeof disabled !== 'undefined' && disabled === 'disabled' ) {
|
433 |
+
|
434 |
+
$this.addClass('updating-message')
|
435 |
+
.text( wp.updates.l10n.installing );
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Process Bulk Plugin Install & Activate
|
439 |
+
*/
|
440 |
+
AstraSitesAdmin._bulkPluginInstallActivate();
|
441 |
+
|
442 |
+
return;
|
443 |
+
}
|
444 |
+
|
445 |
+
// Proceed?
|
446 |
+
if( ! confirm( astraSitesAdmin.strings.importWarning ) ) {
|
447 |
+
return;
|
448 |
+
}
|
449 |
+
|
450 |
+
jQuery('.astra-demo-import').attr('data-import', 'disabled')
|
451 |
+
.addClass('updating-message installing')
|
452 |
+
.text( astraSitesAdmin.strings.importingDemo );
|
453 |
+
|
454 |
+
$this.closest('.theme').focus();
|
455 |
+
|
456 |
+
var $theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header');
|
457 |
+
|
458 |
+
var apiURL = $theme.data('demo-api') || '';
|
459 |
+
|
460 |
+
jQuery.ajax({
|
461 |
+
url: astraSitesAdmin.ajaxurl,
|
462 |
+
type: 'POST',
|
463 |
+
dataType: 'json',
|
464 |
+
data: {
|
465 |
+
action: 'astra-import-demo',
|
466 |
+
api_url: apiURL
|
467 |
+
},
|
468 |
+
})
|
469 |
+
.done(function ( demos ) {
|
470 |
+
|
471 |
+
// Success?
|
472 |
+
if( demos.success ) {
|
473 |
+
jQuery('.astra-demo-import').removeClass('updating-message installing')
|
474 |
+
.removeAttr('data-import')
|
475 |
+
.addClass('view-site')
|
476 |
+
.removeClass('astra-demo-import')
|
477 |
+
.text( astraSitesAdmin.strings.viewSite )
|
478 |
+
.attr('target', '_blank')
|
479 |
+
.append('<i class="dashicons dashicons-external"></i>')
|
480 |
+
.attr('href', astraSitesAdmin.siteURL );
|
481 |
+
|
482 |
+
} else {
|
483 |
+
|
484 |
+
var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
|
485 |
+
output += ' <p>'+demos.message+'</p>';
|
486 |
+
output += ' <button type="button" class="notice-dismiss">';
|
487 |
+
output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
|
488 |
+
output += ' </button>';
|
489 |
+
output += '</div>';
|
490 |
+
|
491 |
+
jQuery('.install-theme-info').prepend( output );
|
492 |
+
|
493 |
+
// !important to add trigger.
|
494 |
+
// Which reinitialize the dismiss error message events.
|
495 |
+
jQuery(document).trigger('wp-updates-notice-added');
|
496 |
+
}
|
497 |
+
|
498 |
+
})
|
499 |
+
.fail(function ( demos ) {
|
500 |
+
jQuery('.astra-demo-import').removeClass('updating-message installing')
|
501 |
+
.removeAttr('data-import')
|
502 |
+
.addClass('view-site')
|
503 |
+
.removeClass('astra-demo-import')
|
504 |
+
.attr('target', '_blank')
|
505 |
+
.attr('href', astraSitesAdmin.strings.importFailedURL );
|
506 |
+
|
507 |
+
jQuery('.wp-full-overlay-header .view-site').text( astraSitesAdmin.strings.importFailedBtnSmall ).append('<i class="dashicons dashicons-external"></i>');
|
508 |
+
jQuery('.footer-import-button-wrap .view-site').text( astraSitesAdmin.strings.importFailedBtnLarge ).append('<i class="dashicons dashicons-external"></i>');
|
509 |
+
});
|
510 |
+
},
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Collapse Sidebar.
|
514 |
+
*/
|
515 |
+
_collapse: function() {
|
516 |
+
event.preventDefault();
|
517 |
+
|
518 |
+
overlay = jQuery('.wp-full-overlay');
|
519 |
+
|
520 |
+
if (overlay.hasClass('expanded')) {
|
521 |
+
overlay.removeClass('expanded');
|
522 |
+
overlay.addClass('collapsed');
|
523 |
+
return;
|
524 |
+
}
|
525 |
+
|
526 |
+
if (overlay.hasClass('collapsed')) {
|
527 |
+
overlay.removeClass('collapsed');
|
528 |
+
overlay.addClass('expanded');
|
529 |
+
return;
|
530 |
+
}
|
531 |
+
},
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Previous Theme.
|
535 |
+
*/
|
536 |
+
_previousTheme: function (event) {
|
537 |
+
event.preventDefault();
|
538 |
+
|
539 |
+
currentDemo = jQuery('.theme-preview-on');
|
540 |
+
currentDemo.removeClass('theme-preview-on');
|
541 |
+
prevDemo = currentDemo.prev('.theme');
|
542 |
+
prevDemo.addClass('theme-preview-on');
|
543 |
+
|
544 |
+
AstraSitesAdmin._renderDemoPreview(prevDemo);
|
545 |
+
},
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Next Theme.
|
549 |
+
*/
|
550 |
+
_nextTheme: function (event) {
|
551 |
+
event.preventDefault();
|
552 |
+
currentDemo = jQuery('.theme-preview-on')
|
553 |
+
currentDemo.removeClass('theme-preview-on');
|
554 |
+
nextDemo = currentDemo.next('.theme');
|
555 |
+
nextDemo.addClass('theme-preview-on');
|
556 |
+
|
557 |
+
AstraSitesAdmin._renderDemoPreview( nextDemo );
|
558 |
+
},
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Individual Site Preview
|
562 |
+
*
|
563 |
+
* On click on image, more link & preview button.
|
564 |
+
*/
|
565 |
+
_preview: function( event ) {
|
566 |
+
|
567 |
+
event.preventDefault();
|
568 |
+
|
569 |
+
var self = jQuery(this).parents('.theme');
|
570 |
+
self.addClass('theme-preview-on');
|
571 |
+
|
572 |
+
jQuery('html').addClass('astra-site-preview-on');
|
573 |
+
|
574 |
+
AstraSitesAdmin._renderDemoPreview( self );
|
575 |
+
},
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Check Next Previous Buttons.
|
579 |
+
*/
|
580 |
+
_checkNextPrevButtons: function() {
|
581 |
+
currentDemo = jQuery('.theme-preview-on');
|
582 |
+
nextDemo = currentDemo.nextAll('.theme').length;
|
583 |
+
prevDemo = currentDemo.prevAll('.theme').length;
|
584 |
+
|
585 |
+
if (nextDemo == 0) {
|
586 |
+
jQuery('.next-theme').addClass('disabled');
|
587 |
+
} else if (nextDemo != 0) {
|
588 |
+
jQuery('.next-theme').removeClass('disabled');
|
589 |
+
}
|
590 |
+
|
591 |
+
if (prevDemo == 0) {
|
592 |
+
jQuery('.previous-theme').addClass('disabled');
|
593 |
+
} else if (prevDemo != 0) {
|
594 |
+
jQuery('.previous-theme').removeClass('disabled');
|
595 |
+
}
|
596 |
+
|
597 |
+
return;
|
598 |
+
},
|
599 |
+
|
600 |
+
/**
|
601 |
+
* Render Demo Preview
|
602 |
+
*/
|
603 |
+
_renderDemoPreview: function(anchor) {
|
604 |
+
|
605 |
+
var demoId = anchor.data('id') || '',
|
606 |
+
apiURL = anchor.data('demo-api') || '',
|
607 |
+
demoType = anchor.data('demo-type') || '',
|
608 |
+
demoURL = anchor.data('demo-url') || '',
|
609 |
+
screenshot = anchor.data('screenshot') || '',
|
610 |
+
demo_name = anchor.data('demo-name') || '',
|
611 |
+
demo_slug = anchor.data('demo-slug') || '',
|
612 |
+
content = anchor.data('content') || '',
|
613 |
+
requiredPlugins = anchor.data('required-plugins') || '',
|
614 |
+
astraSiteOptions = anchor.find('.astra-site-options').val() || '';
|
615 |
+
astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
|
616 |
+
|
617 |
+
var template = wp.template('astra-site-preview');
|
618 |
+
|
619 |
+
templateData = [{
|
620 |
+
id : demoId,
|
621 |
+
astra_demo_type : demoType,
|
622 |
+
astra_demo_url : demoURL,
|
623 |
+
demo_api : apiURL,
|
624 |
+
screenshot : screenshot,
|
625 |
+
demo_name : demo_name,
|
626 |
+
slug : demo_slug,
|
627 |
+
content : content,
|
628 |
+
required_plugins : JSON.stringify(requiredPlugins),
|
629 |
+
astra_site_options : astraSiteOptions,
|
630 |
+
astra_enabled_extensions : astraEnabledExtensions,
|
631 |
+
}];
|
632 |
+
|
633 |
+
// delete any earlier fullscreen preview before we render new one.
|
634 |
+
jQuery('.theme-install-overlay').remove();
|
635 |
+
|
636 |
+
jQuery('#astra-sites-menu-page').append(template(templateData[0]));
|
637 |
+
jQuery('.theme-install-overlay').css('display', 'block');
|
638 |
+
AstraSitesAdmin._checkNextPrevButtons();
|
639 |
+
|
640 |
+
var desc = jQuery('.theme-details');
|
641 |
+
var descHeight = parseInt( desc.outerHeight() );
|
642 |
+
var descBtn = jQuery('.theme-details-read-more');
|
643 |
+
|
644 |
+
if( jQuery.isArray( requiredPlugins ) ) {
|
645 |
+
|
646 |
+
if( descHeight >= 55 ) {
|
647 |
+
|
648 |
+
// Show button.
|
649 |
+
descBtn.css( 'display', 'inline-block' );
|
650 |
+
|
651 |
+
// Set height upto 3 line.
|
652 |
+
desc.css( 'height', 57 );
|
653 |
+
|
654 |
+
// Button Click.
|
655 |
+
descBtn.click(function(event) {
|
656 |
+
|
657 |
+
if( descBtn.hasClass('open') ) {
|
658 |
+
desc.animate({ height: 57 },
|
659 |
+
300, function() {
|
660 |
+
descBtn.removeClass('open');
|
661 |
+
descBtn.html( astraSitesAdmin.strings.DescExpand );
|
662 |
+
});
|
663 |
+
} else {
|
664 |
+
desc.animate({ height: descHeight },
|
665 |
+
300, function() {
|
666 |
+
descBtn.addClass('open');
|
667 |
+
descBtn.html( astraSitesAdmin.strings.DescCollapse );
|
668 |
+
});
|
669 |
+
}
|
670 |
+
|
671 |
+
});
|
672 |
+
}
|
673 |
+
|
674 |
+
// or
|
675 |
+
var $pluginsFilter = jQuery( '#plugin-filter' ),
|
676 |
+
data = {
|
677 |
+
_ajax_nonce : astraSitesAdmin._ajax_nonce,
|
678 |
+
required_plugins : requiredPlugins
|
679 |
+
};
|
680 |
+
|
681 |
+
jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
|
682 |
+
|
683 |
+
wp.ajax.post( 'astra-required-plugins', data ).done( function( response ) {
|
684 |
+
|
685 |
+
// Remove loader.
|
686 |
+
jQuery('.required-plugins').removeClass('loading').html('');
|
687 |
+
|
688 |
+
/**
|
689 |
+
* Count remaining plugins.
|
690 |
+
* @type number
|
691 |
+
*/
|
692 |
+
var remaining_plugins = 0;
|
693 |
+
|
694 |
+
/**
|
695 |
+
* Not Installed
|
696 |
+
*
|
697 |
+
* List of not installed required plugins.
|
698 |
+
*/
|
699 |
+
if ( typeof response.notinstalled !== 'undefined' ) {
|
700 |
+
|
701 |
+
// Add not have installed plugins count.
|
702 |
+
remaining_plugins += parseInt( response.notinstalled.length );
|
703 |
+
|
704 |
+
jQuery( response.notinstalled ).each(function( index, plugin ) {
|
705 |
+
|
706 |
+
var output = '<div class="plugin-card ';
|
707 |
+
output += ' plugin-card-'+plugin.slug+'"';
|
708 |
+
output += ' data-slug="'+plugin.slug+'"';
|
709 |
+
output += ' data-init="'+plugin.init+'">';
|
710 |
+
output += ' <span class="title">'+plugin.name+'</span>';
|
711 |
+
output += ' <button class="button install-now"';
|
712 |
+
output += ' data-init="' + plugin.init + '"';
|
713 |
+
output += ' data-slug="' + plugin.slug + '"';
|
714 |
+
output += ' data-name="' + plugin.name + '">';
|
715 |
+
output += wp.updates.l10n.installNow;
|
716 |
+
output += ' </button>';
|
717 |
+
// output += ' <span class="dashicons-no dashicons"></span>';
|
718 |
+
output += '</div>';
|
719 |
+
|
720 |
+
jQuery('.required-plugins').append(output);
|
721 |
+
|
722 |
+
});
|
723 |
+
}
|
724 |
+
|
725 |
+
/**
|
726 |
+
* Inactive
|
727 |
+
*
|
728 |
+
* List of not inactive required plugins.
|
729 |
+
*/
|
730 |
+
if ( typeof response.inactive !== 'undefined' ) {
|
731 |
+
|
732 |
+
// Add inactive plugins count.
|
733 |
+
remaining_plugins += parseInt( response.inactive.length );
|
734 |
+
|
735 |
+
jQuery( response.inactive ).each(function( index, plugin ) {
|
736 |
+
|
737 |
+
var output = '<div class="plugin-card ';
|
738 |
+
output += ' plugin-card-'+plugin.slug+'"';
|
739 |
+
output += ' data-slug="'+plugin.slug+'"';
|
740 |
+
output += ' data-init="'+plugin.init+'">';
|
741 |
+
output += ' <span class="title">'+plugin.name+'</span>';
|
742 |
+
output += ' <button class="button activate-now button-primary"';
|
743 |
+
output += ' data-init="' + plugin.init + '"';
|
744 |
+
output += ' data-slug="' + plugin.slug + '"';
|
745 |
+
output += ' data-name="' + plugin.name + '">';
|
746 |
+
output += wp.updates.l10n.activatePlugin;
|
747 |
+
output += ' </button>';
|
748 |
+
// output += ' <span class="dashicons-no dashicons"></span>';
|
749 |
+
output += '</div>';
|
750 |
+
|
751 |
+
jQuery('.required-plugins').append(output);
|
752 |
+
|
753 |
+
});
|
754 |
+
}
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Active
|
758 |
+
*
|
759 |
+
* List of not active required plugins.
|
760 |
+
*/
|
761 |
+
if ( typeof response.active !== 'undefined' ) {
|
762 |
+
|
763 |
+
jQuery( response.active ).each(function( index, plugin ) {
|
764 |
+
|
765 |
+
var output = '<div class="plugin-card ';
|
766 |
+
output += ' plugin-card-'+plugin.slug+'"';
|
767 |
+
output += ' data-slug="'+plugin.slug+'"';
|
768 |
+
output += ' data-init="'+plugin.init+'">';
|
769 |
+
output += ' <span class="title">'+plugin.name+'</span>';
|
770 |
+
output += ' <button class="button disabled"';
|
771 |
+
output += ' data-slug="' + plugin.slug + '"';
|
772 |
+
output += ' data-name="' + plugin.name + '">';
|
773 |
+
output += astraSitesAdmin.strings.btnActive;
|
774 |
+
output += ' </button>';
|
775 |
+
// output += ' <span class="dashicons-yes dashicons"></span>';
|
776 |
+
output += '</div>';
|
777 |
+
|
778 |
+
jQuery('.required-plugins').append(output);
|
779 |
+
|
780 |
+
});
|
781 |
+
}
|
782 |
+
|
783 |
+
/**
|
784 |
+
* Enable Demo Import Button
|
785 |
+
* @type number
|
786 |
+
*/
|
787 |
+
astraSitesAdmin.requiredPlugins = response;
|
788 |
+
AstraSitesAdmin._enable_demo_import_button();
|
789 |
+
|
790 |
+
} );
|
791 |
+
|
792 |
+
} else {
|
793 |
+
|
794 |
+
// Enable Demo Import Button
|
795 |
+
AstraSitesAdmin._enable_demo_import_button( demoType );
|
796 |
+
jQuery('.required-plugins-wrap').remove();
|
797 |
+
}
|
798 |
+
|
799 |
+
return;
|
800 |
+
},
|
801 |
+
|
802 |
+
/**
|
803 |
+
* Enable Demo Import Button.
|
804 |
+
*/
|
805 |
+
_enable_demo_import_button: function( type = 'free' ) {
|
806 |
+
|
807 |
+
switch( type ) {
|
808 |
+
|
809 |
+
case 'free':
|
810 |
+
var all_buttons = parseInt( jQuery( '.plugin-card .button' ).length ) || 0,
|
811 |
+
disabled_buttons = parseInt( jQuery( '.plugin-card .button.disabled' ).length ) || 0;
|
812 |
+
|
813 |
+
if( all_buttons === disabled_buttons ) {
|
814 |
+
|
815 |
+
jQuery('.astra-demo-import')
|
816 |
+
.removeAttr('data-import')
|
817 |
+
.removeClass('updating-message')
|
818 |
+
.addClass('button-primary')
|
819 |
+
.text( astraSitesAdmin.strings.importDemo );
|
820 |
+
}
|
821 |
+
|
822 |
+
break;
|
823 |
+
|
824 |
+
case 'upgrade':
|
825 |
+
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
826 |
+
|
827 |
+
jQuery('.astra-demo-import')
|
828 |
+
.addClass('go-pro button-primary')
|
829 |
+
.removeClass('astra-demo-import')
|
830 |
+
.attr('target', '_blank')
|
831 |
+
.attr('href', astraSitesAdmin.getUpgradeURL + demo_slug )
|
832 |
+
.text( astraSitesAdmin.getUpgradeText )
|
833 |
+
.append('<i class="dashicons dashicons-external"></i>');
|
834 |
+
break;
|
835 |
+
|
836 |
+
default:
|
837 |
+
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
838 |
+
|
839 |
+
jQuery('.astra-demo-import')
|
840 |
+
.addClass('go-pro button-primary')
|
841 |
+
.removeClass('astra-demo-import')
|
842 |
+
.attr('target', '_blank')
|
843 |
+
.attr('href', astraSitesAdmin.getProURL )
|
844 |
+
.text( astraSitesAdmin.getProText )
|
845 |
+
.append('<i class="dashicons dashicons-external"></i>');
|
846 |
+
break;
|
847 |
+
}
|
848 |
+
|
849 |
+
},
|
850 |
+
|
851 |
+
/**
|
852 |
+
* Update Page Count.
|
853 |
+
*/
|
854 |
+
_updatedPagedCount: function() {
|
855 |
+
paged = parseInt(jQuery('body').attr('data-astra-demo-paged'));
|
856 |
+
jQuery('body').attr('data-astra-demo-paged', paged + 1);
|
857 |
+
window.setTimeout(function () {
|
858 |
+
jQuery('body').data('scrolling', false);
|
859 |
+
}, 800);
|
860 |
+
},
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Reset Page Count.
|
864 |
+
*/
|
865 |
+
_resetPagedCount: function() {
|
866 |
+
|
867 |
+
$('body').addClass('loading-content');
|
868 |
+
$('body').attr('data-astra-demo-last-request', '1');
|
869 |
+
$('body').attr('data-astra-demo-paged', '1');
|
870 |
+
$('body').attr('data-astra-demo-search', '');
|
871 |
+
$('body').attr('data-scrolling', false);
|
872 |
+
|
873 |
+
},
|
874 |
+
|
875 |
+
/**
|
876 |
+
* Remove plugin from the queue.
|
877 |
+
*/
|
878 |
+
_removePluginFromQueue: function( removeItem, pluginsList ) {
|
879 |
+
return jQuery.grep(pluginsList, function( value ) {
|
880 |
+
return value.slug != removeItem;
|
881 |
+
});
|
882 |
+
}
|
883 |
+
|
884 |
+
};
|
885 |
+
|
886 |
+
/**
|
887 |
+
* Initialize AstraSitesAdmin
|
888 |
+
*/
|
889 |
+
$(function(){
|
890 |
+
AstraSitesAdmin.init();
|
891 |
+
});
|
892 |
+
|
893 |
+
})(jQuery);
|
inc/assets/js/astra-sites-api.js
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
(function($){
|
3 |
+
|
4 |
+
AstraSitesAPI = {
|
5 |
+
|
6 |
+
_api_url : astraSitesApi.ApiURL,
|
7 |
+
|
8 |
+
/**
|
9 |
+
* API Request
|
10 |
+
*/
|
11 |
+
_api_request: function( args ) {
|
12 |
+
|
13 |
+
// Set API Request Data.
|
14 |
+
var data = {
|
15 |
+
url: AstraSitesAPI._api_url + args.slug,
|
16 |
+
cache: false,
|
17 |
+
};
|
18 |
+
|
19 |
+
// Set API Request Header.
|
20 |
+
if( astraRenderGrid.headers ) {
|
21 |
+
data.headers = astraRenderGrid.headers;
|
22 |
+
}
|
23 |
+
|
24 |
+
$.ajax( data )
|
25 |
+
.done(function( items, status, XHR ) {
|
26 |
+
|
27 |
+
if( 'success' === status && XHR.getResponseHeader('x-wp-total') ) {
|
28 |
+
|
29 |
+
var data = {
|
30 |
+
args : args,
|
31 |
+
items : items,
|
32 |
+
items_count : XHR.getResponseHeader('x-wp-total') || 0,
|
33 |
+
};
|
34 |
+
|
35 |
+
if( 'undefined' !== args.trigger && '' !== args.trigger ) {
|
36 |
+
$(document).trigger( args.trigger, [data] );
|
37 |
+
}
|
38 |
+
|
39 |
+
} else {
|
40 |
+
$(document).trigger( 'astra-sites-api-request-error' );
|
41 |
+
}
|
42 |
+
|
43 |
+
})
|
44 |
+
.fail(function( jqXHR, textStatus ) {
|
45 |
+
|
46 |
+
$(document).trigger( 'astra-sites-api-request-fail' );
|
47 |
+
|
48 |
+
})
|
49 |
+
.always(function() {
|
50 |
+
|
51 |
+
$(document).trigger( 'astra-sites-api-request-always' );
|
52 |
+
|
53 |
+
});
|
54 |
+
|
55 |
+
},
|
56 |
+
|
57 |
+
};
|
58 |
+
|
59 |
+
})(jQuery);
|
inc/assets/js/render-grid.js
ADDED
@@ -0,0 +1,502 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
AstraRender = {
|
3 |
+
|
4 |
+
_ref : null,
|
5 |
+
|
6 |
+
/**
|
7 |
+
* _api_params = {
|
8 |
+
* 'search' : '',
|
9 |
+
* 'per_page' : '',
|
10 |
+
* 'astra-site-category' : '',
|
11 |
+
* 'astra-site-page-builder' : '',
|
12 |
+
* 'page' : '',
|
13 |
+
* };
|
14 |
+
*
|
15 |
+
* E.g. per_page=<page-id>&astra-site-category=<category-ids>&astra-site-page-builder=<page-builder-ids>&page=<page>
|
16 |
+
*/
|
17 |
+
_api_params : {},
|
18 |
+
_breakpoint : 768,
|
19 |
+
|
20 |
+
init: function()
|
21 |
+
{
|
22 |
+
this._resetPagedCount();
|
23 |
+
this._bind();
|
24 |
+
this._showFilters();
|
25 |
+
},
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Binds events for the Astra Sites.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @access private
|
32 |
+
* @method _bind
|
33 |
+
*/
|
34 |
+
_bind: function()
|
35 |
+
{
|
36 |
+
$( document ).on('astra-sites-api-request-fail' , AstraRender._apiFailed );
|
37 |
+
$( document ).on('astra-api-post-loaded-on-scroll' , AstraRender._reinitGridScrolled );
|
38 |
+
$( document ).on('astra-api-post-loaded' , AstraRender._reinitGrid );
|
39 |
+
$( document ).on('astra-api-category-loaded' , AstraRender._addFilters );
|
40 |
+
$( document ).on('astra-api-all-category-loaded' , AstraRender._loadFirstGrid );
|
41 |
+
|
42 |
+
// Event's for API request.
|
43 |
+
$( document ).on('click' , '.filter-links a', AstraRender._filterClick );
|
44 |
+
$( document ).on('keyup input' , '#wp-filter-search-input', AstraRender._search );
|
45 |
+
$( document ).on('scroll' , AstraRender._scroll );
|
46 |
+
|
47 |
+
},
|
48 |
+
|
49 |
+
/**
|
50 |
+
* On Filter Clicked
|
51 |
+
*
|
52 |
+
* Prepare Before API Request:
|
53 |
+
* - Empty search input field to avoid search term on filter click.
|
54 |
+
* - Remove Inline Height
|
55 |
+
* - Added 'hide-me' class to hide the 'No more sites!' string.
|
56 |
+
* - Added 'loading-content' for body.
|
57 |
+
* - Show spinner.
|
58 |
+
*/
|
59 |
+
_filterClick: function( event ) {
|
60 |
+
|
61 |
+
event.preventDefault();
|
62 |
+
|
63 |
+
$(this).parents('.filter-links').find('a').removeClass('current');
|
64 |
+
$(this).addClass('current');
|
65 |
+
|
66 |
+
// Prepare Before Search.
|
67 |
+
$('#wp-filter-search-input').val('');
|
68 |
+
$('#astra-sites').hide().css('height', '');
|
69 |
+
$('body').addClass('loading-content');
|
70 |
+
$('#astra-sites-admin').find('.spinner').removeClass('hide-me');
|
71 |
+
|
72 |
+
// Show sites.
|
73 |
+
AstraRender._showSites();
|
74 |
+
},
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Search Site.
|
78 |
+
*
|
79 |
+
* Prepare Before API Request:
|
80 |
+
* - Remove Inline Height
|
81 |
+
* - Added 'hide-me' class to hide the 'No more sites!' string.
|
82 |
+
* - Added 'loading-content' for body.
|
83 |
+
* - Show spinner.
|
84 |
+
*/
|
85 |
+
_search: function() {
|
86 |
+
|
87 |
+
$this = jQuery('#wp-filter-search-input').val();
|
88 |
+
|
89 |
+
// Prepare Before Search.
|
90 |
+
$('#astra-sites').hide().css('height', '');
|
91 |
+
$('body').addClass('loading-content');
|
92 |
+
$('#astra-sites-admin').find('.spinner').removeClass('hide-me');
|
93 |
+
|
94 |
+
window.clearTimeout(AstraRender._ref);
|
95 |
+
AstraRender._ref = window.setTimeout(function () {
|
96 |
+
AstraRender._ref = null;
|
97 |
+
|
98 |
+
AstraRender._resetPagedCount();
|
99 |
+
jQuery('body').addClass('loading-content');
|
100 |
+
jQuery('body').attr('data-astra-demo-search', $this);
|
101 |
+
|
102 |
+
AstraRender._showSites();
|
103 |
+
|
104 |
+
}, 500);
|
105 |
+
|
106 |
+
},
|
107 |
+
|
108 |
+
/**
|
109 |
+
* On Scroll
|
110 |
+
*/
|
111 |
+
_scroll: function(event) {
|
112 |
+
|
113 |
+
if( ! $('body').hasClass('listed-all-sites') ) {
|
114 |
+
|
115 |
+
var scrollDistance = jQuery(window).scrollTop();
|
116 |
+
|
117 |
+
var themesBottom = Math.abs(jQuery(window).height() - jQuery('#astra-sites').offset().top - jQuery('#astra-sites').height());
|
118 |
+
themesBottom = themesBottom - 100;
|
119 |
+
|
120 |
+
ajaxLoading = jQuery('body').data('scrolling');
|
121 |
+
|
122 |
+
if (scrollDistance > themesBottom && ajaxLoading == false) {
|
123 |
+
AstraRender._updatedPagedCount();
|
124 |
+
|
125 |
+
if( ! $('#astra-sites .no-themes').length ) {
|
126 |
+
$('#astra-sites-admin').find('.spinner').addClass('is-active');
|
127 |
+
}
|
128 |
+
|
129 |
+
jQuery('body').data('scrolling', true);
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @see _reinitGridScrolled() which called in trigger 'astra-api-post-loaded-on-scroll'
|
133 |
+
*/
|
134 |
+
AstraRender._showSites( false, 'astra-api-post-loaded-on-scroll' );
|
135 |
+
}
|
136 |
+
}
|
137 |
+
},
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Lazy Load Images
|
141 |
+
*
|
142 |
+
* @see http://jquery.eisbehr.de/lazy/#features
|
143 |
+
*/
|
144 |
+
_lazyLoad: function() {
|
145 |
+
|
146 |
+
$('#astra-sites img').Lazy({
|
147 |
+
effect: 'fadeIn',
|
148 |
+
});
|
149 |
+
},
|
150 |
+
|
151 |
+
_apiAddParam_status: function() {
|
152 |
+
if( astraRenderGrid.sites && astraRenderGrid.sites.status ) {
|
153 |
+
AstraRender._api_params['status'] = astraRenderGrid.sites.status;
|
154 |
+
}
|
155 |
+
},
|
156 |
+
|
157 |
+
// Add 'search'
|
158 |
+
_apiAddParam_search: function() {
|
159 |
+
var search_val = jQuery('#wp-filter-search-input').val() || '';
|
160 |
+
if( '' !== search_val ) {
|
161 |
+
AstraRender._api_params['search'] = search_val;
|
162 |
+
}
|
163 |
+
},
|
164 |
+
|
165 |
+
_apiAddParam_per_page: function() {
|
166 |
+
// Add 'per_page'
|
167 |
+
var per_page_val = 3;
|
168 |
+
if( astraRenderGrid.sites && astraRenderGrid.sites["par-page"] ) {
|
169 |
+
per_page_val = parseInt( astraRenderGrid.sites["par-page"] );
|
170 |
+
}
|
171 |
+
AstraRender._api_params['per_page'] = per_page_val;
|
172 |
+
},
|
173 |
+
|
174 |
+
_apiAddParam_astra_site_category: function() {
|
175 |
+
// Add 'astra-site-category'
|
176 |
+
var selected_category_id = jQuery('.filter-links.astra-site-category').find('.current').data('group') || '';
|
177 |
+
if( '' !== selected_category_id && 'all' !== selected_category_id ) {
|
178 |
+
AstraRender._api_params['astra-site-category'] = selected_category_id;
|
179 |
+
} else if( 'astra-site-category' in astraRenderGrid.settings ) {
|
180 |
+
|
181 |
+
if( $.inArray('all', astraRenderGrid.settings['astra-site-category']) !== -1 ) {
|
182 |
+
var storedCategories = astraRenderGrid.settings['astra-site-category'];
|
183 |
+
storedCategories = jQuery.grep(storedCategories, function(value) {
|
184 |
+
return value != 'all';
|
185 |
+
});
|
186 |
+
AstraRender._api_params['astra-site-category'] = storedCategories.join(',');
|
187 |
+
}
|
188 |
+
}
|
189 |
+
},
|
190 |
+
|
191 |
+
_apiAddParam_astra_site_page_builder: function() {
|
192 |
+
// Add 'astra-site-page-builder'
|
193 |
+
var selected_page_builder_id = jQuery('.filter-links.astra-site-page-builder').find('.current').data('group') || '';
|
194 |
+
if( '' !== selected_page_builder_id && 'all' !== selected_page_builder_id ) {
|
195 |
+
AstraRender._api_params['astra-site-page-builder'] = selected_page_builder_id;
|
196 |
+
} else if( 'astra-site-page-builder' in astraRenderGrid.settings ) {
|
197 |
+
if( $.inArray('all', astraRenderGrid.settings['astra-site-page-builder']) !== -1 ) {
|
198 |
+
var storedBuilders = astraRenderGrid.settings['astra-site-page-builder'];
|
199 |
+
storedBuilders = jQuery.grep(storedBuilders, function(value) {
|
200 |
+
return value != 'all';
|
201 |
+
});
|
202 |
+
AstraRender._api_params['astra-site-page-builder'] = storedBuilders.join(',');
|
203 |
+
}
|
204 |
+
}
|
205 |
+
},
|
206 |
+
|
207 |
+
_apiAddParam_page: function() {
|
208 |
+
// Add 'page'
|
209 |
+
var page_val = parseInt(jQuery('body').attr('data-astra-demo-paged')) || 1;
|
210 |
+
AstraRender._api_params['page'] = page_val;
|
211 |
+
},
|
212 |
+
|
213 |
+
_apiAddParam_purchase_key: function() {
|
214 |
+
if( astraRenderGrid.sites && astraRenderGrid.sites.purchase_key ) {
|
215 |
+
AstraRender._api_params['purchase_key'] = astraRenderGrid.sites.purchase_key;
|
216 |
+
}
|
217 |
+
},
|
218 |
+
|
219 |
+
_apiAddParam_site_url: function() {
|
220 |
+
if( astraRenderGrid.sites && astraRenderGrid.sites.site_url ) {
|
221 |
+
AstraRender._api_params['site_url'] = astraRenderGrid.sites.site_url;
|
222 |
+
}
|
223 |
+
},
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Show Sites
|
227 |
+
*
|
228 |
+
* Params E.g. per_page=<page-id>&astra-site-category=<category-ids>&astra-site-page-builder=<page-builder-ids>&page=<page>
|
229 |
+
*
|
230 |
+
* @param {Boolean} resetPagedCount Reset Paged Count.
|
231 |
+
* @param {String} trigger Filtered Trigger.
|
232 |
+
*/
|
233 |
+
_showSites: function( resetPagedCount, trigger ) {
|
234 |
+
|
235 |
+
if( undefined === resetPagedCount ) {
|
236 |
+
resetPagedCount = true
|
237 |
+
}
|
238 |
+
|
239 |
+
if( undefined === trigger ) {
|
240 |
+
trigger = 'astra-api-post-loaded';
|
241 |
+
}
|
242 |
+
|
243 |
+
if( resetPagedCount ) {
|
244 |
+
AstraRender._resetPagedCount();
|
245 |
+
}
|
246 |
+
|
247 |
+
// Add Params for API request.
|
248 |
+
AstraRender._api_params = {};
|
249 |
+
|
250 |
+
AstraRender._apiAddParam_status();
|
251 |
+
AstraRender._apiAddParam_search();
|
252 |
+
AstraRender._apiAddParam_per_page();
|
253 |
+
AstraRender._apiAddParam_astra_site_category();
|
254 |
+
AstraRender._apiAddParam_astra_site_page_builder();
|
255 |
+
AstraRender._apiAddParam_page();
|
256 |
+
AstraRender._apiAddParam_site_url();
|
257 |
+
AstraRender._apiAddParam_purchase_key();
|
258 |
+
|
259 |
+
// API Request.
|
260 |
+
var api_post = {
|
261 |
+
slug: 'astra-sites?' + decodeURIComponent( $.param( AstraRender._api_params ) ),
|
262 |
+
trigger: trigger,
|
263 |
+
};
|
264 |
+
|
265 |
+
AstraSitesAPI._api_request( api_post );
|
266 |
+
|
267 |
+
},
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Get Category Params
|
271 |
+
*
|
272 |
+
* @param {string} category_slug Category Slug.
|
273 |
+
* @return {mixed} Add `include=<category-ids>` in API request.
|
274 |
+
*/
|
275 |
+
_getCategoryParams: function( category_slug ) {
|
276 |
+
|
277 |
+
// Has category?
|
278 |
+
if( category_slug in astraRenderGrid.settings ) {
|
279 |
+
|
280 |
+
var storedBuilders = astraRenderGrid.settings[ category_slug ];
|
281 |
+
|
282 |
+
// Remove `all` from stored list?
|
283 |
+
storedBuilders = jQuery.grep(storedBuilders, function(value) {
|
284 |
+
return value != 'all';
|
285 |
+
});
|
286 |
+
|
287 |
+
return '?include='+storedBuilders.join(',');
|
288 |
+
}
|
289 |
+
|
290 |
+
return '';
|
291 |
+
},
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Get All Select Status
|
295 |
+
*
|
296 |
+
* @param {string} category_slug Category Slug.
|
297 |
+
* @return {boolean} Return true/false.
|
298 |
+
*/
|
299 |
+
_getCategoryAllSelectStatus: function( category_slug ) {
|
300 |
+
|
301 |
+
// Has category?
|
302 |
+
if( category_slug in astraRenderGrid.settings ) {
|
303 |
+
|
304 |
+
// Has `all` in stored list?
|
305 |
+
if( $.inArray('all', astraRenderGrid.settings[ category_slug ]) === -1 ) {
|
306 |
+
return false;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
return true;
|
311 |
+
},
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Show Filters
|
315 |
+
*/
|
316 |
+
_showFilters: function() {
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Categories
|
320 |
+
*/
|
321 |
+
var category_slug = 'astra-site-page-builder';
|
322 |
+
var category = {
|
323 |
+
slug : category_slug + AstraRender._getCategoryParams( category_slug ),
|
324 |
+
id : category_slug,
|
325 |
+
class : category_slug,
|
326 |
+
trigger : 'astra-api-category-loaded',
|
327 |
+
wrapper_class : 'filter-links',
|
328 |
+
show_all : false,
|
329 |
+
};
|
330 |
+
|
331 |
+
AstraSitesAPI._api_request( category );
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Page Builder
|
335 |
+
*/
|
336 |
+
var category_slug = 'astra-site-category';
|
337 |
+
var category = {
|
338 |
+
slug : category_slug + AstraRender._getCategoryParams( category_slug ),
|
339 |
+
id : category_slug,
|
340 |
+
class : category_slug,
|
341 |
+
trigger : 'astra-api-all-category-loaded',
|
342 |
+
wrapper_class : 'filter-links',
|
343 |
+
show_all : AstraRender._getCategoryAllSelectStatus( category_slug ),
|
344 |
+
};
|
345 |
+
|
346 |
+
AstraSitesAPI._api_request( category );
|
347 |
+
},
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Load First Grid.
|
351 |
+
*
|
352 |
+
* This is triggered after all category loaded.
|
353 |
+
*
|
354 |
+
* @param {object} event Event Object.
|
355 |
+
*/
|
356 |
+
_loadFirstGrid: function( event, data ) {
|
357 |
+
AstraRender._addFilters( event, data );
|
358 |
+
setTimeout(function() {
|
359 |
+
AstraRender._showSites();
|
360 |
+
}, 100);
|
361 |
+
},
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Append filters.
|
365 |
+
*
|
366 |
+
* @param {object} event Object.
|
367 |
+
* @param {object} data API response data.
|
368 |
+
*/
|
369 |
+
_addFilters: function( event, data ) {
|
370 |
+
event.preventDefault();
|
371 |
+
|
372 |
+
if( jQuery('#' + data.args.id).length ) {
|
373 |
+
var template = wp.template('astra-site-filters');
|
374 |
+
jQuery('#' + data.args.id).html(template( data )).find('li:first a').addClass('current');
|
375 |
+
}
|
376 |
+
|
377 |
+
},
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Append sites on scroll.
|
381 |
+
*
|
382 |
+
* @param {object} event Object.
|
383 |
+
* @param {object} data API response data.
|
384 |
+
*/
|
385 |
+
_reinitGridScrolled: function( event, data ) {
|
386 |
+
|
387 |
+
var template = wp.template('astra-sites-list');
|
388 |
+
|
389 |
+
if( data.items.length > 0 ) {
|
390 |
+
|
391 |
+
$('body').removeClass( 'loading-content' );
|
392 |
+
$('.filter-count .count').text( data.items_count );
|
393 |
+
|
394 |
+
setTimeout(function() {
|
395 |
+
jQuery('#astra-sites').append(template( data ));
|
396 |
+
|
397 |
+
AstraRender._lazyLoad();
|
398 |
+
|
399 |
+
AstraRender._imagesLoaded();
|
400 |
+
}, 800);
|
401 |
+
} else {
|
402 |
+
|
403 |
+
$('body').addClass('listed-all-sites');
|
404 |
+
|
405 |
+
// $('#astra-sites-admin').find('.spinner').removeClass('is-active');
|
406 |
+
}
|
407 |
+
|
408 |
+
},
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Update Astra sites list.
|
412 |
+
*
|
413 |
+
* @param {object} event Object.
|
414 |
+
* @param {object} data API response data.
|
415 |
+
*/
|
416 |
+
_reinitGrid: function( event, data ) {
|
417 |
+
|
418 |
+
var template = wp.template('astra-sites-list');
|
419 |
+
|
420 |
+
$('body').removeClass( 'loading-content' );
|
421 |
+
$('.filter-count .count').text( data.items_count );
|
422 |
+
|
423 |
+
jQuery('body').attr('data-astra-demo-last-request', data.items_count);
|
424 |
+
|
425 |
+
jQuery('#astra-sites').show().html(template( data ));
|
426 |
+
|
427 |
+
AstraRender._lazyLoad();
|
428 |
+
|
429 |
+
AstraRender._imagesLoaded();
|
430 |
+
|
431 |
+
$('#astra-sites-admin').find('.spinner').removeClass('is-active');
|
432 |
+
|
433 |
+
if( data.items_count <= 0 ) {
|
434 |
+
$('#astra-sites-admin').find('.spinner').removeClass('is-active');
|
435 |
+
} else {
|
436 |
+
$('body').removeClass('listed-all-sites');
|
437 |
+
}
|
438 |
+
|
439 |
+
|
440 |
+
},
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Check image loaded with function `imagesLoaded()`
|
444 |
+
*/
|
445 |
+
_imagesLoaded: function() {
|
446 |
+
|
447 |
+
var self = jQuery('#sites-filter.execute-only-one-time a');
|
448 |
+
|
449 |
+
$('.astra-sites-grid').imagesLoaded()
|
450 |
+
.always( function( instance ) {
|
451 |
+
if( jQuery( window ).outerWidth() > AstraRender._breakpoint ) {
|
452 |
+
// $('#astra-sites').masonry('reload');
|
453 |
+
}
|
454 |
+
|
455 |
+
$('#astra-sites-admin').find('.spinner').removeClass('is-active');
|
456 |
+
})
|
457 |
+
.progress( function( instance, image ) {
|
458 |
+
var result = image.isLoaded ? 'loaded' : 'broken';
|
459 |
+
});
|
460 |
+
|
461 |
+
},
|
462 |
+
|
463 |
+
/**
|
464 |
+
* API Request Failed/Not found any demos.
|
465 |
+
*/
|
466 |
+
_apiFailed: function() {
|
467 |
+
$('#astra-sites-admin').find('.spinner').removeClass('is-active').addClass('hide-me');
|
468 |
+
},
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Update Page Count.
|
472 |
+
*/
|
473 |
+
_updatedPagedCount: function() {
|
474 |
+
paged = parseInt(jQuery('body').attr('data-astra-demo-paged'));
|
475 |
+
jQuery('body').attr('data-astra-demo-paged', paged + 1);
|
476 |
+
window.setTimeout(function () {
|
477 |
+
jQuery('body').data('scrolling', false);
|
478 |
+
}, 800);
|
479 |
+
},
|
480 |
+
|
481 |
+
/**
|
482 |
+
* Reset Page Count.
|
483 |
+
*/
|
484 |
+
_resetPagedCount: function() {
|
485 |
+
|
486 |
+
jQuery('body').attr('data-astra-demo-last-request', '1');
|
487 |
+
jQuery('body').attr('data-astra-demo-paged', '1');
|
488 |
+
jQuery('body').attr('data-astra-demo-search', '');
|
489 |
+
jQuery('body').attr('data-scrolling', false);
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
+
};
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Initialize AstraRender
|
497 |
+
*/
|
498 |
+
$(function(){
|
499 |
+
AstraRender.init();
|
500 |
+
});
|
501 |
+
|
502 |
+
})(jQuery);
|
inc/assets/vendor/js/jquery.lazy.js
ADDED
@@ -0,0 +1,830 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* jQuery & Zepto Lazy - v1.7.5
|
3 |
+
* http://jquery.eisbehr.de/lazy/
|
4 |
+
*
|
5 |
+
* Copyright 2012 - 2017, Daniel 'Eisbehr' Kern
|
6 |
+
*
|
7 |
+
* Dual licensed under the MIT and GPL-2.0 licenses:
|
8 |
+
* http://www.opensource.org/licenses/mit-license.php
|
9 |
+
* http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*
|
11 |
+
* $("img.lazy").lazy();
|
12 |
+
*/
|
13 |
+
|
14 |
+
;(function(window, undefined) {
|
15 |
+
"use strict";
|
16 |
+
|
17 |
+
// noinspection JSUnresolvedVariable
|
18 |
+
/**
|
19 |
+
* library instance - here and not in construct to be shorter in minimization
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
var $ = window.jQuery || window.Zepto,
|
23 |
+
|
24 |
+
/**
|
25 |
+
* unique plugin instance id counter
|
26 |
+
* @type {number}
|
27 |
+
*/
|
28 |
+
lazyInstanceId = 0,
|
29 |
+
|
30 |
+
/**
|
31 |
+
* helper to register window load for jQuery 3
|
32 |
+
* @type {boolean}
|
33 |
+
*/
|
34 |
+
windowLoaded = false;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* make lazy available to jquery - and make it a bit more case-insensitive :)
|
38 |
+
* @access public
|
39 |
+
* @type {function}
|
40 |
+
* @param {object} settings
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
$.fn.Lazy = $.fn.lazy = function(settings) {
|
44 |
+
return new LazyPlugin(this, settings);
|
45 |
+
};
|
46 |
+
|
47 |
+
/**
|
48 |
+
* helper to add plugins to lazy prototype configuration
|
49 |
+
* @access public
|
50 |
+
* @type {function}
|
51 |
+
* @param {string|Array} names
|
52 |
+
* @param {string|Array} [elements]
|
53 |
+
* @param {function} loader
|
54 |
+
* @return void
|
55 |
+
*/
|
56 |
+
$.Lazy = $.lazy = function(names, elements, loader) {
|
57 |
+
// make second parameter optional
|
58 |
+
if( $.isFunction(elements) ) {
|
59 |
+
loader = elements;
|
60 |
+
elements = [];
|
61 |
+
}
|
62 |
+
|
63 |
+
// exit here if parameter is not a callable function
|
64 |
+
if( !$.isFunction(loader) ) return;
|
65 |
+
|
66 |
+
// make parameters an array of names to be sure
|
67 |
+
names = $.isArray(names) ? names : [names];
|
68 |
+
elements = $.isArray(elements) ? elements : [elements];
|
69 |
+
|
70 |
+
var config = LazyPlugin.prototype.config,
|
71 |
+
forced = config._f || (config._f = {});
|
72 |
+
|
73 |
+
// add the loader plugin for every name
|
74 |
+
for( var i = 0, l = names.length; i < l; i++ )
|
75 |
+
if( config[names[i]] === undefined || $.isFunction(config[names[i]]) )
|
76 |
+
config[names[i]] = loader;
|
77 |
+
|
78 |
+
// add forced elements loader
|
79 |
+
for( var c = 0, a = elements.length; c < a; c++ )
|
80 |
+
forced[elements[c]] = names[0];
|
81 |
+
};
|
82 |
+
|
83 |
+
/**
|
84 |
+
* contains all logic and the whole element handling
|
85 |
+
* is packed in a private function outside class to reduce memory usage, because it will not be created on every plugin instance
|
86 |
+
* @access private
|
87 |
+
* @type {function}
|
88 |
+
* @param {LazyPlugin} instance
|
89 |
+
* @param {object} config
|
90 |
+
* @param {object|Array} items
|
91 |
+
* @param {object} events
|
92 |
+
* @param {string} namespace
|
93 |
+
* @return void
|
94 |
+
*/
|
95 |
+
function _executeLazy(instance, config, items, events, namespace) {
|
96 |
+
/**
|
97 |
+
* a helper to trigger the 'onFinishedAll' callback after all other events
|
98 |
+
* @access private
|
99 |
+
* @type {number}
|
100 |
+
*/
|
101 |
+
var _awaitingAfterLoad = 0,
|
102 |
+
|
103 |
+
/**
|
104 |
+
* visible content width
|
105 |
+
* @access private
|
106 |
+
* @type {number}
|
107 |
+
*/
|
108 |
+
_actualWidth = -1,
|
109 |
+
|
110 |
+
/**
|
111 |
+
* visible content height
|
112 |
+
* @access private
|
113 |
+
* @type {number}
|
114 |
+
*/
|
115 |
+
_actualHeight = -1,
|
116 |
+
|
117 |
+
/**
|
118 |
+
* determine possibly detected high pixel density
|
119 |
+
* @access private
|
120 |
+
* @type {boolean}
|
121 |
+
*/
|
122 |
+
_isRetinaDisplay = false,
|
123 |
+
|
124 |
+
/**
|
125 |
+
* dictionary entry for better minimization
|
126 |
+
* @access private
|
127 |
+
* @type {string}
|
128 |
+
*/
|
129 |
+
_afterLoad = "afterLoad",
|
130 |
+
|
131 |
+
/**
|
132 |
+
* dictionary entry for better minimization
|
133 |
+
* @access private
|
134 |
+
* @type {string}
|
135 |
+
*/
|
136 |
+
_load = "load",
|
137 |
+
|
138 |
+
/**
|
139 |
+
* dictionary entry for better minimization
|
140 |
+
* @access private
|
141 |
+
* @type {string}
|
142 |
+
*/
|
143 |
+
_error = "error",
|
144 |
+
|
145 |
+
/**
|
146 |
+
* dictionary entry for better minimization
|
147 |
+
* @access private
|
148 |
+
* @type {string}
|
149 |
+
*/
|
150 |
+
_img = "img",
|
151 |
+
|
152 |
+
/**
|
153 |
+
* dictionary entry for better minimization
|
154 |
+
* @access private
|
155 |
+
* @type {string}
|
156 |
+
*/
|
157 |
+
_src = "src",
|
158 |
+
|
159 |
+
/**
|
160 |
+
* dictionary entry for better minimization
|
161 |
+
* @access private
|
162 |
+
* @type {string}
|
163 |
+
*/
|
164 |
+
_srcset = "srcset",
|
165 |
+
|
166 |
+
/**
|
167 |
+
* dictionary entry for better minimization
|
168 |
+
* @access private
|
169 |
+
* @type {string}
|
170 |
+
*/
|
171 |
+
_sizes = "sizes",
|
172 |
+
|
173 |
+
/**
|
174 |
+
* dictionary entry for better minimization
|
175 |
+
* @access private
|
176 |
+
* @type {string}
|
177 |
+
*/
|
178 |
+
_backgroundImage = "background-image";
|
179 |
+
|
180 |
+
/**
|
181 |
+
* initialize plugin
|
182 |
+
* bind loading to events or set delay time to load all items at once
|
183 |
+
* @access private
|
184 |
+
* @return void
|
185 |
+
*/
|
186 |
+
function _initialize() {
|
187 |
+
// detect actual device pixel ratio
|
188 |
+
// noinspection JSUnresolvedVariable
|
189 |
+
_isRetinaDisplay = window.devicePixelRatio > 1;
|
190 |
+
|
191 |
+
// prepare all initial items
|
192 |
+
_prepareItems(items);
|
193 |
+
|
194 |
+
// if delay time is set load all items at once after delay time
|
195 |
+
if( config.delay >= 0 ) setTimeout(function() { _lazyLoadItems(true); }, config.delay);
|
196 |
+
|
197 |
+
// if no delay is set or combine usage is active bind events
|
198 |
+
if( config.delay < 0 || config.combined ) {
|
199 |
+
// create unique event function
|
200 |
+
events.e = _throttle(config.throttle, function(event) {
|
201 |
+
// reset detected window size on resize event
|
202 |
+
if( event.type === "resize" )
|
203 |
+
_actualWidth = _actualHeight = -1;
|
204 |
+
|
205 |
+
// execute 'lazy magic'
|
206 |
+
_lazyLoadItems(event.all);
|
207 |
+
});
|
208 |
+
|
209 |
+
// create function to add new items to instance
|
210 |
+
events.a = function(additionalItems) {
|
211 |
+
_prepareItems(additionalItems);
|
212 |
+
items.push.apply(items, additionalItems);
|
213 |
+
};
|
214 |
+
|
215 |
+
// create function to get all instance items left
|
216 |
+
events.g = function() {
|
217 |
+
// filter loaded items before return in case internal filter was not running until now
|
218 |
+
return (items = $(items).filter(function() {
|
219 |
+
return !$(this).data(config.loadedName);
|
220 |
+
}));
|
221 |
+
};
|
222 |
+
|
223 |
+
// create function to force loading elements
|
224 |
+
events.f = function(forcedItems) {
|
225 |
+
for( var i = 0; i < forcedItems.length; i++ ) {
|
226 |
+
// only handle item if available in current instance
|
227 |
+
// use a compare function, because Zepto can't handle object parameter for filter
|
228 |
+
// var item = items.filter(forcedItems[i]);
|
229 |
+
/* jshint loopfunc: true */
|
230 |
+
var item = items.filter(function() {
|
231 |
+
return this === forcedItems[i];
|
232 |
+
});
|
233 |
+
|
234 |
+
if( item.length ) {
|
235 |
+
_lazyLoadItems(false, item);
|
236 |
+
}
|
237 |
+
}
|
238 |
+
};
|
239 |
+
|
240 |
+
// load initial items
|
241 |
+
_lazyLoadItems();
|
242 |
+
|
243 |
+
// bind lazy load functions to scroll and resize event
|
244 |
+
// noinspection JSUnresolvedVariable
|
245 |
+
$(config.appendScroll).on("scroll." + namespace + " resize." + namespace, events.e);
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* prepare items before handle them
|
251 |
+
* @access private
|
252 |
+
* @param {Array|object|jQuery} items
|
253 |
+
* @return void
|
254 |
+
*/
|
255 |
+
function _prepareItems(items) {
|
256 |
+
// fetch used configurations before loops
|
257 |
+
var defaultImage = config.defaultImage,
|
258 |
+
placeholder = config.placeholder,
|
259 |
+
imageBase = config.imageBase,
|
260 |
+
srcsetAttribute = config.srcsetAttribute,
|
261 |
+
loaderAttribute = config.loaderAttribute,
|
262 |
+
forcedTags = config._f || {};
|
263 |
+
|
264 |
+
// filter items and only add those who not handled yet and got needed attributes available
|
265 |
+
items = $(items).filter(function() {
|
266 |
+
var element = $(this),
|
267 |
+
tag = _getElementTagName(this);
|
268 |
+
|
269 |
+
return !element.data(config.handledName) &&
|
270 |
+
(element.attr(config.attribute) || element.attr(srcsetAttribute) || element.attr(loaderAttribute) || forcedTags[tag] !== undefined);
|
271 |
+
})
|
272 |
+
|
273 |
+
// append plugin instance to all elements
|
274 |
+
.data("plugin_" + config.name, instance);
|
275 |
+
|
276 |
+
for( var i = 0, l = items.length; i < l; i++ ) {
|
277 |
+
var element = $(items[i]),
|
278 |
+
tag = _getElementTagName(items[i]),
|
279 |
+
elementImageBase = element.attr(config.imageBaseAttribute) || imageBase;
|
280 |
+
|
281 |
+
// generate and update source set if an image base is set
|
282 |
+
if( tag === _img && elementImageBase && element.attr(srcsetAttribute) )
|
283 |
+
element.attr(srcsetAttribute, _getCorrectedSrcSet(element.attr(srcsetAttribute), elementImageBase));
|
284 |
+
|
285 |
+
// add loader to forced element types
|
286 |
+
if( forcedTags[tag] !== undefined && !element.attr(loaderAttribute) )
|
287 |
+
element.attr(loaderAttribute, forcedTags[tag]);
|
288 |
+
|
289 |
+
// set default image on every element without source
|
290 |
+
if( tag === _img && defaultImage && !element.attr(_src) )
|
291 |
+
element.attr(_src, defaultImage);
|
292 |
+
|
293 |
+
// set placeholder on every element without background image
|
294 |
+
else if( tag !== _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) === "none") )
|
295 |
+
element.css(_backgroundImage, "url('" + placeholder + "')");
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* the 'lazy magic' - check all items
|
301 |
+
* @access private
|
302 |
+
* @param {boolean} [allItems]
|
303 |
+
* @param {object} [forced]
|
304 |
+
* @return void
|
305 |
+
*/
|
306 |
+
function _lazyLoadItems(allItems, forced) {
|
307 |
+
// skip if no items where left
|
308 |
+
if( !items.length ) {
|
309 |
+
// destroy instance if option is enabled
|
310 |
+
if( config.autoDestroy )
|
311 |
+
// noinspection JSUnresolvedFunction
|
312 |
+
instance.destroy();
|
313 |
+
|
314 |
+
return;
|
315 |
+
}
|
316 |
+
|
317 |
+
var elements = forced || items,
|
318 |
+
loadTriggered = false,
|
319 |
+
imageBase = config.imageBase || "",
|
320 |
+
srcsetAttribute = config.srcsetAttribute,
|
321 |
+
handledName = config.handledName;
|
322 |
+
|
323 |
+
// loop all available items
|
324 |
+
for( var i = 0; i < elements.length; i++ ) {
|
325 |
+
// item is at least in loadable area
|
326 |
+
if( allItems || forced || _isInLoadableArea(elements[i]) ) {
|
327 |
+
var element = $(elements[i]),
|
328 |
+
tag = _getElementTagName(elements[i]),
|
329 |
+
attribute = element.attr(config.attribute),
|
330 |
+
elementImageBase = element.attr(config.imageBaseAttribute) || imageBase,
|
331 |
+
customLoader = element.attr(config.loaderAttribute);
|
332 |
+
|
333 |
+
// is not already handled
|
334 |
+
if( !element.data(handledName) &&
|
335 |
+
// and is visible or visibility doesn't matter
|
336 |
+
(!config.visibleOnly || element.is(":visible")) && (
|
337 |
+
// and image source or source set attribute is available
|
338 |
+
(attribute || element.attr(srcsetAttribute)) && (
|
339 |
+
// and is image tag where attribute is not equal source or source set
|
340 |
+
(tag === _img && (elementImageBase + attribute !== element.attr(_src) || element.attr(srcsetAttribute) !== element.attr(_srcset))) ||
|
341 |
+
// or is non image tag where attribute is not equal background
|
342 |
+
(tag !== _img && elementImageBase + attribute !== element.css(_backgroundImage))
|
343 |
+
) ||
|
344 |
+
// or custom loader is available
|
345 |
+
customLoader ))
|
346 |
+
{
|
347 |
+
// mark element always as handled as this point to prevent double handling
|
348 |
+
loadTriggered = true;
|
349 |
+
element.data(handledName, true);
|
350 |
+
|
351 |
+
// load item
|
352 |
+
_handleItem(element, tag, elementImageBase, customLoader);
|
353 |
+
}
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
// when something was loaded remove them from remaining items
|
358 |
+
if( loadTriggered )
|
359 |
+
items = $(items).filter(function() {
|
360 |
+
return !$(this).data(handledName);
|
361 |
+
});
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* load the given element the lazy way
|
366 |
+
* @access private
|
367 |
+
* @param {object} element
|
368 |
+
* @param {string} tag
|
369 |
+
* @param {string} imageBase
|
370 |
+
* @param {function} [customLoader]
|
371 |
+
* @return void
|
372 |
+
*/
|
373 |
+
function _handleItem(element, tag, imageBase, customLoader) {
|
374 |
+
// increment count of items waiting for after load
|
375 |
+
++_awaitingAfterLoad;
|
376 |
+
|
377 |
+
// extended error callback for correct 'onFinishedAll' handling
|
378 |
+
var errorCallback = function() {
|
379 |
+
_triggerCallback("onError", element);
|
380 |
+
_reduceAwaiting();
|
381 |
+
|
382 |
+
// prevent further callback calls
|
383 |
+
errorCallback = $.noop;
|
384 |
+
};
|
385 |
+
|
386 |
+
// trigger function before loading image
|
387 |
+
_triggerCallback("beforeLoad", element);
|
388 |
+
|
389 |
+
// fetch all double used data here for better code minimization
|
390 |
+
var srcAttribute = config.attribute,
|
391 |
+
srcsetAttribute = config.srcsetAttribute,
|
392 |
+
sizesAttribute = config.sizesAttribute,
|
393 |
+
retinaAttribute = config.retinaAttribute,
|
394 |
+
removeAttribute = config.removeAttribute,
|
395 |
+
loadedName = config.loadedName,
|
396 |
+
elementRetina = element.attr(retinaAttribute);
|
397 |
+
|
398 |
+
// handle custom loader
|
399 |
+
if( customLoader ) {
|
400 |
+
// on load callback
|
401 |
+
var loadCallback = function() {
|
402 |
+
// remove attribute from element
|
403 |
+
if( removeAttribute )
|
404 |
+
element.removeAttr(config.loaderAttribute);
|
405 |
+
|
406 |
+
// mark element as loaded
|
407 |
+
element.data(loadedName, true);
|
408 |
+
|
409 |
+
// call after load event
|
410 |
+
_triggerCallback(_afterLoad, element);
|
411 |
+
|
412 |
+
// remove item from waiting queue and possibly trigger finished event
|
413 |
+
// it's needed to be asynchronous to run after filter was in _lazyLoadItems
|
414 |
+
setTimeout(_reduceAwaiting, 1);
|
415 |
+
|
416 |
+
// prevent further callback calls
|
417 |
+
loadCallback = $.noop;
|
418 |
+
};
|
419 |
+
|
420 |
+
// bind error event to trigger callback and reduce waiting amount
|
421 |
+
element.off(_error).one(_error, errorCallback)
|
422 |
+
|
423 |
+
// bind after load callback to element
|
424 |
+
.one(_load, loadCallback);
|
425 |
+
|
426 |
+
// trigger custom loader and handle response
|
427 |
+
if( !_triggerCallback(customLoader, element, function(response) {
|
428 |
+
if( response ) {
|
429 |
+
element.off(_load);
|
430 |
+
loadCallback();
|
431 |
+
}
|
432 |
+
else {
|
433 |
+
element.off(_error);
|
434 |
+
errorCallback();
|
435 |
+
}
|
436 |
+
})) element.trigger(_error);
|
437 |
+
}
|
438 |
+
|
439 |
+
// handle images
|
440 |
+
else {
|
441 |
+
// create image object
|
442 |
+
var imageObj = $(new Image());
|
443 |
+
|
444 |
+
// bind error event to trigger callback and reduce waiting amount
|
445 |
+
imageObj.one(_error, errorCallback)
|
446 |
+
|
447 |
+
// bind after load callback to image
|
448 |
+
.one(_load, function() {
|
449 |
+
// remove element from view
|
450 |
+
element.hide();
|
451 |
+
|
452 |
+
// set image back to element
|
453 |
+
// do it as single 'attr' calls, to be sure 'src' is set after 'srcset'
|
454 |
+
if( tag === _img )
|
455 |
+
element.attr(_sizes, imageObj.attr(_sizes))
|
456 |
+
.attr(_srcset, imageObj.attr(_srcset))
|
457 |
+
.attr(_src, imageObj.attr(_src));
|
458 |
+
else
|
459 |
+
element.css(_backgroundImage, "url('" + imageObj.attr(_src) + "')");
|
460 |
+
|
461 |
+
// bring it back with some effect!
|
462 |
+
element[config.effect](config.effectTime);
|
463 |
+
|
464 |
+
// remove attribute from element
|
465 |
+
if( removeAttribute ) {
|
466 |
+
element.removeAttr(srcAttribute + " " + srcsetAttribute + " " + retinaAttribute + " " + config.imageBaseAttribute);
|
467 |
+
|
468 |
+
// only remove 'sizes' attribute, if it was a custom one
|
469 |
+
if( sizesAttribute !== _sizes )
|
470 |
+
element.removeAttr(sizesAttribute);
|
471 |
+
}
|
472 |
+
|
473 |
+
// mark element as loaded
|
474 |
+
element.data(loadedName, true);
|
475 |
+
|
476 |
+
// call after load event
|
477 |
+
_triggerCallback(_afterLoad, element);
|
478 |
+
|
479 |
+
// cleanup image object
|
480 |
+
imageObj.remove();
|
481 |
+
|
482 |
+
// remove item from waiting queue and possibly trigger finished event
|
483 |
+
_reduceAwaiting();
|
484 |
+
});
|
485 |
+
|
486 |
+
// set sources
|
487 |
+
// do it as single 'attr' calls, to be sure 'src' is set after 'srcset'
|
488 |
+
var imageSrc = (_isRetinaDisplay && elementRetina ? elementRetina : element.attr(srcAttribute)) || "";
|
489 |
+
imageObj.attr(_sizes, element.attr(sizesAttribute))
|
490 |
+
.attr(_srcset, element.attr(srcsetAttribute))
|
491 |
+
.attr(_src, imageSrc ? imageBase + imageSrc : null);
|
492 |
+
|
493 |
+
// call after load even on cached image
|
494 |
+
imageObj.complete && imageObj.trigger(_load); // jshint ignore : line
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
* check if the given element is inside the current viewport or threshold
|
500 |
+
* @access private
|
501 |
+
* @param {object} element
|
502 |
+
* @return {boolean}
|
503 |
+
*/
|
504 |
+
function _isInLoadableArea(element) {
|
505 |
+
var elementBound = element.getBoundingClientRect(),
|
506 |
+
direction = config.scrollDirection,
|
507 |
+
threshold = config.threshold,
|
508 |
+
vertical = // check if element is in loadable area from top
|
509 |
+
((_getActualHeight() + threshold) > elementBound.top) &&
|
510 |
+
// check if element is even in loadable are from bottom
|
511 |
+
(-threshold < elementBound.bottom),
|
512 |
+
horizontal = // check if element is in loadable area from left
|
513 |
+
((_getActualWidth() + threshold) > elementBound.left) &&
|
514 |
+
// check if element is even in loadable area from right
|
515 |
+
(-threshold < elementBound.right);
|
516 |
+
|
517 |
+
if( direction === "vertical" ) return vertical;
|
518 |
+
else if( direction === "horizontal" ) return horizontal;
|
519 |
+
|
520 |
+
return vertical && horizontal;
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* receive the current viewed width of the browser
|
525 |
+
* @access private
|
526 |
+
* @return {number}
|
527 |
+
*/
|
528 |
+
function _getActualWidth() {
|
529 |
+
return _actualWidth >= 0 ? _actualWidth : (_actualWidth = $(window).width());
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* receive the current viewed height of the browser
|
534 |
+
* @access private
|
535 |
+
* @return {number}
|
536 |
+
*/
|
537 |
+
function _getActualHeight() {
|
538 |
+
return _actualHeight >= 0 ? _actualHeight : (_actualHeight = $(window).height());
|
539 |
+
}
|
540 |
+
|
541 |
+
/**
|
542 |
+
* get lowercase tag name of an element
|
543 |
+
* @access private
|
544 |
+
* @param {object} element
|
545 |
+
* @returns {string}
|
546 |
+
*/
|
547 |
+
function _getElementTagName(element) {
|
548 |
+
return element.tagName.toLowerCase();
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* prepend image base to all srcset entries
|
553 |
+
* @access private
|
554 |
+
* @param {string} srcset
|
555 |
+
* @param {string} imageBase
|
556 |
+
* @returns {string}
|
557 |
+
*/
|
558 |
+
function _getCorrectedSrcSet(srcset, imageBase) {
|
559 |
+
if( imageBase ) {
|
560 |
+
// trim, remove unnecessary spaces and split entries
|
561 |
+
var entries = srcset.split(",");
|
562 |
+
srcset = "";
|
563 |
+
|
564 |
+
for( var i = 0, l = entries.length; i < l; i++ )
|
565 |
+
srcset += imageBase + entries[i].trim() + (i !== l - 1 ? "," : "");
|
566 |
+
}
|
567 |
+
|
568 |
+
return srcset;
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* helper function to throttle down event triggering
|
573 |
+
* @access private
|
574 |
+
* @param {number} delay
|
575 |
+
* @param {function} callback
|
576 |
+
* @return {function}
|
577 |
+
*/
|
578 |
+
function _throttle(delay, callback) {
|
579 |
+
var timeout,
|
580 |
+
lastExecute = 0;
|
581 |
+
|
582 |
+
return function(event, ignoreThrottle) {
|
583 |
+
var elapsed = +new Date() - lastExecute;
|
584 |
+
|
585 |
+
function run() {
|
586 |
+
lastExecute = +new Date();
|
587 |
+
callback.call(instance, event);
|
588 |
+
}
|
589 |
+
|
590 |
+
timeout && clearTimeout(timeout); // jshint ignore : line
|
591 |
+
|
592 |
+
if( elapsed > delay || !config.enableThrottle || ignoreThrottle ) run();
|
593 |
+
else timeout = setTimeout(run, delay - elapsed);
|
594 |
+
};
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
* reduce count of awaiting elements to 'afterLoad' event and fire 'onFinishedAll' if reached zero
|
599 |
+
* @access private
|
600 |
+
* @return void
|
601 |
+
*/
|
602 |
+
function _reduceAwaiting() {
|
603 |
+
--_awaitingAfterLoad;
|
604 |
+
|
605 |
+
// if no items were left trigger finished event
|
606 |
+
if( !items.length && !_awaitingAfterLoad ) _triggerCallback("onFinishedAll");
|
607 |
+
}
|
608 |
+
|
609 |
+
/**
|
610 |
+
* single implementation to handle callbacks, pass element and set 'this' to current instance
|
611 |
+
* @access private
|
612 |
+
* @param {string|function} callback
|
613 |
+
* @param {object} [element]
|
614 |
+
* @param {*} [args]
|
615 |
+
* @return {boolean}
|
616 |
+
*/
|
617 |
+
function _triggerCallback(callback, element, args) {
|
618 |
+
if( (callback = config[callback]) ) {
|
619 |
+
// jQuery's internal '$(arguments).slice(1)' are causing problems at least on old iPads
|
620 |
+
// below is shorthand of 'Array.prototype.slice.call(arguments, 1)'
|
621 |
+
callback.apply(instance, [].slice.call(arguments, 1));
|
622 |
+
return true;
|
623 |
+
}
|
624 |
+
|
625 |
+
return false;
|
626 |
+
}
|
627 |
+
|
628 |
+
// if event driven or window is already loaded don't wait for page loading
|
629 |
+
if( config.bind === "event" || windowLoaded )
|
630 |
+
_initialize();
|
631 |
+
|
632 |
+
// otherwise load initial items and start lazy after page load
|
633 |
+
else // noinspection JSUnresolvedVariable
|
634 |
+
$(window).on(_load + "." + namespace, _initialize);
|
635 |
+
}
|
636 |
+
|
637 |
+
/**
|
638 |
+
* lazy plugin class constructor
|
639 |
+
* @constructor
|
640 |
+
* @access private
|
641 |
+
* @param {object} elements
|
642 |
+
* @param {object} settings
|
643 |
+
* @return {object|LazyPlugin}
|
644 |
+
*/
|
645 |
+
function LazyPlugin(elements, settings) {
|
646 |
+
/**
|
647 |
+
* this lazy plugin instance
|
648 |
+
* @access private
|
649 |
+
* @type {object|LazyPlugin|LazyPlugin.prototype}
|
650 |
+
*/
|
651 |
+
var _instance = this,
|
652 |
+
|
653 |
+
/**
|
654 |
+
* this lazy plugin instance configuration
|
655 |
+
* @access private
|
656 |
+
* @type {object}
|
657 |
+
*/
|
658 |
+
_config = $.extend({}, _instance.config, settings),
|
659 |
+
|
660 |
+
/**
|
661 |
+
* instance generated event executed on container scroll or resize
|
662 |
+
* packed in an object to be referenceable and short named because properties will not be minified
|
663 |
+
* @access private
|
664 |
+
* @type {object}
|
665 |
+
*/
|
666 |
+
_events = {},
|
667 |
+
|
668 |
+
/**
|
669 |
+
* unique namespace for instance related events
|
670 |
+
* @access private
|
671 |
+
* @type {string}
|
672 |
+
*/
|
673 |
+
_namespace = _config.name + "-" + (++lazyInstanceId);
|
674 |
+
|
675 |
+
// noinspection JSUndefinedPropertyAssignment
|
676 |
+
/**
|
677 |
+
* wrapper to get or set an entry from plugin instance configuration
|
678 |
+
* much smaller on minify as direct access
|
679 |
+
* @access public
|
680 |
+
* @type {function}
|
681 |
+
* @param {string} entryName
|
682 |
+
* @param {*} [value]
|
683 |
+
* @return {LazyPlugin|*}
|
684 |
+
*/
|
685 |
+
_instance.config = function(entryName, value) {
|
686 |
+
if( value === undefined )
|
687 |
+
return _config[entryName];
|
688 |
+
|
689 |
+
_config[entryName] = value;
|
690 |
+
return _instance;
|
691 |
+
};
|
692 |
+
|
693 |
+
// noinspection JSUndefinedPropertyAssignment
|
694 |
+
/**
|
695 |
+
* add additional items to current instance
|
696 |
+
* @access public
|
697 |
+
* @param {Array|object|string} items
|
698 |
+
* @return {LazyPlugin}
|
699 |
+
*/
|
700 |
+
_instance.addItems = function(items) {
|
701 |
+
_events.a && _events.a($.type(items) === "string" ? $(items) : items); // jshint ignore : line
|
702 |
+
return _instance;
|
703 |
+
};
|
704 |
+
|
705 |
+
// noinspection JSUndefinedPropertyAssignment
|
706 |
+
/**
|
707 |
+
* get all left items of this instance
|
708 |
+
* @access public
|
709 |
+
* @returns {object}
|
710 |
+
*/
|
711 |
+
_instance.getItems = function() {
|
712 |
+
return _events.g ? _events.g() : {};
|
713 |
+
};
|
714 |
+
|
715 |
+
// noinspection JSUndefinedPropertyAssignment
|
716 |
+
/**
|
717 |
+
* force lazy to load all items in loadable area right now
|
718 |
+
* by default without throttle
|
719 |
+
* @access public
|
720 |
+
* @type {function}
|
721 |
+
* @param {boolean} [useThrottle]
|
722 |
+
* @return {LazyPlugin}
|
723 |
+
*/
|
724 |
+
_instance.update = function(useThrottle) {
|
725 |
+
_events.e && _events.e({}, !useThrottle); // jshint ignore : line
|
726 |
+
return _instance;
|
727 |
+
};
|
728 |
+
|
729 |
+
// noinspection JSUndefinedPropertyAssignment
|
730 |
+
/**
|
731 |
+
* force element(s) to load directly, ignoring the viewport
|
732 |
+
* @access public
|
733 |
+
* @param {Array|object|string} items
|
734 |
+
* @return {LazyPlugin}
|
735 |
+
*/
|
736 |
+
_instance.force = function(items) {
|
737 |
+
_events.f && _events.f($.type(items) === "string" ? $(items) : items); // jshint ignore : line
|
738 |
+
return _instance;
|
739 |
+
};
|
740 |
+
|
741 |
+
// noinspection JSUndefinedPropertyAssignment
|
742 |
+
/**
|
743 |
+
* force lazy to load all available items right now
|
744 |
+
* this call ignores throttling
|
745 |
+
* @access public
|
746 |
+
* @type {function}
|
747 |
+
* @return {LazyPlugin}
|
748 |
+
*/
|
749 |
+
_instance.loadAll = function() {
|
750 |
+
_events.e && _events.e({all: true}, true); // jshint ignore : line
|
751 |
+
return _instance;
|
752 |
+
};
|
753 |
+
|
754 |
+
// noinspection JSUndefinedPropertyAssignment
|
755 |
+
/**
|
756 |
+
* destroy this plugin instance
|
757 |
+
* @access public
|
758 |
+
* @type {function}
|
759 |
+
* @return undefined
|
760 |
+
*/
|
761 |
+
_instance.destroy = function() {
|
762 |
+
// unbind instance generated events
|
763 |
+
// noinspection JSUnresolvedFunction, JSUnresolvedVariable
|
764 |
+
$(_config.appendScroll).off("." + _namespace, _events.e);
|
765 |
+
// noinspection JSUnresolvedVariable
|
766 |
+
$(window).off("." + _namespace);
|
767 |
+
|
768 |
+
// clear events
|
769 |
+
_events = {};
|
770 |
+
|
771 |
+
return undefined;
|
772 |
+
};
|
773 |
+
|
774 |
+
// start using lazy and return all elements to be chainable or instance for further use
|
775 |
+
// noinspection JSUnresolvedVariable
|
776 |
+
_executeLazy(_instance, _config, elements, _events, _namespace);
|
777 |
+
return _config.chainable ? elements : _instance;
|
778 |
+
}
|
779 |
+
|
780 |
+
/**
|
781 |
+
* settings and configuration data
|
782 |
+
* @access public
|
783 |
+
* @type {object}
|
784 |
+
*/
|
785 |
+
LazyPlugin.prototype.config = {
|
786 |
+
// general
|
787 |
+
name : "lazy",
|
788 |
+
chainable : true,
|
789 |
+
autoDestroy : true,
|
790 |
+
bind : "load",
|
791 |
+
threshold : 500,
|
792 |
+
visibleOnly : false,
|
793 |
+
appendScroll : window,
|
794 |
+
scrollDirection : "both",
|
795 |
+
imageBase : null,
|
796 |
+
defaultImage : "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
|
797 |
+
placeholder : null,
|
798 |
+
delay : -1,
|
799 |
+
combined : false,
|
800 |
+
|
801 |
+
// attributes
|
802 |
+
attribute : "data-src",
|
803 |
+
srcsetAttribute : "data-srcset",
|
804 |
+
sizesAttribute : "data-sizes",
|
805 |
+
retinaAttribute : "data-retina",
|
806 |
+
loaderAttribute : "data-loader",
|
807 |
+
imageBaseAttribute : "data-imagebase",
|
808 |
+
removeAttribute : true,
|
809 |
+
handledName : "handled",
|
810 |
+
loadedName : "loaded",
|
811 |
+
|
812 |
+
// effect
|
813 |
+
effect : "show",
|
814 |
+
effectTime : 0,
|
815 |
+
|
816 |
+
// throttle
|
817 |
+
enableThrottle : true,
|
818 |
+
throttle : 250,
|
819 |
+
|
820 |
+
// callbacks
|
821 |
+
beforeLoad : undefined,
|
822 |
+
afterLoad : undefined,
|
823 |
+
onError : undefined,
|
824 |
+
onFinishedAll : undefined
|
825 |
+
};
|
826 |
+
|
827 |
+
// register window load event globally to prevent not loading elements
|
828 |
+
// since jQuery 3.X ready state is fully async and may be executed after 'load'
|
829 |
+
$(window).on("load", function() { windowLoaded = true; });
|
830 |
+
})(window);
|
inc/assets/vendor/js/jquery.lazy.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! jQuery & Zepto Lazy v1.7.5 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */
|
2 |
+
!function(t,e){"use strict";function r(r,a,i,l,u){function f(){L=t.devicePixelRatio>1,c(i),a.delay>=0&&setTimeout(function(){s(!0)},a.delay),(a.delay<0||a.combined)&&(l.e=v(a.throttle,function(t){"resize"===t.type&&(w=B=-1),s(t.all)}),l.a=function(t){c(t),i.push.apply(i,t)},l.g=function(){return i=n(i).filter(function(){return!n(this).data(a.loadedName)})},l.f=function(t){for(var e=0;e<t.length;e++){var r=i.filter(function(){return this===t[e]});r.length&&s(!1,r)}},s(),n(a.appendScroll).on("scroll."+u+" resize."+u,l.e))}function c(t){var i=a.defaultImage,o=a.placeholder,l=a.imageBase,u=a.srcsetAttribute,f=a.loaderAttribute,c=a._f||{};t=n(t).filter(function(){var t=n(this),r=m(this);return!t.data(a.handledName)&&(t.attr(a.attribute)||t.attr(u)||t.attr(f)||c[r]!==e)}).data("plugin_"+a.name,r);for(var s=0,d=t.length;s<d;s++){var A=n(t[s]),g=m(t[s]),h=A.attr(a.imageBaseAttribute)||l;g===N&&h&&A.attr(u)&&A.attr(u,b(A.attr(u),h)),c[g]===e||A.attr(f)||A.attr(f,c[g]),g===N&&i&&!A.attr(E)?A.attr(E,i):g===N||!o||A.css(O)&&"none"!==A.css(O)||A.css(O,"url('"+o+"')")}}function s(t,e){if(!i.length)return void(a.autoDestroy&&r.destroy());for(var o=e||i,l=!1,u=a.imageBase||"",f=a.srcsetAttribute,c=a.handledName,s=0;s<o.length;s++)if(t||e||A(o[s])){var g=n(o[s]),h=m(o[s]),b=g.attr(a.attribute),v=g.attr(a.imageBaseAttribute)||u,p=g.attr(a.loaderAttribute);g.data(c)||a.visibleOnly&&!g.is(":visible")||!((b||g.attr(f))&&(h===N&&(v+b!==g.attr(E)||g.attr(f)!==g.attr(F))||h!==N&&v+b!==g.css(O))||p)||(l=!0,g.data(c,!0),d(g,h,v,p))}l&&(i=n(i).filter(function(){return!n(this).data(c)}))}function d(t,e,r,i){++z;var o=function(){y("onError",t),p(),o=n.noop};y("beforeLoad",t);var l=a.attribute,u=a.srcsetAttribute,f=a.sizesAttribute,c=a.retinaAttribute,s=a.removeAttribute,d=a.loadedName,A=t.attr(c);if(i){var g=function(){s&&t.removeAttr(a.loaderAttribute),t.data(d,!0),y(T,t),setTimeout(p,1),g=n.noop};t.off(I).one(I,o).one(D,g),y(i,t,function(e){e?(t.off(D),g()):(t.off(I),o())})||t.trigger(I)}else{var h=n(new Image);h.one(I,o).one(D,function(){t.hide(),e===N?t.attr(C,h.attr(C)).attr(F,h.attr(F)).attr(E,h.attr(E)):t.css(O,"url('"+h.attr(E)+"')"),t[a.effect](a.effectTime),s&&(t.removeAttr(l+" "+u+" "+c+" "+a.imageBaseAttribute),f!==C&&t.removeAttr(f)),t.data(d,!0),y(T,t),h.remove(),p()});var m=(L&&A?A:t.attr(l))||"";h.attr(C,t.attr(f)).attr(F,t.attr(u)).attr(E,m?r+m:null),h.complete&&h.trigger(D)}}function A(t){var e=t.getBoundingClientRect(),r=a.scrollDirection,n=a.threshold,i=h()+n>e.top&&-n<e.bottom,o=g()+n>e.left&&-n<e.right;return"vertical"===r?i:"horizontal"===r?o:i&&o}function g(){return w>=0?w:w=n(t).width()}function h(){return B>=0?B:B=n(t).height()}function m(t){return t.tagName.toLowerCase()}function b(t,e){if(e){var r=t.split(",");t="";for(var a=0,n=r.length;a<n;a++)t+=e+r[a].trim()+(a!==n-1?",":"")}return t}function v(t,e){var n,i=0;return function(o,l){function u(){i=+new Date,e.call(r,o)}var f=+new Date-i;n&&clearTimeout(n),f>t||!a.enableThrottle||l?u():n=setTimeout(u,t-f)}}function p(){--z,i.length||z||y("onFinishedAll")}function y(t,e,n){return!!(t=a[t])&&(t.apply(r,[].slice.call(arguments,1)),!0)}var z=0,w=-1,B=-1,L=!1,T="afterLoad",D="load",I="error",N="img",E="src",F="srcset",C="sizes",O="background-image";"event"===a.bind||o?f():n(t).on(D+"."+u,f)}function a(a,o){var l=this,u=n.extend({},l.config,o),f={},c=u.name+"-"+ ++i;return l.config=function(t,r){return r===e?u[t]:(u[t]=r,l)},l.addItems=function(t){return f.a&&f.a("string"===n.type(t)?n(t):t),l},l.getItems=function(){return f.g?f.g():{}},l.update=function(t){return f.e&&f.e({},!t),l},l.force=function(t){return f.f&&f.f("string"===n.type(t)?n(t):t),l},l.loadAll=function(){return f.e&&f.e({all:!0},!0),l},l.destroy=function(){return n(u.appendScroll).off("."+c,f.e),n(t).off("."+c),f={},e},r(l,u,a,f,c),u.chainable?a:l}var n=t.jQuery||t.Zepto,i=0,o=!1;n.fn.Lazy=n.fn.lazy=function(t){return new a(this,t)},n.Lazy=n.lazy=function(t,r,i){if(n.isFunction(r)&&(i=r,r=[]),n.isFunction(i)){t=n.isArray(t)?t:[t],r=n.isArray(r)?r:[r];for(var o=a.prototype.config,l=o._f||(o._f={}),u=0,f=t.length;u<f;u++)(o[t[u]]===e||n.isFunction(o[t[u]]))&&(o[t[u]]=i);for(var c=0,s=r.length;c<s;c++)l[r[c]]=t[0]}},a.prototype.config={name:"lazy",chainable:!0,autoDestroy:!0,bind:"load",threshold:500,visibleOnly:!1,appendScroll:t,scrollDirection:"both",imageBase:null,defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:!1,attribute:"data-src",srcsetAttribute:"data-srcset",sizesAttribute:"data-sizes",retinaAttribute:"data-retina",loaderAttribute:"data-loader",imageBaseAttribute:"data-imagebase",removeAttribute:!0,handledName:"handled",loadedName:"loaded",effect:"show",effectTime:0,enableThrottle:!0,throttle:250,beforeLoad:e,afterLoad:e,onError:e,onFinishedAll:e},n(t).on("load",function(){o=!0})}(window);
|
inc/classes/class-astra-sites-importer.php
ADDED
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Astra Sites Importer
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package Astra Sites
|
7 |
+
*/
|
8 |
+
|
9 |
+
defined( 'ABSPATH' ) or exit;
|
10 |
+
|
11 |
+
if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Astra Sites Importer
|
15 |
+
*/
|
16 |
+
class Astra_Sites_Importer {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @var (Object) Class object
|
23 |
+
*/
|
24 |
+
private static $_instance = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set Instance
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
*
|
31 |
+
* @return object Class object.
|
32 |
+
*/
|
33 |
+
public static function set_instance() {
|
34 |
+
if ( ! isset( self::$_instance ) ) {
|
35 |
+
self::$_instance = new self;
|
36 |
+
}
|
37 |
+
|
38 |
+
return self::$_instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor.
|
43 |
+
*
|
44 |
+
* @since 1.0.0
|
45 |
+
*/
|
46 |
+
private function __construct() {
|
47 |
+
|
48 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-sites-helper.php';
|
49 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/class-widgets-importer.php';
|
50 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-customizer-import.php';
|
51 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-astra-wxr-importer.php';
|
52 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-site-options-import.php';
|
53 |
+
|
54 |
+
add_action( 'wp_ajax_astra-import-demo', array( $this, 'demo_ajax_import' ) );
|
55 |
+
add_action( 'astra_sites_image_import_complete', array( $this, 'clear_cache' ) );
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Ajax callback for demo import action.
|
61 |
+
*
|
62 |
+
* @since 1.0.0
|
63 |
+
*/
|
64 |
+
public function demo_ajax_import() {
|
65 |
+
|
66 |
+
$report = array(
|
67 |
+
'success' => false,
|
68 |
+
'message' => '',
|
69 |
+
);
|
70 |
+
|
71 |
+
if ( ! current_user_can( 'customize' ) ) {
|
72 |
+
$report['message'] = __( 'You have not "customize" access to import the astra site.', 'astra-sites' );
|
73 |
+
wp_send_json( $report );
|
74 |
+
}
|
75 |
+
|
76 |
+
$demo_api_uri = isset( $_POST['api_url'] ) ? esc_url( $_POST['api_url'] ) : '';
|
77 |
+
$this->import_demo( $demo_api_uri );
|
78 |
+
|
79 |
+
$report['success'] = true;
|
80 |
+
$report['message'] = __( 'Demo Imported Successfully.', 'astra-sites' );
|
81 |
+
wp_send_json( $report );
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Import the demo.
|
88 |
+
*
|
89 |
+
* @since 1.0.0
|
90 |
+
*
|
91 |
+
* @param (String) $demo_api_uri API URL for the single demo.
|
92 |
+
*/
|
93 |
+
public function import_demo( $demo_api_uri ) {
|
94 |
+
|
95 |
+
$demo_data = self::get_astra_single_demo( $demo_api_uri );
|
96 |
+
|
97 |
+
// Import Enabled Extensions.
|
98 |
+
$this->import_astra_enabled_extension( $demo_data['astra-enabled-extensions'] );
|
99 |
+
|
100 |
+
// Import Customizer Settings.
|
101 |
+
$this->import_customizer_settings( $demo_data['astra-site-customizer-data'] );
|
102 |
+
|
103 |
+
// Import XML.
|
104 |
+
$this->import_wxr( $demo_data['astra-site-wxr-path'] );
|
105 |
+
|
106 |
+
// Import WordPress site options.
|
107 |
+
$this->import_site_options( $demo_data['astra-site-options-data'] );
|
108 |
+
|
109 |
+
// Import Custom 404 extension options.
|
110 |
+
$this->import_custom_404_extension_options( $demo_data['astra-custom-404'] );
|
111 |
+
|
112 |
+
// Import Widgets data.
|
113 |
+
$this->import_widgets( $demo_data['astra-site-widgets-data'] );
|
114 |
+
|
115 |
+
// Clear Cache.
|
116 |
+
$this->clear_cache();
|
117 |
+
|
118 |
+
do_action( 'astra_sites_import_complete', $demo_data );
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Import widgets and assign to correct sidebars.
|
123 |
+
*
|
124 |
+
* @since 1.0.0
|
125 |
+
*
|
126 |
+
* @param (Object) $data Widgets data.
|
127 |
+
*/
|
128 |
+
private function import_widgets( $data ) {
|
129 |
+
|
130 |
+
// bail if widgets data is not available.
|
131 |
+
if ( null == $data ) {
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
$widgets_importer = Astra_Widget_Importer::instance();
|
136 |
+
$widgets_importer->import_widgets_data( $data );
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Import custom 404 section.
|
141 |
+
*
|
142 |
+
* @since 1.0.0
|
143 |
+
*
|
144 |
+
* @param (Array) $options_404 404 Extensions settings from the demo.
|
145 |
+
*/
|
146 |
+
private function import_custom_404_extension_options( $options_404 ) {
|
147 |
+
if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
|
148 |
+
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_custom_404', $options_404 );
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Import site options - Front Page, Menus, Blog page etc.
|
154 |
+
*
|
155 |
+
* @since 1.0.0
|
156 |
+
*
|
157 |
+
* @param (Array) $options Array of required site options from the demo.
|
158 |
+
*/
|
159 |
+
private function import_site_options( $options ) {
|
160 |
+
$options_importer = Astra_Site_Options_Import::instance();
|
161 |
+
$options_importer->import_options( $options );
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Download and import the XML from the demo.
|
166 |
+
*
|
167 |
+
* @since 1.0.0
|
168 |
+
*
|
169 |
+
* @param (String) $wxr_url URL of the xml export of the demo to be imported.
|
170 |
+
*/
|
171 |
+
private function import_wxr( $wxr_url ) {
|
172 |
+
$wxr_importer = Astra_WXR_Importer::instance();
|
173 |
+
$xml_path = $wxr_importer->download_xml( $wxr_url );
|
174 |
+
$wxr_importer->import_xml( $xml_path['file'] );
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Import Customizer data.
|
179 |
+
*
|
180 |
+
* @since 1.0.0
|
181 |
+
*
|
182 |
+
* @param (Array) $customizer_data Customizer data for the demo to be imported.
|
183 |
+
*/
|
184 |
+
private function import_customizer_settings( $customizer_data ) {
|
185 |
+
$customizer_import = Astra_Customizer_Import::instance();
|
186 |
+
$customizer_data = $customizer_import->import( $customizer_data );
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Import settings enabled astra extensions from the demo.
|
191 |
+
*
|
192 |
+
* @since 1.0.0
|
193 |
+
*
|
194 |
+
* @param (Array) $saved_extensions Array of enabled extensions.
|
195 |
+
*/
|
196 |
+
private function import_astra_enabled_extension( $saved_extensions ) {
|
197 |
+
if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
|
198 |
+
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $saved_extensions );
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Get single demo.
|
204 |
+
*
|
205 |
+
* @since 1.0.0
|
206 |
+
*
|
207 |
+
* @param (String) $demo_api_uri API URL of a demo.
|
208 |
+
*
|
209 |
+
* @return (Array) $astra_demo_data demo data for the demo.
|
210 |
+
*/
|
211 |
+
public static function get_astra_single_demo( $demo_api_uri ) {
|
212 |
+
|
213 |
+
// default values.
|
214 |
+
$remote_args = array();
|
215 |
+
$defaults = array(
|
216 |
+
'id' => '',
|
217 |
+
'astra-site-widgets-data' => '',
|
218 |
+
'astra-site-customizer-data' => '',
|
219 |
+
'astra-site-options-data' => '',
|
220 |
+
'astra-site-wxr-path' => '',
|
221 |
+
'astra-enabled-extensions' => '',
|
222 |
+
'astra-custom-404' => '',
|
223 |
+
'required-plugins' => '',
|
224 |
+
);
|
225 |
+
|
226 |
+
$api_args = apply_filters(
|
227 |
+
'astra_sites_api_args', array(
|
228 |
+
'timeout' => 15,
|
229 |
+
)
|
230 |
+
);
|
231 |
+
|
232 |
+
// Use this for premium demos.
|
233 |
+
$request_params = apply_filters(
|
234 |
+
'astra_sites_api_params', array(
|
235 |
+
'purchase_key' => '',
|
236 |
+
'site_url' => '',
|
237 |
+
)
|
238 |
+
);
|
239 |
+
|
240 |
+
$demo_api_uri = add_query_arg( $request_params, $demo_api_uri );
|
241 |
+
|
242 |
+
// API Call.
|
243 |
+
$response = wp_remote_get( $demo_api_uri, $api_args );
|
244 |
+
|
245 |
+
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
|
246 |
+
|
247 |
+
$result = json_decode( wp_remote_retrieve_body( $response ), true );
|
248 |
+
|
249 |
+
if ( ! isset( $result['code'] ) ) {
|
250 |
+
$remote_args['id'] = $result['id'];
|
251 |
+
$remote_args['astra-site-widgets-data'] = json_decode( $result['astra-site-widgets-data'] );
|
252 |
+
$remote_args['astra-site-customizer-data'] = $result['astra-site-customizer-data'];
|
253 |
+
$remote_args['astra-site-options-data'] = $result['astra-site-options-data'];
|
254 |
+
$remote_args['astra-site-wxr-path'] = $result['astra-site-wxr-path'];
|
255 |
+
$remote_args['astra-enabled-extensions'] = $result['astra-enabled-extensions'];
|
256 |
+
$remote_args['astra-custom-404'] = $result['astra-custom-404'];
|
257 |
+
$remote_args['required-plugins'] = $result['required-plugins'];
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
// Merge remote demo and defaults.
|
262 |
+
return wp_parse_args( $remote_args, $defaults );
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Clear Cache.
|
267 |
+
*
|
268 |
+
* @since 1.0.9
|
269 |
+
*/
|
270 |
+
public function clear_cache() {
|
271 |
+
|
272 |
+
// Clear 'Elementor' file cache.
|
273 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
274 |
+
Elementor\Plugin::$instance->posts_css_manager->clear_cache();
|
275 |
+
}
|
276 |
+
|
277 |
+
// Clear 'Builder Builder' cache.
|
278 |
+
if ( is_callable( 'FLBuilderModel::delete_asset_cache_for_all_posts' ) ) {
|
279 |
+
FLBuilderModel::delete_asset_cache_for_all_posts();
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Kicking this off by calling 'set_instance()' method
|
287 |
+
*/
|
288 |
+
Astra_Sites_Importer::set_instance();
|
289 |
+
|
290 |
+
endif;
|
inc/classes/class-astra-sites-page.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Astra Sites Page
|
4 |
+
*
|
5 |
+
* @since 1.0.6
|
6 |
+
* @package Astra Sites
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
if ( ! class_exists( 'Astra_Sites_Page' ) ) {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Astra Admin Settings
|
17 |
+
*/
|
18 |
+
class Astra_Sites_Page {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* View all actions
|
22 |
+
*
|
23 |
+
* @since 1.0.6
|
24 |
+
* @var array $view_actions
|
25 |
+
*/
|
26 |
+
static public $view_actions = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Menu page title
|
30 |
+
*
|
31 |
+
* @since 1.0.6
|
32 |
+
* @var array $menu_page_title
|
33 |
+
*/
|
34 |
+
static public $menu_page_title = ASTRA_SITES_NAME;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Plugin slug
|
38 |
+
*
|
39 |
+
* @since 1.0.6
|
40 |
+
* @var array $plugin_slug
|
41 |
+
*/
|
42 |
+
static public $plugin_slug = 'astra-sites';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Default Menu position
|
46 |
+
*
|
47 |
+
* @since 1.0.6
|
48 |
+
* @var array $default_menu_position
|
49 |
+
*/
|
50 |
+
static public $default_menu_position = 'themes.php';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Parent Page Slug
|
54 |
+
*
|
55 |
+
* @since 1.0.6
|
56 |
+
* @var array $parent_page_slug
|
57 |
+
*/
|
58 |
+
static public $parent_page_slug = 'general';
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Current Slug
|
62 |
+
*
|
63 |
+
* @since 1.0.6
|
64 |
+
* @var array $current_slug
|
65 |
+
*/
|
66 |
+
static public $current_slug = 'general';
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Constructor
|
70 |
+
*/
|
71 |
+
function __construct() {
|
72 |
+
|
73 |
+
if ( ! is_admin() ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
add_action( 'after_setup_theme', __CLASS__ . '::init_admin_settings', 99 );
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Admin settings init
|
82 |
+
*/
|
83 |
+
static public function init_admin_settings() {
|
84 |
+
|
85 |
+
self::$menu_page_title = apply_filters( 'astra_sites_menu_page_title', __( 'Astra Sites' , 'astra-sites' ) );
|
86 |
+
|
87 |
+
if ( isset( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], self::$plugin_slug ) !== false ) {
|
88 |
+
|
89 |
+
// Let extensions hook into saving.
|
90 |
+
self::save_settings();
|
91 |
+
}
|
92 |
+
|
93 |
+
add_action( 'admin_menu', __CLASS__ . '::add_admin_menu', 100 );
|
94 |
+
|
95 |
+
add_action( 'astra_sites_menu_general_action', __CLASS__ . '::general_page' );
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Save All admin settings here
|
100 |
+
*/
|
101 |
+
static public function save_settings() {
|
102 |
+
|
103 |
+
// Only admins can save settings.
|
104 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
105 |
+
return;
|
106 |
+
}
|
107 |
+
|
108 |
+
// Let extensions hook into saving.
|
109 |
+
do_action( 'astra_sites_save_settings' );
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Init Nav Menu
|
114 |
+
*
|
115 |
+
* @param mixed $action Action name.
|
116 |
+
* @since 1.0.6
|
117 |
+
*/
|
118 |
+
static public function init_nav_menu( $action = '' ) {
|
119 |
+
|
120 |
+
if ( '' !== $action ) {
|
121 |
+
self::render_tab_menu( $action );
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Render tab menu
|
127 |
+
*
|
128 |
+
* @param mixed $action Action name.
|
129 |
+
* @since 1.0.6
|
130 |
+
*/
|
131 |
+
static public function render_tab_menu( $action = '' ) {
|
132 |
+
?>
|
133 |
+
<div id="astra-sites-menu-page">
|
134 |
+
<?php self::render( $action ); ?>
|
135 |
+
</div>
|
136 |
+
<?php
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* View actions
|
141 |
+
*
|
142 |
+
* @since 1.0.11
|
143 |
+
*/
|
144 |
+
static public function get_view_actions() {
|
145 |
+
|
146 |
+
if ( empty( self::$view_actions ) ) {
|
147 |
+
|
148 |
+
self::$view_actions = apply_filters(
|
149 |
+
'astra_sites_menu_item', array()
|
150 |
+
);
|
151 |
+
}
|
152 |
+
|
153 |
+
return self::$view_actions;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Prints HTML content for tabs
|
158 |
+
*
|
159 |
+
* @param mixed $action Action name.
|
160 |
+
* @since 1.0.6
|
161 |
+
*/
|
162 |
+
static public function render( $action ) {
|
163 |
+
|
164 |
+
?>
|
165 |
+
<div class="nav-tab-wrapper">
|
166 |
+
<h1 class='astra-sites-title'> <?php echo esc_html( self::$menu_page_title ); ?> </h1>
|
167 |
+
<?php
|
168 |
+
$view_actions = self::get_view_actions();
|
169 |
+
|
170 |
+
foreach ( $view_actions as $slug => $data ) {
|
171 |
+
|
172 |
+
if ( ! $data['show'] ) {
|
173 |
+
continue;
|
174 |
+
}
|
175 |
+
|
176 |
+
$url = self::get_page_url( $slug );
|
177 |
+
|
178 |
+
if ( $slug == self::$parent_page_slug ) {
|
179 |
+
update_option( 'astra_parent_page_url', $url );
|
180 |
+
}
|
181 |
+
|
182 |
+
$active = ( $slug == $action ) ? 'nav-tab-active' : '';
|
183 |
+
?>
|
184 |
+
<a class='nav-tab <?php echo esc_attr( $active ); ?>' href='<?php echo esc_url( $url ); ?>'> <?php echo esc_html( $data['label'] ); ?> </a>
|
185 |
+
<?php } ?>
|
186 |
+
</div><!-- .nav-tab-wrapper -->
|
187 |
+
|
188 |
+
<?php
|
189 |
+
// Settings update message.
|
190 |
+
if ( isset( $_REQUEST['message'] ) && ( 'saved' == $_REQUEST['message'] || 'saved_ext' == $_REQUEST['message'] ) ) {
|
191 |
+
?>
|
192 |
+
<span id="message" class="notice notice-success is-dismissive"><p> <?php esc_html_e( 'Settings saved successfully.', 'astra-sites' ); ?> </p></span>
|
193 |
+
<?php
|
194 |
+
}
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Get and return page URL
|
200 |
+
*
|
201 |
+
* @param string $menu_slug Menu name.
|
202 |
+
* @since 1.0.6
|
203 |
+
* @return string page url
|
204 |
+
*/
|
205 |
+
static public function get_page_url( $menu_slug ) {
|
206 |
+
|
207 |
+
$parent_page = self::$default_menu_position;
|
208 |
+
|
209 |
+
if ( strpos( $parent_page, '?' ) !== false ) {
|
210 |
+
$query_var = '&page=' . self::$plugin_slug;
|
211 |
+
} else {
|
212 |
+
$query_var = '?page=' . self::$plugin_slug;
|
213 |
+
}
|
214 |
+
|
215 |
+
$parent_page_url = admin_url( $parent_page . $query_var );
|
216 |
+
|
217 |
+
$url = $parent_page_url . '&action=' . $menu_slug;
|
218 |
+
|
219 |
+
return esc_url( $url );
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Add main menu
|
224 |
+
*
|
225 |
+
* @since 1.0.6
|
226 |
+
*/
|
227 |
+
static public function add_admin_menu() {
|
228 |
+
|
229 |
+
$parent_page = self::$default_menu_position;
|
230 |
+
$page_title = self::$menu_page_title;
|
231 |
+
$capability = 'manage_options';
|
232 |
+
$page_menu_slug = self::$plugin_slug;
|
233 |
+
$page_menu_func = __CLASS__ . '::menu_callback';
|
234 |
+
|
235 |
+
add_theme_page( $page_title, $page_title, $capability, $page_menu_slug, $page_menu_func );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Menu callback
|
240 |
+
*
|
241 |
+
* @since 1.0.6
|
242 |
+
*/
|
243 |
+
static public function menu_callback() {
|
244 |
+
|
245 |
+
$current_slug = isset( $_GET['action'] ) ? esc_attr( $_GET['action'] ) : self::$current_slug;
|
246 |
+
|
247 |
+
$active_tab = str_replace( '_', '-', $current_slug );
|
248 |
+
$current_slug = str_replace( '-', '_', $current_slug );
|
249 |
+
|
250 |
+
?>
|
251 |
+
<div class="astra-sites-menu-page-wrapper">
|
252 |
+
<?php self::init_nav_menu( $active_tab ); ?>
|
253 |
+
<?php do_action( 'astra_sites_menu_' . esc_attr( $current_slug ) . '_action' ); ?>
|
254 |
+
</div>
|
255 |
+
<?php
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Include general page
|
260 |
+
*
|
261 |
+
* @since 1.0.6
|
262 |
+
*/
|
263 |
+
static public function general_page() {
|
264 |
+
require_once ASTRA_SITES_DIR . 'inc/includes/admin-page.php';
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
new Astra_Sites_Page;
|
269 |
+
|
270 |
+
}// End if().
|
inc/classes/class-astra-sites.php
CHANGED
@@ -59,15 +59,12 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
59 |
|
60 |
add_action( 'admin_notices', array( $this, 'add_notice' ), 1 );
|
61 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
62 |
-
|
63 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
|
64 |
-
|
65 |
-
|
66 |
add_action( 'wp_ajax_astra-required-plugins', array( $this, 'required_plugin' ) );
|
67 |
add_action( 'wp_ajax_astra-required-plugin-activate', array( $this, 'required_plugin_activate' ) );
|
68 |
-
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
69 |
-
add_action( 'astra_sites_image_import_complete', array( $this, 'clear_cache' ) );
|
70 |
-
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -137,76 +134,6 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
137 |
|
138 |
}
|
139 |
|
140 |
-
/**
|
141 |
-
* Returns the API URL that depending based on the category, search term and pagination.
|
142 |
-
*
|
143 |
-
* @since 1.0.0
|
144 |
-
*
|
145 |
-
* @param object $args Arguments for selecting correct list of demos.
|
146 |
-
* args->id = ID of the demo.
|
147 |
-
* $args->search = Search term used in the demo.
|
148 |
-
* @param string $page Page number for pagination.
|
149 |
-
*
|
150 |
-
* @return string URL that can be queried to return the demos.
|
151 |
-
*/
|
152 |
-
public static function get_api_url( $args, $page = '1' ) {
|
153 |
-
|
154 |
-
$request_params = apply_filters(
|
155 |
-
'astra_sites_api_params', array(
|
156 |
-
'page' => $page,
|
157 |
-
'per_page' => '15',
|
158 |
-
|
159 |
-
// Use this for premium demos.
|
160 |
-
'purchase_key' => '',
|
161 |
-
'site_url' => '',
|
162 |
-
)
|
163 |
-
);
|
164 |
-
|
165 |
-
$args_search = isset( $args->search ) ? $args->search : '';
|
166 |
-
$args_search = isset( $args->search ) ? $args->search : '';
|
167 |
-
$category_id = isset( $args->category_id ) ? $args->category_id : '';
|
168 |
-
$page_builder_id = isset( $args->page_builder_id ) ? $args->page_builder_id : '';
|
169 |
-
|
170 |
-
// Have Search?
|
171 |
-
if ( ! empty( $args_search ) ) {
|
172 |
-
$request_params['search'] = $args_search;
|
173 |
-
}
|
174 |
-
|
175 |
-
// Have Site Page Builder Category?
|
176 |
-
if ( ! empty( $page_builder_id ) && 'all' != $page_builder_id ) {
|
177 |
-
$request_params['astra-site-page-builder'] = $page_builder_id;
|
178 |
-
}
|
179 |
-
|
180 |
-
// Have Site Category?
|
181 |
-
if ( ! empty( $category_id ) && 'all' != $category_id ) {
|
182 |
-
$request_params['astra-site-category'] = $category_id;
|
183 |
-
}
|
184 |
-
|
185 |
-
return add_query_arg( $request_params, self::$api_url . 'astra-sites' );
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Returns the API URL for searching demos basedon taxanomies.
|
190 |
-
*
|
191 |
-
* @since 1.0.0
|
192 |
-
* @return (String) URL that can be queried to return the demos.
|
193 |
-
*/
|
194 |
-
public static function get_taxanomy_api_url() {
|
195 |
-
$request_params = apply_filters( 'astra_sites_api_params', array() );
|
196 |
-
return add_query_arg( $request_params, self::$api_url . 'astra-site-category/' );
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Returns the API URL for searching site page builders
|
201 |
-
*
|
202 |
-
* @since 1.0.9
|
203 |
-
* @return (String) URL that can be queried to return the demos.
|
204 |
-
*/
|
205 |
-
public static function get_page_builders_api_url() {
|
206 |
-
$request_params = apply_filters( 'astra_sites_api_params', array() );
|
207 |
-
return add_query_arg( $request_params, self::$api_url . 'astra-site-page-builder/' );
|
208 |
-
}
|
209 |
-
|
210 |
/**
|
211 |
* Enqueue admin scripts.
|
212 |
*
|
@@ -223,50 +150,83 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
223 |
return;
|
224 |
}
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
231 |
|
232 |
-
|
233 |
-
'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/js/admin.js', array(
|
234 |
-
'jquery',
|
235 |
-
'wp-util',
|
236 |
-
'updates',
|
237 |
-
), ASTRA_SITES_VER, true
|
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 |
|
@@ -278,18 +238,11 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
278 |
private function includes() {
|
279 |
|
280 |
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-notices.php';
|
281 |
-
|
282 |
-
require_once ASTRA_SITES_DIR . 'inc/admin/class-astra-sites-page.php';
|
283 |
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php';
|
284 |
-
|
285 |
-
// Load the Importers.
|
286 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-sites-helper.php';
|
287 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/class-widgets-importer.php';
|
288 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-customizer-import.php';
|
289 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-astra-wxr-importer.php';
|
290 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-site-options-import.php';
|
291 |
-
|
292 |
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php';
|
|
|
|
|
293 |
}
|
294 |
|
295 |
/**
|
@@ -308,7 +261,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
308 |
);
|
309 |
}
|
310 |
|
311 |
-
$data
|
312 |
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
|
313 |
$astra_site_options = ( isset( $_POST['options'] ) ) ? json_decode( stripslashes( $_POST['options'] ) ) : '';
|
314 |
$enabled_extensions = ( isset( $_POST['enabledExtensions'] ) ) ? json_decode( stripslashes( $_POST['enabledExtensions'] ) ) : '';
|
@@ -449,431 +402,6 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
449 |
|
450 |
return false;
|
451 |
}
|
452 |
-
|
453 |
-
/**
|
454 |
-
* Ajax callback for demo import action.
|
455 |
-
*
|
456 |
-
* @since 1.0.0
|
457 |
-
*/
|
458 |
-
public function demo_ajax_import() {
|
459 |
-
|
460 |
-
$report = array(
|
461 |
-
'success' => false,
|
462 |
-
'message' => '',
|
463 |
-
);
|
464 |
-
|
465 |
-
if ( ! current_user_can( 'customize' ) ) {
|
466 |
-
$report['message'] = __( 'You have not "customize" access to import the astra site.', 'astra-sites' );
|
467 |
-
wp_send_json( $report );
|
468 |
-
}
|
469 |
-
|
470 |
-
$demo_api_uri = isset( $_POST['api_url'] ) ? esc_url( $_POST['api_url'] ) : '';
|
471 |
-
$this->import_demo( $demo_api_uri );
|
472 |
-
|
473 |
-
$report['success'] = true;
|
474 |
-
$report['message'] = __( 'Demo Imported Successfully.', 'astra-sites' );
|
475 |
-
wp_send_json( $report );
|
476 |
-
|
477 |
-
}
|
478 |
-
|
479 |
-
/**
|
480 |
-
* Ajax handler for retreiving the list of demos.
|
481 |
-
*
|
482 |
-
* @since 1.0.0
|
483 |
-
* @return (JSON) Json response retreived from the API.
|
484 |
-
*/
|
485 |
-
public function list_demos() {
|
486 |
-
|
487 |
-
if ( ! current_user_can( 'customize' ) ) {
|
488 |
-
return;
|
489 |
-
}
|
490 |
-
|
491 |
-
$paged = isset( $_POST['paged'] ) ? esc_attr( $_POST['paged'] ) : '1';
|
492 |
-
$args = new stdClass();
|
493 |
-
$args->search = isset( $_POST['search'] ) ? esc_attr( $_POST['search'] ) : '';
|
494 |
-
$args->page_builder_id = isset( $_POST['page_builder_id'] ) ? esc_attr( $_POST['page_builder_id'] ) : '';
|
495 |
-
$args->category_id = isset( $_POST['category_id'] ) ? esc_attr( $_POST['category_id'] ) : '';
|
496 |
-
|
497 |
-
return wp_send_json( self::get_astra_demos( $args, $paged ) );
|
498 |
-
}
|
499 |
-
|
500 |
-
/**
|
501 |
-
* Import the demo.
|
502 |
-
*
|
503 |
-
* @since 1.0.0
|
504 |
-
*
|
505 |
-
* @param (String) $demo_api_uri API URL for the single demo.
|
506 |
-
*/
|
507 |
-
public function import_demo( $demo_api_uri ) {
|
508 |
-
|
509 |
-
$demo_data = self::get_astra_single_demo( $demo_api_uri );
|
510 |
-
|
511 |
-
// Import Enabled Extensions.
|
512 |
-
$this->import_astra_enabled_extension( $demo_data['astra-enabled-extensions'] );
|
513 |
-
|
514 |
-
// Import Customizer Settings.
|
515 |
-
$this->import_customizer_settings( $demo_data['astra-site-customizer-data'] );
|
516 |
-
|
517 |
-
// Import XML.
|
518 |
-
$this->import_wxr( $demo_data['astra-site-wxr-path'] );
|
519 |
-
|
520 |
-
// Import WordPress site options.
|
521 |
-
$this->import_site_options( $demo_data['astra-site-options-data'] );
|
522 |
-
|
523 |
-
// Import Custom 404 extension options.
|
524 |
-
$this->import_custom_404_extension_options( $demo_data['astra-custom-404'] );
|
525 |
-
|
526 |
-
// Import Widgets data.
|
527 |
-
$this->import_widgets( $demo_data['astra-site-widgets-data'] );
|
528 |
-
|
529 |
-
// Clear Cache.
|
530 |
-
$this->clear_cache();
|
531 |
-
|
532 |
-
do_action( 'astra_sites_import_complete', $demo_data );
|
533 |
-
}
|
534 |
-
|
535 |
-
/**
|
536 |
-
* Clear Cache.
|
537 |
-
*
|
538 |
-
* @since 1.0.9
|
539 |
-
*/
|
540 |
-
public function clear_cache() {
|
541 |
-
|
542 |
-
// Clear 'Elementor' file cache.
|
543 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
544 |
-
Elementor\Plugin::$instance->posts_css_manager->clear_cache();
|
545 |
-
}
|
546 |
-
|
547 |
-
// Clear 'Builder Builder' cache.
|
548 |
-
if ( is_callable( 'FLBuilderModel::delete_asset_cache_for_all_posts' ) ) {
|
549 |
-
FLBuilderModel::delete_asset_cache_for_all_posts();
|
550 |
-
}
|
551 |
-
}
|
552 |
-
|
553 |
-
/**
|
554 |
-
* Import widgets and assign to correct sidebars.
|
555 |
-
*
|
556 |
-
* @since 1.0.0
|
557 |
-
*
|
558 |
-
* @param (Object) $data Widgets data.
|
559 |
-
*/
|
560 |
-
private function import_widgets( $data ) {
|
561 |
-
|
562 |
-
// bail if wiegets data is not available.
|
563 |
-
if ( null == $data ) {
|
564 |
-
return;
|
565 |
-
}
|
566 |
-
|
567 |
-
$widgets_importer = Astra_Widget_Importer::instance();
|
568 |
-
$widgets_importer->import_widgets_data( $data );
|
569 |
-
}
|
570 |
-
|
571 |
-
/**
|
572 |
-
* Import Customizer data.
|
573 |
-
*
|
574 |
-
* @since 1.0.0
|
575 |
-
*
|
576 |
-
* @param (Array) $customizer_data Customizer data for the demo to be imported.
|
577 |
-
*/
|
578 |
-
private function import_customizer_settings( $customizer_data ) {
|
579 |
-
$customizer_import = Astra_Customizer_Import::instance();
|
580 |
-
$customizer_data = $customizer_import->import( $customizer_data );
|
581 |
-
}
|
582 |
-
|
583 |
-
/**
|
584 |
-
* Download and import the XML from the demo.
|
585 |
-
*
|
586 |
-
* @since 1.0.0
|
587 |
-
*
|
588 |
-
* @param (String) $wxr_url URL of the xml export of the demo to be imported.
|
589 |
-
*/
|
590 |
-
private function import_wxr( $wxr_url ) {
|
591 |
-
$wxr_importer = Astra_WXR_Importer::instance();
|
592 |
-
$xml_path = $wxr_importer->download_xml( $wxr_url );
|
593 |
-
$wxr_importer->import_xml( $xml_path['file'] );
|
594 |
-
}
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Import site options - Front Page, Menus, Blog page etc.
|
598 |
-
*
|
599 |
-
* @since 1.0.0
|
600 |
-
*
|
601 |
-
* @param (Array) $options Array of required site options from the demo.
|
602 |
-
*/
|
603 |
-
private function import_site_options( $options ) {
|
604 |
-
$options_importer = Astra_Site_Options_Import::instance();
|
605 |
-
$options_importer->import_options( $options );
|
606 |
-
}
|
607 |
-
|
608 |
-
/**
|
609 |
-
* Import settings enabled astra extensions from the demo.
|
610 |
-
*
|
611 |
-
* @since 1.0.0
|
612 |
-
*
|
613 |
-
* @param (Array) $saved_extensions Array of enabled extensions.
|
614 |
-
*/
|
615 |
-
private function import_astra_enabled_extension( $saved_extensions ) {
|
616 |
-
if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
|
617 |
-
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $saved_extensions );
|
618 |
-
}
|
619 |
-
}
|
620 |
-
|
621 |
-
/**
|
622 |
-
* Import custom 404 section.
|
623 |
-
*
|
624 |
-
* @since 1.0.0
|
625 |
-
*
|
626 |
-
* @param (Array) $options_404 404 Extensions settings from the demo.
|
627 |
-
*/
|
628 |
-
private function import_custom_404_extension_options( $options_404 ) {
|
629 |
-
if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
|
630 |
-
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_custom_404', $options_404 );
|
631 |
-
}
|
632 |
-
}
|
633 |
-
|
634 |
-
/**
|
635 |
-
* Get single demo.
|
636 |
-
*
|
637 |
-
* @since 1.0.0
|
638 |
-
*
|
639 |
-
* @param (String) $demo_api_uri API URL of a demo.
|
640 |
-
*
|
641 |
-
* @return (Array) $astra_demo_data demo data for the demo.
|
642 |
-
*/
|
643 |
-
public static function get_astra_single_demo( $demo_api_uri ) {
|
644 |
-
|
645 |
-
// default values.
|
646 |
-
$remote_args = array();
|
647 |
-
$defaults = array(
|
648 |
-
'id' => '',
|
649 |
-
'astra-site-widgets-data' => '',
|
650 |
-
'astra-site-customizer-data' => '',
|
651 |
-
'astra-site-options-data' => '',
|
652 |
-
'astra-site-wxr-path' => '',
|
653 |
-
'astra-enabled-extensions' => '',
|
654 |
-
'astra-custom-404' => '',
|
655 |
-
'required-plugins' => '',
|
656 |
-
);
|
657 |
-
|
658 |
-
$api_args = apply_filters(
|
659 |
-
'astra_sites_api_args', array(
|
660 |
-
'timeout' => 15,
|
661 |
-
)
|
662 |
-
);
|
663 |
-
|
664 |
-
// Use this for premium demos.
|
665 |
-
$request_params = apply_filters(
|
666 |
-
'astra_sites_api_params', array(
|
667 |
-
'purchase_key' => '',
|
668 |
-
'site_url' => '',
|
669 |
-
)
|
670 |
-
);
|
671 |
-
|
672 |
-
$demo_api_uri = add_query_arg( $request_params, $demo_api_uri );
|
673 |
-
|
674 |
-
// API Call.
|
675 |
-
$response = wp_remote_get( $demo_api_uri, $api_args );
|
676 |
-
|
677 |
-
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
|
678 |
-
|
679 |
-
$result = json_decode( wp_remote_retrieve_body( $response ), true );
|
680 |
-
|
681 |
-
if ( ! isset( $result['code'] ) ) {
|
682 |
-
$remote_args['id'] = $result['id'];
|
683 |
-
$remote_args['astra-site-widgets-data'] = json_decode( $result['astra-site-widgets-data'] );
|
684 |
-
$remote_args['astra-site-customizer-data'] = $result['astra-site-customizer-data'];
|
685 |
-
$remote_args['astra-site-options-data'] = $result['astra-site-options-data'];
|
686 |
-
$remote_args['astra-site-wxr-path'] = $result['astra-site-wxr-path'];
|
687 |
-
$remote_args['astra-enabled-extensions'] = $result['astra-enabled-extensions'];
|
688 |
-
$remote_args['astra-custom-404'] = $result['astra-custom-404'];
|
689 |
-
$remote_args['required-plugins'] = $result['required-plugins'];
|
690 |
-
}
|
691 |
-
}
|
692 |
-
|
693 |
-
// Merge remote demo and defaults.
|
694 |
-
return wp_parse_args( $remote_args, $defaults );
|
695 |
-
}
|
696 |
-
|
697 |
-
/**
|
698 |
-
* Get astra demos.
|
699 |
-
*
|
700 |
-
* @since 1.0.0
|
701 |
-
*
|
702 |
-
* @param (Array) $args For selecting the demos (Search terms, pagination etc).
|
703 |
-
* @param (String) $paged Page number.
|
704 |
-
*/
|
705 |
-
public static function get_astra_demos( $args, $paged = '1' ) {
|
706 |
-
|
707 |
-
$url = self::get_api_url( $args, $paged );
|
708 |
-
|
709 |
-
$astra_demos = array(
|
710 |
-
'sites' => array(),
|
711 |
-
'sites_count' => 0,
|
712 |
-
);
|
713 |
-
|
714 |
-
$api_args = apply_filters(
|
715 |
-
'astra_sites_api_args', array(
|
716 |
-
'timeout' => 15,
|
717 |
-
)
|
718 |
-
);
|
719 |
-
|
720 |
-
$response = wp_remote_get( $url, $api_args );
|
721 |
-
|
722 |
-
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
|
723 |
-
|
724 |
-
$astra_demos['sites_count'] = wp_remote_retrieve_header( $response, 'x-wp-total' );
|
725 |
-
|
726 |
-
$result = json_decode( wp_remote_retrieve_body( $response ), true );
|
727 |
-
|
728 |
-
// If is array then proceed
|
729 |
-
// Else skip it.
|
730 |
-
if ( is_array( $result ) ) {
|
731 |
-
|
732 |
-
foreach ( $result as $key => $demo ) {
|
733 |
-
|
734 |
-
if ( ! isset( $demo['id'] ) ) {
|
735 |
-
continue;
|
736 |
-
}
|
737 |
-
|
738 |
-
$astra_demos['sites'][ $key ]['id'] = isset( $demo['id'] ) ? esc_attr( $demo['id'] ) : '';
|
739 |
-
$astra_demos['sites'][ $key ]['slug'] = isset( $demo['slug'] ) ? esc_attr( $demo['slug'] ) : '';
|
740 |
-
$astra_demos['sites'][ $key ]['date'] = isset( $demo['date'] ) ? esc_attr( $demo['date'] ) : '';
|
741 |
-
$astra_demos['sites'][ $key ]['astra_demo_type'] = isset( $demo['astra-site-type'] ) ? sanitize_key( $demo['astra-site-type'] ) : '';
|
742 |
-
$astra_demos['sites'][ $key ]['astra_demo_url'] = isset( $demo['astra-site-url'] ) ? esc_url( $demo['astra-site-url'] ) : '';
|
743 |
-
$astra_demos['sites'][ $key ]['title'] = isset( $demo['title']['rendered'] ) ? esc_attr( $demo['title']['rendered'] ) : '';
|
744 |
-
$astra_demos['sites'][ $key ]['featured_image_url'] = isset( $demo['featured-image-url'] ) ? esc_url( $demo['featured-image-url'] ) : '';
|
745 |
-
$astra_demos['sites'][ $key ]['demo_api'] = isset( $demo['_links']['self'][0]['href'] ) ? esc_url( $demo['_links']['self'][0]['href'] ) : self::get_api_url( new stdClass() ) . $demo['id'];
|
746 |
-
$astra_demos['sites'][ $key ]['content'] = isset( $demo['content']['rendered'] ) ? strip_tags( $demo['content']['rendered'] ) : '';
|
747 |
-
|
748 |
-
if ( isset( $demo['required-plugins'] ) ) {
|
749 |
-
$required_plugins = $demo['required-plugins'];
|
750 |
-
if ( is_array( $required_plugins ) ) {
|
751 |
-
$astra_demos['sites'][ $key ]['required_plugins'] = json_encode( $required_plugins );
|
752 |
-
} else {
|
753 |
-
$astra_demos['sites'][ $key ]['required_plugins'] = $required_plugins;
|
754 |
-
}
|
755 |
-
}
|
756 |
-
$astra_demos['sites'][ $key ]['astra_site_options'] = isset( $demo['astra-site-options-data'] ) ? json_encode( $demo['astra-site-options-data'] ) : '';
|
757 |
-
$astra_demos['sites'][ $key ]['astra_enabled_extensions'] = isset( $demo['astra-enabled-extensions'] ) ? json_encode( $demo['astra-enabled-extensions'] ) : '';
|
758 |
-
|
759 |
-
$demo_status = isset( $demo['status'] ) ? sanitize_key( $demo['status'] ) : '';
|
760 |
-
$astra_demos['sites'][ $key ]['status'] = ( 'draft' === $demo_status ) ? 'beta' : $demo_status;
|
761 |
-
}
|
762 |
-
|
763 |
-
// Free up memory by unsetting variables that are not required.
|
764 |
-
unset( $result );
|
765 |
-
unset( $response );
|
766 |
-
}
|
767 |
-
}
|
768 |
-
|
769 |
-
return $astra_demos;
|
770 |
-
|
771 |
-
}
|
772 |
-
|
773 |
-
/**
|
774 |
-
* Get demo categories.
|
775 |
-
*
|
776 |
-
* @since 1.0.0
|
777 |
-
* @return (Array) Array of demo categories.
|
778 |
-
*/
|
779 |
-
public static function get_demo_categories() {
|
780 |
-
$categories = array();
|
781 |
-
|
782 |
-
$api_args = apply_filters(
|
783 |
-
'astra_demo_api_args', array(
|
784 |
-
'timeout' => 15,
|
785 |
-
)
|
786 |
-
);
|
787 |
-
|
788 |
-
$response = wp_remote_get( self::get_taxanomy_api_url(), $api_args );
|
789 |
-
|
790 |
-
if ( ! is_wp_error( $response ) || 200 === wp_remote_retrieve_response_code( $response ) ) {
|
791 |
-
$result = json_decode( wp_remote_retrieve_body( $response ), true );
|
792 |
-
|
793 |
-
if ( array_key_exists( 'code', $result ) && 'rest_no_route' === $result['code'] ) {
|
794 |
-
return $categories;
|
795 |
-
}
|
796 |
-
|
797 |
-
// If is array then proceed
|
798 |
-
// Else skip it.
|
799 |
-
if ( is_array( $result ) ) {
|
800 |
-
|
801 |
-
foreach ( $result as $key => $category ) {
|
802 |
-
|
803 |
-
if ( apply_filters( 'astra_sites_category_hide_empty', true ) ) {
|
804 |
-
if ( 0 == $category['count'] ) {
|
805 |
-
continue;
|
806 |
-
}
|
807 |
-
}
|
808 |
-
$categories[ $key ]['id'] = $category['id'];
|
809 |
-
$categories[ $key ]['name'] = $category['name'];
|
810 |
-
$categories[ $key ]['slug'] = $category['slug'];
|
811 |
-
$categories[ $key ]['count'] = $category['count'];
|
812 |
-
$categories[ $key ]['link-category'] = $category['_links']['self'][0]['href'];
|
813 |
-
}
|
814 |
-
|
815 |
-
// Free up memory by unsetting variables that are not required.
|
816 |
-
unset( $result );
|
817 |
-
unset( $response );
|
818 |
-
|
819 |
-
}
|
820 |
-
}
|
821 |
-
|
822 |
-
return $categories;
|
823 |
-
}
|
824 |
-
|
825 |
-
/**
|
826 |
-
* Get Site Page Builder Categories.
|
827 |
-
*
|
828 |
-
* @since 1.0.9
|
829 |
-
* @return (Array) Array of Site Page Builder Categories.
|
830 |
-
*/
|
831 |
-
public static function get_page_builders() {
|
832 |
-
$categories = array();
|
833 |
-
|
834 |
-
$api_args = apply_filters(
|
835 |
-
'astra_demo_api_args', array(
|
836 |
-
'timeout' => 15,
|
837 |
-
)
|
838 |
-
);
|
839 |
-
|
840 |
-
$response = wp_remote_get( self::get_page_builders_api_url(), $api_args );
|
841 |
-
|
842 |
-
if ( ! is_wp_error( $response ) || 200 === wp_remote_retrieve_response_code( $response ) ) {
|
843 |
-
$result = json_decode( wp_remote_retrieve_body( $response ), true );
|
844 |
-
|
845 |
-
if ( array_key_exists( 'code', $result ) && 'rest_no_route' === $result['code'] ) {
|
846 |
-
return $categories;
|
847 |
-
}
|
848 |
-
|
849 |
-
// If is array then proceed
|
850 |
-
// Else skip it.
|
851 |
-
if ( is_array( $result ) ) {
|
852 |
-
|
853 |
-
foreach ( $result as $key => $category ) {
|
854 |
-
|
855 |
-
if ( apply_filters( 'astra_sites_category_hide_empty', true ) ) {
|
856 |
-
if ( 0 == $category['count'] ) {
|
857 |
-
continue;
|
858 |
-
}
|
859 |
-
}
|
860 |
-
$categories[ $key ]['id'] = $category['id'];
|
861 |
-
$categories[ $key ]['name'] = $category['name'];
|
862 |
-
$categories[ $key ]['slug'] = $category['slug'];
|
863 |
-
$categories[ $key ]['count'] = $category['count'];
|
864 |
-
$categories[ $key ]['link-category'] = $category['_links']['self'][0]['href'];
|
865 |
-
}
|
866 |
-
|
867 |
-
// Free up memory by unsetting variables that are not required.
|
868 |
-
unset( $result );
|
869 |
-
unset( $response );
|
870 |
-
|
871 |
-
}
|
872 |
-
}
|
873 |
-
|
874 |
-
return $categories;
|
875 |
-
}
|
876 |
-
|
877 |
}
|
878 |
|
879 |
/**
|
59 |
|
60 |
add_action( 'admin_notices', array( $this, 'add_notice' ), 1 );
|
61 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
62 |
+
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
63 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
|
64 |
+
|
65 |
+
// AJAX.
|
66 |
add_action( 'wp_ajax_astra-required-plugins', array( $this, 'required_plugin' ) );
|
67 |
add_action( 'wp_ajax_astra-required-plugin-activate', array( $this, 'required_plugin_activate' ) );
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
/**
|
134 |
|
135 |
}
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
/**
|
138 |
* Enqueue admin scripts.
|
139 |
*
|
150 |
return;
|
151 |
}
|
152 |
|
153 |
+
// Lazyload & Image Loaded.
|
154 |
+
wp_register_script( 'astra-sites-lazyload', ASTRA_SITES_URI . 'inc/assets/vendor/js/jquery.lazy.min.js', array( 'jquery' ), ASTRA_SITES_VER, true );
|
155 |
+
|
156 |
+
// API.
|
157 |
+
wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery' ), ASTRA_SITES_VER, true );
|
158 |
+
|
159 |
+
// Admin Page.
|
160 |
wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
|
161 |
+
wp_enqueue_script( 'astra-sites-admin-page', ASTRA_SITES_URI . 'inc/assets/js/admin-page.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
|
162 |
+
wp_enqueue_script( 'astra-sites-render-grid', ASTRA_SITES_URI . 'inc/assets/js/render-grid.js', array( 'wp-util', 'astra-sites-api', 'imagesloaded', 'jquery', 'astra-sites-lazyload' ), ASTRA_SITES_VER, true );
|
163 |
+
|
164 |
+
$data = array(
|
165 |
+
'ApiURL' => self::$api_url,
|
166 |
+
'filters' => array(
|
167 |
+
'page_builder' => array(
|
168 |
+
'title' => __( 'Page Builder', 'astra-sites' ),
|
169 |
+
'slug' => 'astra-site-page-builder',
|
170 |
+
'trigger' => 'astra-api-category-loaded',
|
171 |
+
),
|
172 |
+
'categories' => array(
|
173 |
+
'title' => __( 'Categories', 'astra-sites' ),
|
174 |
+
'slug' => 'astra-site-category',
|
175 |
+
'trigger' => 'astra-api-category-loaded',
|
176 |
+
),
|
177 |
+
),
|
178 |
+
);
|
179 |
+
wp_localize_script( 'astra-sites-api', 'astraSitesApi', $data );
|
180 |
+
|
181 |
+
// Use this for premium demos.
|
182 |
+
$request_params = apply_filters(
|
183 |
+
'astra_sites_api_params', array(
|
184 |
+
'purchase_key' => '',
|
185 |
+
'site_url' => '',
|
186 |
+
'par-page' => 6,
|
187 |
+
)
|
188 |
+
);
|
189 |
|
190 |
+
$data = apply_filters(
|
191 |
+
'astra_sites_localize_vars',
|
192 |
+
array(
|
193 |
+
'sites' => $request_params,
|
194 |
+
'settings' => array(),
|
195 |
+
)
|
196 |
+
);
|
197 |
|
198 |
+
wp_localize_script( 'astra-sites-render-grid', 'astraRenderGrid', $data );
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
+
$data = apply_filters(
|
201 |
+
'astra_sites_localize_vars',
|
202 |
+
array(
|
203 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
204 |
+
'siteURL' => site_url(),
|
205 |
+
'getProText' => __( 'Purchase', 'astra-sites' ),
|
206 |
+
'getProURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
207 |
+
'getUpgradeText' => __( 'Upgrade', 'astra-sites' ),
|
208 |
+
'getUpgradeURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
209 |
+
'_ajax_nonce' => wp_create_nonce( 'astra-sites' ),
|
210 |
+
'requiredPlugins' => array(),
|
211 |
+
'strings' => array(
|
212 |
+
'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
|
213 |
+
'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
|
214 |
+
'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314' ),
|
215 |
+
'viewSite' => __( 'Done! View Site', 'astra-sites' ),
|
216 |
+
'btnActivating' => __( 'Activating', 'astra-sites' ) . '…',
|
217 |
+
'btnActive' => __( 'Active', 'astra-sites' ),
|
218 |
+
'importDemo' => __( 'Import This Site', 'astra-sites' ),
|
219 |
+
'importingDemo' => __( 'Importing Demo', 'astra-sites' ),
|
220 |
+
'DescExpand' => __( 'Read more', 'astra-sites' ) . '…',
|
221 |
+
'DescCollapse' => __( 'Hide', 'astra-sites' ),
|
222 |
+
'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
|
223 |
+
'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
|
224 |
+
'importWarning' => __( "Executing Demo Import will make your site similar as ours. Please bear in mind -\n\n1. It is recommended to run import on a fresh WordPress installation.\n\n2. Importing site does not delete any pages or posts. However, it can overwrite your existing content.\n\n3. Copyrighted media will not be imported. Instead it will be replaced with placeholders.", 'astra-sites' ),
|
225 |
+
),
|
226 |
+
)
|
227 |
+
);
|
228 |
+
|
229 |
+
wp_localize_script( 'astra-sites-admin-page', 'astraSitesAdmin', $data );
|
230 |
|
231 |
}
|
232 |
|
238 |
private function includes() {
|
239 |
|
240 |
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-notices.php';
|
241 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-page.php';
|
|
|
242 |
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php';
|
244 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer.php';
|
245 |
+
|
246 |
}
|
247 |
|
248 |
/**
|
261 |
);
|
262 |
}
|
263 |
|
264 |
+
$data = array();
|
265 |
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
|
266 |
$astra_site_options = ( isset( $_POST['options'] ) ) ? json_decode( stripslashes( $_POST['options'] ) ) : '';
|
267 |
$enabled_extensions = ( isset( $_POST['enabledExtensions'] ) ) ? json_decode( stripslashes( $_POST['enabledExtensions'] ) ) : '';
|
402 |
|
403 |
return false;
|
404 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
}
|
406 |
|
407 |
/**
|
inc/includes/admin-page.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Shortcode Markup
|
4 |
+
*
|
5 |
+
* TMPL - Single Demo Preview
|
6 |
+
* TMPL - No more demos
|
7 |
+
* TMPL - Filters
|
8 |
+
* TMPL - List
|
9 |
+
*
|
10 |
+
* @package Astra Sites
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
defined( 'ABSPATH' ) or exit;
|
15 |
+
|
16 |
+
?>
|
17 |
+
<div class="wrap" id="astra-sites-admin">
|
18 |
+
|
19 |
+
<div id="astra-sites-filters" class="wp-filter hide-if-no-js">
|
20 |
+
|
21 |
+
<div class="section-left">
|
22 |
+
|
23 |
+
<!-- All Filters -->
|
24 |
+
<div class="filter-count">
|
25 |
+
<span class="count"></span>
|
26 |
+
</div>
|
27 |
+
<div class="filters-wrap">
|
28 |
+
<div id="astra-site-page-builder"></div>
|
29 |
+
</div>
|
30 |
+
|
31 |
+
</div>
|
32 |
+
|
33 |
+
<div class="section-right">
|
34 |
+
|
35 |
+
<div class="filters-wrap">
|
36 |
+
<div id="astra-site-category"></div>
|
37 |
+
</div>
|
38 |
+
|
39 |
+
<div class="search-form">
|
40 |
+
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'astra-sites' ); ?> </label>
|
41 |
+
<input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
|
42 |
+
</div>
|
43 |
+
|
44 |
+
</div>
|
45 |
+
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<?php do_action( 'astra_sites_before_site_grid' ); ?>
|
49 |
+
|
50 |
+
|
51 |
+
<div class="theme-browser rendered">
|
52 |
+
<div id="astra-sites" class="themes wp-clearfix"></div>
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<div class="spinner-wrap">
|
56 |
+
<span class="spinner"></span>
|
57 |
+
</div>
|
58 |
+
|
59 |
+
<?php do_action( 'astra_sites_after_site_grid' ); ?>
|
60 |
+
|
61 |
+
</div>
|
62 |
+
|
63 |
+
<?php
|
64 |
+
/**
|
65 |
+
* TMPL - Single Demo Preview
|
66 |
+
*/
|
67 |
+
?>
|
68 |
+
<script type="text/template" id="tmpl-astra-site-preview">
|
69 |
+
<div class="astra-sites-preview theme-install-overlay wp-full-overlay expanded">
|
70 |
+
<div class="wp-full-overlay-sidebar">
|
71 |
+
<div class="wp-full-overlay-header"
|
72 |
+
data-demo-id="{{{data.id}}}"
|
73 |
+
data-demo-type="{{{data.astra_demo_type}}}"
|
74 |
+
data-demo-url="{{{data.astra_demo_url}}}"
|
75 |
+
data-demo-api="{{{data.demo_api}}}"
|
76 |
+
data-demo-name="{{{data.demo_name}}}"
|
77 |
+
data-demo-slug="{{{data.slug}}}"
|
78 |
+
data-screenshot="{{{data.screenshot}}}"
|
79 |
+
data-content="{{{data.content}}}"
|
80 |
+
data-required-plugins="{{data.required_plugins}}">
|
81 |
+
<input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
|
82 |
+
<input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
|
83 |
+
<button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'astra-sites' ); ?></span></button>
|
84 |
+
<button class="previous-theme"><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'astra-sites' ); ?></span></button>
|
85 |
+
<button class="next-theme"><span class="screen-reader-text"><?php esc_html_e( 'Next', 'astra-sites' ); ?></span></button>
|
86 |
+
<a class="button hide-if-no-customize astra-demo-import" href="#" data-import="disabled"><?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?></a>
|
87 |
+
|
88 |
+
</div>
|
89 |
+
<div class="wp-full-overlay-sidebar-content">
|
90 |
+
<div class="install-theme-info">
|
91 |
+
|
92 |
+
<span class="site-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
|
93 |
+
<h3 class="theme-name">{{{data.demo_name}}}</h3>
|
94 |
+
|
95 |
+
<# if ( data.screenshot.length ) { #>
|
96 |
+
<img class="theme-screenshot" src="{{{data.screenshot}}}" alt="">
|
97 |
+
<# } #>
|
98 |
+
|
99 |
+
<div class="theme-details">
|
100 |
+
{{{data.content}}}
|
101 |
+
</div>
|
102 |
+
<a href="#" class="theme-details-read-more"><?php _e( 'Read more', 'astra-sites' ); ?> …</a>
|
103 |
+
|
104 |
+
<div class="required-plugins-wrap">
|
105 |
+
<h4><?php _e( 'Required Plugins', 'astra-sites' ); ?> </h4>
|
106 |
+
<div class="required-plugins"></div>
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
</div>
|
110 |
+
|
111 |
+
<div class="wp-full-overlay-footer">
|
112 |
+
<div class="footer-import-button-wrap">
|
113 |
+
<a class="button button-hero hide-if-no-customize astra-demo-import" href="#" data-import="disabled">
|
114 |
+
<?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?>
|
115 |
+
</a>
|
116 |
+
</div>
|
117 |
+
<button type="button" class="collapse-sidebar button" aria-expanded="true"
|
118 |
+
aria-label="Collapse Sidebar">
|
119 |
+
<span class="collapse-sidebar-arrow"></span>
|
120 |
+
<span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
|
121 |
+
</button>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
<div class="wp-full-overlay-main">
|
125 |
+
<iframe src="{{{data.astra_demo_url}}}" title="<?php esc_attr_e( 'Preview', 'astra-sites' ); ?>"></iframe>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
</script>
|
129 |
+
|
130 |
+
<?php
|
131 |
+
/**
|
132 |
+
* TMPL - No more demos
|
133 |
+
*/
|
134 |
+
?>
|
135 |
+
<script type="text/template" id="tmpl-astra-site-api-request-failed">
|
136 |
+
<div class="no-themes">
|
137 |
+
<?php
|
138 |
+
|
139 |
+
/* translators: %1$s & %2$s are a Demo API URL */
|
140 |
+
printf( __( '<p> It seems the demo data server, <i><a href="%1$s">%2$s</a></i> is unreachable from your site.</p>', 'astra-sites' ) , esc_url( Astra_Sites::$api_url ), esc_url( Astra_Sites::$api_url ) );
|
141 |
+
|
142 |
+
_e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
|
143 |
+
|
144 |
+
_e( '<p class="left-margin"> 2. If that does not work, you will need to talk to your server administrator and check if demo server is being blocked by the firewall!</p>', 'astra-sites' );
|
145 |
+
|
146 |
+
/* translators: %1$s is a support link */
|
147 |
+
printf( __( '<p>If that does not help, please open up a <a href="%1$s" target="_blank">Support Ticket</a> and we will be glad take a closer look for you.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/support/' ) );
|
148 |
+
?>
|
149 |
+
</div>
|
150 |
+
</script>
|
151 |
+
|
152 |
+
<?php
|
153 |
+
/**
|
154 |
+
* TMPL - Filters
|
155 |
+
*/
|
156 |
+
?>
|
157 |
+
<script type="text/template" id="tmpl-astra-site-filters">
|
158 |
+
|
159 |
+
<# if ( data ) { #>
|
160 |
+
|
161 |
+
<ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
162 |
+
|
163 |
+
<# if ( data.args.show_all ) { #>
|
164 |
+
<li>
|
165 |
+
<a href="#" data-group="all"> All </a>
|
166 |
+
</li>
|
167 |
+
<# } #>
|
168 |
+
|
169 |
+
<# for ( key in data.items ) { #>
|
170 |
+
<# if ( data.items[ key ].count ) { #>
|
171 |
+
<li>
|
172 |
+
<a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
|
173 |
+
{{ data.items[ key ].name }}
|
174 |
+
</a>
|
175 |
+
</li>
|
176 |
+
<# } #>
|
177 |
+
<# } #>
|
178 |
+
|
179 |
+
</ul>
|
180 |
+
<# } #>
|
181 |
+
</script>
|
182 |
+
|
183 |
+
<?php
|
184 |
+
/**
|
185 |
+
* TMPL - List
|
186 |
+
*/
|
187 |
+
?>
|
188 |
+
<script type="text/template" id="tmpl-astra-sites-list">
|
189 |
+
|
190 |
+
<# if ( data.items.length ) { #>
|
191 |
+
<# for ( key in data.items ) { #>
|
192 |
+
|
193 |
+
<div class="theme astra-theme site-single {{ data.items[ key ].status }}" tabindex="0" aria-describedby="astra-theme-action astra-theme-name"
|
194 |
+
data-demo-id="{{{ data.items[ key ].id }}}"
|
195 |
+
data-demo-type="{{{ data.items[ key ]['astra-site-type'] }}}"
|
196 |
+
data-demo-url="{{{ data.items[ key ]['astra-site-url'] }}}"
|
197 |
+
data-demo-api="{{{ data.items[ key ]['_links']['self'][0]['href'] }}}"
|
198 |
+
data-demo-name="{{{ data.items[ key ].title.rendered }}}"
|
199 |
+
data-demo-slug="{{{ data.items[ key ].slug }}}"
|
200 |
+
data-screenshot="{{{ data.items[ key ]['featured-image-url'] }}}"
|
201 |
+
data-content="{{{ data.items[ key ].content.rendered }}}"
|
202 |
+
data-required-plugins="{{ JSON.stringify( data.items[ key ]['required-plugins'] ) }}"
|
203 |
+
data-groups=["{{ data.items[ key ].tags }}"]>
|
204 |
+
<input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
|
205 |
+
<input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
|
206 |
+
|
207 |
+
<!-- <div class="theme astra-theme site-single" data-groups=["{{ data.items[ key ].tags }}"]> -->
|
208 |
+
<div class="inner">
|
209 |
+
<span class="site-preview" data-href="{{ data.items[ key ]['astra-site-url'] }}?TB_iframe=true&width=600&height=550" data-title="{{ data.items[ key ].title.rendered }}">
|
210 |
+
|
211 |
+
<div class="theme-screenshot">
|
212 |
+
<# if( '' !== data.items[ key ]['featured-image-url'] ) { #>
|
213 |
+
<img class="lazy" data-src="{{ data.items[ key ]['featured-image-url'] }}" />
|
214 |
+
<noscript>
|
215 |
+
<img src="{{ data.items[ key ]['featured-image-url'] }}" />
|
216 |
+
</noscript>
|
217 |
+
<# } #>
|
218 |
+
</div>
|
219 |
+
|
220 |
+
<a href="{{{data.astra_demo_url}}}" target="_blank" class="view-demo-wrap">
|
221 |
+
<span class="more-details view-demo" id="astra-theme-action"><?php esc_html_e( 'Details & Preview', 'astra-sites' ); ?></span>
|
222 |
+
</a>
|
223 |
+
|
224 |
+
</span>
|
225 |
+
<h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
226 |
+
<# if ( data.items[ key ]['astra-site-type'] ) { #>
|
227 |
+
<span class="site-type {{data.items[ key ]['astra-site-type']}}">{{data.items[ key ]['astra-site-type']}}</span>
|
228 |
+
<# } #>
|
229 |
+
<# if ( data.items[ key ].status ) { #>
|
230 |
+
<span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
|
231 |
+
<# } #>
|
232 |
+
<div class="theme-actions">
|
233 |
+
<button class="button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
<# } #>
|
238 |
+
<# } else { #>
|
239 |
+
<p class="no-themes" style="display:block;"> <?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?> </p>
|
240 |
+
<# } #>
|
241 |
+
</script>
|
languages/astra-sites.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Astra Sites - Lite package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Astra Sites - Lite 1.0.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
-
"POT-Creation-Date: 2017-09
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -24,88 +24,20 @@ msgstr ""
|
|
24 |
"X-Textdomain-Support: yes\n"
|
25 |
"X-Generator: grunt-wp-i18n1.0.0\n"
|
26 |
|
27 |
-
#: astra-sites.php:18 inc/
|
28 |
msgid "Astra Sites"
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: inc/
|
32 |
-
msgid "
|
33 |
-
msgstr ""
|
34 |
-
|
35 |
-
#: inc/admin/view-astra-sites.php:51
|
36 |
-
msgid "All"
|
37 |
-
msgstr ""
|
38 |
-
|
39 |
-
#: inc/admin/view-astra-sites.php:65
|
40 |
-
msgid "Search Sites"
|
41 |
-
msgstr ""
|
42 |
-
|
43 |
-
#: inc/admin/view-astra-sites.php:66
|
44 |
-
msgid "Search Sites..."
|
45 |
-
msgstr ""
|
46 |
-
|
47 |
-
#: inc/admin/view-astra-sites.php:116
|
48 |
-
msgid "Details & Preview"
|
49 |
-
msgstr ""
|
50 |
-
|
51 |
-
#: inc/admin/view-astra-sites.php:122 inc/admin/view-astra-sites.php:191
|
52 |
-
msgid "Preview"
|
53 |
-
msgstr ""
|
54 |
-
|
55 |
-
#: inc/admin/view-astra-sites.php:149
|
56 |
-
msgid "Close"
|
57 |
-
msgstr ""
|
58 |
-
|
59 |
-
#: inc/admin/view-astra-sites.php:150
|
60 |
-
msgid "Previous"
|
61 |
-
msgstr ""
|
62 |
-
|
63 |
-
#: inc/admin/view-astra-sites.php:151
|
64 |
-
msgid "Next"
|
65 |
-
msgstr ""
|
66 |
-
|
67 |
-
#: inc/admin/view-astra-sites.php:152 inc/admin/view-astra-sites.php:180
|
68 |
-
msgid "Install Plugins"
|
69 |
-
msgstr ""
|
70 |
-
|
71 |
-
#: inc/admin/view-astra-sites.php:168 inc/classes/class-astra-sites.php:260
|
72 |
-
msgid "Read more"
|
73 |
-
msgstr ""
|
74 |
-
|
75 |
-
#: inc/admin/view-astra-sites.php:171
|
76 |
-
msgid "Required Plugins"
|
77 |
-
msgstr ""
|
78 |
-
|
79 |
-
#: inc/admin/view-astra-sites.php:186
|
80 |
-
msgid "Collapse"
|
81 |
-
msgstr ""
|
82 |
-
|
83 |
-
#: inc/admin/view-astra-sites.php:201
|
84 |
-
#. translators: %1$s & %2$s are a Demo API URL
|
85 |
-
msgid ""
|
86 |
-
"<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
|
87 |
-
"unreachable from your site.</p>"
|
88 |
-
msgstr ""
|
89 |
-
|
90 |
-
#: inc/admin/view-astra-sites.php:203
|
91 |
-
msgid ""
|
92 |
-
"<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
|
93 |
-
"temporary issues. No kidding!</p>"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#: inc/
|
97 |
-
msgid ""
|
98 |
-
"<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
|
99 |
-
"to your server administrator and check if demo server is being blocked by "
|
100 |
-
"the firewall!</p>"
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: inc/
|
104 |
-
|
105 |
-
msgid ""
|
106 |
-
"<p>If that does not help, please open up a <a href=\"%1$s\" "
|
107 |
-
"target=\"_blank\">Support Ticket</a> and we will be glad take a closer look "
|
108 |
-
"for you.</p>"
|
109 |
msgstr ""
|
110 |
|
111 |
#: inc/classes/class-astra-sites-white-label.php:176
|
@@ -113,66 +45,78 @@ msgstr ""
|
|
113 |
msgid "%1$s Branding"
|
114 |
msgstr ""
|
115 |
|
116 |
-
#: inc/classes/class-astra-sites.php:
|
117 |
#. translators: 1: theme.php file
|
118 |
msgid ""
|
119 |
"Astra Theme needs to be active for you to use currently installed \"%1$s\" "
|
120 |
"plugin. <a href=\"%2$s\">Install & Activate Now</a>"
|
121 |
msgstr ""
|
122 |
|
123 |
-
#: inc/classes/class-astra-sites.php:
|
124 |
msgid "See Library"
|
125 |
msgstr ""
|
126 |
|
127 |
-
#: inc/classes/class-astra-sites.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
msgid "Purchase"
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: inc/classes/class-astra-sites.php:
|
132 |
msgid "Upgrade"
|
133 |
msgstr ""
|
134 |
|
135 |
-
#: inc/classes/class-astra-sites.php:
|
136 |
msgid "Error!"
|
137 |
msgstr ""
|
138 |
|
139 |
-
#: inc/classes/class-astra-sites.php:
|
140 |
msgid "Error! Read Possibilities."
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: inc/classes/class-astra-sites.php:
|
144 |
msgid "Done! View Site"
|
145 |
msgstr ""
|
146 |
|
147 |
-
#: inc/classes/class-astra-sites.php:
|
148 |
msgid "Activating"
|
149 |
msgstr ""
|
150 |
|
151 |
-
#: inc/classes/class-astra-sites.php:
|
152 |
msgid "Active"
|
153 |
msgstr ""
|
154 |
|
155 |
-
#: inc/classes/class-astra-sites.php:
|
156 |
msgid "Import This Site"
|
157 |
msgstr ""
|
158 |
|
159 |
-
#: inc/classes/class-astra-sites.php:
|
160 |
msgid "Importing Demo"
|
161 |
msgstr ""
|
162 |
|
163 |
-
#: inc/classes/class-astra-sites.php:
|
|
|
|
|
|
|
|
|
164 |
msgid "Hide"
|
165 |
msgstr ""
|
166 |
|
167 |
-
#: inc/classes/class-astra-sites.php:
|
168 |
msgid "There was a problem receiving a response from server."
|
169 |
msgstr ""
|
170 |
|
171 |
-
#: inc/classes/class-astra-sites.php:
|
172 |
msgid "No Demos found, Try a different search."
|
173 |
msgstr ""
|
174 |
|
175 |
-
#: inc/classes/class-astra-sites.php:
|
176 |
msgid ""
|
177 |
"Executing Demo Import will make your site similar as ours. Please bear in "
|
178 |
"mind -\n"
|
@@ -186,22 +130,14 @@ msgid ""
|
|
186 |
"placeholders."
|
187 |
msgstr ""
|
188 |
|
189 |
-
#: inc/classes/class-astra-sites.php:
|
190 |
msgid "No plugin specified"
|
191 |
msgstr ""
|
192 |
|
193 |
-
#: inc/classes/class-astra-sites.php:
|
194 |
msgid "Plugin Successfully Activated"
|
195 |
msgstr ""
|
196 |
|
197 |
-
#: inc/classes/class-astra-sites.php:466
|
198 |
-
msgid "You have not \"customize\" access to import the astra site."
|
199 |
-
msgstr ""
|
200 |
-
|
201 |
-
#: inc/classes/class-astra-sites.php:474
|
202 |
-
msgid "Demo Imported Successfully."
|
203 |
-
msgstr ""
|
204 |
-
|
205 |
#: inc/classes/compatibility/elementor/class-astra-sites-source-remote.php:58
|
206 |
msgid "Remote"
|
207 |
msgstr ""
|
@@ -385,6 +321,74 @@ msgstr ""
|
|
385 |
msgid "Could not update comment #%d with mapped data"
|
386 |
msgstr ""
|
387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
#: inc/includes/white-label.php:23
|
389 |
msgid "Plugin Name:"
|
390 |
msgstr ""
|
2 |
# This file is distributed under the same license as the Astra Sites - Lite package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Astra Sites - Lite 1.0.13\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
+
"POT-Creation-Date: 2017-10-09 14:55:13+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
24 |
"X-Textdomain-Support: yes\n"
|
25 |
"X-Generator: grunt-wp-i18n1.0.0\n"
|
26 |
|
27 |
+
#: astra-sites.php:18 inc/classes/class-astra-sites-page.php:85
|
28 |
msgid "Astra Sites"
|
29 |
msgstr ""
|
30 |
|
31 |
+
#: inc/classes/class-astra-sites-importer.php:72
|
32 |
+
msgid "You have not \"customize\" access to import the astra site."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
msgstr ""
|
34 |
|
35 |
+
#: inc/classes/class-astra-sites-importer.php:80
|
36 |
+
msgid "Demo Imported Successfully."
|
|
|
|
|
|
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: inc/classes/class-astra-sites-page.php:192
|
40 |
+
msgid "Settings saved successfully."
|
|
|
|
|
|
|
|
|
41 |
msgstr ""
|
42 |
|
43 |
#: inc/classes/class-astra-sites-white-label.php:176
|
45 |
msgid "%1$s Branding"
|
46 |
msgstr ""
|
47 |
|
48 |
+
#: inc/classes/class-astra-sites.php:80
|
49 |
#. translators: 1: theme.php file
|
50 |
msgid ""
|
51 |
"Astra Theme needs to be active for you to use currently installed \"%1$s\" "
|
52 |
"plugin. <a href=\"%2$s\">Install & Activate Now</a>"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: inc/classes/class-astra-sites.php:120
|
56 |
msgid "See Library"
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: inc/classes/class-astra-sites.php:168
|
60 |
+
msgid "Page Builder"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: inc/classes/class-astra-sites.php:173
|
64 |
+
msgid "Categories"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: inc/classes/class-astra-sites.php:205
|
68 |
msgid "Purchase"
|
69 |
msgstr ""
|
70 |
|
71 |
+
#: inc/classes/class-astra-sites.php:207
|
72 |
msgid "Upgrade"
|
73 |
msgstr ""
|
74 |
|
75 |
+
#: inc/classes/class-astra-sites.php:212
|
76 |
msgid "Error!"
|
77 |
msgstr ""
|
78 |
|
79 |
+
#: inc/classes/class-astra-sites.php:213
|
80 |
msgid "Error! Read Possibilities."
|
81 |
msgstr ""
|
82 |
|
83 |
+
#: inc/classes/class-astra-sites.php:215
|
84 |
msgid "Done! View Site"
|
85 |
msgstr ""
|
86 |
|
87 |
+
#: inc/classes/class-astra-sites.php:216
|
88 |
msgid "Activating"
|
89 |
msgstr ""
|
90 |
|
91 |
+
#: inc/classes/class-astra-sites.php:217
|
92 |
msgid "Active"
|
93 |
msgstr ""
|
94 |
|
95 |
+
#: inc/classes/class-astra-sites.php:218
|
96 |
msgid "Import This Site"
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: inc/classes/class-astra-sites.php:219
|
100 |
msgid "Importing Demo"
|
101 |
msgstr ""
|
102 |
|
103 |
+
#: inc/classes/class-astra-sites.php:220 inc/includes/admin-page.php:102
|
104 |
+
msgid "Read more"
|
105 |
+
msgstr ""
|
106 |
+
|
107 |
+
#: inc/classes/class-astra-sites.php:221
|
108 |
msgid "Hide"
|
109 |
msgstr ""
|
110 |
|
111 |
+
#: inc/classes/class-astra-sites.php:222
|
112 |
msgid "There was a problem receiving a response from server."
|
113 |
msgstr ""
|
114 |
|
115 |
+
#: inc/classes/class-astra-sites.php:223 inc/includes/admin-page.php:240
|
116 |
msgid "No Demos found, Try a different search."
|
117 |
msgstr ""
|
118 |
|
119 |
+
#: inc/classes/class-astra-sites.php:224
|
120 |
msgid ""
|
121 |
"Executing Demo Import will make your site similar as ours. Please bear in "
|
122 |
"mind -\n"
|
130 |
"placeholders."
|
131 |
msgstr ""
|
132 |
|
133 |
+
#: inc/classes/class-astra-sites.php:259
|
134 |
msgid "No plugin specified"
|
135 |
msgstr ""
|
136 |
|
137 |
+
#: inc/classes/class-astra-sites.php:288
|
138 |
msgid "Plugin Successfully Activated"
|
139 |
msgstr ""
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
#: inc/classes/compatibility/elementor/class-astra-sites-source-remote.php:58
|
142 |
msgid "Remote"
|
143 |
msgstr ""
|
321 |
msgid "Could not update comment #%d with mapped data"
|
322 |
msgstr ""
|
323 |
|
324 |
+
#: inc/includes/admin-page.php:40
|
325 |
+
msgid "Search Sites"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: inc/includes/admin-page.php:41
|
329 |
+
msgid "Search Sites..."
|
330 |
+
msgstr ""
|
331 |
+
|
332 |
+
#: inc/includes/admin-page.php:83
|
333 |
+
msgid "Close"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: inc/includes/admin-page.php:84
|
337 |
+
msgid "Previous"
|
338 |
+
msgstr ""
|
339 |
+
|
340 |
+
#: inc/includes/admin-page.php:85
|
341 |
+
msgid "Next"
|
342 |
+
msgstr ""
|
343 |
+
|
344 |
+
#: inc/includes/admin-page.php:86 inc/includes/admin-page.php:114
|
345 |
+
msgid "Install Plugins"
|
346 |
+
msgstr ""
|
347 |
+
|
348 |
+
#: inc/includes/admin-page.php:105
|
349 |
+
msgid "Required Plugins"
|
350 |
+
msgstr ""
|
351 |
+
|
352 |
+
#: inc/includes/admin-page.php:120
|
353 |
+
msgid "Collapse"
|
354 |
+
msgstr ""
|
355 |
+
|
356 |
+
#: inc/includes/admin-page.php:125 inc/includes/admin-page.php:234
|
357 |
+
msgid "Preview"
|
358 |
+
msgstr ""
|
359 |
+
|
360 |
+
#: inc/includes/admin-page.php:140
|
361 |
+
#. translators: %1$s & %2$s are a Demo API URL
|
362 |
+
msgid ""
|
363 |
+
"<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
|
364 |
+
"unreachable from your site.</p>"
|
365 |
+
msgstr ""
|
366 |
+
|
367 |
+
#: inc/includes/admin-page.php:142
|
368 |
+
msgid ""
|
369 |
+
"<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
|
370 |
+
"temporary issues. No kidding!</p>"
|
371 |
+
msgstr ""
|
372 |
+
|
373 |
+
#: inc/includes/admin-page.php:144
|
374 |
+
msgid ""
|
375 |
+
"<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
|
376 |
+
"to your server administrator and check if demo server is being blocked by "
|
377 |
+
"the firewall!</p>"
|
378 |
+
msgstr ""
|
379 |
+
|
380 |
+
#: inc/includes/admin-page.php:147
|
381 |
+
#. translators: %1$s is a support link
|
382 |
+
msgid ""
|
383 |
+
"<p>If that does not help, please open up a <a href=\"%1$s\" "
|
384 |
+
"target=\"_blank\">Support Ticket</a> and we will be glad take a closer look "
|
385 |
+
"for you.</p>"
|
386 |
+
msgstr ""
|
387 |
+
|
388 |
+
#: inc/includes/admin-page.php:222
|
389 |
+
msgid "Details & Preview"
|
390 |
+
msgstr ""
|
391 |
+
|
392 |
#: inc/includes/white-label.php:23
|
393 |
msgid "Plugin Name:"
|
394 |
msgstr ""
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpastra.com/pro/
|
|
4 |
Tags: demo, theme demos, one click import
|
5 |
Requires at least: 4.4
|
6 |
Tested up to: 4.8.1
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -18,20 +18,11 @@ This plugin is an add-on for the Astra WordPress Theme. It offers a library of r
|
|
18 |
2. Pick a site you like.
|
19 |
3. Install required plugins in one click
|
20 |
4. Import the site data.
|
21 |
-
5. Done
|
22 |
|
23 |
-
Use this imported site as a base for your project and don't waste time starting from scratch
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
https://sites.wpastra.com/gardener-free/
|
28 |
-
https://sites.wpastra.com/hotel-free/
|
29 |
-
https://sites.wpastra.com/agency-free/
|
30 |
-
https://sites.wpastra.com/restaurant-free/
|
31 |
-
https://sites.wpastra.com/construction-free/
|
32 |
-
https://sites.wpastra.com/makeup-artist-free/
|
33 |
-
https://sites.wpastra.com/electrician-free
|
34 |
-
https://sites.wpastra.com/law-free/
|
35 |
|
36 |
== Installation ==
|
37 |
|
@@ -46,6 +37,9 @@ https://sites.wpastra.com/law-free/
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
49 |
v1.0.12 - 29-Sept-2017
|
50 |
* New: Added White Label support from <a href="https://wpastra.com/pro/">Astra Pro</a>.
|
51 |
* Improvement: Don't display sites from both the page builders in the same view.
|
@@ -105,4 +99,3 @@ v1.0.1 - 04-Aug-2017
|
|
105 |
|
106 |
v1.0.0
|
107 |
* Initial release
|
108 |
-
|
4 |
Tags: demo, theme demos, one click import
|
5 |
Requires at least: 4.4
|
6 |
Tested up to: 4.8.1
|
7 |
+
Stable tag: 1.0.13
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
18 |
2. Pick a site you like.
|
19 |
3. Install required plugins in one click
|
20 |
4. Import the site data.
|
21 |
+
5. Done ;)
|
22 |
|
23 |
+
Use this imported site as a base for your project and don't waste time starting from scratch!
|
24 |
|
25 |
+
_<a href="https://wpastra.com/ready-websites/">See list of all available sites to import »</a>_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
== Installation ==
|
28 |
|
37 |
|
38 |
== Changelog ==
|
39 |
|
40 |
+
v1.0.13 - 9-Oct-2017
|
41 |
+
* New: Browsing the Astra Sites in the Admin panel is not faster with JS rendering.
|
42 |
+
|
43 |
v1.0.12 - 29-Sept-2017
|
44 |
* New: Added White Label support from <a href="https://wpastra.com/pro/">Astra Pro</a>.
|
45 |
* Improvement: Don't display sites from both the page builders in the same view.
|
99 |
|
100 |
v1.0.0
|
101 |
* Initial release
|
|