diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php
index b702784..8a0cb02 100644
--- a/class/class-mainwp-backup.php
+++ b/class/class-mainwp-backup.php
@@ -22,7 +22,7 @@ class MainWP_Backup {
public static function get() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Backup();
+ self::$instance = new self();
}
return self::$instance;
diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php
index 2afe0dc..699c104 100644
--- a/class/class-mainwp-child-back-up-buddy.php
+++ b/class/class-mainwp-child-back-up-buddy.php
@@ -21,7 +21,7 @@ class MainWP_Child_Back_Up_Buddy {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Back_Up_Buddy();
+ self::$instance = new self();
}
return self::$instance;
}
@@ -207,7 +207,7 @@ class MainWP_Child_Back_Up_Buddy {
}
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -752,7 +752,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
try {
$information['syncBackupBuddy'] = $this->get_sync_data();
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -796,7 +796,7 @@ class MainWP_Child_Back_Up_Buddy {
}
return $data;
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// not exit here!
}
diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php
index eb4c7c7..87638d1 100644
--- a/class/class-mainwp-child-back-up-wordpress.php
+++ b/class/class-mainwp-child-back-up-wordpress.php
@@ -15,15 +15,14 @@
namespace MainWP\Child;
-class MainWP_Child_Back_Up_Wordpress {
+class MainWP_Child_Back_Up_WordPress{
public static $instance = null;
public $is_plugin_installed = false;
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Back_Up_Wordpress();
+ self::$instance = new self();
}
-
return self::$instance;
}
@@ -154,7 +153,7 @@ class MainWP_Child_Back_Up_Wordpress {
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
try {
$information['syncBackUpWordPress'] = $this->get_sync_data();
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -233,7 +232,7 @@ class MainWP_Child_Back_Up_Wordpress {
}
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php
index 014d13b..d445edc 100644
--- a/class/class-mainwp-child-back-wp-up.php
+++ b/class/class-mainwp-child-back-wp-up.php
@@ -58,7 +58,7 @@ class MainWP_Child_Back_WP_Up {
public static function instance() {
if ( null == self::$instance ) {
- self::$instance = new MainWP_Child_Back_WP_Up();
+ self::$instance = new self();
}
return self::$instance;
@@ -97,7 +97,7 @@ class MainWP_Child_Back_WP_Up {
add_action( 'admin_init', array( $this, 'init_download_backup' ) );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$this->is_backwpup_installed = false;
}
}
@@ -322,7 +322,7 @@ class MainWP_Child_Back_WP_Up {
MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature.
}
}
- } catch ( Exception $ex ) {
+ } catch ( \Exception $ex ) {
// ok!
}
}
@@ -334,7 +334,7 @@ class MainWP_Child_Back_WP_Up {
$information['syncBackwpupData'] = array(
'lastbackup' => $lastbackup,
);
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -1097,7 +1097,7 @@ class MainWP_Child_Back_WP_Up {
$message->setBody( __( 'If this message reaches your inbox, sending backup archives via email should work for you.', 'mainwp-child' ) );
$result = $emailer->send( $message );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$message = 'Swift Mailer: ' . $e->getMessage();
}
diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php
index 8329cae..1a3482f 100644
--- a/class/class-mainwp-child-branding.php
+++ b/class/class-mainwp-child-branding.php
@@ -10,7 +10,7 @@ class MainWP_Child_Branding {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Branding();
+ self::$instance = new self();
}
return self::$instance;
}
@@ -259,7 +259,7 @@ class MainWP_Child_Branding {
}
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information['error']['login_image'] = $e->getMessage();
}
}
@@ -285,7 +285,7 @@ class MainWP_Child_Branding {
}
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information['error']['favico_image'] = $e->getMessage();
}
}
@@ -321,7 +321,7 @@ class MainWP_Child_Branding {
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
if ( is_wp_error( $temporary_file ) ) {
- throw new Exception( $temporary_file->get_error_message() );
+ throw new \Exception( $temporary_file->get_error_message() );
} else {
$upload_dir = wp_upload_dir();
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url );
diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php
index 8929c88..c32d045 100644
--- a/class/class-mainwp-child-ithemes-security.php
+++ b/class/class-mainwp-child-ithemes-security.php
@@ -45,7 +45,7 @@ class MainWP_Child_IThemes_Security {
$information['syncIThemeData'] = array(
'users_and_roles' => $this->get_available_admin_users_and_roles(),
);
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
error_log( $e->getMessage() );
}
}
@@ -993,7 +993,7 @@ class MainWP_Child_IThemes_Security {
$and = '';
}
- $active = $and . " `lockout_active`=1 AND `lockout_expire_gmt` > '" . gmdate( 'Y-m-d H:i:s', $itsec_globals['current_time_gmt'] ) . "'";
+ $active = $and . " `lockout_active`=1 AND `lockout_expire_gmt` > '" . gmdate( 'Y-m-d H:i:s', $itsec_globals['current_time_gmt'] ) . "'";
} else {
diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php
index 3f8b5cd..d67019c 100644
--- a/class/class-mainwp-child-links-checker.php
+++ b/class/class-mainwp-child-links-checker.php
@@ -79,7 +79,7 @@ class MainWP_Child_Links_Checker {
}
}
MainWP_Helper::write( $information );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
}
}
@@ -208,7 +208,7 @@ class MainWP_Child_Links_Checker {
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
try {
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -548,7 +548,7 @@ class MainWP_Child_Links_Checker {
'errors' => array(),
);
foreach ( $rez['errors'] as $error ) {
- /** @var WP_Error $error */
+ /** @var \WP_Error $error */
array_push( $response['errors'], implode( ', ', $error->get_error_messages() ) );
}
diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php
index 842dbb9..49bc284 100644
--- a/class/class-mainwp-child-pagespeed.php
+++ b/class/class-mainwp-child-pagespeed.php
@@ -21,7 +21,7 @@ class MainWP_Child_Pagespeed {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Pagespeed();
+ self::$instance = new self();
}
return self::$instance;
@@ -279,7 +279,7 @@ class MainWP_Child_Pagespeed {
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
try {
$information['syncPageSpeedData'] = $this->get_sync_data();
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
diff --git a/class/class-mainwp-child-plugins-check.php b/class/class-mainwp-child-plugins-check.php
index f55bde7..3479019 100644
--- a/class/class-mainwp-child-plugins-check.php
+++ b/class/class-mainwp-child-plugins-check.php
@@ -23,7 +23,7 @@ class MainWP_Child_Plugins_Check {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Plugins_Check();
+ self::$instance = new self();
}
return self::$instance;
diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php
index ab567e8..41a7e9e 100644
--- a/class/class-mainwp-child-server-information.php
+++ b/class/class-mainwp-child-server-information.php
@@ -552,7 +552,7 @@ class MainWP_Child_Server_Information {
|
|
- |
+ |
|
|
@@ -949,7 +949,7 @@ class MainWP_Child_Server_Information {
try {
$dirs = MainWP_Helper::get_mainwp_dir( null, false );
$path = $dirs[0];
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
return self::render_directory_row( $branding_title, '', 'Writable', $e->getMessage(), false );
}
diff --git a/class/class-mainwp-child-skeleton-key.php b/class/class-mainwp-child-skeleton-key.php
index 77f267c..11eb17e 100644
--- a/class/class-mainwp-child-skeleton-key.php
+++ b/class/class-mainwp-child-skeleton-key.php
@@ -8,7 +8,7 @@ class MainWP_Child_Skeleton_Key {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Skeleton_Key();
+ self::$instance = new self();
}
return self::$instance;
diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php
index 98d19f0..d30849f 100644
--- a/class/class-mainwp-child-staging.php
+++ b/class/class-mainwp-child-staging.php
@@ -21,7 +21,7 @@ class MainWP_Child_Staging {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Staging();
+ self::$instance = new self();
}
return self::$instance;
}
@@ -63,7 +63,7 @@ class MainWP_Child_Staging {
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
try {
$information['syncWPStaging'] = $this->get_sync_data();
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
diff --git a/class/class-mainwp-child-themes-check.php b/class/class-mainwp-child-themes-check.php
index d2ba0fa..ba7592e 100644
--- a/class/class-mainwp-child-themes-check.php
+++ b/class/class-mainwp-child-themes-check.php
@@ -22,7 +22,7 @@ class MainWP_Child_Themes_Check {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Themes_Check();
+ self::$instance = new self();
}
return self::$instance;
diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php
index 8a9683b..081d01b 100644
--- a/class/class-mainwp-child-timecapsule.php
+++ b/class/class-mainwp-child-timecapsule.php
@@ -19,7 +19,7 @@ class MainWP_Child_Timecapsule {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Timecapsule();
+ self::$instance = new self();
}
return self::$instance;
}
@@ -65,7 +65,7 @@ class MainWP_Child_Timecapsule {
try {
$this->require_files();
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$error = $e->getMessage();
MainWP_Helper::write( array( 'error' => $error ) );
}
@@ -281,7 +281,7 @@ class MainWP_Child_Timecapsule {
'backups_count' => $backups_count,
);
return $return;
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// do not exit here!
}
return false;
@@ -727,7 +727,7 @@ class MainWP_Child_Timecapsule {
}
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok.
}
}
diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php
index e72e36f..300366b 100644
--- a/class/class-mainwp-child-updraft-plus-backups.php
+++ b/class/class-mainwp-child-updraft-plus-backups.php
@@ -19,7 +19,7 @@ class MainWP_Child_Updraft_Plus_Backups {
public $is_plugin_installed = false;
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Updraft_Plus_Backups();
+ self::$instance = new self();
}
return self::$instance;
@@ -70,7 +70,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$information['sync_Updraftvault_quota_text'] = $this->connected_html();
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok.
}
@@ -159,7 +159,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$information = $this->vault_disconnect();
break;
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
}
@@ -291,7 +291,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
- // Returns either true (in which case the Vault token will be stored), or false|WP_Error.
+ // Returns either true (in which case the Vault token will be stored), or false|\WP_Error.
private function vault_connect( $email, $password ) {
global $updraftplus;
$vault_mothership = 'https://vault.updraftplus.com/plugin-info/';
@@ -318,9 +318,9 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( ! is_array( $response ) || ! isset( $response['mothership'] ) || ! isset( $response['loggedin'] ) ) {
if ( preg_match( '/has banned your IP address \(([\.:0-9a-f]+)\)/', $result['body'], $matches ) ) {
- return new WP_Error( 'banned_ip', sprintf( __( "UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus' ) . '
' . __( "It appears that your web server's IP Address (%s) is blocked.", 'updraftplus' ) . ' ' . __( 'This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus' ) . '
' . __( 'To remove the block, please go here.', 'updraftplus' ) . ' ', $matches[1] ) );
+ return new \WP_Error( 'banned_ip', sprintf( __( "UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus' ) . '
' . __( "It appears that your web server's IP Address (%s) is blocked.", 'updraftplus' ) . ' ' . __( 'This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus' ) . '
' . __( 'To remove the block, please go here.', 'updraftplus' ) . ' ', $matches[1] ) );
} else {
- return new WP_Error( 'unknown_response', sprintf( __( 'UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus' ), $result['body'] ) );
+ return new \WP_Error( 'unknown_response', sprintf( __( 'UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus' ), $result['body'] ) );
}
}
@@ -342,26 +342,26 @@ class MainWP_Child_Updraft_Plus_Backups {
}
UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings );
} elseif ( isset( $response['quota'] ) && ! $response['quota'] ) {
- return new WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) );
+ return new \WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) );
} else {
- return new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
+ return new \WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
}
break;
case 'authfailed':
if ( ! empty( $response['authproblem'] ) ) {
if ( 'invalidpassword' == $response['authproblem'] ) {
- $authfail_error = new WP_Error( 'authfailed', __( 'Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus' ) . ' ' . __( 'If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus' ) . '' );
+ $authfail_error = new \WP_Error( 'authfailed', __( 'Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus' ) . ' ' . __( 'If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus' ) . '' );
return $authfail_error;
} elseif ( 'invaliduser' == $response['authproblem'] ) {
- return new WP_Error( 'authfailed', __( 'You entered an email address that was not recognised by UpdraftPlus.Com', 'updraftplus' ) );
+ return new \WP_Error( 'authfailed', __( 'You entered an email address that was not recognised by UpdraftPlus.Com', 'updraftplus' ) );
}
}
- $return = new WP_Error( 'authfailed', __( 'Your email address and password were not recognised by UpdraftPlus.Com', 'updraftplus' ) );
+ $return = new \WP_Error( 'authfailed', __( 'Your email address and password were not recognised by UpdraftPlus.Com', 'updraftplus' ) );
break;
default:
- $return = new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
+ $return = new \WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
break;
}
@@ -430,7 +430,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( class_exists( 'UpdraftPlus_Options' ) ) {
foreach ( $keys_filter as $key ) {
if ( 'updraft_googledrive' === $key || 'updraft_googlecloud' === $key || 'updraft_onedrive' === $key ) {
- continue; // skip
+ continue;
}
if ( isset( $settings[ $key ] ) ) {
$settings_key = null;
diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php
index c6d8995..9bdf2cd 100644
--- a/class/class-mainwp-child-vulnerability-checker.php
+++ b/class/class-mainwp-child-vulnerability-checker.php
@@ -23,7 +23,7 @@ class MainWP_Child_Vulnerability_Checker {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Vulnerability_Checker();
+ self::$instance = new self();
}
return self::$instance;
}
diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php
index def436b..24f1903 100644
--- a/class/class-mainwp-child-wordfence.php
+++ b/class/class-mainwp-child-wordfence.php
@@ -173,7 +173,7 @@ class MainWP_Child_Wordfence {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_Wordfence();
+ self::$instance = new self();
}
return self::$instance;
@@ -1258,9 +1258,9 @@ SQL
$result['isPaid'] = 0;
$reload = 'reload';
} else {
- throw new Exception( "The Wordfence server's response did not contain the expected elements." );
+ throw new \Exception( "The Wordfence server's response did not contain the expected elements." );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$result['error'] = 'Your options have been saved, but you left your license key blank, so we tried to get you a free license key from the Wordfence servers. There was a problem fetching the free key: ' . wp_kses( $e->getMessage(), array() );
return $result;
}
@@ -1287,9 +1287,9 @@ SQL
$ping = true;
$reload = 'reload';
} else {
- throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' );
+ throw new \Exception( 'We could not understand the Wordfence API server reply when updating your API key.' );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$result['error'] = 'Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() );
return $result;
}
@@ -1343,7 +1343,7 @@ SQL
$result['paidKeyMsg'] = true;
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$result['error'] = 'Your options have been saved. However we tried to verify your license key with the Wordfence servers and received an error: ' . wp_kses( $e->getMessage(), array() );
return $result;
}
@@ -1435,7 +1435,7 @@ SQL
} else {
wfConfig::removeCodeExecutionProtectionForUploads();
}
- } catch ( wfConfigException $e ) {
+ } catch ( wfConfig\Exception $e ) {
return array( 'error' => $e->getMessage() );
}
}
@@ -1475,9 +1475,9 @@ SQL
$result['isPaid'] = 0;
$reload = 'reload';
} else {
- throw new Exception( "We could not understand the Wordfence server's response because it did not contain an 'ok' and 'apiKey' element." );
+ throw new \Exception( "We could not understand the Wordfence server's response because it did not contain an 'ok' and 'apiKey' element." );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$result['error'] = 'Your options have been saved, but we encountered a problem. You left your API key blank, so we tried to get you a free API key from the Wordfence servers. However we encountered a problem fetching the free key: ' . htmlentities( $e->getMessage() );
return $result;
@@ -1496,9 +1496,9 @@ SQL
}
$reload = 'reload';
} else {
- throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' );
+ throw new \Exception( 'We could not understand the Wordfence API server reply when updating your API key.' );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$result['error'] = 'Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() );
return $result;
@@ -1507,7 +1507,7 @@ SQL
try {
$api = new wfAPI( $apiKey, wfUtils::getWPVersion() );
$res = $api->call( 'ping_api_key', array(), array() );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$result['error'] = 'Your options have been saved. However we noticed you do not change your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() );
return $result;
@@ -1548,9 +1548,9 @@ SQL
} elseif ( $res['err'] ) {
return array( 'errorExport' => __( 'An error occurred: ', 'wordfence' ) . $res['err'] );
} else {
- throw new Exception( __( 'Invalid response: ', 'wordfence' ) . var_export( $res, true ) );
+ throw new \Exception( __( 'Invalid response: ', 'wordfence' ) . var_export( $res, true ) );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
return array( 'errorExport' => __( 'An error occurred: ', 'wordfence' ) . $e->getMessage() );
}
}
@@ -1611,9 +1611,9 @@ SQL
} elseif ( $res['err'] ) {
return array( 'errorImport' => 'An error occurred: ' . $res['err'] );
} else {
- throw new Exception( 'Invalid response: ' . var_export( $res, true ) );
+ throw new \Exception( 'Invalid response: ' . var_export( $res, true ) );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
return array( 'errorImport' => 'An error occurred: ' . $e->getMessage() );
}
}
@@ -1891,11 +1891,11 @@ SQL
wfConfig::save( $changes );
return array( 'success' => true );
- } catch ( wfWAFStorageFileException $e ) {
+ } catch ( wfWAFStorageFile\Exception $e ) {
return array(
'error' => __( 'An error occurred while saving the configuration.', 'wordfence' ),
);
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
return array(
'error' => $e->getMessage(),
);
@@ -1991,9 +1991,9 @@ SQL
// When downgrading we must disable all two factor authentication because it can lock an admin out if we don't.
wfConfig::set_ser( 'twoFactorUsers', array() );
} else {
- throw new Exception( 'Could not understand the response we received from the Wordfence servers when applying for a free API key.' );
+ throw new \Exception( 'Could not understand the response we received from the Wordfence servers when applying for a free API key.' );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$return['errorMsg'] = 'Could not fetch free API key from Wordfence: ' . htmlentities( $e->getMessage() );
return $return;
diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php
index 9aea835..14f4cd0 100644
--- a/class/class-mainwp-child-wp-rocket.php
+++ b/class/class-mainwp-child-wp-rocket.php
@@ -20,7 +20,7 @@ class MainWP_Child_WP_Rocket {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_WP_Rocket();
+ self::$instance = new self();
}
return self::$instance;
@@ -128,7 +128,7 @@ class MainWP_Child_WP_Rocket {
try {
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) );
$information['syncWPRocketData'] = $data;
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -271,7 +271,7 @@ class MainWP_Child_WP_Rocket {
$information = $this->do_admin_post_rocket_purge_opcache();
break;
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
}
diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php
index d7e5c92..b7102d3 100644
--- a/class/class-mainwp-child-wpvivid-backuprestore.php
+++ b/class/class-mainwp-child-wpvivid-backuprestore.php
@@ -9,7 +9,7 @@ class MainWP_Child_WPvivid_BackupRestore {
public $public_intetface;
static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Child_WPvivid_BackupRestore();
+ self::$instance = new self();
}
return self::$instance;
@@ -43,7 +43,7 @@ class MainWP_Child_WPvivid_BackupRestore {
$information['syncWPvividScheduleData'] = $data['schedule'];
$information['syncWPvividSetting'] = $data;
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
}
@@ -124,7 +124,7 @@ class MainWP_Child_WPvivid_BackupRestore {
$information = $this->post_mainwp_data($_POST);
break;
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php
index d55e3e2..1598478 100644
--- a/class/class-mainwp-child.php
+++ b/class/class-mainwp-child.php
@@ -653,6 +653,12 @@ class MainWP_Child {
}
}
+ if ( ! $hide_restore ) {
+ if ( '' === session_id() ) {
+ session_start();
+ }
+ }
+
self::render_header( $shownPage, false );
?>
@@ -664,10 +670,6 @@ class MainWP_Child {
>
ithemes_init();
MainWP_Child_Updraft_Plus_Backups::instance()->updraftplus_init();
- MainWP_Child_Back_Up_Wordpress::instance()->init();
+ MainWP_Child_Back_Up_WordPress::instance()->init();
MainWP_Child_WP_Rocket::instance()->init();
MainWP_Child_Back_WP_Up::instance()->init();
MainWP_Child_Back_Up_Buddy::instance();
@@ -2668,7 +2670,7 @@ class MainWP_Child {
$user->description = trim( $data['description'] );
}
- $errors = new WP_Error();
+ $errors = new \WP_Error();
// checking that username has been typed.
if ( '' == $user->user_login ) {
@@ -3755,7 +3757,7 @@ class MainWP_Child {
try {
do_action( 'mainwp_child_site_stats' );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok.
}
@@ -3774,7 +3776,7 @@ class MainWP_Child {
try {
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -4245,7 +4247,7 @@ class MainWP_Child {
}
MainWP_Helper::write( $information );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information['error'] = $e->getMessage();
MainWP_Helper::write( $information );
}
@@ -4945,7 +4947,7 @@ class MainWP_Child {
}
}
return 0;
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
return 0;
}
}
@@ -5347,7 +5349,7 @@ class MainWP_Child {
if ( null !== $upload ) {
$information['success'] = true;
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information['error'] = $e->getMessage();
}
MainWP_Helper::write( $information );
@@ -5395,7 +5397,7 @@ class MainWP_Child {
$error = sprintf( __( 'PHP Version %s is unsupported.', 'mainwp-child' ), phpversion() );
MainWP_Helper::write( array( 'error' => $error ) );
}
- MainWP_Child_Back_Up_Wordpress::instance()->action();
+ MainWP_Child_Back_Up_WordPress::instance()->action();
}
public function wp_rocket() {
diff --git a/class/class-mainwp-client-report.php b/class/class-mainwp-client-report.php
index 01d0807..ddf45cf 100644
--- a/class/class-mainwp-client-report.php
+++ b/class/class-mainwp-client-report.php
@@ -8,7 +8,7 @@ class MainWP_Client_Report {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Client_Report();
+ self::$instance = new self();
}
return self::$instance;
@@ -50,7 +50,7 @@ class MainWP_Client_Report {
MainWP_Child_Back_Up_Buddy::instance()->do_reports_log( $ext );
break;
case 'backupwordpress':
- MainWP_Child_Back_Up_Wordpress::instance()->do_reports_log( $ext );
+ MainWP_Child_Back_Up_WordPress::instance()->do_reports_log( $ext );
break;
case 'backwpup':
MainWP_Child_Back_WP_Up::instance()->do_reports_log( $ext );
diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php
index 49c18d2..b445226 100644
--- a/class/class-mainwp-clone-install.php
+++ b/class/class-mainwp-clone-install.php
@@ -87,13 +87,13 @@ class MainWP_Clone_Install {
public function test_download() {
if ( ! $this->file_exists( 'wp-content/' ) ) {
- throw new Exception( __( 'This is not a full backup.', 'mainwp-child' ) );
+ throw new \Exception( __( 'This is not a full backup.', 'mainwp-child' ) );
}
if ( ! $this->file_exists( 'wp-admin/' ) ) {
- throw new Exception( __( 'This is not a full backup.', 'mainwp-child' ) );
+ throw new \Exception( __( 'This is not a full backup.', 'mainwp-child' ) );
}
if ( ! $this->file_exists( 'wp-content/dbBackup.sql' ) ) {
- throw new Exception( __( 'Database backup is missing.', 'mainwp-child' ) );
+ throw new \Exception( __( 'Database backup is missing.', 'mainwp-child' ) );
}
}
@@ -135,7 +135,7 @@ class MainWP_Clone_Install {
public function read_configuration_file() {
$configContents = $this->get_config_contents();
if ( false === $configContents ) {
- throw new Exception( __( 'Cant read configuration file from the backup.', 'mainwp-child' ) );
+ throw new \Exception( __( 'Cant read configuration file from the backup.', 'mainwp-child' ) );
}
$this->config = maybe_unserialize( base64_decode( $configContents ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
@@ -169,7 +169,7 @@ class MainWP_Clone_Install {
unlink( $file );
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -241,7 +241,7 @@ class MainWP_Clone_Install {
}
if ( ! feof( $handle ) ) {
- throw new Exception( __( 'Error: unexpected end of file for database.', 'mainwp-child' ) );
+ throw new \Exception( __( 'Error: unexpected end of file for database.', 'mainwp-child' ) );
}
fclose( $handle );
}
@@ -438,7 +438,7 @@ class MainWP_Clone_Install {
return false;
}
if ( PCLZIP_ERR_NO_ERROR !== $zip->error_code ) {
- throw new Exception( $zip->errorInfo( true ) );
+ throw new \Exception( $zip->errorInfo( true ) );
}
return true;
@@ -650,7 +650,7 @@ class MainWP_Clone_Install {
if ( $serialised ) {
return serialize( $data ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.
}
- } catch ( Exception $error ) {
+ } catch ( \Exception $error ) {
// ok!
}
diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php
index bb63d68..a80dec5 100644
--- a/class/class-mainwp-clone.php
+++ b/class/class-mainwp-clone.php
@@ -20,7 +20,7 @@ class MainWP_Clone {
public static function get() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Clone();
+ self::$instance = new self();
}
return self::$instance;
@@ -1141,7 +1141,7 @@ class MainWP_Clone {
$this->secure_request( 'mainwp-child_clone_backupcreate' );
if ( ! isset( $_POST['siteId'] ) ) {
- throw new Exception( __( 'No site given', 'mainwp-child' ) );
+ throw new \Exception( __( 'No site given', 'mainwp-child' ) );
}
$siteId = $_POST['siteId'];
@@ -1149,7 +1149,7 @@ class MainWP_Clone {
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
if ( ! is_array( $sitesToClone ) || ! isset( $sitesToClone[ $siteId ] ) ) {
- throw new Exception( __( 'Site not found', 'mainwp-child' ) );
+ throw new \Exception( __( 'Site not found', 'mainwp-child' ) );
}
$siteToClone = $sitesToClone[ $siteId ];
@@ -1173,7 +1173,7 @@ class MainWP_Clone {
);
if ( ! $result['backup'] ) {
- throw new Exception( __( 'Could not create backupfile on child', 'mainwp-child' ) );
+ throw new \Exception( __( 'Could not create backupfile on child', 'mainwp-child' ) );
}
session_start();
@@ -1184,7 +1184,7 @@ class MainWP_Clone {
'url' => $result['backup'],
'size' => round( $result['size'] / 1024, 0 ),
);
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$output = array( 'error' => $e->getMessage() );
}
@@ -1196,14 +1196,14 @@ class MainWP_Clone {
$this->secure_request( 'mainwp-child_clone_backupcreatepoll' );
if ( ! isset( $_POST['siteId'] ) ) {
- throw new Exception( __( 'No site given', 'mainwp-child' ) );
+ throw new \Exception( __( 'No site given', 'mainwp-child' ) );
}
$siteId = $_POST['siteId'];
$rand = $_POST['rand'];
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
if ( ! is_array( $sitesToClone ) || ! isset( $sitesToClone[ $siteId ] ) ) {
- throw new Exception( __( 'Site not found', 'mainwp-child' ) );
+ throw new \Exception( __( 'Site not found', 'mainwp-child' ) );
}
$siteToClone = $sitesToClone[ $siteId ];
@@ -1224,11 +1224,11 @@ class MainWP_Clone {
);
if ( ! isset( $result['size'] ) ) {
- throw new Exception( __( 'Invalid response', 'mainwp-child' ) );
+ throw new \Exception( __( 'Invalid response', 'mainwp-child' ) );
}
$output = array( 'size' => round( $result['size'] / 1024, 0 ) );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$output = array( 'error' => $e->getMessage() );
}
die( json_encode( $output ) );
@@ -1239,7 +1239,7 @@ class MainWP_Clone {
$this->secure_request( 'mainwp-child_clone_backupdownload' );
if ( ! isset( $_POST['file'] ) ) {
- throw new Exception( __( 'No download link given', 'mainwp-child' ) );
+ throw new \Exception( __( 'No download link given', 'mainwp-child' ) );
}
$file = $_POST['file'];
@@ -1248,7 +1248,7 @@ class MainWP_Clone {
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
if ( ! is_array( $sitesToClone ) || ! isset( $sitesToClone[ $siteId ] ) ) {
- throw new Exception( __( 'Site not found', 'mainwp-child' ) );
+ throw new \Exception( __( 'Site not found', 'mainwp-child' ) );
}
$siteToClone = $sitesToClone[ $siteId ];
@@ -1297,7 +1297,7 @@ class MainWP_Clone {
if ( 200 !== (int) wp_remote_retrieve_response_code( $response ) ) {
unlink( $filename );
- return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
+ return new \WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
}
$output = array( 'done' => $filename );
@@ -1321,10 +1321,10 @@ class MainWP_Clone {
);
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
throw $e;
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$output = array( 'error' => $e->getMessage() );
}
@@ -1349,10 +1349,10 @@ class MainWP_Clone {
}
}
if ( false === $archiveFile ) {
- throw new Exception( __( 'No download file found', 'mainwp-child' ) );
+ throw new \Exception( __( 'No download file found', 'mainwp-child' ) );
}
$output = array( 'size' => filesize( $archiveFile ) / 1024 );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$output = array( 'error' => $e->getMessage() );
}
die( json_encode( $output ) );
@@ -1379,7 +1379,7 @@ class MainWP_Clone {
}
}
if ( false === $archiveFile ) {
- throw new Exception( __( 'No download file found', 'mainwp-child' ) );
+ throw new \Exception( __( 'No download file found', 'mainwp-child' ) );
}
$file = $archiveFile;
} elseif ( file_exists( $file ) ) {
@@ -1387,7 +1387,7 @@ class MainWP_Clone {
} else {
$file = ABSPATH . $file;
if ( ! file_exists( $file ) ) {
- throw new Exception( __( 'Backup file not found', 'mainwp-child' ) );
+ throw new \Exception( __( 'Backup file not found', 'mainwp-child' ) );
}
$testFull = true;
}
@@ -1481,7 +1481,7 @@ class MainWP_Clone {
$output = array( 'result' => 'ok' );
wp_logout();
wp_set_current_user( 0 );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$output = array( 'error' => $e->getMessage() );
}
die( json_encode( $output ) );
diff --git a/class/class-mainwp-custom-post-type.php b/class/class-mainwp-custom-post-type.php
index 67fc516..5ed9f89 100755
--- a/class/class-mainwp-custom-post-type.php
+++ b/class/class-mainwp-custom-post-type.php
@@ -9,7 +9,7 @@ class MainWP_Custom_Post_Type {
public static function instance() {
if ( null == self::$instance ) {
- self::$instance = new MainWP_Custom_Post_Type();
+ self::$instance = new self();
}
return self::$instance;
@@ -124,7 +124,7 @@ class MainWP_Custom_Post_Type {
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
$post_content = str_replace( $lnkToReplace, $linkToReplaceWith, $post_content );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -238,7 +238,7 @@ class MainWP_Custom_Post_Type {
} else {
return array( 'error' => __( 'Cannot add product image', $this->plugin_translate ) );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
continue;
}
}
@@ -259,7 +259,7 @@ class MainWP_Custom_Post_Type {
} else {
return array( 'error' => __( 'Cannot add featured image', $this->plugin_translate ) );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
continue;
}
} else {
diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php
index d6051a5..d343965 100644
--- a/class/class-mainwp-helper.php
+++ b/class/class-mainwp-helper.php
@@ -213,7 +213,7 @@ class MainWP_Helper {
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
if ( is_wp_error( $temporary_file ) ) {
- throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
+ throw new \Exception( 'Error: ' . $temporary_file->get_error_message() );
} else {
$filename = basename( $img_url );
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename;
@@ -337,12 +337,12 @@ class MainWP_Helper {
if ( is_wp_error( $response ) ) {
unlink( $full_file_name );
- throw new Exception( 'Error: ' . $response->get_error_message() );
+ throw new \Exception( 'Error: ' . $response->get_error_message() );
}
if ( 200 !== (int) wp_remote_retrieve_response_code( $response ) ) {
unlink( $full_file_name );
- throw new Exception( 'Error 404: ' . trim( wp_remote_retrieve_response_message( $response ) ) );
+ throw new \Exception( 'Error 404: ' . trim( wp_remote_retrieve_response_message( $response ) ) );
}
if ( '.phpfile.txt' === substr( $file_name, - 12 ) ) {
$new_file_name = substr( $file_name, 0, - 12 ) . '.php';
@@ -352,7 +352,7 @@ class MainWP_Helper {
return array( 'path' => $new_file_name );
} else {
unlink( $full_file_name );
- throw new Exception( 'Error: Copy file.' );
+ throw new \Exception( 'Error: Copy file.' );
}
}
@@ -503,7 +503,7 @@ class MainWP_Helper {
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
$new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
error_log( $e->getMessage() );
}
}
@@ -522,7 +522,7 @@ class MainWP_Helper {
if ( null !== $upload ) {
$replaceAttachedIds[ $gallery['id'] ] = $upload['id'];
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -720,7 +720,7 @@ class MainWP_Helper {
if ( null !== $upload ) {
update_post_meta( $new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post!
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -769,7 +769,7 @@ class MainWP_Helper {
);
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
}
@@ -901,7 +901,7 @@ class MainWP_Helper {
if ( $dieOnError ) {
self::error( $error );
} else {
- throw new Exception( $error );
+ throw new \Exception( $error );
}
}
}
@@ -915,7 +915,7 @@ class MainWP_Helper {
global $wp_filesystem;
try {
self::check_dir( $dir, false );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
// ok!
}
if ( ! empty( $wp_filesystem ) ) {
@@ -1049,10 +1049,10 @@ class MainWP_Helper {
}
return self::m_fetch_url( $tmpUrl . 'wp-admin/', $postdata );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
try {
return self::m_fetch_url( $url, $postdata );
- } catch ( Exception $ex ) {
+ } catch ( \Exception $ex ) {
throw $e;
}
}
@@ -1080,7 +1080,7 @@ class MainWP_Helper {
curl_close( $ch );
if ( ( false === $data ) && ( 0 === $http_status ) ) {
- throw new Exception( 'Http Error: ' . $err );
+ throw new \Exception( 'Http Error: ' . $err );
} elseif ( preg_match( '/(.*)<\/mainwp>/', $data, $results ) > 0 ) {
$result = $results[1];
$result_base = base64_decode( $result ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
@@ -1089,9 +1089,9 @@ class MainWP_Helper {
return $information;
} elseif ( '' === $data ) {
- throw new Exception( __( 'Something went wrong while contacting the child site. Please check if there is an error on the child site. This error could also be caused by trying to clone or restore a site to large for your server settings.', 'mainwp-child' ) );
+ throw new \Exception( __( 'Something went wrong while contacting the child site. Please check if there is an error on the child site. This error could also be caused by trying to clone or restore a site to large for your server settings.', 'mainwp-child' ) );
} else {
- throw new Exception( __( 'Child plugin is disabled or the security key is incorrect. Please resync with your main installation.', 'mainwp-child' ) );
+ throw new \Exception( __( 'Child plugin is disabled or the security key is incorrect. Please resync with your main installation.', 'mainwp-child' ) );
}
}
@@ -1266,7 +1266,7 @@ class MainWP_Helper {
if ( $autoload != $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option_name ) ) ) {
$option_value = get_option( $option_name );
delete_option( $option_name );
- add_option( $option_name, $option_value, null, $autoload );
+ add_option( $option_name, $option_value, '', $autoload );
}
}
@@ -1472,7 +1472,7 @@ class MainWP_Helper {
// Remove anything which isn't a word, whitespace, number or any of the following caracters -_~,;:[]().
// If you don't need to handle multi-byte characters you can use preg_replace rather than mb_ereg_replace.
- // Thanks @Łukasz Rysiak!
+ // Thanks @?ukasz Rysiak!
$filename = mb_ereg_replace( '([^\w\s\d\-_~,;:\[\]\(\).])', '', $filename );
// Remove any runs of periods (thanks falstro!).
$filename = mb_ereg_replace( '([\.]{2,})', '', $filename );
@@ -1583,7 +1583,7 @@ class MainWP_Helper {
if ( $return ) {
return $message;
} else {
- throw new Exception( $message );
+ throw new \Exception( $message );
}
}
return true;
@@ -1608,7 +1608,7 @@ class MainWP_Helper {
if ( $return ) {
return $message;
} else {
- throw new Exception( $message );
+ throw new \Exception( $message );
}
}
return true;
@@ -1634,7 +1634,7 @@ class MainWP_Helper {
if ( $return ) {
return $message;
} else {
- throw new Exception( $message );
+ throw new \Exception( $message );
}
}
@@ -1660,7 +1660,7 @@ class MainWP_Helper {
if ( $return ) {
return $message;
} else {
- throw new Exception( $message );
+ throw new \Exception( $message );
}
}
@@ -1686,7 +1686,7 @@ class MainWP_Helper {
if ( $return ) {
return $message;
} else {
- throw new Exception( $message );
+ throw new \Exception( $message );
}
}
diff --git a/class/class-mainwp-keyword-links.php b/class/class-mainwp-keyword-links.php
index a6d9e30..6edf995 100644
--- a/class/class-mainwp-keyword-links.php
+++ b/class/class-mainwp-keyword-links.php
@@ -16,7 +16,7 @@ class MainWP_Keyword_Links {
static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Keyword_Links();
+ self::$instance = new self();
}
return self::$instance;
diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php
index f0dc387..378e19b 100644
--- a/class/class-mainwp-wordpress-seo.php
+++ b/class/class-mainwp-wordpress-seo.php
@@ -19,7 +19,7 @@ class MainWP_Wordpress_SEO {
public static function instance() {
if ( null === self::$instance ) {
- self::$instance = new MainWP_Wordpress_SEO();
+ self::$instance = new self();
}
return self::$instance;
@@ -62,15 +62,15 @@ class MainWP_Wordpress_SEO {
$temporary_file = download_url( $file_url );
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
if ( is_wp_error( $temporary_file ) ) {
- throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
+ throw new \Exception( 'Error: ' . $temporary_file->get_error_message() );
} else {
if ( $this->import_seo_settings( $temporary_file ) ) {
$information['success'] = true;
} else {
- throw new Exception( __( 'Settings could not be imported.', 'mainwp-child' ) );
+ throw new \Exception( __( 'Settings could not be imported.', 'mainwp-child' ) );
}
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information['error'] = $e->getMessage();
}
@@ -99,9 +99,9 @@ class MainWP_Wordpress_SEO {
$information['success'] = true;
} else {
- throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) );
+ throw new \Exception( __( 'Settings could not be imported:', 'mainwp-child' ) );
}
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
$information['error'] = $e->getMessage();
}
}
@@ -145,21 +145,21 @@ class MainWP_Wordpress_SEO {
return true;
} else {
- throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) );
+ throw new \Exception( __( 'Settings could not be imported:', 'mainwp-child' ) );
}
unset( $options, $name, $optgroup );
} else {
- throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) );
+ throw new \Exception( __( 'Settings could not be imported:', 'mainwp-child' ) );
}
unlink( $filename );
unlink( $p_path );
} else {
- throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) . ' ' . sprintf( __( 'Unzipping failed with error "%s".', 'mainwp-child' ), $unzipped->get_error_message() ) );
+ throw new \Exception( __( 'Settings could not be imported:', 'mainwp-child' ) . ' ' . sprintf( __( 'Unzipping failed with error "%s".', 'mainwp-child' ), $unzipped->get_error_message() ) );
}
unset( $zip, $unzipped );
unlink( $file );
} else {
- throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) . ' ' . __( 'Upload failed.', 'mainwp-child' ) );
+ throw new \Exception( __( 'Settings could not be imported:', 'mainwp-child' ) . ' ' . __( 'Upload failed.', 'mainwp-child' ) );
}
return false;
diff --git a/class/class-tar-archiver.php b/class/class-tar-archiver.php
index 31ed7d3..027aed9 100644
--- a/class/class-tar-archiver.php
+++ b/class/class-tar-archiver.php
@@ -282,10 +282,6 @@ class Tar_Archiver {
$iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path ), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
- if ( class_exists( 'ExampleSortedIterator' ) ) {
- $iterator = new ExampleSortedIterator( $iterator );
- }
-
/** @var $path DirectoryIterator */
foreach ( $iterator as $path ) {
$name = $path->__toString();
@@ -321,15 +317,15 @@ class Tar_Archiver {
if ( 'tar.gz' == $this->type ) {
if ( false === gzwrite( $this->archive, $data, strlen( $data ) ) ) {
- throw new Exception( 'Could not write to archive' );
+ throw new \Exception( 'Could not write to archive' );
}
} elseif ( 'tar.bz2' == $this->type ) {
if ( false === bzwrite( $this->archive, $data, strlen( $data ) ) ) {
- throw new Exception( 'Could not write to archive' );
+ throw new \Exception( 'Could not write to archive' );
}
} else {
if ( false === fwrite( $this->archive, $data, strlen( $data ) ) ) {
- throw new Exception( 'Could not write to archive' );
+ throw new \Exception( 'Could not write to archive' );
}
fflush( $this->archive );
}
@@ -345,16 +341,16 @@ class Tar_Archiver {
$this->log( 'writing & flushing ' . $len );
$this->chunk = gzencode( $this->chunk );
if ( false === fwrite( $this->archive, $this->chunk, strlen( $this->chunk ) ) ) {
- throw new Exception( 'Could not write to archive' );
+ throw new \Exception( 'Could not write to archive' );
}
fflush( $this->archive );
} elseif ( 'tar.bz2' == $this->type ) {
if ( false === bzwrite( $this->archive, $this->chunk, strlen( $len ) ) ) {
- throw new Exception( 'Could not write to archive' );
+ throw new \Exception( 'Could not write to archive' );
}
} else {
if ( false === fwrite( $this->archive, $len, strlen( $len ) ) ) {
- throw new Exception( 'Could not write to archive' );
+ throw new \Exception( 'Could not write to archive' );
}
fflush( $this->archive );
}
@@ -751,7 +747,7 @@ class Tar_Archiver {
* @param $entryName
*
* @return array|bool
- * @throws Exception
+ * @throws \Exception
*/
private function is_next_file( $entryName ) {
$currentOffset = ftell( $this->archive );
@@ -764,7 +760,7 @@ class Tar_Archiver {
}
if ( 512 != strlen( $block ) ) {
- throw new Exception( 'Invalid block found' );
+ throw new \Exception( 'Invalid block found' );
}
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
@@ -795,7 +791,7 @@ class Tar_Archiver {
return true;
} else {
- throw new Exception( 'Unexpected directory [' . $file['name'] . ']' );
+ throw new \Exception( 'Unexpected directory [' . $file['name'] . ']' );
}
} elseif ( 0 == $file['type'] ) {
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
@@ -850,13 +846,13 @@ class Tar_Archiver {
return true;
} else {
$this->log( 'Unexpected file [' . $file['name'] . ']' );
- throw new Exception( 'Unexpected file' );
+ throw new \Exception( 'Unexpected file' );
}
}
$this->log( 'ERROR' );
- throw new Exception( 'Should never get here?' );
- } catch ( Exception $e ) {
+ throw new \Exception( 'Should never get here?' );
+ } catch ( \Exception $e ) {
$this->log( $e->getMessage() );
throw $e;
}
@@ -930,7 +926,7 @@ class Tar_Archiver {
}
if ( ! $this->is_valid_block( substr( $read, 10, $pos - 10 ) ) ) {
- throw new Exception( 'invalid!' );
+ throw new \Exception( 'invalid!' );
}
$lastCorrect += $pos;
@@ -939,11 +935,11 @@ class Tar_Archiver {
}
if ( ! $this->is_valid_block( substr( $read, 10 ) ) ) {
- throw new Exception( 'invalid!' );
+ throw new \Exception( 'invalid!' );
}
fclose( $fh );
- } catch ( Exception $e ) {
+ } catch ( \Exception $e ) {
fclose( $fh );
$fh = fopen( $filepath, 'ab+' );
fseek( $fh, $lastCorrect );
@@ -1242,43 +1238,3 @@ class Tar_Archiver {
return $crcFound == $crc;
}
}
-
-if ( class_exists( 'SplHeap' ) ) {
- class ExampleSortedIterator extends SplHeap {
- public function __construct( Iterator $iterator ) {
- foreach ( $iterator as $item ) {
- $this->insert( $item );
- }
- }
-
- public function compare( $b, $a ) {
- $pathA = $a->__toString();
- $pathB = $b->__toString();
- $dirnameA = ( is_file( $pathA ) ? dirname( $pathA ) : $pathA );
- $dirnameB = ( is_file( $pathB ) ? dirname( $pathB ) : $pathB );
-
- if ( dirname( $pathA ) == dirname( $pathB ) ) {
- if ( is_file( $pathA ) && ! is_file( $pathB ) ) {
- return - 1;
- } elseif ( ! is_file( $pathA ) && is_file( $pathB ) ) {
- return 1;
- }
-
- return strcmp( $pathA, $pathB );
- } elseif ( $dirnameA == $dirnameB ) {
- return strcmp( $pathA, $pathB );
- } elseif ( MainWP_Helper::starts_with( $dirnameA, $dirnameB ) ) {
- return 1;
- } elseif ( MainWP_Helper::starts_with( $dirnameB, $dirnameA ) ) {
- return - 1;
- } else {
- $cmp = strcmp( $dirnameA, $dirnameB );
- if ( 0 == $cmp ) {
- return strcmp( $pathA, $pathB );
- }
-
- return $cmp;
- }
- }
- }
-}