Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Astra Starter Sites |
Version | 1.0.11 |
Comparing to | |
See all releases |
Code changes from version 1.0.10 to 1.0.11
- astra-sites.php +2 -2
- inc/admin/class-astra-sites-page.php +37 -3
- inc/admin/view-astra-sites.php +0 -4
- inc/assets/css/admin.css +7 -12
- inc/assets/js/admin.js +1004 -699
- inc/classes/class-astra-sites.php +47 -40
- inc/classes/compatibility/{class-astra-sites-compatibility-astra-pro.php → astra-pro/class-astra-sites-compatibility-astra-pro.php} +0 -0
- inc/classes/compatibility/class-astra-sites-compatibility.php +69 -0
- inc/classes/compatibility/elementor/background-processing/class-astra-elementor-image-importer-process.php +64 -0
- inc/classes/compatibility/elementor/class-astra-sites-compatibility-elementor.php +144 -0
- inc/classes/compatibility/elementor/class-astra-sites-source-remote.php +302 -0
- inc/classes/compatibility/{class-astra-sites-compatibility-so-widgets.php → so-widgets-bundle/class-astra-sites-compatibility-so-widgets.php} +0 -0
- inc/classes/vendor/wp-async-request.php +164 -0
- inc/classes/vendor/wp-background-process.php +507 -0
- languages/astra-sites.pot +55 -39
- readme.txt +8 -1
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
|
@@ -15,7 +15,7 @@
|
|
15 |
* Set constants.
|
16 |
*/
|
17 |
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
18 |
-
define( 'ASTRA_SITES_VER', '1.0.
|
19 |
}
|
20 |
|
21 |
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.11
|
7 |
* Author: Brainstorm Force
|
8 |
* Author URI: http://www.brainstormforce.com
|
9 |
* Text Domain: astra-sites
|
15 |
* Set constants.
|
16 |
*/
|
17 |
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
18 |
+
define( 'ASTRA_SITES_VER', '1.0.11' );
|
19 |
}
|
20 |
|
21 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
inc/admin/class-astra-sites-page.php
CHANGED
@@ -87,8 +87,6 @@ if ( ! class_exists( 'Astra_Sites_Page' ) ) {
|
|
87 |
if ( isset( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], self::$plugin_slug ) !== false ) {
|
88 |
|
89 |
// Let extensions hook into saving.
|
90 |
-
do_action( 'astra_sites_page' );
|
91 |
-
|
92 |
self::save_settings();
|
93 |
}
|
94 |
|
@@ -108,7 +106,7 @@ if ( ! class_exists( 'Astra_Sites_Page' ) ) {
|
|
108 |
}
|
109 |
|
110 |
// Let extensions hook into saving.
|
111 |
-
do_action( '
|
112 |
}
|
113 |
|
114 |
/**
|
@@ -138,6 +136,23 @@ if ( ! class_exists( 'Astra_Sites_Page' ) ) {
|
|
138 |
<?php
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
/**
|
142 |
* Prints HTML content for tabs
|
143 |
*
|
@@ -149,6 +164,25 @@ if ( ! class_exists( 'Astra_Sites_Page' ) ) {
|
|
149 |
?>
|
150 |
<div class="nav-tab-wrapper">
|
151 |
<h1 class='astra-sites-title'> <?php echo esc_html( self::$menu_page_title ); ?> </h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
</div><!-- .nav-tab-wrapper -->
|
153 |
|
154 |
<?php
|
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 |
|
106 |
}
|
107 |
|
108 |
// Let extensions hook into saving.
|
109 |
+
do_action( 'astra_sites_save_settings' );
|
110 |
}
|
111 |
|
112 |
/**
|
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 |
*
|
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
|
inc/admin/view-astra-sites.php
CHANGED
@@ -7,10 +7,6 @@
|
|
7 |
|
8 |
defined( 'ABSPATH' ) or exit;
|
9 |
|
10 |
-
// Enqueue scripts.
|
11 |
-
wp_enqueue_script( 'astra-sites-admin' );
|
12 |
-
wp_enqueue_style( 'astra-sites-admin' );
|
13 |
-
|
14 |
/**
|
15 |
* Initial Demo List
|
16 |
*
|
7 |
|
8 |
defined( 'ABSPATH' ) or exit;
|
9 |
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* Initial Demo List
|
12 |
*
|
inc/assets/css/admin.css
CHANGED
@@ -1,15 +1,3 @@
|
|
1 |
-
.theme-browser .theme.focus .theme-actions,
|
2 |
-
.theme-browser .theme:focus .theme-actions,
|
3 |
-
.theme-browser .theme:hover .theme-actions {
|
4 |
-
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
|
5 |
-
opacity: 1
|
6 |
-
}
|
7 |
-
.theme-browser .theme .theme-screenshot:after {
|
8 |
-
content: "";
|
9 |
-
display: block;
|
10 |
-
padding-top: 66.66666%
|
11 |
-
}
|
12 |
-
|
13 |
.wrap .status,
|
14 |
.wrap .demo-type {
|
15 |
position: absolute;
|
@@ -88,6 +76,7 @@
|
|
88 |
}
|
89 |
.required-plugins .spinner {
|
90 |
float: none;
|
|
|
91 |
}
|
92 |
|
93 |
.expanded .wp-full-overlay-footer {
|
@@ -225,4 +214,10 @@
|
|
225 |
}
|
226 |
.astra-site-preview-on {
|
227 |
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
.wrap .status,
|
2 |
.wrap .demo-type {
|
3 |
position: absolute;
|
76 |
}
|
77 |
.required-plugins .spinner {
|
78 |
float: none;
|
79 |
+
margin: 0;
|
80 |
}
|
81 |
|
82 |
.expanded .wp-full-overlay-footer {
|
214 |
}
|
215 |
.astra-site-preview-on {
|
216 |
overflow: hidden;
|
217 |
+
}
|
218 |
+
|
219 |
+
#astra-sites-menu-page .notice {
|
220 |
+
margin-left: 0;
|
221 |
+
width: auto;
|
222 |
+
float: none;
|
223 |
}
|
inc/assets/js/admin.js
CHANGED
@@ -1,826 +1,1131 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
});
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
18 |
},
|
19 |
-
})
|
20 |
-
.done(function (demos) {
|
21 |
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
renderDemoGrid( demos.sites );
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
.fail(function () {
|
37 |
-
jQuery('body').removeClass('loading-content');
|
38 |
-
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.responseError+'</p>');
|
39 |
-
});
|
40 |
-
}
|
41 |
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
|
54 |
-
|
55 |
-
if( 0 >= remaining ) {
|
56 |
|
57 |
-
|
58 |
-
.removeAttr('data-import')
|
59 |
-
.addClass('button-primary')
|
60 |
-
.text( astraDemo.strings.importDemo );
|
61 |
-
}
|
62 |
-
break;
|
63 |
-
|
64 |
-
case 'upgrade':
|
65 |
-
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
66 |
-
|
67 |
-
jQuery('.astra-demo-import')
|
68 |
-
.addClass('go-pro button-primary')
|
69 |
-
.removeClass('astra-demo-import')
|
70 |
-
.attr('target', '_blank')
|
71 |
-
.attr('href', astraDemo.getUpgradeURL + demo_slug )
|
72 |
-
.text( astraDemo.getUpgradeText )
|
73 |
-
.append('<i class="dashicons dashicons-external"></i>');
|
74 |
-
break;
|
75 |
-
|
76 |
-
default:
|
77 |
-
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
78 |
-
|
79 |
-
jQuery('.astra-demo-import')
|
80 |
-
.addClass('go-pro button-primary')
|
81 |
-
.removeClass('astra-demo-import')
|
82 |
-
.attr('target', '_blank')
|
83 |
-
.attr('href', astraDemo.getProURL )
|
84 |
-
.text( astraDemo.getProText )
|
85 |
-
.append('<i class="dashicons dashicons-external"></i>');
|
86 |
-
break;
|
87 |
-
}
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
function resetPagedCount() {
|
92 |
-
categoryId = jQuery('.astra-category.filter-links li .current').data('id');
|
93 |
-
jQuery('body').attr('data-astra-demo-paged', '1');
|
94 |
-
jQuery('body').attr('data-astra-site-category', categoryId);
|
95 |
-
jQuery('body').attr('data-astra-demo-search', '');
|
96 |
-
jQuery('body').attr('data-scrolling', false);
|
97 |
-
jQuery('body').attr( 'data-required-plugins', 0 )
|
98 |
-
}
|
99 |
-
|
100 |
-
function updatedPagedCount() {
|
101 |
-
paged = parseInt(jQuery('body').attr('data-astra-demo-paged'));
|
102 |
-
jQuery('body').attr('data-astra-demo-paged', paged + 1);
|
103 |
-
window.setTimeout(function () {
|
104 |
-
jQuery('body').data('scrolling', false);
|
105 |
-
}, 800);
|
106 |
-
}
|
107 |
-
|
108 |
-
jQuery(document).scroll(function (event) {
|
109 |
-
var scrollDistance = jQuery(window).scrollTop();
|
110 |
-
|
111 |
-
var themesBottom = Math.abs(jQuery(window).height() - jQuery('.themes').offset().top - jQuery('.themes').height());
|
112 |
-
themesBottom = themesBottom * 20 / 100;
|
113 |
-
|
114 |
-
ajaxLoading = jQuery('body').data('scrolling');
|
115 |
-
|
116 |
-
if (scrollDistance > themesBottom && ajaxLoading == false) {
|
117 |
-
updatedPagedCount();
|
118 |
-
jQuery('body').data('scrolling', true);
|
119 |
-
body = jQuery('body');
|
120 |
-
id = body.attr('data-astra-site-category');
|
121 |
-
search = body.attr('data-astra-demo-search');
|
122 |
-
paged = body.attr('data-astra-demo-paged');
|
123 |
-
|
124 |
-
if (search !== '') {
|
125 |
-
id = '';
|
126 |
-
} else {
|
127 |
-
search = '';
|
128 |
-
}
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
var astra_page_builder = jQuery('.filter-links.astra-page-builder'),
|
133 |
-
astra_category = jQuery('.filter-links.astra-category'),
|
134 |
-
page_builder_id = astra_page_builder.find('.current').data('id'),
|
135 |
-
category_id = astra_category.find('.current').data('id');
|
136 |
-
|
137 |
-
jQuery.ajax({
|
138 |
-
url: astraDemo.ajaxurl,
|
139 |
-
type: 'POST',
|
140 |
-
dataType: 'json',
|
141 |
-
data: {
|
142 |
-
action: 'astra-list-sites',
|
143 |
-
paged: paged,
|
144 |
-
search: search,
|
145 |
-
page_builder_id : page_builder_id,
|
146 |
-
category_id : category_id,
|
147 |
-
},
|
148 |
-
})
|
149 |
-
.done(function (demos) {
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
161 |
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
*/
|
167 |
-
jQuery(document).on('click', '.theme-browser .theme-screenshot, .theme-browser .more-details, .theme-browser .install-theme-preview', function (event) {
|
168 |
-
event.preventDefault();
|
169 |
|
170 |
-
|
171 |
-
|
172 |
|
173 |
-
|
|
|
174 |
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
177 |
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
});
|
186 |
|
187 |
-
jQuery(
|
188 |
-
event.preventDefault();
|
189 |
-
currentDemo = jQuery('.theme-preview-on')
|
190 |
-
currentDemo.removeClass('theme-preview-on');
|
191 |
-
nextDemo = currentDemo.next('.theme');
|
192 |
-
nextDemo.addClass('theme-preview-on');
|
193 |
|
194 |
-
|
|
|
|
|
|
|
195 |
|
196 |
-
|
197 |
|
198 |
-
|
199 |
-
event.preventDefault();
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
prevDemo.addClass('theme-preview-on');
|
205 |
|
206 |
-
|
207 |
-
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
* @since 4.6.0
|
213 |
-
*
|
214 |
-
* @param {Event} event Event interface.
|
215 |
-
*/
|
216 |
-
jQuery(document).on('click', '.install-now', function (event) {
|
217 |
-
event.preventDefault();
|
218 |
|
219 |
-
|
220 |
-
|
|
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
}
|
225 |
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
-
|
230 |
-
var $message = $( '.install-now.updating-message' );
|
231 |
|
232 |
-
|
233 |
-
.removeClass( 'updating-message' )
|
234 |
-
.text( wp.updates.l10n.installNow );
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
}
|
239 |
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
243 |
|
244 |
-
|
|
|
245 |
|
246 |
-
|
247 |
|
248 |
-
|
249 |
|
250 |
-
|
251 |
-
.addClass( 'button-primary' )
|
252 |
-
.html( wp.updates.l10n.installNow );
|
253 |
|
254 |
-
});
|
255 |
|
256 |
-
|
257 |
-
event.preventDefault();
|
258 |
|
259 |
-
|
260 |
-
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
261 |
-
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
262 |
|
263 |
-
|
264 |
-
|
|
|
|
|
265 |
|
266 |
-
|
267 |
-
.addClass('updating-message')
|
268 |
-
.html( astraDemo.strings.btnActivating );
|
269 |
|
270 |
-
|
271 |
-
|
|
|
272 |
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
data: {
|
277 |
-
'action' : 'astra-required-plugin-activate',
|
278 |
-
'init' : $init,
|
279 |
-
'options' : $siteOptions,
|
280 |
-
'enabledExtensions' : $enabledExtensions,
|
281 |
-
},
|
282 |
-
})
|
283 |
-
.done(function (result) {
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
-
|
292 |
-
astraDemo.requiredPluginsCount--;
|
293 |
-
enable_demo_import_button();
|
294 |
-
} else {
|
295 |
|
296 |
-
|
297 |
|
298 |
-
|
|
|
299 |
|
300 |
-
|
|
|
|
|
|
|
301 |
|
302 |
-
|
|
|
303 |
|
304 |
-
}
|
305 |
|
|
|
|
|
|
|
306 |
|
307 |
-
/**
|
308 |
-
* Click handler for plugin installs in plugin install view.
|
309 |
-
*
|
310 |
-
* @since 4.6.0
|
311 |
-
*
|
312 |
-
* @param {Event} event Event interface.
|
313 |
-
*/
|
314 |
-
jQuery(document).on('click', '.activate-now', function (event) {
|
315 |
-
event.preventDefault();
|
316 |
-
|
317 |
-
var $button = jQuery( event.target ),
|
318 |
-
$init = $button.data( 'init' );
|
319 |
-
|
320 |
-
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
321 |
-
return;
|
322 |
-
}
|
323 |
-
|
324 |
-
$button.addClass('updating-message button-primary')
|
325 |
-
.html( astraDemo.strings.btnActivating );
|
326 |
-
|
327 |
-
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
328 |
-
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
329 |
-
|
330 |
-
jQuery.ajax({
|
331 |
-
url: astraDemo.ajaxurl,
|
332 |
-
type: 'POST',
|
333 |
-
data: {
|
334 |
-
'action' : 'astra-required-plugin-activate',
|
335 |
-
'init' : $init,
|
336 |
-
'options' : $siteOptions,
|
337 |
-
'enabledExtensions' : $enabledExtensions,
|
338 |
},
|
339 |
-
})
|
340 |
-
.done(function (result) {
|
341 |
-
|
342 |
-
if( result.success ) {
|
343 |
-
$button.removeClass( 'button-primary activate-now updating-message' )
|
344 |
-
.attr('disabled', 'disabled')
|
345 |
-
.addClass('disabled')
|
346 |
-
.text( astraDemo.strings.btnActive );
|
347 |
-
|
348 |
-
// Enable Demo Import Button
|
349 |
-
astraDemo.requiredPluginsCount--;
|
350 |
-
enable_demo_import_button();
|
351 |
-
}
|
352 |
|
353 |
-
|
354 |
-
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
-
} );
|
358 |
-
|
359 |
-
function renderDemoPreview(anchor) {
|
360 |
-
|
361 |
-
var demoId = anchor.data('id') || '',
|
362 |
-
apiURL = anchor.data('demo-api') || '',
|
363 |
-
demoType = anchor.data('demo-type') || '',
|
364 |
-
demoURL = anchor.data('demo-url') || '',
|
365 |
-
screenshot = anchor.data('screenshot') || '',
|
366 |
-
demo_name = anchor.data('demo-name') || '',
|
367 |
-
demo_slug = anchor.data('demo-slug') || '',
|
368 |
-
content = anchor.data('content') || '',
|
369 |
-
requiredPlugins = anchor.data('required-plugins') || '',
|
370 |
-
astraSiteOptions = anchor.find('.astra-site-options').val() || '';
|
371 |
-
astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
|
372 |
-
|
373 |
-
var template = wp.template('astra-demo-preview');
|
374 |
-
|
375 |
-
templateData = [{
|
376 |
-
id : demoId,
|
377 |
-
astra_demo_type : demoType,
|
378 |
-
astra_demo_url : demoURL,
|
379 |
-
demo_api : apiURL,
|
380 |
-
screenshot : screenshot,
|
381 |
-
demo_name : demo_name,
|
382 |
-
slug : demo_slug,
|
383 |
-
content : content,
|
384 |
-
requiredPlugins : requiredPlugins,
|
385 |
-
astra_site_options : astraSiteOptions,
|
386 |
-
astra_enabled_extensions : astraEnabledExtensions,
|
387 |
-
}];
|
388 |
-
|
389 |
-
// Initial set count.
|
390 |
-
astraDemo.requiredPluginsCount = requiredPlugins.length || 0;
|
391 |
-
|
392 |
-
// delete any earlier fullscreen preview before we render new one.
|
393 |
-
jQuery('.theme-install-overlay').remove();
|
394 |
-
|
395 |
-
jQuery('#astra-sites-menu-page').append(template(templateData[0]));
|
396 |
-
jQuery('.theme-install-overlay').css('display', 'block');
|
397 |
-
checkNextPrevButtons();
|
398 |
-
|
399 |
-
var desc = jQuery('.theme-details');
|
400 |
-
var descHeight = parseInt( desc.outerHeight() );
|
401 |
-
var descBtn = jQuery('.theme-details-read-more');
|
402 |
-
|
403 |
-
if( jQuery.isArray( requiredPlugins ) ) {
|
404 |
-
|
405 |
-
if( descHeight >= 55 ) {
|
406 |
-
|
407 |
-
// Show button.
|
408 |
-
descBtn.css( 'display', 'inline-block' );
|
409 |
-
|
410 |
-
// Set height upto 3 line.
|
411 |
-
desc.css( 'height', 57 );
|
412 |
-
|
413 |
-
// Button Click.
|
414 |
-
descBtn.click(function(event) {
|
415 |
-
|
416 |
-
if( descBtn.hasClass('open') ) {
|
417 |
-
desc.animate({ height: 57 },
|
418 |
-
300, function() {
|
419 |
-
descBtn.removeClass('open');
|
420 |
-
descBtn.html( astraDemo.strings.DescExpand );
|
421 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
} else {
|
423 |
-
|
424 |
-
300, function() {
|
425 |
-
descBtn.addClass('open');
|
426 |
-
descBtn.html( astraDemo.strings.DescCollapse );
|
427 |
-
});
|
428 |
}
|
429 |
|
|
|
|
|
|
|
|
|
430 |
});
|
431 |
-
}
|
432 |
|
433 |
-
|
434 |
-
var $pluginsFilter = jQuery( '#plugin-filter' ),
|
435 |
-
data = {
|
436 |
-
_ajax_nonce : astraDemo._ajax_nonce,
|
437 |
-
required_plugins : requiredPlugins
|
438 |
-
};
|
439 |
-
|
440 |
-
jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
|
441 |
-
|
442 |
-
wp.ajax.post( 'astra-required-plugins', data ).done( function( response ) {
|
443 |
-
|
444 |
-
// Remove loader.
|
445 |
-
jQuery('.required-plugins').removeClass('loading').html('');
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Count remaining plugins.
|
449 |
-
* @type number
|
450 |
-
*/
|
451 |
-
var remaining_plugins = 0;
|
452 |
-
|
453 |
-
/**
|
454 |
-
* Not Installed
|
455 |
-
*
|
456 |
-
* List of not installed required plugins.
|
457 |
-
*/
|
458 |
-
if ( typeof response.notinstalled !== 'undefined' ) {
|
459 |
-
|
460 |
-
// Add not have installed plugins count.
|
461 |
-
remaining_plugins += parseInt( response.notinstalled.length );
|
462 |
-
|
463 |
-
jQuery( response.notinstalled ).each(function( index, plugin ) {
|
464 |
-
|
465 |
-
var output = '<div class="plugin-card ';
|
466 |
-
output += ' plugin-card-'+plugin.slug+'"';
|
467 |
-
output += ' data-slug="'+plugin.slug+'">';
|
468 |
-
output += ' <span class="title">'+plugin.name+'</span>';
|
469 |
-
output += ' <button class="button install-now"';
|
470 |
-
output += ' data-init="' + plugin.init + '"';
|
471 |
-
output += ' data-slug="' + plugin.slug + '"';
|
472 |
-
output += ' data-name="' + plugin.name + '">';
|
473 |
-
output += wp.updates.l10n.installNow;
|
474 |
-
output += ' </button>';
|
475 |
-
output += '</div>';
|
476 |
|
477 |
-
jQuery('.required-plugins').append(output);
|
478 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
}
|
|
|
481 |
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
|
489 |
-
|
490 |
-
remaining_plugins += parseInt( response.inactive.length );
|
491 |
|
492 |
-
|
|
|
493 |
|
494 |
-
|
495 |
-
output += ' plugin-card-'+plugin.slug+'"';
|
496 |
-
output += ' data-slug="'+plugin.slug+'">';
|
497 |
-
output += ' <span class="title">'+plugin.name+'</span>';
|
498 |
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
|
505 |
-
|
506 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
});
|
|
|
508 |
}
|
|
|
509 |
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
* List of not active required plugins.
|
514 |
-
*/
|
515 |
-
if ( typeof response.active !== 'undefined' ) {
|
516 |
-
|
517 |
-
jQuery( response.active ).each(function( index, plugin ) {
|
518 |
-
|
519 |
-
var output = '<div class="plugin-card ';
|
520 |
-
output += ' plugin-card-'+plugin.slug+'"';
|
521 |
-
output += ' data-slug="'+plugin.slug+'">';
|
522 |
-
output += ' <span class="title">'+plugin.name+'</span>';
|
523 |
-
output += ' <button class="button disabled"';
|
524 |
-
output += ' data-slug="' + plugin.slug + '"';
|
525 |
-
output += ' data-name="' + plugin.name + '">';
|
526 |
-
output += astraDemo.strings.btnActive;
|
527 |
-
output += ' </button>';
|
528 |
-
output += '</div>';
|
529 |
|
530 |
-
|
|
|
531 |
|
532 |
-
|
|
|
533 |
}
|
534 |
|
535 |
-
|
536 |
-
|
537 |
-
* @type number
|
538 |
-
*/
|
539 |
-
astraDemo.requiredPluginsCount = remaining_plugins;
|
540 |
-
enable_demo_import_button();
|
541 |
|
542 |
-
|
|
|
543 |
|
544 |
-
|
|
|
|
|
545 |
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
jQuery('.required-plugins-wrap').remove();
|
550 |
-
}
|
551 |
|
552 |
-
|
553 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
|
555 |
-
function
|
556 |
-
currentDemo = jQuery('.theme-preview-on');
|
557 |
-
nextDemo = currentDemo.nextAll('.theme').length;
|
558 |
-
prevDemo = currentDemo.prevAll('.theme').length;
|
559 |
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
|
|
565 |
|
566 |
-
|
567 |
-
jQuery('.previous-theme').addClass('disabled');
|
568 |
-
} else if (prevDemo != 0) {
|
569 |
-
jQuery('.previous-theme').removeClass('disabled');
|
570 |
-
}
|
571 |
|
572 |
-
|
573 |
-
}
|
574 |
|
575 |
-
jQuery(
|
576 |
-
event.preventDefault();
|
577 |
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
|
|
|
|
586 |
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
},
|
606 |
-
})
|
607 |
-
.done(function (demos) {
|
608 |
-
jQuery('.filter-count .count').text( demos.sites_count );
|
609 |
-
jQuery('body').removeClass('loading-content');
|
610 |
-
|
611 |
-
if ( demos.sites_count > 0 ) {
|
612 |
-
renderDemoGrid(demos.sites);
|
613 |
-
} else {
|
614 |
-
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.searchNoFound+'</p>');
|
615 |
-
}
|
616 |
-
})
|
617 |
-
.fail(function () {
|
618 |
-
jQuery('body').removeClass('loading-content');
|
619 |
-
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.responseError+'</p>');
|
620 |
-
});
|
621 |
|
622 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
|
624 |
-
|
625 |
-
|
626 |
-
$this = jQuery('#wp-filter-search-input').val();
|
627 |
|
628 |
-
|
629 |
-
|
630 |
-
id = 'all';
|
631 |
-
}
|
632 |
|
633 |
-
|
634 |
-
|
635 |
-
page_builder_id = astra_page_builder.find('.current').data('id'),
|
636 |
-
category_id = astra_category.find('.current').data('id');
|
637 |
-
|
638 |
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
renderDemoGrid(demos.sites);
|
669 |
-
} else {
|
670 |
-
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.searchNoFound+'</p>');
|
671 |
}
|
672 |
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
719 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
720 |
|
721 |
-
}
|
722 |
|
723 |
-
|
724 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
725 |
|
726 |
-
|
|
|
|
|
727 |
|
728 |
-
if (overlay.hasClass('expanded')) {
|
729 |
-
overlay.removeClass('expanded');
|
730 |
-
overlay.addClass('collapsed');
|
731 |
-
return;
|
732 |
-
}
|
733 |
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
}
|
739 |
-
});
|
740 |
|
741 |
-
|
742 |
-
|
743 |
|
744 |
-
|
745 |
-
disabled = $this.attr('data-import');
|
746 |
|
747 |
-
|
|
|
|
|
|
|
748 |
|
749 |
-
|
750 |
-
var pluginTitle = jQuery('.required-plugins-wrap h4');
|
751 |
-
pluginTitle.css({'background-color':'rgba(255, 235, 59, 0.20)'});
|
752 |
-
setTimeout(function() {
|
753 |
-
pluginTitle.css({'background-color':''});
|
754 |
-
}, 1000);
|
755 |
|
756 |
-
|
757 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
758 |
|
759 |
-
|
760 |
-
if( ! confirm( astraDemo.strings.importWarning ) ) {
|
761 |
-
return;
|
762 |
-
}
|
763 |
|
764 |
-
|
765 |
-
|
766 |
-
|
|
|
767 |
|
768 |
-
|
|
|
|
|
769 |
|
770 |
-
|
|
|
|
|
|
|
771 |
|
772 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
773 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
774 |
|
775 |
-
jQuery.ajax({
|
776 |
-
url: astraDemo.ajaxurl,
|
777 |
-
type: 'POST',
|
778 |
-
dataType: 'json',
|
779 |
-
data: {
|
780 |
-
action: 'astra-import-demo',
|
781 |
-
api_url: apiURL
|
782 |
},
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
jQuery
|
789 |
-
.
|
790 |
-
|
791 |
-
.removeClass('astra-demo-import')
|
792 |
-
.text( astraDemo.strings.viewSite )
|
793 |
-
.attr('target', '_blank')
|
794 |
-
.append('<i class="dashicons dashicons-external"></i>')
|
795 |
-
.attr('href', astraDemo.siteURL );
|
796 |
-
|
797 |
-
} else {
|
798 |
-
|
799 |
-
var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
|
800 |
-
output += ' <p>'+demos.message+'</p>';
|
801 |
-
output += ' <button type="button" class="notice-dismiss">';
|
802 |
-
output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
|
803 |
-
output += ' </button>';
|
804 |
-
output += '</div>';
|
805 |
-
|
806 |
-
jQuery('.install-theme-info').prepend( output );
|
807 |
-
|
808 |
-
// !important to add trigger.
|
809 |
-
// Which reinitialize the dismiss error message events.
|
810 |
-
jQuery(document).trigger('wp-updates-notice-added');
|
811 |
}
|
812 |
|
813 |
-
}
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
.attr('href', astraDemo.strings.importFailedURL );
|
821 |
-
|
822 |
-
jQuery('.wp-full-overlay-header .view-site').text( astraDemo.strings.importFailedBtnSmall ).append('<i class="dashicons dashicons-external"></i>');
|
823 |
-
jQuery('.footer-import-button-wrap .view-site').text( astraDemo.strings.importFailedBtnLarge ).append('<i class="dashicons dashicons-external"></i>');
|
824 |
});
|
825 |
|
826 |
-
});
|
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 |
|
78 |
+
(function($){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
+
AstraSites = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
_ref: null,
|
83 |
+
|
84 |
+
_iconUploader: null,
|
85 |
+
|
86 |
+
init: function()
|
87 |
+
{
|
88 |
+
this._bind();
|
89 |
+
this._resetPagedCount();
|
90 |
+
this._initial_load_demos();
|
91 |
+
},
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Binds events for the Astra Sites.
|
95 |
+
*
|
96 |
+
* @since 1.0.1
|
97 |
+
* @access private
|
98 |
+
* @method _bind
|
99 |
+
*/
|
100 |
+
_bind: function()
|
101 |
+
{
|
102 |
+
$( document ).on('scroll', AstraSites._scroll);
|
103 |
+
$( document ).on('click', '.astra-demo-import', AstraSites._importDemo);
|
104 |
+
$( document ).on('click', '.install-now', AstraSites._installNow);
|
105 |
+
$( document ).on('click', '.theme-browser .theme-screenshot, .theme-browser .more-details, .theme-browser .install-theme-preview', AstraSites._preview);
|
106 |
+
$( document ).on('click', '.collapse-sidebar', AstraSites._collapse);
|
107 |
+
$( document ).on('click', '.filter-links li a', AstraSites._filter);
|
108 |
+
$( document ).on('click', '.activate-now', AstraSites._activateNow);
|
109 |
+
$( document ).on('click', '.close-full-overlay', AstraSites._fullOverlay);
|
110 |
+
$( document ).on('click', '.next-theme', AstraSites._nextTheme);
|
111 |
+
$( document ).on('click', '.previous-theme', AstraSites._previousTheme);
|
112 |
+
$( document ).on('keyup input', '#wp-filter-search-input', AstraSites._serach);
|
113 |
+
$( document ).on('wp-plugin-installing', AstraSites._pluginInstalling);
|
114 |
+
$( document ).on('wp-plugin-install-error', AstraSites._installError);
|
115 |
+
$( document ).on('wp-plugin-install-success', AstraSites._installSuccess);
|
116 |
+
},
|
117 |
|
118 |
+
/**
|
119 |
+
* Previous Theme.
|
120 |
+
*/
|
121 |
+
_previousTheme: function (event) {
|
122 |
+
event.preventDefault();
|
123 |
|
124 |
+
currentDemo = jQuery('.theme-preview-on');
|
125 |
+
currentDemo.removeClass('theme-preview-on');
|
126 |
+
prevDemo = currentDemo.prev('.theme');
|
127 |
+
prevDemo.addClass('theme-preview-on');
|
|
|
|
|
|
|
128 |
|
129 |
+
AstraSites._renderDemoPreview(prevDemo);
|
130 |
+
},
|
131 |
|
132 |
+
_fullOverlay: function (event) {
|
133 |
+
event.preventDefault();
|
134 |
|
135 |
+
jQuery('.theme-install-overlay').css('display', 'none');
|
136 |
+
jQuery('.theme-install-overlay').remove();
|
137 |
+
jQuery('.theme-preview-on').removeClass('theme-preview-on');
|
138 |
+
jQuery('html').removeClass('astra-site-preview-on');
|
139 |
+
},
|
140 |
|
141 |
+
/**
|
142 |
+
* Next Theme.
|
143 |
+
*/
|
144 |
+
_nextTheme: function (event) {
|
145 |
+
event.preventDefault();
|
146 |
+
currentDemo = jQuery('.theme-preview-on')
|
147 |
+
currentDemo.removeClass('theme-preview-on');
|
148 |
+
nextDemo = currentDemo.next('.theme');
|
149 |
+
nextDemo.addClass('theme-preview-on');
|
150 |
+
|
151 |
+
AstraSites._renderDemoPreview( nextDemo );
|
152 |
+
},
|
153 |
|
154 |
+
/**
|
155 |
+
* Plugin Installation Error.
|
156 |
+
*/
|
157 |
+
_installError: function( event, response ) {
|
|
|
158 |
|
159 |
+
var $card = jQuery( '.plugin-card-' + response.slug );
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
$card
|
162 |
+
.addClass( 'button-primary' )
|
163 |
+
.html( wp.updates.l10n.installNow );
|
164 |
+
},
|
165 |
|
166 |
+
_installSuccess: function( event, response ) {
|
167 |
|
168 |
+
event.preventDefault();
|
|
|
169 |
|
170 |
+
var $message = jQuery( '.plugin-card-' + response.slug ).find( '.button' );
|
171 |
+
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
172 |
+
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
|
|
173 |
|
174 |
+
// Transform the 'Install' button into an 'Activate' button.
|
175 |
+
var $init = $message.data('init');
|
176 |
|
177 |
+
$message.removeClass( 'install-now installed button-disabled updated-message' )
|
178 |
+
.addClass('updating-message')
|
179 |
+
.html( astraDemo.strings.btnActivating );
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
+
// Reset not installed plugins list.
|
182 |
+
var pluginsList = astraDemo.requiredPlugins.notinstalled;
|
183 |
+
astraDemo.requiredPlugins.notinstalled = AstraSites._removePluginFromQueue( response.slug, pluginsList );
|
184 |
|
185 |
+
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
|
186 |
+
setTimeout( function() {
|
|
|
187 |
|
188 |
+
jQuery.ajax({
|
189 |
+
url: astraDemo.ajaxurl,
|
190 |
+
type: 'POST',
|
191 |
+
data: {
|
192 |
+
'action' : 'astra-required-plugin-activate',
|
193 |
+
'init' : $init,
|
194 |
+
'options' : $siteOptions,
|
195 |
+
'enabledExtensions' : $enabledExtensions,
|
196 |
+
},
|
197 |
+
})
|
198 |
+
.done(function (result) {
|
199 |
|
200 |
+
if( result.success ) {
|
|
|
201 |
|
202 |
+
var pluginsList = astraDemo.requiredPlugins.inactive;
|
|
|
|
|
203 |
|
204 |
+
// Reset not installed plugins list.
|
205 |
+
astraDemo.requiredPlugins.inactive = AstraSites._removePluginFromQueue( response.slug, pluginsList );
|
|
|
206 |
|
207 |
+
$message.removeClass( 'button-primary install-now activate-now updating-message' )
|
208 |
+
.attr('disabled', 'disabled')
|
209 |
+
.addClass('disabled')
|
210 |
+
.text( astraDemo.strings.btnActive );
|
211 |
|
212 |
+
// Enable Demo Import Button
|
213 |
+
AstraSites._enable_demo_import_button();
|
214 |
|
215 |
+
} else {
|
216 |
|
217 |
+
$message.removeClass( 'updating-message' );
|
218 |
|
219 |
+
}
|
|
|
|
|
220 |
|
221 |
+
});
|
222 |
|
223 |
+
}, 1200 );
|
|
|
224 |
|
225 |
+
},
|
|
|
|
|
226 |
|
227 |
+
/**
|
228 |
+
* Render Demo Preview
|
229 |
+
*/
|
230 |
+
_activateNow: function( eventn ) {
|
231 |
|
232 |
+
event.preventDefault();
|
|
|
|
|
233 |
|
234 |
+
var $button = jQuery( event.target ),
|
235 |
+
$init = $button.data( 'init' ),
|
236 |
+
$slug = $button.data( 'slug' );
|
237 |
|
238 |
+
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
239 |
+
return;
|
240 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
+
$button.addClass('updating-message button-primary')
|
243 |
+
.html( astraDemo.strings.btnActivating );
|
244 |
+
|
245 |
+
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
246 |
+
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
247 |
+
|
248 |
+
jQuery.ajax({
|
249 |
+
url: astraDemo.ajaxurl,
|
250 |
+
type: 'POST',
|
251 |
+
data: {
|
252 |
+
'action' : 'astra-required-plugin-activate',
|
253 |
+
'init' : $init,
|
254 |
+
'options' : $siteOptions,
|
255 |
+
'enabledExtensions' : $enabledExtensions,
|
256 |
+
},
|
257 |
+
})
|
258 |
+
.done(function (result) {
|
259 |
|
260 |
+
if( result.success ) {
|
|
|
|
|
|
|
261 |
|
262 |
+
var pluginsList = astraDemo.requiredPlugins.inactive;
|
263 |
|
264 |
+
// Reset not installed plugins list.
|
265 |
+
astraDemo.requiredPlugins.inactive = AstraSites._removePluginFromQueue( $slug, pluginsList );
|
266 |
|
267 |
+
$button.removeClass( 'button-primary install-now activate-now updating-message' )
|
268 |
+
.attr('disabled', 'disabled')
|
269 |
+
.addClass('disabled')
|
270 |
+
.text( astraDemo.strings.btnActive );
|
271 |
|
272 |
+
// Enable Demo Import Button
|
273 |
+
AstraSites._enable_demo_import_button();
|
274 |
|
275 |
+
}
|
276 |
|
277 |
+
})
|
278 |
+
.fail(function () {
|
279 |
+
});
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
+
_renderDemoPreview: function(anchor) {
|
284 |
+
|
285 |
+
var demoId = anchor.data('id') || '',
|
286 |
+
apiURL = anchor.data('demo-api') || '',
|
287 |
+
demoType = anchor.data('demo-type') || '',
|
288 |
+
demoURL = anchor.data('demo-url') || '',
|
289 |
+
screenshot = anchor.data('screenshot') || '',
|
290 |
+
demo_name = anchor.data('demo-name') || '',
|
291 |
+
demo_slug = anchor.data('demo-slug') || '',
|
292 |
+
content = anchor.data('content') || '',
|
293 |
+
requiredPlugins = anchor.data('required-plugins') || '',
|
294 |
+
astraSiteOptions = anchor.find('.astra-site-options').val() || '';
|
295 |
+
astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
|
296 |
+
|
297 |
+
var template = wp.template('astra-demo-preview');
|
298 |
+
|
299 |
+
templateData = [{
|
300 |
+
id : demoId,
|
301 |
+
astra_demo_type : demoType,
|
302 |
+
astra_demo_url : demoURL,
|
303 |
+
demo_api : apiURL,
|
304 |
+
screenshot : screenshot,
|
305 |
+
demo_name : demo_name,
|
306 |
+
slug : demo_slug,
|
307 |
+
content : content,
|
308 |
+
required_plugins : JSON.stringify(requiredPlugins),
|
309 |
+
astra_site_options : astraSiteOptions,
|
310 |
+
astra_enabled_extensions : astraEnabledExtensions,
|
311 |
+
}];
|
312 |
+
|
313 |
+
// delete any earlier fullscreen preview before we render new one.
|
314 |
+
jQuery('.theme-install-overlay').remove();
|
315 |
+
|
316 |
+
jQuery('#astra-sites-menu-page').append(template(templateData[0]));
|
317 |
+
jQuery('.theme-install-overlay').css('display', 'block');
|
318 |
+
AstraSites._checkNextPrevButtons();
|
319 |
+
|
320 |
+
var desc = jQuery('.theme-details');
|
321 |
+
var descHeight = parseInt( desc.outerHeight() );
|
322 |
+
var descBtn = jQuery('.theme-details-read-more');
|
323 |
+
|
324 |
+
if( jQuery.isArray( requiredPlugins ) ) {
|
325 |
+
|
326 |
+
if( descHeight >= 55 ) {
|
327 |
+
|
328 |
+
// Show button.
|
329 |
+
descBtn.css( 'display', 'inline-block' );
|
330 |
+
|
331 |
+
// Set height upto 3 line.
|
332 |
+
desc.css( 'height', 57 );
|
333 |
+
|
334 |
+
// Button Click.
|
335 |
+
descBtn.click(function(event) {
|
336 |
+
|
337 |
+
if( descBtn.hasClass('open') ) {
|
338 |
+
desc.animate({ height: 57 },
|
339 |
+
300, function() {
|
340 |
+
descBtn.removeClass('open');
|
341 |
+
descBtn.html( astraDemo.strings.DescExpand );
|
342 |
+
});
|
343 |
+
} else {
|
344 |
+
desc.animate({ height: descHeight },
|
345 |
+
300, function() {
|
346 |
+
descBtn.addClass('open');
|
347 |
+
descBtn.html( astraDemo.strings.DescCollapse );
|
348 |
+
});
|
349 |
+
}
|
350 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
});
|
352 |
+
}
|
353 |
+
|
354 |
+
// or
|
355 |
+
var $pluginsFilter = jQuery( '#plugin-filter' ),
|
356 |
+
data = {
|
357 |
+
_ajax_nonce : astraDemo._ajax_nonce,
|
358 |
+
required_plugins : requiredPlugins
|
359 |
+
};
|
360 |
+
|
361 |
+
jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
|
362 |
+
|
363 |
+
wp.ajax.post( 'astra-required-plugins', data ).done( function( response ) {
|
364 |
+
|
365 |
+
// Remove loader.
|
366 |
+
jQuery('.required-plugins').removeClass('loading').html('');
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Count remaining plugins.
|
370 |
+
* @type number
|
371 |
+
*/
|
372 |
+
var remaining_plugins = 0;
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Not Installed
|
376 |
+
*
|
377 |
+
* List of not installed required plugins.
|
378 |
+
*/
|
379 |
+
if ( typeof response.notinstalled !== 'undefined' ) {
|
380 |
+
|
381 |
+
// Add not have installed plugins count.
|
382 |
+
remaining_plugins += parseInt( response.notinstalled.length );
|
383 |
+
|
384 |
+
jQuery( response.notinstalled ).each(function( index, plugin ) {
|
385 |
+
|
386 |
+
var output = '<div class="plugin-card ';
|
387 |
+
output += ' plugin-card-'+plugin.slug+'"';
|
388 |
+
output += ' data-slug="'+plugin.slug+'"';
|
389 |
+
output += ' data-init="'+plugin.init+'">';
|
390 |
+
output += ' <span class="title">'+plugin.name+'</span>';
|
391 |
+
output += ' <button class="button install-now"';
|
392 |
+
output += ' data-init="' + plugin.init + '"';
|
393 |
+
output += ' data-slug="' + plugin.slug + '"';
|
394 |
+
output += ' data-name="' + plugin.name + '">';
|
395 |
+
output += wp.updates.l10n.installNow;
|
396 |
+
output += ' </button>';
|
397 |
+
// output += ' <span class="dashicons-no dashicons"></span>';
|
398 |
+
output += '</div>';
|
399 |
+
|
400 |
+
jQuery('.required-plugins').append(output);
|
401 |
+
|
402 |
+
});
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Inactive
|
407 |
+
*
|
408 |
+
* List of not inactive required plugins.
|
409 |
+
*/
|
410 |
+
if ( typeof response.inactive !== 'undefined' ) {
|
411 |
+
|
412 |
+
// Add inactive plugins count.
|
413 |
+
remaining_plugins += parseInt( response.inactive.length );
|
414 |
+
|
415 |
+
jQuery( response.inactive ).each(function( index, plugin ) {
|
416 |
+
|
417 |
+
var output = '<div class="plugin-card ';
|
418 |
+
output += ' plugin-card-'+plugin.slug+'"';
|
419 |
+
output += ' data-slug="'+plugin.slug+'"';
|
420 |
+
output += ' data-init="'+plugin.init+'">';
|
421 |
+
output += ' <span class="title">'+plugin.name+'</span>';
|
422 |
+
output += ' <button class="button activate-now button-primary"';
|
423 |
+
output += ' data-init="' + plugin.init + '"';
|
424 |
+
output += ' data-slug="' + plugin.slug + '"';
|
425 |
+
output += ' data-name="' + plugin.name + '">';
|
426 |
+
output += wp.updates.l10n.activatePlugin;
|
427 |
+
output += ' </button>';
|
428 |
+
// output += ' <span class="dashicons-no dashicons"></span>';
|
429 |
+
output += '</div>';
|
430 |
+
|
431 |
+
jQuery('.required-plugins').append(output);
|
432 |
+
|
433 |
+
});
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Active
|
438 |
+
*
|
439 |
+
* List of not active required plugins.
|
440 |
+
*/
|
441 |
+
if ( typeof response.active !== 'undefined' ) {
|
442 |
+
|
443 |
+
jQuery( response.active ).each(function( index, plugin ) {
|
444 |
+
|
445 |
+
var output = '<div class="plugin-card ';
|
446 |
+
output += ' plugin-card-'+plugin.slug+'"';
|
447 |
+
output += ' data-slug="'+plugin.slug+'"';
|
448 |
+
output += ' data-init="'+plugin.init+'">';
|
449 |
+
output += ' <span class="title">'+plugin.name+'</span>';
|
450 |
+
output += ' <button class="button disabled"';
|
451 |
+
output += ' data-slug="' + plugin.slug + '"';
|
452 |
+
output += ' data-name="' + plugin.name + '">';
|
453 |
+
output += astraDemo.strings.btnActive;
|
454 |
+
output += ' </button>';
|
455 |
+
// output += ' <span class="dashicons-yes dashicons"></span>';
|
456 |
+
output += '</div>';
|
457 |
+
|
458 |
+
jQuery('.required-plugins').append(output);
|
459 |
+
|
460 |
+
});
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Enable Demo Import Button
|
465 |
+
* @type number
|
466 |
+
*/
|
467 |
+
astraDemo.requiredPlugins = response;
|
468 |
+
AstraSites._enable_demo_import_button();
|
469 |
+
|
470 |
+
} );
|
471 |
+
|
472 |
+
} else {
|
473 |
+
|
474 |
+
// Enable Demo Import Button
|
475 |
+
AstraSites._enable_demo_import_button( demoType );
|
476 |
+
jQuery('.required-plugins-wrap').remove();
|
477 |
+
}
|
478 |
+
|
479 |
+
return;
|
480 |
+
},
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Check Next Previous Buttons.
|
484 |
+
*/
|
485 |
+
_checkNextPrevButtons: function() {
|
486 |
+
currentDemo = jQuery('.theme-preview-on');
|
487 |
+
nextDemo = currentDemo.nextAll('.theme').length;
|
488 |
+
prevDemo = currentDemo.prevAll('.theme').length;
|
489 |
+
|
490 |
+
if (nextDemo == 0) {
|
491 |
+
jQuery('.next-theme').addClass('disabled');
|
492 |
+
} else if (nextDemo != 0) {
|
493 |
+
jQuery('.next-theme').removeClass('disabled');
|
494 |
+
}
|
495 |
+
|
496 |
+
if (prevDemo == 0) {
|
497 |
+
jQuery('.previous-theme').addClass('disabled');
|
498 |
+
} else if (prevDemo != 0) {
|
499 |
+
jQuery('.previous-theme').removeClass('disabled');
|
500 |
+
}
|
501 |
+
|
502 |
+
return;
|
503 |
+
},
|
504 |
+
|
505 |
+
/**
|
506 |
+
* Filter Demo by Category.
|
507 |
+
*/
|
508 |
+
_filter: function(event) {
|
509 |
+
event.preventDefault();
|
510 |
+
|
511 |
+
$this = jQuery(this);
|
512 |
+
$this.parent('li').siblings().find('.current').removeClass('current');
|
513 |
+
$this.addClass('current');
|
514 |
+
|
515 |
+
var astra_page_builder = jQuery('.filter-links.astra-page-builder'),
|
516 |
+
astra_category = jQuery('.filter-links.astra-category'),
|
517 |
+
page_builder_id = astra_page_builder.find('.current').data('id'),
|
518 |
+
category_id = astra_category.find('.current').data('id');
|
519 |
+
|
520 |
+
AstraSites._resetPagedCount();
|
521 |
+
|
522 |
+
paged = parseInt(jQuery('body').attr('data-astra-demo-paged'));
|
523 |
+
|
524 |
+
jQuery('body').addClass('loading-content');
|
525 |
+
jQuery('.theme-browser .theme').remove();
|
526 |
+
jQuery('.no-themes').remove();
|
527 |
+
jQuery('#wp-filter-search-input').val('');
|
528 |
+
|
529 |
+
jQuery.ajax({
|
530 |
+
url: astraDemo.ajaxurl,
|
531 |
+
type: 'POST',
|
532 |
+
dataType: 'json',
|
533 |
+
data: {
|
534 |
+
action: 'astra-list-sites',
|
535 |
+
paged: paged,
|
536 |
+
page_builder_id : page_builder_id,
|
537 |
+
category_id : category_id,
|
538 |
+
},
|
539 |
+
})
|
540 |
+
.done(function (demos) {
|
541 |
+
|
542 |
+
jQuery('.filter-count .count').text( demos.sites_count );
|
543 |
+
jQuery('body').removeClass('loading-content');
|
544 |
+
|
545 |
+
if ( demos.sites_count > 0 ) {
|
546 |
+
AstraSites._renderDemoGrid(demos.sites);
|
547 |
} else {
|
548 |
+
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.searchNoFound+'</p>');
|
|
|
|
|
|
|
|
|
549 |
}
|
550 |
|
551 |
+
})
|
552 |
+
.fail(function () {
|
553 |
+
jQuery('body').removeClass('loading-content');
|
554 |
+
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.responseError+'</p>');
|
555 |
});
|
|
|
556 |
|
557 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
|
|
|
559 |
|
560 |
+
/**
|
561 |
+
* Search Site.
|
562 |
+
*/
|
563 |
+
_serach: function() {
|
564 |
+
$this = jQuery('#wp-filter-search-input').val();
|
565 |
+
|
566 |
+
id = '';
|
567 |
+
if ($this.length < 2) {
|
568 |
+
id = 'all';
|
569 |
+
}
|
570 |
+
|
571 |
+
var astra_page_builder = jQuery('.filter-links.astra-page-builder'),
|
572 |
+
astra_category = jQuery('.filter-links.astra-category'),
|
573 |
+
page_builder_id = astra_page_builder.find('.current').data('id'),
|
574 |
+
category_id = astra_category.find('.current').data('id');
|
575 |
+
|
576 |
+
|
577 |
+
window.clearTimeout(AstraSites._ref);
|
578 |
+
AstraSites._ref = window.setTimeout(function () {
|
579 |
+
AstraSites._ref = null;
|
580 |
+
|
581 |
+
AstraSites._resetPagedCount();
|
582 |
+
jQuery('body').addClass('loading-content');
|
583 |
+
jQuery('.theme-browser .theme').remove();
|
584 |
+
jQuery('.no-themes').remove();
|
585 |
+
jQuery('body').attr('data-astra-demo-search', $this);
|
586 |
+
|
587 |
+
jQuery.ajax({
|
588 |
+
url: astraDemo.ajaxurl,
|
589 |
+
type: 'POST',
|
590 |
+
dataType: 'json',
|
591 |
+
data: {
|
592 |
+
action: 'astra-list-sites',
|
593 |
+
search: $this,
|
594 |
+
page_builder_id : page_builder_id,
|
595 |
+
category_id : category_id,
|
596 |
+
},
|
597 |
+
})
|
598 |
+
.done(function (demos) {
|
599 |
+
jQuery('body').removeClass('loading-content');
|
600 |
+
|
601 |
+
jQuery('.filter-count .count').text( demos.sites_count );
|
602 |
+
|
603 |
+
if ( demos.sites_count > 0 ) {
|
604 |
+
AstraSites._renderDemoGrid(demos.sites);
|
605 |
+
} else {
|
606 |
+
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.searchNoFound+'</p>');
|
607 |
+
}
|
608 |
+
|
609 |
+
})
|
610 |
+
.fail(function () {
|
611 |
+
jQuery('body').removeClass('loading-content');
|
612 |
+
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.responseError+'.</p>');
|
613 |
});
|
614 |
+
|
615 |
+
|
616 |
+
}, 500);
|
617 |
+
|
618 |
+
},
|
619 |
+
|
620 |
+
/**
|
621 |
+
* Collapse Sidebar.
|
622 |
+
*/
|
623 |
+
_collapse: function() {
|
624 |
+
event.preventDefault();
|
625 |
+
|
626 |
+
overlay = jQuery('.wp-full-overlay');
|
627 |
+
|
628 |
+
if (overlay.hasClass('expanded')) {
|
629 |
+
overlay.removeClass('expanded');
|
630 |
+
overlay.addClass('collapsed');
|
631 |
+
return;
|
632 |
+
}
|
633 |
+
|
634 |
+
if (overlay.hasClass('collapsed')) {
|
635 |
+
overlay.removeClass('collapsed');
|
636 |
+
overlay.addClass('expanded');
|
637 |
+
return;
|
638 |
}
|
639 |
+
},
|
640 |
|
641 |
+
/**
|
642 |
+
* Individual Site Preview
|
643 |
+
*
|
644 |
+
* On click on image, more link & preview button.
|
645 |
+
*/
|
646 |
+
_preview: function() {
|
647 |
|
648 |
+
event.preventDefault();
|
|
|
649 |
|
650 |
+
$this = jQuery(this).parents('.theme');
|
651 |
+
$this.addClass('theme-preview-on');
|
652 |
|
653 |
+
jQuery('html').addClass('astra-site-preview-on');
|
|
|
|
|
|
|
654 |
|
655 |
+
AstraSites._renderDemoPreview($this);
|
656 |
+
},
|
657 |
+
|
658 |
+
_scroll: function(event) {
|
659 |
+
|
660 |
+
var scrollDistance = jQuery(window).scrollTop();
|
661 |
+
|
662 |
+
var themesBottom = Math.abs(jQuery(window).height() - jQuery('.themes').offset().top - jQuery('.themes').height());
|
663 |
+
themesBottom = themesBottom * 20 / 100;
|
664 |
+
|
665 |
+
ajaxLoading = jQuery('body').data('scrolling');
|
666 |
+
|
667 |
+
if (scrollDistance > themesBottom && ajaxLoading == false) {
|
668 |
+
AstraSites._updatedPagedCount();
|
669 |
|
670 |
+
jQuery('body').data('scrolling', true);
|
671 |
|
672 |
+
var body = jQuery('body'),
|
673 |
+
id = body.attr('data-astra-site-category'),
|
674 |
+
search = body.attr('data-astra-demo-search'),
|
675 |
+
paged = body.attr('data-astra-demo-paged');
|
676 |
+
|
677 |
+
if (search !== '') {
|
678 |
+
id = '';
|
679 |
+
} else {
|
680 |
+
search = '';
|
681 |
+
}
|
682 |
+
|
683 |
+
jQuery('.no-themes').remove();
|
684 |
+
|
685 |
+
var astra_page_builder = jQuery('.filter-links.astra-page-builder'),
|
686 |
+
astra_category = jQuery('.filter-links.astra-category'),
|
687 |
+
page_builder_id = astra_page_builder.find('.current').data('id'),
|
688 |
+
category_id = astra_category.find('.current').data('id');
|
689 |
+
|
690 |
+
jQuery.ajax({
|
691 |
+
url: astraDemo.ajaxurl,
|
692 |
+
type: 'POST',
|
693 |
+
dataType: 'json',
|
694 |
+
data: {
|
695 |
+
action: 'astra-list-sites',
|
696 |
+
paged: paged,
|
697 |
+
search: search,
|
698 |
+
page_builder_id : page_builder_id,
|
699 |
+
category_id : category_id,
|
700 |
+
},
|
701 |
+
})
|
702 |
+
.done(function (demos) {
|
703 |
+
jQuery('body').removeClass('loading-content');
|
704 |
+
if ( demos.sites_count > 0 ) {
|
705 |
+
AstraSites._renderDemoGrid(demos.sites);
|
706 |
+
}
|
707 |
+
})
|
708 |
+
.fail(function () {
|
709 |
+
jQuery('body').removeClass('loading-content');
|
710 |
+
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.responseError+'</p>');
|
711 |
});
|
712 |
+
|
713 |
}
|
714 |
+
},
|
715 |
|
716 |
+
_installNow: function(event)
|
717 |
+
{
|
718 |
+
event.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
719 |
|
720 |
+
var $button = jQuery( event.target ),
|
721 |
+
$document = jQuery(document);
|
722 |
|
723 |
+
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
724 |
+
return;
|
725 |
}
|
726 |
|
727 |
+
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
|
728 |
+
wp.updates.requestFilesystemCredentials( event );
|
|
|
|
|
|
|
|
|
729 |
|
730 |
+
$document.on( 'credential-modal-cancel', function() {
|
731 |
+
var $message = $( '.install-now.updating-message' );
|
732 |
|
733 |
+
$message
|
734 |
+
.removeClass( 'updating-message' )
|
735 |
+
.text( wp.updates.l10n.installNow );
|
736 |
|
737 |
+
wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
|
738 |
+
} );
|
739 |
+
}
|
|
|
|
|
740 |
|
741 |
+
wp.updates.installPlugin( {
|
742 |
+
slug: $button.data( 'slug' )
|
743 |
+
} );
|
744 |
+
},
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Update Page Count.
|
748 |
+
*/
|
749 |
+
_updatedPagedCount: function() {
|
750 |
+
paged = parseInt(jQuery('body').attr('data-astra-demo-paged'));
|
751 |
+
jQuery('body').attr('data-astra-demo-paged', paged + 1);
|
752 |
+
window.setTimeout(function () {
|
753 |
+
jQuery('body').data('scrolling', false);
|
754 |
+
}, 800);
|
755 |
+
},
|
756 |
|
757 |
+
_resetPagedCount: function() {
|
|
|
|
|
|
|
758 |
|
759 |
+
categoryId = jQuery('.astra-category.filter-links li .current').data('id');
|
760 |
+
jQuery('body').attr('data-astra-demo-paged', '1');
|
761 |
+
jQuery('body').attr('data-astra-site-category', categoryId);
|
762 |
+
jQuery('body').attr('data-astra-demo-search', '');
|
763 |
+
jQuery('body').attr('data-scrolling', false);
|
764 |
+
jQuery('body').attr( 'data-required-plugins', 0 )
|
765 |
|
766 |
+
},
|
|
|
|
|
|
|
|
|
767 |
|
768 |
+
_initial_load_demos: function() {
|
|
|
769 |
|
770 |
+
jQuery('body').addClass('loading-content');
|
|
|
771 |
|
772 |
+
jQuery.ajax({
|
773 |
+
url: astraDemo.ajaxurl,
|
774 |
+
type: 'POST',
|
775 |
+
dataType: 'json',
|
776 |
+
data: {
|
777 |
+
action : 'astra-list-sites',
|
778 |
+
paged : '1',
|
779 |
+
},
|
780 |
+
})
|
781 |
+
.done(function (demos) {
|
782 |
|
783 |
+
jQuery('body').removeClass('loading-content');
|
784 |
+
jQuery('.filter-count .count').text( demos.sites_count );
|
785 |
+
|
786 |
+
// Has sites?
|
787 |
+
if ( demos.sites_count > 0 ) {
|
788 |
+
AstraSites._renderDemoGrid( demos.sites );
|
789 |
+
|
790 |
+
// Something is wrong in API request.
|
791 |
+
} else {
|
792 |
+
var template = wp.template('astra-no-demos');
|
793 |
+
jQuery('.themes').append( template );
|
794 |
+
}
|
795 |
+
|
796 |
+
})
|
797 |
+
.fail(function () {
|
798 |
+
jQuery('body').removeClass('loading-content');
|
799 |
+
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.responseError+'</p>');
|
800 |
+
});
|
801 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
802 |
|
803 |
+
/**
|
804 |
+
* Render Demo Grid.
|
805 |
+
*/
|
806 |
+
_renderDemoGrid: function(demos) {
|
807 |
+
|
808 |
+
jQuery.each(demos, function (index, demo) {
|
809 |
+
|
810 |
+
id = demo.id;
|
811 |
+
content = demo.content;
|
812 |
+
demo_api = demo.demo_api;
|
813 |
+
demo_name = demo.title;
|
814 |
+
demo_slug = demo.slug;
|
815 |
+
screenshot = demo.featured_image_url;
|
816 |
+
astra_demo_url = demo.astra_demo_url;
|
817 |
+
astra_demo_type = demo.astra_demo_type;
|
818 |
+
requiredPlugins = demo.required_plugins;
|
819 |
+
status = demo.status;
|
820 |
+
astraSiteOptions = demo.astra_site_options || '';
|
821 |
+
astraEnabledExtensions = demo.astra_enabled_extensions || '';
|
822 |
+
|
823 |
+
templateData = [{
|
824 |
+
id: id,
|
825 |
+
astra_demo_type: astra_demo_type,
|
826 |
+
status: status,
|
827 |
+
astra_demo_url: astra_demo_url,
|
828 |
+
demo_api: demo_api,
|
829 |
+
screenshot: screenshot,
|
830 |
+
demo_name: demo_name,
|
831 |
+
slug: demo_slug,
|
832 |
+
content: content,
|
833 |
+
required_plugins: requiredPlugins,
|
834 |
+
astra_site_options: astraSiteOptions,
|
835 |
+
astra_enabled_extensions: astraEnabledExtensions
|
836 |
+
}]
|
837 |
+
|
838 |
+
var template = wp.template('astra-single-demo');
|
839 |
+
jQuery('.themes').append(template(templateData[0]));
|
840 |
+
});
|
841 |
+
|
842 |
+
},
|
843 |
|
844 |
+
_pluginInstalling: function(event, args) {
|
845 |
+
event.preventDefault();
|
|
|
846 |
|
847 |
+
var $card = jQuery( '.plugin-card-' + args.slug );
|
848 |
+
var $button = $card.find( '.button' );
|
|
|
|
|
849 |
|
850 |
+
$card.addClass('updating-message');
|
851 |
+
$button.addClass('already-started');
|
|
|
|
|
|
|
852 |
|
853 |
+
},
|
854 |
+
|
855 |
+
/**
|
856 |
+
* Fires when a nav item is clicked.
|
857 |
+
*
|
858 |
+
* @since 1.0
|
859 |
+
* @access private
|
860 |
+
* @method _importDemo
|
861 |
+
*/
|
862 |
+
_importDemo: function()
|
863 |
+
{
|
864 |
+
var $this = jQuery(this),
|
865 |
+
$theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header'),
|
866 |
+
apiURL = $theme.data('demo-api') || '',
|
867 |
+
plugins = $theme.data('required-plugins');
|
868 |
+
|
869 |
+
var disabled = $this.attr('data-import');
|
870 |
+
|
871 |
+
if ( typeof disabled !== 'undefined' && disabled === 'disabled' ) {
|
872 |
+
|
873 |
+
$this.addClass('updating-message')
|
874 |
+
.text( wp.updates.l10n.installing );
|
875 |
+
|
876 |
+
/**
|
877 |
+
* Process Bulk Plugin Install & Activate
|
878 |
+
*/
|
879 |
+
AstraSites._bulkPluginInstallActivate();
|
880 |
+
|
881 |
+
return;
|
|
|
|
|
|
|
882 |
}
|
883 |
|
884 |
+
// Proceed?
|
885 |
+
if( ! confirm( astraDemo.strings.importWarning ) ) {
|
886 |
+
return;
|
887 |
+
}
|
888 |
+
|
889 |
+
jQuery('.astra-demo-import').attr('data-import', 'disabled')
|
890 |
+
.addClass('updating-message installing')
|
891 |
+
.text( astraDemo.strings.importingDemo );
|
892 |
+
|
893 |
+
$this.closest('.theme').focus();
|
894 |
+
|
895 |
+
var $theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header');
|
896 |
+
|
897 |
+
var apiURL = $theme.data('demo-api') || '';
|
898 |
+
|
899 |
+
jQuery.ajax({
|
900 |
+
url: astraDemo.ajaxurl,
|
901 |
+
type: 'POST',
|
902 |
+
dataType: 'json',
|
903 |
+
data: {
|
904 |
+
action: 'astra-import-demo',
|
905 |
+
api_url: apiURL
|
906 |
+
},
|
907 |
+
})
|
908 |
+
.done(function ( demos ) {
|
909 |
+
|
910 |
+
// Success?
|
911 |
+
if( demos.success ) {
|
912 |
+
jQuery('.astra-demo-import').removeClass('updating-message installing')
|
913 |
+
.removeAttr('data-import')
|
914 |
+
.addClass('view-site')
|
915 |
+
.removeClass('astra-demo-import')
|
916 |
+
.text( astraDemo.strings.viewSite )
|
917 |
+
.attr('target', '_blank')
|
918 |
+
.append('<i class="dashicons dashicons-external"></i>')
|
919 |
+
.attr('href', astraDemo.siteURL );
|
920 |
+
|
921 |
+
} else {
|
922 |
+
|
923 |
+
var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
|
924 |
+
output += ' <p>'+demos.message+'</p>';
|
925 |
+
output += ' <button type="button" class="notice-dismiss">';
|
926 |
+
output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
|
927 |
+
output += ' </button>';
|
928 |
+
output += '</div>';
|
929 |
+
|
930 |
+
jQuery('.install-theme-info').prepend( output );
|
931 |
+
|
932 |
+
// !important to add trigger.
|
933 |
+
// Which reinitialize the dismiss error message events.
|
934 |
+
jQuery(document).trigger('wp-updates-notice-added');
|
935 |
+
}
|
936 |
|
937 |
+
})
|
938 |
+
.fail(function ( demos ) {
|
939 |
+
jQuery('.astra-demo-import').removeClass('updating-message installing')
|
940 |
+
.removeAttr('data-import')
|
941 |
+
.addClass('view-site')
|
942 |
+
.removeClass('astra-demo-import')
|
943 |
+
.attr('target', '_blank')
|
944 |
+
.attr('href', astraDemo.strings.importFailedURL );
|
945 |
+
|
946 |
+
jQuery('.wp-full-overlay-header .view-site').text( astraDemo.strings.importFailedBtnSmall ).append('<i class="dashicons dashicons-external"></i>');
|
947 |
+
jQuery('.footer-import-button-wrap .view-site').text( astraDemo.strings.importFailedBtnLarge ).append('<i class="dashicons dashicons-external"></i>');
|
948 |
+
});
|
949 |
+
},
|
950 |
+
|
951 |
+
_bulkPluginInstallActivate: function()
|
952 |
+
{
|
953 |
+
if( 0 === astraDemo.requiredPlugins.length ) {
|
954 |
+
return;
|
955 |
+
}
|
956 |
+
|
957 |
+
jQuery('.required-plugins')
|
958 |
+
.find('.install-now')
|
959 |
+
.addClass( 'updating-message' )
|
960 |
+
.removeClass( 'install-now' )
|
961 |
+
.text( wp.updates.l10n.installing );
|
962 |
+
|
963 |
+
jQuery('.required-plugins')
|
964 |
+
.find('.activate-now')
|
965 |
+
.addClass('updating-message')
|
966 |
+
.removeClass( 'activate-now' )
|
967 |
+
.html( astraDemo.strings.btnActivating );
|
968 |
+
|
969 |
+
var not_installed = astraDemo.requiredPlugins.notinstalled || '';
|
970 |
+
var activate_plugins = astraDemo.requiredPlugins.inactive || '';
|
971 |
+
|
972 |
+
// First Install Bulk.
|
973 |
+
if( not_installed.length > 0 ) {
|
974 |
+
AstraSites._installAllPlugins( not_installed );
|
975 |
+
}
|
976 |
+
|
977 |
+
// Second Activate Bulk.
|
978 |
+
if( activate_plugins.length > 0 ) {
|
979 |
+
AstraSites._activateAllPlugins( activate_plugins );
|
980 |
+
}
|
981 |
|
982 |
+
},
|
983 |
|
984 |
+
/**
|
985 |
+
* Install All Plugins.
|
986 |
+
*/
|
987 |
+
_installAllPlugins: function( not_installed ) {
|
988 |
+
|
989 |
+
jQuery.each( not_installed, function(index, single_plugin) {
|
990 |
+
|
991 |
+
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
992 |
+
$button = $card.find('.button');
|
993 |
+
|
994 |
+
if( ! $button.hasClass('already-started') ) {
|
995 |
+
|
996 |
+
// Add each plugin activate request in Ajax queue.
|
997 |
+
// @see wp-admin/js/updates.js
|
998 |
+
wp.updates.queue.push( {
|
999 |
+
action: 'install-plugin', // Required action.
|
1000 |
+
data: {
|
1001 |
+
slug: single_plugin.slug
|
1002 |
+
}
|
1003 |
+
} );
|
1004 |
+
}
|
1005 |
+
});
|
1006 |
|
1007 |
+
// Required to set queue.
|
1008 |
+
wp.updates.queueChecker();
|
1009 |
+
},
|
1010 |
|
|
|
|
|
|
|
|
|
|
|
1011 |
|
1012 |
+
/**
|
1013 |
+
* Activate All Plugins.
|
1014 |
+
*/
|
1015 |
+
_activateAllPlugins: function( activate_plugins ) {
|
|
|
|
|
1016 |
|
1017 |
+
// Process of cloud templates - (download, remove & fetch).
|
1018 |
+
AstraSitesAjaxQueue.run();
|
1019 |
|
1020 |
+
jQuery.each( activate_plugins, function(index, single_plugin) {
|
|
|
1021 |
|
1022 |
+
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
1023 |
+
$button = $card.find('.button'),
|
1024 |
+
$siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val(),
|
1025 |
+
$enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
1026 |
|
1027 |
+
$button.addClass('updating-message');
|
|
|
|
|
|
|
|
|
|
|
1028 |
|
1029 |
+
AstraSitesAjaxQueue.add({
|
1030 |
+
url: astraDemo.ajaxurl,
|
1031 |
+
type: 'POST',
|
1032 |
+
data: {
|
1033 |
+
'action' : 'astra-required-plugin-activate',
|
1034 |
+
'init' : single_plugin.init,
|
1035 |
+
'options' : $siteOptions,
|
1036 |
+
'enabledExtensions' : $enabledExtensions,
|
1037 |
+
},
|
1038 |
+
success: function( result ){
|
1039 |
|
1040 |
+
if( result.success ) {
|
|
|
|
|
|
|
1041 |
|
1042 |
+
var $card = jQuery( '.plugin-card-' + single_plugin.slug );
|
1043 |
+
var $button = $card.find( '.button' );
|
1044 |
+
if( ! $button.hasClass('already-started') ) {
|
1045 |
+
var pluginsList = astraDemo.requiredPlugins.inactive;
|
1046 |
|
1047 |
+
// Reset not installed plugins list.
|
1048 |
+
astraDemo.requiredPlugins.inactive = AstraSites._removePluginFromQueue( single_plugin.slug, pluginsList );
|
1049 |
+
}
|
1050 |
|
1051 |
+
$button.removeClass( 'button-primary install-now activate-now updating-message' )
|
1052 |
+
.attr('disabled', 'disabled')
|
1053 |
+
.addClass('disabled')
|
1054 |
+
.text( astraDemo.strings.btnActive );
|
1055 |
|
1056 |
+
// Enable Demo Import Button
|
1057 |
+
AstraSites._enable_demo_import_button();
|
1058 |
+
}
|
1059 |
+
}
|
1060 |
+
});
|
1061 |
+
});
|
1062 |
+
},
|
1063 |
|
1064 |
+
/**
|
1065 |
+
* Enable Demo Import Button.
|
1066 |
+
*/
|
1067 |
+
_enable_demo_import_button: function( type = 'free' ) {
|
1068 |
+
|
1069 |
+
switch( type ) {
|
1070 |
+
|
1071 |
+
case 'free':
|
1072 |
+
var all_buttons = parseInt( jQuery( '.plugin-card .button' ).length ) || 0,
|
1073 |
+
disabled_buttons = parseInt( jQuery( '.plugin-card .button.disabled' ).length ) || 0;
|
1074 |
+
|
1075 |
+
if( all_buttons === disabled_buttons ) {
|
1076 |
+
|
1077 |
+
jQuery('.astra-demo-import')
|
1078 |
+
.removeAttr('data-import')
|
1079 |
+
.removeClass('updating-message')
|
1080 |
+
.addClass('button-primary')
|
1081 |
+
.text( astraDemo.strings.importDemo );
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
break;
|
1085 |
+
|
1086 |
+
case 'upgrade':
|
1087 |
+
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
1088 |
+
|
1089 |
+
jQuery('.astra-demo-import')
|
1090 |
+
.addClass('go-pro button-primary')
|
1091 |
+
.removeClass('astra-demo-import')
|
1092 |
+
.attr('target', '_blank')
|
1093 |
+
.attr('href', astraDemo.getUpgradeURL + demo_slug )
|
1094 |
+
.text( astraDemo.getUpgradeText )
|
1095 |
+
.append('<i class="dashicons dashicons-external"></i>');
|
1096 |
+
break;
|
1097 |
+
|
1098 |
+
default:
|
1099 |
+
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
1100 |
+
|
1101 |
+
jQuery('.astra-demo-import')
|
1102 |
+
.addClass('go-pro button-primary')
|
1103 |
+
.removeClass('astra-demo-import')
|
1104 |
+
.attr('target', '_blank')
|
1105 |
+
.attr('href', astraDemo.getProURL )
|
1106 |
+
.text( astraDemo.getProText )
|
1107 |
+
.append('<i class="dashicons dashicons-external"></i>');
|
1108 |
+
break;
|
1109 |
+
}
|
1110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1111 |
},
|
1112 |
+
|
1113 |
+
/**
|
1114 |
+
* Remove plugin from the queue.
|
1115 |
+
*/
|
1116 |
+
_removePluginFromQueue: function( removeItem, pluginsList ) {
|
1117 |
+
return jQuery.grep(pluginsList, function( value ) {
|
1118 |
+
return value.slug != removeItem;
|
1119 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1120 |
}
|
1121 |
|
1122 |
+
};
|
1123 |
+
|
1124 |
+
/**
|
1125 |
+
* Initialize AstraSites
|
1126 |
+
*/
|
1127 |
+
$(function(){
|
1128 |
+
AstraSites.init();
|
|
|
|
|
|
|
|
|
1129 |
});
|
1130 |
|
1131 |
+
})(jQuery);
|
inc/classes/class-astra-sites.php
CHANGED
@@ -66,6 +66,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
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 |
|
70 |
}
|
71 |
|
@@ -84,6 +85,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
84 |
'dismissible-time' => MINUTE_IN_SECONDS,
|
85 |
)
|
86 |
);
|
|
|
87 |
}
|
88 |
|
89 |
/**
|
@@ -221,44 +223,50 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
221 |
return;
|
222 |
}
|
223 |
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
)
|
259 |
)
|
260 |
-
)
|
261 |
-
|
262 |
|
263 |
}
|
264 |
|
@@ -272,8 +280,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
272 |
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-notices.php';
|
273 |
|
274 |
require_once ASTRA_SITES_DIR . 'inc/admin/class-astra-sites-page.php';
|
275 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility
|
276 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility-astra-pro.php';
|
277 |
|
278 |
// Load the Importers.
|
279 |
require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-sites-helper.php';
|
@@ -518,6 +525,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
518 |
// Clear Cache.
|
519 |
$this->clear_cache();
|
520 |
|
|
|
521 |
}
|
522 |
|
523 |
/**
|
@@ -525,7 +533,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
525 |
*
|
526 |
* @since 1.0.9
|
527 |
*/
|
528 |
-
|
529 |
|
530 |
// Clear 'Elementor' file cache.
|
531 |
if ( class_exists( '\Elementor\Plugin' ) ) {
|
@@ -536,7 +544,6 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
536 |
if ( is_callable( 'FLBuilderModel::delete_asset_cache_for_all_posts' ) ) {
|
537 |
FLBuilderModel::delete_asset_cache_for_all_posts();
|
538 |
}
|
539 |
-
|
540 |
}
|
541 |
|
542 |
/**
|
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 |
|
85 |
'dismissible-time' => MINUTE_IN_SECONDS,
|
86 |
)
|
87 |
);
|
88 |
+
|
89 |
}
|
90 |
|
91 |
/**
|
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 |
+
// Load Admin JS for only if there is no Tab.
|
229 |
+
// If have a tab then load only in General Tab.
|
230 |
+
if ( ! isset( $_GET['action'] ) || ( isset( $_GET['action'] ) && 'general' === $_GET['action'] ) ) {
|
231 |
+
|
232 |
+
wp_enqueue_script(
|
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 |
+
wp_localize_script(
|
241 |
+
'astra-sites-admin', 'astraDemo', apply_filters(
|
242 |
+
'astra_sites_localize_vars', array(
|
243 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
244 |
+
'siteURL' => site_url(),
|
245 |
+
'getProText' => __( 'Purchase', 'astra-sites' ),
|
246 |
+
'getProURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
247 |
+
'getUpgradeText' => __( 'Upgrade', 'astra-sites' ),
|
248 |
+
'getUpgradeURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
249 |
+
'_ajax_nonce' => wp_create_nonce( 'astra-sites' ),
|
250 |
+
'requiredPlugins' => array(),
|
251 |
+
'strings' => array(
|
252 |
+
'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
|
253 |
+
'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
|
254 |
+
'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314' ),
|
255 |
+
'viewSite' => __( 'Done! View Site', 'astra-sites' ),
|
256 |
+
'btnActivating' => __( 'Activating', 'astra-sites' ) . '…',
|
257 |
+
'btnActive' => __( 'Active', 'astra-sites' ),
|
258 |
+
'importDemo' => __( 'Import This Site', 'astra-sites' ),
|
259 |
+
'importingDemo' => __( 'Importing Demo', 'astra-sites' ),
|
260 |
+
'DescExpand' => __( 'Read more', 'astra-sites' ) . '…',
|
261 |
+
'DescCollapse' => __( 'Hide', 'astra-sites' ),
|
262 |
+
'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
|
263 |
+
'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
|
264 |
+
'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' ),
|
265 |
+
),
|
266 |
+
)
|
267 |
)
|
268 |
+
);
|
269 |
+
}
|
270 |
|
271 |
}
|
272 |
|
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';
|
525 |
// Clear Cache.
|
526 |
$this->clear_cache();
|
527 |
|
528 |
+
do_action( 'astra_sites_import_complete', $demo_data );
|
529 |
}
|
530 |
|
531 |
/**
|
533 |
*
|
534 |
* @since 1.0.9
|
535 |
*/
|
536 |
+
public function clear_cache() {
|
537 |
|
538 |
// Clear 'Elementor' file cache.
|
539 |
if ( class_exists( '\Elementor\Plugin' ) ) {
|
544 |
if ( is_callable( 'FLBuilderModel::delete_asset_cache_for_all_posts' ) ) {
|
545 |
FLBuilderModel::delete_asset_cache_for_all_posts();
|
546 |
}
|
|
|
547 |
}
|
548 |
|
549 |
/**
|
inc/classes/compatibility/{class-astra-sites-compatibility-astra-pro.php → astra-pro/class-astra-sites-compatibility-astra-pro.php}
RENAMED
File without changes
|
inc/classes/compatibility/class-astra-sites-compatibility.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Astra Sites Compatibility for 3rd party plugins.
|
4 |
+
*
|
5 |
+
* @package Astra Sites
|
6 |
+
* @since 1.0.11
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Astra Sites Compatibility
|
13 |
+
*
|
14 |
+
* @since 1.0.11
|
15 |
+
*/
|
16 |
+
class Astra_Sites_Compatibility {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @access private
|
22 |
+
* @var object Class object.
|
23 |
+
* @since 1.0.11
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*
|
30 |
+
* @since 1.0.11
|
31 |
+
* @return object initialized object of class.
|
32 |
+
*/
|
33 |
+
public static function instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self;
|
36 |
+
}
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*
|
43 |
+
* @since 1.0.11
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
|
47 |
+
// Background Processing.
|
48 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/vendor/wp-async-request.php';
|
49 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/vendor/wp-background-process.php';
|
50 |
+
|
51 |
+
// Plugin - Astra Pro.
|
52 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php';
|
53 |
+
|
54 |
+
// Plugin - Site Origin Widgets.
|
55 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/so-widgets-bundle/class-astra-sites-compatibility-so-widgets.php';
|
56 |
+
|
57 |
+
// Plugin - Elementor.
|
58 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/elementor/class-astra-sites-compatibility-elementor.php';
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Kicking this off by calling 'instance()' method
|
66 |
+
*/
|
67 |
+
Astra_Sites_Compatibility::instance();
|
68 |
+
|
69 |
+
endif;
|
inc/classes/compatibility/elementor/background-processing/class-astra-elementor-image-importer-process.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Image Background Process
|
4 |
+
*
|
5 |
+
* @package Astra Sites
|
6 |
+
* @since 1.0.11
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( class_exists( 'WP_Background_Process' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Image Background Process
|
13 |
+
*
|
14 |
+
* @since 1.0.11
|
15 |
+
*/
|
16 |
+
class Astra_Elementor_Image_Importer_Process extends WP_Background_Process {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Image Process
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $action = 'image_process';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Task
|
27 |
+
*
|
28 |
+
* Override this method to perform any actions required on each
|
29 |
+
* queue item. Return the modified item for further processing
|
30 |
+
* in the next pass through. Or, return false to remove the
|
31 |
+
* item from the queue.
|
32 |
+
*
|
33 |
+
* @since 1.0.11
|
34 |
+
*
|
35 |
+
* @param mixed $post_id Queue item to iterate over.
|
36 |
+
* @return mixed
|
37 |
+
*/
|
38 |
+
protected function task( $post_id ) {
|
39 |
+
|
40 |
+
$import = new \Elementor\TemplateLibrary\Astra_Sites_Source_Remote();
|
41 |
+
$import->hotlink_images( $post_id );
|
42 |
+
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Complete
|
48 |
+
*
|
49 |
+
* Override if applicable, but ensure that the below actions are
|
50 |
+
* performed, or, call parent::complete().
|
51 |
+
*
|
52 |
+
* @since 1.0.11
|
53 |
+
*/
|
54 |
+
protected function complete() {
|
55 |
+
|
56 |
+
parent::complete();
|
57 |
+
|
58 |
+
do_action( 'astra_sites_image_import_complete' );
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
endif;
|
inc/classes/compatibility/elementor/class-astra-sites-compatibility-elementor.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Astra Sites Elementor
|
4 |
+
*
|
5 |
+
* @package Astra Sites
|
6 |
+
* @since 1.0.11
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Astra_Sites_Compatibility_Elementor' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Astra_Sites_Compatibility_Elementor
|
13 |
+
*
|
14 |
+
* @since 1.0.11
|
15 |
+
*/
|
16 |
+
class Astra_Sites_Compatibility_Elementor {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* All Processes.
|
20 |
+
*
|
21 |
+
* @since 1.0.11
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @var $process_all
|
25 |
+
*/
|
26 |
+
protected $process_all;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Instance
|
30 |
+
*
|
31 |
+
* @since 1.0.11
|
32 |
+
*
|
33 |
+
* @access private
|
34 |
+
* @var object Class object.
|
35 |
+
*/
|
36 |
+
private static $instance;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initiator
|
40 |
+
*
|
41 |
+
* @since 1.0.11
|
42 |
+
* @return object initialized object of class.
|
43 |
+
*/
|
44 |
+
public static function set_instance() {
|
45 |
+
if ( ! isset( self::$instance ) ) {
|
46 |
+
self::$instance = new self;
|
47 |
+
}
|
48 |
+
return self::$instance;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Constructor
|
53 |
+
*
|
54 |
+
* @since 1.0.11
|
55 |
+
*/
|
56 |
+
public function __construct() {
|
57 |
+
|
58 |
+
if ( ini_get( 'allow_url_fopen' ) ) {
|
59 |
+
|
60 |
+
require_once ABSPATH . 'wp-admin/includes/image.php';
|
61 |
+
|
62 |
+
// Remote Source extends Elementor Remote API.
|
63 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/elementor/class-astra-sites-source-remote.php';
|
64 |
+
|
65 |
+
// Background Processing.
|
66 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/elementor/background-processing/class-astra-elementor-image-importer-process.php';
|
67 |
+
|
68 |
+
$this->process_all = new Astra_Elementor_Image_Importer_Process();
|
69 |
+
|
70 |
+
// Start image importing after site import complete.
|
71 |
+
add_action( 'astra_sites_import_complete', array( $this, 'start_image_import' ) );
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Start Image Import
|
79 |
+
*
|
80 |
+
* @since 1.0.11
|
81 |
+
*
|
82 |
+
* @param array $data Site API Data.
|
83 |
+
* @return void
|
84 |
+
*/
|
85 |
+
public function start_image_import( $data ) {
|
86 |
+
|
87 |
+
// Have Required Plugins?
|
88 |
+
if ( array_key_exists( 'required-plugins', $data ) ) {
|
89 |
+
|
90 |
+
// Have Elementor Plugin?
|
91 |
+
// Yes, Then proceed!
|
92 |
+
if ( in_array( 'elementor', array_column( $data['required-plugins'], 'slug' ) ) ) {
|
93 |
+
|
94 |
+
$page_ids = $this->get_pages();
|
95 |
+
|
96 |
+
if ( is_array( $page_ids ) ) {
|
97 |
+
foreach ( $page_ids as $page_id ) {
|
98 |
+
error_log( $page_id );
|
99 |
+
$this->process_all->push_to_queue( $page_id );
|
100 |
+
}
|
101 |
+
$this->process_all->save()->dispatch();
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get Page IDs
|
109 |
+
*
|
110 |
+
* @since 1.0.11
|
111 |
+
*
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
protected function get_pages() {
|
115 |
+
|
116 |
+
$args = array(
|
117 |
+
'post_type' => 'page',
|
118 |
+
|
119 |
+
// Query performance optimization.
|
120 |
+
'fields' => 'ids',
|
121 |
+
'no_found_rows' => true,
|
122 |
+
'post_status' => 'publish',
|
123 |
+
);
|
124 |
+
|
125 |
+
$query = new WP_Query( $args );
|
126 |
+
|
127 |
+
// Have posts?
|
128 |
+
if ( $query->have_posts() ) :
|
129 |
+
|
130 |
+
return $query->posts;
|
131 |
+
|
132 |
+
endif;
|
133 |
+
|
134 |
+
return null;
|
135 |
+
}
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Kicking this off by calling 'set_instance()' method
|
141 |
+
*/
|
142 |
+
Astra_Sites_Compatibility_Elementor::set_instance();
|
143 |
+
|
144 |
+
endif;
|
inc/classes/compatibility/elementor/class-astra-sites-source-remote.php
ADDED
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Elementor Images
|
4 |
+
*
|
5 |
+
* @package Astra Sites
|
6 |
+
* @since 1.0.11
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace Elementor;
|
10 |
+
|
11 |
+
// If plugin - 'Elementor' not exist then return.
|
12 |
+
if ( ! class_exists( '\Elementor\Plugin' ) ) {
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
|
16 |
+
namespace Elementor\TemplateLibrary;
|
17 |
+
|
18 |
+
use Elementor\Core\Settings\Manager as SettingsManager;
|
19 |
+
use Elementor\TemplateLibrary\Classes\Import_Images;
|
20 |
+
use Elementor\TemplateLibrary;
|
21 |
+
use Elementor\TemplateLibrary\Classes;
|
22 |
+
use Elementor\Api;
|
23 |
+
use Elementor\PageSettings\Page;
|
24 |
+
|
25 |
+
// For working protected methods defined in.
|
26 |
+
// file '/elementor/includes/template-library/sources/base.php'.
|
27 |
+
use Elementor\Plugin;
|
28 |
+
use Elementor\Utils;
|
29 |
+
|
30 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
31 |
+
exit; // Exit if accessed directly.
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Astra Source Remote
|
36 |
+
*/
|
37 |
+
class Astra_Sites_Source_Remote extends Source_Base {
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get ID
|
41 |
+
*
|
42 |
+
* @since 1.0.4
|
43 |
+
*
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function get_id() {
|
47 |
+
return 'remote';
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get Title.
|
52 |
+
*
|
53 |
+
* @since 1.0.4
|
54 |
+
*
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function get_title() {
|
58 |
+
return __( 'Remote', 'astra-sites' );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get Data
|
63 |
+
*
|
64 |
+
* @since 1.0.4
|
65 |
+
*
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
public function register_data() {}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get Items
|
72 |
+
*
|
73 |
+
* @since 1.0.4
|
74 |
+
*
|
75 |
+
* @param array $args Arguments.
|
76 |
+
* @return array
|
77 |
+
*/
|
78 |
+
public function get_items( $args = array() ) {
|
79 |
+
$templates_data = Api::get_templates_data();
|
80 |
+
|
81 |
+
$templates = array();
|
82 |
+
|
83 |
+
if ( ! empty( $templates_data ) ) {
|
84 |
+
foreach ( $templates_data as $template_data ) {
|
85 |
+
$templates[] = $this->get_item( $template_data );
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
if ( ! empty( $args ) ) {
|
90 |
+
$templates = wp_list_filter( $templates, $args );
|
91 |
+
}
|
92 |
+
|
93 |
+
return $templates;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Get Item
|
98 |
+
*
|
99 |
+
* @param array $template_data Template Data.
|
100 |
+
*
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
public function get_item( $template_data ) {
|
104 |
+
return array(
|
105 |
+
'template_id' => $template_data['id'],
|
106 |
+
'source' => $this->get_id(),
|
107 |
+
'title' => $template_data['title'],
|
108 |
+
'thumbnail' => $template_data['thumbnail'],
|
109 |
+
'date' => date( get_option( 'date_format' ), $template_data['tmpl_created'] ),
|
110 |
+
'author' => $template_data['author'],
|
111 |
+
'categories' => array(),
|
112 |
+
'keywords' => array(),
|
113 |
+
'isPro' => ( '1' === $template_data['is_pro'] ),
|
114 |
+
'hasPageSettings' => ( '1' === $template_data['has_page_settings'] ),
|
115 |
+
'url' => $template_data['url'],
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Template Data
|
121 |
+
*
|
122 |
+
* @param boolean $template_data Template Data.
|
123 |
+
* @return boolean Return false.
|
124 |
+
*/
|
125 |
+
public function save_item( $template_data ) {
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Update Item
|
131 |
+
*
|
132 |
+
* @param boolean $new_data New Data.
|
133 |
+
* @return boolean Return false.
|
134 |
+
*/
|
135 |
+
public function update_item( $new_data ) {
|
136 |
+
return false;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Delete Template
|
141 |
+
*
|
142 |
+
* @param boolean $template_id Template ID.
|
143 |
+
* @return boolean Return false.
|
144 |
+
*/
|
145 |
+
public function delete_template( $template_id ) {
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Delete Template
|
151 |
+
*
|
152 |
+
* @param boolean $template_id Template ID.
|
153 |
+
* @return boolean Return false.
|
154 |
+
*/
|
155 |
+
public function export_template( $template_id ) {
|
156 |
+
return false;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Get Data
|
161 |
+
*
|
162 |
+
* @param array $args Arguments.
|
163 |
+
* @param string $context Context.
|
164 |
+
* @return array Data.
|
165 |
+
*/
|
166 |
+
public function get_data( array $args, $context = 'display' ) {
|
167 |
+
$data = Api::get_template_content( $args['template_id'] );
|
168 |
+
|
169 |
+
if ( is_wp_error( $data ) ) {
|
170 |
+
return $data;
|
171 |
+
}
|
172 |
+
|
173 |
+
// TODO: since 1.5.0 to content container named `content` instead of `data`.
|
174 |
+
if ( ! empty( $data['data'] ) ) {
|
175 |
+
$data['content'] = $data['data'];
|
176 |
+
unset( $data['data'] );
|
177 |
+
}
|
178 |
+
|
179 |
+
$data['content'] = $this->replace_elements_ids( $data['content'] );
|
180 |
+
$data['content'] = $this->process_export_import_content( $data['content'], 'on_import' );
|
181 |
+
|
182 |
+
if ( ! empty( $args['page_settings'] ) && ! empty( $data['page_settings'] ) ) {
|
183 |
+
$page = new Page(
|
184 |
+
array(
|
185 |
+
'settings' => $data['page_settings'],
|
186 |
+
)
|
187 |
+
);
|
188 |
+
|
189 |
+
$page_settings_data = $this->process_element_export_import_content( $page, 'on_import' );
|
190 |
+
$data['page_settings'] = $page_settings_data['settings'];
|
191 |
+
}
|
192 |
+
|
193 |
+
return $data;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Replace Elements Ids
|
198 |
+
*
|
199 |
+
* @param string $content Context.
|
200 |
+
* @return array Element.
|
201 |
+
*/
|
202 |
+
public function replace_elements_ids( $content ) {
|
203 |
+
return Plugin::$instance->db->iterate_data(
|
204 |
+
$content, function( $element ) {
|
205 |
+
$element['id'] = Utils::generate_random_string();
|
206 |
+
|
207 |
+
return $element;
|
208 |
+
}
|
209 |
+
);
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Process Import Content.
|
214 |
+
*
|
215 |
+
* @param array $content a set of elements.
|
216 |
+
* @param string $method (on_export|on_import).
|
217 |
+
*
|
218 |
+
* @return mixed
|
219 |
+
*/
|
220 |
+
public function process_export_import_content( $content, $method ) {
|
221 |
+
return Plugin::$instance->db->iterate_data(
|
222 |
+
$content, function( $element_data ) use ( $method ) {
|
223 |
+
$element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
|
224 |
+
|
225 |
+
// If the widget/element isn't exist, like a plugin that creates a widget but deactivated.
|
226 |
+
if ( ! $element ) {
|
227 |
+
return null;
|
228 |
+
}
|
229 |
+
|
230 |
+
return $this->process_element_export_import_content( $element, $method );
|
231 |
+
}
|
232 |
+
);
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Process Element/Export Import Content.
|
237 |
+
*
|
238 |
+
* @param \Elementor\Controls_Stack $element Element.
|
239 |
+
* @param string $method Method.
|
240 |
+
*
|
241 |
+
* @return array
|
242 |
+
*/
|
243 |
+
public function process_element_export_import_content( $element, $method ) {
|
244 |
+
$element_data = $element->get_data();
|
245 |
+
|
246 |
+
if ( method_exists( $element, $method ) ) {
|
247 |
+
// TODO: Use the internal element data without parameters.
|
248 |
+
$element_data = $element->{$method}( $element_data );
|
249 |
+
}
|
250 |
+
|
251 |
+
foreach ( $element->get_controls() as $control ) {
|
252 |
+
$control_class = Plugin::$instance->controls_manager->get_control( $control['type'] );
|
253 |
+
|
254 |
+
// If the control isn't exist, like a plugin that creates the control but deactivated.
|
255 |
+
if ( ! $control_class ) {
|
256 |
+
return $element_data;
|
257 |
+
}
|
258 |
+
|
259 |
+
if ( method_exists( $control_class, $method ) ) {
|
260 |
+
$element_data['settings'][ $control['name'] ] = $control_class->{$method}( $element->get_settings( $control['name'] ) );
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
return $element_data;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Update post meta.
|
269 |
+
*
|
270 |
+
* @param integer $post_id Post ID.
|
271 |
+
* @return void
|
272 |
+
*/
|
273 |
+
public function hotlink_images( $post_id = 0 ) {
|
274 |
+
|
275 |
+
if ( ! empty( $post_id ) ) {
|
276 |
+
|
277 |
+
$hotlink_imported = get_post_meta( $post_id, '_astra_sites_hotlink_imported', true );
|
278 |
+
|
279 |
+
if ( empty( $hotlink_imported ) ) {
|
280 |
+
|
281 |
+
$data = get_post_meta( $post_id, '_elementor_data', true );
|
282 |
+
|
283 |
+
if ( ! empty( $data ) ) {
|
284 |
+
|
285 |
+
$data = json_decode( $data, true );
|
286 |
+
|
287 |
+
$data = $this->replace_elements_ids( $data );
|
288 |
+
$data = $this->process_export_import_content( $data, 'on_import' );
|
289 |
+
|
290 |
+
// Update processed meta.
|
291 |
+
update_metadata( 'post', $post_id, '_elementor_data', $data );
|
292 |
+
update_metadata( 'post', $post_id, '_astra_sites_hotlink_imported', true );
|
293 |
+
|
294 |
+
// !important, Clear the cache after images import.
|
295 |
+
Plugin::$instance->posts_css_manager->clear_cache();
|
296 |
+
|
297 |
+
}
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
}
|
302 |
+
}
|
inc/classes/compatibility/{class-astra-sites-compatibility-so-widgets.php → so-widgets-bundle/class-astra-sites-compatibility-so-widgets.php}
RENAMED
File without changes
|
inc/classes/vendor/wp-async-request.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP Async Request
|
4 |
+
*
|
5 |
+
* @see https://github.com/A5hleyRich/wp-background-processing/
|
6 |
+
* @package WP-Background-Processing
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'WP_Async_Request' ) ) {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Abstract WP_Async_Request class.
|
13 |
+
*
|
14 |
+
* @abstract
|
15 |
+
*/
|
16 |
+
abstract class WP_Async_Request {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Prefix
|
20 |
+
*
|
21 |
+
* (default value: 'wp')
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
* @access protected
|
25 |
+
*/
|
26 |
+
protected $prefix = 'wp';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Action
|
30 |
+
*
|
31 |
+
* (default value: 'async_request')
|
32 |
+
*
|
33 |
+
* @var string
|
34 |
+
* @access protected
|
35 |
+
*/
|
36 |
+
protected $action = 'async_request';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Identifier
|
40 |
+
*
|
41 |
+
* @var mixed
|
42 |
+
* @access protected
|
43 |
+
*/
|
44 |
+
protected $identifier;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Data
|
48 |
+
*
|
49 |
+
* (default value: array())
|
50 |
+
*
|
51 |
+
* @var array
|
52 |
+
* @access protected
|
53 |
+
*/
|
54 |
+
protected $data = array();
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Initiate new async request
|
58 |
+
*/
|
59 |
+
public function __construct() {
|
60 |
+
$this->identifier = $this->prefix . '_' . $this->action;
|
61 |
+
|
62 |
+
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
63 |
+
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Set data used during the request
|
68 |
+
*
|
69 |
+
* @param array $data Data.
|
70 |
+
*
|
71 |
+
* @return $this
|
72 |
+
*/
|
73 |
+
public function data( $data ) {
|
74 |
+
$this->data = $data;
|
75 |
+
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Dispatch the async request
|
81 |
+
*
|
82 |
+
* @return array|WP_Error
|
83 |
+
*/
|
84 |
+
public function dispatch() {
|
85 |
+
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
|
86 |
+
$args = $this->get_post_args();
|
87 |
+
|
88 |
+
return wp_remote_post( esc_url_raw( $url ), $args );
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Get query args
|
93 |
+
*
|
94 |
+
* @return array
|
95 |
+
*/
|
96 |
+
protected function get_query_args() {
|
97 |
+
if ( property_exists( $this, 'query_args' ) ) {
|
98 |
+
return $this->query_args;
|
99 |
+
}
|
100 |
+
|
101 |
+
return array(
|
102 |
+
'action' => $this->identifier,
|
103 |
+
'nonce' => wp_create_nonce( $this->identifier ),
|
104 |
+
);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get query URL
|
109 |
+
*
|
110 |
+
* @return string
|
111 |
+
*/
|
112 |
+
protected function get_query_url() {
|
113 |
+
if ( property_exists( $this, 'query_url' ) ) {
|
114 |
+
return $this->query_url;
|
115 |
+
}
|
116 |
+
|
117 |
+
return admin_url( 'admin-ajax.php' );
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Get post args
|
122 |
+
*
|
123 |
+
* @return array
|
124 |
+
*/
|
125 |
+
protected function get_post_args() {
|
126 |
+
if ( property_exists( $this, 'post_args' ) ) {
|
127 |
+
return $this->post_args;
|
128 |
+
}
|
129 |
+
|
130 |
+
return array(
|
131 |
+
'timeout' => 0.01,
|
132 |
+
'blocking' => false,
|
133 |
+
'body' => $this->data,
|
134 |
+
'cookies' => $_COOKIE,
|
135 |
+
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
|
136 |
+
);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Maybe handle
|
141 |
+
*
|
142 |
+
* Check for correct nonce and pass to handler.
|
143 |
+
*/
|
144 |
+
public function maybe_handle() {
|
145 |
+
// Don't lock up other requests while processing
|
146 |
+
session_write_close();
|
147 |
+
|
148 |
+
check_ajax_referer( $this->identifier, 'nonce' );
|
149 |
+
|
150 |
+
$this->handle();
|
151 |
+
|
152 |
+
wp_die();
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Handle
|
157 |
+
*
|
158 |
+
* Override this method to perform any actions required
|
159 |
+
* during the async request.
|
160 |
+
*/
|
161 |
+
abstract protected function handle();
|
162 |
+
|
163 |
+
}
|
164 |
+
}
|
inc/classes/vendor/wp-background-process.php
ADDED
@@ -0,0 +1,507 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP Background Process
|
4 |
+
*
|
5 |
+
* @see https://github.com/A5hleyRich/wp-background-processing/
|
6 |
+
* @package WP-Background-Processing
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Abstract WP_Background_Process class.
|
13 |
+
*
|
14 |
+
* @abstract
|
15 |
+
* @extends WP_Async_Request
|
16 |
+
*/
|
17 |
+
abstract class WP_Background_Process extends WP_Async_Request {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Action
|
21 |
+
*
|
22 |
+
* (default value: 'background_process')
|
23 |
+
*
|
24 |
+
* @var string
|
25 |
+
* @access protected
|
26 |
+
*/
|
27 |
+
protected $action = 'background_process';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Start time of current process.
|
31 |
+
*
|
32 |
+
* (default value: 0)
|
33 |
+
*
|
34 |
+
* @var int
|
35 |
+
* @access protected
|
36 |
+
*/
|
37 |
+
protected $start_time = 0;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Cron_hook_identifier
|
41 |
+
*
|
42 |
+
* @var mixed
|
43 |
+
* @access protected
|
44 |
+
*/
|
45 |
+
protected $cron_hook_identifier;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Cron_interval_identifier
|
49 |
+
*
|
50 |
+
* @var mixed
|
51 |
+
* @access protected
|
52 |
+
*/
|
53 |
+
protected $cron_interval_identifier;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Initiate new background process
|
57 |
+
*/
|
58 |
+
public function __construct() {
|
59 |
+
parent::__construct();
|
60 |
+
|
61 |
+
$this->cron_hook_identifier = $this->identifier . '_cron';
|
62 |
+
$this->cron_interval_identifier = $this->identifier . '_cron_interval';
|
63 |
+
|
64 |
+
add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
|
65 |
+
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Dispatch
|
70 |
+
*
|
71 |
+
* @access public
|
72 |
+
* @return void
|
73 |
+
*/
|
74 |
+
public function dispatch() {
|
75 |
+
// Schedule the cron healthcheck.
|
76 |
+
$this->schedule_event();
|
77 |
+
|
78 |
+
// Perform remote post.
|
79 |
+
return parent::dispatch();
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Push to queue
|
84 |
+
*
|
85 |
+
* @param mixed $data Data.
|
86 |
+
*
|
87 |
+
* @return $this
|
88 |
+
*/
|
89 |
+
public function push_to_queue( $data ) {
|
90 |
+
$this->data[] = $data;
|
91 |
+
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Save queue
|
97 |
+
*
|
98 |
+
* @return $this
|
99 |
+
*/
|
100 |
+
public function save() {
|
101 |
+
$key = $this->generate_key();
|
102 |
+
|
103 |
+
if ( ! empty( $this->data ) ) {
|
104 |
+
update_site_option( $key, $this->data );
|
105 |
+
}
|
106 |
+
|
107 |
+
return $this;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Update queue
|
112 |
+
*
|
113 |
+
* @param string $key Key.
|
114 |
+
* @param array $data Data.
|
115 |
+
*
|
116 |
+
* @return $this
|
117 |
+
*/
|
118 |
+
public function update( $key, $data ) {
|
119 |
+
if ( ! empty( $data ) ) {
|
120 |
+
update_site_option( $key, $data );
|
121 |
+
}
|
122 |
+
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Delete queue
|
128 |
+
*
|
129 |
+
* @param string $key Key.
|
130 |
+
*
|
131 |
+
* @return $this
|
132 |
+
*/
|
133 |
+
public function delete( $key ) {
|
134 |
+
delete_site_option( $key );
|
135 |
+
|
136 |
+
return $this;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Generate key
|
141 |
+
*
|
142 |
+
* Generates a unique key based on microtime. Queue items are
|
143 |
+
* given a unique key so that they can be merged upon save.
|
144 |
+
*
|
145 |
+
* @param int $length Length.
|
146 |
+
*
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
protected function generate_key( $length = 64 ) {
|
150 |
+
$unique = md5( microtime() . rand() );
|
151 |
+
$prepend = $this->identifier . '_batch_';
|
152 |
+
|
153 |
+
return substr( $prepend . $unique, 0, $length );
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Maybe process queue
|
158 |
+
*
|
159 |
+
* Checks whether data exists within the queue and that
|
160 |
+
* the process is not already running.
|
161 |
+
*/
|
162 |
+
public function maybe_handle() {
|
163 |
+
// Don't lock up other requests while processing
|
164 |
+
session_write_close();
|
165 |
+
|
166 |
+
if ( $this->is_process_running() ) {
|
167 |
+
// Background process already running.
|
168 |
+
wp_die();
|
169 |
+
}
|
170 |
+
|
171 |
+
if ( $this->is_queue_empty() ) {
|
172 |
+
// No data to process.
|
173 |
+
wp_die();
|
174 |
+
}
|
175 |
+
|
176 |
+
check_ajax_referer( $this->identifier, 'nonce' );
|
177 |
+
|
178 |
+
$this->handle();
|
179 |
+
|
180 |
+
wp_die();
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Is queue empty
|
185 |
+
*
|
186 |
+
* @return bool
|
187 |
+
*/
|
188 |
+
protected function is_queue_empty() {
|
189 |
+
global $wpdb;
|
190 |
+
|
191 |
+
$table = $wpdb->options;
|
192 |
+
$column = 'option_name';
|
193 |
+
|
194 |
+
if ( is_multisite() ) {
|
195 |
+
$table = $wpdb->sitemeta;
|
196 |
+
$column = 'meta_key';
|
197 |
+
}
|
198 |
+
|
199 |
+
$key = $this->identifier . '_batch_%';
|
200 |
+
|
201 |
+
$count = $wpdb->get_var( $wpdb->prepare( "
|
202 |
+
SELECT COUNT(*)
|
203 |
+
FROM {$table}
|
204 |
+
WHERE {$column} LIKE %s
|
205 |
+
", $key ) );
|
206 |
+
|
207 |
+
return ( $count > 0 ) ? false : true;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Is process running
|
212 |
+
*
|
213 |
+
* Check whether the current process is already running
|
214 |
+
* in a background process.
|
215 |
+
*/
|
216 |
+
protected function is_process_running() {
|
217 |
+
if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
|
218 |
+
// Process already running.
|
219 |
+
return true;
|
220 |
+
}
|
221 |
+
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Lock process
|
227 |
+
*
|
228 |
+
* Lock the process so that multiple instances can't run simultaneously.
|
229 |
+
* Override if applicable, but the duration should be greater than that
|
230 |
+
* defined in the time_exceeded() method.
|
231 |
+
*/
|
232 |
+
protected function lock_process() {
|
233 |
+
$this->start_time = time(); // Set start time of current process.
|
234 |
+
|
235 |
+
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
|
236 |
+
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
|
237 |
+
|
238 |
+
set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Unlock process
|
243 |
+
*
|
244 |
+
* Unlock the process so that other instances can spawn.
|
245 |
+
*
|
246 |
+
* @return $this
|
247 |
+
*/
|
248 |
+
protected function unlock_process() {
|
249 |
+
delete_site_transient( $this->identifier . '_process_lock' );
|
250 |
+
|
251 |
+
return $this;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Get batch
|
256 |
+
*
|
257 |
+
* @return stdClass Return the first batch from the queue
|
258 |
+
*/
|
259 |
+
protected function get_batch() {
|
260 |
+
global $wpdb;
|
261 |
+
|
262 |
+
$table = $wpdb->options;
|
263 |
+
$column = 'option_name';
|
264 |
+
$key_column = 'option_id';
|
265 |
+
$value_column = 'option_value';
|
266 |
+
|
267 |
+
if ( is_multisite() ) {
|
268 |
+
$table = $wpdb->sitemeta;
|
269 |
+
$column = 'meta_key';
|
270 |
+
$key_column = 'meta_id';
|
271 |
+
$value_column = 'meta_value';
|
272 |
+
}
|
273 |
+
|
274 |
+
$key = $this->identifier . '_batch_%';
|
275 |
+
|
276 |
+
$query = $wpdb->get_row( $wpdb->prepare( "
|
277 |
+
SELECT *
|
278 |
+
FROM {$table}
|
279 |
+
WHERE {$column} LIKE %s
|
280 |
+
ORDER BY {$key_column} ASC
|
281 |
+
LIMIT 1
|
282 |
+
", $key ) );
|
283 |
+
|
284 |
+
$batch = new stdClass();
|
285 |
+
$batch->key = $query->$column;
|
286 |
+
$batch->data = maybe_unserialize( $query->$value_column );
|
287 |
+
|
288 |
+
return $batch;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Handle
|
293 |
+
*
|
294 |
+
* Pass each queue item to the task handler, while remaining
|
295 |
+
* within server memory and time limit constraints.
|
296 |
+
*/
|
297 |
+
protected function handle() {
|
298 |
+
$this->lock_process();
|
299 |
+
|
300 |
+
do {
|
301 |
+
$batch = $this->get_batch();
|
302 |
+
|
303 |
+
foreach ( $batch->data as $key => $value ) {
|
304 |
+
$task = $this->task( $value );
|
305 |
+
|
306 |
+
if ( false !== $task ) {
|
307 |
+
$batch->data[ $key ] = $task;
|
308 |
+
} else {
|
309 |
+
unset( $batch->data[ $key ] );
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( $this->time_exceeded() || $this->memory_exceeded() ) {
|
313 |
+
// Batch limits reached.
|
314 |
+
break;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
// Update or delete current batch.
|
319 |
+
if ( ! empty( $batch->data ) ) {
|
320 |
+
$this->update( $batch->key, $batch->data );
|
321 |
+
} else {
|
322 |
+
$this->delete( $batch->key );
|
323 |
+
}
|
324 |
+
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
|
325 |
+
|
326 |
+
$this->unlock_process();
|
327 |
+
|
328 |
+
// Start next batch or complete process.
|
329 |
+
if ( ! $this->is_queue_empty() ) {
|
330 |
+
$this->dispatch();
|
331 |
+
} else {
|
332 |
+
$this->complete();
|
333 |
+
}
|
334 |
+
|
335 |
+
wp_die();
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Memory exceeded
|
340 |
+
*
|
341 |
+
* Ensures the batch process never exceeds 90%
|
342 |
+
* of the maximum WordPress memory.
|
343 |
+
*
|
344 |
+
* @return bool
|
345 |
+
*/
|
346 |
+
protected function memory_exceeded() {
|
347 |
+
$memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
|
348 |
+
$current_memory = memory_get_usage( true );
|
349 |
+
$return = false;
|
350 |
+
|
351 |
+
if ( $current_memory >= $memory_limit ) {
|
352 |
+
$return = true;
|
353 |
+
}
|
354 |
+
|
355 |
+
return apply_filters( $this->identifier . '_memory_exceeded', $return );
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Get memory limit
|
360 |
+
*
|
361 |
+
* @return int
|
362 |
+
*/
|
363 |
+
protected function get_memory_limit() {
|
364 |
+
if ( function_exists( 'ini_get' ) ) {
|
365 |
+
$memory_limit = ini_get( 'memory_limit' );
|
366 |
+
} else {
|
367 |
+
// Sensible default.
|
368 |
+
$memory_limit = '128M';
|
369 |
+
}
|
370 |
+
|
371 |
+
if ( ! $memory_limit || -1 === $memory_limit ) {
|
372 |
+
// Unlimited, set to 32GB.
|
373 |
+
$memory_limit = '32000M';
|
374 |
+
}
|
375 |
+
|
376 |
+
return intval( $memory_limit ) * 1024 * 1024;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Time exceeded.
|
381 |
+
*
|
382 |
+
* Ensures the batch never exceeds a sensible time limit.
|
383 |
+
* A timeout limit of 30s is common on shared hosting.
|
384 |
+
*
|
385 |
+
* @return bool
|
386 |
+
*/
|
387 |
+
protected function time_exceeded() {
|
388 |
+
$finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
|
389 |
+
$return = false;
|
390 |
+
|
391 |
+
if ( time() >= $finish ) {
|
392 |
+
$return = true;
|
393 |
+
}
|
394 |
+
|
395 |
+
return apply_filters( $this->identifier . '_time_exceeded', $return );
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Complete.
|
400 |
+
*
|
401 |
+
* Override if applicable, but ensure that the below actions are
|
402 |
+
* performed, or, call parent::complete().
|
403 |
+
*/
|
404 |
+
protected function complete() {
|
405 |
+
// Unschedule the cron healthcheck.
|
406 |
+
$this->clear_scheduled_event();
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Schedule cron healthcheck
|
411 |
+
*
|
412 |
+
* @access public
|
413 |
+
* @param mixed $schedules Schedules.
|
414 |
+
* @return mixed
|
415 |
+
*/
|
416 |
+
public function schedule_cron_healthcheck( $schedules ) {
|
417 |
+
$interval = apply_filters( $this->identifier . '_cron_interval', 5 );
|
418 |
+
|
419 |
+
if ( property_exists( $this, 'cron_interval' ) ) {
|
420 |
+
$interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier );
|
421 |
+
}
|
422 |
+
|
423 |
+
// Adds every 5 minutes to the existing schedules.
|
424 |
+
$schedules[ $this->identifier . '_cron_interval' ] = array(
|
425 |
+
'interval' => MINUTE_IN_SECONDS * $interval,
|
426 |
+
'display' => sprintf( __( 'Every %d Minutes', 'astra-sites' ), $interval ),
|
427 |
+
);
|
428 |
+
|
429 |
+
return $schedules;
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Handle cron healthcheck
|
434 |
+
*
|
435 |
+
* Restart the background process if not already running
|
436 |
+
* and data exists in the queue.
|
437 |
+
*/
|
438 |
+
public function handle_cron_healthcheck() {
|
439 |
+
if ( $this->is_process_running() ) {
|
440 |
+
// Background process already running.
|
441 |
+
exit;
|
442 |
+
}
|
443 |
+
|
444 |
+
if ( $this->is_queue_empty() ) {
|
445 |
+
// No data to process.
|
446 |
+
$this->clear_scheduled_event();
|
447 |
+
exit;
|
448 |
+
}
|
449 |
+
|
450 |
+
$this->handle();
|
451 |
+
|
452 |
+
exit;
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Schedule event
|
457 |
+
*/
|
458 |
+
protected function schedule_event() {
|
459 |
+
if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
|
460 |
+
wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
|
461 |
+
}
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* Clear scheduled event
|
466 |
+
*/
|
467 |
+
protected function clear_scheduled_event() {
|
468 |
+
$timestamp = wp_next_scheduled( $this->cron_hook_identifier );
|
469 |
+
|
470 |
+
if ( $timestamp ) {
|
471 |
+
wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Cancel Process
|
477 |
+
*
|
478 |
+
* Stop processing queue items, clear cronjob and delete batch.
|
479 |
+
*
|
480 |
+
*/
|
481 |
+
public function cancel_process() {
|
482 |
+
if ( ! $this->is_queue_empty() ) {
|
483 |
+
$batch = $this->get_batch();
|
484 |
+
|
485 |
+
$this->delete( $batch->key );
|
486 |
+
|
487 |
+
wp_clear_scheduled_hook( $this->cron_hook_identifier );
|
488 |
+
}
|
489 |
+
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* Task
|
494 |
+
*
|
495 |
+
* Override this method to perform any actions required on each
|
496 |
+
* queue item. Return the modified item for further processing
|
497 |
+
* in the next pass through. Or, return false to remove the
|
498 |
+
* item from the queue.
|
499 |
+
*
|
500 |
+
* @param mixed $item Queue item to iterate over.
|
501 |
+
*
|
502 |
+
* @return mixed
|
503 |
+
*/
|
504 |
+
abstract protected function task( $item );
|
505 |
+
|
506 |
+
}
|
507 |
+
}
|
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,83 +24,83 @@ msgstr ""
|
|
24 |
"X-Textdomain-Support: yes\n"
|
25 |
"X-Generator: grunt-wp-i18n1.0.0\n"
|
26 |
|
27 |
-
|
28 |
-
msgid "Astra Sites
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: inc/admin/class-astra-sites-page.php:
|
32 |
msgid "Settings saved successfully."
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: inc/admin/view-astra-sites.php:
|
36 |
msgid "All"
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: inc/admin/view-astra-sites.php:
|
40 |
msgid "Search Sites"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: inc/admin/view-astra-sites.php:
|
44 |
msgid "Search Sites..."
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: inc/admin/view-astra-sites.php:
|
48 |
msgid "Details & Preview"
|
49 |
msgstr ""
|
50 |
|
51 |
-
#: inc/admin/view-astra-sites.php:
|
52 |
msgid "Preview"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: inc/admin/view-astra-sites.php:
|
56 |
msgid "Close"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: inc/admin/view-astra-sites.php:
|
60 |
msgid "Previous"
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: inc/admin/view-astra-sites.php:
|
64 |
msgid "Next"
|
65 |
msgstr ""
|
66 |
|
67 |
-
#: inc/admin/view-astra-sites.php:
|
68 |
msgid "Install Plugins"
|
69 |
msgstr ""
|
70 |
|
71 |
-
#: inc/admin/view-astra-sites.php:
|
72 |
msgid "Read more"
|
73 |
msgstr ""
|
74 |
|
75 |
-
#: inc/admin/view-astra-sites.php:
|
76 |
msgid "Required Plugins"
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: inc/admin/view-astra-sites.php:
|
80 |
msgid "Collapse"
|
81 |
msgstr ""
|
82 |
|
83 |
-
#: inc/admin/view-astra-sites.php:
|
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:
|
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/admin/view-astra-sites.php:
|
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/admin/view-astra-sites.php:
|
104 |
#. translators: %1$s is a support link
|
105 |
msgid ""
|
106 |
"<p>If that does not help, please open up a <a href=\"%1$s\" "
|
@@ -108,62 +108,66 @@ msgid ""
|
|
108 |
"for you.</p>"
|
109 |
msgstr ""
|
110 |
|
111 |
-
#: inc/classes/class-astra-sites.php:
|
112 |
#. translators: 1: theme.php file
|
113 |
msgid ""
|
114 |
"Astra Theme needs to be active for you to use currently installed \"Astra "
|
115 |
"Sites\" plugin. <a href=\"%1$s\">Install & Activate Now</a>"
|
116 |
msgstr ""
|
117 |
|
118 |
-
#: inc/classes/class-astra-sites.php:
|
119 |
msgid "See Library"
|
120 |
msgstr ""
|
121 |
|
122 |
-
#: inc/classes/class-astra-sites.php:
|
123 |
msgid "Purchase"
|
124 |
msgstr ""
|
125 |
|
126 |
-
#: inc/classes/class-astra-sites.php:
|
127 |
msgid "Upgrade"
|
128 |
msgstr ""
|
129 |
|
130 |
-
#: inc/classes/class-astra-sites.php:
|
131 |
msgid "Error!"
|
132 |
msgstr ""
|
133 |
|
134 |
-
#: inc/classes/class-astra-sites.php:
|
135 |
msgid "Error! Read Possibilities."
|
136 |
msgstr ""
|
137 |
|
138 |
-
#: inc/classes/class-astra-sites.php:
|
139 |
msgid "Done! View Site"
|
140 |
msgstr ""
|
141 |
|
142 |
-
#: inc/classes/class-astra-sites.php:
|
143 |
msgid "Activating"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: inc/classes/class-astra-sites.php:
|
147 |
msgid "Active"
|
148 |
msgstr ""
|
149 |
|
150 |
-
#: inc/classes/class-astra-sites.php:
|
151 |
msgid "Import This Site"
|
152 |
msgstr ""
|
153 |
|
154 |
-
#: inc/classes/class-astra-sites.php:
|
|
|
|
|
|
|
|
|
155 |
msgid "Hide"
|
156 |
msgstr ""
|
157 |
|
158 |
-
#: inc/classes/class-astra-sites.php:
|
159 |
msgid "There was a problem receiving a response from server."
|
160 |
msgstr ""
|
161 |
|
162 |
-
#: inc/classes/class-astra-sites.php:
|
163 |
msgid "No Demos found, Try a different search."
|
164 |
msgstr ""
|
165 |
|
166 |
-
#: inc/classes/class-astra-sites.php:
|
167 |
msgid ""
|
168 |
"Executing Demo Import will make your site similar as ours. Please bear in "
|
169 |
"mind -\n"
|
@@ -177,22 +181,30 @@ msgid ""
|
|
177 |
"placeholders."
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: inc/classes/class-astra-sites.php:
|
181 |
msgid "No plugin specified"
|
182 |
msgstr ""
|
183 |
|
184 |
-
#: inc/classes/class-astra-sites.php:
|
185 |
msgid "Plugin Successfully Activated"
|
186 |
msgstr ""
|
187 |
|
188 |
-
#: inc/classes/class-astra-sites.php:
|
189 |
msgid "You have not \"customize\" access to import the astra site."
|
190 |
msgstr ""
|
191 |
|
192 |
-
#: inc/classes/class-astra-sites.php:
|
193 |
msgid "Demo Imported Successfully."
|
194 |
msgstr ""
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
#: inc/importers/class-widgets-importer.php:83
|
197 |
msgid "Import data could not be read. Please try a different file."
|
198 |
msgstr ""
|
@@ -368,6 +380,10 @@ msgstr ""
|
|
368 |
msgid "Could not update comment #%d with mapped data"
|
369 |
msgstr ""
|
370 |
|
|
|
|
|
|
|
|
|
371 |
#. Plugin URI of the plugin/theme
|
372 |
msgid "http://www.wpastra.com/pro/"
|
373 |
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.11\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
+
"POT-Creation-Date: 2017-09-20 12:32:51+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 |
+
#: inc/admin/class-astra-sites-page.php:85
|
28 |
+
msgid "Astra Sites"
|
29 |
msgstr ""
|
30 |
|
31 |
+
#: inc/admin/class-astra-sites-page.php:192
|
32 |
msgid "Settings saved successfully."
|
33 |
msgstr ""
|
34 |
|
35 |
+
#: inc/admin/view-astra-sites.php:43
|
36 |
msgid "All"
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: inc/admin/view-astra-sites.php:57
|
40 |
msgid "Search Sites"
|
41 |
msgstr ""
|
42 |
|
43 |
+
#: inc/admin/view-astra-sites.php:58
|
44 |
msgid "Search Sites..."
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: inc/admin/view-astra-sites.php:108
|
48 |
msgid "Details & Preview"
|
49 |
msgstr ""
|
50 |
|
51 |
+
#: inc/admin/view-astra-sites.php:114 inc/admin/view-astra-sites.php:183
|
52 |
msgid "Preview"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: inc/admin/view-astra-sites.php:141
|
56 |
msgid "Close"
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: inc/admin/view-astra-sites.php:142
|
60 |
msgid "Previous"
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: inc/admin/view-astra-sites.php:143
|
64 |
msgid "Next"
|
65 |
msgstr ""
|
66 |
|
67 |
+
#: inc/admin/view-astra-sites.php:144 inc/admin/view-astra-sites.php:172
|
68 |
msgid "Install Plugins"
|
69 |
msgstr ""
|
70 |
|
71 |
+
#: inc/admin/view-astra-sites.php:160 inc/classes/class-astra-sites.php:260
|
72 |
msgid "Read more"
|
73 |
msgstr ""
|
74 |
|
75 |
+
#: inc/admin/view-astra-sites.php:163
|
76 |
msgid "Required Plugins"
|
77 |
msgstr ""
|
78 |
|
79 |
+
#: inc/admin/view-astra-sites.php:178
|
80 |
msgid "Collapse"
|
81 |
msgstr ""
|
82 |
|
83 |
+
#: inc/admin/view-astra-sites.php:193
|
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:195
|
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/admin/view-astra-sites.php:197
|
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/admin/view-astra-sites.php:200
|
104 |
#. translators: %1$s is a support link
|
105 |
msgid ""
|
106 |
"<p>If that does not help, please open up a <a href=\"%1$s\" "
|
108 |
"for you.</p>"
|
109 |
msgstr ""
|
110 |
|
111 |
+
#: inc/classes/class-astra-sites.php:83
|
112 |
#. translators: 1: theme.php file
|
113 |
msgid ""
|
114 |
"Astra Theme needs to be active for you to use currently installed \"Astra "
|
115 |
"Sites\" plugin. <a href=\"%1$s\">Install & Activate Now</a>"
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: inc/classes/class-astra-sites.php:123
|
119 |
msgid "See Library"
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: inc/classes/class-astra-sites.php:245
|
123 |
msgid "Purchase"
|
124 |
msgstr ""
|
125 |
|
126 |
+
#: inc/classes/class-astra-sites.php:247
|
127 |
msgid "Upgrade"
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: inc/classes/class-astra-sites.php:252
|
131 |
msgid "Error!"
|
132 |
msgstr ""
|
133 |
|
134 |
+
#: inc/classes/class-astra-sites.php:253
|
135 |
msgid "Error! Read Possibilities."
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: inc/classes/class-astra-sites.php:255
|
139 |
msgid "Done! View Site"
|
140 |
msgstr ""
|
141 |
|
142 |
+
#: inc/classes/class-astra-sites.php:256
|
143 |
msgid "Activating"
|
144 |
msgstr ""
|
145 |
|
146 |
+
#: inc/classes/class-astra-sites.php:257
|
147 |
msgid "Active"
|
148 |
msgstr ""
|
149 |
|
150 |
+
#: inc/classes/class-astra-sites.php:258
|
151 |
msgid "Import This Site"
|
152 |
msgstr ""
|
153 |
|
154 |
+
#: inc/classes/class-astra-sites.php:259
|
155 |
+
msgid "Importing Demo"
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
#: inc/classes/class-astra-sites.php:261
|
159 |
msgid "Hide"
|
160 |
msgstr ""
|
161 |
|
162 |
+
#: inc/classes/class-astra-sites.php:262
|
163 |
msgid "There was a problem receiving a response from server."
|
164 |
msgstr ""
|
165 |
|
166 |
+
#: inc/classes/class-astra-sites.php:263
|
167 |
msgid "No Demos found, Try a different search."
|
168 |
msgstr ""
|
169 |
|
170 |
+
#: inc/classes/class-astra-sites.php:264
|
171 |
msgid ""
|
172 |
"Executing Demo Import will make your site similar as ours. Please bear in "
|
173 |
"mind -\n"
|
181 |
"placeholders."
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: inc/classes/class-astra-sites.php:304
|
185 |
msgid "No plugin specified"
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: inc/classes/class-astra-sites.php:333
|
189 |
msgid "Plugin Successfully Activated"
|
190 |
msgstr ""
|
191 |
|
192 |
+
#: inc/classes/class-astra-sites.php:462
|
193 |
msgid "You have not \"customize\" access to import the astra site."
|
194 |
msgstr ""
|
195 |
|
196 |
+
#: inc/classes/class-astra-sites.php:470
|
197 |
msgid "Demo Imported Successfully."
|
198 |
msgstr ""
|
199 |
|
200 |
+
#: inc/classes/compatibility/elementor/class-astra-sites-source-remote.php:58
|
201 |
+
msgid "Remote"
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: inc/classes/vendor/wp-background-process.php:426
|
205 |
+
msgid "Every %d Minutes"
|
206 |
+
msgstr ""
|
207 |
+
|
208 |
#: inc/importers/class-widgets-importer.php:83
|
209 |
msgid "Import data could not be read. Please try a different file."
|
210 |
msgstr ""
|
380 |
msgid "Could not update comment #%d with mapped data"
|
381 |
msgstr ""
|
382 |
|
383 |
+
#. Plugin Name of the plugin/theme
|
384 |
+
msgid "Astra Sites - Lite"
|
385 |
+
msgstr ""
|
386 |
+
|
387 |
#. Plugin URI of the plugin/theme
|
388 |
msgid "http://www.wpastra.com/pro/"
|
389 |
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 |
|
@@ -46,6 +46,13 @@ https://sites.wpastra.com/law-free/
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
v1.0.10 - 11-Sept-2017
|
50 |
* Improvement: Added support for retina logo import.
|
51 |
* Fix: Site logo image not displayed in customizer.
|
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.11
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
46 |
|
47 |
== Changelog ==
|
48 |
|
49 |
+
v1.0.11 - 22-Sept-2017
|
50 |
+
* New: Single click Install & activate required plugins.
|
51 |
+
* New: Added filter `astra_sites_menu_item` for adding extra tabs in admin page.
|
52 |
+
* New: Added back image import feature for `elementor` page builder. In batch image import we import all images from astra site into client site.
|
53 |
+
* Improvement: Updated JS code with object prototype.
|
54 |
+
* Fix: Screen bounce on retina devices.
|
55 |
+
|
56 |
v1.0.10 - 11-Sept-2017
|
57 |
* Improvement: Added support for retina logo import.
|
58 |
* Fix: Site logo image not displayed in customizer.
|