Astra Starter Sites - Version 1.2.15

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon Astra Starter Sites
Version 1.2.15
Comparing to
See all releases

Code changes from version 1.2.14 to 1.2.15

astra-sites.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Astra Starter Sites – Elementor, Beaver Builder & Gutenberg Templates
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
- * Version: 1.2.14
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.2.14' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
3
  * Plugin Name: Astra Starter Sites – Elementor, Beaver Builder & Gutenberg Templates
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
+ * Version: 1.2.15
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.2.15' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
inc/assets/js/admin-page.js CHANGED
@@ -208,8 +208,8 @@ var AstraSitesAjaxQueue = (function() {
208
  }
209
  })
210
  .fail(function( jqXHR ){
211
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
212
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
213
  })
214
  .done(function ( data ) {
215
 
@@ -248,8 +248,8 @@ var AstraSitesAjaxQueue = (function() {
248
  },
249
  })
250
  .fail(function( jqXHR ){
251
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
252
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
253
  })
254
  .done(function ( widgets_data ) {
255
 
@@ -286,8 +286,8 @@ var AstraSitesAjaxQueue = (function() {
286
  },
287
  })
288
  .fail(function( jqXHR ){
289
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
290
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
291
  })
292
  .done(function ( options_data ) {
293
 
@@ -325,8 +325,8 @@ var AstraSitesAjaxQueue = (function() {
325
  },
326
  })
327
  .fail(function( jqXHR ){
328
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
329
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
330
  })
331
  .done(function ( xml_data ) {
332
 
@@ -396,8 +396,8 @@ var AstraSitesAjaxQueue = (function() {
396
  },
397
  })
398
  .fail(function( jqXHR ){
399
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
400
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
401
  })
402
  .done(function ( forms ) {
403
 
@@ -434,8 +434,8 @@ var AstraSitesAjaxQueue = (function() {
434
  },
435
  })
436
  .fail(function( jqXHR ){
437
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
438
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
439
  })
440
  .done(function ( customizer_data ) {
441
 
@@ -970,8 +970,8 @@ var AstraSitesAjaxQueue = (function() {
970
  },
971
  })
972
  .fail(function( jqXHR ){
973
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
974
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
975
  })
976
  .done(function ( demo_data ) {
977
 
208
  }
209
  })
210
  .fail(function( jqXHR ){
211
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
212
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
213
  })
214
  .done(function ( data ) {
215
 
248
  },
249
  })
250
  .fail(function( jqXHR ){
251
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
252
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
253
  })
254
  .done(function ( widgets_data ) {
255
 
286
  },
287
  })
288
  .fail(function( jqXHR ){
289
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
290
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
291
  })
292
  .done(function ( options_data ) {
293
 
325
  },
326
  })
327
  .fail(function( jqXHR ){
328
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
329
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
330
  })
331
  .done(function ( xml_data ) {
332
 
396
  },
397
  })
398
  .fail(function( jqXHR ){
399
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
400
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
401
  })
402
  .done(function ( forms ) {
403
 
434
  },
435
  })
436
  .fail(function( jqXHR ){
437
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
438
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
439
  })
440
  .done(function ( customizer_data ) {
441
 
970
  },
971
  })
972
  .fail(function( jqXHR ){
973
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
974
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
975
  })
