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