Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | |
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 |
|