976
  .done(function ( demo_data ) {
977
 
inc/classes/class-astra-sites-importer-log.php CHANGED
@@ -1,510 +1,510 @@
1
- <?php
2
- /**
3
- * Astra Sites Importer Log
4
- *
5
- * @since 1.1.0
6
- * @package Astra Sites
7
- */
8
-
9
- defined( 'ABSPATH' ) or exit;
10
-
11
- if ( ! class_exists( 'Astra_Sites_Importer_Log' ) ) :
12
-
13
- /**
14
- * Astra Sites Importer
15
- */
16
- class Astra_Sites_Importer_Log {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.1.0
22
- * @var (Object) Class object
23
- */
24
- private static $_instance = null;
25
-
26
- /**
27
- * Log File
28
- *
29
- * @since 1.1.0
30
- * @var (Object) Class object
31
- */
32
- private static $log_file = null;
33
-
34
- /**
35
- * Set Instance
36
- *
37
- * @since 1.1.0
38
- *
39
- * @return object Class object.
40
- */
41
- public static function get_instance() {
42
- if ( ! isset( self::$_instance ) ) {
43
- self::$_instance = new self;
44
- }
45
-
46
- return self::$_instance;
47
- }
48
-
49
- /**
50
- * Constructor.
51
- *
52
- * @since 1.1.0
53
- */
54
- private function __construct() {
55
-
56
- // Check file read/write permissions.
57
- add_action( 'admin_init', array( $this, 'has_file_read_write' ) );
58
-
59
- }
60
-
61
- /**
62
- * Check file read/write permissions and process.
63
- *
64
- * @since 1.1.0
65
- * @return null
66
- */
67
- function has_file_read_write() {
68
-
69
- // Get user credentials for WP file-system API.
70
- $astra_sites_import = wp_nonce_url( admin_url( 'themes.php?page=astra-sites' ), 'astra-import' );
71
- if ( false === ( $creds = request_filesystem_credentials( $astra_sites_import, '', false, false, null ) ) ) {
72
- return;
73
- }
74
-
75
- // Set log file.
76
- self::set_log_file();
77
-
78
- // Initial AJAX Import Hooks.
79
- add_action( 'astra_sites_import_start', array( $this, 'start' ), 10, 2 );
80
- add_action( 'astra_sites_import_customizer_settings', array( $this, 'start_customizer' ) );
81
- add_action( 'astra_sites_import_prepare_xml_data', array( $this, 'start_xml' ) );
82
- add_action( 'astra_sites_import_options', array( $this, 'start_options' ) );
83
- add_action( 'astra_sites_import_widgets', array( $this, 'start_widgets' ) );
84
- add_action( 'astra_sites_import_complete', array( $this, 'start_end' ) );
85
-
86
- // Hooks in between the process of import.
87
- add_filter( 'wie_import_results', array( $this, 'widgets_data' ) );
88
- add_action( 'astra_sites_import_xml_log', array( $this, 'xml_log' ), 10, 3 );
89
- }
90
-
91
- /**
92
- * Add log file URL in UI response.
93
- *
94
- * @since 1.1.0
95
- */
96
- public static function add_log_file_url() {
97
-
98
- $upload_dir = self::log_dir();
99
- $upload_path = trailingslashit( $upload_dir['url'] );
100
- $file_abs_url = get_option( 'astra_sites_recent_import_log_file', self::$log_file );
101
- $file_url = $upload_path . basename( $file_abs_url );
102
-
103
- return array(
104
- 'abs_url' => $file_abs_url,
105
- 'url' => $file_url,
106
- );
107
- }
108
-
109
- /**
110
- * XML Log.
111
- *
112
- * @since 1.1.0
113
- * @param string $level Level (Debug, Info etc.).
114
- * @param string $message Message.
115
- * @param string $context Context.
116
- * @return void
117
- */
118
- function xml_log( $level = '', $message = '', $context = '' ) {
119
- Astra_Sites_Importer_Log::add( $message );
120
- }
121
-
122
- /**
123
- * Current Time for log.
124
- *
125
- * @since 1.1.0
126
- * @return string Current time with time zone.
127
- */
128
- public static function current_time() {
129
- return date( 'H:i:s' ) . ' ' . date_default_timezone_get();
130
- }
131
-
132
- /**
133
- * Import Start
134
- *
135
- * @since 1.1.0
136
- * @param array $data Import Data.
137
- * @param string $demo_api_uri Import site API URL.
138
- * @return void
139
- */
140
- function start( $data = array(), $demo_api_uri = '' ) {
141
-
142
- Astra_Sites_Importer_Log::add( '# System Details: ' );
143
- Astra_Sites_Importer_Log::add( "Debug Mode \t\t: " . self::get_debug_mode() );
144
- Astra_Sites_Importer_Log::add( "Operating System \t: " . self::get_os() );
145
- Astra_Sites_Importer_Log::add( "Software \t\t: " . self::get_software() );
146
- Astra_Sites_Importer_Log::add( "MySQL version \t\t: " . self::get_mysql_version() );
147
- Astra_Sites_Importer_Log::add( "XML Reader \t\t: " . self::get_xmlreader_status() );
148
- Astra_Sites_Importer_Log::add( "PHP Version \t\t: " . self::get_php_version() );
149
- Astra_Sites_Importer_Log::add( "PHP Max Input Vars \t: " . self::get_php_max_input_vars() );
150
- Astra_Sites_Importer_Log::add( "PHP Max Post Size \t: " . self::get_php_max_post_size() );
151
- Astra_Sites_Importer_Log::add( "PHP Extension GD \t: " . self::get_php_extension_gd() );
152
- Astra_Sites_Importer_Log::add( "PHP Max Execution Time \t: " . self::get_max_execution_time() );
153
- Astra_Sites_Importer_Log::add( "Max Upload Size \t: " . size_format( wp_max_upload_size() ) );
154
- Astra_Sites_Importer_Log::add( "Memory Limit \t\t: " . self::get_memory_limit() );
155
- Astra_Sites_Importer_Log::add( "Timezone \t\t: " . self::get_timezone() );
156
- Astra_Sites_Importer_Log::add( PHP_EOL . '-----' . PHP_EOL );
157
- Astra_Sites_Importer_Log::add( 'Importing Started! - ' . self::current_time() );
158
-
159
- Astra_Sites_Importer_Log::add( '---' . PHP_EOL );
160
- Astra_Sites_Importer_Log::add( 'WHY IMPORT PROCESS CAN FAIL? READ THIS - ' );
161
- Astra_Sites_Importer_Log::add( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' . PHP_EOL );
162
- Astra_Sites_Importer_Log::add( '---' . PHP_EOL );
163
-
164
- }
165
-
166
- /**
167
- * Start Customizer Import
168
- *
169
- * @since 1.1.0
170
- * @return void
171
- */
172
- function start_customizer() {
173
- Astra_Sites_Importer_Log::add( PHP_EOL . '1. Imported "Customizer Settings" - ' . self::current_time() );
174
- Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
175
- }
176
-
177
- /**
178
- * Start XML Import
179
- *
180
- * @since 1.1.0
181
- * @return void
182
- */
183
- function start_xml() {
184
- Astra_Sites_Importer_Log::add( PHP_EOL . '2. Importing "XML" - ' . self::current_time() );
185
- }
186
-
187
- /**
188
- * Start Options Import
189
- *
190
- * @since 1.1.0
191
- * @return void
192
- */
193
- function start_options() {
194
- Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
195
- Astra_Sites_Importer_Log::add( PHP_EOL . '3. Imported "Site Options" - ' . self::current_time() );
196
- Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
197
- }
198
-
199
- /**
200
- * Start Widgets Import
201
- *
202
- * @since 1.1.0
203
- * @return void
204
- */
205
- function start_widgets() {
206
- Astra_Sites_Importer_Log::add( PHP_EOL . '4. Importing "Widgets" - ' . self::current_time() );
207
- }
208
-
209
- /**
210
- * End Import Process
211
- *
212
- * @since 1.1.0
213
- * @return void
214
- */
215
- function start_end() {
216
- Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
217
- Astra_Sites_Importer_Log::add( PHP_EOL . 'Import Complete! - ' . self::current_time() );
218
-
219
- // Delete Log file.
220
- delete_option( 'astra_sites_recent_import_log_file' );
221
- }
222
-
223
- /**
224
- * Log Widget Import Data.
225
- *
226
- * @since 1.1.0
227
- * @param array $results Widget import info in array.
228
- * @return void
229
- */
230
- function widgets_data( $results = array() ) {
231
-
232
- if ( is_array( $results ) ) {
233
- foreach ( $results as $sidebar_key => $widgets ) {
234
- Astra_Sites_Importer_Log::add( 'Sidebar: ' . $sidebar_key );
235
- foreach ( $widgets['widgets'] as $widget_key => $widget ) {
236
- if ( isset( $widget['name'] ) && isset( $widget['message'] ) ) {
237
- Astra_Sites_Importer_Log::add( 'Widget: "' . $widget['name'] . '" - ' . $widget['message'] );
238
- }
239
- }
240
- }
241
- }
242
- }
243
-
244
- /**
245
- * Get an instance of WP_Filesystem_Direct.
246
- *
247
- * @since 1.1.0
248
- * @return object A WP_Filesystem_Direct instance.
249
- */
250
- static public function get_filesystem() {
251
- global $wp_filesystem;
252
-
253
- require_once ABSPATH . '/wp-admin/includes/file.php';
254
-
255
- WP_Filesystem();
256
-
257
- return $wp_filesystem;
258
- }
259
-
260
- /**
261
- * Get Log File
262
- *
263
- * @since 1.1.0
264
- * @return string log file URL.
265
- */
266
- public static function get_log_file() {
267
- return self::$log_file;
268
- }
269
-
270
- /**
271
- * Log file directory
272
- *
273
- * @since 1.1.0
274
- * @param string $dir_name Directory Name.
275
- * @return array Uploads directory array.
276
- */
277
- public static function log_dir( $dir_name = 'astra-sites' ) {
278
-
279
- $upload_dir = wp_upload_dir();
280
-
281
- // Build the paths.
282
- $dir_info = array(
283
- 'path' => $upload_dir['basedir'] . '/' . $dir_name . '/',
284
- 'url' => $upload_dir['baseurl'] . '/' . $dir_name . '/',
285
- );
286
-
287
- // Create the upload dir if it doesn't exist.
288
- if ( ! file_exists( $dir_info['path'] ) ) {
289
-
290
- // Create the directory.
291
- wp_mkdir_p( $dir_info['path'] );
292
-
293
- // Add an index file for security.
294
- self::get_filesystem()->put_contents( $dir_info['path'] . 'index.html', '' );
295
- }
296
-
297
- return $dir_info;
298
- }
299
-
300
- /**
301
- * Set log file
302
- *
303
- * @since 1.1.0
304
- */
305
- public static function set_log_file() {
306
-
307
- $upload_dir = self::log_dir();
308
-
309
- $upload_path = trailingslashit( $upload_dir['path'] );
310
-
311
- // File format e.g. 'import-31-Oct-2017-06-39-12.txt'.
312
- self::$log_file = $upload_path . 'import-' . date( 'd-M-Y-h-i-s' ) . '.txt';
313
-
314
- if ( ! get_option( 'astra_sites_recent_import_log_file', false ) ) {
315
- update_option( 'astra_sites_recent_import_log_file', self::$log_file );
316
- }
317
- }
318
-
319
- /**
320
- * Write content to a file.
321
- *
322
- * @since 1.1.0
323
- * @param string $content content to be saved to the file.
324
- */
325
- public static function add( $content ) {
326
-
327
- if ( get_option( 'astra_sites_recent_import_log_file', false ) ) {
328
- $log_file = get_option( 'astra_sites_recent_import_log_file', self::$log_file );
329
- } else {
330
- $log_file = self::$log_file;
331
- }
332
-
333
- $existing_data = '';
334
- if ( file_exists( $log_file ) ) {
335
- $existing_data = self::get_filesystem()->get_contents( $log_file );
336
- }
337
-
338
- // Style separator.
339
- $separator = PHP_EOL;
340
-
341
- self::get_filesystem()->put_contents( $log_file, $existing_data . $separator . $content, FS_CHMOD_FILE );
342
- }
343
-
344
- /**
345
- * Debug Mode
346
- *
347
- * @since 1.1.0
348
- * @return string Enabled for Debug mode ON and Disabled for Debug mode Off.
349
- */
350
- public static function get_debug_mode() {
351
- if ( WP_DEBUG ) {
352
- return __( 'Enabled', 'astra-sites' );
353
- }
354
-
355
- return __( 'Disabled', 'astra-sites' );
356
- }
357
-
358
- /**
359
- * Memory Limit
360
- *
361
- * @since 1.1.0
362
- * @return string Memory limit.
363
- */
364
- public static function get_memory_limit() {
365
-
366
- $required_memory = '64M';
367
- $memory_limit_in_bytes_current = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
368
- $memory_limit_in_bytes_required = wp_convert_hr_to_bytes( $required_memory );
369
-
370
- if ( $memory_limit_in_bytes_current < $memory_limit_in_bytes_required ) {
371
- return sprintf(
372
- /* translators: %1$s Memory Limit, %2$s Recommended memory limit. */
373
- _x( 'Current memory limit %1$s. We recommend setting memory to at least %2$s.', 'Recommended Memory Limit', 'astra-sites' ),
374
- WP_MEMORY_LIMIT,
375
- $required_memory
376
- );
377
- }
378
-
379
- return WP_MEMORY_LIMIT;
380
- }
381
-
382
- /**
383
- * Timezone
384
- *
385
- * @since 1.1.0
386
- * @see https://codex.wordpress.org/Option_Reference/
387
- *
388
- * @return string Current timezone.
389
- */
390
- public static function get_timezone() {
391
- $timezone = get_option( 'timezone_string' );
392
-
393
- if ( ! $timezone ) {
394
- return get_option( 'gmt_offset' );
395
- }
396
-
397
- return $timezone;
398
- }
399
-
400
- /**
401
- * Operating System
402
- *
403
- * @since 1.1.0
404
- * @return string Current Operating System.
405
- */
406
- public static function get_os() {
407
- return PHP_OS;
408
- }
409
-
410
- /**
411
- * Server Software
412
- *
413
- * @since 1.1.0
414
- * @return string Current Server Software.
415
- */
416
- public static function get_software() {
417
- return $_SERVER['SERVER_SOFTWARE'];
418
- }
419
-
420
- /**
421
- * MySql Version
422
- *
423
- * @since 1.1.0
424
- * @return string Current MySql Version.
425
- */
426
- public static function get_mysql_version() {
427
- global $wpdb;
428
- return $wpdb->db_version();
429
- }
430
-
431
- /**
432
- * XML Reader
433
- *
434
- * @since 1.2.8
435
- * @return string Current XML Reader status.
436
- */
437
- public static function get_xmlreader_status() {
438
-
439
- if ( class_exists( 'XMLReader' ) ) {
440
- return __( 'Yes', 'astra-sites' );
441
- }
442
-
443
- return __( 'No', 'astra-sites' );
444
- }
445
-
446
- /**
447
- * PHP Version
448
- *
449
- * @since 1.1.0
450
- * @return string Current PHP Version.
451
- */
452
- public static function get_php_version() {
453
- if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
454
- return _x( 'We recommend to use php 5.4 or higher', 'PHP Version', 'astra-sites' );
455
- }
456
- return PHP_VERSION;
457
- }
458
-
459
- /**
460
- * PHP Max Input Vars
461
- *
462
- * @since 1.1.0
463
- * @return string Current PHP Max Input Vars
464
- */
465
- public static function get_php_max_input_vars() {
466
- return ini_get( 'max_input_vars' ); // phpcs:disable PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
467
- }
468
-
469
- /**
470
- * PHP Max Post Size
471
- *
472
- * @since 1.1.0
473
- * @return string Current PHP Max Post Size
474
- */
475
- public static function get_php_max_post_size() {
476
- return ini_get( 'post_max_size' );
477
- }
478
-
479
- /**
480
- * PHP Max Execution Time
481
- *
482
- * @since 1.1.0
483
- * @return string Current Max Execution Time
484
- */
485
- public static function get_max_execution_time() {
486
- return ini_get( 'max_execution_time' );
487
- }
488
-
489
- /**
490
- * PHP GD Extension
491
- *
492
- * @since 1.1.0
493
- * @return string Current PHP GD Extension
494
- */
495
- public static function get_php_extension_gd() {
496
- if ( extension_loaded( 'gd' ) ) {
497
- return __( 'Yes', 'astra-sites' );
498
- }
499
-
500
- return __( 'No', 'astra-sites' );
501
- }
502
-
503
- }
504
-
505
- /**
506
- * Kicking this off by calling 'get_instance()' method
507
- */
508
- Astra_Sites_Importer_Log::get_instance();
509
-
510
- endif;
1
+ <?php
2
+ /**
3
+ * Astra Sites Importer Log
4
+ *
5
+ * @since 1.1.0
6
+ * @package Astra Sites
7
+ */
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ if ( ! class_exists( 'Astra_Sites_Importer_Log' ) ) :
12
+
13
+ /**
14
+ * Astra Sites Importer
15
+ */
16
+ class Astra_Sites_Importer_Log {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.1.0
22
+ * @var (Object) Class object
23
+ */
24
+ private static $_instance = null;
25
+
26
+ /**
27
+ * Log File
28
+ *
29
+ * @since 1.1.0
30
+ * @var (Object) Class object
31
+ */
32
+ private static $log_file = null;
33
+
34
+ /**
35
+ * Set Instance
36
+ *
37
+ * @since 1.1.0
38
+ *
39
+ * @return object Class object.
40
+ */
41
+ public static function get_instance() {
42
+ if ( ! isset( self::$_instance ) ) {
43
+ self::$_instance = new self;
44
+ }
45
+
46
+ return self::$_instance;
47
+ }
48
+
49
+ /**
50
+ * Constructor.
51
+ *
52
+ * @since 1.1.0
53
+ */
54
+ private function __construct() {
55
+
56
+ // Check file read/write permissions.
57
+ add_action( 'admin_init', array( $this, 'has_file_read_write' ) );
58
+
59
+ }
60
+
61
+ /**
62
+ * Check file read/write permissions and process.
63
+ *
64
+ * @since 1.1.0
65
+ * @return null
66
+ */
67
+ function has_file_read_write() {
68
+
69
+ // Get user credentials for WP file-system API.
70
+ $astra_sites_import = wp_nonce_url( admin_url( 'themes.php?page=astra-sites' ), 'astra-import' );
71
+ if ( false === ( $creds = request_filesystem_credentials( $astra_sites_import, '', false, false, null ) ) ) {
72
+ return;
73
+ }
74
+
75
+ // Set log file.
76
+ self::set_log_file();
77
+
78
+ // Initial AJAX Import Hooks.
79
+ add_action( 'astra_sites_import_start', array( $this, 'start' ), 10, 2 );
80
+ add_action( 'astra_sites_import_customizer_settings', array( $this, 'start_customizer' ) );
81
+ add_action( 'astra_sites_import_prepare_xml_data', array( $this, 'start_xml' ) );
82
+ add_action( 'astra_sites_import_options', array( $this, 'start_options' ) );
83
+ add_action( 'astra_sites_import_widgets', array( $this, 'start_widgets' ) );
84
+ add_action( 'astra_sites_import_complete', array( $this, 'start_end' ) );
85
+
86
+ // Hooks in between the process of import.
87
+ add_filter( 'wie_import_results', array( $this, 'widgets_data' ) );
88
+ add_action( 'astra_sites_import_xml_log', array( $this, 'xml_log' ), 10, 3 );
89
+ }
90
+
91
+ /**
92
+ * Add log file URL in UI response.
93
+ *
94
+ * @since 1.1.0
95
+ */
96
+ public static function add_log_file_url() {
97
+
98
+ $upload_dir = self::log_dir();
99
+ $upload_path = trailingslashit( $upload_dir['url'] );
100
+ $file_abs_url = get_option( 'astra_sites_recent_import_log_file', self::$log_file );
101
+ $file_url = $upload_path . basename( $file_abs_url );
102
+
103
+ return array(
104
+ 'abs_url' => $file_abs_url,
105
+ 'url' => $file_url,
106
+ );
107
+ }
108
+
109
+ /**
110
+ * XML Log.
111
+ *
112
+ * @since 1.1.0
113
+ * @param string $level Level (Debug, Info etc.).
114
+ * @param string $message Message.
115
+ * @param string $context Context.
116
+ * @return void
117
+ */
118
+ function xml_log( $level = '', $message = '', $context = '' ) {
119
+ Astra_Sites_Importer_Log::add( $message );
120
+ }
121
+
122
+ /**
123
+ * Current Time for log.
124
+ *
125
+ * @since 1.1.0
126
+ * @return string Current time with time zone.
127
+ */
128
+ public static function current_time() {
129
+ return date( 'H:i:s' ) . ' ' . date_default_timezone_get();
130
+ }
131
+
132
+ /**
133
+ * Import Start
134
+ *
135
+ * @since 1.1.0
136
+ * @param array $data Import Data.
137
+ * @param string $demo_api_uri Import site API URL.
138
+ * @return void
139
+ */
140
+ function start( $data = array(), $demo_api_uri = '' ) {
141
+
142
+ Astra_Sites_Importer_Log::add( '# System Details: ' );
143
+ Astra_Sites_Importer_Log::add( "Debug Mode \t\t: " . self::get_debug_mode() );
144
+ Astra_Sites_Importer_Log::add( "Operating System \t: " . self::get_os() );
145
+ Astra_Sites_Importer_Log::add( "Software \t\t: " . self::get_software() );
146
+ Astra_Sites_Importer_Log::add( "MySQL version \t\t: " . self::get_mysql_version() );
147
+ Astra_Sites_Importer_Log::add( "XML Reader \t\t: " . self::get_xmlreader_status() );
148
+ Astra_Sites_Importer_Log::add( "PHP Version \t\t: " . self::get_php_version() );
149
+ Astra_Sites_Importer_Log::add( "PHP Max Input Vars \t: " . self::get_php_max_input_vars() );
150
+ Astra_Sites_Importer_Log::add( "PHP Max Post Size \t: " . self::get_php_max_post_size() );
151
+ Astra_Sites_Importer_Log::add( "PHP Extension GD \t: " . self::get_php_extension_gd() );
152
+ Astra_Sites_Importer_Log::add( "PHP Max Execution Time \t: " . self::get_max_execution_time() );
153
+ Astra_Sites_Importer_Log::add( "Max Upload Size \t: " . size_format( wp_max_upload_size() ) );
154
+ Astra_Sites_Importer_Log::add( "Memory Limit \t\t: " . self::get_memory_limit() );
155
+ Astra_Sites_Importer_Log::add( "Timezone \t\t: " . self::get_timezone() );
156
+ Astra_Sites_Importer_Log::add( PHP_EOL . '-----' . PHP_EOL );
157
+ Astra_Sites_Importer_Log::add( 'Importing Started! - ' . self::current_time() );
158
+
159
+ Astra_Sites_Importer_Log::add( '---' . PHP_EOL );
160
+ Astra_Sites_Importer_Log::add( 'WHY IMPORT PROCESS CAN FAIL? READ THIS - ' );
161
+ Astra_Sites_Importer_Log::add( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' . PHP_EOL );
162
+ Astra_Sites_Importer_Log::add( '---' . PHP_EOL );
163
+
164
+ }
165
+
166
+ /**
167
+ * Start Customizer Import
168
+ *
169
+ * @since 1.1.0
170
+ * @return void
171
+ */
172
+ function start_customizer() {
173
+ Astra_Sites_Importer_Log::add( PHP_EOL . '1. Imported "Customizer Settings" - ' . self::current_time() );
174
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
175
+ }
176
+
177
+ /**
178
+ * Start XML Import
179
+ *
180
+ * @since 1.1.0
181
+ * @return void
182
+ */
183
+ function start_xml() {
184
+ Astra_Sites_Importer_Log::add( PHP_EOL . '2. Importing "XML" - ' . self::current_time() );
185
+ }
186
+
187
+ /**
188
+ * Start Options Import
189
+ *
190
+ * @since 1.1.0
191
+ * @return void
192
+ */
193
+ function start_options() {
194
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
195
+ Astra_Sites_Importer_Log::add( PHP_EOL . '3. Imported "Site Options" - ' . self::current_time() );
196
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
197
+ }
198
+
199
+ /**
200
+ * Start Widgets Import
201
+ *
202
+ * @since 1.1.0
203
+ * @return void
204
+ */
205
+ function start_widgets() {
206
+ Astra_Sites_Importer_Log::add( PHP_EOL . '4. Importing "Widgets" - ' . self::current_time() );
207
+ }
208
+
209
+ /**
210
+ * End Import Process
211
+ *
212
+ * @since 1.1.0
213
+ * @return void
214
+ */
215
+ function start_end() {
216
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
217
+ Astra_Sites_Importer_Log::add( PHP_EOL . 'Import Complete! - ' . self::current_time() );
218
+
219
+ // Delete Log file.
220
+ delete_option( 'astra_sites_recent_import_log_file' );
221
+ }
222
+
223
+ /**
224
+ * Log Widget Import Data.
225
+ *
226
+ * @since 1.1.0
227
+ * @param array $results Widget import info in array.
228
+ * @return void
229
+ */
230
+ function widgets_data( $results = array() ) {
231
+
232
+ if ( is_array( $results ) ) {
233
+ foreach ( $results as $sidebar_key => $widgets ) {
234
+ Astra_Sites_Importer_Log::add( 'Sidebar: ' . $sidebar_key );
235
+ foreach ( $widgets['widgets'] as $widget_key => $widget ) {
236
+ if ( isset( $widget['name'] ) && isset( $widget['message'] ) ) {
237
+ Astra_Sites_Importer_Log::add( 'Widget: "' . $widget['name'] . '" - ' . $widget['message'] );
238
+ }
239
+ }
240
+ }
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Get an instance of WP_Filesystem_Direct.
246
+ *
247
+ * @since 1.1.0
248
+ * @return object A WP_Filesystem_Direct instance.
249
+ */
250
+ static public function get_filesystem() {
251
+ global $wp_filesystem;
252
+
253
+ require_once ABSPATH . '/wp-admin/includes/file.php';
254
+
255
+ WP_Filesystem();
256
+
257
+ return $wp_filesystem;
258
+ }
259
+
260
+ /**
261
+ * Get Log File
262
+ *
263
+ * @since 1.1.0
264
+ * @return string log file URL.
265
+ */
266
+ public static function get_log_file() {
267
+ return self::$log_file;
268
+ }
269
+
270
+ /**
271
+ * Log file directory
272
+ *
273
+ * @since 1.1.0
274
+ * @param string $dir_name Directory Name.
275
+ * @return array Uploads directory array.
276
+ */
277
+ public static function log_dir( $dir_name = 'astra-sites' ) {
278
+
279
+ $upload_dir = wp_upload_dir();
280
+
281
+ // Build the paths.
282
+ $dir_info = array(
283
+ 'path' => $upload_dir['basedir'] . '/' . $dir_name . '/',
284
+ 'url' => $upload_dir['baseurl'] . '/' . $dir_name . '/',
285
+ );
286
+
287
+ // Create the upload dir if it doesn't exist.
288
+ if ( ! file_exists( $dir_info['path'] ) ) {
289
+
290
+ // Create the directory.
291
+ wp_mkdir_p( $dir_info['path'] );
292
+
293
+ // Add an index file for security.
294
+ self::get_filesystem()->put_contents( $dir_info['path'] . 'index.html', '' );
295
+ }
296
+
297
+ return $dir_info;
298
+ }
299
+
300
+ /**
301
+ * Set log file
302
+ *
303
+ * @since 1.1.0
304
+ */
305
+ public static function set_log_file() {
306
+
307
+ $upload_dir = self::log_dir();
308
+
309
+ $upload_path = trailingslashit( $upload_dir['path'] );
310
+
311
+ // File format e.g. 'import-31-Oct-2017-06-39-12.txt'.
312
+ self::$log_file = $upload_path . 'import-' . date( 'd-M-Y-h-i-s' ) . '.txt';
313
+
314
+ if ( ! get_option( 'astra_sites_recent_import_log_file', false ) ) {
315
+ update_option( 'astra_sites_recent_import_log_file', self::$log_file );
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Write content to a file.
321
+ *
322
+ * @since 1.1.0
323
+ * @param string $content content to be saved to the file.
324
+ */
325
+ public static function add( $content ) {
326
+
327
+ if ( get_option( 'astra_sites_recent_import_log_file', false ) ) {
328
+ $log_file = get_option( 'astra_sites_recent_import_log_file', self::$log_file );
329
+ } else {
330
+ $log_file = self::$log_file;
331
+ }
332
+
333
+ $existing_data = '';
334
+ if ( file_exists( $log_file ) ) {
335
+ $existing_data = self::get_filesystem()->get_contents( $log_file );
336
+ }
337
+
338
+ // Style separator.
339
+ $separator = PHP_EOL;
340
+
341
+ self::get_filesystem()->put_contents( $log_file, $existing_data . $separator . $content, FS_CHMOD_FILE );
342
+ }
343
+
344
+ /**
345
+ * Debug Mode
346
+ *
347
+ * @since 1.1.0
348
+ * @return string Enabled for Debug mode ON and Disabled for Debug mode Off.
349
+ */
350
+ public static function get_debug_mode() {
351
+ if ( WP_DEBUG ) {
352
+ return __( 'Enabled', 'astra-sites' );
353
+ }
354
+
355
+ return __( 'Disabled', 'astra-sites' );
356
+ }
357
+
358
+ /**
359
+ * Memory Limit
360
+ *
361
+ * @since 1.1.0
362
+ * @return string Memory limit.
363
+ */
364
+ public static function get_memory_limit() {
365
+
366
+ $required_memory = '64M';
367
+ $memory_limit_in_bytes_current = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
368
+ $memory_limit_in_bytes_required = wp_convert_hr_to_bytes( $required_memory );
369
+
370
+ if ( $memory_limit_in_bytes_current < $memory_limit_in_bytes_required ) {
371
+ return sprintf(
372
+ /* translators: %1$s Memory Limit, %2$s Recommended memory limit. */
373
+ _x( 'Current memory limit %1$s. We recommend setting memory to at least %2$s.', 'Recommended Memory Limit', 'astra-sites' ),
374
+ WP_MEMORY_LIMIT,
375
+ $required_memory
376
+ );
377
+ }
378
+
379
+ return WP_MEMORY_LIMIT;
380
+ }
381
+
382
+ /**
383
+ * Timezone
384
+ *
385
+ * @since 1.1.0
386
+ * @see https://codex.wordpress.org/Option_Reference/
387
+ *
388
+ * @return string Current timezone.
389
+ */
390
+ public static function get_timezone() {
391
+ $timezone = get_option( 'timezone_string' );
392
+
393
+ if ( ! $timezone ) {
394
+ return get_option( 'gmt_offset' );
395
+ }
396
+
397
+ return $timezone;
398
+ }
399
+
400
+ /**
401
+ * Operating System
402
+ *
403
+ * @since 1.1.0
404
+ * @return string Current Operating System.
405
+ */
406
+ public static function get_os() {
407
+ return PHP_OS;
408
+ }
409
+
410
+ /**
411
+ * Server Software
412
+ *
413
+ * @since 1.1.0
414
+ * @return string Current Server Software.
415
+ */
416
+ public static function get_software() {
417
+ return $_SERVER['SERVER_SOFTWARE'];
418
+ }
419
+
420
+ /**
421
+ * MySql Version
422
+ *
423
+ * @since 1.1.0
424
+ * @return string Current MySql Version.
425
+ */
426
+ public static function get_mysql_version() {
427
+ global $wpdb;
428
+ return $wpdb->db_version();
429
+ }
430
+
431
+ /**
432
+ * XML Reader
433
+ *
434
+ * @since 1.2.8
435
+ * @return string Current XML Reader status.
436
+ */
437
+ public static function get_xmlreader_status() {
438
+
439
+ if ( class_exists( 'XMLReader' ) ) {
440
+ return __( 'Yes', 'astra-sites' );
441
+ }
442
+
443
+ return __( 'No', 'astra-sites' );
444
+ }
445
+
446
+ /**
447
+ * PHP Version
448
+ *
449
+ * @since 1.1.0
450
+ * @return string Current PHP Version.
451
+ */
452
+ public static function get_php_version() {
453
+ if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
454
+ return _x( 'We recommend to use php 5.4 or higher', 'PHP Version', 'astra-sites' );
455
+ }
456
+ return PHP_VERSION;
457
+ }
458
+
459
+ /**
460
+ * PHP Max Input Vars
461
+ *
462
+ * @since 1.1.0
463
+ * @return string Current PHP Max Input Vars
464
+ */
465
+ public static function get_php_max_input_vars() {
466
+ return ini_get( 'max_input_vars' ); // phpcs:disable PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
467
+ }
468
+
469
+ /**
470
+ * PHP Max Post Size
471
+ *
472
+ * @since 1.1.0
473
+ * @return string Current PHP Max Post Size
474
+ */
475
+ public static function get_php_max_post_size() {
476
+ return ini_get( 'post_max_size' );
477
+ }
478
+
479
+ /**
480
+ * PHP Max Execution Time
481
+ *
482
+ * @since 1.1.0
483
+ * @return string Current Max Execution Time
484
+ */
485
+ public static function get_max_execution_time() {
486
+ return ini_get( 'max_execution_time' );
487
+ }
488
+
489
+ /**
490
+ * PHP GD Extension
491
+ *
492
+ * @since 1.1.0
493
+ * @return string Current PHP GD Extension
494
+ */
495
+ public static function get_php_extension_gd() {
496
+ if ( extension_loaded( 'gd' ) ) {
497
+ return __( 'Yes', 'astra-sites' );
498
+ }
499
+
500
+ return __( 'No', 'astra-sites' );
501
+ }
502
+
503
+ }
504
+
505
+ /**
506
+ * Kicking this off by calling 'get_instance()' method
507
+ */
508
+ Astra_Sites_Importer_Log::get_instance();
509
+
510
+ endif;
inc/classes/class-astra-sites-page.php CHANGED
@@ -1,294 +1,294 @@
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
- add_action( 'admin_notices', __CLASS__ . '::notices' );
97
- }
98
-
99
- /**
100
- * Admin notice
101
- *
102
- * @since 1.2.8
103
- */
104
- public static function notices() {
105
-
106
- if ( 'appearance_page_astra-sites' !== get_current_screen()->id ) {
107
- return;
108
- }
109
-
110
- if ( ! class_exists( 'XMLReader' ) ) {
111
- ?>
112
- <div class="notice astra-sites-xml-notice notice-error">
113
- <p><b><?php _e( 'Required XMLReader PHP extension is missing on your server!', 'astra-sites' ); ?></b></p>
114
- <?php /* translators: %s is the white label name. */ ?>
115
- <p><?php printf( __( '%s import requires XMLReader extension to be installed. Please contact your web hosting provider and ask them to install and activate the XMLReader PHP extension.', 'astra-sites' ), self::$menu_page_title ); ?></p>
116
- </div>
117
- <?php
118
- }
119
- }
120
-
121
- /**
122
- * Save All admin settings here
123
- */
124
- static public function save_settings() {
125
-
126
- // Only admins can save settings.
127
- if ( ! current_user_can( 'manage_options' ) ) {
128
- return;
129
- }
130
-
131
- // Let extensions hook into saving.
132
- do_action( 'astra_sites_save_settings' );
133
- }
134
-
135
- /**
136
- * Init Nav Menu
137
- *
138
- * @param mixed $action Action name.
139
- * @since 1.0.6
140
- */
141
- static public function init_nav_menu( $action = '' ) {
142
-
143
- if ( '' !== $action ) {
144
- self::render_tab_menu( $action );
145
- }
146
- }
147
-
148
- /**
149
- * Render tab menu
150
- *
151
- * @param mixed $action Action name.
152
- * @since 1.0.6
153
- */
154
- static public function render_tab_menu( $action = '' ) {
155
- ?>
156
- <div id="astra-sites-menu-page">
157
- <?php self::render( $action ); ?>
158
- </div>
159
- <?php
160
- }
161
-
162
- /**
163
- * View actions
164
- *
165
- * @since 1.0.11
166
- */
167
- static public function get_view_actions() {
168
-
169
- if ( empty( self::$view_actions ) ) {
170
-
171
- self::$view_actions = apply_filters(
172
- 'astra_sites_menu_item',
173
- array()
174
- );
175
- }
176
-
177
- return self::$view_actions;
178
- }
179
-
180
- /**
181
- * Prints HTML content for tabs
182
- *
183
- * @param mixed $action Action name.
184
- * @since 1.0.6
185
- */
186
- static public function render( $action ) {
187
-
188
- ?>
189
- <div class="nav-tab-wrapper">
190
- <h1 class='astra-sites-title'> <?php echo esc_html( self::$menu_page_title ); ?> </h1>
191
- <?php
192
- $view_actions = self::get_view_actions();
193
-
194
- foreach ( $view_actions as $slug => $data ) {
195
-
196
- if ( ! $data['show'] ) {
197
- continue;
198
- }
199
-
200
- $url = self::get_page_url( $slug );
201
-
202
- if ( $slug == self::$parent_page_slug ) {
203
- update_option( 'astra_parent_page_url', $url );
204
- }
205
-
206
- $active = ( $slug == $action ) ? 'nav-tab-active' : '';
207
- ?>
208
- <a class='nav-tab <?php echo esc_attr( $active ); ?>' href='<?php echo esc_url( $url ); ?>'> <?php echo esc_html( $data['label'] ); ?> </a>
209
- <?php } ?>
210
- </div><!-- .nav-tab-wrapper -->
211
-
212
- <?php
213
- // Settings update message.
214
- if ( isset( $_REQUEST['message'] ) && ( 'saved' == $_REQUEST['message'] || 'saved_ext' == $_REQUEST['message'] ) ) {
215
- ?>
216
- <span id="message" class="notice notice-success is-dismissive"><p> <?php esc_html_e( 'Settings saved successfully.', 'astra-sites' ); ?> </p></span>
217
- <?php
218
- }
219
-
220
- }
221
-
222
- /**
223
- * Get and return page URL
224
- *
225
- * @param string $menu_slug Menu name.
226
- * @since 1.0.6
227
- * @return string page url
228
- */
229
- static public function get_page_url( $menu_slug ) {
230
-
231
- $parent_page = self::$default_menu_position;
232
-
233
- if ( strpos( $parent_page, '?' ) !== false ) {
234
- $query_var = '&page=' . self::$plugin_slug;
235
- } else {
236
- $query_var = '?page=' . self::$plugin_slug;
237
- }
238
-
239
- $parent_page_url = admin_url( $parent_page . $query_var );
240
-
241
- $url = $parent_page_url . '&action=' . $menu_slug;
242
-
243
- return esc_url( $url );
244
- }
245
-
246
- /**
247
- * Add main menu
248
- *
249
- * @since 1.0.6
250
- */
251
- static public function add_admin_menu() {
252
-
253
- $parent_page = self::$default_menu_position;
254
- $page_title = self::$menu_page_title;
255
- $capability = 'manage_options';
256
- $page_menu_slug = self::$plugin_slug;
257
- $page_menu_func = __CLASS__ . '::menu_callback';
258
-
259
- add_theme_page( $page_title, $page_title, $capability, $page_menu_slug, $page_menu_func );
260
- }
261
-
262
- /**
263
- * Menu callback
264
- *
265
- * @since 1.0.6
266
- */
267
- static public function menu_callback() {
268
-
269
- $current_slug = isset( $_GET['action'] ) ? esc_attr( $_GET['action'] ) : self::$current_slug;
270
-
271
- $active_tab = str_replace( '_', '-', $current_slug );
272
- $current_slug = str_replace( '-', '_', $current_slug );
273
-
274
- ?>
275
- <div class="astra-sites-menu-page-wrapper">
276
- <?php self::init_nav_menu( $active_tab ); ?>
277
- <?php do_action( 'astra_sites_menu_' . esc_attr( $current_slug ) . '_action' ); ?>
278
- </div>
279
- <?php
280
- }
281
-
282
- /**
283
- * Include general page
284
- *
285
- * @since 1.0.6
286
- */
287
- static public function general_page() {
288
- require_once ASTRA_SITES_DIR . 'inc/includes/admin-page.php';
289
- }
290
- }
291
-
292
- new Astra_Sites_Page;
293
-
294
- }// End if.
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
+ add_action( 'admin_notices', __CLASS__ . '::notices' );
97
+ }
98
+
99
+ /**
100
+ * Admin notice
101
+ *
102
+ * @since 1.2.8
103
+ */
104
+ public static function notices() {
105
+
106
+ if ( 'appearance_page_astra-sites' !== get_current_screen()->id ) {
107
+ return;
108
+ }
109
+
110
+ if ( ! class_exists( 'XMLReader' ) ) {
111
+ ?>
112
+ <div class="notice astra-sites-xml-notice notice-error">
113
+ <p><b><?php _e( 'Required XMLReader PHP extension is missing on your server!', 'astra-sites' ); ?></b></p>
114
+ <?php /* translators: %s is the white label name. */ ?>
115
+ <p><?php printf( __( '%s import requires XMLReader extension to be installed. Please contact your web hosting provider and ask them to install and activate the XMLReader PHP extension.', 'astra-sites' ), self::$menu_page_title ); ?></p>
116
+ </div>
117
+ <?php
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Save All admin settings here
123
+ */
124
+ static public function save_settings() {
125
+
126
+ // Only admins can save settings.
127
+ if ( ! current_user_can( 'manage_options' ) ) {
128
+ return;
129
+ }
130
+
131
+ // Let extensions hook into saving.
132
+ do_action( 'astra_sites_save_settings' );
133
+ }
134
+
135
+ /**
136
+ * Init Nav Menu
137
+ *
138
+ * @param mixed $action Action name.
139
+ * @since 1.0.6
140
+ */
141
+ static public function init_nav_menu( $action = '' ) {
142
+
143
+ if ( '' !== $action ) {
144
+ self::render_tab_menu( $action );
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Render tab menu
150
+ *
151
+ * @param mixed $action Action name.
152
+ * @since 1.0.6
153
+ */
154
+ static public function render_tab_menu( $action = '' ) {
155
+ ?>
156
+ <div id="astra-sites-menu-page">
157
+ <?php self::render( $action ); ?>
158
+ </div>
159
+ <?php
160
+ }
161
+
162
+ /**
163
+ * View actions
164
+ *
165
+ * @since 1.0.11
166
+ */
167
+ static public function get_view_actions() {
168
+
169
+ if ( empty( self::$view_actions ) ) {
170
+
171
+ self::$view_actions = apply_filters(
172
+ 'astra_sites_menu_item',
173
+ array()
174
+ );
175
+ }
176
+
177
+ return self::$view_actions;
178
+ }
179
+
180
+ /**
181
+ * Prints HTML content for tabs
182
+ *
183
+ * @param mixed $action Action name.
184
+ * @since 1.0.6
185
+ */
186
+ static public function render( $action ) {
187
+
188
+ ?>
189
+ <div class="nav-tab-wrapper">
190
+ <h1 class='astra-sites-title'> <?php echo esc_html( self::$menu_page_title ); ?> </h1>
191
+ <?php
192
+ $view_actions = self::get_view_actions();
193
+
194
+ foreach ( $view_actions as $slug => $data ) {
195
+
196
+ if ( ! $data['show'] ) {
197
+ continue;
198
+ }
199
+
200
+ $url = self::get_page_url( $slug );
201
+
202
+ if ( $slug == self::$parent_page_slug ) {
203
+ update_option( 'astra_parent_page_url', $url );
204
+ }
205
+
206
+ $active = ( $slug == $action ) ? 'nav-tab-active' : '';
207
+ ?>
208
+ <a class='nav-tab <?php echo esc_attr( $active ); ?>' href='<?php echo esc_url( $url ); ?>'> <?php echo esc_html( $data['label'] ); ?> </a>
209
+ <?php } ?>
210
+ </div><!-- .nav-tab-wrapper -->
211
+
212
+ <?php
213
+ // Settings update message.
214
+ if ( isset( $_REQUEST['message'] ) && ( 'saved' == $_REQUEST['message'] || 'saved_ext' == $_REQUEST['message'] ) ) {
215
+ ?>
216
+ <span id="message" class="notice notice-success is-dismissive"><p> <?php esc_html_e( 'Settings saved successfully.', 'astra-sites' ); ?> </p></span>
217
+ <?php
218
+ }
219
+
220
+ }
221
+
222
+ /**
223
+ * Get and return page URL
224
+ *
225
+ * @param string $menu_slug Menu name.
226
+ * @since 1.0.6
227
+ * @return string page url
228
+ */
229
+ static public function get_page_url( $menu_slug ) {
230
+
231
+ $parent_page = self::$default_menu_position;
232
+
233
+ if ( strpos( $parent_page, '?' ) !== false ) {
234
+ $query_var = '&page=' . self::$plugin_slug;
235
+ } else {
236
+ $query_var = '?page=' . self::$plugin_slug;
237
+ }
238
+
239
+ $parent_page_url = admin_url( $parent_page . $query_var );
240
+
241
+ $url = $parent_page_url . '&action=' . $menu_slug;
242
+
243
+ return esc_url( $url );
244
+ }
245
+
246
+ /**
247
+ * Add main menu
248
+ *
249
+ * @since 1.0.6
250
+ */
251
+ static public function add_admin_menu() {
252
+
253
+ $parent_page = self::$default_menu_position;
254
+ $page_title = self::$menu_page_title;
255
+ $capability = 'manage_options';
256
+ $page_menu_slug = self::$plugin_slug;
257
+ $page_menu_func = __CLASS__ . '::menu_callback';
258
+
259
+ add_theme_page( $page_title, $page_title, $capability, $page_menu_slug, $page_menu_func );
260
+ }
261
+
262
+ /**
263
+ * Menu callback
264
+ *
265
+ * @since 1.0.6
266
+ */
267
+ static public function menu_callback() {
268
+
269
+ $current_slug = isset( $_GET['action'] ) ? esc_attr( $_GET['action'] ) : self::$current_slug;
270
+
271
+ $active_tab = str_replace( '_', '-', $current_slug );
272
+ $current_slug = str_replace( '-', '_', $current_slug );
273
+
274
+ ?>
275
+ <div class="astra-sites-menu-page-wrapper">
276
+ <?php self::init_nav_menu( $active_tab ); ?>
277
+ <?php do_action( 'astra_sites_menu_' . esc_attr( $current_slug ) . '_action' ); ?>
278
+ </div>
279
+ <?php
280
+ }
281
+
282
+ /**
283
+ * Include general page
284
+ *
285
+ * @since 1.0.6
286
+ */
287
+ static public function general_page() {
288
+ require_once ASTRA_SITES_DIR . 'inc/includes/admin-page.php';
289
+ }
290
+ }
291
+
292
+ new Astra_Sites_Page;
293
+
294
+ }// End if.
inc/classes/class-astra-sites-white-label.php CHANGED
@@ -1,238 +1,238 @@
1
- <?php
2
- /**
3
- * Astra Sites White Label
4
- *
5
- * @package Astra Sites
6
- * @since 1.0.12
7
- */
8
-
9
- if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
10
-
11
- /**
12
- * Astra_Sites_White_Label
13
- *
14
- * @since 1.0.12
15
- */
16
- class Astra_Sites_White_Label {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.0.12
22
- *
23
- * @var object Class Object.
24
- * @access private
25
- */
26
- private static $instance;
27
-
28
- /**
29
- * Member Variable
30
- *
31
- * @since 1.0.12
32
- *
33
- * @var array branding
34
- * @access private
35
- */
36
- private static $branding;
37
-
38
- /**
39
- * Settings
40
- *
41
- * @since 1.2.11
42
- *
43
- * @var array settings
44
- *
45
- * @access private
46
- */
47
- private $settings;
48
-
49
- /**
50
- * Initiator
51
- *
52
- * @since 1.0.12
53
- *
54
- * @return object initialized object of class.
55
- */
56
- public static function get_instance() {
57
- if ( ! isset( self::$instance ) ) {
58
- self::$instance = new self;
59
- }
60
- return self::$instance;
61
- }
62
-
63
- /**
64
- * Constructor
65
- *
66
- * @since 1.0.12
67
- */
68
- public function __construct() {
69
- add_filter( 'all_plugins', array( $this, 'plugins_page' ) );
70
- add_filter( 'astra_addon_branding_options', __CLASS__ . '::settings' );
71
- add_action( 'astra_pro_white_label_add_form', __CLASS__ . '::add_white_lavel_form' );
72
- add_filter( 'astra_sites_menu_page_title', array( $this, 'page_title' ) );
73
-
74
- // Display the link with the plugin meta.
75
- if ( is_admin() ) {
76
- add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 4 );
77
- }
78
- }
79
-
80
- /**
81
- * White labels the plugins page.
82
- *
83
- * @since 1.0.12
84
- *
85
- * @param array $plugins Plugins Array.
86
- * @return array
87
- */
88
- function plugins_page( $plugins ) {
89
-
90
- if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
91
- return $plugins;
92
- }
93
-
94
- if ( ! isset( $plugins[ ASTRA_SITES_BASE ] ) ) {
95
- return $plugins;
96
- }
97
-
98
- // Set White Labels.
99
- $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
100
- $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
101
- $author = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author' );
102
- $author_uri = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author_url' );
103
-
104
- if ( ! empty( $name ) ) {
105
- $plugins[ ASTRA_SITES_BASE ]['Name'] = $name;
106
-
107
- // Remove Plugin URI if Agency White Label name is set.
108
- $plugins[ ASTRA_SITES_BASE ]['PluginURI'] = '';
109
- }
110
-
111
- if ( ! empty( $description ) ) {
112
- $plugins[ ASTRA_SITES_BASE ]['Description'] = $description;
113
- }
114
-
115
- if ( ! empty( $author ) ) {
116
- $plugins[ ASTRA_SITES_BASE ]['Author'] = $author;
117
- }
118
-
119
- if ( ! empty( $author_uri ) ) {
120
- $plugins[ ASTRA_SITES_BASE ]['AuthorURI'] = $author_uri;
121
- }
122
-
123
- return $plugins;
124
- }
125
-
126
- /**
127
- * Remove a "view details" link from the plugin list table
128
- *
129
- * @since 1.0.12
130
- *
131
- * @param array $plugin_meta List of links.
132
- * @param string $plugin_file Relative path to the main plugin file from the plugins directory.
133
- * @param array $plugin_data Data from the plugin headers.
134
- * @return array
135
- */
136
- public function plugin_links( $plugin_meta, $plugin_file, $plugin_data ) {
137
-
138
- if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
139
- return $plugin_meta;
140
- }
141
-
142
- // Set White Labels.
143
- if ( ASTRA_SITES_BASE == $plugin_file ) {
144
-
145
- $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
146
- $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
147
-
148
- // Remove Plugin URI if Agency White Label name is set.
149
- if ( ! empty( $name ) ) {
150
- unset( $plugin_meta[2] );
151
- }
152
- }
153
-
154
- return $plugin_meta;
155
- }
156
-
157
- /**
158
- * Add White Label setting's
159
- *
160
- * @since 1.0.12
161
- *
162
- * @param array $settings White label setting.
163
- * @return array
164
- */
165
- public static function settings( $settings = array() ) {
166
-
167
- $settings['astra-sites'] = array(
168
- 'name' => '',
169
- 'description' => '',
170
- );
171
-
172
- return $settings;
173
- }
174
-
175
- /**
176
- * Add White Label form
177
- *
178
- * @since 1.0.12
179
- *
180
- * @param array $settings White label setting.
181
- * @return void
182
- */
183
- public static function add_white_lavel_form( $settings = array() ) {
184
-
185
- /* translators: %1$s product name */
186
- $plugin_name = sprintf( __( '%1$s Branding', 'astra-sites' ), ASTRA_SITES_NAME );
187
-
188
- require_once ASTRA_SITES_DIR . 'inc/includes/white-label.php';
189
- }
190
-
191
- /**
192
- * Page Title
193
- *
194
- * @since 1.0.12
195
- *
196
- * @param string $title Page Title.
197
- * @return string Filtered Page Title.
198
- */
199
- function page_title( $title ) {
200
-
201
- if ( is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
202
- $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
203
- if ( ! empty( $astra_sites_name ) ) {
204
- $title = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
205
- }
206
- }
207
-
208
- return $title;
209
- }
210
-
211
- /**
212
- * Is Astra sites White labeled
213
- *
214
- * @since 1.2.13
215
- *
216
- * @return string
217
- */
218
- function is_white_labeled() {
219
- if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
220
- return false;
221
- }
222
-
223
- $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
224
- if ( empty( $astra_sites_name ) ) {
225
- return false;
226
- }
227
-
228
- return true;
229
- }
230
-
231
- }
232
-
233
- /**
234
- * Kicking this off by calling 'get_instance()' method
235
- */
236
- Astra_Sites_White_Label::get_instance();
237
-
238
- endif;
1
+ <?php
2
+ /**
3
+ * Astra Sites White Label
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.12
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
10
+
11
+ /**
12
+ * Astra_Sites_White_Label
13
+ *
14
+ * @since 1.0.12
15
+ */
16
+ class Astra_Sites_White_Label {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.12
22
+ *
23
+ * @var object Class Object.
24
+ * @access private
25
+ */
26
+ private static $instance;
27
+
28
+ /**
29
+ * Member Variable
30
+ *
31
+ * @since 1.0.12
32
+ *
33
+ * @var array branding
34
+ * @access private
35
+ */
36
+ private static $branding;
37
+
38
+ /**
39
+ * Settings
40
+ *
41
+ * @since 1.2.11
42
+ *
43
+ * @var array settings
44
+ *
45
+ * @access private
46
+ */
47
+ private $settings;
48
+
49
+ /**
50
+ * Initiator
51
+ *
52
+ * @since 1.0.12
53
+ *
54
+ * @return object initialized object of class.
55
+ */
56
+ public static function get_instance() {
57
+ if ( ! isset( self::$instance ) ) {
58
+ self::$instance = new self;
59
+ }
60
+ return self::$instance;
61
+ }
62
+
63
+ /**
64
+ * Constructor
65
+ *
66
+ * @since 1.0.12
67
+ */
68
+ public function __construct() {
69
+ add_filter( 'all_plugins', array( $this, 'plugins_page' ) );
70
+ add_filter( 'astra_addon_branding_options', __CLASS__ . '::settings' );
71
+ add_action( 'astra_pro_white_label_add_form', __CLASS__ . '::add_white_lavel_form' );
72
+ add_filter( 'astra_sites_menu_page_title', array( $this, 'page_title' ) );
73
+
74
+ // Display the link with the plugin meta.
75
+ if ( is_admin() ) {
76
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 4 );
77
+ }
78
+ }
79
+
80
+ /**
81
+ * White labels the plugins page.
82
+ *
83
+ * @since 1.0.12
84
+ *
85
+ * @param array $plugins Plugins Array.
86
+ * @return array
87
+ */
88
+ function plugins_page( $plugins ) {
89
+
90
+ if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
91
+ return $plugins;
92
+ }
93
+
94
+ if ( ! isset( $plugins[ ASTRA_SITES_BASE ] ) ) {
95
+ return $plugins;
96
+ }
97
+
98
+ // Set White Labels.
99
+ $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
100
+ $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
101
+ $author = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author' );
102
+ $author_uri = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author_url' );
103
+
104
+ if ( ! empty( $name ) ) {
105
+ $plugins[ ASTRA_SITES_BASE ]['Name'] = $name;
106
+
107
+ // Remove Plugin URI if Agency White Label name is set.
108
+ $plugins[ ASTRA_SITES_BASE ]['PluginURI'] = '';
109
+ }
110
+
111
+ if ( ! empty( $description ) ) {
112
+ $plugins[ ASTRA_SITES_BASE ]['Description'] = $description;
113
+ }
114
+
115
+ if ( ! empty( $author ) ) {
116
+ $plugins[ ASTRA_SITES_BASE ]['Author'] = $author;
117
+ }
118
+
119
+ if ( ! empty( $author_uri ) ) {
120
+ $plugins[ ASTRA_SITES_BASE ]['AuthorURI'] = $author_uri;
121
+ }
122
+
123
+ return $plugins;
124
+ }
125
+
126
+ /**
127
+ * Remove a "view details" link from the plugin list table
128
+ *
129
+ * @since 1.0.12
130
+ *
131
+ * @param array $plugin_meta List of links.
132
+ * @param string $plugin_file Relative path to the main plugin file from the plugins directory.
133
+ * @param array $plugin_data Data from the plugin headers.
134
+ * @return array
135
+ */
136
+ public function plugin_links( $plugin_meta, $plugin_file, $plugin_data ) {
137
+
138
+ if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
139
+ return $plugin_meta;
140
+ }
141
+
142
+ // Set White Labels.
143
+ if ( ASTRA_SITES_BASE == $plugin_file ) {
144
+
145
+ $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
146
+ $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
147
+
148
+ // Remove Plugin URI if Agency White Label name is set.
149
+ if ( ! empty( $name ) ) {
150
+ unset( $plugin_meta[2] );
151
+ }
152
+ }
153
+
154
+ return $plugin_meta;
155
+ }
156
+
157
+ /**
158
+ * Add White Label setting's
159
+ *
160
+ * @since 1.0.12
161
+ *
162
+ * @param array $settings White label setting.
163
+ * @return array
164
+ */
165
+ public static function settings( $settings = array() ) {
166
+
167
+ $settings['astra-sites'] = array(
168
+ 'name' => '',
169
+ 'description' => '',
170
+ );
171
+
172
+ return $settings;
173
+ }
174
+
175
+ /**
176
+ * Add White Label form
177
+ *
178
+ * @since 1.0.12
179
+ *
180
+ * @param array $settings White label setting.
181
+ * @return void
182
+ */
183
+ public static function add_white_lavel_form( $settings = array() ) {
184
+
185
+ /* translators: %1$s product name */
186
+ $plugin_name = sprintf( __( '%1$s Branding', 'astra-sites' ), ASTRA_SITES_NAME );
187
+
188
+ require_once ASTRA_SITES_DIR . 'inc/includes/white-label.php';
189
+ }
190
+
191
+ /**
192
+ * Page Title
193
+ *
194
+ * @since 1.0.12
195
+ *
196
+ * @param string $title Page Title.
197
+ * @return string Filtered Page Title.
198
+ */
199
+ function page_title( $title ) {
200
+
201
+ if ( is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
202
+ $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
203
+ if ( ! empty( $astra_sites_name ) ) {
204
+ $title = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
205
+ }
206
+ }
207
+
208
+ return $title;
209
+ }
210
+
211
+ /**
212
+ * Is Astra sites White labeled
213
+ *
214
+ * @since 1.2.13
215
+ *
216
+ * @return string
217
+ */
218
+ function is_white_labeled() {
219
+ if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
220
+ return false;
221
+ }
222
+
223
+ $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
224
+ if ( empty( $astra_sites_name ) ) {
225
+ return false;
226
+ }
227
+
228
+ return true;
229
+ }
230
+
231
+ }
232
+
233
+ /**
234
+ * Kicking this off by calling 'get_instance()' method
235
+ */
236
+ Astra_Sites_White_Label::get_instance();
237
+
238
+ endif;
inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php CHANGED
@@ -1,302 +1,302 @@
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 get_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
- add_action( 'astra_sites_import_start', array( $this, 'import_enabled_extension' ), 10, 2 );
50
- add_action( 'astra_sites_import_complete', array( $this, 'clear_cache' ) );
51
- }
52
-
53
- /**
54
- * Import
55
- *
56
- * @since 1.1.6
57
- * @return void
58
- */
59
- public function import() {
60
- Astra_Sites_Image_Importer::log( '---- Processing Mapping - for Astra Pro ----' );
61
-
62
- self::start_post_mapping();
63
- }
64
-
65
- /**
66
- * Update Site Origin Active Widgets
67
- *
68
- * @since 1.0.0
69
- *
70
- * @param string $plugin_init Plugin init file.
71
- * @param array $data Data.
72
- * @return void
73
- */
74
- function astra_pro( $plugin_init = '', $data = array() ) {
75
-
76
- if ( 'astra-addon/astra-addon.php' === $plugin_init ) {
77
-
78
- $data = json_decode( json_encode( $data ), true );
79
-
80
- if ( isset( $data['enabled_extensions'] ) ) {
81
- $extensions = $data['enabled_extensions'];
82
-
83
- if ( ! empty( $extensions ) ) {
84
- if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
85
- Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $extensions );
86
- }
87
- }
88
- }
89
- }
90
- }
91
-
92
- /**
93
- * Import custom 404 section.
94
- *
95
- * @since 1.0.0
96
- * @param array $demo_data Site all data render from API call.
97
- * @param array $demo_api_uri Demo URL.
98
- */
99
- public function import_custom_404( $demo_data = array(), $demo_api_uri = '' ) {
100
-
101
- if ( isset( $demo_data['astra-custom-404'] ) ) {
102
- if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
103
- $options_404 = $demo_data['astra-custom-404'];
104
- Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_custom_404', $options_404 );
105
- }
106
- }
107
- }
108
-
109
- /**
110
- * Import settings enabled Astra extensions from the demo.
111
- *
112
- * @since 1.0.0
113
- * @param array $demo_data Site all data render from API call.
114
- * @param array $demo_api_uri Demo URL.
115
- */
116
- public function import_enabled_extension( $demo_data = array(), $demo_api_uri = '' ) {
117
-
118
- if ( isset( $demo_data['astra-enabled-extensions'] ) ) {
119
- if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
120
- Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $demo_data['astra-enabled-extensions'] );
121
- }
122
- }
123
- }
124
-
125
- /**
126
- * Start post meta mapping of Astra Addon
127
- *
128
- * @since 1.1.6
129
- *
130
- * @return null If there is no import option data found.
131
- */
132
- public static function start_post_mapping() {
133
- $demo_data = get_option( 'astra_sites_import_data', array() );
134
- if ( ! isset( $demo_data['astra-post-data-mapping'] ) ) {
135
- return;
136
- }
137
-
138
- $post_type = 'astra-advanced-hook';
139
- $posts = ( isset( $demo_data['astra-post-data-mapping'][ $post_type ] ) ) ? $demo_data['astra-post-data-mapping'][ $post_type ] : array();
140
- if ( ! empty( $posts ) ) {
141
- foreach ( $posts as $key => $post ) {
142
- $page = get_page_by_title( $post['post_title'], OBJECT, $post_type );
143
- if ( is_object( $page ) ) {
144
- self::update_location_rules( $page->ID, 'ast-advanced-hook-location', $post['mapping']['ast-advanced-hook-location'] );
145
- }
146
- }
147
- }
148
-
149
- $post_type = 'astra_adv_header';
150
- $posts = ( isset( $demo_data['astra-post-data-mapping'][ $post_type ] ) ) ? $demo_data['astra-post-data-mapping'][ $post_type ] : array();
151
- if ( ! empty( $posts ) ) {
152
- foreach ( $posts as $key => $post ) {
153
- $page = get_page_by_title( $post['post_title'], OBJECT, $post_type );
154
- if ( is_object( $page ) ) {
155
-
156
- self::update_location_rules( $page->ID, 'ast-advanced-headers-location', $post['mapping']['ast-advanced-headers-location'] );
157
- self::update_location_rules( $page->ID, 'ast-advanced-headers-exclusion', $post['mapping']['ast-advanced-headers-exclusion'] );
158
- self::update_header_mapping( $page->ID, 'ast-advanced-headers-design', $post['mapping']['ast-advanced-headers-design'] );
159
- }
160
- }
161
- }
162
- }
163
-
164
- /**
165
- * Update Header Mapping Data
166
- *
167
- * @since 1.1.6
168
- *
169
- * @param int $post_id Post ID.
170
- * @param string $meta_key Post meta key.
171
- * @param array $mapping Mapping array.
172
- * @return void
173
- */
174
- public static function update_header_mapping( $post_id = '', $meta_key = '', $mapping = array() ) {
175
- Astra_Sites_Image_Importer::log( 'Mapping "' . $meta_key . '" for ' . $post_id );
176
-
177
- $headers_old = get_post_meta( $post_id, $meta_key, true );
178
- $headers_new = self::get_header_mapping( $headers_old, $mapping );
179
- update_post_meta( $post_id, $meta_key, $headers_new );
180
- }
181
-
182
- /**
183
- * Update Location Rules
184
- *
185
- * @since 1.1.6
186
- *
187
- * @param int $post_id Post ID.
188
- * @param string $meta_key Post meta key.
189
- * @param array $mapping Mapping array.
190
- * @return void
191
- */
192
- public static function update_location_rules( $post_id = '', $meta_key = '', $mapping = array() ) {
193
- Astra_Sites_Image_Importer::log( 'Mapping "' . $meta_key . '" for ' . $post_id );
194
-
195
- $location_new = self::get_location_mappings( $mapping );
196
- update_post_meta( $post_id, $meta_key, $location_new );
197
- }
198
-
199
- /**
200
- * Get mapping locations.
201
- *
202
- * @since 1.1.6
203
- *
204
- * @param array $location Location data.
205
- * @return array Location mapping data.
206
- */
207
- public static function get_location_mappings( $location = array() ) {
208
- if ( empty( $location ) ) {
209
- return $location;
210
- }
211
-
212
- if ( ! isset( $location['specific'] ) || empty( $location['specific'] ) ) {
213
- return $location;
214
- }
215
-
216
- $mapping = array();
217
-
218
- if ( isset( $location['specific']['post'] ) ) {
219
- foreach ( $location['specific']['post'] as $post_type => $old_post_data ) {
220
- if ( is_array( $old_post_data ) ) {
221
- foreach ( $old_post_data as $post_key => $post ) {
222
- if ( $post_object = get_page_by_path( $post['slug'] ) ) {
223
- $mapping[] = 'post-' . absint( $post_object->ID );
224
- }
225
- }
226
- }
227
- }
228
- }
229
-
230
- if ( isset( $location['specific']['tax'] ) ) {
231
- foreach ( $location['specific']['tax'] as $taxonomy_type => $old_term_data ) {
232
- if ( is_array( $old_term_data ) ) {
233
- foreach ( $old_term_data as $term_key => $term_data ) {
234
- $term = get_term_by( 'slug', $term_data['slug'], $taxonomy_type );
235
- if ( is_object( $term ) ) {
236
- $mapping[] = 'tax-' . absint( $term->term_id );
237
- }
238
- }
239
- }
240
- }
241
- }
242
-
243
- $location['specific'] = $mapping;
244
-
245
- return $location;
246
- }
247
-
248
- /**
249
- * Get advanced header mapping data
250
- *
251
- * @since 1.1.6
252
- *
253
- * @param array $headers_old Header mapping stored data.
254
- * @param array $headers_data Header mapping data.
255
- * @return array Filtered header mapping data.
256
- */
257
- public static function get_header_mapping( $headers_old = array(), $headers_data = array() ) {
258
-
259
- // Set menu location by menu slug.
260
- if ( isset( $headers_data['menus'] ) && ! empty( $headers_data['menus'] ) ) {
261
- foreach ( $headers_data['menus'] as $header_option_name => $menu_data ) {
262
- $term = get_term_by( 'slug', $menu_data['slug'], 'nav_menu' );
263
- if ( is_object( $term ) ) {
264
- $headers_old[ $header_option_name ] = $term->term_id;
265
- }
266
- }
267
- }
268
-
269
- // Set image ID & URL after importing these on website.
270
- if ( isset( $headers_data['images'] ) && ! empty( $headers_data['images'] ) ) {
271
- foreach ( $headers_data['images'] as $key => $image_data ) {
272
- if ( isset( $image_data['image'] ) && ! empty( $image_data['image'] ) ) {
273
- $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image_data['image'] );
274
-
275
- $headers_old[ $image_data['key_map']['url'] ] = $downloaded_image['url'];
276
- $headers_old[ $image_data['key_map']['id'] ] = $downloaded_image['id'];
277
- }
278
- }
279
- }
280
-
281
- return $headers_old;
282
- }
283
-
284
- /**
285
- * Clear Cache
286
- *
287
- * @since 1.2.3
288
- * @return void
289
- */
290
- function clear_cache() {
291
- if ( is_callable( 'Astra_Minify::refresh_assets' ) ) {
292
- Astra_Minify::refresh_assets();
293
- }
294
- }
295
- }
296
-
297
- /**
298
- * Kicking this off by calling 'get_instance()' method
299
- */
300
- Astra_Sites_Compatibility_Astra_Pro::get_instance();
301
-
302
- endif;
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 get_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
+ add_action( 'astra_sites_import_start', array( $this, 'import_enabled_extension' ), 10, 2 );
50
+ add_action( 'astra_sites_import_complete', array( $this, 'clear_cache' ) );
51
+ }
52
+
53
+ /**
54
+ * Import
55
+ *
56
+ * @since 1.1.6
57
+ * @return void
58
+ */
59
+ public function import() {
60
+ Astra_Sites_Image_Importer::log( '---- Processing Mapping - for Astra Pro ----' );
61
+
62
+ self::start_post_mapping();
63
+ }
64
+
65
+ /**
66
+ * Update Site Origin Active Widgets
67
+ *
68
+ * @since 1.0.0
69
+ *
70
+ * @param string $plugin_init Plugin init file.
71
+ * @param array $data Data.
72
+ * @return void
73
+ */
74
+ function astra_pro( $plugin_init = '', $data = array() ) {
75
+
76
+ if ( 'astra-addon/astra-addon.php' === $plugin_init ) {
77
+
78
+ $data = json_decode( json_encode( $data ), true );
79
+
80
+ if ( isset( $data['enabled_extensions'] ) ) {
81
+ $extensions = $data['enabled_extensions'];
82
+
83
+ if ( ! empty( $extensions ) ) {
84
+ if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
85
+ Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $extensions );
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Import custom 404 section.
94
+ *
95
+ * @since 1.0.0
96
+ * @param array $demo_data Site all data render from API call.
97
+ * @param array $demo_api_uri Demo URL.
98
+ */
99
+ public function import_custom_404( $demo_data = array(), $demo_api_uri = '' ) {
100
+
101
+ if ( isset( $demo_data['astra-custom-404'] ) ) {
102
+ if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
103
+ $options_404 = $demo_data['astra-custom-404'];
104
+ Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_custom_404', $options_404 );
105
+ }
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Import settings enabled Astra extensions from the demo.
111
+ *
112
+ * @since 1.0.0
113
+ * @param array $demo_data Site all data render from API call.
114
+ * @param array $demo_api_uri Demo URL.
115
+ */
116
+ public function import_enabled_extension( $demo_data = array(), $demo_api_uri = '' ) {
117
+
118
+ if ( isset( $demo_data['astra-enabled-extensions'] ) ) {
119
+ if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
120
+ Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $demo_data['astra-enabled-extensions'] );
121
+ }
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Start post meta mapping of Astra Addon
127
+ *
128
+ * @since 1.1.6
129
+ *
130
+ * @return null If there is no import option data found.
131
+ */
132
+ public static function start_post_mapping() {
133
+ $demo_data = get_option( 'astra_sites_import_data', array() );
134
+ if ( ! isset( $demo_data['astra-post-data-mapping'] ) ) {
135
+ return;
136
+ }
137
+
138
+ $post_type = 'astra-advanced-hook';
139
+ $posts = ( isset( $demo_data['astra-post-data-mapping'][ $post_type ] ) ) ? $demo_data['astra-post-data-mapping'][ $post_type ] : array();
140
+ if ( ! empty( $posts ) ) {
141
+ foreach ( $posts as $key => $post ) {
142
+ $page = get_page_by_title( $post['post_title'], OBJECT, $post_type );
143
+ if ( is_object( $page ) ) {
144
+ self::update_location_rules( $page->ID, 'ast-advanced-hook-location', $post['mapping']['ast-advanced-hook-location'] );
145
+ }
146
+ }
147
+ }
148
+
149
+ $post_type = 'astra_adv_header';
150
+ $posts = ( isset( $demo_data['astra-post-data-mapping'][ $post_type ] ) ) ? $demo_data['astra-post-data-mapping'][ $post_type ] : array();
151
+ if ( ! empty( $posts ) ) {
152
+ foreach ( $posts as $key => $post ) {
153
+ $page = get_page_by_title( $post['post_title'], OBJECT, $post_type );
154
+ if ( is_object( $page ) ) {
155
+
156
+ self::update_location_rules( $page->ID, 'ast-advanced-headers-location', $post['mapping']['ast-advanced-headers-location'] );
157
+ self::update_location_rules( $page->ID, 'ast-advanced-headers-exclusion', $post['mapping']['ast-advanced-headers-exclusion'] );
158
+ self::update_header_mapping( $page->ID, 'ast-advanced-headers-design', $post['mapping']['ast-advanced-headers-design'] );
159
+ }
160
+ }
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Update Header Mapping Data
166
+ *
167
+ * @since 1.1.6
168
+ *
169
+ * @param int $post_id Post ID.
170
+ * @param string $meta_key Post meta key.
171
+ * @param array $mapping Mapping array.
172
+ * @return void
173
+ */
174
+ public static function update_header_mapping( $post_id = '', $meta_key = '', $mapping = array() ) {
175
+ Astra_Sites_Image_Importer::log( 'Mapping "' . $meta_key . '" for ' . $post_id );
176
+
177
+ $headers_old = get_post_meta( $post_id, $meta_key, true );
178
+ $headers_new = self::get_header_mapping( $headers_old, $mapping );
179
+ update_post_meta( $post_id, $meta_key, $headers_new );
180
+ }
181
+
182
+ /**
183
+ * Update Location Rules
184
+ *
185
+ * @since 1.1.6
186
+ *
187
+ * @param int $post_id Post ID.
188
+ * @param string $meta_key Post meta key.
189
+ * @param array $mapping Mapping array.
190
+ * @return void
191
+ */
192
+ public static function update_location_rules( $post_id = '', $meta_key = '', $mapping = array() ) {
193
+ Astra_Sites_Image_Importer::log( 'Mapping "' . $meta_key . '" for ' . $post_id );
194
+
195
+ $location_new = self::get_location_mappings( $mapping );
196
+ update_post_meta( $post_id, $meta_key, $location_new );
197
+ }
198
+
199
+ /**
200
+ * Get mapping locations.
201
+ *
202
+ * @since 1.1.6
203
+ *
204
+ * @param array $location Location data.
205
+ * @return array Location mapping data.
206
+ */
207
+ public static function get_location_mappings( $location = array() ) {
208
+ if ( empty( $location ) ) {
209
+ return $location;
210
+ }
211
+
212
+ if ( ! isset( $location['specific'] ) || empty( $location['specific'] ) ) {
213
+ return $location;
214
+ }
215
+
216
+ $mapping = array();
217
+
218
+ if ( isset( $location['specific']['post'] ) ) {
219
+ foreach ( $location['specific']['post'] as $post_type => $old_post_data ) {
220
+ if ( is_array( $old_post_data ) ) {
221
+ foreach ( $old_post_data as $post_key => $post ) {
222
+ if ( $post_object = get_page_by_path( $post['slug'] ) ) {
223
+ $mapping[] = 'post-' . absint( $post_object->ID );
224
+ }
225
+ }
226
+ }
227
+ }
228
+ }
229
+
230
+ if ( isset( $location['specific']['tax'] ) ) {
231
+ foreach ( $location['specific']['tax'] as $taxonomy_type => $old_term_data ) {
232
+ if ( is_array( $old_term_data ) ) {
233
+ foreach ( $old_term_data as $term_key => $term_data ) {
234
+ $term = get_term_by( 'slug', $term_data['slug'], $taxonomy_type );
235
+ if ( is_object( $term ) ) {
236
+ $mapping[] = 'tax-' . absint( $term->term_id );
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ $location['specific'] = $mapping;
244
+
245
+ return $location;
246
+ }
247
+
248
+ /**
249
+ * Get advanced header mapping data
250
+ *
251
+ * @since 1.1.6
252
+ *
253
+ * @param array $headers_old Header mapping stored data.
254
+ * @param array $headers_data Header mapping data.
255
+ * @return array Filtered header mapping data.
256
+ */
257
+ public static function get_header_mapping( $headers_old = array(), $headers_data = array() ) {
258
+
259
+ // Set menu location by menu slug.
260
+ if ( isset( $headers_data['menus'] ) && ! empty( $headers_data['menus'] ) ) {
261
+ foreach ( $headers_data['menus'] as $header_option_name => $menu_data ) {
262
+ $term = get_term_by( 'slug', $menu_data['slug'], 'nav_menu' );
263
+ if ( is_object( $term ) ) {
264
+ $headers_old[ $header_option_name ] = $term->term_id;
265
+ }
266
+ }
267
+ }
268
+
269
+ // Set image ID & URL after importing these on website.
270
+ if ( isset( $headers_data['images'] ) && ! empty( $headers_data['images'] ) ) {
271
+ foreach ( $headers_data['images'] as $key => $image_data ) {
272
+ if ( isset( $image_data['image'] ) && ! empty( $image_data['image'] ) ) {
273
+ $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image_data['image'] );
274
+
275
+ $headers_old[ $image_data['key_map']['url'] ] = $downloaded_image['url'];
276
+ $headers_old[ $image_data['key_map']['id'] ] = $downloaded_image['id'];
277
+ }
278
+ }
279
+ }
280
+
281
+ return $headers_old;
282
+ }
283
+
284
+ /**
285
+ * Clear Cache
286
+ *
287
+ * @since 1.2.3
288
+ * @return void
289
+ */
290
+ function clear_cache() {
291
+ if ( is_callable( 'Astra_Minify::refresh_assets' ) ) {
292
+ Astra_Minify::refresh_assets();
293
+ }
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Kicking this off by calling 'get_instance()' method
299
+ */
300
+ Astra_Sites_Compatibility_Astra_Pro::get_instance();
301
+
302
+ endif;
inc/classes/compatibility/class-astra-sites-compatibility.php CHANGED
@@ -1,66 +1,66 @@
1
- <?php
2
- /**
3
- * Astra Sites Compatibility for 3rd party plugins.
4
- *
5
- * @package Astra Sites
6
- * @since 1.0.11
7
- */
8
-
9
- if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
10
-
11
- /**
12
- * Astra Sites Compatibility
13
- *
14
- * @since 1.0.11
15
- */
16
- class Astra_Sites_Compatibility {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @access private
22
- * @var object Class object.
23
- * @since 1.0.11
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Initiator
29
- *
30
- * @since 1.0.11
31
- * @return object initialized object of class.
32
- */
33
- public static function instance() {
34
- if ( ! isset( self::$instance ) ) {
35
- self::$instance = new self;
36
- }
37
- return self::$instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- *
43
- * @since 1.0.11
44
- */
45
- public function __construct() {
46
-
47
- // Plugin - Astra Pro.
48
- require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php';
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
-
59
- /**
60
- * Kicking this off by calling 'instance()' method
61
- */
62
- Astra_Sites_Compatibility::instance();
63
-
64
- endif;
65
-
66
-
1
+ <?php
2
+ /**
3
+ * Astra Sites Compatibility for 3rd party plugins.
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.11
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
10
+
11
+ /**
12
+ * Astra Sites Compatibility
13
+ *
14
+ * @since 1.0.11
15
+ */
16
+ class Astra_Sites_Compatibility {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @access private
22
+ * @var object Class object.
23
+ * @since 1.0.11
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.0.11
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function instance() {
34
+ if ( ! isset( self::$instance ) ) {
35
+ self::$instance = new self;
36
+ }
37
+ return self::$instance;
38
+ }
39
+
40
+ /**
41
+ * Constructor
42
+ *
43
+ * @since 1.0.11
44
+ */
45
+ public function __construct() {
46
+
47
+ // Plugin - Astra Pro.
48
+ require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php';
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
+
59
+ /**
60
+ * Kicking this off by calling 'instance()' method
61
+ */
62
+ Astra_Sites_Compatibility::instance();
63
+
64
+ endif;
65
+
66
+
inc/importers/batch-processing/class-astra-sites-batch-processing-gutenberg.php CHANGED
@@ -1,146 +1,146 @@
1
- <?php
2
- /**
3
- * Batch Processing
4
- *
5
- * @package Astra Sites
6
- * @since 1.2.14
7
- */
8
-
9
- if ( ! class_exists( 'Astra_Sites_Batch_Processing_Gutenberg' ) ) :
10
-
11
- /**
12
- * Astra Sites Batch Processing Brizy
13
- *
14
- * @since 1.2.14
15
- */
16
- class Astra_Sites_Batch_Processing_Gutenberg {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.2.14
22
- * @access private
23
- * @var object Class object.
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Initiator
29
- *
30
- * @since 1.2.14
31
- * @return object initialized object of class.
32
- */
33
- public static function get_instance() {
34
-
35
- if ( ! isset( self::$instance ) ) {
36
- self::$instance = new self;
37
- }
38
- return self::$instance;
39
- }
40
-
41
- /**
42
- * Constructor
43
- *
44
- * @since 1.2.14
45
- */
46
- public function __construct() {}
47
-
48
- /**
49
- * Allowed tags for the batch update process.
50
- *
51
- * @param array $allowedposttags Array of default allowable HTML tags.
52
- * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
53
- * 'strip', 'data', 'entities', or the name of a field filter such as
54
- * 'pre_user_description'.
55
- * @return array Array of allowed HTML tags and their allowed attributes.
56
- */
57
- function allowed_tags_and_attributes( $allowedposttags, $context ) {
58
-
59
- // Keep only for 'post' contenxt.
60
- if ( 'post' === $context ) {
61
-
62
- // <svg> tag and attributes.
63
- $allowedposttags['svg'] = array(
64
- 'xmlns' => true,
65
- 'viewbox' => true,
66
- );
67
-
68
- // <path> tag and attributes.
69
- $allowedposttags['path'] = array(
70
- 'd' => true,
71
- );
72
- }
73
-
74
- return $allowedposttags;
75
- }
76
-
77
- /**
78
- * Import
79
- *
80
- * @since 1.2.14
81
- * @return void
82
- */
83
- public function import() {
84
-
85
- // Allow the SVG tags in batch update process.
86
- add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 );
87
-
88
- Astra_Sites_Image_Importer::log( '---- Processing WordPress Posts / Pages - for "Gutenberg" ----' );
89
-
90
- $post_ids = Astra_Sites_Batch_Processing::get_pages( array( 'page' ) );
91
- if ( empty( $post_ids ) && ! is_array( $post_ids ) ) {
92
- return;
93
- }
94
-
95
- foreach ( $post_ids as $post_id ) {
96
- $this->import_single_post( $post_id );
97
- }
98
- }
99
-
100
- /**
101
- * Update post meta.
102
- *
103
- * @param integer $post_id Post ID.
104
- * @return void
105
- */
106
- public function import_single_post( $post_id = 0 ) {
107
-
108
- $ids_mapping = get_option( 'astra_sites_wpforms_ids_mapping', array() );
109
-
110
- // Empty mapping? Then return.
111
- if ( empty( $ids_mapping ) ) {
112
- return;
113
- }
114
-
115
- // Post content.
116
- $content = get_post_field( 'post_content', $post_id );
117
-
118
- // Replace ID's.
119
- foreach ( $ids_mapping as $old_id => $new_id ) {
120
- $content = str_replace( '[wpforms id="' . $old_id, '[wpforms id="' . $new_id, $content );
121
- }
122
-
123
- // # Tweak
124
- // Gutenberg break block markup from render. Because the '&' is updated in database with '&amp;' and it
125
- // expects as 'u0026amp;'. So, Converted '&amp;' with 'u0026amp;'.
126
- //
127
- // @todo This affect for normal page content too. Detect only Gutenberg pages and process only on it.
128
- $content = str_replace( '&amp;', 'u0026amp;', $content );
129
-
130
- // Update content.
131
- wp_update_post(
132
- array(
133
- 'ID' => $post_id,
134
- 'post_content' => $content,
135
- )
136
- );
137
- }
138
-
139
- }
140
-
141
- /**
142
- * Kicking this off by calling 'get_instance()' method
143
- */
144
- Astra_Sites_Batch_Processing_Gutenberg::get_instance();
145
-
146
- endif;
1
+ <?php
2
+ /**
3
+ * Batch Processing
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.2.14
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Batch_Processing_Gutenberg' ) ) :
10
+
11
+ /**
12
+ * Astra Sites Batch Processing Brizy
13
+ *
14
+ * @since 1.2.14
15
+ */
16
+ class Astra_Sites_Batch_Processing_Gutenberg {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.2.14
22
+ * @access private
23
+ * @var object Class object.
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.2.14
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function get_instance() {
34
+
35
+ if ( ! isset( self::$instance ) ) {
36
+ self::$instance = new self;
37
+ }
38
+ return self::$instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ *
44
+ * @since 1.2.14
45
+ */
46
+ public function __construct() {}
47
+
48
+ /**
49
+ * Allowed tags for the batch update process.
50
+ *
51
+ * @param array $allowedposttags Array of default allowable HTML tags.
52
+ * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
53
+ * 'strip', 'data', 'entities', or the name of a field filter such as
54
+ * 'pre_user_description'.
55
+ * @return array Array of allowed HTML tags and their allowed attributes.
56
+ */
57
+ function allowed_tags_and_attributes( $allowedposttags, $context ) {
58
+
59
+ // Keep only for 'post' contenxt.
60
+ if ( 'post' === $context ) {
61
+
62
+ // <svg> tag and attributes.
63
+ $allowedposttags['svg'] = array(
64
+ 'xmlns' => true,
65
+ 'viewbox' => true,
66
+ );
67
+
68
+ // <path> tag and attributes.
69
+ $allowedposttags['path'] = array(
70
+ 'd' => true,
71
+ );
72
+ }
73
+
74
+ return $allowedposttags;
75
+ }
76
+
77
+ /**
78
+ * Import
79
+ *
80
+ * @since 1.2.14
81
+ * @return void
82
+ */
83
+ public function import() {
84
+
85
+ // Allow the SVG tags in batch update process.
86
+ add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 );
87
+
88
+ Astra_Sites_Image_Importer::log( '---- Processing WordPress Posts / Pages - for "Gutenberg" ----' );
89
+
90
+ $post_ids = Astra_Sites_Batch_Processing::get_pages( array( 'page' ) );
91
+ if ( empty( $post_ids ) && ! is_array( $post_ids ) ) {
92
+ return;
93
+ }
94
+
95
+ foreach ( $post_ids as $post_id ) {
96
+ $this->import_single_post( $post_id );
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Update post meta.
102
+ *
103
+ * @param integer $post_id Post ID.
104
+ * @return void
105
+ */
106
+ public function import_single_post( $post_id = 0 ) {
107
+
108
+ $ids_mapping = get_option( 'astra_sites_wpforms_ids_mapping', array() );
109
+
110
+ // Empty mapping? Then return.
111
+ if ( empty( $ids_mapping ) ) {
112
+ return;
113
+ }
114
+
115
+ // Post content.
116
+ $content = get_post_field( 'post_content', $post_id );
117
+
118
+ // Replace ID's.
119
+ foreach ( $ids_mapping as $old_id => $new_id ) {
120
+ $content = str_replace( '[wpforms id="' . $old_id, '[wpforms id="' . $new_id, $content );
121
+ }
122
+
123
+ // # Tweak
124
+ // Gutenberg break block markup from render. Because the '&' is updated in database with '&amp;' and it
125
+ // expects as 'u0026amp;'. So, Converted '&amp;' with 'u0026amp;'.
126
+ //
127
+ // @todo This affect for normal page content too. Detect only Gutenberg pages and process only on it.
128
+ $content = str_replace( '&amp;', 'u0026amp;', $content );
129
+
130
+ // Update content.
131
+ wp_update_post(
132
+ array(
133
+ 'ID' => $post_id,
134
+ 'post_content' => $content,
135
+ )
136
+ );
137
+ }
138
+
139
+ }
140
+
141
+ /**
142
+ * Kicking this off by calling 'get_instance()' method
143
+ */
144
+ Astra_Sites_Batch_Processing_Gutenberg::get_instance();
145
+
146
+ endif;
inc/importers/batch-processing/class-astra-sites-batch-processing-widgets.php CHANGED
@@ -1,98 +1,98 @@
1
- <?php
2
- /**
3
- * Batch Processing
4
- *
5
- * @package Astra Sites
6
- * @since 1.0.14
7
- */
8
-
9
- if ( ! class_exists( 'Astra_Sites_Batch_Processing_Widgets' ) ) :
10
-
11
- /**
12
- * Astra_Sites_Batch_Processing_Widgets
13
- *
14
- * @since 1.0.14
15
- */
16
- class Astra_Sites_Batch_Processing_Widgets {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.0.14
22
- * @access private
23
- * @var object Class object.
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Initiator
29
- *
30
- * @since 1.0.14
31
- * @return object initialized object of class.
32
- */
33
- public static function get_instance() {
34
- if ( ! isset( self::$instance ) ) {
35
- self::$instance = new self;
36
- }
37
- return self::$instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- *
43
- * @since 1.0.14
44
- */
45
- public function __construct() {
46
- }
47
-
48
- /**
49
- * Import
50
- *
51
- * @since 1.0.14
52
- * @return void
53
- */
54
- public function import() {
55
- $this->widget_media_image();
56
- }
57
-
58
- /**
59
- * Widget Media Image
60
- *
61
- * @since 1.0.14
62
- * @return void
63
- */
64
- public function widget_media_image() {
65
-
66
- $data = get_option( 'widget_media_image', null );
67
-
68
- Astra_Sites_Image_Importer::log( '---- Processing Images from Widgets -----' );
69
-
70
- foreach ( $data as $key => $value ) {
71
-
72
- if (
73
- isset( $value['url'] ) &&
74
- isset( $value['attachment_id'] )
75
- ) {
76
-
77
- $image = array(
78
- 'url' => $value['url'],
79
- 'id' => $value['attachment_id'],
80
- );
81
-
82
- $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
83
-
84
- $data[ $key ]['url'] = $downloaded_image['url'];
85
- $data[ $key ]['attachment_id'] = $downloaded_image['id'];
86
- }
87
- }
88
-
89
- update_option( 'widget_media_image', $data );
90
- }
91
- }
92
-
93
- /**
94
- * Kicking this off by calling 'get_instance()' method
95
- */
96
- Astra_Sites_Batch_Processing_Widgets::get_instance();
97
-
98
- endif;
1
+ <?php
2
+ /**
3
+ * Batch Processing
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.14
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Batch_Processing_Widgets' ) ) :
10
+
11
+ /**
12
+ * Astra_Sites_Batch_Processing_Widgets
13
+ *
14
+ * @since 1.0.14
15
+ */
16
+ class Astra_Sites_Batch_Processing_Widgets {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.14
22
+ * @access private
23
+ * @var object Class object.
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.0.14
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function get_instance() {
34
+ if ( ! isset( self::$instance ) ) {
35
+ self::$instance = new self;
36
+ }
37
+ return self::$instance;
38
+ }
39
+
40
+ /**
41
+ * Constructor
42
+ *
43
+ * @since 1.0.14
44
+ */
45
+ public function __construct() {
46
+ }
47
+
48
+ /**
49
+ * Import
50
+ *
51
+ * @since 1.0.14
52
+ * @return void
53
+ */
54
+ public function import() {
55
+ $this->widget_media_image();
56
+ }
57
+
58
+ /**
59
+ * Widget Media Image
60
+ *
61
+ * @since 1.0.14
62
+ * @return void
63
+ */
64
+ public function widget_media_image() {
65
+
66
+ $data = get_option( 'widget_media_image', null );
67
+
68
+ Astra_Sites_Image_Importer::log( '---- Processing Images from Widgets -----' );
69
+
70
+ foreach ( $data as $key => $value ) {
71
+
72
+ if (
73
+ isset( $value['url'] ) &&
74
+ isset( $value['attachment_id'] )
75
+ ) {
76
+
77
+ $image = array(
78
+ 'url' => $value['url'],
79
+ 'id' => $value['attachment_id'],
80
+ );
81
+
82
+ $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
83
+
84
+ $data[ $key ]['url'] = $downloaded_image['url'];
85
+ $data[ $key ]['attachment_id'] = $downloaded_image['id'];
86
+ }
87
+ }
88
+
89
+ update_option( 'widget_media_image', $data );
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Kicking this off by calling 'get_instance()' method
95
+ */
96
+ Astra_Sites_Batch_Processing_Widgets::get_instance();
97
+
98
+ endif;
inc/importers/batch-processing/helpers/class-astra-sites-image-importer.php CHANGED
@@ -1,280 +1,280 @@
1
- <?php
2
- /**
3
- * Image Importer
4
- *
5
- * => How to use?
6
- *
7
- * $image = array(
8
- * 'url' => '<image-url>',
9
- * 'id' => '<image-id>',
10
- * );
11
- *
12
- * $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
13
- *
14
- * @package Astra Sites
15
- * @since 1.0.14
16
- */
17
-
18
- if ( ! class_exists( 'Astra_Sites_Image_Importer' ) ) :
19
-
20
- /**
21
- * Astra Sites Image Importer
22
- *
23
- * @since 1.0.14
24
- */
25
- class Astra_Sites_Image_Importer {
26
-
27
- /**
28
- * Instance
29
- *
30
- * @since 1.0.14
31
- * @var object Class object.
32
- * @access private
33
- */
34
- private static $instance;
35
-
36
- /**
37
- * Images IDs
38
- *
39
- * @var array The Array of already image IDs.
40
- * @since 1.0.14
41
- */
42
- private $already_imported_ids = array();
43
-
44
- /**
45
- * Initiator
46
- *
47
- * @since 1.0.14
48
- * @return object initialized object of class.
49
- */
50
- public static function get_instance() {
51
- if ( ! isset( self::$instance ) ) {
52
- self::$instance = new self;
53
- }
54
- return self::$instance;
55
- }
56
-
57
- /**
58
- * Constructor
59
- *
60
- * @since 1.0.14
61
- */
62
- public function __construct() {
63
-
64
- if ( ! function_exists( 'WP_Filesystem' ) ) {
65
- require_once ABSPATH . 'wp-admin/includes/file.php';
66
- }
67
-
68
- WP_Filesystem();
69
- }
70
-
71
- /**
72
- * Process Image Download
73
- *
74
- * @since 1.0.14
75
- * @param array $attachments Attachment array.
76
- * @return array Attachment array.
77
- */
78
- public function process( $attachments ) {
79
-
80
- $downloaded_images = array();
81
-
82
- foreach ( $attachments as $key => $attachment ) {
83
- $downloaded_images[] = $this->import( $attachment );
84
- }
85
-
86
- return $downloaded_images;
87
- }
88
-
89
- /**
90
- * Get Hash Image.
91
- *
92
- * @since 1.0.14
93
- * @param string $attachment_url Attachment URL.
94
- * @return string Hash string.
95
- */
96
- private function get_hash_image( $attachment_url ) {
97
- return sha1( $attachment_url );
98
- }
99
-
100
- /**
101
- * Get Saved Image.
102
- *
103
- * @since 1.0.14
104
- * @param string $attachment Attachment Data.
105
- * @return string Hash string.
106
- */
107
- private function get_saved_image( $attachment ) {
108
-
109
- if ( apply_filters( 'astra_sites_image_importer_skip_image', false, $attachment ) ) {
110
-
111
- Astra_Sites_Image_Importer::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
112
-
113
- return $attachment;
114
- }
115
-
116
- global $wpdb;
117
-
118
- // Already imported? Then return!
119
- if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
120
-
121
- Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
122
-
123
- return $this->already_imported_ids[ $attachment['id'] ];
124
- }
125
-
126
- // 1. Is already imported in Batch Import Process?
127
- $post_id = $wpdb->get_var(
128
- $wpdb->prepare(
129
- 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
130
- WHERE `meta_key` = \'_astra_sites_image_hash\'
131
- AND `meta_value` = %s
132
- ;',
133
- $this->get_hash_image( $attachment['url'] )
134
- )
135
- );
136
-
137
- // 2. Is image already imported though XML?
138
- if ( empty( $post_id ) ) {
139
-
140
- // Get file name without extension.
141
- // To check it exist in attachment.
142
- $filename = basename( $attachment['url'] );
143
-
144
- $post_id = $wpdb->get_var(
145
- $wpdb->prepare(
146
- 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
147
- WHERE `meta_key` = \'_wp_attached_file\'
148
- AND `meta_value` LIKE %s
149
- ;',
150
- '%' . $filename . '%'
151
- )
152
- );
153
-
154
- $post_id = $wpdb->get_var(
155
- $wpdb->prepare(
156
- "SELECT post_id FROM {$wpdb->postmeta}
157
- WHERE meta_key = '_wp_attached_file'
158
- AND meta_value LIKE %s",
159
- '%' . $filename . '%'
160
- )
161
- );
162
-
163
- Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
164
- }
165
-
166
- if ( $post_id ) {
167
- $new_attachment = array(
168
- 'id' => $post_id,
169
- 'url' => wp_get_attachment_url( $post_id ),
170
- );
171
- $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
172
-
173
- return $new_attachment;
174
- }
175
-
176
- return false;
177
- }
178
-
179
- /**
180
- * Import Image
181
- *
182
- * @since 1.0.14
183
- * @param array $attachment Attachment array.
184
- * @return array Attachment array.
185
- */
186
- public function import( $attachment ) {
187
-
188
- $saved_image = $this->get_saved_image( $attachment );
189
- if ( $saved_image ) {
190
- return $saved_image;
191
- }
192
-
193
- $file_content = wp_remote_retrieve_body(
194
- wp_safe_remote_get(
195
- $attachment['url'],
196
- array(
197
- 'timeout' => '60',
198
- 'sslverify' => false,
199
- )
200
- )
201
- );
202
-
203
- // Empty file content?
204
- if ( empty( $file_content ) ) {
205
-
206
- Astra_Sites_Image_Importer::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
207
- Astra_Sites_Image_Importer::log( 'Error: Failed wp_remote_retrieve_body().' );
208
-
209
- return $attachment;
210
- }
211
-
212
- // Extract the file name and extension from the URL.
213
- $filename = basename( $attachment['url'] );
214
-
215
- $upload = wp_upload_bits(
216
- $filename,
217
- null,
218
- $file_content
219
- );
220
-
221
- $post = array(
222
- 'post_title' => $filename,
223
- 'guid' => $upload['url'],
224
- );
225
-
226
- $info = wp_check_filetype( $upload['file'] );
227
- if ( $info ) {
228
- $post['post_mime_type'] = $info['type'];
229
- } else {
230
- // For now just return the origin attachment.
231
- return $attachment;
232
- }
233
-
234
- $post_id = wp_insert_attachment( $post, $upload['file'] );
235
- wp_update_attachment_metadata(
236
- $post_id,
237
- wp_generate_attachment_metadata( $post_id, $upload['file'] )
238
- );
239
- update_post_meta( $post_id, '_astra_sites_image_hash', $this->get_hash_image( $attachment['url'] ) );
240
-
241
- $new_attachment = array(
242
- 'id' => $post_id,
243
- 'url' => $upload['url'],
244
- );
245
-
246
- Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
247
-
248
- $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
249
-
250
- return $new_attachment;
251
- }
252
-
253
- /**
254
- * Debugging Log.
255
- *
256
- * @since 1.0.14
257
- * @param mixed $log Log data.
258
- * @return void
259
- */
260
- public static function log( $log ) {
261
-
262
- if ( ! WP_DEBUG_LOG ) {
263
- return;
264
- }
265
-
266
- if ( is_array( $log ) || is_object( $log ) ) {
267
- error_log( print_r( $log, true ) );
268
- } else {
269
- error_log( $log );
270
- }
271
- }
272
-
273
- }
274
-
275
- /**
276
- * Kicking this off by calling 'get_instance()' method
277
- */
278
- Astra_Sites_Image_Importer::get_instance();
279
-
280
- endif;
1
+ <?php
2
+ /**
3
+ * Image Importer
4
+ *
5
+ * => How to use?
6
+ *
7
+ * $image = array(
8
+ * 'url' => '<image-url>',
9
+ * 'id' => '<image-id>',
10
+ * );
11
+ *
12
+ * $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
13
+ *
14
+ * @package Astra Sites
15
+ * @since 1.0.14
16
+ */
17
+
18
+ if ( ! class_exists( 'Astra_Sites_Image_Importer' ) ) :
19
+
20
+ /**
21
+ * Astra Sites Image Importer
22
+ *
23
+ * @since 1.0.14
24
+ */
25
+ class Astra_Sites_Image_Importer {
26
+
27
+ /**
28
+ * Instance
29
+ *
30
+ * @since 1.0.14
31
+ * @var object Class object.
32
+ * @access private
33
+ */
34
+ private static $instance;
35
+
36
+ /**
37
+ * Images IDs
38
+ *
39
+ * @var array The Array of already image IDs.
40
+ * @since 1.0.14
41
+ */
42
+ private $already_imported_ids = array();
43
+
44
+ /**
45
+ * Initiator
46
+ *
47
+ * @since 1.0.14
48
+ * @return object initialized object of class.
49
+ */
50
+ public static function get_instance() {
51
+ if ( ! isset( self::$instance ) ) {
52
+ self::$instance = new self;
53
+ }
54
+ return self::$instance;
55
+ }
56
+
57
+ /**
58
+ * Constructor
59
+ *
60
+ * @since 1.0.14
61
+ */
62
+ public function __construct() {
63
+
64
+ if ( ! function_exists( 'WP_Filesystem' ) ) {
65
+ require_once ABSPATH . 'wp-admin/includes/file.php';
66
+ }
67
+
68
+ WP_Filesystem();
69
+ }
70
+
71
+ /**
72
+ * Process Image Download
73
+ *
74
+ * @since 1.0.14
75
+ * @param array $attachments Attachment array.
76
+ * @return array Attachment array.
77
+ */
78
+ public function process( $attachments ) {
79
+
80
+ $downloaded_images = array();
81
+
82
+ foreach ( $attachments as $key => $attachment ) {
83
+ $downloaded_images[] = $this->import( $attachment );
84
+ }
85
+
86
+ return $downloaded_images;
87
+ }
88
+
89
+ /**
90
+ * Get Hash Image.
91
+ *
92
+ * @since 1.0.14
93
+ * @param string $attachment_url Attachment URL.
94
+ * @return string Hash string.
95
+ */
96
+ private function get_hash_image( $attachment_url ) {
97
+ return sha1( $attachment_url );
98
+ }
99
+
100
+ /**
101
+ * Get Saved Image.
102
+ *
103
+ * @since 1.0.14
104
+ * @param string $attachment Attachment Data.
105
+ * @return string Hash string.
106
+ */
107
+ private function get_saved_image( $attachment ) {
108
+
109
+ if ( apply_filters( 'astra_sites_image_importer_skip_image', false, $attachment ) ) {
110
+
111
+ Astra_Sites_Image_Importer::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
112
+
113
+ return $attachment;
114
+ }
115
+
116
+ global $wpdb;
117
+
118
+ // Already imported? Then return!
119
+ if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
120
+
121
+ Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
122
+
123
+ return $this->already_imported_ids[ $attachment['id'] ];
124
+ }
125
+
126
+ // 1. Is already imported in Batch Import Process?
127
+ $post_id = $wpdb->get_var(
128
+ $wpdb->prepare(
129
+ 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
130
+ WHERE `meta_key` = \'_astra_sites_image_hash\'
131
+ AND `meta_value` = %s
132
+ ;',
133
+ $this->get_hash_image( $attachment['url'] )
134
+ )
135
+ );
136
+
137
+ // 2. Is image already imported though XML?
138
+ if ( empty( $post_id ) ) {
139
+
140
+ // Get file name without extension.
141
+ // To check it exist in attachment.
142
+ $filename = basename( $attachment['url'] );
143
+
144
+ $post_id = $wpdb->get_var(
145
+ $wpdb->prepare(
146
+ 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
147
+ WHERE `meta_key` = \'_wp_attached_file\'
148
+ AND `meta_value` LIKE %s
149
+ ;',
150
+ '%' . $filename . '%'
151
+ )
152
+ );
153
+
154
+ $post_id = $wpdb->get_var(
155
+ $wpdb->prepare(
156
+ "SELECT post_id FROM {$wpdb->postmeta}
157
+ WHERE meta_key = '_wp_attached_file'
158
+ AND meta_value LIKE %s",
159
+ '%' . $filename . '%'
160
+ )
161
+ );
162
+
163
+ Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
164
+ }
165
+
166
+ if ( $post_id ) {
167
+ $new_attachment = array(
168
+ 'id' => $post_id,
169
+ 'url' => wp_get_attachment_url( $post_id ),
170
+ );
171
+ $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
172
+
173
+ return $new_attachment;
174
+ }
175
+
176
+ return false;
177
+ }
178
+
179
+ /**
180
+ * Import Image
181
+ *
182
+ * @since 1.0.14
183
+ * @param array $attachment Attachment array.
184
+ * @return array Attachment array.
185
+ */
186
+ public function import( $attachment ) {
187
+
188
+ $saved_image = $this->get_saved_image( $attachment );
189
+ if ( $saved_image ) {
190
+ return $saved_image;
191
+ }
192
+
193
+ $file_content = wp_remote_retrieve_body(
194
+ wp_safe_remote_get(
195
+ $attachment['url'],
196
+ array(
197
+ 'timeout' => '60',
198
+ 'sslverify' => false,
199
+ )
200
+ )
201
+ );
202
+
203
+ // Empty file content?
204
+ if ( empty( $file_content ) ) {
205
+
206
+ Astra_Sites_Image_Importer::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
207
+ Astra_Sites_Image_Importer::log( 'Error: Failed wp_remote_retrieve_body().' );
208
+
209
+ return $attachment;
210
+ }
211
+
212
+ // Extract the file name and extension from the URL.
213
+ $filename = basename( $attachment['url'] );
214
+
215
+ $upload = wp_upload_bits(
216
+ $filename,
217
+ null,
218
+ $file_content
219
+ );
220
+
221
+ $post = array(
222
+ 'post_title' => $filename,
223
+ 'guid' => $upload['url'],
224
+ );
225
+
226
+ $info = wp_check_filetype( $upload['file'] );
227
+ if ( $info ) {
228
+ $post['post_mime_type'] = $info['type'];
229
+ } else {
230
+ // For now just return the origin attachment.
231
+ return $attachment;
232
+ }
233
+
234
+ $post_id = wp_insert_attachment( $post, $upload['file'] );
235
+ wp_update_attachment_metadata(
236
+ $post_id,
237
+ wp_generate_attachment_metadata( $post_id, $upload['file'] )
238
+ );
239
+ update_post_meta( $post_id, '_astra_sites_image_hash', $this->get_hash_image( $attachment['url'] ) );
240
+
241
+ $new_attachment = array(
242
+ 'id' => $post_id,
243
+ 'url' => $upload['url'],
244
+ );
245
+
246
+ Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
247
+
248
+ $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
249
+
250
+ return $new_attachment;
251
+ }
252
+
253
+ /**
254
+ * Debugging Log.
255
+ *
256
+ * @since 1.0.14
257
+ * @param mixed $log Log data.
258
+ * @return void
259
+ */
260
+ public static function log( $log ) {
261
+
262
+ if ( ! WP_DEBUG_LOG ) {
263
+ return;
264
+ }
265
+
266
+ if ( is_array( $log ) || is_object( $log ) ) {
267
+ error_log( print_r( $log, true ) );
268
+ } else {
269
+ error_log( $log );
270
+ }
271
+ }
272
+
273
+ }
274
+
275
+ /**
276
+ * Kicking this off by calling 'get_instance()' method
277
+ */
278
+ Astra_Sites_Image_Importer::get_instance();
279
+
280
+ endif;
inc/importers/batch-processing/helpers/class-wp-background-process-astra.php CHANGED
@@ -1,67 +1,67 @@
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 WP_Background_Process_Astra 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 object $process Queue item object.
36
- * @return mixed
37
- */
38
- protected function task( $process ) {
39
-
40
- if ( method_exists( $process, 'import' ) ) {
41
- $process->import();
42
- }
43
-
44
- return false;
45
- }
46
-
47
- /**
48
- * Complete
49
- *
50
- * Override if applicable, but ensure that the below actions are
51
- * performed, or, call parent::complete().
52
- *
53
- * @since 1.0.11
54
- */
55
- protected function complete() {
56
-
57
- Astra_Sites_Image_Importer::log( '=================== ' . Astra_Sites_White_Label::get_instance()->page_title( ASTRA_SITES_NAME ) . ' - Importing Images Complete ===================' );
58
-
59
- parent::complete();
60
-
61
- do_action( 'astra_sites_image_import_complete' );
62
-
63
- }
64
-
65
- }
66
-
67
- endif;
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 WP_Background_Process_Astra 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 object $process Queue item object.
36
+ * @return mixed
37
+ */
38
+ protected function task( $process ) {
39
+
40
+ if ( method_exists( $process, 'import' ) ) {
41
+ $process->import();
42
+ }
43
+
44
+ return false;
45
+ }
46
+
47
+ /**
48
+ * Complete
49
+ *
50
+ * Override if applicable, but ensure that the below actions are
51
+ * performed, or, call parent::complete().
52
+ *
53
+ * @since 1.0.11
54
+ */
55
+ protected function complete() {
56
+
57
+ Astra_Sites_Image_Importer::log( '=================== ' . Astra_Sites_White_Label::get_instance()->page_title( ASTRA_SITES_NAME ) . ' - Importing Images Complete ===================' );
58
+
59
+ parent::complete();
60
+
61
+ do_action( 'astra_sites_image_import_complete' );
62
+
63
+ }
64
+
65
+ }
66
+
67
+ endif;
inc/importers/class-astra-customizer-import.php CHANGED
@@ -1,88 +1,88 @@
1
- <?php
2
- /**
3
- * Customizer Data importer class.
4
- *
5
- * @since 1.0.0
6
- * @package Astra Addon
7
- */
8
-
9
- defined( 'ABSPATH' ) or exit;
10
-
11
- /**
12
- * Customizer Data importer class.
13
- *
14
- * @since 1.0.0
15
- */
16
- class Astra_Customizer_Import {
17
-
18
- /**
19
- * Instance of Astra_Customizer_Import
20
- *
21
- * @since 1.0.0
22
- * @var Astra_Customizer_Import
23
- */
24
- private static $_instance = null;
25
-
26
- /**
27
- * Instantiate Astra_Customizer_Import
28
- *
29
- * @since 1.0.0
30
- * @return (Object) Astra_Customizer_Import
31
- */
32
- public static function instance() {
33
-
34
- if ( ! isset( self::$_instance ) ) {
35
- self::$_instance = new self;
36
- }
37
-
38
- return self::$_instance;
39
- }
40
-
41
- /**
42
- * Import customizer options.
43
- *
44
- * @since 1.0.0
45
- *
46
- * @param (Array) $options customizer options from the demo.
47
- */
48
- public function import( $options ) {
49
-
50
- // Update Astra Theme customizer settings.
51
- if ( isset( $options['astra-settings'] ) ) {
52
- self::_import_settings( $options['astra-settings'] );
53
- }
54
-
55
- // Add Custom CSS.
56
- if ( isset( $options['custom-css'] ) ) {
57
- wp_update_custom_css_post( $options['custom-css'] );
58
- }
59
-
60
- }
61
-
62
- /**
63
- * Import Astra Setting's
64
- *
65
- * Download & Import images from Astra Customizer Settings.
66
- *
67
- * @since 1.0.10
68
- *
69
- * @param array $options Astra Customizer setting array.
70
- * @return void
71
- */
72
- static public function _import_settings( $options = array() ) {
73
- foreach ( $options as $key => $val ) {
74
-
75
- if ( Astra_Sites_Helper::_is_image_url( $val ) ) {
76
-
77
- $data = Astra_Sites_Helper::_sideload_image( $val );
78
-
79
- if ( ! is_wp_error( $data ) ) {
80
- $options[ $key ] = $data->url;
81
- }
82
- }
83
- }
84
-
85
- // Updated settings.
86
- update_option( 'astra-settings', $options );
87
- }
88
- }
1
+ <?php
2
+ /**
3
+ * Customizer Data importer class.
4
+ *
5
+ * @since 1.0.0
6
+ * @package Astra Addon
7
+ */
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ /**
12
+ * Customizer Data importer class.
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ class Astra_Customizer_Import {
17
+
18
+ /**
19
+ * Instance of Astra_Customizer_Import
20
+ *
21
+ * @since 1.0.0
22
+ * @var Astra_Customizer_Import
23
+ */
24
+ private static $_instance = null;
25
+
26
+ /**
27
+ * Instantiate Astra_Customizer_Import
28
+ *
29
+ * @since 1.0.0
30
+ * @return (Object) Astra_Customizer_Import
31
+ */
32
+ public static function instance() {
33
+
34
+ if ( ! isset( self::$_instance ) ) {
35
+ self::$_instance = new self;
36
+ }
37
+
38
+ return self::$_instance;
39
+ }
40
+
41
+ /**
42
+ * Import customizer options.
43
+ *
44
+ * @since 1.0.0
45
+ *
46
+ * @param (Array) $options customizer options from the demo.
47
+ */
48
+ public function import( $options ) {
49
+
50
+ // Update Astra Theme customizer settings.
51
+ if ( isset( $options['astra-settings'] ) ) {
52
+ self::_import_settings( $options['astra-settings'] );
53
+ }
54
+
55
+ // Add Custom CSS.
56
+ if ( isset( $options['custom-css'] ) ) {
57
+ wp_update_custom_css_post( $options['custom-css'] );
58
+ }
59
+
60
+ }
61
+
62
+ /**
63
+ * Import Astra Setting's
64
+ *
65
+ * Download & Import images from Astra Customizer Settings.
66
+ *
67
+ * @since 1.0.10
68
+ *
69
+ * @param array $options Astra Customizer setting array.
70
+ * @return void
71
+ */
72
+ static public function _import_settings( $options = array() ) {
73
+ foreach ( $options as $key => $val ) {
74
+
75
+ if ( Astra_Sites_Helper::_is_image_url( $val ) ) {
76
+
77
+ $data = Astra_Sites_Helper::_sideload_image( $val );
78
+
79
+ if ( ! is_wp_error( $data ) ) {
80
+ $options[ $key ] = $data->url;
81
+ }
82
+ }
83
+ }
84
+
85
+ // Updated settings.
86
+ update_option( 'astra-settings', $options );
87
+ }
88
+ }
inc/importers/wxr-importer/class-astra-wxr-importer.php CHANGED
@@ -53,8 +53,14 @@ class Astra_WXR_Importer {
53
  add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
54
  add_action( 'wp_ajax_astra-wxr-import', array( $this, 'sse_import' ) );
55
  add_filter( 'wxr_importer.pre_process.user', '__return_null' );
56
- add_filter( 'wp_check_filetype_and_ext', array( $this, 'real_mime_type_for_xml' ), 10, 5 );
57
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'gutenberg_content_fix' ), 10, 4 );
 
 
 
 
 
 
 
58
  }
59
 
60
  /**
@@ -95,7 +101,39 @@ class Astra_WXR_Importer {
95
  * @param array $mimes Key is the file extension with value as the mime type.
96
  * @param string $real_mime Real MIME type of the uploaded file.
97
  */
98
- function real_mime_type_for_xml( $defaults, $file, $filename, $mimes, $real_mime ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  // Set EXT and real MIME type only for the file name `wxr.xml`.
101
  if ( 'wxr.xml' == $filename ) {
53
  add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
54
  add_action( 'wp_ajax_astra-wxr-import', array( $this, 'sse_import' ) );
55
  add_filter( 'wxr_importer.pre_process.user', '__return_null' );
 
56
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'gutenberg_content_fix' ), 10, 4 );
57
+
58
+ if ( version_compare( get_bloginfo( 'version' ), '5.1.0', '>=' ) ) {
59
+ add_filter( 'wp_check_filetype_and_ext', array( $this, 'real_mime_types_5_1_0' ), 10, 5 );
60
+ } else {
61
+ add_filter( 'wp_check_filetype_and_ext', array( $this, 'real_mime_types' ), 10, 4 );
62
+ }
63
+
64
  }
65
 
66
  /**
101
  * @param array $mimes Key is the file extension with value as the mime type.
102
  * @param string $real_mime Real MIME type of the uploaded file.
103
  */
104
+ function real_mime_types_5_1_0( $defaults, $file, $filename, $mimes, $real_mime ) {
105
+ return $this->real_mimes( $defaults, $filename );
106
+ }
107
+
108
+ /**
109
+ * Different MIME type of different PHP version
110
+ *
111
+ * Filters the "real" file type of the given file.
112
+ *
113
+ * @since 1.2.9
114
+ *
115
+ * @param array $defaults File data array containing 'ext', 'type', and
116
+ * 'proper_filename' keys.
117
+ * @param string $file Full path to the file.
118
+ * @param string $filename The name of the file (may differ from $file due to
119
+ * $file being in a tmp directory).
120
+ * @param array $mimes Key is the file extension with value as the mime type.
121
+ */
122
+ function real_mime_types( $defaults, $file, $filename, $mimes ) {
123
+ return $this->real_mimes( $defaults, $filename );
124
+ }
125
+
126
+ /**
127
+ * Real Mime Type
128
+ *
129
+ * @since 1.2.15
130
+ *
131
+ * @param array $defaults File data array containing 'ext', 'type', and
132
+ * 'proper_filename' keys.
133
+ * @param string $filename The name of the file (may differ from $file due to
134
+ * $file being in a tmp directory).
135
+ */
136
+ function real_mimes( $defaults, $filename ) {
137
 
138
  // Set EXT and real MIME type only for the file name `wxr.xml`.
139
  if ( 'wxr.xml' == $filename ) {
inc/includes/admin-page.php CHANGED
@@ -1,348 +1,348 @@
1
- <?php
2
- /**
3
- * Shortcode Markup
4
- *
5
- * TMPL - Single Demo Preview
6
- * TMPL - No more demos
7
- * TMPL - Filters
8
- * TMPL - List
9
- *
10
- * @package Astra Sites
11
- * @since 1.0.0
12
- */
13
-
14
- defined( 'ABSPATH' ) or exit;
15
- ?>
16
-
17
- <div class="wrap" id="astra-sites-admin">
18
-
19
- <div id="astra-sites-filters">
20
-
21
- <?php if ( apply_filters( 'astra_sites_show_filters', true ) ) { ?>
22
- <div class="wp-filter hide-if-no-js">
23
- <div class="section-left">
24
-
25
- <!-- All Filters -->
26
- <div class="filter-count">
27
- <span class="count"></span>
28
- </div>
29
- <div class="filters-wrap">
30
- <div id="astra-site-page-builder"></div>
31
- </div>
32
-
33
- </div>
34
-
35
- <div class="section-right">
36
-
37
- <div class="filters-wrap">
38
- <div id="astra-site-category"></div>
39
- </div>
40
-
41
- <div class="search-form">
42
- <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'astra-sites' ); ?> </label>
43
- <input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
44
- </div>
45
-
46
- </div>
47
- </div>
48
- <?php } ?>
49
-
50
- </div>
51
-
52
- <?php do_action( 'astra_sites_before_site_grid' ); ?>
53
-
54
- <div class="theme-browser rendered">
55
- <div id="astra-sites" class="themes wp-clearfix"></div>
56
- </div>
57
-
58
- <div class="spinner-wrap">
59
- <span class="spinner"></span>
60
- </div>
61
-
62
- <?php do_action( 'astra_sites_after_site_grid' ); ?>
63
-
64
- </div>
65
-
66
- <?php
67
- /**
68
- * TMPL - Pro Site Description
69
- */
70
- ?>
71
- <script type="text/template" id="tmpl-astra-sites-pro-site-description">
72
- <p><?php _e( 'Liked this demo?', 'astra-sites' ); ?></p>
73
- <p>
74
- <?php
75
- /* translators: %s is pricing page link */
76
- printf( __( 'It is a premium website demo which is available only with the Agency Bundles <a href="%s" target="_blank">Buy Now!</a>', 'astra-sites' ), 'https://wpastra.com/pricing/' );
77
- ?>
78
- </p>
79
- <p>
80
- <?php
81
- /* translators: %s is article link */
82
- printf( __( 'Already own an Agency Bundle? Read an article to know how you can <a href="%s" target="_blank">import a premium website demo</a>.', 'astra-sites' ), 'https://wpastra.com/docs/import-astra-agency-website-demos/' );
83
- ?>
84
- </p>
85
- </script>
86
-
87
- <?php
88
- /**
89
- * TMPL - Pro Site Description for Inactive license
90
- */
91
- ?>
92
- <script type="text/template" id="tmpl-astra-sites-pro-inactive-site-description">
93
- <p><?php _e( 'You are just 2 minutes away from importing this demo!', 'astra-sites' ); ?></p>
94
- <p><?php _e( 'It is a premium website demo and you need to activate the license to access it.', 'astra-sites' ); ?></p>
95
- <p>
96
- <?php
97
- /* translators: %s is article link */
98
- printf( __( 'Learn how you can <a href="%s" target="_blank">activate the license</a> of the Astra Premium Sites plugin.', 'astra-sites' ), 'https://wpastra.com/docs/activate-license-for-astra-premium-sites-plugin/' );
99
- ?>
100
- </p>
101
- </script>
102
-
103
- <?php
104
- /**
105
- * TMPL - Single Demo Preview
106
- */
107
- ?>
108
- <script type="text/template" id="tmpl-astra-site-select-page-builder">
109
- <div class="select-page-builder">
110
- <div class="note-wrap">
111
- <h3>
112
- <span class="up-arrow dashicons dashicons-editor-break"></span>
113
- <div class="note"><?php _e( 'Select Your Favorite Page Builder', 'astra-sites' ); ?></div>
114
- </h3>
115
- </div>
116
- <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/sites-screenshot.jpg' ); ?>" alt="<?php _e( 'Sites List..', 'astra-sites' ); ?>" title="<?php _e( 'Sites List..', 'astra-sites' ); ?>" />
117
- </div>
118
- </script>
119
-
120
- <?php
121
- /**
122
- * TMPL - Single Demo Preview
123
- */
124
- ?>
125
- <script type="text/template" id="tmpl-astra-site-preview">
126
- <div class="astra-sites-preview theme-install-overlay wp-full-overlay expanded">
127
- <div class="wp-full-overlay-sidebar">
128
- <div class="wp-full-overlay-header"
129
- data-demo-id="{{{data.id}}}"
130
- data-demo-type="{{{data.astra_demo_type}}}"
131
- data-demo-url="{{{data.astra_demo_url}}}"
132
- data-demo-api="{{{data.demo_api}}}"
133
- data-demo-name="{{{data.demo_name}}}"
134
- data-demo-slug="{{{data.slug}}}"
135
- data-screenshot="{{{data.screenshot}}}"
136
- data-content="{{{data.content}}}"
137
- data-required-plugins="{{data.required_plugins}}">
138
- <input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
139
- <input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
140
- <button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'astra-sites' ); ?></span></button>
141
- <button class="previous-theme"><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'astra-sites' ); ?></span></button>
142
- <button class="next-theme"><span class="screen-reader-text"><?php esc_html_e( 'Next', 'astra-sites' ); ?></span></button>
143
- <a class="button hide-if-no-customize astra-demo-import" href="#" data-import="disabled"><?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?></a>
144
-
145
- </div>
146
- <div class="wp-full-overlay-sidebar-content">
147
- <div class="install-theme-info">
148
-
149
- <span class="site-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
150
- <h3 class="theme-name">{{{data.demo_name}}}</h3>
151
-
152
- <# if ( data.screenshot.length ) { #>
153
- <img class="theme-screenshot" src="{{{data.screenshot}}}" alt="">
154
- <# } #>
155
-
156
- <div class="theme-details">
157
- {{{data.content}}}
158
- </div>
159
- <a href="#" class="theme-details-read-more"><?php _e( 'Read more', 'astra-sites' ); ?> &hellip;</a>
160
-
161
- <div class="required-plugins-wrap">
162
- <h4><?php _e( 'Required Plugins', 'astra-sites' ); ?> </h4>
163
- <div class="required-plugins"></div>
164
- </div>
165
- </div>
166
- </div>
167
-
168
- <div class="wp-full-overlay-footer">
169
- <div class="footer-import-button-wrap">
170
- <a class="button button-hero hide-if-no-customize astra-demo-import" href="#" data-import="disabled">
171
- <?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?>
172
- </a>
173
- </div>
174
- <button type="button" class="collapse-sidebar button" aria-expanded="true"
175
- aria-label="Collapse Sidebar">
176
- <span class="collapse-sidebar-arrow"></span>
177
- <span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
178
- </button>
179
-
180
- <div class="devices-wrapper">
181
- <div class="devices">
182
- <button type="button" class="preview-desktop active" aria-pressed="true" data-device="desktop">
183
- <span class="screen-reader-text"><?php _e( 'Enter desktop preview mode', 'astra-sites' ); ?></span>
184
- </button>
185
- <button type="button" class="preview-tablet" aria-pressed="false" data-device="tablet">
186
- <span class="screen-reader-text"><?php _e( 'Enter tablet preview mode', 'astra-sites' ); ?></span>
187
- </button>
188
- <button type="button" class="preview-mobile" aria-pressed="false" data-device="mobile">
189
- <span class="screen-reader-text"><?php _e( 'Enter mobile preview mode', 'astra-sites' ); ?></span>
190
- </button>
191
- </div>
192
- </div>
193
-
194
- </div>
195
- </div>
196
- <div class="wp-full-overlay-main">
197
- <iframe src="{{{data.astra_demo_url}}}" title="<?php esc_attr_e( 'Preview', 'astra-sites' ); ?>"></iframe>
198
- </div>
199
- </div>
200
- </script>
201
-
202
- <?php
203
- /**
204
- * TMPL - No more demos
205
- */
206
- ?>
207
- <script type="text/template" id="tmpl-astra-site-api-request-failed">
208
- <div class="no-themes">
209
- <?php
210
-
211
- /* translators: %1$s & %2$s are a Demo API URL */
212
- 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 ) );
213
-
214
- _e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
215
-
216
- _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' );
217
-
218
- /* translators: %1$s is a support link */
219
- 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/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=api-request-failed' ) );
220
- ?>
221
- </div>
222
- </script>
223
-
224
- <?php
225
- /**
226
- * TMPL - Site Down
227
- */
228
- ?>
229
- <script type="text/template" id="tmpl-astra-site-down">
230
- <div class="postbox astra-site-down">
231
- <h2><?php _e( 'Under Maintenance..', 'astra-sites' ); ?></h2>
232
- <p><?php _e( 'If you are seeing this message, most likely our servers are under routine maintenance and we will be back shortly. ', 'astra-sites' ); ?></p>
233
- <p><?php _e( 'In rare case, it is possible your website is having trouble connecting with ours. If you need help, please feel free to get in touch with us from our website.', 'astra-sites' ); ?></p>
234
- </div>
235
- </script>
236
-
237
- <?php
238
- /**
239
- * TMPL - Filters
240
- */
241
- ?>
242
- <script type="text/template" id="tmpl-astra-site-filters">
243
-
244
- <# if ( data ) { #>
245
-
246
- <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
247
-
248
- <# if ( data.args.show_all ) { #>
249
- <li>
250
- <a href="#" data-group="all"> All </a>
251
- </li>
252
- <# } #>
253
-
254
- <# for ( key in data.items ) { #>
255
- <# if ( data.items[ key ].count ) { #>
256
- <li>
257
- <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
258
- {{ data.items[ key ].name }}
259
- </a>
260
- </li>
261
- <# } #>
262
- <# } #>
263
-
264
- </ul>
265
- <# } #>
266
- </script>
267
-
268
- <?php
269
- /**
270
- * TMPL - List
271
- */
272
- ?>
273
- <script type="text/template" id="tmpl-astra-sites-list">
274
-
275
- <# if ( data.items.length ) { #>
276
- <# for ( key in data.items ) { #>
277
-
278
- <div class="theme astra-theme site-single {{ data.items[ key ].status }}" tabindex="0" aria-describedby="astra-theme-action astra-theme-name"
279
- data-demo-id="{{{ data.items[ key ].id }}}"
280
- data-demo-type="{{{ data.items[ key ]['astra-site-type'] }}}"
281
- data-demo-url="{{{ data.items[ key ]['astra-site-url'] }}}"
282
- data-demo-api="{{{ data.items[ key ]['_links']['self'][0]['href'] }}}"
283
- data-demo-name="{{{ data.items[ key ].title.rendered }}}"
284
- data-demo-slug="{{{ data.items[ key ].slug }}}"
285
- data-screenshot="{{{ data.items[ key ]['featured-image-url'] }}}"
286
- data-content="{{{ data.items[ key ].content.rendered }}}"
287
- data-required-plugins="{{ JSON.stringify( data.items[ key ]['required-plugins'] ) }}"
288
- data-groups=["{{ data.items[ key ].tags }}"]>
289
- <input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
290
- <input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
291
-
292
- <div class="inner">
293
- <span class="site-preview" data-href="{{ data.items[ key ]['astra-site-url'] }}?TB_iframe=true&width=600&height=550" data-title="{{ data.items[ key ].title.rendered }}">
294
- <div class="theme-screenshot">
295
- <# if( '' !== data.items[ key ]['featured-image-url'] ) { #>
296
- <img src="{{ data.items[ key ]['featured-image-url'] }}" />
297
- <# } #>
298
- </div>
299
- </span>
300
- <span class="more-details"> <?php esc_html_e( 'Details &amp; Preview', 'astra-sites' ); ?> </span>
301
- <# if ( data.items[ key ]['astra-site-type'] ) { #>
302
- <# var type = ( data.items[ key ]['astra-site-type'] !== 'premium' ) ? ( data.items[ key ]['astra-site-type'] ) : 'agency'; #>
303
- <span class="site-type {{data.items[ key ]['astra-site-type']}}">{{ type }}</span>
304
- <# } #>
305
- <# if ( data.items[ key ].status ) { #>
306
- <span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
307
- <# } #>
308
- <div class="theme-id-container">
309
- <h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
310
- <div class="theme-actions">
311
- <button class="button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
312
- </div>
313
- </div>
314
- </div>
315
- </div>
316
- <# } #>
317
- <# } else { #>
318
- <p class="no-themes" style="display:block;">
319
- <?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?>
320
- <span class="description">
321
- <?php
322
- /* translators: %1$s External Link */
323
- printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
324
- ?>
325
- </span>
326
- </p>
327
- <# } #>
328
- </script>
329
-
330
- <?php
331
- /**
332
- * TMPL - List
333
- */
334
- ?>
335
- <script type="text/template" id="tmpl-astra-sites-suggestions">
336
- <div class="theme astra-theme site-single astra-sites-suggestions">
337
- <div class="inner">
338
- <p>
339
- <?php
340
- /* translators: %1$s External Link */
341
- printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
342
- ?>
343
- </p>
344
- </div>
345
- </div>
346
- </script>
347
- <?php
348
- wp_print_admin_notice_templates();
1
+ <?php
2
+ /**
3
+ * Shortcode Markup
4
+ *
5
+ * TMPL - Single Demo Preview
6
+ * TMPL - No more demos
7
+ * TMPL - Filters
8
+ * TMPL - List
9
+ *
10
+ * @package Astra Sites
11
+ * @since 1.0.0
12
+ */
13
+
14
+ defined( 'ABSPATH' ) or exit;
15
+ ?>
16
+
17
+ <div class="wrap" id="astra-sites-admin">
18
+
19
+ <div id="astra-sites-filters">
20
+
21
+ <?php if ( apply_filters( 'astra_sites_show_filters', true ) ) { ?>
22
+ <div class="wp-filter hide-if-no-js">
23
+ <div class="section-left">
24
+
25
+ <!-- All Filters -->
26
+ <div class="filter-count">
27
+ <span class="count"></span>
28
+ </div>
29
+ <div class="filters-wrap">
30
+ <div id="astra-site-page-builder"></div>
31
+ </div>
32
+
33
+ </div>
34
+
35
+ <div class="section-right">
36
+
37
+ <div class="filters-wrap">
38
+ <div id="astra-site-category"></div>
39
+ </div>
40
+
41
+ <div class="search-form">
42
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'astra-sites' ); ?> </label>
43
+ <input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
44
+ </div>
45
+
46
+ </div>
47
+ </div>
48
+ <?php } ?>
49
+
50
+ </div>
51
+
52
+ <?php do_action( 'astra_sites_before_site_grid' ); ?>
53
+
54
+ <div class="theme-browser rendered">
55
+ <div id="astra-sites" class="themes wp-clearfix"></div>
56
+ </div>
57
+
58
+ <div class="spinner-wrap">
59
+ <span class="spinner"></span>
60
+ </div>
61
+
62
+ <?php do_action( 'astra_sites_after_site_grid' ); ?>
63
+
64
+ </div>
65
+
66
+ <?php
67
+ /**
68
+ * TMPL - Pro Site Description
69
+ */
70
+ ?>
71
+ <script type="text/template" id="tmpl-astra-sites-pro-site-description">
72
+ <p><?php _e( 'Liked this demo?', 'astra-sites' ); ?></p>
73
+ <p>
74
+ <?php
75
+ /* translators: %s is pricing page link */
76
+ printf( __( 'It is a premium website demo which is available only with the Agency Bundles <a href="%s" target="_blank">Buy Now!</a>', 'astra-sites' ), 'https://wpastra.com/pricing/' );
77
+ ?>
78
+ </p>
79
+ <p>
80
+ <?php
81
+ /* translators: %s is article link */
82
+ printf( __( 'Already own an Agency Bundle? Read an article to know how you can <a href="%s" target="_blank">import a premium website demo</a>.', 'astra-sites' ), 'https://wpastra.com/docs/import-astra-agency-website-demos/' );
83
+ ?>
84
+ </p>
85
+ </script>
86
+
87
+ <?php
88
+ /**
89
+ * TMPL - Pro Site Description for Inactive license
90
+ */
91
+ ?>
92
+ <script type="text/template" id="tmpl-astra-sites-pro-inactive-site-description">
93
+ <p><?php _e( 'You are just 2 minutes away from importing this demo!', 'astra-sites' ); ?></p>
94
+ <p><?php _e( 'It is a premium website demo and you need to activate the license to access it.', 'astra-sites' ); ?></p>
95
+ <p>
96
+ <?php
97
+ /* translators: %s is article link */
98
+ printf( __( 'Learn how you can <a href="%s" target="_blank">activate the license</a> of the Astra Premium Sites plugin.', 'astra-sites' ), 'https://wpastra.com/docs/activate-license-for-astra-premium-sites-plugin/' );
99
+ ?>
100
+ </p>
101
+ </script>
102
+
103
+ <?php
104
+ /**
105
+ * TMPL - Single Demo Preview
106
+ */
107
+ ?>
108
+ <script type="text/template" id="tmpl-astra-site-select-page-builder">
109
+ <div class="select-page-builder">
110
+ <div class="note-wrap">
111
+ <h3>
112
+ <span class="up-arrow dashicons dashicons-editor-break"></span>
113
+ <div class="note"><?php _e( 'Select Your Favorite Page Builder', 'astra-sites' ); ?></div>
114
+ </h3>
115
+ </div>
116
+ <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/sites-screenshot.jpg' ); ?>" alt="<?php _e( 'Sites List..', 'astra-sites' ); ?>" title="<?php _e( 'Sites List..', 'astra-sites' ); ?>" />
117
+ </div>
118
+ </script>
119
+
120
+ <?php
121
+ /**
122
+ * TMPL - Single Demo Preview
123
+ */
124
+ ?>
125
+ <script type="text/template" id="tmpl-astra-site-preview">
126
+ <div class="astra-sites-preview theme-install-overlay wp-full-overlay expanded">
127
+ <div class="wp-full-overlay-sidebar">
128
+ <div class="wp-full-overlay-header"
129
+ data-demo-id="{{{data.id}}}"
130
+ data-demo-type="{{{data.astra_demo_type}}}"
131
+ data-demo-url="{{{data.astra_demo_url}}}"
132
+ data-demo-api="{{{data.demo_api}}}"
133
+ data-demo-name="{{{data.demo_name}}}"
134
+ data-demo-slug="{{{data.slug}}}"
135
+ data-screenshot="{{{data.screenshot}}}"
136
+ data-content="{{{data.content}}}"
137
+ data-required-plugins="{{data.required_plugins}}">
138
+ <input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
139
+ <input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
140
+ <button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'astra-sites' ); ?></span></button>
141
+ <button class="previous-theme"><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'astra-sites' ); ?></span></button>
142
+ <button class="next-theme"><span class="screen-reader-text"><?php esc_html_e( 'Next', 'astra-sites' ); ?></span></button>
143
+ <a class="button hide-if-no-customize astra-demo-import" href="#" data-import="disabled"><?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?></a>
144
+
145
+ </div>
146
+ <div class="wp-full-overlay-sidebar-content">
147
+ <div class="install-theme-info">
148
+
149
+ <span class="site-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
150
+ <h3 class="theme-name">{{{data.demo_name}}}</h3>
151
+
152
+ <# if ( data.screenshot.length ) { #>
153
+ <img class="theme-screenshot" src="{{{data.screenshot}}}" alt="">
154
+ <# } #>
155
+
156
+ <div class="theme-details">
157
+ {{{data.content}}}
158
+ </div>
159
+ <a href="#" class="theme-details-read-more"><?php _e( 'Read more', 'astra-sites' ); ?> &hellip;</a>
160
+
161
+ <div class="required-plugins-wrap">
162
+ <h4><?php _e( 'Required Plugins', 'astra-sites' ); ?> </h4>
163
+ <div class="required-plugins"></div>
164
+ </div>
165
+ </div>
166
+ </div>
167
+
168
+ <div class="wp-full-overlay-footer">
169
+ <div class="footer-import-button-wrap">
170
+ <a class="button button-hero hide-if-no-customize astra-demo-import" href="#" data-import="disabled">
171
+ <?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?>
172
+ </a>
173
+ </div>
174
+ <button type="button" class="collapse-sidebar button" aria-expanded="true"
175
+ aria-label="Collapse Sidebar">
176
+ <span class="collapse-sidebar-arrow"></span>
177
+ <span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
178
+ </button>
179
+
180
+ <div class="devices-wrapper">
181
+ <div class="devices">
182
+ <button type="button" class="preview-desktop active" aria-pressed="true" data-device="desktop">
183
+ <span class="screen-reader-text"><?php _e( 'Enter desktop preview mode', 'astra-sites' ); ?></span>
184
+ </button>
185
+ <button type="button" class="preview-tablet" aria-pressed="false" data-device="tablet">
186
+ <span class="screen-reader-text"><?php _e( 'Enter tablet preview mode', 'astra-sites' ); ?></span>
187
+ </button>
188
+ <button type="button" class="preview-mobile" aria-pressed="false" data-device="mobile">
189
+ <span class="screen-reader-text"><?php _e( 'Enter mobile preview mode', 'astra-sites' ); ?></span>
190
+ </button>
191
+ </div>
192
+ </div>
193
+
194
+ </div>
195
+ </div>
196
+ <div class="wp-full-overlay-main">
197
+ <iframe src="{{{data.astra_demo_url}}}" title="<?php esc_attr_e( 'Preview', 'astra-sites' ); ?>"></iframe>
198
+ </div>
199
+ </div>
200
+ </script>
201
+
202
+ <?php
203
+ /**
204
+ * TMPL - No more demos
205
+ */
206
+ ?>
207
+ <script type="text/template" id="tmpl-astra-site-api-request-failed">
208
+ <div class="no-themes">
209
+ <?php
210
+
211
+ /* translators: %1$s & %2$s are a Demo API URL */
212
+ 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 ) );
213
+
214
+ _e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
215
+
216
+ _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' );
217
+
218
+ /* translators: %1$s is a support link */
219
+ 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/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=api-request-failed' ) );
220
+ ?>
221
+ </div>
222
+ </script>
223
+
224
+ <?php
225
+ /**
226
+ * TMPL - Site Down
227
+ */
228
+ ?>
229
+ <script type="text/template" id="tmpl-astra-site-down">
230
+ <div class="postbox astra-site-down">
231
+ <h2><?php _e( 'Under Maintenance..', 'astra-sites' ); ?></h2>
232
+ <p><?php _e( 'If you are seeing this message, most likely our servers are under routine maintenance and we will be back shortly. ', 'astra-sites' ); ?></p>
233
+ <p><?php _e( 'In rare case, it is possible your website is having trouble connecting with ours. If you need help, please feel free to get in touch with us from our website.', 'astra-sites' ); ?></p>
234
+ </div>
235
+ </script>
236
+
237
+ <?php
238
+ /**
239
+ * TMPL - Filters
240
+ */
241
+ ?>
242
+ <script type="text/template" id="tmpl-astra-site-filters">
243
+
244
+ <# if ( data ) { #>
245
+
246
+ <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
247
+
248
+ <# if ( data.args.show_all ) { #>
249
+ <li>
250
+ <a href="#" data-group="all"> All </a>
251
+ </li>
252
+ <# } #>
253
+
254
+ <# for ( key in data.items ) { #>
255
+ <# if ( data.items[ key ].count ) { #>
256
+ <li>
257
+ <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
258
+ {{ data.items[ key ].name }}
259
+ </a>
260
+ </li>
261
+ <# } #>
262
+ <# } #>
263
+
264
+ </ul>
265
+ <# } #>
266
+ </script>
267
+
268
+ <?php
269
+ /**
270
+ * TMPL - List
271
+ */
272
+ ?>
273
+ <script type="text/template" id="tmpl-astra-sites-list">
274
+
275
+ <# if ( data.items.length ) { #>
276
+ <# for ( key in data.items ) { #>
277
+
278
+ <div class="theme astra-theme site-single {{ data.items[ key ].status }}" tabindex="0" aria-describedby="astra-theme-action astra-theme-name"
279
+ data-demo-id="{{{ data.items[ key ].id }}}"
280
+ data-demo-type="{{{ data.items[ key ]['astra-site-type'] }}}"
281
+ data-demo-url="{{{ data.items[ key ]['astra-site-url'] }}}"
282
+ data-demo-api="{{{ data.items[ key ]['_links']['self'][0]['href'] }}}"
283
+ data-demo-name="{{{ data.items[ key ].title.rendered }}}"
284
+ data-demo-slug="{{{ data.items[ key ].slug }}}"
285
+ data-screenshot="{{{ data.items[ key ]['featured-image-url'] }}}"
286
+ data-content="{{{ data.items[ key ].content.rendered }}}"
287
+ data-required-plugins="{{ JSON.stringify( data.items[ key ]['required-plugins'] ) }}"
288
+ data-groups=["{{ data.items[ key ].tags }}"]>
289
+ <input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
290
+ <input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
291
+
292
+ <div class="inner">
293
+ <span class="site-preview" data-href="{{ data.items[ key ]['astra-site-url'] }}?TB_iframe=true&width=600&height=550" data-title="{{ data.items[ key ].title.rendered }}">
294
+ <div class="theme-screenshot">
295
+ <# if( '' !== data.items[ key ]['featured-image-url'] ) { #>
296
+ <img src="{{ data.items[ key ]['featured-image-url'] }}" />
297
+ <# } #>
298
+ </div>
299
+ </span>
300
+ <span class="more-details"> <?php esc_html_e( 'Details &amp; Preview', 'astra-sites' ); ?> </span>
301
+ <# if ( data.items[ key ]['astra-site-type'] ) { #>
302
+ <# var type = ( data.items[ key ]['astra-site-type'] !== 'premium' ) ? ( data.items[ key ]['astra-site-type'] ) : 'agency'; #>
303
+ <span class="site-type {{data.items[ key ]['astra-site-type']}}">{{ type }}</span>
304
+ <# } #>
305
+ <# if ( data.items[ key ].status ) { #>
306
+ <span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
307
+ <# } #>
308
+ <div class="theme-id-container">
309
+ <h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
310
+ <div class="theme-actions">
311
+ <button class="button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
312
+ </div>
313
+ </div>
314
+ </div>
315
+ </div>
316
+ <# } #>
317
+ <# } else { #>
318
+ <p class="no-themes" style="display:block;">
319
+ <?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?>
320
+ <span class="description">
321
+ <?php
322
+ /* translators: %1$s External Link */
323
+ printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
324
+ ?>
325
+ </span>
326
+ </p>
327
+ <# } #>
328
+ </script>
329
+
330
+ <?php
331
+ /**
332
+ * TMPL - List
333
+ */
334
+ ?>
335
+ <script type="text/template" id="tmpl-astra-sites-suggestions">
336
+ <div class="theme astra-theme site-single astra-sites-suggestions">
337
+ <div class="inner">
338
+ <p>
339
+ <?php
340
+ /* translators: %1$s External Link */
341
+ printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
342
+ ?>
343
+ </p>
344
+ </div>
345
+ </div>
346
+ </script>
347
+ <?php
348
+ wp_print_admin_notice_templates();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: Elementor,Beaver Builder,Templates,Gutenberg,Astra Starter Sites
5
  Requires at least: 4.4
6
  Requires PHP: 5.3
7
  Tested up to: 5.1
8
- Stable tag: 1.2.14
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -117,6 +117,9 @@ We are open to suggestions and would love to work on topics that our users are l
117
 
118
  == Changelog ==
119
 
 
 
 
120
  v1.2.14 - 13-March-2019
121
  - Improvement: Added support for the WPForms plugin.
122
 
5
  Requires at least: 4.4
6
  Requires PHP: 5.3
7
  Tested up to: 5.1
8
+ Stable tag: 1.2.15
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
117
 
118
  == Changelog ==
119
 
120
+ v1.2.15 - 19-March-2019
121
+ - Improvement: Added backward compatibility for filter `wp_check_filetype_and_ext` which accepts 5 parameter after WordPress version 5.1.
122
+
123
  v1.2.14 - 13-March-2019
124
  - Improvement: Added support for the WPForms plugin.
125