Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Astra Starter Sites |
Version | 1.1.4 |
Comparing to | |
See all releases |
Code changes from version 1.1.3 to 1.1.4
- astra-sites.php +2 -2
- inc/admin/class-astra-sites-page.php +0 -270
- inc/admin/view-astra-sites.php +0 -211
- inc/assets/css/admin.css +3 -0
- inc/assets/js/admin-page.js +24 -10
- inc/assets/js/admin.js +0 -1138
- inc/assets/js/astra-sites-notices.js +1 -1
- inc/assets/vendor/js/jquery.lazy.js +0 -830
- inc/assets/vendor/js/jquery.lazy.min.js +0 -2
- inc/classes/class-astra-sites-importer.php +4 -1
- inc/classes/class-astra-sites-notices.php +3 -7
- inc/classes/class-astra-sites.php +3 -3
- inc/classes/compatibility/class-astra-sites-compatibility-astra-pro.php +0 -86
- inc/classes/compatibility/class-astra-sites-compatibility-so-widgets.php +0 -86
- inc/classes/compatibility/class-astra-sites-compatibility.php +4 -0
- inc/classes/compatibility/elementor/background-processing/class-astra-elementor-image-importer-process.php +0 -64
- inc/classes/compatibility/elementor/class-astra-sites-compatibility-elementor.php +0 -144
- inc/classes/compatibility/elementor/class-astra-sites-source-remote.php +0 -302
- inc/classes/compatibility/woocommerce/class-astra-sites-compatibility-woocommerce.php +85 -0
- inc/classes/vendor/wp-async-request.php +0 -164
- inc/classes/vendor/wp-background-process.php +0 -507
- inc/importers/class-astra-site-options-import.php +53 -5
- languages/astra-sites.pot +38 -42
- readme.txt +6 -1
astra-sites.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Astra Starter Sites
|
4 |
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
* Description: Import free sites build with Astra theme.
|
6 |
-
* Version: 1.1.
|
7 |
* Author: Brainstorm Force
|
8 |
* Author URI: http://www.brainstormforce.com
|
9 |
* Text Domain: astra-sites
|
@@ -19,7 +19,7 @@ if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
|
|
19 |
}
|
20 |
|
21 |
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
22 |
-
define( 'ASTRA_SITES_VER', '1.1.
|
23 |
}
|
24 |
|
25 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
3 |
* Plugin Name: Astra Starter Sites
|
4 |
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
* Description: Import free sites build with Astra theme.
|
6 |
+
* Version: 1.1.4
|
7 |
* Author: Brainstorm Force
|
8 |
* Author URI: http://www.brainstormforce.com
|
9 |
* Text Domain: astra-sites
|
19 |
}
|
20 |
|
21 |
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
22 |
+
define( 'ASTRA_SITES_VER', '1.1.4' );
|
23 |
}
|
24 |
|
25 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
inc/admin/class-astra-sites-page.php
DELETED
@@ -1,270 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Astra Sites Page
|
4 |
-
*
|
5 |
-
* @since 1.0.6
|
6 |
-
* @package Astra Sites
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
if ( ! class_exists( 'Astra_Sites_Page' ) ) {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Astra Admin Settings
|
17 |
-
*/
|
18 |
-
class Astra_Sites_Page {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* View all actions
|
22 |
-
*
|
23 |
-
* @since 1.0.6
|
24 |
-
* @var array $view_actions
|
25 |
-
*/
|
26 |
-
static public $view_actions = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Menu page title
|
30 |
-
*
|
31 |
-
* @since 1.0.6
|
32 |
-
* @var array $menu_page_title
|
33 |
-
*/
|
34 |
-
static public $menu_page_title = ASTRA_SITES_NAME;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Plugin slug
|
38 |
-
*
|
39 |
-
* @since 1.0.6
|
40 |
-
* @var array $plugin_slug
|
41 |
-
*/
|
42 |
-
static public $plugin_slug = 'astra-sites';
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Default Menu position
|
46 |
-
*
|
47 |
-
* @since 1.0.6
|
48 |
-
* @var array $default_menu_position
|
49 |
-
*/
|
50 |
-
static public $default_menu_position = 'themes.php';
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Parent Page Slug
|
54 |
-
*
|
55 |
-
* @since 1.0.6
|
56 |
-
* @var array $parent_page_slug
|
57 |
-
*/
|
58 |
-
static public $parent_page_slug = 'general';
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Current Slug
|
62 |
-
*
|
63 |
-
* @since 1.0.6
|
64 |
-
* @var array $current_slug
|
65 |
-
*/
|
66 |
-
static public $current_slug = 'general';
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Constructor
|
70 |
-
*/
|
71 |
-
function __construct() {
|
72 |
-
|
73 |
-
if ( ! is_admin() ) {
|
74 |
-
return;
|
75 |
-
}
|
76 |
-
|
77 |
-
add_action( 'after_setup_theme', __CLASS__ . '::init_admin_settings', 99 );
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Admin settings init
|
82 |
-
*/
|
83 |
-
static public function init_admin_settings() {
|
84 |
-
|
85 |
-
self::$menu_page_title = apply_filters( 'astra_sites_menu_page_title', __( 'Astra Sites' , 'astra-sites' ) );
|
86 |
-
|
87 |
-
if ( isset( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], self::$plugin_slug ) !== false ) {
|
88 |
-
|
89 |
-
// Let extensions hook into saving.
|
90 |
-
self::save_settings();
|
91 |
-
}
|
92 |
-
|
93 |
-
add_action( 'admin_menu', __CLASS__ . '::add_admin_menu', 100 );
|
94 |
-
|
95 |
-
add_action( 'astra_sites_menu_general_action', __CLASS__ . '::general_page' );
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Save All admin settings here
|
100 |
-
*/
|
101 |
-
static public function save_settings() {
|
102 |
-
|
103 |
-
// Only admins can save settings.
|
104 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
105 |
-
return;
|
106 |
-
}
|
107 |
-
|
108 |
-
// Let extensions hook into saving.
|
109 |
-
do_action( 'astra_sites_save_settings' );
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Init Nav Menu
|
114 |
-
*
|
115 |
-
* @param mixed $action Action name.
|
116 |
-
* @since 1.0.6
|
117 |
-
*/
|
118 |
-
static public function init_nav_menu( $action = '' ) {
|
119 |
-
|
120 |
-
if ( '' !== $action ) {
|
121 |
-
self::render_tab_menu( $action );
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Render tab menu
|
127 |
-
*
|
128 |
-
* @param mixed $action Action name.
|
129 |
-
* @since 1.0.6
|
130 |
-
*/
|
131 |
-
static public function render_tab_menu( $action = '' ) {
|
132 |
-
?>
|
133 |
-
<div id="astra-sites-menu-page">
|
134 |
-
<?php self::render( $action ); ?>
|
135 |
-
</div>
|
136 |
-
<?php
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* View actions
|
141 |
-
*
|
142 |
-
* @since 1.0.11
|
143 |
-
*/
|
144 |
-
static public function get_view_actions() {
|
145 |
-
|
146 |
-
if ( empty( self::$view_actions ) ) {
|
147 |
-
|
148 |
-
self::$view_actions = apply_filters(
|
149 |
-
'astra_sites_menu_item', array()
|
150 |
-
);
|
151 |
-
}
|
152 |
-
|
153 |
-
return self::$view_actions;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Prints HTML content for tabs
|
158 |
-
*
|
159 |
-
* @param mixed $action Action name.
|
160 |
-
* @since 1.0.6
|
161 |
-
*/
|
162 |
-
static public function render( $action ) {
|
163 |
-
|
164 |
-
?>
|
165 |
-
<div class="nav-tab-wrapper">
|
166 |
-
<h1 class='astra-sites-title'> <?php echo esc_html( self::$menu_page_title ); ?> </h1>
|
167 |
-
<?php
|
168 |
-
$view_actions = self::get_view_actions();
|
169 |
-
|
170 |
-
foreach ( $view_actions as $slug => $data ) {
|
171 |
-
|
172 |
-
if ( ! $data['show'] ) {
|
173 |
-
continue;
|
174 |
-
}
|
175 |
-
|
176 |
-
$url = self::get_page_url( $slug );
|
177 |
-
|
178 |
-
if ( $slug == self::$parent_page_slug ) {
|
179 |
-
update_option( 'astra_parent_page_url', $url );
|
180 |
-
}
|
181 |
-
|
182 |
-
$active = ( $slug == $action ) ? 'nav-tab-active' : '';
|
183 |
-
?>
|
184 |
-
<a class='nav-tab <?php echo esc_attr( $active ); ?>' href='<?php echo esc_url( $url ); ?>'> <?php echo esc_html( $data['label'] ); ?> </a>
|
185 |
-
<?php } ?>
|
186 |
-
</div><!-- .nav-tab-wrapper -->
|
187 |
-
|
188 |
-
<?php
|
189 |
-
// Settings update message.
|
190 |
-
if ( isset( $_REQUEST['message'] ) && ( 'saved' == $_REQUEST['message'] || 'saved_ext' == $_REQUEST['message'] ) ) {
|
191 |
-
?>
|
192 |
-
<span id="message" class="notice notice-success is-dismissive"><p> <?php esc_html_e( 'Settings saved successfully.', 'astra-sites' ); ?> </p></span>
|
193 |
-
<?php
|
194 |
-
}
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Get and return page URL
|
200 |
-
*
|
201 |
-
* @param string $menu_slug Menu name.
|
202 |
-
* @since 1.0.6
|
203 |
-
* @return string page url
|
204 |
-
*/
|
205 |
-
static public function get_page_url( $menu_slug ) {
|
206 |
-
|
207 |
-
$parent_page = self::$default_menu_position;
|
208 |
-
|
209 |
-
if ( strpos( $parent_page, '?' ) !== false ) {
|
210 |
-
$query_var = '&page=' . self::$plugin_slug;
|
211 |
-
} else {
|
212 |
-
$query_var = '?page=' . self::$plugin_slug;
|
213 |
-
}
|
214 |
-
|
215 |
-
$parent_page_url = admin_url( $parent_page . $query_var );
|
216 |
-
|
217 |
-
$url = $parent_page_url . '&action=' . $menu_slug;
|
218 |
-
|
219 |
-
return esc_url( $url );
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Add main menu
|
224 |
-
*
|
225 |
-
* @since 1.0.6
|
226 |
-
*/
|
227 |
-
static public function add_admin_menu() {
|
228 |
-
|
229 |
-
$parent_page = self::$default_menu_position;
|
230 |
-
$page_title = self::$menu_page_title;
|
231 |
-
$capability = 'manage_options';
|
232 |
-
$page_menu_slug = self::$plugin_slug;
|
233 |
-
$page_menu_func = __CLASS__ . '::menu_callback';
|
234 |
-
|
235 |
-
add_theme_page( $page_title, $page_title, $capability, $page_menu_slug, $page_menu_func );
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Menu callback
|
240 |
-
*
|
241 |
-
* @since 1.0.6
|
242 |
-
*/
|
243 |
-
static public function menu_callback() {
|
244 |
-
|
245 |
-
$current_slug = isset( $_GET['action'] ) ? esc_attr( $_GET['action'] ) : self::$current_slug;
|
246 |
-
|
247 |
-
$active_tab = str_replace( '_', '-', $current_slug );
|
248 |
-
$current_slug = str_replace( '-', '_', $current_slug );
|
249 |
-
|
250 |
-
?>
|
251 |
-
<div class="astra-sites-menu-page-wrapper">
|
252 |
-
<?php self::init_nav_menu( $active_tab ); ?>
|
253 |
-
<?php do_action( 'astra_sites_menu_' . esc_attr( $current_slug ) . '_action' ); ?>
|
254 |
-
</div>
|
255 |
-
<?php
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Include general page
|
260 |
-
*
|
261 |
-
* @since 1.0.6
|
262 |
-
*/
|
263 |
-
static public function general_page() {
|
264 |
-
require_once ASTRA_SITES_DIR . 'inc/admin/view-astra-sites.php';
|
265 |
-
}
|
266 |
-
}
|
267 |
-
|
268 |
-
new Astra_Sites_Page;
|
269 |
-
|
270 |
-
}// End if().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/admin/view-astra-sites.php
DELETED
@@ -1,211 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Astra Demo View.
|
4 |
-
*
|
5 |
-
* @package Astra Addon
|
6 |
-
*/
|
7 |
-
|
8 |
-
defined( 'ABSPATH' ) or exit;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Initial Demo List
|
12 |
-
*
|
13 |
-
* Generated though PHP
|
14 |
-
*/
|
15 |
-
?>
|
16 |
-
<div class="wrap">
|
17 |
-
|
18 |
-
|
19 |
-
<div class="wp-filter hide-if-no-js">
|
20 |
-
|
21 |
-
<div class="section-left">
|
22 |
-
|
23 |
-
<div class="filter-count">
|
24 |
-
<span class="count"></span>
|
25 |
-
</div>
|
26 |
-
|
27 |
-
<ul class="filter-links astra-page-builder">
|
28 |
-
<?php
|
29 |
-
foreach ( Astra_Sites::get_page_builders() as $key => $category ) {
|
30 |
-
$current = '';
|
31 |
-
|
32 |
-
if ( 0 === $key ) {
|
33 |
-
$current = 'current';
|
34 |
-
}
|
35 |
-
?>
|
36 |
-
<li>
|
37 |
-
<a href="#"
|
38 |
-
data-sort="<?php echo esc_attr( $category['slug'] ); ?>"
|
39 |
-
data-id="<?php echo esc_attr( $category['id'] ); ?>"
|
40 |
-
class="<?php echo esc_attr( $current ); ?>">
|
41 |
-
<?php echo esc_attr( $category['name'] ); ?>
|
42 |
-
</a>
|
43 |
-
</li>
|
44 |
-
<?php } ?>
|
45 |
-
</ul>
|
46 |
-
</div>
|
47 |
-
|
48 |
-
<div class="section-right">
|
49 |
-
<ul class="filter-links astra-category">
|
50 |
-
|
51 |
-
<li><a href="#" data-sort="all" class="current" data-id="all"><?php esc_html_e( 'All', 'astra-sites' ); ?></a></li>
|
52 |
-
|
53 |
-
<?php foreach ( Astra_Sites::get_demo_categories() as $key => $category ) { ?>
|
54 |
-
<li>
|
55 |
-
<a href="#"
|
56 |
-
data-sort="<?php echo esc_attr( $category['slug'] ); ?>"
|
57 |
-
data-id="<?php echo esc_attr( $category['id'] ); ?>">
|
58 |
-
<?php echo esc_attr( $category['name'] ); ?>
|
59 |
-
</a>
|
60 |
-
</li>
|
61 |
-
<?php } ?>
|
62 |
-
</ul>
|
63 |
-
|
64 |
-
<div class="search-form">
|
65 |
-
<label class="screen-reader-text" for="wp-filter-search-input"><?php esc_html_e( 'Search Sites', 'astra-sites' ); ?></label>
|
66 |
-
<input placeholder="<?php esc_attr_e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
|
67 |
-
</div>
|
68 |
-
</div>
|
69 |
-
|
70 |
-
</div>
|
71 |
-
|
72 |
-
<?php do_action( 'astra_sites_before_site_grid' ); ?>
|
73 |
-
|
74 |
-
<span class="spinner"></span>
|
75 |
-
|
76 |
-
<div class="theme-browser rendered">
|
77 |
-
<div class="themes wp-clearfix"></div>
|
78 |
-
</div>
|
79 |
-
|
80 |
-
<?php do_action( 'astra_sites_after_site_grid' ); ?>
|
81 |
-
|
82 |
-
</div>
|
83 |
-
|
84 |
-
<?php
|
85 |
-
/**
|
86 |
-
* Regenerated Demo List
|
87 |
-
*
|
88 |
-
* Generated though JS after search demo, filter demo etc.
|
89 |
-
*/
|
90 |
-
?>
|
91 |
-
<script type="text/template" id="tmpl-astra-single-demo">
|
92 |
-
<div class="theme astra-theme {{data.status}}" tabindex="0" aria-describedby="astra-theme-action astra-theme-name"
|
93 |
-
data-demo-id="{{{data.id}}}"
|
94 |
-
data-demo-type="{{{data.astra_demo_type}}}"
|
95 |
-
data-demo-url="{{{data.astra_demo_url}}}"
|
96 |
-
data-demo-api="{{{data.demo_api}}}"
|
97 |
-
data-demo-name="{{{data.demo_name}}}"
|
98 |
-
data-demo-slug="{{{data.slug}}}"
|
99 |
-
data-screenshot="{{{data.screenshot}}}"
|
100 |
-
data-content="{{{data.content}}}"
|
101 |
-
data-required-plugins="{{data.required_plugins}}">
|
102 |
-
<input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
|
103 |
-
<input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
|
104 |
-
|
105 |
-
<span class="status {{data.status}}">{{data.status}}</span>
|
106 |
-
|
107 |
-
<span class="demo-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
|
108 |
-
|
109 |
-
<div class="theme-screenshot">
|
110 |
-
<# if ( data.screenshot.length ) { #>
|
111 |
-
<img src="{{{data.screenshot}}}" alt="">
|
112 |
-
<# } #>
|
113 |
-
</div>
|
114 |
-
|
115 |
-
<a href="{{{data.astra_demo_url}}}" target="_blank">
|
116 |
-
<span class="more-details" id="astra-theme-action"><?php esc_html_e( 'Details & Preview', 'astra-sites' ); ?></span>
|
117 |
-
</a>
|
118 |
-
|
119 |
-
<h3 class="theme-name" id="astra-theme-name">{{{data.demo_name}}}</h3>
|
120 |
-
|
121 |
-
<div class="theme-actions">
|
122 |
-
<button class="button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
|
123 |
-
|
124 |
-
</div>
|
125 |
-
|
126 |
-
</div>
|
127 |
-
</script>
|
128 |
-
|
129 |
-
<?php
|
130 |
-
/**
|
131 |
-
* Single Demo Preview
|
132 |
-
*/
|
133 |
-
?>
|
134 |
-
<script type="text/template" id="tmpl-astra-demo-preview">
|
135 |
-
<div class="astra-sites-preview theme-install-overlay wp-full-overlay expanded">
|
136 |
-
<div class="wp-full-overlay-sidebar">
|
137 |
-
<div class="wp-full-overlay-header"
|
138 |
-
data-demo-id="{{{data.id}}}"
|
139 |
-
data-demo-type="{{{data.astra_demo_type}}}"
|
140 |
-
data-demo-url="{{{data.astra_demo_url}}}"
|
141 |
-
data-demo-api="{{{data.demo_api}}}"
|
142 |
-
data-demo-name="{{{data.demo_name}}}"
|
143 |
-
data-demo-slug="{{{data.slug}}}"
|
144 |
-
data-screenshot="{{{data.screenshot}}}"
|
145 |
-
data-content="{{{data.content}}}"
|
146 |
-
data-required-plugins="{{data.required_plugins}}">
|
147 |
-
<input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
|
148 |
-
<input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
|
149 |
-
<button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'astra-sites' ); ?></span></button>
|
150 |
-
<button class="previous-theme"><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'astra-sites' ); ?></span></button>
|
151 |
-
<button class="next-theme"><span class="screen-reader-text"><?php esc_html_e( 'Next', 'astra-sites' ); ?></span></button>
|
152 |
-
<a class="button hide-if-no-customize astra-demo-import" href="#" data-import="disabled"><?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?></a>
|
153 |
-
|
154 |
-
</div>
|
155 |
-
<div class="wp-full-overlay-sidebar-content">
|
156 |
-
<div class="install-theme-info">
|
157 |
-
|
158 |
-
<span class="demo-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
|
159 |
-
<h3 class="theme-name">{{{data.demo_name}}}</h3>
|
160 |
-
|
161 |
-
<# if ( data.screenshot.length ) { #>
|
162 |
-
<img class="theme-screenshot" src="{{{data.screenshot}}}" alt="">
|
163 |
-
<# } #>
|
164 |
-
|
165 |
-
<div class="theme-details">
|
166 |
-
{{{data.content}}}
|
167 |
-
</div>
|
168 |
-
<a href="#" class="theme-details-read-more"><?php _e( 'Read more', 'astra-sites' ); ?> …</a>
|
169 |
-
|
170 |
-
<div class="required-plugins-wrap">
|
171 |
-
<h4><?php _e( 'Required Plugins', 'astra-sites' ); ?> </h4>
|
172 |
-
<div class="required-plugins"></div>
|
173 |
-
</div>
|
174 |
-
</div>
|
175 |
-
</div>
|
176 |
-
|
177 |
-
<div class="wp-full-overlay-footer">
|
178 |
-
<div class="footer-import-button-wrap">
|
179 |
-
<a class="button button-hero hide-if-no-customize astra-demo-import" href="#" data-import="disabled">
|
180 |
-
<?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?>
|
181 |
-
</a>
|
182 |
-
</div>
|
183 |
-
<button type="button" class="collapse-sidebar button" aria-expanded="true"
|
184 |
-
aria-label="Collapse Sidebar">
|
185 |
-
<span class="collapse-sidebar-arrow"></span>
|
186 |
-
<span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
|
187 |
-
</button>
|
188 |
-
</div>
|
189 |
-
</div>
|
190 |
-
<div class="wp-full-overlay-main">
|
191 |
-
<iframe src="{{{data.astra_demo_url}}}" title="<?php esc_attr_e( 'Preview', 'astra-sites' ); ?>"></iframe>
|
192 |
-
</div>
|
193 |
-
</div>
|
194 |
-
</script>
|
195 |
-
|
196 |
-
<script type="text/template" id="tmpl-astra-no-demos">
|
197 |
-
<div class="no-themes">
|
198 |
-
<?php
|
199 |
-
|
200 |
-
/* translators: %1$s & %2$s are a Demo API URL */
|
201 |
-
printf( __( '<p> It seems the demo data server, <i><a href="%1$s">%2$s</a></i> is unreachable from your site.</p>', 'astra-sites' ) , esc_url( Astra_Sites::$api_url ), esc_url( Astra_Sites::$api_url ) );
|
202 |
-
|
203 |
-
_e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
|
204 |
-
|
205 |
-
_e( '<p class="left-margin"> 2. If that does not work, you will need to talk to your server administrator and check if demo server is being blocked by the firewall!</p>', 'astra-sites' );
|
206 |
-
|
207 |
-
/* translators: %1$s is a support link */
|
208 |
-
printf( __( '<p>If that does not help, please open up a <a href="%1$s" target="_blank">Support Ticket</a> and we will be glad take a closer look for you.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/support/' ) );
|
209 |
-
?>
|
210 |
-
</div>
|
211 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/assets/css/admin.css
CHANGED
@@ -315,4 +315,7 @@
|
|
315 |
.astra-sites-preview .wp-full-overlay-footer .devices button.active:hover {
|
316 |
border-bottom-color: transparent;
|
317 |
background-color: transparent;
|
|
|
|
|
|
|
318 |
}
|
315 |
.astra-sites-preview .wp-full-overlay-footer .devices button.active:hover {
|
316 |
border-bottom-color: transparent;
|
317 |
background-color: transparent;
|
318 |
+
}
|
319 |
+
.not-click-able {
|
320 |
+
pointer-events: none !important;
|
321 |
}
|
inc/assets/js/admin-page.js
CHANGED
@@ -197,6 +197,7 @@ var AstraSitesAjaxQueue = (function() {
|
|
197 |
$.ajax({
|
198 |
url : astraSitesAdmin.ajaxurl,
|
199 |
type : 'POST',
|
|
|
200 |
data : {
|
201 |
action : 'astra-sites-import-end',
|
202 |
},
|
@@ -231,6 +232,7 @@ var AstraSitesAjaxQueue = (function() {
|
|
231 |
$.ajax({
|
232 |
url : astraSitesAdmin.ajaxurl,
|
233 |
type : 'POST',
|
|
|
234 |
data : {
|
235 |
action : 'astra-sites-import-widgets',
|
236 |
widgets_data : AstraSitesAdmin.widgets_data,
|
@@ -268,6 +270,7 @@ var AstraSitesAjaxQueue = (function() {
|
|
268 |
$.ajax({
|
269 |
url : astraSitesAdmin.ajaxurl,
|
270 |
type : 'POST',
|
|
|
271 |
data : {
|
272 |
action : 'astra-sites-import-options',
|
273 |
options_data : AstraSitesAdmin.options_data,
|
@@ -306,6 +309,7 @@ var AstraSitesAjaxQueue = (function() {
|
|
306 |
$.ajax({
|
307 |
url : astraSitesAdmin.ajaxurl,
|
308 |
type : 'POST',
|
|
|
309 |
data : {
|
310 |
action : 'astra-sites-import-prepare-xml',
|
311 |
wxr_url : AstraSitesAdmin.wxr_url,
|
@@ -375,6 +379,7 @@ var AstraSitesAjaxQueue = (function() {
|
|
375 |
$.ajax({
|
376 |
url : astraSitesAdmin.ajaxurl,
|
377 |
type : 'POST',
|
|
|
378 |
data : {
|
379 |
action : 'astra-sites-import-customizer-settings',
|
380 |
customizer_data : AstraSitesAdmin.customizer_data,
|
@@ -611,14 +616,14 @@ var AstraSitesAjaxQueue = (function() {
|
|
611 |
|
612 |
var $card = jQuery( '.plugin-card-' + response.slug );
|
613 |
|
614 |
-
AstraSitesAdmin._log(
|
615 |
|
616 |
$card
|
617 |
.removeClass( 'button-primary' )
|
618 |
.addClass( 'disabled' )
|
619 |
.html( wp.updates.l10n.installFailedShort );
|
620 |
|
621 |
-
AstraSitesAdmin._importFailMessage(
|
622 |
},
|
623 |
|
624 |
/**
|
@@ -849,7 +854,7 @@ var AstraSitesAjaxQueue = (function() {
|
|
849 |
|
850 |
var disabled = $this.attr('data-import');
|
851 |
|
852 |
-
if ( typeof disabled !== 'undefined' && disabled === 'disabled' ) {
|
853 |
|
854 |
$('.astra-demo-import').addClass('updating-message installing')
|
855 |
.text( wp.updates.l10n.installing );
|
@@ -903,6 +908,7 @@ var AstraSitesAjaxQueue = (function() {
|
|
903 |
$.ajax({
|
904 |
url : astraSitesAdmin.ajaxurl,
|
905 |
type : 'POST',
|
|
|
906 |
data : {
|
907 |
'action' : 'astra-sites-import-set-site-data',
|
908 |
'api_url' : apiURL,
|
@@ -914,13 +920,6 @@ var AstraSitesAjaxQueue = (function() {
|
|
914 |
})
|
915 |
.done(function ( demo_data ) {
|
916 |
|
917 |
-
/**
|
918 |
-
* Set log file URL
|
919 |
-
*/
|
920 |
-
if( astraSitesAdmin.debug && ( undefined !== demo_data.data.log_file.abs_url || null !== demo_data.data.log_file.abs_url ) ) {
|
921 |
-
AstraSitesAdmin.log_file_url = decodeURIComponent( demo_data.data.log_file.url ) || '';
|
922 |
-
}
|
923 |
-
|
924 |
// 1. Fail - Request Site Import
|
925 |
if( false === demo_data.success ) {
|
926 |
|
@@ -928,6 +927,11 @@ var AstraSitesAjaxQueue = (function() {
|
|
928 |
|
929 |
} else {
|
930 |
|
|
|
|
|
|
|
|
|
|
|
931 |
// 1. Pass - Request Site Import
|
932 |
AstraSitesAdmin._log( astraSitesAdmin.log.processingRequest );
|
933 |
|
@@ -1115,6 +1119,11 @@ var AstraSitesAjaxQueue = (function() {
|
|
1115 |
required_plugins : requiredPlugins
|
1116 |
};
|
1117 |
|
|
|
|
|
|
|
|
|
|
|
1118 |
jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
|
1119 |
|
1120 |
// Required Required.
|
@@ -1133,6 +1142,11 @@ var AstraSitesAjaxQueue = (function() {
|
|
1133 |
})
|
1134 |
.done(function ( response ) {
|
1135 |
|
|
|
|
|
|
|
|
|
|
|
1136 |
// Remove loader.
|
1137 |
jQuery('.required-plugins').removeClass('loading').html('');
|
1138 |
|
197 |
$.ajax({
|
198 |
url : astraSitesAdmin.ajaxurl,
|
199 |
type : 'POST',
|
200 |
+
dataType: 'json',
|
201 |
data : {
|
202 |
action : 'astra-sites-import-end',
|
203 |
},
|
232 |
$.ajax({
|
233 |
url : astraSitesAdmin.ajaxurl,
|
234 |
type : 'POST',
|
235 |
+
dataType: 'json',
|
236 |
data : {
|
237 |
action : 'astra-sites-import-widgets',
|
238 |
widgets_data : AstraSitesAdmin.widgets_data,
|
270 |
$.ajax({
|
271 |
url : astraSitesAdmin.ajaxurl,
|
272 |
type : 'POST',
|
273 |
+
dataType: 'json',
|
274 |
data : {
|
275 |
action : 'astra-sites-import-options',
|
276 |
options_data : AstraSitesAdmin.options_data,
|
309 |
$.ajax({
|
310 |
url : astraSitesAdmin.ajaxurl,
|
311 |
type : 'POST',
|
312 |
+
dataType: 'json',
|
313 |
data : {
|
314 |
action : 'astra-sites-import-prepare-xml',
|
315 |
wxr_url : AstraSitesAdmin.wxr_url,
|
379 |
$.ajax({
|
380 |
url : astraSitesAdmin.ajaxurl,
|
381 |
type : 'POST',
|
382 |
+
dataType: 'json',
|
383 |
data : {
|
384 |
action : 'astra-sites-import-customizer-settings',
|
385 |
customizer_data : AstraSitesAdmin.customizer_data,
|
616 |
|
617 |
var $card = jQuery( '.plugin-card-' + response.slug );
|
618 |
|
619 |
+
AstraSitesAdmin._log( response.errorMessage + ' ' + response.slug );
|
620 |
|
621 |
$card
|
622 |
.removeClass( 'button-primary' )
|
623 |
.addClass( 'disabled' )
|
624 |
.html( wp.updates.l10n.installFailedShort );
|
625 |
|
626 |
+
AstraSitesAdmin._importFailMessage( response.errorMessage );
|
627 |
},
|
628 |
|
629 |
/**
|
854 |
|
855 |
var disabled = $this.attr('data-import');
|
856 |
|
857 |
+
if ( typeof disabled !== 'undefined' && disabled === 'disabled' || $this.hasClass('disabled') ) {
|
858 |
|
859 |
$('.astra-demo-import').addClass('updating-message installing')
|
860 |
.text( wp.updates.l10n.installing );
|
908 |
$.ajax({
|
909 |
url : astraSitesAdmin.ajaxurl,
|
910 |
type : 'POST',
|
911 |
+
dataType: 'json',
|
912 |
data : {
|
913 |
'action' : 'astra-sites-import-set-site-data',
|
914 |
'api_url' : apiURL,
|
920 |
})
|
921 |
.done(function ( demo_data ) {
|
922 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
923 |
// 1. Fail - Request Site Import
|
924 |
if( false === demo_data.success ) {
|
925 |
|
927 |
|
928 |
} else {
|
929 |
|
930 |
+
// Set log file URL.
|
931 |
+
if( 'log_file' in demo_data.data ){
|
932 |
+
AstraSitesAdmin.log_file_url = decodeURIComponent( demo_data.data.log_file ) || '';
|
933 |
+
}
|
934 |
+
|
935 |
// 1. Pass - Request Site Import
|
936 |
AstraSitesAdmin._log( astraSitesAdmin.log.processingRequest );
|
937 |
|
1119 |
required_plugins : requiredPlugins
|
1120 |
};
|
1121 |
|
1122 |
+
// Add disabled class from import button.
|
1123 |
+
$('.astra-demo-import')
|
1124 |
+
.addClass('disabled not-click-able')
|
1125 |
+
.removeAttr('data-import');
|
1126 |
+
|
1127 |
jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
|
1128 |
|
1129 |
// Required Required.
|
1142 |
})
|
1143 |
.done(function ( response ) {
|
1144 |
|
1145 |
+
// Release disabled class from import button.
|
1146 |
+
$('.astra-demo-import')
|
1147 |
+
.removeClass('disabled not-click-able')
|
1148 |
+
.attr('data-import', 'disabled');
|
1149 |
+
|
1150 |
// Remove loader.
|
1151 |
jQuery('.required-plugins').removeClass('loading').html('');
|
1152 |
|
inc/assets/js/admin.js
DELETED
@@ -1,1138 +0,0 @@
|
|
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( event ) {
|
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 |
-
var astra_page_builder = jQuery('.filter-links.astra-page-builder'),
|
771 |
-
astra_category = jQuery('.filter-links.astra-category'),
|
772 |
-
page_builder_id = astra_page_builder.find('.current').data('id'),
|
773 |
-
category_id = astra_category.find('.current').data('id');
|
774 |
-
|
775 |
-
jQuery('body').addClass('loading-content');
|
776 |
-
|
777 |
-
jQuery.ajax({
|
778 |
-
url: astraDemo.ajaxurl,
|
779 |
-
type: 'POST',
|
780 |
-
dataType: 'json',
|
781 |
-
data: {
|
782 |
-
action : 'astra-list-sites',
|
783 |
-
paged : '1',
|
784 |
-
page_builder_id : page_builder_id,
|
785 |
-
category_id : category_id,
|
786 |
-
},
|
787 |
-
})
|
788 |
-
.done(function (demos) {
|
789 |
-
|
790 |
-
jQuery('body').removeClass('loading-content');
|
791 |
-
jQuery('.filter-count .count').text( demos.sites_count );
|
792 |
-
|
793 |
-
// Has sites?
|
794 |
-
if ( demos.sites_count > 0 ) {
|
795 |
-
AstraSites._renderDemoGrid( demos.sites );
|
796 |
-
|
797 |
-
// Something is wrong in API request.
|
798 |
-
} else {
|
799 |
-
var template = wp.template('astra-no-demos');
|
800 |
-
jQuery('.themes').append( template );
|
801 |
-
}
|
802 |
-
|
803 |
-
})
|
804 |
-
.fail(function () {
|
805 |
-
jQuery('body').removeClass('loading-content');
|
806 |
-
jQuery('.spinner').after('<p class="no-themes" style="display:block;">'+astraDemo.strings.responseError+'</p>');
|
807 |
-
});
|
808 |
-
},
|
809 |
-
|
810 |
-
/**
|
811 |
-
* Render Demo Grid.
|
812 |
-
*/
|
813 |
-
_renderDemoGrid: function(demos) {
|
814 |
-
|
815 |
-
jQuery.each(demos, function (index, demo) {
|
816 |
-
|
817 |
-
id = demo.id;
|
818 |
-
content = demo.content;
|
819 |
-
demo_api = demo.demo_api;
|
820 |
-
demo_name = demo.title;
|
821 |
-
demo_slug = demo.slug;
|
822 |
-
screenshot = demo.featured_image_url;
|
823 |
-
astra_demo_url = demo.astra_demo_url;
|
824 |
-
astra_demo_type = demo.astra_demo_type;
|
825 |
-
requiredPlugins = demo.required_plugins;
|
826 |
-
status = demo.status;
|
827 |
-
astraSiteOptions = demo.astra_site_options || '';
|
828 |
-
astraEnabledExtensions = demo.astra_enabled_extensions || '';
|
829 |
-
|
830 |
-
templateData = [{
|
831 |
-
id: id,
|
832 |
-
astra_demo_type: astra_demo_type,
|
833 |
-
status: status,
|
834 |
-
astra_demo_url: astra_demo_url,
|
835 |
-
demo_api: demo_api,
|
836 |
-
screenshot: screenshot,
|
837 |
-
demo_name: demo_name,
|
838 |
-
slug: demo_slug,
|
839 |
-
content: content,
|
840 |
-
required_plugins: requiredPlugins,
|
841 |
-
astra_site_options: astraSiteOptions,
|
842 |
-
astra_enabled_extensions: astraEnabledExtensions
|
843 |
-
}]
|
844 |
-
|
845 |
-
var template = wp.template('astra-single-demo');
|
846 |
-
jQuery('.themes').append(template(templateData[0]));
|
847 |
-
});
|
848 |
-
|
849 |
-
},
|
850 |
-
|
851 |
-
_pluginInstalling: function(event, args) {
|
852 |
-
event.preventDefault();
|
853 |
-
|
854 |
-
var $card = jQuery( '.plugin-card-' + args.slug );
|
855 |
-
var $button = $card.find( '.button' );
|
856 |
-
|
857 |
-
$card.addClass('updating-message');
|
858 |
-
$button.addClass('already-started');
|
859 |
-
|
860 |
-
},
|
861 |
-
|
862 |
-
/**
|
863 |
-
* Fires when a nav item is clicked.
|
864 |
-
*
|
865 |
-
* @since 1.0
|
866 |
-
* @access private
|
867 |
-
* @method _importDemo
|
868 |
-
*/
|
869 |
-
_importDemo: function()
|
870 |
-
{
|
871 |
-
var $this = jQuery(this),
|
872 |
-
$theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header'),
|
873 |
-
apiURL = $theme.data('demo-api') || '',
|
874 |
-
plugins = $theme.data('required-plugins');
|
875 |
-
|
876 |
-
var disabled = $this.attr('data-import');
|
877 |
-
|
878 |
-
if ( typeof disabled !== 'undefined' && disabled === 'disabled' ) {
|
879 |
-
|
880 |
-
$this.addClass('updating-message')
|
881 |
-
.text( wp.updates.l10n.installing );
|
882 |
-
|
883 |
-
/**
|
884 |
-
* Process Bulk Plugin Install & Activate
|
885 |
-
*/
|
886 |
-
AstraSites._bulkPluginInstallActivate();
|
887 |
-
|
888 |
-
return;
|
889 |
-
}
|
890 |
-
|
891 |
-
// Proceed?
|
892 |
-
if( ! confirm( astraDemo.strings.importWarning ) ) {
|
893 |
-
return;
|
894 |
-
}
|
895 |
-
|
896 |
-
jQuery('.astra-demo-import').attr('data-import', 'disabled')
|
897 |
-
.addClass('updating-message installing')
|
898 |
-
.text( astraDemo.strings.importingDemo );
|
899 |
-
|
900 |
-
$this.closest('.theme').focus();
|
901 |
-
|
902 |
-
var $theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header');
|
903 |
-
|
904 |
-
var apiURL = $theme.data('demo-api') || '';
|
905 |
-
|
906 |
-
jQuery.ajax({
|
907 |
-
url: astraDemo.ajaxurl,
|
908 |
-
type: 'POST',
|
909 |
-
dataType: 'json',
|
910 |
-
data: {
|
911 |
-
action: 'astra-import-demo',
|
912 |
-
api_url: apiURL
|
913 |
-
},
|
914 |
-
})
|
915 |
-
.done(function ( demos ) {
|
916 |
-
|
917 |
-
// Success?
|
918 |
-
if( demos.success ) {
|
919 |
-
jQuery('.astra-demo-import').removeClass('updating-message installing')
|
920 |
-
.removeAttr('data-import')
|
921 |
-
.addClass('view-site')
|
922 |
-
.removeClass('astra-demo-import')
|
923 |
-
.text( astraDemo.strings.viewSite )
|
924 |
-
.attr('target', '_blank')
|
925 |
-
.append('<i class="dashicons dashicons-external"></i>')
|
926 |
-
.attr('href', astraDemo.siteURL );
|
927 |
-
|
928 |
-
} else {
|
929 |
-
|
930 |
-
var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
|
931 |
-
output += ' <p>'+demos.message+'</p>';
|
932 |
-
output += ' <button type="button" class="notice-dismiss">';
|
933 |
-
output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
|
934 |
-
output += ' </button>';
|
935 |
-
output += '</div>';
|
936 |
-
|
937 |
-
jQuery('.install-theme-info').prepend( output );
|
938 |
-
|
939 |
-
// !important to add trigger.
|
940 |
-
// Which reinitialize the dismiss error message events.
|
941 |
-
jQuery(document).trigger('wp-updates-notice-added');
|
942 |
-
}
|
943 |
-
|
944 |
-
})
|
945 |
-
.fail(function ( demos ) {
|
946 |
-
jQuery('.astra-demo-import').removeClass('updating-message installing')
|
947 |
-
.removeAttr('data-import')
|
948 |
-
.addClass('view-site')
|
949 |
-
.removeClass('astra-demo-import')
|
950 |
-
.attr('target', '_blank')
|
951 |
-
.attr('href', astraDemo.strings.importFailedURL );
|
952 |
-
|
953 |
-
jQuery('.wp-full-overlay-header .view-site').text( astraDemo.strings.importFailedBtnSmall ).append('<i class="dashicons dashicons-external"></i>');
|
954 |
-
jQuery('.footer-import-button-wrap .view-site').text( astraDemo.strings.importFailedBtnLarge ).append('<i class="dashicons dashicons-external"></i>');
|
955 |
-
});
|
956 |
-
},
|
957 |
-
|
958 |
-
_bulkPluginInstallActivate: function()
|
959 |
-
{
|
960 |
-
if( 0 === astraDemo.requiredPlugins.length ) {
|
961 |
-
return;
|
962 |
-
}
|
963 |
-
|
964 |
-
jQuery('.required-plugins')
|
965 |
-
.find('.install-now')
|
966 |
-
.addClass( 'updating-message' )
|
967 |
-
.removeClass( 'install-now' )
|
968 |
-
.text( wp.updates.l10n.installing );
|
969 |
-
|
970 |
-
jQuery('.required-plugins')
|
971 |
-
.find('.activate-now')
|
972 |
-
.addClass('updating-message')
|
973 |
-
.removeClass( 'activate-now' )
|
974 |
-
.html( astraDemo.strings.btnActivating );
|
975 |
-
|
976 |
-
var not_installed = astraDemo.requiredPlugins.notinstalled || '';
|
977 |
-
var activate_plugins = astraDemo.requiredPlugins.inactive || '';
|
978 |
-
|
979 |
-
// First Install Bulk.
|
980 |
-
if( not_installed.length > 0 ) {
|
981 |
-
AstraSites._installAllPlugins( not_installed );
|
982 |
-
}
|
983 |
-
|
984 |
-
// Second Activate Bulk.
|
985 |
-
if( activate_plugins.length > 0 ) {
|
986 |
-
AstraSites._activateAllPlugins( activate_plugins );
|
987 |
-
}
|
988 |
-
|
989 |
-
},
|
990 |
-
|
991 |
-
/**
|
992 |
-
* Install All Plugins.
|
993 |
-
*/
|
994 |
-
_installAllPlugins: function( not_installed ) {
|
995 |
-
|
996 |
-
jQuery.each( not_installed, function(index, single_plugin) {
|
997 |
-
|
998 |
-
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
999 |
-
$button = $card.find('.button');
|
1000 |
-
|
1001 |
-
if( ! $button.hasClass('already-started') ) {
|
1002 |
-
|
1003 |
-
// Add each plugin activate request in Ajax queue.
|
1004 |
-
// @see wp-admin/js/updates.js
|
1005 |
-
wp.updates.queue.push( {
|
1006 |
-
action: 'install-plugin', // Required action.
|
1007 |
-
data: {
|
1008 |
-
slug: single_plugin.slug
|
1009 |
-
}
|
1010 |
-
} );
|
1011 |
-
}
|
1012 |
-
});
|
1013 |
-
|
1014 |
-
// Required to set queue.
|
1015 |
-
wp.updates.queueChecker();
|
1016 |
-
},
|
1017 |
-
|
1018 |
-
|
1019 |
-
/**
|
1020 |
-
* Activate All Plugins.
|
1021 |
-
*/
|
1022 |
-
_activateAllPlugins: function( activate_plugins ) {
|
1023 |
-
|
1024 |
-
// Process of cloud templates - (download, remove & fetch).
|
1025 |
-
AstraSitesAjaxQueue.run();
|
1026 |
-
|
1027 |
-
jQuery.each( activate_plugins, function(index, single_plugin) {
|
1028 |
-
|
1029 |
-
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
1030 |
-
$button = $card.find('.button'),
|
1031 |
-
$siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val(),
|
1032 |
-
$enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
1033 |
-
|
1034 |
-
$button.addClass('updating-message');
|
1035 |
-
|
1036 |
-
AstraSitesAjaxQueue.add({
|
1037 |
-
url: astraDemo.ajaxurl,
|
1038 |
-
type: 'POST',
|
1039 |
-
data: {
|
1040 |
-
'action' : 'astra-required-plugin-activate',
|
1041 |
-
'init' : single_plugin.init,
|
1042 |
-
'options' : $siteOptions,
|
1043 |
-
'enabledExtensions' : $enabledExtensions,
|
1044 |
-
},
|
1045 |
-
success: function( result ){
|
1046 |
-
|
1047 |
-
if( result.success ) {
|
1048 |
-
|
1049 |
-
var $card = jQuery( '.plugin-card-' + single_plugin.slug );
|
1050 |
-
var $button = $card.find( '.button' );
|
1051 |
-
if( ! $button.hasClass('already-started') ) {
|
1052 |
-
var pluginsList = astraDemo.requiredPlugins.inactive;
|
1053 |
-
|
1054 |
-
// Reset not installed plugins list.
|
1055 |
-
astraDemo.requiredPlugins.inactive = AstraSites._removePluginFromQueue( single_plugin.slug, pluginsList );
|
1056 |
-
}
|
1057 |
-
|
1058 |
-
$button.removeClass( 'button-primary install-now activate-now updating-message' )
|
1059 |
-
.attr('disabled', 'disabled')
|
1060 |
-
.addClass('disabled')
|
1061 |
-
.text( astraDemo.strings.btnActive );
|
1062 |
-
|
1063 |
-
// Enable Demo Import Button
|
1064 |
-
AstraSites._enable_demo_import_button();
|
1065 |
-
}
|
1066 |
-
}
|
1067 |
-
});
|
1068 |
-
});
|
1069 |
-
},
|
1070 |
-
|
1071 |
-
/**
|
1072 |
-
* Enable Demo Import Button.
|
1073 |
-
*/
|
1074 |
-
_enable_demo_import_button: function( type = 'free' ) {
|
1075 |
-
|
1076 |
-
switch( type ) {
|
1077 |
-
|
1078 |
-
case 'free':
|
1079 |
-
var all_buttons = parseInt( jQuery( '.plugin-card .button' ).length ) || 0,
|
1080 |
-
disabled_buttons = parseInt( jQuery( '.plugin-card .button.disabled' ).length ) || 0;
|
1081 |
-
|
1082 |
-
if( all_buttons === disabled_buttons ) {
|
1083 |
-
|
1084 |
-
jQuery('.astra-demo-import')
|
1085 |
-
.removeAttr('data-import')
|
1086 |
-
.removeClass('updating-message')
|
1087 |
-
.addClass('button-primary')
|
1088 |
-
.text( astraDemo.strings.importDemo );
|
1089 |
-
}
|
1090 |
-
|
1091 |
-
break;
|
1092 |
-
|
1093 |
-
case 'upgrade':
|
1094 |
-
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
1095 |
-
|
1096 |
-
jQuery('.astra-demo-import')
|
1097 |
-
.addClass('go-pro button-primary')
|
1098 |
-
.removeClass('astra-demo-import')
|
1099 |
-
.attr('target', '_blank')
|
1100 |
-
.attr('href', astraDemo.getUpgradeURL + demo_slug )
|
1101 |
-
.text( astraDemo.getUpgradeText )
|
1102 |
-
.append('<i class="dashicons dashicons-external"></i>');
|
1103 |
-
break;
|
1104 |
-
|
1105 |
-
default:
|
1106 |
-
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
1107 |
-
|
1108 |
-
jQuery('.astra-demo-import')
|
1109 |
-
.addClass('go-pro button-primary')
|
1110 |
-
.removeClass('astra-demo-import')
|
1111 |
-
.attr('target', '_blank')
|
1112 |
-
.attr('href', astraDemo.getProURL )
|
1113 |
-
.text( astraDemo.getProText )
|
1114 |
-
.append('<i class="dashicons dashicons-external"></i>');
|
1115 |
-
break;
|
1116 |
-
}
|
1117 |
-
|
1118 |
-
},
|
1119 |
-
|
1120 |
-
/**
|
1121 |
-
* Remove plugin from the queue.
|
1122 |
-
*/
|
1123 |
-
_removePluginFromQueue: function( removeItem, pluginsList ) {
|
1124 |
-
return jQuery.grep(pluginsList, function( value ) {
|
1125 |
-
return value.slug != removeItem;
|
1126 |
-
});
|
1127 |
-
}
|
1128 |
-
|
1129 |
-
};
|
1130 |
-
|
1131 |
-
/**
|
1132 |
-
* Initialize AstraSites
|
1133 |
-
*/
|
1134 |
-
$(function(){
|
1135 |
-
AstraSites.init();
|
1136 |
-
});
|
1137 |
-
|
1138 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/assets/js/astra-sites-notices.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
jQuery(document).ready(function ($) {
|
2 |
|
3 |
-
jQuery( '.astra-notice.is-dismissible' ).on( 'click', function() {
|
4 |
var $id = jQuery( this ).attr( 'id' ) || '';
|
5 |
var $time = jQuery( this ).attr( 'dismissible-time' ) || '';
|
6 |
var $meta = jQuery( this ).attr( 'dismissible-meta' ) || '';
|
1 |
jQuery(document).ready(function ($) {
|
2 |
|
3 |
+
jQuery( '.astra-notice.is-dismissible .notice-dismiss' ).on( 'click', function() {
|
4 |
var $id = jQuery( this ).attr( 'id' ) || '';
|
5 |
var $time = jQuery( this ).attr( 'dismissible-time' ) || '';
|
6 |
var $meta = jQuery( this ).attr( 'dismissible-meta' ) || '';
|
inc/assets/vendor/js/jquery.lazy.js
DELETED
@@ -1,830 +0,0 @@
|
|
1 |
-
/*!
|
2 |
-
* jQuery & Zepto Lazy - v1.7.5
|
3 |
-
* http://jquery.eisbehr.de/lazy/
|
4 |
-
*
|
5 |
-
* Copyright 2012 - 2017, Daniel 'Eisbehr' Kern
|
6 |
-
*
|
7 |
-
* Dual licensed under the MIT and GPL-2.0 licenses:
|
8 |
-
* http://www.opensource.org/licenses/mit-license.php
|
9 |
-
* http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
*
|
11 |
-
* $("img.lazy").lazy();
|
12 |
-
*/
|
13 |
-
|
14 |
-
;(function(window, undefined) {
|
15 |
-
"use strict";
|
16 |
-
|
17 |
-
// noinspection JSUnresolvedVariable
|
18 |
-
/**
|
19 |
-
* library instance - here and not in construct to be shorter in minimization
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
var $ = window.jQuery || window.Zepto,
|
23 |
-
|
24 |
-
/**
|
25 |
-
* unique plugin instance id counter
|
26 |
-
* @type {number}
|
27 |
-
*/
|
28 |
-
lazyInstanceId = 0,
|
29 |
-
|
30 |
-
/**
|
31 |
-
* helper to register window load for jQuery 3
|
32 |
-
* @type {boolean}
|
33 |
-
*/
|
34 |
-
windowLoaded = false;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* make lazy available to jquery - and make it a bit more case-insensitive :)
|
38 |
-
* @access public
|
39 |
-
* @type {function}
|
40 |
-
* @param {object} settings
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
$.fn.Lazy = $.fn.lazy = function(settings) {
|
44 |
-
return new LazyPlugin(this, settings);
|
45 |
-
};
|
46 |
-
|
47 |
-
/**
|
48 |
-
* helper to add plugins to lazy prototype configuration
|
49 |
-
* @access public
|
50 |
-
* @type {function}
|
51 |
-
* @param {string|Array} names
|
52 |
-
* @param {string|Array} [elements]
|
53 |
-
* @param {function} loader
|
54 |
-
* @return void
|
55 |
-
*/
|
56 |
-
$.Lazy = $.lazy = function(names, elements, loader) {
|
57 |
-
// make second parameter optional
|
58 |
-
if( $.isFunction(elements) ) {
|
59 |
-
loader = elements;
|
60 |
-
elements = [];
|
61 |
-
}
|
62 |
-
|
63 |
-
// exit here if parameter is not a callable function
|
64 |
-
if( !$.isFunction(loader) ) return;
|
65 |
-
|
66 |
-
// make parameters an array of names to be sure
|
67 |
-
names = $.isArray(names) ? names : [names];
|
68 |
-
elements = $.isArray(elements) ? elements : [elements];
|
69 |
-
|
70 |
-
var config = LazyPlugin.prototype.config,
|
71 |
-
forced = config._f || (config._f = {});
|
72 |
-
|
73 |
-
// add the loader plugin for every name
|
74 |
-
for( var i = 0, l = names.length; i < l; i++ )
|
75 |
-
if( config[names[i]] === undefined || $.isFunction(config[names[i]]) )
|
76 |
-
config[names[i]] = loader;
|
77 |
-
|
78 |
-
// add forced elements loader
|
79 |
-
for( var c = 0, a = elements.length; c < a; c++ )
|
80 |
-
forced[elements[c]] = names[0];
|
81 |
-
};
|
82 |
-
|
83 |
-
/**
|
84 |
-
* contains all logic and the whole element handling
|
85 |
-
* is packed in a private function outside class to reduce memory usage, because it will not be created on every plugin instance
|
86 |
-
* @access private
|
87 |
-
* @type {function}
|
88 |
-
* @param {LazyPlugin} instance
|
89 |
-
* @param {object} config
|
90 |
-
* @param {object|Array} items
|
91 |
-
* @param {object} events
|
92 |
-
* @param {string} namespace
|
93 |
-
* @return void
|
94 |
-
*/
|
95 |
-
function _executeLazy(instance, config, items, events, namespace) {
|
96 |
-
/**
|
97 |
-
* a helper to trigger the 'onFinishedAll' callback after all other events
|
98 |
-
* @access private
|
99 |
-
* @type {number}
|
100 |
-
*/
|
101 |
-
var _awaitingAfterLoad = 0,
|
102 |
-
|
103 |
-
/**
|
104 |
-
* visible content width
|
105 |
-
* @access private
|
106 |
-
* @type {number}
|
107 |
-
*/
|
108 |
-
_actualWidth = -1,
|
109 |
-
|
110 |
-
/**
|
111 |
-
* visible content height
|
112 |
-
* @access private
|
113 |
-
* @type {number}
|
114 |
-
*/
|
115 |
-
_actualHeight = -1,
|
116 |
-
|
117 |
-
/**
|
118 |
-
* determine possibly detected high pixel density
|
119 |
-
* @access private
|
120 |
-
* @type {boolean}
|
121 |
-
*/
|
122 |
-
_isRetinaDisplay = false,
|
123 |
-
|
124 |
-
/**
|
125 |
-
* dictionary entry for better minimization
|
126 |
-
* @access private
|
127 |
-
* @type {string}
|
128 |
-
*/
|
129 |
-
_afterLoad = "afterLoad",
|
130 |
-
|
131 |
-
/**
|
132 |
-
* dictionary entry for better minimization
|
133 |
-
* @access private
|
134 |
-
* @type {string}
|
135 |
-
*/
|
136 |
-
_load = "load",
|
137 |
-
|
138 |
-
/**
|
139 |
-
* dictionary entry for better minimization
|
140 |
-
* @access private
|
141 |
-
* @type {string}
|
142 |
-
*/
|
143 |
-
_error = "error",
|
144 |
-
|
145 |
-
/**
|
146 |
-
* dictionary entry for better minimization
|
147 |
-
* @access private
|
148 |
-
* @type {string}
|
149 |
-
*/
|
150 |
-
_img = "img",
|
151 |
-
|
152 |
-
/**
|
153 |
-
* dictionary entry for better minimization
|
154 |
-
* @access private
|
155 |
-
* @type {string}
|
156 |
-
*/
|
157 |
-
_src = "src",
|
158 |
-
|
159 |
-
/**
|
160 |
-
* dictionary entry for better minimization
|
161 |
-
* @access private
|
162 |
-
* @type {string}
|
163 |
-
*/
|
164 |
-
_srcset = "srcset",
|
165 |
-
|
166 |
-
/**
|
167 |
-
* dictionary entry for better minimization
|
168 |
-
* @access private
|
169 |
-
* @type {string}
|
170 |
-
*/
|
171 |
-
_sizes = "sizes",
|
172 |
-
|
173 |
-
/**
|
174 |
-
* dictionary entry for better minimization
|
175 |
-
* @access private
|
176 |
-
* @type {string}
|
177 |
-
*/
|
178 |
-
_backgroundImage = "background-image";
|
179 |
-
|
180 |
-
/**
|
181 |
-
* initialize plugin
|
182 |
-
* bind loading to events or set delay time to load all items at once
|
183 |
-
* @access private
|
184 |
-
* @return void
|
185 |
-
*/
|
186 |
-
function _initialize() {
|
187 |
-
// detect actual device pixel ratio
|
188 |
-
// noinspection JSUnresolvedVariable
|
189 |
-
_isRetinaDisplay = window.devicePixelRatio > 1;
|
190 |
-
|
191 |
-
// prepare all initial items
|
192 |
-
_prepareItems(items);
|
193 |
-
|
194 |
-
// if delay time is set load all items at once after delay time
|
195 |
-
if( config.delay >= 0 ) setTimeout(function() { _lazyLoadItems(true); }, config.delay);
|
196 |
-
|
197 |
-
// if no delay is set or combine usage is active bind events
|
198 |
-
if( config.delay < 0 || config.combined ) {
|
199 |
-
// create unique event function
|
200 |
-
events.e = _throttle(config.throttle, function(event) {
|
201 |
-
// reset detected window size on resize event
|
202 |
-
if( event.type === "resize" )
|
203 |
-
_actualWidth = _actualHeight = -1;
|
204 |
-
|
205 |
-
// execute 'lazy magic'
|
206 |
-
_lazyLoadItems(event.all);
|
207 |
-
});
|
208 |
-
|
209 |
-
// create function to add new items to instance
|
210 |
-
events.a = function(additionalItems) {
|
211 |
-
_prepareItems(additionalItems);
|
212 |
-
items.push.apply(items, additionalItems);
|
213 |
-
};
|
214 |
-
|
215 |
-
// create function to get all instance items left
|
216 |
-
events.g = function() {
|
217 |
-
// filter loaded items before return in case internal filter was not running until now
|
218 |
-
return (items = $(items).filter(function() {
|
219 |
-
return !$(this).data(config.loadedName);
|
220 |
-
}));
|
221 |
-
};
|
222 |
-
|
223 |
-
// create function to force loading elements
|
224 |
-
events.f = function(forcedItems) {
|
225 |
-
for( var i = 0; i < forcedItems.length; i++ ) {
|
226 |
-
// only handle item if available in current instance
|
227 |
-
// use a compare function, because Zepto can't handle object parameter for filter
|
228 |
-
// var item = items.filter(forcedItems[i]);
|
229 |
-
/* jshint loopfunc: true */
|
230 |
-
var item = items.filter(function() {
|
231 |
-
return this === forcedItems[i];
|
232 |
-
});
|
233 |
-
|
234 |
-
if( item.length ) {
|
235 |
-
_lazyLoadItems(false, item);
|
236 |
-
}
|
237 |
-
}
|
238 |
-
};
|
239 |
-
|
240 |
-
// load initial items
|
241 |
-
_lazyLoadItems();
|
242 |
-
|
243 |
-
// bind lazy load functions to scroll and resize event
|
244 |
-
// noinspection JSUnresolvedVariable
|
245 |
-
$(config.appendScroll).on("scroll." + namespace + " resize." + namespace, events.e);
|
246 |
-
}
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* prepare items before handle them
|
251 |
-
* @access private
|
252 |
-
* @param {Array|object|jQuery} items
|
253 |
-
* @return void
|
254 |
-
*/
|
255 |
-
function _prepareItems(items) {
|
256 |
-
// fetch used configurations before loops
|
257 |
-
var defaultImage = config.defaultImage,
|
258 |
-
placeholder = config.placeholder,
|
259 |
-
imageBase = config.imageBase,
|
260 |
-
srcsetAttribute = config.srcsetAttribute,
|
261 |
-
loaderAttribute = config.loaderAttribute,
|
262 |
-
forcedTags = config._f || {};
|
263 |
-
|
264 |
-
// filter items and only add those who not handled yet and got needed attributes available
|
265 |
-
items = $(items).filter(function() {
|
266 |
-
var element = $(this),
|
267 |
-
tag = _getElementTagName(this);
|
268 |
-
|
269 |
-
return !element.data(config.handledName) &&
|
270 |
-
(element.attr(config.attribute) || element.attr(srcsetAttribute) || element.attr(loaderAttribute) || forcedTags[tag] !== undefined);
|
271 |
-
})
|
272 |
-
|
273 |
-
// append plugin instance to all elements
|
274 |
-
.data("plugin_" + config.name, instance);
|
275 |
-
|
276 |
-
for( var i = 0, l = items.length; i < l; i++ ) {
|
277 |
-
var element = $(items[i]),
|
278 |
-
tag = _getElementTagName(items[i]),
|
279 |
-
elementImageBase = element.attr(config.imageBaseAttribute) || imageBase;
|
280 |
-
|
281 |
-
// generate and update source set if an image base is set
|
282 |
-
if( tag === _img && elementImageBase && element.attr(srcsetAttribute) )
|
283 |
-
element.attr(srcsetAttribute, _getCorrectedSrcSet(element.attr(srcsetAttribute), elementImageBase));
|
284 |
-
|
285 |
-
// add loader to forced element types
|
286 |
-
if( forcedTags[tag] !== undefined && !element.attr(loaderAttribute) )
|
287 |
-
element.attr(loaderAttribute, forcedTags[tag]);
|
288 |
-
|
289 |
-
// set default image on every element without source
|
290 |
-
if( tag === _img && defaultImage && !element.attr(_src) )
|
291 |
-
element.attr(_src, defaultImage);
|
292 |
-
|
293 |
-
// set placeholder on every element without background image
|
294 |
-
else if( tag !== _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) === "none") )
|
295 |
-
element.css(_backgroundImage, "url('" + placeholder + "')");
|
296 |
-
}
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* the 'lazy magic' - check all items
|
301 |
-
* @access private
|
302 |
-
* @param {boolean} [allItems]
|
303 |
-
* @param {object} [forced]
|
304 |
-
* @return void
|
305 |
-
*/
|
306 |
-
function _lazyLoadItems(allItems, forced) {
|
307 |
-
// skip if no items where left
|
308 |
-
if( !items.length ) {
|
309 |
-
// destroy instance if option is enabled
|
310 |
-
if( config.autoDestroy )
|
311 |
-
// noinspection JSUnresolvedFunction
|
312 |
-
instance.destroy();
|
313 |
-
|
314 |
-
return;
|
315 |
-
}
|
316 |
-
|
317 |
-
var elements = forced || items,
|
318 |
-
loadTriggered = false,
|
319 |
-
imageBase = config.imageBase || "",
|
320 |
-
srcsetAttribute = config.srcsetAttribute,
|
321 |
-
handledName = config.handledName;
|
322 |
-
|
323 |
-
// loop all available items
|
324 |
-
for( var i = 0; i < elements.length; i++ ) {
|
325 |
-
// item is at least in loadable area
|
326 |
-
if( allItems || forced || _isInLoadableArea(elements[i]) ) {
|
327 |
-
var element = $(elements[i]),
|
328 |
-
tag = _getElementTagName(elements[i]),
|
329 |
-
attribute = element.attr(config.attribute),
|
330 |
-
elementImageBase = element.attr(config.imageBaseAttribute) || imageBase,
|
331 |
-
customLoader = element.attr(config.loaderAttribute);
|
332 |
-
|
333 |
-
// is not already handled
|
334 |
-
if( !element.data(handledName) &&
|
335 |
-
// and is visible or visibility doesn't matter
|
336 |
-
(!config.visibleOnly || element.is(":visible")) && (
|
337 |
-
// and image source or source set attribute is available
|
338 |
-
(attribute || element.attr(srcsetAttribute)) && (
|
339 |
-
// and is image tag where attribute is not equal source or source set
|
340 |
-
(tag === _img && (elementImageBase + attribute !== element.attr(_src) || element.attr(srcsetAttribute) !== element.attr(_srcset))) ||
|
341 |
-
// or is non image tag where attribute is not equal background
|
342 |
-
(tag !== _img && elementImageBase + attribute !== element.css(_backgroundImage))
|
343 |
-
) ||
|
344 |
-
// or custom loader is available
|
345 |
-
customLoader ))
|
346 |
-
{
|
347 |
-
// mark element always as handled as this point to prevent double handling
|
348 |
-
loadTriggered = true;
|
349 |
-
element.data(handledName, true);
|
350 |
-
|
351 |
-
// load item
|
352 |
-
_handleItem(element, tag, elementImageBase, customLoader);
|
353 |
-
}
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
// when something was loaded remove them from remaining items
|
358 |
-
if( loadTriggered )
|
359 |
-
items = $(items).filter(function() {
|
360 |
-
return !$(this).data(handledName);
|
361 |
-
});
|
362 |
-
}
|
363 |
-
|
364 |
-
/**
|
365 |
-
* load the given element the lazy way
|
366 |
-
* @access private
|
367 |
-
* @param {object} element
|
368 |
-
* @param {string} tag
|
369 |
-
* @param {string} imageBase
|
370 |
-
* @param {function} [customLoader]
|
371 |
-
* @return void
|
372 |
-
*/
|
373 |
-
function _handleItem(element, tag, imageBase, customLoader) {
|
374 |
-
// increment count of items waiting for after load
|
375 |
-
++_awaitingAfterLoad;
|
376 |
-
|
377 |
-
// extended error callback for correct 'onFinishedAll' handling
|
378 |
-
var errorCallback = function() {
|
379 |
-
_triggerCallback("onError", element);
|
380 |
-
_reduceAwaiting();
|
381 |
-
|
382 |
-
// prevent further callback calls
|
383 |
-
errorCallback = $.noop;
|
384 |
-
};
|
385 |
-
|
386 |
-
// trigger function before loading image
|
387 |
-
_triggerCallback("beforeLoad", element);
|
388 |
-
|
389 |
-
// fetch all double used data here for better code minimization
|
390 |
-
var srcAttribute = config.attribute,
|
391 |
-
srcsetAttribute = config.srcsetAttribute,
|
392 |
-
sizesAttribute = config.sizesAttribute,
|
393 |
-
retinaAttribute = config.retinaAttribute,
|
394 |
-
removeAttribute = config.removeAttribute,
|
395 |
-
loadedName = config.loadedName,
|
396 |
-
elementRetina = element.attr(retinaAttribute);
|
397 |
-
|
398 |
-
// handle custom loader
|
399 |
-
if( customLoader ) {
|
400 |
-
// on load callback
|
401 |
-
var loadCallback = function() {
|
402 |
-
// remove attribute from element
|
403 |
-
if( removeAttribute )
|
404 |
-
element.removeAttr(config.loaderAttribute);
|
405 |
-
|
406 |
-
// mark element as loaded
|
407 |
-
element.data(loadedName, true);
|
408 |
-
|
409 |
-
// call after load event
|
410 |
-
_triggerCallback(_afterLoad, element);
|
411 |
-
|
412 |
-
// remove item from waiting queue and possibly trigger finished event
|
413 |
-
// it's needed to be asynchronous to run after filter was in _lazyLoadItems
|
414 |
-
setTimeout(_reduceAwaiting, 1);
|
415 |
-
|
416 |
-
// prevent further callback calls
|
417 |
-
loadCallback = $.noop;
|
418 |
-
};
|
419 |
-
|
420 |
-
// bind error event to trigger callback and reduce waiting amount
|
421 |
-
element.off(_error).one(_error, errorCallback)
|
422 |
-
|
423 |
-
// bind after load callback to element
|
424 |
-
.one(_load, loadCallback);
|
425 |
-
|
426 |
-
// trigger custom loader and handle response
|
427 |
-
if( !_triggerCallback(customLoader, element, function(response) {
|
428 |
-
if( response ) {
|
429 |
-
element.off(_load);
|
430 |
-
loadCallback();
|
431 |
-
}
|
432 |
-
else {
|
433 |
-
element.off(_error);
|
434 |
-
errorCallback();
|
435 |
-
}
|
436 |
-
})) element.trigger(_error);
|
437 |
-
}
|
438 |
-
|
439 |
-
// handle images
|
440 |
-
else {
|
441 |
-
// create image object
|
442 |
-
var imageObj = $(new Image());
|
443 |
-
|
444 |
-
// bind error event to trigger callback and reduce waiting amount
|
445 |
-
imageObj.one(_error, errorCallback)
|
446 |
-
|
447 |
-
// bind after load callback to image
|
448 |
-
.one(_load, function() {
|
449 |
-
// remove element from view
|
450 |
-
element.hide();
|
451 |
-
|
452 |
-
// set image back to element
|
453 |
-
// do it as single 'attr' calls, to be sure 'src' is set after 'srcset'
|
454 |
-
if( tag === _img )
|
455 |
-
element.attr(_sizes, imageObj.attr(_sizes))
|
456 |
-
.attr(_srcset, imageObj.attr(_srcset))
|
457 |
-
.attr(_src, imageObj.attr(_src));
|
458 |
-
else
|
459 |
-
element.css(_backgroundImage, "url('" + imageObj.attr(_src) + "')");
|
460 |
-
|
461 |
-
// bring it back with some effect!
|
462 |
-
element[config.effect](config.effectTime);
|
463 |
-
|
464 |
-
// remove attribute from element
|
465 |
-
if( removeAttribute ) {
|
466 |
-
element.removeAttr(srcAttribute + " " + srcsetAttribute + " " + retinaAttribute + " " + config.imageBaseAttribute);
|
467 |
-
|
468 |
-
// only remove 'sizes' attribute, if it was a custom one
|
469 |
-
if( sizesAttribute !== _sizes )
|
470 |
-
element.removeAttr(sizesAttribute);
|
471 |
-
}
|
472 |
-
|
473 |
-
// mark element as loaded
|
474 |
-
element.data(loadedName, true);
|
475 |
-
|
476 |
-
// call after load event
|
477 |
-
_triggerCallback(_afterLoad, element);
|
478 |
-
|
479 |
-
// cleanup image object
|
480 |
-
imageObj.remove();
|
481 |
-
|
482 |
-
// remove item from waiting queue and possibly trigger finished event
|
483 |
-
_reduceAwaiting();
|
484 |
-
});
|
485 |
-
|
486 |
-
// set sources
|
487 |
-
// do it as single 'attr' calls, to be sure 'src' is set after 'srcset'
|
488 |
-
var imageSrc = (_isRetinaDisplay && elementRetina ? elementRetina : element.attr(srcAttribute)) || "";
|
489 |
-
imageObj.attr(_sizes, element.attr(sizesAttribute))
|
490 |
-
.attr(_srcset, element.attr(srcsetAttribute))
|
491 |
-
.attr(_src, imageSrc ? imageBase + imageSrc : null);
|
492 |
-
|
493 |
-
// call after load even on cached image
|
494 |
-
imageObj.complete && imageObj.trigger(_load); // jshint ignore : line
|
495 |
-
}
|
496 |
-
}
|
497 |
-
|
498 |
-
/**
|
499 |
-
* check if the given element is inside the current viewport or threshold
|
500 |
-
* @access private
|
501 |
-
* @param {object} element
|
502 |
-
* @return {boolean}
|
503 |
-
*/
|
504 |
-
function _isInLoadableArea(element) {
|
505 |
-
var elementBound = element.getBoundingClientRect(),
|
506 |
-
direction = config.scrollDirection,
|
507 |
-
threshold = config.threshold,
|
508 |
-
vertical = // check if element is in loadable area from top
|
509 |
-
((_getActualHeight() + threshold) > elementBound.top) &&
|
510 |
-
// check if element is even in loadable are from bottom
|
511 |
-
(-threshold < elementBound.bottom),
|
512 |
-
horizontal = // check if element is in loadable area from left
|
513 |
-
((_getActualWidth() + threshold) > elementBound.left) &&
|
514 |
-
// check if element is even in loadable area from right
|
515 |
-
(-threshold < elementBound.right);
|
516 |
-
|
517 |
-
if( direction === "vertical" ) return vertical;
|
518 |
-
else if( direction === "horizontal" ) return horizontal;
|
519 |
-
|
520 |
-
return vertical && horizontal;
|
521 |
-
}
|
522 |
-
|
523 |
-
/**
|
524 |
-
* receive the current viewed width of the browser
|
525 |
-
* @access private
|
526 |
-
* @return {number}
|
527 |
-
*/
|
528 |
-
function _getActualWidth() {
|
529 |
-
return _actualWidth >= 0 ? _actualWidth : (_actualWidth = $(window).width());
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* receive the current viewed height of the browser
|
534 |
-
* @access private
|
535 |
-
* @return {number}
|
536 |
-
*/
|
537 |
-
function _getActualHeight() {
|
538 |
-
return _actualHeight >= 0 ? _actualHeight : (_actualHeight = $(window).height());
|
539 |
-
}
|
540 |
-
|
541 |
-
/**
|
542 |
-
* get lowercase tag name of an element
|
543 |
-
* @access private
|
544 |
-
* @param {object} element
|
545 |
-
* @returns {string}
|
546 |
-
*/
|
547 |
-
function _getElementTagName(element) {
|
548 |
-
return element.tagName.toLowerCase();
|
549 |
-
}
|
550 |
-
|
551 |
-
/**
|
552 |
-
* prepend image base to all srcset entries
|
553 |
-
* @access private
|
554 |
-
* @param {string} srcset
|
555 |
-
* @param {string} imageBase
|
556 |
-
* @returns {string}
|
557 |
-
*/
|
558 |
-
function _getCorrectedSrcSet(srcset, imageBase) {
|
559 |
-
if( imageBase ) {
|
560 |
-
// trim, remove unnecessary spaces and split entries
|
561 |
-
var entries = srcset.split(",");
|
562 |
-
srcset = "";
|
563 |
-
|
564 |
-
for( var i = 0, l = entries.length; i < l; i++ )
|
565 |
-
srcset += imageBase + entries[i].trim() + (i !== l - 1 ? "," : "");
|
566 |
-
}
|
567 |
-
|
568 |
-
return srcset;
|
569 |
-
}
|
570 |
-
|
571 |
-
/**
|
572 |
-
* helper function to throttle down event triggering
|
573 |
-
* @access private
|
574 |
-
* @param {number} delay
|
575 |
-
* @param {function} callback
|
576 |
-
* @return {function}
|
577 |
-
*/
|
578 |
-
function _throttle(delay, callback) {
|
579 |
-
var timeout,
|
580 |
-
lastExecute = 0;
|
581 |
-
|
582 |
-
return function(event, ignoreThrottle) {
|
583 |
-
var elapsed = +new Date() - lastExecute;
|
584 |
-
|
585 |
-
function run() {
|
586 |
-
lastExecute = +new Date();
|
587 |
-
callback.call(instance, event);
|
588 |
-
}
|
589 |
-
|
590 |
-
timeout && clearTimeout(timeout); // jshint ignore : line
|
591 |
-
|
592 |
-
if( elapsed > delay || !config.enableThrottle || ignoreThrottle ) run();
|
593 |
-
else timeout = setTimeout(run, delay - elapsed);
|
594 |
-
};
|
595 |
-
}
|
596 |
-
|
597 |
-
/**
|
598 |
-
* reduce count of awaiting elements to 'afterLoad' event and fire 'onFinishedAll' if reached zero
|
599 |
-
* @access private
|
600 |
-
* @return void
|
601 |
-
*/
|
602 |
-
function _reduceAwaiting() {
|
603 |
-
--_awaitingAfterLoad;
|
604 |
-
|
605 |
-
// if no items were left trigger finished event
|
606 |
-
if( !items.length && !_awaitingAfterLoad ) _triggerCallback("onFinishedAll");
|
607 |
-
}
|
608 |
-
|
609 |
-
/**
|
610 |
-
* single implementation to handle callbacks, pass element and set 'this' to current instance
|
611 |
-
* @access private
|
612 |
-
* @param {string|function} callback
|
613 |
-
* @param {object} [element]
|
614 |
-
* @param {*} [args]
|
615 |
-
* @return {boolean}
|
616 |
-
*/
|
617 |
-
function _triggerCallback(callback, element, args) {
|
618 |
-
if( (callback = config[callback]) ) {
|
619 |
-
// jQuery's internal '$(arguments).slice(1)' are causing problems at least on old iPads
|
620 |
-
// below is shorthand of 'Array.prototype.slice.call(arguments, 1)'
|
621 |
-
callback.apply(instance, [].slice.call(arguments, 1));
|
622 |
-
return true;
|
623 |
-
}
|
624 |
-
|
625 |
-
return false;
|
626 |
-
}
|
627 |
-
|
628 |
-
// if event driven or window is already loaded don't wait for page loading
|
629 |
-
if( config.bind === "event" || windowLoaded )
|
630 |
-
_initialize();
|
631 |
-
|
632 |
-
// otherwise load initial items and start lazy after page load
|
633 |
-
else // noinspection JSUnresolvedVariable
|
634 |
-
$(window).on(_load + "." + namespace, _initialize);
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* lazy plugin class constructor
|
639 |
-
* @constructor
|
640 |
-
* @access private
|
641 |
-
* @param {object} elements
|
642 |
-
* @param {object} settings
|
643 |
-
* @return {object|LazyPlugin}
|
644 |
-
*/
|
645 |
-
function LazyPlugin(elements, settings) {
|
646 |
-
/**
|
647 |
-
* this lazy plugin instance
|
648 |
-
* @access private
|
649 |
-
* @type {object|LazyPlugin|LazyPlugin.prototype}
|
650 |
-
*/
|
651 |
-
var _instance = this,
|
652 |
-
|
653 |
-
/**
|
654 |
-
* this lazy plugin instance configuration
|
655 |
-
* @access private
|
656 |
-
* @type {object}
|
657 |
-
*/
|
658 |
-
_config = $.extend({}, _instance.config, settings),
|
659 |
-
|
660 |
-
/**
|
661 |
-
* instance generated event executed on container scroll or resize
|
662 |
-
* packed in an object to be referenceable and short named because properties will not be minified
|
663 |
-
* @access private
|
664 |
-
* @type {object}
|
665 |
-
*/
|
666 |
-
_events = {},
|
667 |
-
|
668 |
-
/**
|
669 |
-
* unique namespace for instance related events
|
670 |
-
* @access private
|
671 |
-
* @type {string}
|
672 |
-
*/
|
673 |
-
_namespace = _config.name + "-" + (++lazyInstanceId);
|
674 |
-
|
675 |
-
// noinspection JSUndefinedPropertyAssignment
|
676 |
-
/**
|
677 |
-
* wrapper to get or set an entry from plugin instance configuration
|
678 |
-
* much smaller on minify as direct access
|
679 |
-
* @access public
|
680 |
-
* @type {function}
|
681 |
-
* @param {string} entryName
|
682 |
-
* @param {*} [value]
|
683 |
-
* @return {LazyPlugin|*}
|
684 |
-
*/
|
685 |
-
_instance.config = function(entryName, value) {
|
686 |
-
if( value === undefined )
|
687 |
-
return _config[entryName];
|
688 |
-
|
689 |
-
_config[entryName] = value;
|
690 |
-
return _instance;
|
691 |
-
};
|
692 |
-
|
693 |
-
// noinspection JSUndefinedPropertyAssignment
|
694 |
-
/**
|
695 |
-
* add additional items to current instance
|
696 |
-
* @access public
|
697 |
-
* @param {Array|object|string} items
|
698 |
-
* @return {LazyPlugin}
|
699 |
-
*/
|
700 |
-
_instance.addItems = function(items) {
|
701 |
-
_events.a && _events.a($.type(items) === "string" ? $(items) : items); // jshint ignore : line
|
702 |
-
return _instance;
|
703 |
-
};
|
704 |
-
|
705 |
-
// noinspection JSUndefinedPropertyAssignment
|
706 |
-
/**
|
707 |
-
* get all left items of this instance
|
708 |
-
* @access public
|
709 |
-
* @returns {object}
|
710 |
-
*/
|
711 |
-
_instance.getItems = function() {
|
712 |
-
return _events.g ? _events.g() : {};
|
713 |
-
};
|
714 |
-
|
715 |
-
// noinspection JSUndefinedPropertyAssignment
|
716 |
-
/**
|
717 |
-
* force lazy to load all items in loadable area right now
|
718 |
-
* by default without throttle
|
719 |
-
* @access public
|
720 |
-
* @type {function}
|
721 |
-
* @param {boolean} [useThrottle]
|
722 |
-
* @return {LazyPlugin}
|
723 |
-
*/
|
724 |
-
_instance.update = function(useThrottle) {
|
725 |
-
_events.e && _events.e({}, !useThrottle); // jshint ignore : line
|
726 |
-
return _instance;
|
727 |
-
};
|
728 |
-
|
729 |
-
// noinspection JSUndefinedPropertyAssignment
|
730 |
-
/**
|
731 |
-
* force element(s) to load directly, ignoring the viewport
|
732 |
-
* @access public
|
733 |
-
* @param {Array|object|string} items
|
734 |
-
* @return {LazyPlugin}
|
735 |
-
*/
|
736 |
-
_instance.force = function(items) {
|
737 |
-
_events.f && _events.f($.type(items) === "string" ? $(items) : items); // jshint ignore : line
|
738 |
-
return _instance;
|
739 |
-
};
|
740 |
-
|
741 |
-
// noinspection JSUndefinedPropertyAssignment
|
742 |
-
/**
|
743 |
-
* force lazy to load all available items right now
|
744 |
-
* this call ignores throttling
|
745 |
-
* @access public
|
746 |
-
* @type {function}
|
747 |
-
* @return {LazyPlugin}
|
748 |
-
*/
|
749 |
-
_instance.loadAll = function() {
|
750 |
-
_events.e && _events.e({all: true}, true); // jshint ignore : line
|
751 |
-
return _instance;
|
752 |
-
};
|
753 |
-
|
754 |
-
// noinspection JSUndefinedPropertyAssignment
|
755 |
-
/**
|
756 |
-
* destroy this plugin instance
|
757 |
-
* @access public
|
758 |
-
* @type {function}
|
759 |
-
* @return undefined
|
760 |
-
*/
|
761 |
-
_instance.destroy = function() {
|
762 |
-
// unbind instance generated events
|
763 |
-
// noinspection JSUnresolvedFunction, JSUnresolvedVariable
|
764 |
-
$(_config.appendScroll).off("." + _namespace, _events.e);
|
765 |
-
// noinspection JSUnresolvedVariable
|
766 |
-
$(window).off("." + _namespace);
|
767 |
-
|
768 |
-
// clear events
|
769 |
-
_events = {};
|
770 |
-
|
771 |
-
return undefined;
|
772 |
-
};
|
773 |
-
|
774 |
-
// start using lazy and return all elements to be chainable or instance for further use
|
775 |
-
// noinspection JSUnresolvedVariable
|
776 |
-
_executeLazy(_instance, _config, elements, _events, _namespace);
|
777 |
-
return _config.chainable ? elements : _instance;
|
778 |
-
}
|
779 |
-
|
780 |
-
/**
|
781 |
-
* settings and configuration data
|
782 |
-
* @access public
|
783 |
-
* @type {object}
|
784 |
-
*/
|
785 |
-
LazyPlugin.prototype.config = {
|
786 |
-
// general
|
787 |
-
name : "lazy",
|
788 |
-
chainable : true,
|
789 |
-
autoDestroy : true,
|
790 |
-
bind : "load",
|
791 |
-
threshold : 500,
|
792 |
-
visibleOnly : false,
|
793 |
-
appendScroll : window,
|
794 |
-
scrollDirection : "both",
|
795 |
-
imageBase : null,
|
796 |
-
defaultImage : "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
|
797 |
-
placeholder : null,
|
798 |
-
delay : -1,
|
799 |
-
combined : false,
|
800 |
-
|
801 |
-
// attributes
|
802 |
-
attribute : "data-src",
|
803 |
-
srcsetAttribute : "data-srcset",
|
804 |
-
sizesAttribute : "data-sizes",
|
805 |
-
retinaAttribute : "data-retina",
|
806 |
-
loaderAttribute : "data-loader",
|
807 |
-
imageBaseAttribute : "data-imagebase",
|
808 |
-
removeAttribute : true,
|
809 |
-
handledName : "handled",
|
810 |
-
loadedName : "loaded",
|
811 |
-
|
812 |
-
// effect
|
813 |
-
effect : "show",
|
814 |
-
effectTime : 0,
|
815 |
-
|
816 |
-
// throttle
|
817 |
-
enableThrottle : true,
|
818 |
-
throttle : 250,
|
819 |
-
|
820 |
-
// callbacks
|
821 |
-
beforeLoad : undefined,
|
822 |
-
afterLoad : undefined,
|
823 |
-
onError : undefined,
|
824 |
-
onFinishedAll : undefined
|
825 |
-
};
|
826 |
-
|
827 |
-
// register window load event globally to prevent not loading elements
|
828 |
-
// since jQuery 3.X ready state is fully async and may be executed after 'load'
|
829 |
-
$(window).on("load", function() { windowLoaded = true; });
|
830 |
-
})(window);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/assets/vendor/js/jquery.lazy.min.js
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
/*! jQuery & Zepto Lazy v1.7.5 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */
|
2 |
-
!function(t,e){"use strict";function r(r,a,i,l,u){function f(){L=t.devicePixelRatio>1,c(i),a.delay>=0&&setTimeout(function(){s(!0)},a.delay),(a.delay<0||a.combined)&&(l.e=v(a.throttle,function(t){"resize"===t.type&&(w=B=-1),s(t.all)}),l.a=function(t){c(t),i.push.apply(i,t)},l.g=function(){return i=n(i).filter(function(){return!n(this).data(a.loadedName)})},l.f=function(t){for(var e=0;e<t.length;e++){var r=i.filter(function(){return this===t[e]});r.length&&s(!1,r)}},s(),n(a.appendScroll).on("scroll."+u+" resize."+u,l.e))}function c(t){var i=a.defaultImage,o=a.placeholder,l=a.imageBase,u=a.srcsetAttribute,f=a.loaderAttribute,c=a._f||{};t=n(t).filter(function(){var t=n(this),r=m(this);return!t.data(a.handledName)&&(t.attr(a.attribute)||t.attr(u)||t.attr(f)||c[r]!==e)}).data("plugin_"+a.name,r);for(var s=0,d=t.length;s<d;s++){var A=n(t[s]),g=m(t[s]),h=A.attr(a.imageBaseAttribute)||l;g===N&&h&&A.attr(u)&&A.attr(u,b(A.attr(u),h)),c[g]===e||A.attr(f)||A.attr(f,c[g]),g===N&&i&&!A.attr(E)?A.attr(E,i):g===N||!o||A.css(O)&&"none"!==A.css(O)||A.css(O,"url('"+o+"')")}}function s(t,e){if(!i.length)return void(a.autoDestroy&&r.destroy());for(var o=e||i,l=!1,u=a.imageBase||"",f=a.srcsetAttribute,c=a.handledName,s=0;s<o.length;s++)if(t||e||A(o[s])){var g=n(o[s]),h=m(o[s]),b=g.attr(a.attribute),v=g.attr(a.imageBaseAttribute)||u,p=g.attr(a.loaderAttribute);g.data(c)||a.visibleOnly&&!g.is(":visible")||!((b||g.attr(f))&&(h===N&&(v+b!==g.attr(E)||g.attr(f)!==g.attr(F))||h!==N&&v+b!==g.css(O))||p)||(l=!0,g.data(c,!0),d(g,h,v,p))}l&&(i=n(i).filter(function(){return!n(this).data(c)}))}function d(t,e,r,i){++z;var o=function(){y("onError",t),p(),o=n.noop};y("beforeLoad",t);var l=a.attribute,u=a.srcsetAttribute,f=a.sizesAttribute,c=a.retinaAttribute,s=a.removeAttribute,d=a.loadedName,A=t.attr(c);if(i){var g=function(){s&&t.removeAttr(a.loaderAttribute),t.data(d,!0),y(T,t),setTimeout(p,1),g=n.noop};t.off(I).one(I,o).one(D,g),y(i,t,function(e){e?(t.off(D),g()):(t.off(I),o())})||t.trigger(I)}else{var h=n(new Image);h.one(I,o).one(D,function(){t.hide(),e===N?t.attr(C,h.attr(C)).attr(F,h.attr(F)).attr(E,h.attr(E)):t.css(O,"url('"+h.attr(E)+"')"),t[a.effect](a.effectTime),s&&(t.removeAttr(l+" "+u+" "+c+" "+a.imageBaseAttribute),f!==C&&t.removeAttr(f)),t.data(d,!0),y(T,t),h.remove(),p()});var m=(L&&A?A:t.attr(l))||"";h.attr(C,t.attr(f)).attr(F,t.attr(u)).attr(E,m?r+m:null),h.complete&&h.trigger(D)}}function A(t){var e=t.getBoundingClientRect(),r=a.scrollDirection,n=a.threshold,i=h()+n>e.top&&-n<e.bottom,o=g()+n>e.left&&-n<e.right;return"vertical"===r?i:"horizontal"===r?o:i&&o}function g(){return w>=0?w:w=n(t).width()}function h(){return B>=0?B:B=n(t).height()}function m(t){return t.tagName.toLowerCase()}function b(t,e){if(e){var r=t.split(",");t="";for(var a=0,n=r.length;a<n;a++)t+=e+r[a].trim()+(a!==n-1?",":"")}return t}function v(t,e){var n,i=0;return function(o,l){function u(){i=+new Date,e.call(r,o)}var f=+new Date-i;n&&clearTimeout(n),f>t||!a.enableThrottle||l?u():n=setTimeout(u,t-f)}}function p(){--z,i.length||z||y("onFinishedAll")}function y(t,e,n){return!!(t=a[t])&&(t.apply(r,[].slice.call(arguments,1)),!0)}var z=0,w=-1,B=-1,L=!1,T="afterLoad",D="load",I="error",N="img",E="src",F="srcset",C="sizes",O="background-image";"event"===a.bind||o?f():n(t).on(D+"."+u,f)}function a(a,o){var l=this,u=n.extend({},l.config,o),f={},c=u.name+"-"+ ++i;return l.config=function(t,r){return r===e?u[t]:(u[t]=r,l)},l.addItems=function(t){return f.a&&f.a("string"===n.type(t)?n(t):t),l},l.getItems=function(){return f.g?f.g():{}},l.update=function(t){return f.e&&f.e({},!t),l},l.force=function(t){return f.f&&f.f("string"===n.type(t)?n(t):t),l},l.loadAll=function(){return f.e&&f.e({all:!0},!0),l},l.destroy=function(){return n(u.appendScroll).off("."+c,f.e),n(t).off("."+c),f={},e},r(l,u,a,f,c),u.chainable?a:l}var n=t.jQuery||t.Zepto,i=0,o=!1;n.fn.Lazy=n.fn.lazy=function(t){return new a(this,t)},n.Lazy=n.lazy=function(t,r,i){if(n.isFunction(r)&&(i=r,r=[]),n.isFunction(i)){t=n.isArray(t)?t:[t],r=n.isArray(r)?r:[r];for(var o=a.prototype.config,l=o._f||(o._f={}),u=0,f=t.length;u<f;u++)(o[t[u]]===e||n.isFunction(o[t[u]]))&&(o[t[u]]=i);for(var c=0,s=r.length;c<s;c++)l[r[c]]=t[0]}},a.prototype.config={name:"lazy",chainable:!0,autoDestroy:!0,bind:"load",threshold:500,visibleOnly:!1,appendScroll:t,scrollDirection:"both",imageBase:null,defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:!1,attribute:"data-src",srcsetAttribute:"data-srcset",sizesAttribute:"data-sizes",retinaAttribute:"data-retina",loaderAttribute:"data-loader",imageBaseAttribute:"data-imagebase",removeAttribute:!0,handledName:"handled",loadedName:"loaded",effect:"show",effectTime:0,enableThrottle:!0,throttle:250,beforeLoad:e,afterLoad:e,onError:e,onFinishedAll:e},n(t).on("load",function(){o=!0})}(window);
|
|
|
|
inc/classes/class-astra-sites-importer.php
CHANGED
@@ -91,7 +91,10 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
|
|
91 |
if ( is_wp_error( $demo_data ) ) {
|
92 |
wp_send_json_error( $demo_data->get_error_message() );
|
93 |
} else {
|
94 |
-
$
|
|
|
|
|
|
|
95 |
do_action( 'astra_sites_import_start', $demo_data, $demo_api_uri );
|
96 |
}
|
97 |
|
91 |
if ( is_wp_error( $demo_data ) ) {
|
92 |
wp_send_json_error( $demo_data->get_error_message() );
|
93 |
} else {
|
94 |
+
$log_file = Astra_Sites_Importer_Log::add_log_file_url();
|
95 |
+
if ( isset( $log_file['abs_url'] ) && ! empty( $log_file['abs_url'] ) ) {
|
96 |
+
$demo_data['log_file'] = $log_file['abs_url'];
|
97 |
+
}
|
98 |
do_action( 'astra_sites_import_start', $demo_data, $demo_api_uri );
|
99 |
}
|
100 |
|
inc/classes/class-astra-sites-notices.php
CHANGED
@@ -150,15 +150,11 @@ if ( ! class_exists( 'Astra_Sites_Notices' ) ) :
|
|
150 |
}
|
151 |
|
152 |
// Notice ID.
|
153 |
-
$notice_id
|
154 |
-
$notice['id']
|
155 |
-
if ( ! isset( $notice['id'] ) ) {
|
156 |
-
$notice_id = 'astra-sites-notices-id-' . $key;
|
157 |
-
$notice['id'] = $notice_id;
|
158 |
-
} else {
|
159 |
$notice_id = $notice['id'];
|
160 |
}
|
161 |
-
|
162 |
$notice['classes'] = implode( ' ', $classes );
|
163 |
|
164 |
// User meta.
|
150 |
}
|
151 |
|
152 |
// Notice ID.
|
153 |
+
$notice_id = 'astra-sites-notices-id-' . $key;
|
154 |
+
if ( isset( $notice['id'] ) && ! empty( $notice['id'] ) ) {
|
|
|
|
|
|
|
|
|
155 |
$notice_id = $notice['id'];
|
156 |
}
|
157 |
+
$notice['id'] = $notice_id;
|
158 |
$notice['classes'] = implode( ' ', $classes );
|
159 |
|
160 |
// User meta.
|
inc/classes/class-astra-sites.php
CHANGED
@@ -74,7 +74,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
74 |
|
75 |
Astra_Sites_Notices::add_notice(
|
76 |
array(
|
77 |
-
'id' => 'theme-activation-nag',
|
78 |
'type' => 'error',
|
79 |
'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
|
80 |
/* translators: 1: theme.php file*/
|
@@ -233,7 +233,6 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
233 |
'log' => array(
|
234 |
'installingPlugin' => __( 'Installing plugin ', 'astra-sites' ),
|
235 |
'installed' => __( 'Successfully plugin installed!', 'astra-sites' ),
|
236 |
-
'installError' => __( 'There was an error while installing the plugin ', 'astra-sites' ),
|
237 |
'activating' => __( 'Activating plugin ', 'astra-sites' ),
|
238 |
'activated' => __( 'Successfully plugin activated ', 'astra-sites' ),
|
239 |
'bulkActivation' => __( 'Bulk plugin activation...', 'astra-sites' ),
|
@@ -424,7 +423,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
424 |
'beaver-builder-lite-version/fl-builder.php' => array(
|
425 |
'slug' => 'bb-plugin',
|
426 |
'init' => 'bb-plugin/fl-builder.php',
|
427 |
-
'name' => 'Beaver Builder Plugin
|
428 |
),
|
429 |
'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array(
|
430 |
'slug' => 'bb-ultimate-addon',
|
@@ -444,6 +443,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
|
|
444 |
|
445 |
return false;
|
446 |
}
|
|
|
447 |
}
|
448 |
|
449 |
/**
|
74 |
|
75 |
Astra_Sites_Notices::add_notice(
|
76 |
array(
|
77 |
+
'id' => 'astra-theme-activation-nag',
|
78 |
'type' => 'error',
|
79 |
'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
|
80 |
/* translators: 1: theme.php file*/
|
233 |
'log' => array(
|
234 |
'installingPlugin' => __( 'Installing plugin ', 'astra-sites' ),
|
235 |
'installed' => __( 'Successfully plugin installed!', 'astra-sites' ),
|
|
|
236 |
'activating' => __( 'Activating plugin ', 'astra-sites' ),
|
237 |
'activated' => __( 'Successfully plugin activated ', 'astra-sites' ),
|
238 |
'bulkActivation' => __( 'Bulk plugin activation...', 'astra-sites' ),
|
423 |
'beaver-builder-lite-version/fl-builder.php' => array(
|
424 |
'slug' => 'bb-plugin',
|
425 |
'init' => 'bb-plugin/fl-builder.php',
|
426 |
+
'name' => 'Beaver Builder Plugin',
|
427 |
),
|
428 |
'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array(
|
429 |
'slug' => 'bb-ultimate-addon',
|
443 |
|
444 |
return false;
|
445 |
}
|
446 |
+
|
447 |
}
|
448 |
|
449 |
/**
|
inc/classes/compatibility/class-astra-sites-compatibility-astra-pro.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Astra Sites Compatibility for 'Astra Pro'
|
4 |
-
*
|
5 |
-
* @see https://wordpress.org/plugins/astra-pro/
|
6 |
-
*
|
7 |
-
* @package Astra Sites
|
8 |
-
* @since 1.0.0
|
9 |
-
*/
|
10 |
-
|
11 |
-
if ( ! class_exists( 'Astra_Sites_Compatibility_Astra_Pro' ) ) :
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Astra_Sites_Compatibility_Astra_Pro
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*/
|
18 |
-
class Astra_Sites_Compatibility_Astra_Pro {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Instance
|
22 |
-
*
|
23 |
-
* @access private
|
24 |
-
* @var object Class object.
|
25 |
-
* @since 1.0.0
|
26 |
-
*/
|
27 |
-
private static $instance;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Initiator
|
31 |
-
*
|
32 |
-
* @since 1.0.0
|
33 |
-
* @return object initialized object of class.
|
34 |
-
*/
|
35 |
-
public static function instance() {
|
36 |
-
if ( ! isset( self::$instance ) ) {
|
37 |
-
self::$instance = new self;
|
38 |
-
}
|
39 |
-
return self::$instance;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*
|
45 |
-
* @since 1.0.0
|
46 |
-
*/
|
47 |
-
public function __construct() {
|
48 |
-
add_action( 'astra_sites_after_plugin_activation', array( $this, 'astra_pro' ), 10, 2 );
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Update Site Origin Active Widgets
|
53 |
-
*
|
54 |
-
* @since 1.0.0
|
55 |
-
*
|
56 |
-
* @param string $plugin_init Plugin init file.
|
57 |
-
* @param array $data Data.
|
58 |
-
* @return void
|
59 |
-
*/
|
60 |
-
function astra_pro( $plugin_init = '', $data = array() ) {
|
61 |
-
|
62 |
-
if ( 'astra-addon/astra-addon.php' === $plugin_init ) {
|
63 |
-
|
64 |
-
$data = json_decode( json_encode( $data ), true );
|
65 |
-
|
66 |
-
if ( isset( $data['enabled_extensions'] ) ) {
|
67 |
-
$extensions = $data['enabled_extensions'];
|
68 |
-
|
69 |
-
if ( ! empty( $extensions ) ) {
|
70 |
-
if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
|
71 |
-
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $extensions );
|
72 |
-
}
|
73 |
-
}
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Kicking this off by calling 'instance()' method
|
83 |
-
*/
|
84 |
-
Astra_Sites_Compatibility_Astra_Pro::instance();
|
85 |
-
|
86 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/classes/compatibility/class-astra-sites-compatibility-so-widgets.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Astra Sites Compatibility for 'SiteOrigin Widgets Bundle'
|
4 |
-
*
|
5 |
-
* @see https://wordpress.org/plugins/so-widgets-bundle/
|
6 |
-
*
|
7 |
-
* @package Astra Sites
|
8 |
-
* @since 1.0.0
|
9 |
-
*/
|
10 |
-
|
11 |
-
if ( ! class_exists( 'Astra_Sites_Compatibility_SO_Widgets' ) ) :
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Astra_Sites_Compatibility_SO_Widgets
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*/
|
18 |
-
class Astra_Sites_Compatibility_SO_Widgets {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Instance
|
22 |
-
*
|
23 |
-
* @access private
|
24 |
-
* @var object Class object.
|
25 |
-
* @since 1.0.0
|
26 |
-
*/
|
27 |
-
private static $instance;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Initiator
|
31 |
-
*
|
32 |
-
* @since 1.0.0
|
33 |
-
* @return object initialized object of class.
|
34 |
-
*/
|
35 |
-
public static function instance() {
|
36 |
-
if ( ! isset( self::$instance ) ) {
|
37 |
-
self::$instance = new self;
|
38 |
-
}
|
39 |
-
return self::$instance;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*
|
45 |
-
* @since 1.0.0
|
46 |
-
*/
|
47 |
-
public function __construct() {
|
48 |
-
add_action( 'astra_sites_after_plugin_activation', array( $this, 'site_origin' ), 10, 2 );
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Update Site Origin Active Widgets
|
53 |
-
*
|
54 |
-
* @since 1.0.0
|
55 |
-
*
|
56 |
-
* @param string $plugin_init Plugin init file.
|
57 |
-
* @param array $data Data.
|
58 |
-
* @return void
|
59 |
-
*/
|
60 |
-
function site_origin( $plugin_init = '', $data = array() ) {
|
61 |
-
|
62 |
-
if ( 'so-widgets-bundle/so-widgets-bundle.php' === $plugin_init ) {
|
63 |
-
|
64 |
-
$data = json_decode( json_encode( $data ), true );
|
65 |
-
|
66 |
-
if ( isset( $data['astra_site_options'] ) ) {
|
67 |
-
|
68 |
-
$widgets = ( isset( $data['astra_site_options']['siteorigin_widgets_active'] ) ) ? $data['astra_site_options']['siteorigin_widgets_active'] : '';
|
69 |
-
|
70 |
-
if ( ! empty( $widgets ) ) {
|
71 |
-
update_option( 'siteorigin_widgets_active', $widgets );
|
72 |
-
wp_cache_delete( 'active_widgets', 'siteorigin_widgets' );
|
73 |
-
}
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Kicking this off by calling 'instance()' method
|
83 |
-
*/
|
84 |
-
Astra_Sites_Compatibility_SO_Widgets::instance();
|
85 |
-
|
86 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/classes/compatibility/class-astra-sites-compatibility.php
CHANGED
@@ -49,6 +49,10 @@ if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
|
|
49 |
|
50 |
// Plugin - Site Origin Widgets.
|
51 |
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/so-widgets-bundle/class-astra-sites-compatibility-so-widgets.php';
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
}
|
49 |
|
50 |
// Plugin - Site Origin Widgets.
|
51 |
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/so-widgets-bundle/class-astra-sites-compatibility-so-widgets.php';
|
52 |
+
|
53 |
+
// Plugin - WooCommerce.
|
54 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/woocommerce/class-astra-sites-compatibility-woocommerce.php';
|
55 |
+
|
56 |
}
|
57 |
|
58 |
}
|
inc/classes/compatibility/elementor/background-processing/class-astra-elementor-image-importer-process.php
DELETED
@@ -1,64 +0,0 @@
|
|
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
DELETED
@@ -1,144 +0,0 @@
|
|
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
DELETED
@@ -1,302 +0,0 @@
|
|
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/woocommerce/class-astra-sites-compatibility-woocommerce.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Astra Sites Compatibility for 'WooCommerce'
|
4 |
+
*
|
5 |
+
* @see https://wordpress.org/plugins/woocommerce/
|
6 |
+
*
|
7 |
+
* @package Astra Sites
|
8 |
+
* @since 1.1.4
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! class_exists( 'Astra_Sites_Compatibility_WooCommerce' ) ) :
|
12 |
+
|
13 |
+
/**
|
14 |
+
* WooCommerce Compatibility
|
15 |
+
*
|
16 |
+
* @since 1.1.4
|
17 |
+
*/
|
18 |
+
class Astra_Sites_Compatibility_WooCommerce {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Instance
|
22 |
+
*
|
23 |
+
* @access private
|
24 |
+
* @var object Class object.
|
25 |
+
* @since 1.1.4
|
26 |
+
*/
|
27 |
+
private static $instance;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Initiator
|
31 |
+
*
|
32 |
+
* @since 1.1.4
|
33 |
+
* @return object initialized object of class.
|
34 |
+
*/
|
35 |
+
public static function instance() {
|
36 |
+
if ( ! isset( self::$instance ) ) {
|
37 |
+
self::$instance = new self;
|
38 |
+
}
|
39 |
+
return self::$instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
*
|
45 |
+
* @since 1.1.4
|
46 |
+
*/
|
47 |
+
public function __construct() {
|
48 |
+
add_filter( 'woocommerce_enable_setup_wizard', '__return_false', 5 );
|
49 |
+
add_action( 'astra_sites_import_start', array( $this, 'add_attributes' ), 10, 2 );
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Add product attributes.
|
54 |
+
*
|
55 |
+
* @since 1.1.4
|
56 |
+
*
|
57 |
+
* @param string $demo_data Import data.
|
58 |
+
* @param array $demo_api_uri Demo site URL.
|
59 |
+
* @return void
|
60 |
+
*/
|
61 |
+
function add_attributes( $demo_data = array(), $demo_api_uri = '' ) {
|
62 |
+
$attributes = ( isset( $demo_data['astra-site-options-data']['woocommerce_product_attributes'] ) ) ? $demo_data['astra-site-options-data']['woocommerce_product_attributes'] : array();
|
63 |
+
|
64 |
+
if ( ! empty( $attributes ) && function_exists( 'wc_create_attribute' ) ) {
|
65 |
+
foreach ( $attributes as $key => $attribute ) {
|
66 |
+
$args = array(
|
67 |
+
'name' => $attribute['attribute_label'],
|
68 |
+
'slug' => $attribute['attribute_name'],
|
69 |
+
'type' => $attribute['attribute_type'],
|
70 |
+
'order_by' => $attribute['attribute_orderby'],
|
71 |
+
'has_archives' => $attribute['attribute_public'],
|
72 |
+
);
|
73 |
+
|
74 |
+
$id = wc_create_attribute( $args );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Kicking this off by calling 'instance()' method
|
82 |
+
*/
|
83 |
+
Astra_Sites_Compatibility_WooCommerce::instance();
|
84 |
+
|
85 |
+
endif;
|
inc/classes/vendor/wp-async-request.php
DELETED
@@ -1,164 +0,0 @@
|
|
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
DELETED
@@ -1,507 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/importers/class-astra-site-options-import.php
CHANGED
@@ -52,10 +52,10 @@ class Astra_Site_Options_Import {
|
|
52 |
'page_on_front',
|
53 |
'page_for_posts',
|
54 |
|
55 |
-
// Plugin
|
56 |
'siteorigin_widgets_active',
|
57 |
|
58 |
-
// Plugin
|
59 |
'elementor_container_width',
|
60 |
'elementor_cpt_support',
|
61 |
'elementor_css_print_method',
|
@@ -72,6 +72,7 @@ class Astra_Site_Options_Import {
|
|
72 |
'elementor_space_between_widgets',
|
73 |
'elementor_stretched_section_container',
|
74 |
|
|
|
75 |
'_fl_builder_enabled_icons',
|
76 |
'_fl_builder_enabled_modules',
|
77 |
'_fl_builder_post_types',
|
@@ -81,7 +82,12 @@ class Astra_Site_Options_Import {
|
|
81 |
'_fl_builder_user_access',
|
82 |
'_fl_builder_enabled_templates',
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
85 |
);
|
86 |
}
|
87 |
|
@@ -110,8 +116,11 @@ class Astra_Site_Options_Import {
|
|
110 |
|
111 |
switch ( $option_name ) {
|
112 |
|
113 |
-
// page
|
114 |
-
|
|
|
|
|
|
|
115 |
case 'page_for_posts':
|
116 |
case 'page_on_front':
|
117 |
$this->update_page_id_by_option_value( $option_name, $option_value );
|
@@ -122,6 +131,11 @@ class Astra_Site_Options_Import {
|
|
122 |
$this->set_nav_menu_locations( $option_value );
|
123 |
break;
|
124 |
|
|
|
|
|
|
|
|
|
|
|
125 |
// insert logo.
|
126 |
case 'custom_logo':
|
127 |
$this->insert_logo( $option_value );
|
@@ -180,6 +194,40 @@ class Astra_Site_Options_Import {
|
|
180 |
}
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
/**
|
185 |
* Insert Logo By URL
|
52 |
'page_on_front',
|
53 |
'page_for_posts',
|
54 |
|
55 |
+
// Plugin: SiteOrigin Widgets Bundle.
|
56 |
'siteorigin_widgets_active',
|
57 |
|
58 |
+
// Plugin: Elementor.
|
59 |
'elementor_container_width',
|
60 |
'elementor_cpt_support',
|
61 |
'elementor_css_print_method',
|
72 |
'elementor_space_between_widgets',
|
73 |
'elementor_stretched_section_container',
|
74 |
|
75 |
+
// Plugin: Beaver Builder.
|
76 |
'_fl_builder_enabled_icons',
|
77 |
'_fl_builder_enabled_modules',
|
78 |
'_fl_builder_post_types',
|
82 |
'_fl_builder_user_access',
|
83 |
'_fl_builder_enabled_templates',
|
84 |
|
85 |
+
// Plugin: WooCommerce.
|
86 |
+
'woocommerce_shop_page_title',
|
87 |
+
'woocommerce_cart_page_title',
|
88 |
+
'woocommerce_checkout_page_title',
|
89 |
+
'woocommerce_myaccount_page_title',
|
90 |
+
'woocommerce_product_cat',
|
91 |
);
|
92 |
}
|
93 |
|
116 |
|
117 |
switch ( $option_name ) {
|
118 |
|
119 |
+
// Set page ID by page Title.
|
120 |
+
case 'woocommerce_shop_page_title':
|
121 |
+
case 'woocommerce_cart_page_title':
|
122 |
+
case 'woocommerce_checkout_page_title':
|
123 |
+
case 'woocommerce_myaccount_page_title':
|
124 |
case 'page_for_posts':
|
125 |
case 'page_on_front':
|
126 |
$this->update_page_id_by_option_value( $option_name, $option_value );
|
131 |
$this->set_nav_menu_locations( $option_value );
|
132 |
break;
|
133 |
|
134 |
+
// import WooCommerce category images.
|
135 |
+
case 'woocommerce_product_cat':
|
136 |
+
$this->set_woocommerce_product_cat( $option_value );
|
137 |
+
break;
|
138 |
+
|
139 |
// insert logo.
|
140 |
case 'custom_logo':
|
141 |
$this->insert_logo( $option_value );
|
194 |
}
|
195 |
}
|
196 |
|
197 |
+
/**
|
198 |
+
* Set WooCommerce category images.
|
199 |
+
*
|
200 |
+
* @since 1.1.4
|
201 |
+
*
|
202 |
+
* @param array $cats Array of categories.
|
203 |
+
*/
|
204 |
+
private function set_woocommerce_product_cat( $cats = array() ) {
|
205 |
+
|
206 |
+
$menu_locations = array();
|
207 |
+
|
208 |
+
if ( isset( $cats ) ) {
|
209 |
+
|
210 |
+
foreach ( $cats as $key => $cat ) {
|
211 |
+
|
212 |
+
if ( ! empty( $cat['slug'] ) && ! empty( $cat['thumbnail_src'] ) ) {
|
213 |
+
|
214 |
+
$image = (object) Astra_Sites_Helper::_sideload_image( $cat['thumbnail_src'] );
|
215 |
+
|
216 |
+
if ( ! is_wp_error( $image ) ) {
|
217 |
+
|
218 |
+
if ( isset( $image->attachment_id ) && ! empty( $image->attachment_id ) ) {
|
219 |
+
|
220 |
+
$term = get_term_by( 'slug', $cat['slug'], 'product_cat' );
|
221 |
+
|
222 |
+
if ( is_object( $term ) ) {
|
223 |
+
update_term_meta( $term->term_id, 'thumbnail_id', $image->attachment_id );
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
|
232 |
/**
|
233 |
* Insert Logo By URL
|
languages/astra-sites.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Astra Starter Sites package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Astra Starter Sites 1.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
-
"POT-Creation-Date: 2017-12-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -48,27 +48,27 @@ msgstr ""
|
|
48 |
msgid "You have not \"customize\" access to import the Astra site."
|
49 |
msgstr ""
|
50 |
|
51 |
-
#: inc/classes/class-astra-sites-importer.php:
|
52 |
msgid "Request site API URL is empty. Try again!"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: inc/classes/class-astra-sites-importer.php:
|
56 |
msgid "Customizer data is empty!"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: inc/classes/class-astra-sites-importer.php:
|
60 |
msgid "There was an error downloading the XML file."
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: inc/classes/class-astra-sites-importer.php:
|
64 |
msgid "Invalid site XML file!"
|
65 |
msgstr ""
|
66 |
|
67 |
-
#: inc/classes/class-astra-sites-importer.php:
|
68 |
msgid "Site options are empty!"
|
69 |
msgstr ""
|
70 |
|
71 |
-
#: inc/classes/class-astra-sites-importer.php:
|
72 |
msgid "Widget data is empty!"
|
73 |
msgstr ""
|
74 |
|
@@ -140,7 +140,7 @@ msgstr ""
|
|
140 |
msgid "Import This Site"
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: inc/classes/class-astra-sites.php:226 inc/classes/class-astra-sites.php:
|
144 |
msgid "Importing.."
|
145 |
msgstr ""
|
146 |
|
@@ -183,126 +183,122 @@ msgid "Successfully plugin installed!"
|
|
183 |
msgstr ""
|
184 |
|
185 |
#: inc/classes/class-astra-sites.php:236
|
186 |
-
msgid "There was an error while installing the plugin "
|
187 |
-
msgstr ""
|
188 |
-
|
189 |
-
#: inc/classes/class-astra-sites.php:237
|
190 |
msgid "Activating plugin "
|
191 |
msgstr ""
|
192 |
|
193 |
-
#: inc/classes/class-astra-sites.php:
|
194 |
msgid "Successfully plugin activated "
|
195 |
msgstr ""
|
196 |
|
197 |
-
#: inc/classes/class-astra-sites.php:
|
198 |
msgid "Bulk plugin activation..."
|
199 |
msgstr ""
|
200 |
|
201 |
-
#: inc/classes/class-astra-sites.php:
|
202 |
msgid "Successfully plugin activate - "
|
203 |
msgstr ""
|
204 |
|
205 |
-
#: inc/classes/class-astra-sites.php:
|
206 |
msgid "Error! While activating plugin - "
|
207 |
msgstr ""
|
208 |
|
209 |
-
#: inc/classes/class-astra-sites.php:
|
210 |
msgid "Bulk plugin installation..."
|
211 |
msgstr ""
|
212 |
|
213 |
-
#: inc/classes/class-astra-sites.php:
|
214 |
msgid "Site API "
|
215 |
msgstr ""
|
216 |
|
217 |
-
#: inc/classes/class-astra-sites.php:
|
218 |
msgid "Processing requests..."
|
219 |
msgstr ""
|
220 |
|
221 |
-
#: inc/classes/class-astra-sites.php:
|
222 |
msgid "1) Importing \"Customizer Settings\"..."
|
223 |
msgstr ""
|
224 |
|
225 |
-
#: inc/classes/class-astra-sites.php:
|
226 |
msgid "Successfully imported customizer settings!"
|
227 |
msgstr ""
|
228 |
|
229 |
-
#: inc/classes/class-astra-sites.php:
|
230 |
msgid "2) Preparing \"XML\" Data..."
|
231 |
msgstr ""
|
232 |
|
233 |
-
#: inc/classes/class-astra-sites.php:
|
234 |
msgid "Successfully set XML data!"
|
235 |
msgstr ""
|
236 |
|
237 |
-
#: inc/classes/class-astra-sites.php:
|
238 |
msgid "3) Importing \"XML\"..."
|
239 |
msgstr ""
|
240 |
|
241 |
-
#: inc/classes/class-astra-sites.php:
|
242 |
msgid "Successfully imported XML!"
|
243 |
msgstr ""
|
244 |
|
245 |
-
#: inc/classes/class-astra-sites.php:
|
246 |
msgid "4) Importing \"Options\"..."
|
247 |
msgstr ""
|
248 |
|
249 |
-
#: inc/classes/class-astra-sites.php:
|
250 |
msgid "Successfully imported Options!"
|
251 |
msgstr ""
|
252 |
|
253 |
-
#: inc/classes/class-astra-sites.php:
|
254 |
msgid "5) Importing \"Widgets\"..."
|
255 |
msgstr ""
|
256 |
|
257 |
-
#: inc/classes/class-astra-sites.php:
|
258 |
msgid "Successfully imported Widgets!"
|
259 |
msgstr ""
|
260 |
|
261 |
-
#: inc/classes/class-astra-sites.php:
|
262 |
msgid "Site imported successfully! visit : "
|
263 |
msgstr ""
|
264 |
|
265 |
-
#: inc/classes/class-astra-sites.php:
|
266 |
msgid "Getting Site Information.."
|
267 |
msgstr ""
|
268 |
|
269 |
-
#: inc/classes/class-astra-sites.php:
|
270 |
msgid "Importing Customizer Settings.."
|
271 |
msgstr ""
|
272 |
|
273 |
-
#: inc/classes/class-astra-sites.php:
|
274 |
msgid "Setting up import data.."
|
275 |
msgstr ""
|
276 |
|
277 |
-
#: inc/classes/class-astra-sites.php:
|
278 |
msgid "Importing Pages, Posts & Media.."
|
279 |
msgstr ""
|
280 |
|
281 |
-
#: inc/classes/class-astra-sites.php:
|
282 |
msgid "Importing Site Options.."
|
283 |
msgstr ""
|
284 |
|
285 |
-
#: inc/classes/class-astra-sites.php:
|
286 |
msgid "Importing Widgets.."
|
287 |
msgstr ""
|
288 |
|
289 |
-
#: inc/classes/class-astra-sites.php:
|
290 |
msgid "Import Complete.."
|
291 |
msgstr ""
|
292 |
|
293 |
-
#: inc/classes/class-astra-sites.php:
|
294 |
msgid "Previewing "
|
295 |
msgstr ""
|
296 |
|
297 |
-
#: inc/classes/class-astra-sites.php:
|
298 |
msgid "See Error Log →"
|
299 |
msgstr ""
|
300 |
|
301 |
-
#: inc/classes/class-astra-sites.php:
|
302 |
msgid "No plugin specified"
|
303 |
msgstr ""
|
304 |
|
305 |
-
#: inc/classes/class-astra-sites.php:
|
306 |
msgid "Plugin Successfully Activated"
|
307 |
msgstr ""
|
308 |
|
2 |
# This file is distributed under the same license as the Astra Starter Sites package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Astra Starter Sites 1.1.4\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
+
"POT-Creation-Date: 2017-12-28 08:58:28+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
48 |
msgid "You have not \"customize\" access to import the Astra site."
|
49 |
msgstr ""
|
50 |
|
51 |
+
#: inc/classes/class-astra-sites-importer.php:104
|
52 |
msgid "Request site API URL is empty. Try again!"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: inc/classes/class-astra-sites-importer.php:127
|
56 |
msgid "Customizer data is empty!"
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: inc/classes/class-astra-sites-importer.php:156
|
60 |
msgid "There was an error downloading the XML file."
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: inc/classes/class-astra-sites-importer.php:162
|
64 |
msgid "Invalid site XML file!"
|
65 |
msgstr ""
|
66 |
|
67 |
+
#: inc/classes/class-astra-sites-importer.php:184
|
68 |
msgid "Site options are empty!"
|
69 |
msgstr ""
|
70 |
|
71 |
+
#: inc/classes/class-astra-sites-importer.php:206
|
72 |
msgid "Widget data is empty!"
|
73 |
msgstr ""
|
74 |
|
140 |
msgid "Import This Site"
|
141 |
msgstr ""
|
142 |
|
143 |
+
#: inc/classes/class-astra-sites.php:226 inc/classes/class-astra-sites.php:243
|
144 |
msgid "Importing.."
|
145 |
msgstr ""
|
146 |
|
183 |
msgstr ""
|
184 |
|
185 |
#: inc/classes/class-astra-sites.php:236
|
|
|
|
|
|
|
|
|
186 |
msgid "Activating plugin "
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: inc/classes/class-astra-sites.php:237
|
190 |
msgid "Successfully plugin activated "
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: inc/classes/class-astra-sites.php:238
|
194 |
msgid "Bulk plugin activation..."
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: inc/classes/class-astra-sites.php:239
|
198 |
msgid "Successfully plugin activate - "
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: inc/classes/class-astra-sites.php:240
|
202 |
msgid "Error! While activating plugin - "
|
203 |
msgstr ""
|
204 |
|
205 |
+
#: inc/classes/class-astra-sites.php:241
|
206 |
msgid "Bulk plugin installation..."
|
207 |
msgstr ""
|
208 |
|
209 |
+
#: inc/classes/class-astra-sites.php:242
|
210 |
msgid "Site API "
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: inc/classes/class-astra-sites.php:244
|
214 |
msgid "Processing requests..."
|
215 |
msgstr ""
|
216 |
|
217 |
+
#: inc/classes/class-astra-sites.php:245
|
218 |
msgid "1) Importing \"Customizer Settings\"..."
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: inc/classes/class-astra-sites.php:246
|
222 |
msgid "Successfully imported customizer settings!"
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: inc/classes/class-astra-sites.php:247
|
226 |
msgid "2) Preparing \"XML\" Data..."
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: inc/classes/class-astra-sites.php:248
|
230 |
msgid "Successfully set XML data!"
|
231 |
msgstr ""
|
232 |
|
233 |
+
#: inc/classes/class-astra-sites.php:249
|
234 |
msgid "3) Importing \"XML\"..."
|
235 |
msgstr ""
|
236 |
|
237 |
+
#: inc/classes/class-astra-sites.php:250
|
238 |
msgid "Successfully imported XML!"
|
239 |
msgstr ""
|
240 |
|
241 |
+
#: inc/classes/class-astra-sites.php:251
|
242 |
msgid "4) Importing \"Options\"..."
|
243 |
msgstr ""
|
244 |
|
245 |
+
#: inc/classes/class-astra-sites.php:252
|
246 |
msgid "Successfully imported Options!"
|
247 |
msgstr ""
|
248 |
|
249 |
+
#: inc/classes/class-astra-sites.php:253
|
250 |
msgid "5) Importing \"Widgets\"..."
|
251 |
msgstr ""
|
252 |
|
253 |
+
#: inc/classes/class-astra-sites.php:254
|
254 |
msgid "Successfully imported Widgets!"
|
255 |
msgstr ""
|
256 |
|
257 |
+
#: inc/classes/class-astra-sites.php:256
|
258 |
msgid "Site imported successfully! visit : "
|
259 |
msgstr ""
|
260 |
|
261 |
+
#: inc/classes/class-astra-sites.php:257
|
262 |
msgid "Getting Site Information.."
|
263 |
msgstr ""
|
264 |
|
265 |
+
#: inc/classes/class-astra-sites.php:258
|
266 |
msgid "Importing Customizer Settings.."
|
267 |
msgstr ""
|
268 |
|
269 |
+
#: inc/classes/class-astra-sites.php:259
|
270 |
msgid "Setting up import data.."
|
271 |
msgstr ""
|
272 |
|
273 |
+
#: inc/classes/class-astra-sites.php:260
|
274 |
msgid "Importing Pages, Posts & Media.."
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: inc/classes/class-astra-sites.php:261
|
278 |
msgid "Importing Site Options.."
|
279 |
msgstr ""
|
280 |
|
281 |
+
#: inc/classes/class-astra-sites.php:262
|
282 |
msgid "Importing Widgets.."
|
283 |
msgstr ""
|
284 |
|
285 |
+
#: inc/classes/class-astra-sites.php:263
|
286 |
msgid "Import Complete.."
|
287 |
msgstr ""
|
288 |
|
289 |
+
#: inc/classes/class-astra-sites.php:264
|
290 |
msgid "Previewing "
|
291 |
msgstr ""
|
292 |
|
293 |
+
#: inc/classes/class-astra-sites.php:265
|
294 |
msgid "See Error Log →"
|
295 |
msgstr ""
|
296 |
|
297 |
+
#: inc/classes/class-astra-sites.php:300
|
298 |
msgid "No plugin specified"
|
299 |
msgstr ""
|
300 |
|
301 |
+
#: inc/classes/class-astra-sites.php:329
|
302 |
msgid "Plugin Successfully Activated"
|
303 |
msgstr ""
|
304 |
|
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.9.1
|
7 |
-
Stable tag: 1.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -56,6 +56,11 @@ https://wpastra.com/sites-suggestions/
|
|
56 |
|
57 |
== Changelog ==
|
58 |
|
|
|
|
|
|
|
|
|
|
|
59 |
v1.1.3 - 20-Dec-2017
|
60 |
* Improvement: Retain WooCommerce shop page when importing the ready WooCommerce sites.
|
61 |
|
4 |
Tags: demo, theme demos, one click import
|
5 |
Requires at least: 4.4
|
6 |
Tested up to: 4.9.1
|
7 |
+
Stable tag: 1.1.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
56 |
|
57 |
== Changelog ==
|
58 |
|
59 |
+
v1.1.4 - 28-Dec-2017
|
60 |
+
* Improvement: Importing WooCommerce product category images.
|
61 |
+
* Improvement: Retain WooCommerce cart, checkout & my account pages when importing the ready WooCommerce sites.
|
62 |
+
* Fix: Disabled WooCommerce plugin setup wizard after plugin install & activate.
|
63 |
+
|
64 |
v1.1.3 - 20-Dec-2017
|
65 |
* Improvement: Retain WooCommerce shop page when importing the ready WooCommerce sites.
|
66 |
|