[CodeFactor] Apply fixes to commit f9a9b37

[ci skip] [skip ci]
This commit is contained in:
codefactor-io 2020-03-27 15:13:11 +00:00
parent f9a9b37b4a
commit 01c3ff7137
28 changed files with 4888 additions and 4888 deletions

View file

@ -38,7 +38,7 @@ class MainWP_Child_Back_Up_Buddy {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@ -47,23 +47,23 @@ class MainWP_Child_Back_Up_Buddy {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
}
}
function hide_update_notice( $slugs ) {
$slugs[] = 'backupbuddy/backupbuddy.php';
return $slugs;
}
function hide_update_notice( $slugs ) {
$slugs[] = 'backupbuddy/backupbuddy.php';
return $slugs;
}
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( isset( $value->response['backupbuddy/backupbuddy.php'] ) ) {
unset( $value->response['backupbuddy/backupbuddy.php'] );
@ -103,41 +103,41 @@ class MainWP_Child_Back_Up_Buddy {
$this->do_reports_log('backupbuddy');
}
}
// ok
// ok
function do_reports_log( $ext = '' ) {
if ( $ext !== 'backupbuddy' ) {
return;
}
}
if ( ! $this->is_backupbuddy_installed ) {
return;
}
try {
try {
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
if ( ! class_exists( 'backupbuddy_core' ) ) {
if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') ) {
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
}
}
if ( ! class_exists( 'backupbuddy_core' ) ) {
if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') ) {
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
}
}
if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php') ) {
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
}
if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php') ) {
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
}
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' ));
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' ));
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
// Backup type.
$pretty_type = array(
'full' => 'Full',
'db' => 'Database',
'files' => 'Files',
);
// Backup type.
$pretty_type = array(
'full' => 'Full',
'db' => 'Database',
'files' => 'Files',
);
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
foreach ( $recentBackups_list as $backup_fileoptions ) {
@ -206,10 +206,10 @@ class MainWP_Child_Back_Up_Buddy {
}
}
}
} catch ( Exception $e ) {
} catch ( Exception $e ) {
}
}
}
}
public function action() {
$information = array();
@ -597,8 +597,8 @@ class MainWP_Child_Back_Up_Buddy {
}
$run_time = 'First run: ' . $first_run . '<br>' .
'Last run: ' . $last_run . '<br>' .
'Next run: ' . $next_run;
'Last run: ' . $last_run . '<br>' .
'Next run: ' . $next_run;
$schedules_run_time[ $schedule_id ] = $run_time;
@ -613,8 +613,8 @@ class MainWP_Child_Back_Up_Buddy {
$information['next_schedule_index'] = pb_backupbuddy::$options['next_schedule_index'];
$information['schedules_run_time'] = $this->get_schedules_run_time();
// to fix missing destination notice
if ( isset(pb_backupbuddy::$options['remote_destinations']) ) { // update
// to fix missing destination notice
if ( isset(pb_backupbuddy::$options['remote_destinations']) ) { // update
$information['remote_destinations'] = pb_backupbuddy::$options['remote_destinations'];
}
@ -635,7 +635,7 @@ class MainWP_Child_Back_Up_Buddy {
}
pb_backupbuddy::alert( 'Manually running scheduled backup "' . pb_backupbuddy::$options['schedules'][ $schedule_id ]['title'] . '" in the background.' . '<br>' .
__( 'Note: If there is no site activity there may be delays between steps in the backup. Access the site or use a 3rd party service, such as a free pinging service, to generate site activity.', 'it-l10n-backupbuddy' ) );
__( 'Note: If there is no site activity there may be delays between steps in the backup. Access the site or use a 3rd party service, such as a free pinging service, to generate site activity.', 'it-l10n-backupbuddy' ) );
pb_backupbuddy_cron::_run_scheduled_backup( $schedule_id );
$information['result'] = 'SUCCESS';
@ -698,7 +698,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( isset(pb_backupbuddy::$options['profiles'][ $profile_id ]) ) {
unset(pb_backupbuddy::$options['profiles'][ $profile_id ]);
}
}
pb_backupbuddy::save();
$information['result'] = 'SUCCESS';
@ -748,65 +748,65 @@ class MainWP_Child_Back_Up_Buddy {
return $information;
}
// ok
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
try {
$information['syncBackupBuddy'] = $this->get_sync_data();
} catch ( Exception $e ) {
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
try {
$information['syncBackupBuddy'] = $this->get_sync_data();
} catch ( Exception $e ) {
}
}
}
}
return $information;
}
// ok
// ok
public function get_sync_data() {
try {
if ( ! class_exists( 'backupbuddy_core' ) ) {
MainWP_Helper::check_classes_exists('pb_backupbuddy');
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
try {
if ( ! class_exists( 'backupbuddy_core' ) ) {
MainWP_Helper::check_classes_exists('pb_backupbuddy');
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
$plugin_path = pb_backupbuddy::plugin_path();
if ( file_exists($plugin_path . '/classes/core.php') ) {
require_once $plugin_path . '/classes/core.php';
}
}
$plugin_path = pb_backupbuddy::plugin_path();
if ( file_exists($plugin_path . '/classes/core.php') ) {
require_once $plugin_path . '/classes/core.php';
}
}
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' ));
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) );
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' ));
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) );
$data = array();
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
$data['themes_root'] = backupbuddy_core::get_themes_root();
$data['media_root'] = backupbuddy_core::get_media_root();
$data['additional_tables'] = $this->pb_additional_tables();
$data['abspath'] = ABSPATH;
$data = array();
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
$data['themes_root'] = backupbuddy_core::get_themes_root();
$data['media_root'] = backupbuddy_core::get_media_root();
$data['additional_tables'] = $this->pb_additional_tables();
$data['abspath'] = ABSPATH;
$getOverview = backupbuddy_api::getOverview();
$data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'];
$getOverview = backupbuddy_api::getOverview();
$data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'];
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
$finish_time = $getOverview['lastBackupStats']['finish'];
$time = $this->localize_time( $finish_time );
$data['lastBackupStats'] = date('M j - g:i A', $time);
$data['lasttime_backup'] = $finish_time;
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature
} else {
$data['lastBackupStats'] = 'Unknown';
}
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
$finish_time = $getOverview['lastBackupStats']['finish'];
$time = $this->localize_time( $finish_time );
$data['lastBackupStats'] = date('M j - g:i A', $time);
$data['lasttime_backup'] = $finish_time;
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature
} else {
$data['lastBackupStats'] = 'Unknown';
}
return $data;
} catch ( Exception $e ) {
return $data;
} catch ( Exception $e ) {
// not exit here
}
}
return false;
}
function localize_time( $timestamp ) {
function localize_time( $timestamp ) {
if ( function_exists( 'get_option' ) ) {
$gmt_offset = get_option( 'gmt_offset' );
} else {
@ -877,7 +877,7 @@ class MainWP_Child_Back_Up_Buddy {
);
} else {
return array( 'error' => 'Not found the file' );
}
}
}
function zip_viewer() {
@ -1070,13 +1070,13 @@ class MainWP_Child_Back_Up_Buddy {
}
}
// ok
// ok
function pb_additional_tables( $display_size = false ) {
MainWP_Helper::check_classes_exists('pb_backupbuddy');
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
MainWP_Helper::check_classes_exists('pb_backupbuddy');
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
$return = '';
$size_string = '';
@ -1437,8 +1437,8 @@ class MainWP_Child_Back_Up_Buddy {
$backupType = '<div>
<span style="color: #AAA; float: left;">' . pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type ) . '</span>
<span style="display: inline-block; float: left; height: 15px; border-right: 1px solid #EBEBEB; margin-left: 6px; margin-right: 6px;"></span>'
. $backup['profile']['title'] .
'</div>';
. $backup['profile']['title'] .
'</div>';
} else {
$backupType = backupbuddy_core::pretty_backup_type( backupbuddy_core::getBackupTypeFromFile( $backup['archive_file'] ) );
if ( '' == $backupType ) {
@ -1530,7 +1530,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<textarea readonly="readonly" id="backupbuddy_messages" wrap="off" style="width: 100%; min-height: 400px; height: 500px; height: 80%; background: #FFF;">
<?php
<?php
foreach ( (array) $lines as $rawline ) {
$line = json_decode( $rawline, true );
// print_r( $line );
@ -1549,7 +1549,7 @@ class MainWP_Child_Back_Up_Buddy {
}
}
?>
</textarea><br><br>
</textarea><br><br>
<small>Log file: <?php echo $logFile; ?></small>
<br>
<?php
@ -1942,26 +1942,26 @@ class MainWP_Child_Back_Up_Buddy {
$data = isset($_POST['data']) ? $_POST['data'] : false;
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0;
if ( is_array($data) && isset($data['do_not_override']) ) {
if ( is_array($data) && isset($data['do_not_override']) ) {
if ( true == $data['do_not_override'] ) {
if ( ( $data['type'] == 's32' || $data['type'] == 's33' ) ) {
$not_override = array(
'accesskey',
'secretkey',
'bucket',
'region',
);
foreach ( $not_override as $opt ) {
if ( isset($data[ $opt ]) ) {
unset($data[ $opt ]);
}
}
}
}
if ( true == $data['do_not_override'] ) {
if ( ( $data['type'] == 's32' || $data['type'] == 's33' ) ) {
$not_override = array(
'accesskey',
'secretkey',
'bucket',
'region',
);
foreach ( $not_override as $opt ) {
if ( isset($data[ $opt ]) ) {
unset($data[ $opt ]);
}
}
}
}
unset($data['do_not_override']);
}
unset($data['do_not_override']);
}
if ( is_array($data) ) {
if ( isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]) ) { // update
@ -2323,8 +2323,8 @@ class MainWP_Child_Back_Up_Buddy {
echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />';
backupbuddy_core::addNotification( 'malware_not_found', 'No malware detected on `' . $url . '`.', 'A malware scan was run on the site and did not detect malware.' );
}
?>
<br />
?>
<br />
</div>
</div>
@ -2333,7 +2333,7 @@ class MainWP_Child_Back_Up_Buddy {
<h3 class="hndle"><span><?php _e('Web server details', 'it-l10n-backupbuddy' ); ?></span></h3>
<div class="inside">
<label><?php _e('Site', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['SCAN']['SITE'] ) ) {
echo lined_array( $scan['SCAN']['SITE'] );
} else {
@ -2341,7 +2341,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('Hostname', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['SCAN']['DOMAIN'] ) ) {
echo lined_array( $scan['SCAN']['DOMAIN'] );
} else {
@ -2349,7 +2349,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('IP Address', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['SCAN']['IP'] ) ) {
echo lined_array( $scan['SCAN']['IP'] );
} else {
@ -2357,7 +2357,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('System details', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['SYSTEM']['NOTICE'] ) ) {
echo lined_array( $scan['SYSTEM']['NOTICE'] );
} else {
@ -2365,7 +2365,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('Information', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['SYSTEM']['INFO'] ) ) {
echo lined_array( $scan['SYSTEM']['INFO'] );
} else {
@ -2380,7 +2380,7 @@ class MainWP_Child_Back_Up_Buddy {
<h3 class="hndle"><span><?php _e('Web application', 'it-l10n-backupbuddy' ); ?></span></h3>
<div class="inside">
<label><?php _e('Details', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['WEBAPP']['INFO'] ) ) {
echo lined_array( $scan['WEBAPP']['INFO'] );
} else {
@ -2388,7 +2388,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('Versions', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['WEBAPP']['VERSION'] ) ) {
echo lined_array( $scan['WEBAPP']['VERSION'] );
} else {
@ -2396,7 +2396,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('Notices', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['WEBAPP']['NOTICE'] ) ) {
echo lined_array( $scan['WEBAPP']['NOTICE'] );
} else {
@ -2404,7 +2404,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('Errors', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['WEBAPP']['ERROR'] ) ) {
echo lined_array( $scan['WEBAPP']['ERROR'] );
} else {
@ -2412,7 +2412,7 @@ class MainWP_Child_Back_Up_Buddy {
?>
<br />
<label><?php _e('Warnings', 'it-l10n-backupbuddy' ); ?></label>
<?php
<?php
if ( ! empty( $scan['WEBAPP']['WARN'] ) ) {
echo lined_array( $scan['WEBAPP']['WARN'] );
} else {
@ -2427,7 +2427,7 @@ class MainWP_Child_Back_Up_Buddy {
<h3 class="hndle"><span><?php _e('Links', 'it-l10n-backupbuddy' ); ?></span></h3>
<div class="inside">
<?php
if ( ! empty( $scan['LINKS']['URL'] ) ) {
if ( ! empty( $scan['LINKS']['URL'] ) ) {
echo lined_array( $scan['LINKS']['URL'] );
} else {
echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
@ -2440,7 +2440,7 @@ class MainWP_Child_Back_Up_Buddy {
<h3 class="hndle"><span><?php _e('Local Javascript', 'it-l10n-backupbuddy' ); ?></span></h3>
<div class="inside">
<?php
if ( ! empty( $scan['LINKS']['JSLOCAL'] ) ) {
if ( ! empty( $scan['LINKS']['JSLOCAL'] ) ) {
echo lined_array( $scan['LINKS']['JSLOCAL'] );
} else {
echo '<i>', __('none', 'it-l10n-backupbuddy' ),'</i><br />'; }
@ -2453,7 +2453,7 @@ class MainWP_Child_Back_Up_Buddy {
<h3 class="hndle"><span><?php _e('External Javascript', 'it-l10n-backupbuddy' ); ?></span></h3>
<div class="inside">
<?php
if ( ! empty( $scan['LINKS']['JSEXTERNAL'] ) ) {
if ( ! empty( $scan['LINKS']['JSEXTERNAL'] ) ) {
echo lined_array( $scan['LINKS']['JSEXTERNAL'] );
} else {
echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
@ -2466,7 +2466,7 @@ class MainWP_Child_Back_Up_Buddy {
<h3 class="hndle"><span><?php _e('Iframes Included', 'it-l10n-backupbuddy' ); ?></span></h3>
<div class="inside">
<?php
if ( ! empty( $scan['LINKS']['IFRAME'] ) ) {
if ( ! empty( $scan['LINKS']['IFRAME'] ) ) {
echo lined_array( $scan['LINKS']['IFRAME'] );
} else {
echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
@ -2479,7 +2479,7 @@ class MainWP_Child_Back_Up_Buddy {
<h3 class="hndle"><span><?php _e('Blacklisting Status', 'it-l10n-backupbuddy' ); ?></span></h3>
<div class="inside">
<?php
if ( ! empty( $scan['BLACKLIST']['INFO'] ) ) {
if ( ! empty( $scan['BLACKLIST']['INFO'] ) ) {
echo lined_array( $scan['BLACKLIST']['INFO'] );
} else {
echo '<i>', __('none', 'it-l10n-backupbuddy' ), '</i><br />'; }
@ -2675,7 +2675,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( ! empty($error) ) {
$return['error'] = $error;
}
}
return $return;
}
@ -3017,7 +3017,7 @@ class MainWP_Child_Back_Up_Buddy {
foreach ( $response['packages'] as $package => $data ) {
if ( preg_match( '/ \|\|\| \d+$/', $package ) ) {
continue;
}
}
$name = Ithemes_Updater_Functions::get_package_name( $package );
@ -3027,7 +3027,7 @@ class MainWP_Child_Back_Up_Buddy {
$warn[ $name ] = __( 'Your product subscription has expired', 'it-l10n-backupbuddy' );
} else {
$fail[ $name ] = $data['error']['message'];
}
}
}
if ( ! empty( $success ) ) {
@ -3038,14 +3038,14 @@ class MainWP_Child_Back_Up_Buddy {
if ( ! empty( $fail ) ) {
foreach ( $fail as $name => $reason ) {
$errors[] = sprintf( __( 'Unable to license %1$s. Reason: %2$s', 'it-l10n-backupbuddy' ), $name, $reason );
}
}
$return['errors'] = $errors;
}
if ( ! empty( $warn ) ) {
foreach ( $warn as $name => $reason ) {
$soft_errors[] = sprintf( __( 'Unable to license %1$s. Reason: %2$s', 'it-l10n-backupbuddy' ), $name, $reason );
}
}
$return['soft_errors'] = $soft_errors;
}
}
@ -3090,7 +3090,7 @@ class MainWP_Child_Back_Up_Buddy {
foreach ( $response['packages'] as $package => $data ) {
if ( preg_match( '/ \|\|\| \d+$/', $package ) ) {
continue;
}
}
$name = Ithemes_Updater_Functions::get_package_name( $package );
@ -3100,7 +3100,7 @@ class MainWP_Child_Back_Up_Buddy {
$fail[ $name ] = $data['error']['message'];
} else {
$fail[ $name ] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' );
}
}
}
if ( ! empty( $success ) ) {
@ -3111,7 +3111,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( ! empty( $fail ) ) {
foreach ( $fail as $name => $reason ) {
$errors[] = sprintf( __( 'Unable to remove license from %1$s. Reason: %2$s', 'it-l10n-mainwp-backupbuddy' ), $name, $reason );
}
}
$return['errors'] = $errors;
}
@ -3148,7 +3148,7 @@ class MainWP_Child_Back_Up_Buddy {
$message = sprintf( __( 'An unknown error relating to the %1$s product occurred. Please contact iThemes support. Error details: %2$s', 'it-l10n-mainwp-backupbuddy' ), $package_name, $error->get_error_message() . " ($code)" );
} else {
$message = sprintf( __( 'An unknown error occurred. Please contact iThemes support. Error details: %s', 'it-l10n-mainwp-backupbuddy' ), $error->get_error_message() . " ($code)" );
}
}
}
return $message;

View file

@ -19,7 +19,7 @@
class MainWP_Child_Back_Up_Wordpress {
public static $instance = null;
public $is_plugin_installed = false;
public $is_plugin_installed = false;
static function Instance() {
if ( null === self::$instance ) {
self::$instance = new MainWP_Child_Back_Up_Wordpress();
@ -28,48 +28,48 @@ class MainWP_Child_Back_Up_Wordpress {
return self::$instance;
}
public function __construct() {
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
$this->is_plugin_installed = true;
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
$this->is_plugin_installed = true;
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
}
}
}
public function init() {
if ( version_compare( phpversion(), '5.3', '<' ) ) {
return;
}
if ( version_compare( phpversion(), '5.3', '<' ) ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
}
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
if ( get_option( 'mainwp_backupwordpress_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
}
}
function hide_update_notice( $slugs ) {
$slugs[] = 'backupwordpress/backupwordpress.php';
return $slugs;
}
function hide_update_notice( $slugs ) {
$slugs[] = 'backupwordpress/backupwordpress.php';
return $slugs;
}
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( isset( $value->response['backupwordpress/backupwordpress.php'] ) ) {
unset( $value->response['backupwordpress/backupwordpress.php'] );
}
@ -125,7 +125,7 @@ class MainWP_Child_Back_Up_Wordpress {
case 'exclude_remove_rule':
$information = $this->hmbkp_remove_exclude_rule();
break;
case 'general_exclude_add_rule':
case 'general_exclude_add_rule':
$information = $this->general_exclude_add_rule();
break;
}
@ -150,38 +150,38 @@ class MainWP_Child_Back_Up_Wordpress {
return $schedule_id;
}
// ok
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
try {
$information['syncBackUpWordPress'] = $this->get_sync_data();
} catch ( Exception $e ) {
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
try {
$information['syncBackUpWordPress'] = $this->get_sync_data();
} catch ( Exception $e ) {
}
}
}
}
return $information;
}
// ok
// ok
private function get_sync_data() {
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
$backups_time = array();
if ( is_array($schedules) && count($schedules) ) {
$check = current($schedules);
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
if ( is_array($schedules) && count($schedules) ) {
$check = current($schedules);
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
foreach ( $schedules as $sche ) {
$existing_backup = $sche->get_backups();
if ( ! empty( $existing_backup ) ) {
$backups_time = array_merge( $backups_time, array_keys( $existing_backup ) );
}
}
}
foreach ( $schedules as $sche ) {
$existing_backup = $sche->get_backups();
if ( ! empty( $existing_backup ) ) {
$backups_time = array_merge( $backups_time, array_keys( $existing_backup ) );
}
}
}
$lasttime_backup = 0;
if ( ! empty( $backups_time ) ) {
@ -193,53 +193,53 @@ class MainWP_Child_Back_Up_Wordpress {
return $return;
}
function do_site_stats() {
if ( has_action('mainwp_child_reports_log') ) {
do_action( 'mainwp_child_reports_log', 'backupwordpress');
} else {
$this->do_reports_log('backupwordpress');
}
}
function do_site_stats() {
if ( has_action('mainwp_child_reports_log') ) {
do_action( 'mainwp_child_reports_log', 'backupwordpress');
} else {
$this->do_reports_log('backupwordpress');
}
}
// ok
public function do_reports_log( $ext = '' ) {
if ( $ext !== 'backupwordpress' ) {
// ok
public function do_reports_log( $ext = '' ) {
if ( $ext !== 'backupwordpress' ) {
return;
}
if ( ! $this->is_plugin_installed ) {
}
if ( ! $this->is_plugin_installed ) {
return;
}
}
try {
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ));
try {
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ));
// Refresh the schedules from the database to make sure we have the latest changes
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
if ( is_array($schedules) && count($schedules) > 0 ) {
$check = current($schedules);
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
// Refresh the schedules from the database to make sure we have the latest changes
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
if ( is_array($schedules) && count($schedules) > 0 ) {
$check = current($schedules);
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
foreach ( $schedules as $schedule ) {
foreach ( $schedule->get_backups() as $file ) {
$backup_type = $schedule->get_type();
$message = 'BackupWordpres backup ' . $backup_type . ' finished';
$destination = 'N/A';
if ( file_exists( $file ) ) {
$date = @filemtime( $file );
if ( ! empty( $date ) ) {
do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date );
MainWP_Helper::update_lasttime_backup('backupwordpress', $date); // to support backup before update feature
}
}
}
}
}
} catch ( Exception $e ) {
foreach ( $schedules as $schedule ) {
foreach ( $schedule->get_backups() as $file ) {
$backup_type = $schedule->get_type();
$message = 'BackupWordpres backup ' . $backup_type . ' finished';
$destination = 'N/A';
if ( file_exists( $file ) ) {
$date = @filemtime( $file );
if ( ! empty( $date ) ) {
do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date );
MainWP_Helper::update_lasttime_backup('backupwordpress', $date); // to support backup before update feature
}
}
}
}
}
} catch ( Exception $e ) {
}
}
}
}
function set_showhide() {
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
@ -327,7 +327,7 @@ class MainWP_Child_Back_Up_Wordpress {
$task->schedule();
} else {
return array( 'error' => __('Error while trying to trigger the schedule', 'mainwp-child') );
}
}
return array( 'result' => 'SUCCESS' );
}
@ -402,7 +402,7 @@ class MainWP_Child_Back_Up_Wordpress {
$backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() );
} else {
$backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() );
}
}
$information['backups_path'] = $backups_path;
$information['send_back_schedules'] = $send_back_schedules;
@ -462,7 +462,7 @@ class MainWP_Child_Back_Up_Wordpress {
<tbody>
<?php
if ( $schedule->get_backups() ) {
if ( $schedule->get_backups() ) {
$schedule->delete_old_backups();
@ -480,7 +480,7 @@ class MainWP_Child_Back_Up_Wordpress {
<tr>
<td class="hmbkp-no-backups"
colspan="4"><?php esc_html_e( 'This is where your backups will appear once you have some.', 'mainwp-backupwordpress-extension' ); ?></td>
colspan="4"><?php esc_html_e( 'This is where your backups will appear once you have some.', 'mainwp-backupwordpress-extension' ); ?></td>
</tr>
<?php } ?>
@ -532,14 +532,14 @@ class MainWP_Child_Back_Up_Wordpress {
<td>
<?php
if ( function_exists('hmbkp_is_path_accessible') ) {
if ( function_exists('hmbkp_is_path_accessible') ) {
if ( hmbkp_is_path_accessible( hmbkp_path() ) ) {
?>
<a href="#"
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
<?php
};
};
} elseif ( function_exists('HM\BackUpWordPress\is_path_accessible') ) {
if ( HM\BackUpWordPress\is_path_accessible(HM\BackUpWordPress\Path::get_path()) ) {
?>
@ -547,7 +547,7 @@ class MainWP_Child_Back_Up_Wordpress {
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
<?php
};
};
}
?>
@ -560,7 +560,7 @@ class MainWP_Child_Back_Up_Wordpress {
</tr>
<?php
}
}
function get_excluded( $browse_dir = null ) {
@ -629,7 +629,7 @@ class MainWP_Child_Back_Up_Wordpress {
$is_default_rule = ( in_array( $exclude, $excludes->get_default_excludes() ) ) || ( HM\BackUpWordPress\Path::get_path() === trailingslashit( HM\BackUpWordPress\Path::get_root() ) . untrailingslashit( $exclude ) );
} else {
$is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) );
}
}
if ( $is_default_rule ) :
?>
@ -686,7 +686,7 @@ class MainWP_Child_Back_Up_Wordpress {
if ( function_exists('HM\BackUpWordPress\list_directory_by_total_filesize') ) {
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes );
}
}
} else {
$files = $schedule->list_directory_by_total_filesize( $directory );
$exclude_string = $schedule->backup->exclude_string( 'regex' );
@ -702,7 +702,7 @@ class MainWP_Child_Back_Up_Wordpress {
<th scope="col"><?php esc_html_e( 'Name', 'backupwordpress' ); ?></th>
<th scope="col" class="column-format"><?php esc_html_e( 'Size', 'backupwordpress' ); ?></th>
<th scope="col"
class="column-format"><?php esc_html_e( 'Permissions', 'backupwordpress' ); ?></th>
class="column-format"><?php esc_html_e( 'Permissions', 'backupwordpress' ); ?></th>
<th scope="col" class="column-format"><?php esc_html_e( 'Type', 'backupwordpress' ); ?></th>
<th scope="col" class="column-format"><?php esc_html_e( 'Status', 'backupwordpress' ); ?></th>
</tr>
@ -716,7 +716,7 @@ class MainWP_Child_Back_Up_Wordpress {
<th scope="col">
<?php
if ( $root_dir !== $directory ) {
if ( $root_dir !== $directory ) {
// echo esc_url( remove_query_arg( 'hmbkp_directory_browse' ) );
?>
<a href="#"
@ -724,7 +724,7 @@ class MainWP_Child_Back_Up_Wordpress {
<code>/</code>
<?php
$parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
$parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
foreach ( $parents as $directory_basename ) {
?>
@ -810,7 +810,7 @@ class MainWP_Child_Back_Up_Wordpress {
<tbody>
<?php
foreach ( $files as $size => $file ) {
foreach ( $files as $size => $file ) {
$is_excluded = $is_unreadable = false;
@ -829,7 +829,7 @@ class MainWP_Child_Back_Up_Wordpress {
if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) {
$is_unreadable = true;
}
?>
?>
<tr>
@ -858,7 +858,7 @@ class MainWP_Child_Back_Up_Wordpress {
?>
<code class="strikethrough"
title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
<?php } elseif ( $file->isFile() ) { ?>
@ -872,13 +872,13 @@ class MainWP_Child_Back_Up_Wordpress {
<?php
}
}
} else {
if ( $is_unreadable ) {
?>
<code class="strikethrough"
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
<?php } elseif ( $file->isFile() ) { ?>
@ -886,7 +886,7 @@ class MainWP_Child_Back_Up_Wordpress {
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
<?php
} elseif ( $file->isDir() ) {
} elseif ( $file->isDir() ) {
// echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
?>
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
@ -894,7 +894,7 @@ class MainWP_Child_Back_Up_Wordpress {
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( $file->getPathname() ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
<?php
}
}
}
?>
@ -921,7 +921,7 @@ class MainWP_Child_Back_Up_Wordpress {
if ( ! $size ) {
$size = '0 B';
}
?>
?>
<code>
@ -943,7 +943,7 @@ class MainWP_Child_Back_Up_Wordpress {
<code>--</code>
<?php
}
}
endif;
?>
@ -961,7 +961,7 @@ class MainWP_Child_Back_Up_Wordpress {
title="<?php echo esc_attr( wp_normalize_path( $file->GetRealPath() ) ); ?>"><?php esc_html_e( 'Symlink', 'backupwordpress' ); ?></span>
<?php
elseif ( $file->isDir() ) :
elseif ( $file->isDir() ) :
esc_html_e( 'Folder', 'backupwordpress' );
@ -1081,7 +1081,7 @@ class MainWP_Child_Back_Up_Wordpress {
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
} else {
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
}
}
$schedule->save();
@ -1100,56 +1100,56 @@ class MainWP_Child_Back_Up_Wordpress {
}
function general_exclude_add_rule() {
function general_exclude_add_rule() {
$sch_id = $this->check_schedule();
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
$exclude_paths = urldecode( $_POST['exclude_paths'] );
$exclude_paths = explode("\n", $exclude_paths);
if ( is_array($exclude_paths) && count($exclude_paths) > 0 ) {
foreach ( $exclude_paths as $excl_rule ) {
$excl_rule = trim($excl_rule);
$excl_rule = trim($excl_rule, '/');
$exclude_paths = urldecode( $_POST['exclude_paths'] );
$exclude_paths = explode("\n", $exclude_paths);
if ( is_array($exclude_paths) && count($exclude_paths) > 0 ) {
foreach ( $exclude_paths as $excl_rule ) {
$excl_rule = trim($excl_rule);
$excl_rule = trim($excl_rule, '/');
if ( empty($excl_rule) ) {
continue;
}
if ( empty($excl_rule) ) {
continue;
}
$exclude_rule = ABSPATH . $excl_rule;
$path = realpath($exclude_rule);
// If it exist
if ( $path !== false ) {
$schedule->set_excludes( $exclude_rule, true );
$schedule->save();
}
}
}
$exclude_rule = ABSPATH . $excl_rule;
$path = realpath($exclude_rule);
// If it exist
if ( $path !== false ) {
$schedule->set_excludes( $exclude_rule, true );
$schedule->save();
}
}
}
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
$un_exclude_paths = explode("\n", $un_exclude_paths);
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
$un_exclude_paths = explode("\n", $un_exclude_paths);
if ( is_array($un_exclude_paths) && count(get_user_excludes) > 0 ) {
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
$exclude_rule_to_remove = trim($exclude_rule_to_remove);
$exclude_rule_to_remove = trim($exclude_rule_to_remove, '/');
if ( is_array($un_exclude_paths) && count(get_user_excludes) > 0 ) {
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
$exclude_rule_to_remove = trim($exclude_rule_to_remove);
$exclude_rule_to_remove = trim($exclude_rule_to_remove, '/');
if ( empty($exclude_rule_to_remove) ) {
continue;
}
$excludes = $schedule->get_excludes();
$excludes = $schedule->get_excludes();
if ( method_exists($excludes, 'get_user_excludes') ) {
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
} else {
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
}
$schedule->save();
}
}
$schedule->save();
}
}
return array( 'result' => 'SUCCESS' );
}
return array( 'result' => 'SUCCESS' );
}
function update_schedule() {
@ -1187,7 +1187,7 @@ class MainWP_Child_Back_Up_Wordpress {
}
update_option( 'hmbkp_schedule_' . $sch_id, $options );
delete_transient( 'hmbkp_schedules' );
delete_transient( 'hmbkp_schedules' );
$out['result'] = 'SUCCESS';
} else {
$out['result'] = 'NOTCHANGE';
@ -1222,7 +1222,7 @@ class MainWP_Child_Back_Up_Wordpress {
foreach ( $schedules as $sch_id => $sch ) {
if ( empty($sch_id) || ! isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) {
continue;
}
}
$options = $sch['options'];
$filter_opts = array(
'type',
@ -1258,7 +1258,7 @@ class MainWP_Child_Back_Up_Wordpress {
}
$out['result'] = 'SUCCESS';
}
delete_transient( 'hmbkp_schedules' );
delete_transient( 'hmbkp_schedules' );
return $out;
}

View file

@ -68,42 +68,42 @@ class MainWP_Child_Back_WP_Up {
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
try {
try {
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/Pro/class-pro.php';
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/Pro/class-pro.php';
// to fix
if ( ! file_exists( $file_path2 ) ) {
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
}
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once $file_path1;
require_once $file_path2;
$this->is_backwpup_installed = true;
$this->is_backwpup_pro = true;
} elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
MainWP_Helper::check_files_exists(array( $file_path ));
require_once $file_path;
$this->is_backwpup_installed = true;
}
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once $file_path1;
require_once $file_path2;
$this->is_backwpup_installed = true;
$this->is_backwpup_pro = true;
} elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
MainWP_Helper::check_files_exists(array( $file_path ));
require_once $file_path;
$this->is_backwpup_installed = true;
}
if ( $this->is_backwpup_installed ) {
MainWP_Helper::check_classes_exists('BackWPup');
MainWP_Helper::check_methods('get_instance');
BackWPup::get_instance();
if ( $this->is_backwpup_installed ) {
MainWP_Helper::check_classes_exists('BackWPup');
MainWP_Helper::check_methods('get_instance');
BackWPup::get_instance();
// add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
// add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
add_action( 'admin_init', array( $this, 'init_download_backup' ) );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
} catch ( Exception $e ) {
// do not exit()
$this->is_backwpup_installed = false;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
} catch ( Exception $e ) {
// do not exit()
$this->is_backwpup_installed = false;
}
}
public function action() {
@ -220,7 +220,7 @@ class MainWP_Child_Back_WP_Up {
if ( ! $this->is_backwpup_installed ) {
return;
}
}
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@ -237,120 +237,120 @@ class MainWP_Child_Back_WP_Up {
$this->do_reports_log('backwpup');
}
}
// ok
// ok
public function do_reports_log( $ext = '' ) {
if ( $ext !== 'backwpup' ) {
return;
}
}
if ( ! $this->is_backwpup_installed ) {
return;
}
}
try {
try {
MainWP_Helper::check_classes_exists(array( 'BackWPup_File', 'BackWPup_Job' ));
MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' ));
MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' ));
MainWP_Helper::check_classes_exists(array( 'BackWPup_File', 'BackWPup_Job' ));
MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' ));
MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' ));
$lasttime_logged = MainWP_Helper::get_lasttime_backup('backwpup');
$lasttime_logged = MainWP_Helper::get_lasttime_backup('backwpup');
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_folder = untrailingslashit( $log_folder );
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_folder = untrailingslashit( $log_folder );
// load logs
$logfiles = array();
if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) {
while ( ( $file = readdir( $dir ) ) !== false ) {
$log_file = $log_folder . '/' . $file;
if ( is_file( $log_file ) && is_readable( $log_file ) && false !== strpos( $file, 'backwpup_log_' ) && false !== strpos( $file, '.html' ) ) {
$logfiles[] = $file;
}
}
closedir( $dir );
}
// load logs
$logfiles = array();
if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) {
while ( ( $file = readdir( $dir ) ) !== false ) {
$log_file = $log_folder . '/' . $file;
if ( is_file( $log_file ) && is_readable( $log_file ) && false !== strpos( $file, 'backwpup_log_' ) && false !== strpos( $file, '.html' ) ) {
$logfiles[] = $file;
}
}
closedir( $dir );
}
$log_items = array();
foreach ( $logfiles as $mtime => $logfile ) {
$meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile );
if ( ! isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged ) {
continue;
}
$log_items = array();
foreach ( $logfiles as $mtime => $logfile ) {
$meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile );
if ( ! isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged ) {
continue;
}
if ( isset($meta['errors']) && ! empty($meta['errors']) ) {
continue; // do not logging backups have errors
}
if ( isset($meta['errors']) && ! empty($meta['errors']) ) {
continue; // do not logging backups have errors
}
$log_items[ $mtime ] = $meta;
$log_items[ $mtime ]['file'] = $logfile;
}
$log_items[ $mtime ] = $meta;
$log_items[ $mtime ]['file'] = $logfile;
}
if ( ! empty( $log_items ) ) {
$job_types = array(
'DBDUMP' => __('Database backup', 'mainwp-child'),
'FILE' => __('File backup', 'mainwp-child'),
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
'DBCHECK' => __('Check database tables', 'mainwp-child'),
);
if ( ! empty( $log_items ) ) {
$job_types = array(
'DBDUMP' => __('Database backup', 'mainwp-child'),
'FILE' => __('File backup', 'mainwp-child'),
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
'DBCHECK' => __('Check database tables', 'mainwp-child'),
);
$new_lasttime_logged = $lasttime_logged;
$new_lasttime_logged = $lasttime_logged;
foreach ( $log_items as $log ) {
$backup_time = $log['logtime'];
if ( $backup_time < $lasttime_logged ) {
// small than last backup time then skip
continue;
}
$job_job_types = explode('+', $log['type']);
$backup_type = '';
foreach ( $job_job_types as $typeid ) {
if ( isset( $job_types[ $typeid ] ) ) {
$backup_type .= ' + ' . $job_types[ $typeid ];
}
}
foreach ( $log_items as $log ) {
$backup_time = $log['logtime'];
if ( $backup_time < $lasttime_logged ) {
// small than last backup time then skip
continue;
}
$job_job_types = explode('+', $log['type']);
$backup_type = '';
foreach ( $job_job_types as $typeid ) {
if ( isset( $job_types[ $typeid ] ) ) {
$backup_type .= ' + ' . $job_types[ $typeid ];
}
}
if ( empty($backup_type) ) {
continue;
} else {
$backup_type = ltrim($backup_type, ' + ');
}
$message = 'BackWPup backup finished (' . $backup_type . ')';
do_action( 'mainwp_reports_backwpup_backup', $message, $backup_type, $backup_time );
if ( empty($backup_type) ) {
continue;
} else {
$backup_type = ltrim($backup_type, ' + ');
}
$message = 'BackWPup backup finished (' . $backup_type . ')';
do_action( 'mainwp_reports_backwpup_backup', $message, $backup_type, $backup_time );
if ( $new_lasttime_logged < $backup_time ) {
$new_lasttime_logged = $backup_time;
}
}
if ( $new_lasttime_logged < $backup_time ) {
$new_lasttime_logged = $backup_time;
}
}
if ( $new_lasttime_logged > $lasttime_logged ) {
MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature
}
}
} catch ( Exception $ex ) {
if ( $new_lasttime_logged > $lasttime_logged ) {
MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature
}
}
} catch ( Exception $ex ) {
}
}
}
// ok
function syncOthersData( $information, $data = array() ) {
// ok
function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
try {
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
$information['syncBackwpupData'] = array(
'lastbackup' => $lastbackup,
);
} catch ( Exception $e ) {
try {
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
$information['syncBackwpupData'] = array(
'lastbackup' => $lastbackup,
);
} catch ( Exception $e ) {
}
}
}
return $information;
}
return $information;
}
function get_destinations_list() {
MainWP_Helper::check_classes_exists(array( 'BackWPup', 'BackWPup_Option' ));
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
MainWP_Helper::check_classes_exists(array( 'BackWPup', 'BackWPup_Option' ));
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
$jobdest = array();
$jobids = BackWPup_Option::get_job_ids();
@ -366,12 +366,12 @@ class MainWP_Child_Back_WP_Up {
}
$dest_class = BackWPup::get_destination( $dest );
if ( $dest_class && method_exists($dest_class, 'file_get_list') ) {
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $can_do_dest ) ) {
$jobdest[] = $jobid . '_' . $dest;
}
}
if ( $dest_class && method_exists($dest_class, 'file_get_list') ) {
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $can_do_dest ) ) {
$jobdest[] = $jobid . '_' . $dest;
}
}
}
}
@ -471,7 +471,7 @@ class MainWP_Child_Back_WP_Up {
echo '<tr><td>' . __( 'Log folder:', 'backwpup' ) . '</td><td>';
$log_folder = BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) );
$log_folder = BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) );
if ( ! is_dir( $log_folder ) ) {
echo sprintf( __( 'Logs folder %s not exist.', 'backwpup' ), esc_html( $log_folder ) );
@ -549,7 +549,7 @@ class MainWP_Child_Back_WP_Up {
return array( 'error' => __( 'Missing logfile.', $this->plugin_translate ) );
}
$dir = get_site_option( 'backwpup_cfg_logfolder' );
$dir = get_site_option( 'backwpup_cfg_logfolder' );
$dir = BackWPup_File::get_absolute_path( $dir );
foreach ( $_POST['settings']['logfile'] as $logfile ) {
@ -628,7 +628,7 @@ class MainWP_Child_Back_WP_Up {
return array( 'error' => __( 'Missing logfile.', $this->plugin_translate ) );
}
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_file = $log_folder . basename( $_POST['settings']['logfile'] );
@ -674,9 +674,9 @@ class MainWP_Child_Back_WP_Up {
switch ( $type ) {
case 'logs':
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_folder = untrailingslashit( $log_folder );
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
$log_folder = untrailingslashit( $log_folder );
if ( ! is_dir( $log_folder ) ) {
return array(
@ -713,7 +713,7 @@ class MainWP_Child_Back_WP_Up {
foreach ( $items as $item ) {
$temp_single_item = $item;
$temp_single_item['dest'] = $jobid . '_' . $dest;
$temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item['time'], true ), date_i18n( get_option( 'time_format' ), $temp_single_item['time'], true ) );
$temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item['time'], true ), date_i18n( get_option( 'time_format' ), $temp_single_item['time'], true ) );
$output->items[] = $temp_single_item;
}
}
@ -814,10 +814,10 @@ class MainWP_Child_Back_WP_Up {
?>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
var downloadLink = document.querySelector( 'a.backup-download-link[data-jobid="<?php echo intval($_GET['download_click_id']); ?>"' );
var downloadLink = document.querySelector( 'a.backup-download-link[data-jobid="<?php echo intval($_GET['download_click_id']); ?>"' );
if (typeof(downloadLink) !== 'undefined' && downloadLink !== null) {
downloadLink.click();
}
downloadLink.click();
}
});
</script>
<?php
@ -1459,7 +1459,7 @@ class MainWP_Child_Back_WP_Up {
BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'backwpup' ) . '</a> | <a href="' . $url['url'] . '">' . __( 'Run now', 'backwpup' ) . '</a>' );
}
} elseif ( $settings['tab'] == 'dest-DROPBOX' ) {
unset($settings['value']); // do not save dropbox settings
unset($settings['value']); // do not save dropbox settings
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
} else {
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
@ -1536,7 +1536,7 @@ class MainWP_Child_Back_WP_Up {
update_site_option( 'backwpup_messages', array() );
$settings_views = array();
$settings_views = array();
$settings_updaters = array();
$backwpup = new BackWPup_Page_Settings($settings_views, $settings_updaters);

View file

@ -17,62 +17,62 @@ class MainWP_Child_Branding {
$this->child_plugin_dir = dirname( dirname( __FILE__ ) );
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
add_filter( 'mainwp_child_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 3 );
$this->child_branding_options = $this->init_options();
$this->child_branding_options = $this->init_options();
}
function init_options() {
function init_options() {
$opts = get_option( 'mainwp_child_branding_settings' );
$opts = get_option( 'mainwp_child_branding_settings' );
if ( ! is_array( $opts ) ) {
// compatible with old code
$opts = array();
if ( ! is_array( $opts ) ) {
// compatible with old code
$opts = array();
$label = get_option( 'mainwp_branding_button_contact_label' );
if ( ! empty( $label ) ) {
$label = stripslashes( $label );
}
$label = get_option( 'mainwp_branding_button_contact_label' );
if ( ! empty( $label ) ) {
$label = stripslashes( $label );
}
$opts['contact_label'] = $label;
$opts['extra_settings'] = get_option( 'mainwp_branding_extra_settings' );
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts );
}
$opts['contact_label'] = $label;
$opts['extra_settings'] = get_option( 'mainwp_branding_extra_settings' );
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts );
}
if ( ! isset($opts['contact_label']) || empty($opts['contact_label']) ) {
$opts['contact_label'] = 'Contact Support';
}
if ( ! isset($opts['contact_label']) || empty($opts['contact_label']) ) {
$opts['contact_label'] = 'Contact Support';
}
$disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
$preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
$cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
$disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
$preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
$cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
$opts['cancelled_branding'] = $cancelled_branding;
$opts['branding_preserve_title'] = '';
$opts['cancelled_branding'] = $cancelled_branding;
$opts['branding_preserve_title'] = '';
if ( ! $cancelled_branding ) {
if ( isset($opts['branding_header']) ) {
$branding_header = $opts['branding_header'];
if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) {
$opts['branding_preserve_title'] = stripslashes( $branding_header['name'] );
}
}
if ( ! $cancelled_branding ) {
if ( isset($opts['branding_header']) ) {
$branding_header = $opts['branding_header'];
if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) {
$opts['branding_preserve_title'] = stripslashes( $branding_header['name'] );
}
}
}
$opts = apply_filters( 'mainwp_child_branding_init_options', $opts );
return $opts;
}
return $opts;
}
function get_extra_options() {
$extra = array();
if ( is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings']) ) {
$extra = $this->child_branding_options['extra_settings'];
if ( ! is_array($extra) ) {
$extra = array();
}
}
function get_extra_options() {
$extra = array();
if ( is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings']) ) {
$extra = $this->child_branding_options['extra_settings'];
if ( ! is_array($extra) ) {
$extra = array();
}
}
return $extra;
}
return $extra;
}
public function plugin_row_meta( $plugin_meta, $plugin_file, $child_plugin_slug ) {
if ( $child_plugin_slug !== $plugin_file ) {
@ -96,7 +96,7 @@ class MainWP_Child_Branding {
}
public function child_deactivation() {
// will remove later
// will remove later
$dell_all = array(
'mainwp_branding_disable_change',
'mainwp_branding_disable_switching_theme',
@ -123,34 +123,34 @@ class MainWP_Child_Branding {
delete_option( $opt );
}
$brandingOptions_empty = array(
'hide',
'disable_change',
'disable_switching_theme',
'show_support',
'support_email',
'support_message',
'remove_restore',
'remove_setting',
'remove_server_info',
'remove_wp_tools',
'remove_wp_setting',
'remove_permalink',
// 'branding_header', // don't remove header
'contact_label',
'email_message',
'message_return_sender',
'submit_button_title',
'extra_settings',
'branding_ext_enabled',
);
$brandingOptions_empty = array(
'hide',
'disable_change',
'disable_switching_theme',
'show_support',
'support_email',
'support_message',
'remove_restore',
'remove_setting',
'remove_server_info',
'remove_wp_tools',
'remove_wp_setting',
'remove_permalink',
// 'branding_header', // don't remove header
'contact_label',
'email_message',
'message_return_sender',
'submit_button_title',
'extra_settings',
'branding_ext_enabled',
);
foreach ( $brandingOptions_empty as $opt ) {
if ( isset($this->child_branding_options[ $opt ]) ) {
$this->child_branding_options[ $opt ] = '';
}
}
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
foreach ( $brandingOptions_empty as $opt ) {
if ( isset($this->child_branding_options[ $opt ]) ) {
$this->child_branding_options[ $opt ] = '';
}
}
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
}
@ -171,11 +171,11 @@ class MainWP_Child_Branding {
return $information;
}
$current_settings = $this->child_branding_options;
$current_extra_setting = $this->child_branding_options['extra_settings'];
$current_settings = $this->child_branding_options;
$current_extra_setting = $this->child_branding_options['extra_settings'];
// MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
$current_settings['branding_ext_enabled'] = 'Y';
$current_settings['branding_ext_enabled'] = 'Y';
$header = array(
'name' => $settings['child_plugin_name'],
@ -204,23 +204,23 @@ class MainWP_Child_Branding {
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
// }
$current_settings['preserve_branding'] = $settings['child_preserve_branding'];
$current_settings['branding_header'] = $header;
$current_settings['support_email'] = $settings['child_support_email'];
$current_settings['support_message'] = $settings['child_support_message'];
$current_settings['remove_restore'] = $settings['child_remove_restore'];
$current_settings['remove_setting'] = $settings['child_remove_setting'];
$current_settings['remove_server_info'] = $settings['child_remove_server_info'];
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0;
$current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
$current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
$current_settings['remove_permalink'] = $settings['child_remove_permalink'];
$current_settings['contact_label'] = $settings['child_button_contact_label'];
$current_settings['email_message'] = $settings['child_send_email_message'];
$current_settings['return_sender'] = $settings['child_message_return_sender'];
$current_settings['submit_button_title'] = $settings['child_submit_button_title'];
$current_settings['preserve_branding'] = $settings['child_preserve_branding'];
$current_settings['branding_header'] = $header;
$current_settings['support_email'] = $settings['child_support_email'];
$current_settings['support_message'] = $settings['child_support_message'];
$current_settings['remove_restore'] = $settings['child_remove_restore'];
$current_settings['remove_setting'] = $settings['child_remove_setting'];
$current_settings['remove_server_info'] = $settings['child_remove_server_info'];
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0;
$current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
$current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
$current_settings['remove_permalink'] = $settings['child_remove_permalink'];
$current_settings['contact_label'] = $settings['child_button_contact_label'];
$current_settings['email_message'] = $settings['child_send_email_message'];
$current_settings['return_sender'] = $settings['child_message_return_sender'];
$current_settings['submit_button_title'] = $settings['child_submit_button_title'];
if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
$current_settings['disable_wp_branding'] = $settings['child_disable_wp_branding'];
}
@ -314,9 +314,9 @@ class MainWP_Child_Branding {
}
// MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
$current_settings['extra_settings'] = $extra_setting;
$current_settings['extra_settings'] = $extra_setting;
// keep it to compatible with old version of child reports plugin
// keep it to compatible with old version of child reports plugin
if ( $settings['child_plugin_hide'] ) {
MainWP_Helper::update_option( 'mainwp_branding_child_hide', 'T', 'yes' );
} else {
@ -341,12 +341,12 @@ class MainWP_Child_Branding {
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
// }
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
$current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
$current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
$current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
$current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $current_settings );
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $current_settings );
$information['result'] = 'SUCCESS';
@ -356,10 +356,10 @@ class MainWP_Child_Branding {
static function uploadImage( $img_url ) {
include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
global $mainWPChild;
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
// Download $img_url
$temporary_file = download_url( $img_url );
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
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() );
@ -388,30 +388,30 @@ class MainWP_Child_Branding {
$extra_setting = $this->get_extra_options();
// to hide updates notice
if ( is_admin() ) {
// back end
add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
} elseif ( is_user_logged_in() ) {
// front end
add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' ));
}
$opts = $this->child_branding_options;
// to hide updates notice
if ( is_admin() ) {
// back end
add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
} elseif ( is_user_logged_in() ) {
// front end
add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' ));
}
$opts = $this->child_branding_options;
$cancelled_branding = $opts['cancelled_branding'];
if ( $cancelled_branding ) {
return;
}
// enable branding in case child plugin deactive and re-activated
// enable branding in case child plugin deactive and re-activated
add_filter( 'all_plugins', array( $this, 'modify_plugin_header' ) );
if ( $this->is_branding() ) {
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
}
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
return;
}
@ -462,7 +462,7 @@ class MainWP_Child_Branding {
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
// remove_filter( 'update_footer', 'core_update_footer' );
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
}
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
@ -479,19 +479,19 @@ class MainWP_Child_Branding {
remove_action( 'admin_notices', 'update_nag', 3 );
}
// to fix conflict with other plugin
function admin_menu() {
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
if ( $allow_contact ) {; // ok
} elseif ( ! current_user_can( 'administrator' ) ) {
// to fix conflict with other plugin
function admin_menu() {
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
if ( $allow_contact ) {; // ok
} elseif ( ! current_user_can( 'administrator' ) ) {
return false;
}
$extra_setting = $this->get_extra_options();
$extra_setting = $this->get_extra_options();
if ( empty ( $extra_setting ) ) {
return false;
}
$opts = $this->child_branding_options;
$opts = $this->child_branding_options;
if ( 'T' === $opts['show_support'] ) {
$title = $opts['contact_label'];
@ -641,7 +641,7 @@ class MainWP_Child_Branding {
}
});
</script>
<?php
<?php
}
function core_update_footer() {
@ -807,16 +807,16 @@ class MainWP_Child_Branding {
public function send_support_mail() {
$email = $this->child_branding_options['support_email'];
$sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
$from = trim($_POST['mainwp_branding_contact_send_from']);
$from = trim($_POST['mainwp_branding_contact_send_from']);
$subject = ! empty( $sub ) ? $sub : 'MainWP - Support Contact';
$content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
$mail = $headers = '';
$mail = $headers = '';
if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
global $current_user;
$headers .= "Content-Type: text/html;charset=utf-8\r\n";
if ( ! empty($from) ) {
$headers .= 'From: "' . $from . '" <' . $from . ">\r\n";
}
if ( ! empty($from) ) {
$headers .= 'From: "' . $from . '" <' . $from . ">\r\n";
}
$mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
$mail .= '<p>Sent from WordPress page: ' . ( ! empty( $_POST['mainwp_branding_send_from_page'] ) ? "<a href='" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "'>" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "</a></p>\r\n\r\n" : '' );
$mail .= '<p>Client Email: ' . $current_user->user_email . " </p>\r\n\r\n";
@ -833,7 +833,7 @@ class MainWP_Child_Branding {
}
function contact_support() {
global $current_user;
global $current_user;
?>
<style>
.mainwp_info-box-yellow {
@ -848,7 +848,7 @@ class MainWP_Child_Branding {
}
</style>
<?php
$opts = $this->child_branding_options;
$opts = $this->child_branding_options;
if ( isset( $_POST['submit'] ) ) {
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], '_contactNonce' ) ) {
@ -872,7 +872,7 @@ class MainWP_Child_Branding {
?>
<div
class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . '&nbsp;&nbsp' . $back_link; ?></div>
<?php
<?php
} else {
$from_page = '';
if ( isset( $_GET['from_page'] ) ) {
@ -885,7 +885,7 @@ class MainWP_Child_Branding {
$support_message = $opts['support_message'];
$support_message = nl2br( stripslashes( $support_message ) );
$from_email = $current_user ? $current_user->user_email : '';
$from_email = $current_user ? $current_user->user_email : '';
?>
<form action="" method="post">
<div style="width: 99%;">
@ -895,8 +895,8 @@ class MainWP_Child_Branding {
<p><?php echo wp_kses_post( $support_message ); ?></p>
<p><label for="mainwp_branding_contact_message_subject"><?php _e('Subject:', 'mainwp-child'); ?></label><br>
<input type="text" id="mainwp_branding_contact_message_subject" name="mainwp_branding_contact_message_subject" style="width: 650px;"></p>
<p><label for="mainwp_branding_contact_send_from"><?php _e('From:', 'mainwp-child'); ?></label><br>
<input type="text" id="mainwp_branding_contact_send_from" name="mainwp_branding_contact_send_from" style="width: 650px;" value="<?php echo esc_html( $from_email ); ?>"></p>
<p><label for="mainwp_branding_contact_send_from"><?php _e('From:', 'mainwp-child'); ?></label><br>
<input type="text" id="mainwp_branding_contact_send_from" name="mainwp_branding_contact_send_from" style="width: 650px;" value="<?php echo esc_html( $from_email ); ?>"></p>
<div style="max-width: 650px;">
<label for="mainwp_branding_contact_message_content"><?php _e('Your message:', 'mainwp-child'); ?></label><br>
<?php
@ -918,24 +918,24 @@ class MainWP_Child_Branding {
$button_title = ! empty( $button_title ) ? $button_title : __( 'Submit' );
?>
<input id="mainwp-branding-contact-support-submit" type="submit" name="submit"
value="<?php echo esc_attr( $button_title ); ?>"
class="button-primary button" style="float: left"/>
value="<?php echo esc_attr( $button_title ); ?>"
class="button-primary button" style="float: left"/>
</div>
<input type="hidden" name="mainwp_branding_send_from_page"
value="<?php echo esc_url( $from_page ); ?>"/>
value="<?php echo esc_url( $from_page ); ?>"/>
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( '_contactNonce' ) ); ?>"/>
</form>
<?php
}
}
}
/**
* @param WP_Admin_Bar $wp_admin_bar
*/
public function add_support_button_in_top_admin_bar( $wp_admin_bar ) {
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
if ( $allow_contact ) {; // ok
} elseif ( ! current_user_can( 'administrator' ) ) {
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
if ( $allow_contact ) {; // ok
} elseif ( ! current_user_can( 'administrator' ) ) {
return false;
}
@ -961,177 +961,177 @@ class MainWP_Child_Branding {
}
public function is_branding() {
$opts = $this->child_branding_options;
$opts = $this->child_branding_options;
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
return false;
}
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
return false;
}
$is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
$cancelled_branding = $opts['cancelled_branding'];
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
$is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
$cancelled_branding = $opts['cancelled_branding'];
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
if ( $cancelled_branding ) {
return false;
}
// hide
if ( 'T' === $is_hide ) {
return true;
}
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
return true;
}
return false;
if ( $cancelled_branding ) {
return false;
}
// hide
if ( 'T' === $is_hide ) {
return true;
}
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
return true;
}
return false;
}
public function get_branding_title() {
public function get_branding_title() {
if ( $this->is_branding() ) {
$branding_header = $this->child_branding_options['branding_header'];
$branding_header = $this->child_branding_options['branding_header'];
return $branding_header['name'];
}
return '';
}
public function get_branding_options() {
return $this->child_branding_options;
}
public function get_branding_options() {
return $this->child_branding_options;
}
public function save_branding_options( $name, $val ) {
$this->child_branding_options[ $name ] = $val;
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
}
public function save_branding_options( $name, $val ) {
$this->child_branding_options[ $name ] = $val;
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
}
public function after_admin_bar_render() {
public function after_admin_bar_render() {
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
if ( ! is_array($hide_slugs) ) {
$hide_slugs = array();
}
if ( ! is_array($hide_slugs) ) {
$hide_slugs = array();
}
if ( count($hide_slugs) == 0 ) {
return;
}
if ( count($hide_slugs) == 0 ) {
return;
}
if ( ! function_exists('get_plugin_updates') ) {
include_once ABSPATH . '/wp-admin/includes/update.php';
}
if ( ! function_exists('get_plugin_updates') ) {
include_once ABSPATH . '/wp-admin/includes/update.php';
}
$count_hide = 0;
$count_hide = 0;
$updates = get_plugin_updates();
if ( is_array($updates) ) {
foreach ( $updates as $slug => $data ) {
if ( in_array($slug, $hide_slugs) ) {
$count_hide++;
}
}
}
$updates = get_plugin_updates();
if ( is_array($updates) ) {
foreach ( $updates as $slug => $data ) {
if ( in_array($slug, $hide_slugs) ) {
$count_hide++;
}
}
}
if ( $count_hide == 0 ) {
return;
}
// js for front end
?>
<script type="text/javascript">
var mainwpCountHide = <?php echo esc_attr($count_hide); ?>;
if ( $count_hide == 0 ) {
return;
}
// js for front end
?>
<script type="text/javascript">
var mainwpCountHide = <?php echo esc_attr($count_hide); ?>;
document.addEventListener("DOMContentLoaded", function(event) {
var $adminBarUpdates = document.querySelector( '#wp-admin-bar-updates .ab-label' ),
itemCount;
var $adminBarUpdates = document.querySelector( '#wp-admin-bar-updates .ab-label' ),
itemCount;
if (typeof($adminBarUpdates) !== 'undefined' && $adminBarUpdates !== null) {
itemCount = $adminBarUpdates.textContent;
itemCount = parseInt(itemCount);
if (typeof($adminBarUpdates) !== 'undefined' && $adminBarUpdates !== null) {
itemCount = $adminBarUpdates.textContent;
itemCount = parseInt(itemCount);
itemCount -= mainwpCountHide;
if (itemCount < 0)
itemCount = 0;
itemCount -= mainwpCountHide;
if (itemCount < 0)
itemCount = 0;
$adminBarUpdates.textContent = itemCount;
}
$adminBarUpdates.textContent = itemCount;
}
});
</script>
<?php
}
<?php
}
public function in_admin_footer() {
public function in_admin_footer() {
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
if ( ! is_array($hide_slugs) ) {
$hide_slugs = array();
}
if ( ! is_array($hide_slugs) ) {
$hide_slugs = array();
}
$count_hide = 0;
$count_hide = 0;
$updates = get_plugin_updates();
if ( is_array($updates) ) {
foreach ( $updates as $slug => $data ) {
if ( in_array($slug, $hide_slugs) ) {
$count_hide++;
}
}
}
$updates = get_plugin_updates();
if ( is_array($updates) ) {
foreach ( $updates as $slug => $data ) {
if ( in_array($slug, $hide_slugs) ) {
$count_hide++;
}
}
}
if ( $count_hide == 0 ) {
return;
}
if ( $count_hide == 0 ) {
return;
}
// to tweaks counting of update notification display
// js for admin end
?>
<script type="text/javascript">
var mainwpCountHide = <?php echo esc_attr($count_hide); ?>;
// to tweaks counting of update notification display
// js for admin end
?>
<script type="text/javascript">
var mainwpCountHide = <?php echo esc_attr($count_hide); ?>;
document.addEventListener("DOMContentLoaded", function(event) {
if (typeof(pagenow) !== 'undefined' && pagenow == 'plugins') {
<?php
// hide update notice row
if ( in_array('mainwp-child/mainwp-child.php', $hide_slugs) ) {
?>
var el = document.querySelector('tr#mainwp-child-update');
if (typeof(el) !== 'undefined' && el !== null) {
el.style.display = 'none';
}
<?php
}
// hide update notice row
if ( in_array('mainwp-child-reports/mainwp-child-reports.php', $hide_slugs) ) {
?>
var el = document.querySelector('tr#mainwp-child-reports-update');
if (typeof(el) !== 'undefined' && el !== null) {
el.style.display = 'none';
}
<?php
}
?>
}
if (typeof(pagenow) !== 'undefined' && pagenow == 'plugins') {
<?php
// hide update notice row
if ( in_array('mainwp-child/mainwp-child.php', $hide_slugs) ) {
?>
var el = document.querySelector('tr#mainwp-child-update');
if (typeof(el) !== 'undefined' && el !== null) {
el.style.display = 'none';
}
<?php
}
// hide update notice row
if ( in_array('mainwp-child-reports/mainwp-child-reports.php', $hide_slugs) ) {
?>
var el = document.querySelector('tr#mainwp-child-reports-update');
if (typeof(el) !== 'undefined' && el !== null) {
el.style.display = 'none';
}
<?php
}
?>
}
if (mainwpCountHide > 0) {
jQuery( document ).ready( function () {
if (mainwpCountHide > 0) {
jQuery( document ).ready( function () {
var $adminBarUpdates = jQuery( '#wp-admin-bar-updates' ),
$pluginsNavMenuUpdateCount = jQuery( 'a[href="plugins.php"] .update-plugins' ),
itemCount;
itemCount = $adminBarUpdates.find( '.ab-label' ).text();
itemCount -= mainwpCountHide;
if (itemCount < 0)
itemCount = 0;
var $adminBarUpdates = jQuery( '#wp-admin-bar-updates' ),
$pluginsNavMenuUpdateCount = jQuery( 'a[href="plugins.php"] .update-plugins' ),
itemCount;
itemCount = $adminBarUpdates.find( '.ab-label' ).text();
itemCount -= mainwpCountHide;
if (itemCount < 0)
itemCount = 0;
itemPCount = $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text();
itemPCount -= mainwpCountHide;
itemPCount = $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text();
itemPCount -= mainwpCountHide;
if (itemPCount < 0)
itemPCount = 0;
if (itemPCount < 0)
itemPCount = 0;
$adminBarUpdates.find( '.ab-label' ).text(itemCount);
$pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( itemPCount );
$adminBarUpdates.find( '.ab-label' ).text(itemCount);
$pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( itemPCount );
});
}
});
}
});
</script>
<?php
}
<?php
}
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
if ( isset($this->child_branding_options['disable_switching_theme']) && 'T' === $this->child_branding_options['disable_switching_theme'] ) {
@ -1144,50 +1144,50 @@ class MainWP_Child_Branding {
}
public function modify_plugin_header( $plugins ) {
$opts = $this->child_branding_options;
if ( is_array($opts) ) {
$is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
$cancelled_branding = $opts['cancelled_branding'];
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
$opts = $this->child_branding_options;
if ( is_array($opts) ) {
$is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
$cancelled_branding = $opts['cancelled_branding'];
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
if ( $cancelled_branding ) {
return $plugins;
}
if ( $cancelled_branding ) {
return $plugins;
}
if ( $is_hide === 'T' ) {
foreach ( $plugins as $key => $value ) {
$plugin_slug = basename( $key, '.php' );
if ( 'mainwp-child' === $plugin_slug ) {
unset( $plugins[ $key ] );
}
}
return $plugins;
}
if ( $is_hide === 'T' ) {
foreach ( $plugins as $key => $value ) {
$plugin_slug = basename( $key, '.php' );
if ( 'mainwp-child' === $plugin_slug ) {
unset( $plugins[ $key ] );
}
}
return $plugins;
}
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
return $this->update_plugin_header( $plugins, $branding_header );
} else {
return $plugins;
}
}
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
return $this->update_plugin_header( $plugins, $branding_header );
} else {
return $plugins;
}
}
return $plugins;
return $plugins;
}
function hide_update_notice( $slugs ) {
$slugs[] = 'mainwp-child/mainwp-child.php';
return $slugs;
}
function hide_update_notice( $slugs ) {
$slugs[] = 'mainwp-child/mainwp-child.php';
return $slugs;
}
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( isset( $value->response['mainwp-child/mainwp-child.php'] ) ) {
unset( $value->response['mainwp-child/mainwp-child.php'] );

View file

@ -17,7 +17,7 @@
class MainWP_Child_iThemes_Security {
public static $instance = null;
public $is_plugin_installed = false;
public $is_plugin_installed = false;
static function Instance() {
if ( null === self::$instance ) {
@ -28,27 +28,27 @@ class MainWP_Child_iThemes_Security {
}
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) {
$this->is_plugin_installed = true;
$this->is_plugin_installed = true;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
// ok
// ok
function syncOthersData( $information, $data = array() ) {
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
try {
$information['syncIThemeData'] = array(
'users_and_roles' => $this->get_available_admin_users_and_roles(),
);
} catch ( Exception $e ) {
error_log($e->getMessage());
}
try {
$information['syncIThemeData'] = array(
'users_and_roles' => $this->get_available_admin_users_and_roles(),
);
} catch ( Exception $e ) {
error_log($e->getMessage());
}
}
return $information;
}
@ -131,9 +131,9 @@ class MainWP_Child_iThemes_Security {
}
public function ithemes_init() {
if ( ! $this->is_plugin_installed ) {
if ( ! $this->is_plugin_installed ) {
return;
}
}
if ( get_option( 'mainwp_ithemes_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
@ -195,11 +195,11 @@ class MainWP_Child_iThemes_Security {
'network-brute-force',
'ssl',
// 'strong-passwords',
'password-requirements',
'password-requirements',
'system-tweaks',
'wordpress-tweaks',
'multisite-tweaks',
'notification-center',
'notification-center',
// 'salts',
// 'content-directory',
);
@ -277,24 +277,24 @@ class MainWP_Child_iThemes_Security {
}
$settings = $nbf_settings;
} elseif ( $module == 'notification-center' ) {
$current_settings = ITSEC_Modules::get_settings( $module );
if ( isset($settings['notifications']) ) {
$update_fields = array( 'schedule', 'enabled', 'subject' );
if ( isset($_POST['is_individual']) && $_POST['is_individual'] ) {
$update_fields = array_merge($update_fields, array( 'user_list', 'email_list' ));
}
foreach ( $settings['notifications'] as $key => $val ) {
foreach ( $update_fields as $field ) {
if ( isset($val[ $field ]) ) {
$current_settings['notifications'][ $key ][ $field ] = $val[ $field ];
}
}
}
$updated = true;
ITSEC_Modules::set_settings( $module, $current_settings );
}
continue;
}
$current_settings = ITSEC_Modules::get_settings( $module );
if ( isset($settings['notifications']) ) {
$update_fields = array( 'schedule', 'enabled', 'subject' );
if ( isset($_POST['is_individual']) && $_POST['is_individual'] ) {
$update_fields = array_merge($update_fields, array( 'user_list', 'email_list' ));
}
foreach ( $settings['notifications'] as $key => $val ) {
foreach ( $update_fields as $field ) {
if ( isset($val[ $field ]) ) {
$current_settings['notifications'][ $key ][ $field ] = $val[ $field ];
}
}
}
$updated = true;
ITSEC_Modules::set_settings( $module, $current_settings );
}
continue;
}
if ( ! $do_not_save ) {
ITSEC_Modules::set_settings( $module, $settings );
@ -303,13 +303,13 @@ class MainWP_Child_iThemes_Security {
}
}
if ( isset( $update_settings['itsec_active_modules'] ) ) {
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ( $update_settings['itsec_active_modules'] as $mod => $val ) {
$current_val[ $mod ] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
}
if ( isset( $update_settings['itsec_active_modules'] ) ) {
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ( $update_settings['itsec_active_modules'] as $mod => $val ) {
$current_val[ $mod ] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
}
require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php';
@ -328,10 +328,10 @@ class MainWP_Child_iThemes_Security {
'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ),
'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ),
'excludable_tables' => $this->get_excludable_tables(),
'users_and_roles' => $this->get_available_admin_users_and_roles(),
'users_and_roles' => $this->get_available_admin_users_and_roles(),
);
$return = array(
$return = array(
'site_status' => $values,
);
@ -349,7 +349,7 @@ class MainWP_Child_iThemes_Security {
$return['result'] = 'success';
} else {
$return['error'] = __('Not Updated', 'mainwp-child' );
}
}
return $return;
}
@ -691,7 +691,7 @@ class MainWP_Child_iThemes_Security {
if ( ! is_array($settings) ) {
$settings = array();
}
}
$new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : '';
$change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false;
@ -705,15 +705,15 @@ class MainWP_Child_iThemes_Security {
$username_exists = username_exists( 'admin' );
$user_id_exists = ITSEC_Lib::user_id_exists( 1 );
$msg = '';
if ( strlen( $new_username ) >= 1 ) {
global $current_user;
if ( ! $username_exists ) {
$msg = __( 'Admin user already changes.', 'mainwp-child' );
} elseif ( $current_user->user_login == 'admin' ) {
$return['result'] = 'CHILD_ADMIN';
return $return;
}
}
if ( strlen( $new_username ) >= 1 ) {
global $current_user;
if ( ! $username_exists ) {
$msg = __( 'Admin user already changes.', 'mainwp-child' );
} elseif ( $current_user->user_login == 'admin' ) {
$return['result'] = 'CHILD_ADMIN';
return $return;
}
}
if ( true === $change_id && ! $user_id_exists ) {
if ( ! empty( $msg ) ) {
@ -753,7 +753,7 @@ class MainWP_Child_iThemes_Security {
global $wpdb;
$itsec_files = ITSEC_Core::get_itsec_files();
// do not need to check this
// do not need to check this
// if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
// sanitize the username
@ -1112,12 +1112,12 @@ class MainWP_Child_iThemes_Security {
if ( ! is_array($active_modules) ) {
$active_modules = array();
}
}
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ( $active_modules as $mod => $val ) {
$current_val[ $mod ] = $val;
}
$current_val = get_site_option( 'itsec_active_modules', array() );
foreach ( $active_modules as $mod => $val ) {
$current_val[ $mod ] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
return array( 'result' => 'success' );
@ -1170,13 +1170,13 @@ class MainWP_Child_iThemes_Security {
return $excludes;
}
private function security_site() {
private function security_site() {
global $mainwp_itsec_modules_path;
require_once $mainwp_itsec_modules_path . 'security-check/scanner.php';
require_once $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php';
$results = ITSEC_Security_Check_Scanner::get_results();
ob_start();
ITSEC_Security_Check_Feedback_Renderer::render( $results );
require_once $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php';
$results = ITSEC_Security_Check_Scanner::get_results();
ob_start();
ITSEC_Security_Check_Feedback_Renderer::render( $results );
$response = ob_get_clean();
return array(
'result' => 'success',
@ -1184,9 +1184,9 @@ class MainWP_Child_iThemes_Security {
);
}
// source from itheme plugin
// ok
public function get_available_admin_users_and_roles() {
// source from itheme plugin
// ok
public function get_available_admin_users_and_roles() {
if ( is_callable( 'wp_roles' ) ) {
$roles = wp_roles();
} else {

View file

@ -16,7 +16,7 @@
class MainWP_Child_Links_Checker {
public static $instance = null;
public $is_plugin_installed = false;
public $is_plugin_installed = false;
static function Instance() {
if ( null === self::$instance ) {
@ -27,16 +27,16 @@ class MainWP_Child_Links_Checker {
}
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) {
$this->is_plugin_installed = true;
$this->is_plugin_installed = true;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
public function action() {
@ -47,44 +47,44 @@ class MainWP_Child_Links_Checker {
}
blc_init();
MainWP_Helper::update_option( 'mainwp_linkschecker_ext_enabled', 'Y', 'yes' );
// need this try()
try {
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'sync_data':
$information = $this->get_sync_data();
break;
case 'sync_links_data':
$information = $this->get_links_data();
break;
case 'edit_link':
$information = $this->edit_link();
break;
case 'unlink':
$information = $this->unlink();
break;
case 'set_dismiss':
$information = $this->set_link_dismissed();
break;
case 'discard':
$information = $this->discard();
break;
case 'save_settings':
$information = $this->save_settings();
break;
case 'force_recheck':
$information = $this->force_recheck();
break;
}
}
MainWP_Helper::write( $information );
} catch ( Exception $e ) {
MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
}
MainWP_Helper::update_option( 'mainwp_linkschecker_ext_enabled', 'Y', 'yes' );
// need this try()
try {
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'sync_data':
$information = $this->get_sync_data();
break;
case 'sync_links_data':
$information = $this->get_links_data();
break;
case 'edit_link':
$information = $this->edit_link();
break;
case 'unlink':
$information = $this->unlink();
break;
case 'set_dismiss':
$information = $this->set_link_dismissed();
break;
case 'discard':
$information = $this->discard();
break;
case 'save_settings':
$information = $this->save_settings();
break;
case 'force_recheck':
$information = $this->force_recheck();
break;
}
}
MainWP_Helper::write( $information );
} catch ( Exception $e ) {
MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
}
}
@ -207,15 +207,15 @@ class MainWP_Child_Links_Checker {
return $information;
}
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
try {
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
} catch ( Exception $e ) {
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
try {
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
} catch ( Exception $e ) {
}
}
}
}
return $information;
}
@ -223,31 +223,31 @@ class MainWP_Child_Links_Checker {
function get_sync_data( $strategy = '' ) {
$information = array();
$data = $this->get_count_links();
if ( is_array($data) ) {
$information['data'] = $data;
}
if ( is_array($data) ) {
$information['data'] = $data;
}
return $information;
}
function get_links_data() {
if ( ! defined('BLC_DIRECTORY') ) {
if ( ! defined('BLC_DIRECTORY') ) {
return;
}
}
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once $file_path1;
require_once $file_path2;
require_once $file_path1;
require_once $file_path2;
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
$blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
$total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
@ -292,25 +292,25 @@ class MainWP_Child_Links_Checker {
}
function get_count_links() {
if ( ! defined('BLC_DIRECTORY') ) {
if ( ! defined('BLC_DIRECTORY') ) {
return;
}
}
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once $file_path1;
require_once $file_path2;
require_once $file_path1;
require_once $file_path2;
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
$data = array();
$blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
$data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) );
$data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) );
@ -322,8 +322,8 @@ class MainWP_Child_Links_Checker {
function links_checker_data( $params ) {
MainWP_Helper::check_functions('blc_get_links');
MainWP_Helper::check_classes_exists('blcLink');
MainWP_Helper::check_functions('blc_get_links');
MainWP_Helper::check_classes_exists('blcLink');
$links = blc_get_links( $params );
@ -388,14 +388,14 @@ class MainWP_Child_Links_Checker {
$get_link = new blcLink( intval( $link->link_id ) );
if ( $get_link->valid() ) {
MainWP_Helper::check_methods($get_link, 'get_instances');
MainWP_Helper::check_methods($get_link, 'get_instances');
$instances = $get_link->get_instances();
}
if ( ! empty( $instances ) ) {
$first_instance = reset( $instances );
$first_instance = reset( $instances );
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) );
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) );
$new_link->link_text = $first_instance->ui_get_link_text();
$extra_info['count_instance'] = count( $instances );
@ -404,13 +404,13 @@ class MainWP_Child_Links_Checker {
/** @var blcContainer $container */
if ( ! empty( $container ) /* && ($container instanceof blcAnyPostContainer) */ ) {
if ( true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true ) ) {
if ( true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true ) ) {
$extra_info['container_type'] = $container->container_type;
$extra_info['container_id'] = $container->container_id;
$extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field );
}
}
if ( true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true ) ) {
if ( true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true ) ) {
$extra_info['container_type'] = $container->container_type;
$extra_info['container_id'] = $container->container_id;
$extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field );
}
}
}
$can_edit_text = false;
@ -659,11 +659,11 @@ class MainWP_Child_Links_Checker {
$image = 'font-awesome/font-awesome-comment-alt.png';
}
if ( true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object' ), true ) ) {
return false;
}
if ( true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object' ), true ) ) {
return false;
}
$comment = $container->get_wrapped_object();
$comment = $container->get_wrapped_object();
// Display a small text sample from the comment
$text_sample = strip_tags( $comment->comment_content );

View file

@ -34,11 +34,11 @@ class MainWP_Child_Pagespeed {
$this->is_plugin_installed = true;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
}
@ -76,9 +76,9 @@ class MainWP_Child_Pagespeed {
}
public function init() {
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
@ -164,7 +164,7 @@ class MainWP_Child_Pagespeed {
return array( 'result' => 'RUNNING' );
}
$information = array();
$information = array();
$settings = $_POST['settings'];
$settings = maybe_unserialize( base64_decode( $settings ) );
@ -183,10 +183,10 @@ class MainWP_Child_Pagespeed {
$current_values['strategy'] = $_POST['strategy'];
}
if ( isset( $settings['store_screenshots'] ) ) {
if ( isset( $settings['store_screenshots'] ) ) {
$current_values['store_screenshots'] = $settings['store_screenshots'];
}
if ( isset( $settings['use_schedule'] ) ) {
if ( isset( $settings['use_schedule'] ) ) {
$current_values['use_schedule'] = $settings['use_schedule'];
}
@ -219,7 +219,7 @@ class MainWP_Child_Pagespeed {
$current_values['check_pages'] = in_array( 'page', $settings['check_report'] ) ? true : false;
$current_values['check_posts'] = in_array( 'post', $settings['check_report'] ) ? true : false;
$current_values['check_categories'] = in_array( 'category', $settings['check_report'] ) ? true : false;
$current_values['check_custom_urls'] = in_array( 'custom_urls', $settings['check_report'] ) ? true : false;
$current_values['check_custom_urls'] = in_array( 'custom_urls', $settings['check_report'] ) ? true : false;
} else {
$current_values['check_pages'] = $current_values['check_posts'] = $current_values['check_categories'] = $current_values['check_custom_urls'] = false;
}
@ -277,7 +277,7 @@ class MainWP_Child_Pagespeed {
$information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
} else {
// do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
do_action( 'run_gpi', $forceRecheck ); // to fix
do_action( 'run_gpi', $forceRecheck ); // to fix
$information['checked_pages'] = 1;
}
}
@ -285,16 +285,16 @@ class MainWP_Child_Pagespeed {
}
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
try {
$information['syncPageSpeedData'] = $this->get_sync_data();
} catch ( Exception $e ) {
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
try {
$information['syncPageSpeedData'] = $this->get_sync_data();
} catch ( Exception $e ) {
}
}
}
}
return $information;
}
// ok
// ok
public function get_sync_data( $strategy = '' ) {
if ( empty( $strategy ) ) {
$strategy = 'both';
@ -312,19 +312,19 @@ class MainWP_Child_Pagespeed {
if ( 'both' === $strategy || 'desktop' === $strategy ) {
$result = self::cal_pagespeed_data( 'desktop' );
if ( ! empty($result) && is_array($result) ) {
$data['desktop_score'] = $result['average_score'];
$data['desktop_total_pages'] = $result['total_pages'];
$data['desktop_last_modified'] = $result['last_modified'];
}
if ( ! empty($result) && is_array($result) ) {
$data['desktop_score'] = $result['average_score'];
$data['desktop_total_pages'] = $result['total_pages'];
$data['desktop_last_modified'] = $result['last_modified'];
}
}
if ( 'both' === $strategy || 'mobile' === $strategy ) {
$result = self::cal_pagespeed_data( 'mobile' );
if ( ! empty($result) && is_array($result) ) {
$data['mobile_score'] = $result['average_score'];
$data['mobile_total_pages'] = $result['total_pages'];
$data['mobile_last_modified'] = $result['last_modified'];
}
if ( ! empty($result) && is_array($result) ) {
$data['mobile_score'] = $result['average_score'];
$data['mobile_total_pages'] = $result['total_pages'];
$data['mobile_last_modified'] = $result['last_modified'];
}
}
$information['data'] = $data;
@ -497,7 +497,7 @@ class MainWP_Child_Pagespeed {
}
}
if ( $gpi_options['check_custom_urls'] ) {
if ( $gpi_options['check_custom_urls'] ) {
global $wpdb;
$gpi_custom_urls = $wpdb->prefix . 'gpi_custom_urls';
@ -510,8 +510,8 @@ class MainWP_Child_Pagespeed {
if ( ! empty( $custom_url_types ) ) {
foreach ( $custom_url_types as $custom_url_type ) {
$typestocheck[] = 'type = %s';
$types[1][] = $custom_url_type;
$typestocheck[] = 'type = %s';
$types[1][] = $custom_url_type;
}
}
}

View file

@ -37,20 +37,20 @@ class MainWP_Child_Plugins_Check {
}
public function __construct() {
if ( get_option('mainwp_child_plugintheme_days_outdate') ) {
$this->schedule_watchdog();
if ( get_option('mainwp_child_plugintheme_days_outdate') ) {
$this->schedule_watchdog();
add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
// add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
// add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
}
add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
}
}
private function cleanup_basic() {

View file

@ -24,7 +24,7 @@ class MainWP_Child_Server_Information {
} else {
$warnings = self::getWarnings();
}
$dismissWarnings['warnings'] = $warnings;
$dismissWarnings['warnings'] = $warnings;
}
MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings );
}
@ -67,7 +67,7 @@ class MainWP_Child_Server_Information {
var data = {
action: 'mainwp-child_dismiss_warnings',
what: pAction,
warnings: <?php echo intval($warnings); ?>
warnings: <?php echo intval($warnings); ?>
};
jQuery.ajax( {
@ -475,15 +475,15 @@ class MainWP_Child_Server_Information {
<br/>
<div class="mwp_server_info_box">
<h2><?php esc_html_e( 'Server Information' ); ?></h2>
<?php
<?php
self::render();
?>
<h2><?php esc_html_e( 'Cron Schedules' ); ?></h2>
<?php
<h2><?php esc_html_e( 'Cron Schedules' ); ?></h2>
<?php
self::renderCron();
?>
<h2><?php esc_html_e( 'Error Log' ); ?></h2>
<?php
<h2><?php esc_html_e( 'Error Log' ); ?></h2>
<?php
self::renderErrorLogPage();
?>
</div>
@ -543,11 +543,11 @@ class MainWP_Child_Server_Information {
}
public static function render() {
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
$isBranding = true;
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
$isBranding = true;
if ( $branding_title == '' ) {
$branding_title = 'MainWP Child';
$isBranding = false;
$branding_title = 'MainWP Child';
$isBranding = false;
}
?>
@ -556,11 +556,11 @@ class MainWP_Child_Server_Information {
<thead>
<tr>
<th scope="col" class="manage-column column-posts mwp-not-generate-row"
style="width: 1px;"></th>
style="width: 1px;"></th>
<th scope="col" class="manage-column column-posts" style="">
<span><?php esc_html_e( 'Server configuration', 'mainwp-child' ); ?></span></th>
<th scope="col" class="manage-column column-posts"
style=""><?php esc_html_e( 'Required value', 'mainwp-child' ); ?></th>
style=""><?php esc_html_e( 'Required value', 'mainwp-child' ); ?></th>
<th scope="col" class="manage-column column-posts" style=""><?php esc_html_e( 'Value', 'mainwp-child' ); ?></th>
<th scope="col" class="manage-column column-posts" style=""><?php esc_html_e( 'Status', 'mainwp-child' ); ?></th>
</tr>
@ -591,7 +591,7 @@ class MainWP_Child_Server_Information {
<tr>
<td style="background: #333; color: #fff;" colspan="5"><?php esc_html_e( 'WordPress', 'mainwp-child' ); ?></td>
</tr>
<?php
<?php
self::renderRow( 'WordPress Version', '>=', '3.4', 'getWordpressVersion' );
self::renderRow( 'WordPress Memory Limit', '>=', '64M', 'getWordpressMemoryLimit' );
self::renderRow( 'MultiSite Disabled', '=', true, 'checkIfMultisite' );
@ -605,9 +605,9 @@ class MainWP_Child_Server_Information {
</tr>
<tr>
<td style="background: #333; color: #fff;"
colspan="5"><?php esc_html_e( 'PHP SETTINGS', 'mainwp-child' ); ?></td>
colspan="5"><?php esc_html_e( 'PHP SETTINGS', 'mainwp-child' ); ?></td>
</tr>
<?php
<?php
self::renderRow( 'PHP Version', '>=', '5.6', 'getPHPVersion' );
?>
<tr>
@ -636,16 +636,16 @@ class MainWP_Child_Server_Information {
?>
<tr>
<td style="background: #333; color: #fff;"
colspan="5"><?php esc_html_e( 'MySQL SETTINGS', 'mainwp-child' ); ?></td>
colspan="5"><?php esc_html_e( 'MySQL SETTINGS', 'mainwp-child' ); ?></td>
</tr>
<?php
<?php
self::renderRow( 'MySQL Version', '>=', '5.0', 'getMySQLVersion' );
?>
<tr>
<td style="background: #333; color: #fff;"
colspan="5"><?php esc_html_e( 'BACKUP ARCHIVE INFORMATION', 'mainwp-child' ); ?></td>
colspan="5"><?php esc_html_e( 'BACKUP ARCHIVE INFORMATION', 'mainwp-child' ); ?></td>
</tr>
<?php
<?php
self::renderRow( 'ZipArchive enabled in PHP', '=', true, 'getZipArchiveEnabled' );
self::renderRow( 'Tar GZip supported', '=', true, 'getGZipEnabled' );
self::renderRow( 'Tar BZip2 supported', '=', true, 'getBZipEnabled' );
@ -653,7 +653,7 @@ class MainWP_Child_Server_Information {
<tr>
<td style="background: #333; color: #fff;"
colspan="5"><?php esc_html_e( 'SERVER INFORMATION', 'mainwp-child' ); ?></td>
colspan="5"><?php esc_html_e( 'SERVER INFORMATION', 'mainwp-child' ); ?></td>
</tr>
<tr>
<td></td>
@ -805,7 +805,7 @@ class MainWP_Child_Server_Information {
</tr>
<tr>
<td style="background: #333; color: #fff;"
colspan="5"><?php esc_html_e( 'MySQL INFORMATION', 'mainwp-child' ); ?></td>
colspan="5"><?php esc_html_e( 'MySQL INFORMATION', 'mainwp-child' ); ?></td>
</tr>
<tr>
<td></td>
@ -823,20 +823,20 @@ class MainWP_Child_Server_Information {
<?php
$all_plugins = get_plugins();
foreach ( $all_plugins as $slug => $plugin ) {
if ( $slug == 'mainwp-child/mainwp-child.php' || $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) {
if ( $isBranding ) {
if ( $slug == 'mainwp-child/mainwp-child.php' ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) );
} elseif ( $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports';
}
}
}
if ( $slug == 'mainwp-child/mainwp-child.php' || $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) {
if ( $isBranding ) {
if ( $slug == 'mainwp-child/mainwp-child.php' ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) );
} elseif ( $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports';
}
}
}
?>
<tr>
<td>&nbsp;</td>
<td><?php echo esc_html($plugin['Name']); ?></td>
<td><?php echo esc_html($plugin['Name']); ?></td>
<td><?php echo esc_html($plugin['Version']); ?></td>
<td><?php echo is_plugin_active($slug) ? 'Active' : 'Inactive'; ?></td>
<td>&nbsp;</td>
@ -966,10 +966,10 @@ class MainWP_Child_Server_Information {
}
protected static function checkDirectoryMainWPDirectory( $write = true ) {
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
if ( $branding_title == '' ) {
$branding_title = 'MainWP';
}
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
if ( $branding_title == '' ) {
$branding_title = 'MainWP';
}
$branding_title .= ' Upload Directory';
@ -1181,9 +1181,9 @@ class MainWP_Child_Server_Information {
protected static function getArchitecture() {
echo esc_html( PHP_INT_SIZE * 8 )
?>
&nbsp;bit
<?php
?>
&nbsp;bit
<?php
}
protected static function memoryUsage() {
@ -1263,7 +1263,7 @@ class MainWP_Child_Server_Information {
}
protected static function getServerGetawayInterface() {
$gate = isset($_SERVER['GATEWAY_INTERFACE']) ? $_SERVER['GATEWAY_INTERFACE'] : '';
$gate = isset($_SERVER['GATEWAY_INTERFACE']) ? $_SERVER['GATEWAY_INTERFACE'] : '';
echo esc_html( $gate );
}
@ -1354,7 +1354,7 @@ class MainWP_Child_Server_Information {
_e( 'Response Test O.K.', 'mainwp-child' );
} else {
echo $test_result;
}
}
}
@ -1430,15 +1430,15 @@ class MainWP_Child_Server_Information {
/*
*Plugin-Name: Error Log Dashboard Widget
*Plugin URI: http://wordpress.org/extend/plugins/error-log-dashboard-widget/
*Description: Robust zero-configuration and low-memory way to keep an eye on error log.
*Author: Andrey "Rarst" Savchenko
*Author URI: http://www.rarst.net/
*Version: 1.0.2
*License: GPLv2 or later
*Plugin-Name: Error Log Dashboard Widget
*Plugin URI: http://wordpress.org/extend/plugins/error-log-dashboard-widget/
*Description: Robust zero-configuration and low-memory way to keep an eye on error log.
*Author: Andrey "Rarst" Savchenko
*Author URI: http://www.rarst.net/
*Version: 1.0.2
*License: GPLv2 or later
*Includes last_lines() function by phant0m, licensed under cc-wiki and GPLv2+
*Includes last_lines() function by phant0m, licensed under cc-wiki and GPLv2+
*/
public static function renderErrorLogPage() {
@ -1481,11 +1481,11 @@ class MainWP_Child_Server_Information {
$lines = array_filter( $lines );
if ( empty( $lines ) ) {
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
if ( $branding_title == '' ) {
$branding_title = 'MainWP';
}
$msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.';
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
if ( $branding_title == '' ) {
$branding_title = 'MainWP';
}
$msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.';
echo '<tr><td colspan="2">' . $msg . '</td></tr>';
return;
}
@ -1671,26 +1671,26 @@ class MainWP_Child_Server_Information {
<div class="postbox" id="connection_detail">
<h3 class="mainwp_box_title"><span><?php _e( 'Connection details', 'mainwp-child' ); ?></span></h3>
<div class="inside">
<div class="mainwp-postbox-actions-top mainwp-padding-5">
<div class="mainwp-postbox-actions-top mainwp-padding-5">
<?php
echo sprintf(__('If you are trying to connect this child site to your %s Dashboard, you can use following details to do that. Please note that these are only suggested values.', 'mainwp-child'), stripslashes( $branding_title ));
?>
</div>
<table id="mainwp-table" class="wp-list-table widefat" cellspacing="0" style="border: 0">
<tbody>
</div>
<table id="mainwp-table" class="wp-list-table widefat" cellspacing="0" style="border: 0">
<tbody>
<?php
foreach ( $details as $row ) {
?>
<tr>
<th style="width: 20%"><strong><?php echo esc_html($row['title']); ?></strong></th>
<td style="width: 20%"><strong><?php echo esc_html($row['value']); ?></strong></td>
<td><?php echo esc_html($row['desc']); ?></td>
</tr>
<tr>
<th style="width: 20%"><strong><?php echo esc_html($row['title']); ?></strong></th>
<td style="width: 20%"><strong><?php echo esc_html($row['value']); ?></strong></td>
<td><?php echo esc_html($row['desc']); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</tbody>
</table>
</div>
</div>
<?php

View file

@ -130,8 +130,8 @@ class MainWP_Child_Skeleton_Key {
$full_url = add_query_arg( $get_args, get_site_url() . $url );
global $mainWPChild;
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
global $mainWPChild;
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
$response = wp_remote_post( $full_url, $post_args );
@ -197,7 +197,7 @@ class MainWP_Child_Skeleton_Key {
if ( ! is_array($settings) || empty($settings) ) {
return array( 'error' => 'Invalid data. Please check and try again.' );
}
}
$whitelist_options = array(
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
@ -206,10 +206,10 @@ class MainWP_Child_Skeleton_Key {
if ( ! is_multisite() ) {
if ( ! defined( 'WP_SITEURL' ) ) {
$whitelist_options['general'][] = 'siteurl';
}
}
if ( ! defined( 'WP_HOME' ) ) {
$whitelist_options['general'][] = 'home';
}
}
$whitelist_options['general'][] = 'admin_email';
$whitelist_options['general'][] = 'users_can_register';
@ -235,7 +235,7 @@ class MainWP_Child_Skeleton_Key {
if ( in_array($option, $whitelist_general) ) {
if ( ! is_array( $value ) ) {
$value = trim( $value );
}
}
$value = wp_unslash( $value );
update_option($option, $value);
$updated = true;
@ -244,7 +244,7 @@ class MainWP_Child_Skeleton_Key {
if ( ! $updated ) {
return false;
}
}
return array( 'result' => 'ok' );
}

View file

@ -18,65 +18,65 @@
class MainWP_Child_Staging {
public static $instance = null;
public $is_plugin_installed = false;
public static $instance = null;
public $is_plugin_installed = false;
static function Instance() {
if ( null === self::$instance ) {
self::$instance = new MainWP_Child_Staging();
}
return self::$instance;
}
static function Instance() {
if ( null === self::$instance ) {
self::$instance = new MainWP_Child_Staging();
}
return self::$instance;
}
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR') ) {
$this->is_plugin_installed = true;
$this->is_plugin_installed = true;
} elseif ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) {
$this->is_plugin_installed = true;
$this->is_plugin_installed = true;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
}
public function init() {
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) {
return;
}
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
}
}
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
try {
$information['syncWPStaging'] = $this->get_sync_data();
} catch ( Exception $e ) {
// do not exit
}
}
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
try {
$information['syncWPStaging'] = $this->get_sync_data();
} catch ( Exception $e ) {
// do not exit
}
}
return $information;
}
// ok
public function get_sync_data() {
return $this->get_overview();
}
// ok
public function get_sync_data() {
return $this->get_overview();
}
public function action() {
public function action() {
if ( ! $this->is_plugin_installed ) {
MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) );
}
@ -84,9 +84,9 @@ class MainWP_Child_Staging {
if ( ! class_exists( 'WPStaging\WPStaging' ) ) {
require_once WPSTG_PLUGIN_DIR . 'apps/Core/WPStaging.php';
}
\WPStaging\WPStaging::getInstance();
\WPStaging\WPStaging::getInstance();
$information = array();
$information = array();
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) {
MainWP_Helper::update_option( 'mainwp_wp_staging_ext_enabled', 'Y', 'yes' );
}
@ -146,70 +146,70 @@ class MainWP_Child_Staging {
break;
}
}
MainWP_Helper::write( $information );
}
MainWP_Helper::write( $information );
}
function set_showhide() {
function set_showhide() {
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
MainWP_Helper::update_option( 'mainwp_wp_staging_hide_plugin', $hide, 'yes' );
$information['result'] = 'SUCCESS';
return $information;
}
function save_settings() {
$settings = $_POST['settings'];
$filters = array(
'queryLimit',
'fileLimit',
'batchSize',
'cpuLoad',
'delayRequests',
'disableAdminLogin',
'querySRLimit',
'maxFileSize',
// 'wpSubDirectory', // removed
'debugMode',
'unInstallOnDelete',
'checkDirectorySize',
function save_settings() {
$settings = $_POST['settings'];
$filters = array(
'queryLimit',
'fileLimit',
'batchSize',
'cpuLoad',
'delayRequests',
'disableAdminLogin',
'querySRLimit',
'maxFileSize',
// 'wpSubDirectory', // removed
'debugMode',
'unInstallOnDelete',
'checkDirectorySize',
'optimizer',
// 'loginSlug' // removed
);
);
$save_fields = array();
foreach ( $filters as $field ) {
if ( isset($settings[ $field ]) ) {
$save_fields[ $field ] = $settings[ $field ];
}
}
update_option('wpstg_settings', $save_fields );
return array( 'result' => 'success' );
}
$save_fields = array();
foreach ( $filters as $field ) {
if ( isset($settings[ $field ]) ) {
$save_fields[ $field ] = $settings[ $field ];
}
}
update_option('wpstg_settings', $save_fields );
return array( 'result' => 'success' );
}
public function get_overview() {
$return = array(
'availableClones' => get_option( 'wpstg_existing_clones_beta', array()),
);
return $return;
}
public function get_overview() {
$return = array(
'availableClones' => get_option( 'wpstg_existing_clones_beta', array()),
);
return $return;
}
public function get_scan() {
// Scan
$scan = new WPStaging\Backend\Modules\Jobs\Scan();
$scan->start();
public function get_scan() {
// Scan
$scan = new WPStaging\Backend\Modules\Jobs\Scan();
$scan->start();
// Get Options
$options = $scan->getOptions();
// Get Options
$options = $scan->getOptions();
$return = array(
'options' => serialize($options),
'directoryListing' => $scan->directoryListing(),
'prefix' => WPStaging\WPStaging::getTablePrefix(),
);
return $return;
$return = array(
'options' => serialize($options),
'directoryListing' => $scan->directoryListing(),
'prefix' => WPStaging\WPStaging::getTablePrefix(),
);
return $return;
}
public function ajaxCheckCloneName() {
public function ajaxCheckCloneName() {
$cloneName = sanitize_key( $_POST['cloneID'] );
$cloneNameLength = strlen( $cloneName );
$clones = get_option( 'wpstg_existing_clones_beta', array() );
@ -245,7 +245,7 @@ class MainWP_Child_Staging {
return $result;
}
public function ajaxCloneDatabase() {
public function ajaxCloneDatabase() {
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
@ -325,7 +325,7 @@ class MainWP_Child_Staging {
return $cancel->start();
}
public function ajaxCancelUpdate() {
public function ajaxCancelUpdate() {
$cancel = new WPStaging\Backend\Modules\Jobs\CancelUpdate();
return $cancel->start();
}
@ -344,12 +344,12 @@ class MainWP_Child_Staging {
return $result;
}
public function ajaxCheckFreeSpace() {
public function ajaxCheckFreeSpace() {
return $this->hasFreeDiskSpace();
}
}
// from wp-staging plugin
public function hasFreeDiskSpace() {
// from wp-staging plugin
public function hasFreeDiskSpace() {
if ( ! function_exists( 'disk_free_space' ) ) {
return null;
}
@ -368,8 +368,8 @@ class MainWP_Child_Staging {
return $data;
}
// from wp-staging plugin
function getDirectorySizeInclSubdirs( $dir ) {
// from wp-staging plugin
function getDirectorySizeInclSubdirs( $dir ) {
$size = 0;
foreach ( glob( rtrim( $dir, '/' ) . '/*', GLOB_NOSORT ) as $each ) {
$size += is_file( $each ) ? filesize( $each ) : $this->getDirectorySizeInclSubdirs( $each );
@ -377,23 +377,23 @@ class MainWP_Child_Staging {
return $size;
}
// from wp-staging plugin
public function formatSize( $bytes, $precision = 2 ) {
if ( (float) $bytes < 1 ) {
return '';
}
// from wp-staging plugin
public function formatSize( $bytes, $precision = 2 ) {
if ( (float) $bytes < 1 ) {
return '';
}
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
$bytes = (float) $bytes;
$base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc
$pow = pow(1000, $base - floor($base)); // Same rule for 1000
$bytes = (float) $bytes;
$base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc
$pow = pow(1000, $base - floor($base)); // Same rule for 1000
return round($pow, $precision) . ' ' . $units[ (int) floor($base) ];
}
return round($pow, $precision) . ' ' . $units[ (int) floor($base) ];
}
public function all_plugins( $plugins ) {
public function all_plugins( $plugins ) {
foreach ( $plugins as $key => $value ) {
$plugin_slug = basename( $key, '.php' );
if ( 'wp-staging' === $plugin_slug ) {
@ -405,7 +405,7 @@ class MainWP_Child_Staging {
}
public function remove_menu() {
remove_menu_page( 'wpstg_clone' );
remove_menu_page( 'wpstg_clone' );
$pos = stripos( $_SERVER['REQUEST_URI'], 'admin.php?page=wpstg_clone' );
if ( false !== $pos ) {
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
@ -413,25 +413,25 @@ class MainWP_Child_Staging {
}
}
function hide_update_notice( $slugs ) {
$slugs[] = 'wp-staging/wp-staging.php';
return $slugs;
}
function hide_update_notice( $slugs ) {
$slugs[] = 'wp-staging/wp-staging.php';
return $slugs;
}
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( isset( $value->response['wp-staging/wp-staging.php'] ) ) {
unset( $value->response['wp-staging/wp-staging.php'] );
}
if ( isset( $value->response['wp-staging-pro/wp-staging-pro.php'] ) ) {
if ( isset( $value->response['wp-staging-pro/wp-staging-pro.php'] ) ) {
unset( $value->response['wp-staging-pro/wp-staging-pro.php'] );
}

View file

@ -38,17 +38,17 @@ class MainWP_Child_Themes_Check {
public function __construct() {
if ( get_option('mainwp_child_plugintheme_days_outdate') ) {
$this->schedule_watchdog();
add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
if ( get_option('mainwp_child_plugintheme_days_outdate') ) {
$this->schedule_watchdog();
add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
add_filter( 'themes_api_args', array( $this, 'modify_theme_api_search_query' ), 10, 2 );
add_filter( 'themes_api_args', array( $this, 'modify_theme_api_search_query' ), 10, 2 );
add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
}
add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
}
}
private function cleanup_basic() {
@ -172,14 +172,14 @@ class MainWP_Child_Themes_Check {
$responses = array();
}
$avoid_themes = array( 'superstore' );
$avoid_themes = array( 'superstore' );
$themes_to_scan = array_splice( $all_themes, 0, apply_filters( 'mainwp_child_theme_health_check_max_themes_to_batch', 10 ) );
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
foreach ( $themes_to_scan as $slug => $v ) {
if ( in_array( $slug, $avoid_themes ) ) {
if ( in_array( $slug, $avoid_themes ) ) {
continue;
}
}
$body = $this->try_get_response_body( $slug, false );

File diff suppressed because it is too large Load diff

View file

@ -17,8 +17,8 @@
class MainWP_Child_Updraft_Plus_Backups {
public static $instance = null;
public $is_plugin_installed = false;
static function Instance() {
public $is_plugin_installed = false;
static function Instance() {
if ( null === self::$instance ) {
self::$instance = new MainWP_Child_Updraft_Plus_Backups();
}
@ -27,14 +27,14 @@ class MainWP_Child_Updraft_Plus_Backups {
}
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR') ) {
$this->is_plugin_installed = true;
$this->is_plugin_installed = true;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
@ -43,36 +43,36 @@ class MainWP_Child_Updraft_Plus_Backups {
public static function hookUpdraftplusSaveLastBackup( $last_backup ) {
if ( ! is_array($last_backup) ) {
return $last_backup;
}
}
if ( isset($last_backup['backup_time']) ) {
$backup_time = $last_backup['backup_time'];
if ( $last_backup['success'] ) {
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
}
}
return $last_backup;
}
// ok
// ok
function syncOthersData( $information, $data = array() ) {
try {
if ( isset( $data['syncUpdraftData'] ) && $info = $data['syncUpdraftData'] ) {
if ( $this->is_plugin_installed ) {
$with_hist = true;
if ( version_compare( $info, '1.7', '>=' ) ) {
$with_hist = false;
try {
if ( isset( $data['syncUpdraftData'] ) && $info = $data['syncUpdraftData'] ) {
if ( $this->is_plugin_installed ) {
$with_hist = true;
if ( version_compare( $info, '1.7', '>=' ) ) {
$with_hist = false;
}
$information['syncUpdraftData'] = $this->get_sync_data( $with_hist );
$information['syncUpdraftData'] = $this->get_sync_data( $with_hist );
}
}
if ( isset( $data['sync_Updraftvault_quota_text'] ) && $data['sync_Updraftvault_quota_text'] ) {
if ( $this->is_plugin_installed ) {
$information['sync_Updraftvault_quota_text'] = $this->connected_html();
}
}
} catch ( Exception $e ) {
}
if ( isset( $data['sync_Updraftvault_quota_text'] ) && $data['sync_Updraftvault_quota_text'] ) {
if ( $this->is_plugin_installed ) {
$information['sync_Updraftvault_quota_text'] = $this->connected_html();
}
}
} catch ( Exception $e ) {
}
}
return $information;
}
@ -84,7 +84,7 @@ class MainWP_Child_Updraft_Plus_Backups {
MainWP_Helper::write( $information );
}
$this->required_files();
$this->required_files();
global $updraftplus;
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
@ -96,75 +96,75 @@ class MainWP_Child_Updraft_Plus_Backups {
}
if ( isset( $_POST['mwp_action'] ) ) {
try {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'save_settings':
$information = $this->save_settings();
break;
case 'addons_connect':
$information = $this->addons_connect();
break;
case 'backup_now':
$information = $this->backup_now();
break;
case 'activejobs_list':
$information = $this->activejobs_list();
break;
case 'diskspaceused':
$information = $this->diskspaceused();
break;
case 'last_backup_html':
$information = $this->last_backup_html();
break;
case 'reload_data':
$information = $this->get_updraft_data();
break;
case 'next_scheduled_backups':
$information = $this->next_scheduled_backups();
break;
case 'forcescheduledresumption':
$information = $this->forceScheduledResumption();
break;
case 'fetch_updraft_log':
$information = $this->fetch_updraft_log();
break;
case 'activejobs_delete':
$information = $this->activejobs_delete();
break;
case 'historystatus':
$information = $this->historystatus();
break;
case 'deleteset':
$information = $this->deleteset();
break;
case 'updraft_download_backup':
$information = $this->updraft_download_backup();
break;
case 'restore_alldownloaded':
$information = $this->restore_alldownloaded();
break;
case 'restorebackup': // not used
$information = $this->restoreBackup();
break;
case 'extradbtestconnection':
$information = $this->extradb_testconnection();
break;
case 'delete_old_dirs':
$information = $this->delete_old_dirs_go();
break;
case 'vault_connect':
$information = $this->do_vault_connect();
break;
case 'vault_disconnect':
$information = $this->vault_disconnect();
break;
}
} catch ( Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
try {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'save_settings':
$information = $this->save_settings();
break;
case 'addons_connect':
$information = $this->addons_connect();
break;
case 'backup_now':
$information = $this->backup_now();
break;
case 'activejobs_list':
$information = $this->activejobs_list();
break;
case 'diskspaceused':
$information = $this->diskspaceused();
break;
case 'last_backup_html':
$information = $this->last_backup_html();
break;
case 'reload_data':
$information = $this->get_updraft_data();
break;
case 'next_scheduled_backups':
$information = $this->next_scheduled_backups();
break;
case 'forcescheduledresumption':
$information = $this->forceScheduledResumption();
break;
case 'fetch_updraft_log':
$information = $this->fetch_updraft_log();
break;
case 'activejobs_delete':
$information = $this->activejobs_delete();
break;
case 'historystatus':
$information = $this->historystatus();
break;
case 'deleteset':
$information = $this->deleteset();
break;
case 'updraft_download_backup':
$information = $this->updraft_download_backup();
break;
case 'restore_alldownloaded':
$information = $this->restore_alldownloaded();
break;
case 'restorebackup': // not used
$information = $this->restoreBackup();
break;
case 'extradbtestconnection':
$information = $this->extradb_testconnection();
break;
case 'delete_old_dirs':
$information = $this->delete_old_dirs_go();
break;
case 'vault_connect':
$information = $this->do_vault_connect();
break;
case 'vault_disconnect':
$information = $this->vault_disconnect();
break;
}
} catch ( Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
}
MainWP_Helper::write( $information );
}
@ -238,7 +238,7 @@ class MainWP_Child_Updraft_Plus_Backups {
'updraft_googlecloud',
// 'updraft_updraftvault',
'updraft_retain_extrarules',
'updraft_backblaze',
'updraft_backblaze',
);
}
@ -249,7 +249,7 @@ class MainWP_Child_Updraft_Plus_Backups {
'connected' => true,
'html' => $this->connected_html(),
);
}
}
$connect = $this->vault_connect( $_REQUEST['email'], $_REQUEST['passwd'] );
if ( true === $connect ) {
@ -272,8 +272,8 @@ class MainWP_Child_Updraft_Plus_Backups {
private function connected_html() {
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
if ( ! is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
@ -320,7 +320,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( is_wp_error( $result ) || ( false === $result ) ) {
return $result;
}
}
$response = json_decode( $result['body'], true );
@ -339,14 +339,14 @@ class MainWP_Child_Updraft_Plus_Backups {
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
if ( ! is_array( $vault_settings ) ) {
$vault_settings = array();
}
}
$vault_settings['email'] = $email;
$vault_settings['token'] = (string) $response['token'];
$vault_settings['quota'] = -1;
unset( $vault_settings['last_config'] );
if ( isset($response['quota'] ) ) {
$vault_settings['quota'] = $response['quota'];
}
}
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' ) );
@ -401,7 +401,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( ! empty( $vault_settings['token'] ) ) {
$post_body['token'] = (string) $vault_settings['token'];
}
}
// Use SSL to prevent snooping
wp_remote_post( $vault_mothership . '/?udm_action=vault_disconnect', array(
@ -411,17 +411,17 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
function required_files() {
if ( defined('UPDRAFTPLUS_DIR') ) {
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
require_once UPDRAFTPLUS_DIR . '/class-updraftplus.php';
}
function required_files() {
if ( defined('UPDRAFTPLUS_DIR') ) {
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
require_once UPDRAFTPLUS_DIR . '/class-updraftplus.php';
}
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
require_once UPDRAFTPLUS_DIR . '/options.php';
}
}
}
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
require_once UPDRAFTPLUS_DIR . '/options.php';
}
}
}
function save_settings() {
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
@ -436,9 +436,9 @@ class MainWP_Child_Updraft_Plus_Backups {
$settings_key = null;
if ( 'updraft_dropbox' === $key && is_array($settings[ $key ]) ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' );
if ( ! is_array($opts) ) {
$opts = array();
}
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
if ( isset($settings['is_general']) && ! empty($settings['is_general']) ) {
@ -459,7 +459,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_googledrive' === $key ) {
// do not saving from dashboard
// do not saving from dashboard
// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
// if (!is_array($opts))
// $opts = array();
@ -475,7 +475,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// }
// UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_googlecloud' === $key ) {
// do not saving from dashboard
// do not saving from dashboard
// $opts = UpdraftPlus_Options::get_updraft_option( $key );
// if (!is_array($opts))
// $opts = array();
@ -497,7 +497,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// }
// UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_onedrive' === $key ) {
// do not saving from dashboard
// do not saving from dashboard
// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
// if (!is_array($opts))
// $opts = array();
@ -524,13 +524,13 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $value );
} elseif ( 'updraft_s3' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
if ( ! is_array($opts) ) {
$opts = array();
}
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
if ( ! empty($opts['settings'][ $settings_key ]['path']) && '/' == substr($opts['settings'][ $settings_key ]['path'], 0, 1) ) {
$opts['settings'][ $settings_key ]['path'] = substr($opts['settings'][ $settings_key ]['path'], 1);
@ -540,8 +540,8 @@ class MainWP_Child_Updraft_Plus_Backups {
$opts['settings'][ $settings_key ]['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
}
} else {
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
if ( ! empty($opts['path']) && '/' == substr($opts['path'], 0, 1) ) {
$opts['path'] = substr($opts['path'], 1);
@ -555,42 +555,42 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_s3generic' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' );
if ( ! is_array($opts) ) {
$opts = array();
}
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey'];
$opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
} else {
$opts['endpoint'] = $settings[ $key ]['endpoint'];
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['endpoint'] = $settings[ $key ]['endpoint'];
$opts['accesskey'] = $settings[ $key ]['accesskey'];
$opts['secretkey'] = $settings[ $key ]['secretkey'];
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_dreamobjects' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' );
if ( ! is_array($opts) ) {
$opts = array();
}
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
$opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint'];
} else {
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
$opts['endpoint'] = $settings[ $key ]['endpoint'];
$opts['endpoint'] = $settings[ $key ]['endpoint'];
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_ftp' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' );
if ( ! is_array($opts) ) {
$opts = array();
}
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
@ -613,9 +613,9 @@ class MainWP_Child_Updraft_Plus_Backups {
UpdraftPlus_Options::update_updraft_option( $key, $opts );
} elseif ( 'updraft_sftp_settings' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' );
if ( ! is_array($opts) ) {
$opts = array();
}
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
if ( isset( $settings[ $key ]['path'] ) ) {
@ -640,34 +640,34 @@ class MainWP_Child_Updraft_Plus_Backups {
}
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
} elseif ( 'updraft_webdav_settings' == $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_webdav' );
if ( ! is_array($opts) ) {
$opts = array();
}
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_webdav' );
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['url'] = $this->replace_tokens( $settings[ $key ]['url'] );
UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts );
}
$opts['settings'][ $settings_key ]['url'] = $this->replace_tokens( $settings[ $key ]['url'] );
UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts );
}
} elseif ( 'updraft_backblaze' === $key ) {
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
if ( ! is_array($opts) ) {
$opts = array();
if ( ! is_array($opts) ) {
$opts = array();
}
if ( is_array($opts) && isset($opts['settings']) ) {
$settings_key = key($opts['settings']);
$opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id'];
$opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
$bname = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
$bpath = $this->replace_tokens( $settings[ $key ]['backup_path'] );
$bname = str_replace('.', '-', $bname);
$bpath = str_replace('.', '-', $bpath);
$bname = str_replace('_', '', $bname); // to fix strange character
$bpath = str_replace('_', '', $bpath);
$opts['settings'][ $settings_key ]['bucket_name'] = $bname;
$opts['settings'][ $settings_key ]['backup_path'] = $bpath;
UpdraftPlus_Options::update_updraft_option( $key, $opts );
$opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id'];
$opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
$bname = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
$bpath = $this->replace_tokens( $settings[ $key ]['backup_path'] );
$bname = str_replace('.', '-', $bname);
$bpath = str_replace('.', '-', $bpath);
$bname = str_replace('_', '', $bname); // to fix strange character
$bpath = str_replace('_', '', $bpath);
$opts['settings'][ $settings_key ]['bucket_name'] = $bname;
$opts['settings'][ $settings_key ]['backup_path'] = $bpath;
UpdraftPlus_Options::update_updraft_option( $key, $opts );
}
} else {
UpdraftPlus_Options::update_updraft_option( $key, $settings[ $key ] );
@ -676,9 +676,9 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
if ( ! isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings']) ) {
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
}
if ( ! isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings']) ) {
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
}
global $updraftplus;
if ( isset( $settings['updraft_interval'] ) ) {
@ -727,12 +727,12 @@ class MainWP_Child_Updraft_Plus_Backups {
function addons_connect() {
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
if ( is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php') ) {
if ( is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php') ) {
require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php';
}
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
return array( 'error' => 'NO_PREMIUM' );
}
}
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
return array( 'error' => 'NO_PREMIUM' );
}
}
$addons_options = maybe_unserialize( base64_decode( $_POST['addons_options'] ) );
@ -813,17 +813,17 @@ class MainWP_Child_Updraft_Plus_Backups {
/*
*Plugin: UpdraftPlus - Backup/Restore
*PluginURI: http://updraftplus.com
*Description: Backup and restore: take backups locally, or backup to Amazon S3, Dropbox, Google Drive, Rackspace, (S)FTP, WebDAV & email, on automatic schedules.
*Author: UpdraftPlus.Com, DavidAnderson
*Version: 1.9.60
*Donate link: http://david.dw-perspective.org.uk/donate
*License: GPLv3 or later
*Text Domain: updraftplus
*Domain Path: /languages
*Author URI: http://updraftplus.com
*/
*Plugin: UpdraftPlus - Backup/Restore
*PluginURI: http://updraftplus.com
*Description: Backup and restore: take backups locally, or backup to Amazon S3, Dropbox, Google Drive, Rackspace, (S)FTP, WebDAV & email, on automatic schedules.
*Author: UpdraftPlus.Com, DavidAnderson
*Version: 1.9.60
*Donate link: http://david.dw-perspective.org.uk/donate
*License: GPLv3 or later
*Text Domain: updraftplus
*Domain Path: /languages
*Author URI: http://updraftplus.com
*/
public function extradb_testconnection() {
@ -897,7 +897,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( ! $failed ) {
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N );
// $all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables );
$all_tables = array_map(array( $this, 'cb_get_name_base_type' ), $all_tables);
$all_tables = array_map(array( $this, 'cb_get_name_base_type' ), $all_tables);
if ( empty( $_POST['prefix'] ) ) {
$ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) );
@ -958,8 +958,8 @@ class MainWP_Child_Updraft_Plus_Backups {
'm' => '<strong>' . __( 'Start backup', 'updraftplus' ) . ':</strong> ' . htmlspecialchars( __( 'OK. You should soon see activity in the "Last log message" field below.', 'updraftplus' ) ),
);
// to fix issue for some site
// unfix for tic#22678
// to fix issue for some site
// unfix for tic#22678
$this->close_browser_connection( $msg );
$options = array(
@ -974,9 +974,9 @@ class MainWP_Child_Updraft_Plus_Backups {
do_action( $event, apply_filters( 'updraft_backupnow_options', $options, array() ) );
// return $msg;
// return $msg;
// Control returns when the backup finished; but, the browser connection should have been closed before
// Control returns when the backup finished; but, the browser connection should have been closed before
die;
// not used anymore
@ -1123,10 +1123,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$next_scheduled_backup = 'Nothing currently scheduled';
}
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Options', 'UpdraftPlus_Filesystem_Functions' ));
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location' ));
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Options', 'UpdraftPlus_Filesystem_Functions' ));
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location' ));
$next_scheduled_backup_database = wp_next_scheduled( 'updraft_backup_database' );
if ( UpdraftPlus_Options::get_updraft_option( 'updraft_interval_database', UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) === UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) {
@ -1143,7 +1143,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
$updraft_dir = $updraftplus->backups_dir_location();
$backup_disabled = ( UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir) ) ? 0 : 1;
$backup_disabled = ( UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir) ) ? 0 : 1;
$current_timegmt = time();
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
@ -1166,10 +1166,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$bh = $this->build_historystatus();
// to fix performance issue
if ( $with_hist ) {
// to fix performance issue
if ( $with_hist ) {
$out['updraft_historystatus'] = $bh['h'];
}
}
$out['updraft_count_backups'] = $bh['c'];
@ -1186,7 +1186,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
// UNIX timestamp
// UNIX timestamp
$next_scheduled_backup = wp_next_scheduled('updraft_backup');
if ( $next_scheduled_backup ) {
// Convert to GMT
@ -1270,11 +1270,11 @@ class MainWP_Child_Updraft_Plus_Backups {
private function deleteset() {
global $updraftplus;
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backups = $updraftplus->get_backup_history();
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backups = UpdraftPlus_Backup_History::get_history();
}
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backups = $updraftplus->get_backup_history();
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backups = UpdraftPlus_Backup_History::get_history();
}
$timestamp = $_POST['backup_timestamp'];
if ( ! isset( $backups[ $timestamp ] ) ) {
$bh = $this->build_historystatus();
@ -1404,8 +1404,8 @@ class MainWP_Child_Updraft_Plus_Backups {
public function build_historystatus() {
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
$backup_history = UpdraftPlus_Backup_History::get_history();
@ -1498,11 +1498,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms );
// Retrieve the information from our backup history
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backup_history = $updraftplus->get_backup_history();
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backup_history = UpdraftPlus_Backup_History::get_history();
}
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backup_history = $updraftplus->get_backup_history();
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backup_history = UpdraftPlus_Backup_History::get_history();
}
// Base name
$file = $backup_history[ $timestamp ][ $type ];
@ -1658,11 +1658,11 @@ class MainWP_Child_Updraft_Plus_Backups {
public function restore_alldownloaded() {
global $updraftplus;
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backups = $updraftplus->get_backup_history();
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backups = UpdraftPlus_Backup_History::get_history();
}
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backups = $updraftplus->get_backup_history();
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backups = UpdraftPlus_Backup_History::get_history();
}
$updraft_dir = $updraftplus->backups_dir_location();
@ -2377,11 +2377,11 @@ class MainWP_Child_Updraft_Plus_Backups {
// This attempts to raise the maximum packet size. This can't be done within the session, only globally. Therefore, it has to be done before the session starts; in our case, during the pre-analysis.
$updraftplus->get_max_packet_size();
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backup = $updraftplus->get_backup_history($timestamp);
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backup = UpdraftPlus_Backup_History::get_history($timestamp);
}
if ( method_exists($updraftplus, 'get_backup_history') ) {
$backup = $updraftplus->get_backup_history($timestamp);
} elseif ( class_exists('UpdraftPlus_Backup_History') ) {
$backup = UpdraftPlus_Backup_History::get_history($timestamp);
}
if ( ! isset( $backup['nonce'] ) || ! isset( $backup['db'] ) ) {
return array( $mess, $warn, $err, $info );
@ -2615,14 +2615,14 @@ class MainWP_Child_Updraft_Plus_Backups {
$backup = UpdraftPlus_Backup_History::get_history($timestamp);
if ( ! isset($backup['nonce']) || ! isset($backup['db']) ) {
return array( $mess, $warn, $err, $info );
}
}
$db_file = ( is_string($backup['db']) ) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0];
}
if ( ! is_readable($db_file) ) {
return array( $mess, $warn, $err, $info );
}
}
// Encrypted - decrypt it
if ( UpdraftPlus_Encryption::is_file_encrypted($db_file) ) {
@ -2767,7 +2767,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$powarn = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '</a>', $old_home, $res);
if ( ! empty($powarn) ) {
$warn[] = $powarn;
}
}
}
} elseif ( ! isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches) ) {
$info['created_by_version'] = trim($matches[1]);
@ -2775,7 +2775,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$old_wp_version = $matches[1];
if ( ! empty($matches[3]) ) {
$old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1);
}
}
if ( version_compare($old_wp_version, $wp_version, '>') ) {
// $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version);
$warn[] = sprintf(__('You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version);
@ -2821,7 +2821,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$info['multisite'] = $val ? true : false;
if ( $val ) {
$mess[] = '<strong>' . __('Site information:', 'updraftplus') . '</strong> ' . 'backup is of a WordPress Network';
}
}
}
$old_siteinfo[ $key ] = $val;
}
@ -2919,7 +2919,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$charset_select_html .= '</select>';
if ( empty($info['addui']) ) {
$info['addui'] = '';
}
}
$info['addui'] .= $charset_select_html;
}
}
@ -2985,7 +2985,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
/*
$blog_tables = "CREATE TABLE $wpdb->terms (
$blog_tables = "CREATE TABLE $wpdb->terms (
CREATE TABLE $wpdb->term_taxonomy (
CREATE TABLE $wpdb->term_relationships (
CREATE TABLE $wpdb->commentmeta (
@ -3006,7 +3006,7 @@ class MainWP_Child_Updraft_Plus_Backups {
*/
if ( ! isset($skipped_tables) ) {
$skipped_tables = array();
}
}
$missing_tables = array();
if ( $old_table_prefix ) {
if ( ! $header_only ) {
@ -3140,7 +3140,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return '<div class="ui yellow message">' . __( 'You have not yet made any backups.', 'updraftplus' ) . '</div>';
}
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'get_backupable_file_entities' ));
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'get_backupable_file_entities' ));
$updraft_dir = $updraftplus->backups_dir_location();
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
@ -3194,24 +3194,24 @@ class MainWP_Child_Updraft_Plus_Backups {
$date_label = $this->date_label( $pretty_date, $key, $backup, $jobdata, $non );
$service_title = '';
if ( ! isset($backup['service']) ) {
$service_title = '';
if ( ! isset($backup['service']) ) {
$backup['service'] = array();
}
if ( ! is_array($backup['service']) ) {
}
if ( ! is_array($backup['service']) ) {
$backup['service'] = array( $backup['service'] );
}
foreach ( $backup['service'] as $service ) {
if ( 'none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) ) ) {
// Do nothing
} else {
}
foreach ( $backup['service'] as $service ) {
if ( 'none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) ) ) {
// Do nothing
} else {
// $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png';
$remote_storage = ( 'remotesend' === $service ) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[ $service ];
$remote_storage = ( 'remotesend' === $service ) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[ $service ];
$service_title = '<br>' . esc_attr(sprintf(__('Remote storage: %s', 'updraftplus'), $remote_storage));
}
}
$service_title = '<br>' . esc_attr(sprintf(__('Remote storage: %s', 'updraftplus'), $remote_storage));
}
}
$ret .= <<<ENDHERE
<tr id="updraft_existing_backups_row_$key">
@ -3230,11 +3230,11 @@ ENDHERE;
// Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field.
$db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db'];
if ( class_exists( 'UpdraftPlus_Encryption') ) {
if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted') ) {
if ( UpdraftPlus_Encryption::is_file_encrypted($db) ) {
if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted') ) {
if ( UpdraftPlus_Encryption::is_file_encrypted($db) ) {
$entities .= '/dbcrypted=1/';
}
}
}
}
} elseif ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
$entities .= '/dbcrypted=1/';
}
@ -3396,7 +3396,7 @@ ENDHERE;
}
}
$fix_perfomance = 0;
$fix_perfomance = 0;
if ( isset( $backup[ $type ] ) ) {
if ( ! is_array( $backup[ $type ] ) ) {
@ -3446,10 +3446,10 @@ ENDHERE;
$first_printed = false;
}
$fix_perfomance++;
if ( $fix_perfomance > 50 ) { // // to fix perfomance issue of response when too much backup files
break;
}
$fix_perfomance++;
if ( $fix_perfomance > 50 ) { // // to fix perfomance issue of response when too much backup files
break;
}
}
}
}
@ -4051,14 +4051,14 @@ ENDHERE;
public function updraftplus_init() {
if ( ! $this->is_plugin_installed ) {
return;
}
return;
}
if ( get_option( 'mainwp_updraftplus_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_action( 'wp_before_admin_bar_render', array( $this, 'wp_before_admin_bar_render' ), 99 );
add_action( 'admin_init', array( $this, 'remove_notices' ) );
}
@ -4105,18 +4105,18 @@ ENDHERE;
}
}
function hide_update_notice( $slugs ) {
$slugs[] = 'updraftplus/updraftplus.php';
return $slugs;
}
function hide_update_notice( $slugs ) {
$slugs[] = 'updraftplus/updraftplus.php';
return $slugs;
}
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( isset( $value->response['updraftplus/updraftplus.php'] ) ) {
unset( $value->response['updraftplus/updraftplus.php'] );
@ -4126,7 +4126,7 @@ ENDHERE;
}
public function get_sync_data( $with_hist = false ) {
$this->required_files();
$this->required_files();
return $this->get_updraft_data( $with_hist );
}

View file

@ -18,7 +18,7 @@
class MainWP_Child_Vulnerability_Checker {
public static $instance = null;
public static $instance = null;
private $wpvulndb_api = 'https://wpvulndb.com/api/v3/';
private $wpvulndb_token = false;
@ -26,15 +26,15 @@ class MainWP_Child_Vulnerability_Checker {
if ( null === self::$instance ) {
self::$instance = new MainWP_Child_Vulnerability_Checker();
}
return self::$instance;
}
return self::$instance;
}
public function __construct() {
public function __construct() {
$this->wpvulndb_token = get_option('mainwp_child_wpvulndb_token', '');
}
}
public function action() {
$information = array();
public function action() {
$information = array();
if ( ! empty( $this->wpvulndb_token ) ) {
if ( isset( $_POST['mwp_action'] ) ) {
@ -46,25 +46,25 @@ class MainWP_Child_Vulnerability_Checker {
}
}
MainWP_Helper::write( $information );
}
MainWP_Helper::write( $information );
}
function vulner_recheck() {
$result = array();
$force = ( isset($_POST['force']) && ! empty($_POST['force']) ) ? true : false;
$result['plugin'] = $this->check_plugins($force);
$result['wp'] = $this->check_wp($force);
$result['theme'] = $this->check_themes($force);
$information = array(
function vulner_recheck() {
$result = array();
$force = ( isset($_POST['force']) && ! empty($_POST['force']) ) ? true : false;
$result['plugin'] = $this->check_plugins($force);
$result['wp'] = $this->check_wp($force);
$result['theme'] = $this->check_themes($force);
$information = array(
'result' => $result,
'ok' => 1,
);
return $information;
}
return $information;
}
function check_plugins( $force = false ) {
$result = array();
$active_plugins = get_option('active_plugins');
function check_plugins( $force = false ) {
$result = array();
$active_plugins = get_option('active_plugins');
if ( ! empty($active_plugins) ) {
foreach ( $active_plugins as $plug ) {
@ -115,130 +115,130 @@ class MainWP_Child_Vulnerability_Checker {
$result[ $plug ] = $plug_vuln;
}
}
return $result;
}
return $result;
}
function check_wp( $force = false ) {
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
$wp_version = str_replace('.', '', get_bloginfo('version'));
function check_wp( $force = false ) {
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
$wp_version = str_replace('.', '', get_bloginfo('version'));
if ( false === $wp_vuln || $force ) {
$wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version);
set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS);
}
return $wp_vuln;
}
return $wp_vuln;
}
function check_themes( $force = false ) {
function check_themes( $force = false ) {
require_once ABSPATH . 'wp-admin/includes/misc.php';
require_once ABSPATH . 'wp-admin/includes/theme.php';
require_once ABSPATH . 'wp-admin/includes/misc.php';
require_once ABSPATH . 'wp-admin/includes/theme.php';
if ( current_user_can( 'switch_themes' ) ) {
$themes = wp_prepare_themes_for_js();
} else {
$themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
}
wp_reset_vars( array( 'theme', 'search' ) );
$result = array();
if ( ! empty($themes) ) {
foreach ( $themes as $th ) {
if ( empty($th['parent']) ) {
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
if ( false === $th_vuln || $force ) {
$th_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'themes/' . $th['id']);
set_transient('mainwp_vulnche_trans_theme_' . $th['id'], $th_vuln, 1 * DAY_IN_SECONDS);
}
if ( current_user_can( 'switch_themes' ) ) {
$themes = wp_prepare_themes_for_js();
} else {
$themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
}
wp_reset_vars( array( 'theme', 'search' ) );
$result = array();
if ( ! empty($themes) ) {
foreach ( $themes as $th ) {
if ( empty($th['parent']) ) {
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
if ( false === $th_vuln || $force ) {
$th_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'themes/' . $th['id']);
set_transient('mainwp_vulnche_trans_theme_' . $th['id'], $th_vuln, 1 * DAY_IN_SECONDS);
}
if ( $th_vuln ) {
$th_vuln = json_decode($th_vuln, true);
$th_vuln_filter = $th_vuln;
foreach ( $th_vuln as $slug => $th_data ) {
if ( isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0 ) {
if ( $th_vuln ) {
$th_vuln = json_decode($th_vuln, true);
$th_vuln_filter = $th_vuln;
foreach ( $th_vuln as $slug => $th_data ) {
if ( isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0 ) {
$th_vulner_data = array();
foreach ( $th_data['vulnerabilities'] as $vuln_data ) {
if ( empty($vuln_data) ) {
continue;
}
$th_vulner_data = array();
foreach ( $th_data['vulnerabilities'] as $vuln_data ) {
if ( empty($vuln_data) ) {
continue;
}
if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) {
continue;
}
if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) {
continue;
}
$th_vulner_data[] = $vuln_data;
}
$th_vulner_data[] = $vuln_data;
}
if ( count($th_vulner_data) == 0 ) {
unset($th_vuln_filter[ $slug ]);
} else {
$th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data;
}
} else {
unset($th_vuln_filter[ $slug ]);
}
}
if ( count($th_vulner_data) == 0 ) {
unset($th_vuln_filter[ $slug ]);
} else {
$th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data;
}
} else {
unset($th_vuln_filter[ $slug ]);
}
}
if ( count($th_vuln_filter) == 0 ) {
continue;
}
if ( count($th_vuln_filter) == 0 ) {
continue;
}
$th_vuln = json_encode($th_vuln_filter);
} else {
continue;
}
$th_vuln = json_encode($th_vuln_filter);
} else {
continue;
}
$result[ $th['id'] ]['vulner_data'] = $th_vuln;
$result[ $th['id'] ]['name'] = $th['name'];
$result[ $th['id'] ]['author'] = $th['author'];
$result[ $th['id'] ]['detected_version'] = $th['version'];
}
}
}
return $result;
}
$result[ $th['id'] ]['vulner_data'] = $th_vuln;
$result[ $th['id'] ]['name'] = $th['name'];
$result[ $th['id'] ]['author'] = $th['author'];
$result[ $th['id'] ]['detected_version'] = $th['version'];
}
}
}
return $result;
}
function vulnche_get_content( $url ) {
function vulnche_get_content( $url ) {
$ch = curl_init();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Token token=' . $this->wpvulndb_token ));
curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$output = curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ( $output === false || $info != 200 ) {
$output = null;
}
return $output;
}
curl_close($ch);
if ( $output === false || $info != 200 ) {
$output = null;
}
return $output;
}
function get_random_user_agent() {
function get_random_user_agent() {
$someUA = array(
'Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13',
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)',
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)',
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)',
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
'Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)',
'Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)',
'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)',
);
$someUA = array(
'Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13',
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)',
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)',
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)',
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
'Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)',
'Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)',
'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)',
);
srand( (float) microtime() * 1000000);
srand( (float) microtime() * 1000000);
return $someUA[ rand(0, count($someUA) - 1) ];
}
return $someUA[ rand(0, count($someUA) - 1) ];
}
}

View file

@ -48,7 +48,7 @@ class MainWP_Child_WooCommerce_Status {
case 'report_data':
$information = ! $is_ver220 ? $this->report_data() : $this->report_data_two();
break;
case 'update_wc_db':
case 'update_wc_db':
$information = $this->update_wc_db();
break;
}
@ -189,8 +189,8 @@ class MainWP_Child_WooCommerce_Status {
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
$start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date );
$start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date );
// Get sales
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
@ -298,12 +298,12 @@ class MainWP_Child_WooCommerce_Status {
}
function sync_data_two() {
// sync data for current month
$start_date = date( 'Y-m-01 00:00:00', time() );
$end_date = date( 'Y-m-d H:i:s', time() );
// sync data for current month
$start_date = date( 'Y-m-01 00:00:00', time() );
$end_date = date( 'Y-m-d H:i:s', time() );
$start_date = strtotime( $start_date );
$end_date = strtotime( $end_date );
$start_date = strtotime( $start_date );
$end_date = strtotime( $end_date );
return $this->get_woocom_data( $start_date, $end_date );
}
@ -315,11 +315,11 @@ class MainWP_Child_WooCommerce_Status {
return $this->get_woocom_data( $start_date, $end_date );
}
function check_db_update() {
function check_db_update() {
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
return true;
}
return false;
return true;
}
return false;
}
function get_woocom_data( $start_date, $end_date ) {
@ -331,8 +331,8 @@ class MainWP_Child_WooCommerce_Status {
return false;
}
$start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date );
$start_date = date( 'Y-m-d H:i:s', $start_date );
$end_date = date( 'Y-m-d H:i:s', $end_date );
$reports = new WC_Admin_Report();
// Sales
@ -436,12 +436,12 @@ class MainWP_Child_WooCommerce_Status {
'outstock' => $outofstock_count,
);
$information['data'] = $data;
$information['need_db_update'] = $this->check_db_update();
$information['need_db_update'] = $this->check_db_update();
return $information;
}
private static function update_wc_db() {
include_once WC()->plugin_path() . '/includes/class-wc-background-updater.php';
private static function update_wc_db() {
include_once WC()->plugin_path() . '/includes/class-wc-background-updater.php';
$background_updater = new WC_Background_Updater();
$current_db_version = get_option( 'woocommerce_db_version' );
@ -465,7 +465,7 @@ class MainWP_Child_WooCommerce_Status {
$background_updater->save()->dispatch();
}
return array( 'result' => 'success' );
return array( 'result' => 'success' );
}
}

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@
class MainWP_Child_WP_Rocket {
public static $instance = null;
public $is_plugin_installed = false;
public $is_plugin_installed = false;
public static function Instance() {
if ( null === self::$instance ) {
@ -28,9 +28,9 @@ class MainWP_Child_WP_Rocket {
}
public function __construct() {
if ( is_plugin_active( 'wp-rocket/wp-rocket.php' ) ) {
$this->is_plugin_installed = true;
}
if ( is_plugin_active( 'wp-rocket/wp-rocket.php' ) ) {
$this->is_plugin_installed = true;
}
}
public function init() {
@ -38,17 +38,17 @@ class MainWP_Child_WP_Rocket {
// return;
// }
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
if ( get_option( 'mainwp_wprocket_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
add_action( 'wp_before_admin_bar_render', array( $this, 'wp_before_admin_bar_render' ), 99 );
add_action( 'admin_init', array( $this, 'remove_notices' ) );
}
@ -134,15 +134,15 @@ class MainWP_Child_WP_Rocket {
);
}
// ok
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
try {
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) );
$information['syncWPRocketData'] = $data;
} catch ( Exception $e ) {
}
}
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
try {
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) );
$information['syncWPRocketData'] = $data;
} catch ( Exception $e ) {
}
}
return $information;
}
@ -182,19 +182,19 @@ class MainWP_Child_WP_Rocket {
}
}
function hide_update_notice( $slugs ) {
$slugs[] = 'wp-rocket/wp-rocket.php';
return $slugs;
}
function hide_update_notice( $slugs ) {
$slugs[] = 'wp-rocket/wp-rocket.php';
return $slugs;
}
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( ! MainWP_Helper::is_screen_with_update() ) {
return $value;
}
if ( isset( $value->response['wp-rocket/wp-rocket.php'] ) ) {
unset( $value->response['wp-rocket/wp-rocket.php'] );
@ -204,9 +204,9 @@ class MainWP_Child_WP_Rocket {
}
public function isActivated() {
if ( ! $this->is_plugin_installed ) {
return false;
}
if ( ! $this->is_plugin_installed ) {
return false;
}
// if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) {
// return false;
// }
@ -244,7 +244,7 @@ class MainWP_Child_WP_Rocket {
public function action() {
if ( ! $this->is_plugin_installed ) {
if ( ! $this->is_plugin_installed ) {
MainWP_Helper::write( array( 'error' => __( 'Please install WP Rocket plugin on child website', $this->plugin_translate ) ) );
return;
}
@ -253,42 +253,42 @@ class MainWP_Child_WP_Rocket {
if ( isset( $_POST['mwp_action'] ) ) {
// MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' );
try {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'purge_cloudflare':
$information = $this->purge_cloudflare();
break;
case 'purge_all':
$information = $this->purge_cache_all();
break;
case 'preload_cache':
$information = $this->preload_cache();
break;
case 'generate_critical_css':
$information = $this->generate_critical_css();
break;
case 'save_settings':
$information = $this->save_settings();
break;
case 'load_existing_settings':
$information = $this->load_existing_settings();
break;
case 'optimize_database':
$information = $this->optimize_database();
break;
case 'get_optimize_info':
$information = $this->get_optimize_info();
break;
case 'purge_opcache':
$information = $this->do_admin_post_rocket_purge_opcache();
break;
}
} catch ( Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
try {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
$information = $this->set_showhide();
break;
case 'purge_cloudflare':
$information = $this->purge_cloudflare();
break;
case 'purge_all':
$information = $this->purge_cache_all();
break;
case 'preload_cache':
$information = $this->preload_cache();
break;
case 'generate_critical_css':
$information = $this->generate_critical_css();
break;
case 'save_settings':
$information = $this->save_settings();
break;
case 'load_existing_settings':
$information = $this->load_existing_settings();
break;
case 'optimize_database':
$information = $this->optimize_database();
break;
case 'get_optimize_info':
$information = $this->get_optimize_info();
break;
case 'purge_opcache':
$information = $this->do_admin_post_rocket_purge_opcache();
break;
}
} catch ( Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
}
MainWP_Helper::write( $information );
}
@ -301,14 +301,14 @@ class MainWP_Child_WP_Rocket {
return $information;
}
function do_admin_post_rocket_purge_opcache() {
if ( function_exists( 'opcache_reset' ) ) {
@opcache_reset();
} else {
return array( 'error' => 'The host do not support the function reset opcache.' );
}
return array( 'result' => 'SUCCESS' );
}
function do_admin_post_rocket_purge_opcache() {
if ( function_exists( 'opcache_reset' ) ) {
@opcache_reset();
} else {
return array( 'error' => 'The host do not support the function reset opcache.' );
}
return array( 'result' => 'SUCCESS' );
}
function purge_cloudflare() {
if ( function_exists( 'rocket_purge_cloudflare' ) ) {
@ -335,7 +335,7 @@ class MainWP_Child_WP_Rocket {
rocket_clean_cache_busting();
}
if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH') ) {
if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH') ) {
require_once WP_ROCKET_ADMIN_PATH . 'admin.php';
}
@ -357,24 +357,24 @@ class MainWP_Child_WP_Rocket {
}
function preload_cache() {
MainWP_Helper::check_functions( array( 'run_rocket_sitemap_preload', 'run_rocket_bot' ) );
MainWP_Helper::check_classes_exists('WP_Rocket\Preload\Full_Process');
MainWP_Helper::check_functions( array( 'run_rocket_sitemap_preload', 'run_rocket_bot' ) );
MainWP_Helper::check_classes_exists('WP_Rocket\Preload\Full_Process');
$preload_process = new WP_Rocket\Preload\Full_Process();
MainWP_Helper::check_methods($preload_process, array( 'is_process_running' ));
$preload_process = new WP_Rocket\Preload\Full_Process();
MainWP_Helper::check_methods($preload_process, array( 'is_process_running' ));
if ( $preload_process->is_process_running() ) {
return array( 'result' => 'RUNNING' );
}
if ( $preload_process->is_process_running() ) {
return array( 'result' => 'RUNNING' );
}
delete_transient( 'rocket_preload_errors' );
run_rocket_bot( 'cache-preload', '' );
run_rocket_sitemap_preload();
return array( 'result' => 'SUCCESS' );
delete_transient( 'rocket_preload_errors' );
run_rocket_bot( 'cache-preload', '' );
run_rocket_sitemap_preload();
return array( 'result' => 'SUCCESS' );
}
function generate_critical_css() {
MainWP_Helper::check_classes_exists( array(
function generate_critical_css() {
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber',
'WP_Rocket\Optimization\CSS\Critical_CSS',
'WP_Rocket\Optimization\CSS\Critical_CSS_Generation',
@ -382,18 +382,18 @@ class MainWP_Child_WP_Rocket {
'WP_Rocket\Admin\Options_Data',
));
$critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() );
$options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' );
$options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) );
$critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() );
$options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' );
$options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) );
$sitemap_preload = new WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber( $critical_css, $options );
$sitemap_preload = new WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber( $critical_css, $options );
MainWP_Helper::check_properties($sitemap_preload, 'critical_css');
MainWP_Helper::check_methods($sitemap_preload->critical_css, 'process_handler');
MainWP_Helper::check_properties($sitemap_preload, 'critical_css');
MainWP_Helper::check_methods($sitemap_preload->critical_css, 'process_handler');
$sitemap_preload->critical_css->process_handler();
$sitemap_preload->critical_css->process_handler();
return array( 'result' => 'SUCCESS' );
return array( 'result' => 'SUCCESS' );
}
function save_settings() {
@ -413,7 +413,7 @@ class MainWP_Child_WP_Rocket {
update_option( WP_ROCKET_SLUG, $options );
if ( isset($_POST['do_database_optimization']) && ! empty($_POST['do_database_optimization']) ) {
if ( isset($_POST['do_database_optimization']) && ! empty($_POST['do_database_optimization']) ) {
$this->optimize_database();
}
@ -422,53 +422,53 @@ class MainWP_Child_WP_Rocket {
function optimize_database() {
MainWP_Helper::check_classes_exists( array(
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
'WP_Rocket\Admin\Options',
'WP_Rocket\Admin\Options_Data',
));
$process = new WP_Rocket\Admin\Database\Optimization_Process();
$optimization = new WP_Rocket\Admin\Database\Optimization( $process );
MainWP_Helper::check_methods( $optimization, array( 'process_handler', 'get_options' ) );
$process = new WP_Rocket\Admin\Database\Optimization_Process();
$optimization = new WP_Rocket\Admin\Database\Optimization( $process );
MainWP_Helper::check_methods( $optimization, array( 'process_handler', 'get_options' ) );
$options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' );
$options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) );
$options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' );
$options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) );
$items = array_filter( array_keys( $optimization->get_options() ), array( $options, 'get' ) );
$items = array_filter( array_keys( $optimization->get_options() ), array( $options, 'get' ) );
if ( ! empty( $items ) ) {
$optimization->process_handler( $items );
$optimization->process_handler( $items );
}
$return['result'] = 'SUCCESS';
$return['result'] = 'SUCCESS';
return $return;
}
function get_optimize_info() {
MainWP_Helper::check_classes_exists( array(
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
));
$process = new WP_Rocket\Admin\Database\Optimization_Process();
$optimization = new WP_Rocket\Admin\Database\Optimization( $process );
MainWP_Helper::check_methods($optimization, 'count_cleanup_items');
$process = new WP_Rocket\Admin\Database\Optimization_Process();
$optimization = new WP_Rocket\Admin\Database\Optimization( $process );
MainWP_Helper::check_methods($optimization, 'count_cleanup_items');
$information['optimize_info'] = array(
'total_revisions' => $optimization->count_cleanup_items( 'database_revisions' ),
'total_auto_draft' => $optimization->count_cleanup_items( 'database_auto_drafts' ),
'total_trashed_posts' => $optimization->count_cleanup_items( 'database_trashed_posts' ),
'total_spam_comments' => $optimization->count_cleanup_items( 'database_spam_comments' ),
'total_trashed_comments' => $optimization->count_cleanup_items( 'database_trashed_comments' ),
'total_expired_transients' => $optimization->count_cleanup_items( 'database_expired_transients' ),
'total_all_transients' => $optimization->count_cleanup_items( 'database_all_transients' ),
'total_optimize_tables' => $optimization->count_cleanup_items( 'database_optimize_tables' ),
);
$information['optimize_info'] = array(
'total_revisions' => $optimization->count_cleanup_items( 'database_revisions' ),
'total_auto_draft' => $optimization->count_cleanup_items( 'database_auto_drafts' ),
'total_trashed_posts' => $optimization->count_cleanup_items( 'database_trashed_posts' ),
'total_spam_comments' => $optimization->count_cleanup_items( 'database_spam_comments' ),
'total_trashed_comments' => $optimization->count_cleanup_items( 'database_trashed_comments' ),
'total_expired_transients' => $optimization->count_cleanup_items( 'database_expired_transients' ),
'total_all_transients' => $optimization->count_cleanup_items( 'database_all_transients' ),
'total_optimize_tables' => $optimization->count_cleanup_items( 'database_optimize_tables' ),
);
$information['result'] = 'SUCCESS';
$information['result'] = 'SUCCESS';
return $information;
}

View file

@ -2,278 +2,278 @@
class MainWP_Child_WPvivid_BackupRestore {
public static $instance = null;
public $is_plugin_installed = false;
public $public_intetface;
static function Instance() {
if ( null === self::$instance ) {
self::$instance = new MainWP_Child_WPvivid_BackupRestore();
}
public static $instance = null;
public $is_plugin_installed = false;
public $public_intetface;
static function Instance() {
if ( null === self::$instance ) {
self::$instance = new MainWP_Child_WPvivid_BackupRestore();
}
return self::$instance;
}
return self::$instance;
}
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR') ) {
$this->is_plugin_installed = true;
}
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR') ) {
$this->is_plugin_installed = true;
}
if ( ! $this->is_plugin_installed ) {
return;
}
if ( ! $this->is_plugin_installed ) {
return;
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
$this->public_intetface = new WPvivid_Public_Interface();
}
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
$this->public_intetface = new WPvivid_Public_Interface();
}
public function init() {
}
public function init() {
}
function syncOthersData( $information, $data = array() ) {
try {
function syncOthersData( $information, $data = array() ) {
try {
if ( isset( $data['syncWPvividData'] ) ) {
$information['syncWPvividData'] = 1;
$data = WPvivid_Setting::get_sync_data();
$information['syncWPvividSettingData'] = $data['setting'];
$information['syncWPvividRemoteData'] = $data['remote'];
$information['syncWPvividScheduleData'] = $data['schedule'];
$information['syncWPvividSetting'] = $data;
}
if ( isset( $data['syncWPvividData'] ) ) {
$information['syncWPvividData'] = 1;
$data = WPvivid_Setting::get_sync_data();
$information['syncWPvividSettingData'] = $data['setting'];
$information['syncWPvividRemoteData'] = $data['remote'];
$information['syncWPvividScheduleData'] = $data['schedule'];
$information['syncWPvividSetting'] = $data;
}
} catch ( Exception $e ) {
}
}
return $information;
}
public function action() {
$information = array();
if ( ! $this->is_plugin_installed ) {
$information['error'] = 'NO_WPVIVIDBACKUP';
MainWP_Helper::write( $information );
}
if ( isset( $_POST['mwp_action'] ) ) {
try {
switch ( $_POST['mwp_action'] ) {
case 'prepare_backup':
$information = $this->prepare_backup();
break;
case 'backup_now':
$information = $this->backup_now();
break;
case 'get_status':
$information = $this->get_status();
break;
case 'get_backup_schedule':
$information = $this->get_backup_schedule();
break;
case 'get_backup_list':
$information = $this->get_backup_list();
break;
case 'get_default_remote':
$information = $this->get_default_remote();
break;
case 'delete_backup':
$information = $this->delete_backup();
break;
case 'delete_backup_array':
$information = $this->delete_backup_array();
break;
case 'set_security_lock':
$information = $this->set_security_lock();
break;
case 'view_log':
$information = $this->view_log();
break;
case 'read_last_backup_log':
$information = $this->read_last_backup_log();
break;
case 'view_backup_task_log':
$information = $this->view_backup_task_log();
break;
case 'backup_cancel':
$information = $this->backup_cancel();
break;
case 'init_download_page':
$information = $this->init_download_page();
break;
case 'prepare_download_backup':
$information = $this->prepare_download_backup();
break;
case 'get_download_task':
$information = $this->get_download_task();
break;
case 'download_backup':
$information = $this->download_backup();
break;
case 'set_general_setting':
$information = $this->set_general_setting();
break;
case 'set_schedule':
$information = $this->set_schedule();
break;
case 'set_remote':
$information = $this->set_remote();
break;
default:
$information = $this->post_mainwp_data($_POST);
break;
}
} catch ( Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
MainWP_Helper::write($information);
}
}
public function post_mainwp_data( $data ) {
global $wpvivid_plugin;
$ret = $wpvivid_plugin->wpvivid_handle_mainwp_action($data);
return $ret;
}
public function prepare_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->prepare_backup($_POST['backup']);
return $ret;
return $information;
}
public function backup_now() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->backup_now($_POST['task_id']);
return $ret;
}
public function action() {
$information = array();
if ( ! $this->is_plugin_installed ) {
$information['error'] = 'NO_WPVIVIDBACKUP';
MainWP_Helper::write( $information );
}
public function get_status() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_status();
return $ret;
}
if ( isset( $_POST['mwp_action'] ) ) {
try {
switch ( $_POST['mwp_action'] ) {
case 'prepare_backup':
$information = $this->prepare_backup();
break;
case 'backup_now':
$information = $this->backup_now();
break;
case 'get_status':
$information = $this->get_status();
break;
case 'get_backup_schedule':
$information = $this->get_backup_schedule();
break;
case 'get_backup_list':
$information = $this->get_backup_list();
break;
case 'get_default_remote':
$information = $this->get_default_remote();
break;
case 'delete_backup':
$information = $this->delete_backup();
break;
case 'delete_backup_array':
$information = $this->delete_backup_array();
break;
case 'set_security_lock':
$information = $this->set_security_lock();
break;
case 'view_log':
$information = $this->view_log();
break;
case 'read_last_backup_log':
$information = $this->read_last_backup_log();
break;
case 'view_backup_task_log':
$information = $this->view_backup_task_log();
break;
case 'backup_cancel':
$information = $this->backup_cancel();
break;
case 'init_download_page':
$information = $this->init_download_page();
break;
case 'prepare_download_backup':
$information = $this->prepare_download_backup();
break;
case 'get_download_task':
$information = $this->get_download_task();
break;
case 'download_backup':
$information = $this->download_backup();
break;
case 'set_general_setting':
$information = $this->set_general_setting();
break;
case 'set_schedule':
$information = $this->set_schedule();
break;
case 'set_remote':
$information = $this->set_remote();
break;
default:
$information = $this->post_mainwp_data($_POST);
break;
}
} catch ( Exception $e ) {
$information = array( 'error' => $e->getMessage() );
}
public function get_backup_schedule() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_backup_schedule();
return $ret;
MainWP_Helper::write($information);
}
}
public function get_backup_list() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_backup_list();
return $ret;
public function post_mainwp_data( $data ) {
global $wpvivid_plugin;
$ret = $wpvivid_plugin->wpvivid_handle_mainwp_action($data);
return $ret;
}
public function get_default_remote() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_default_remote();
return $ret;
public function prepare_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->prepare_backup($_POST['backup']);
return $ret;
}
public function delete_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']);
return $ret;
public function backup_now() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->backup_now($_POST['task_id']);
return $ret;
}
public function delete_backup_array() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->delete_backup_array($_POST['backup_id']);
return $ret;
public function get_status() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_status();
return $ret;
}
public function set_security_lock() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']);
return $ret;
public function get_backup_schedule() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_backup_schedule();
return $ret;
}
public function view_log() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->view_log($_POST['id']);
return $ret;
public function get_backup_list() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_backup_list();
return $ret;
}
public function read_last_backup_log() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']);
return $ret;
public function get_default_remote() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_default_remote();
return $ret;
}
public function view_backup_task_log() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->view_backup_task_log($_POST['id']);
return $ret;
public function delete_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']);
return $ret;
}
public function backup_cancel() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->backup_cancel($_POST['task_id']);
return $ret;
public function delete_backup_array() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->delete_backup_array($_POST['backup_id']);
return $ret;
}
public function init_download_page() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->init_download_page($_POST['backup_id']);
return $ret;
public function set_security_lock() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']);
return $ret;
}
public function prepare_download_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']);
return $ret;
public function view_log() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->view_log($_POST['id']);
return $ret;
}
public function get_download_task() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_download_task($_POST['backup_id']);
return $ret;
public function read_last_backup_log() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']);
return $ret;
}
public function download_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']);
return $ret;
public function view_backup_task_log() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->view_backup_task_log($_POST['id']);
return $ret;
}
public function set_general_setting() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_general_setting($_POST['setting']);
return $ret;
public function backup_cancel() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->backup_cancel($_POST['task_id']);
return $ret;
}
public function set_schedule() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_schedule($_POST['schedule']);
return $ret;
public function init_download_page() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->init_download_page($_POST['backup_id']);
return $ret;
}
public function set_remote() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_remote($_POST['remote']);
return $ret;
public function prepare_download_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']);
return $ret;
}
public function get_download_task() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->get_download_task($_POST['backup_id']);
return $ret;
}
public function download_backup() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']);
return $ret;
}
public function set_general_setting() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_general_setting($_POST['setting']);
return $ret;
}
public function set_schedule() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_schedule($_POST['schedule']);
return $ret;
}
public function set_remote() {
global $wpvivid_plugin;
$wpvivid_plugin->ajax_check_security();
$ret = $this->public_intetface->set_remote($_POST['remote']);
return $ret;
}
}

File diff suppressed because it is too large Load diff

View file

@ -487,7 +487,7 @@ class MainWP_Client_Report {
if ( $record->connector == 'editor' ) {
if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) {
continue;
}
}
} elseif ( $connector !== $record->connector ) {
continue;
}

View file

@ -648,7 +648,7 @@ class MainWP_Clone_Install {
* @return array The original array with all elements replaced as needed.
*/
/* Fixed serialize issue */
/* Fixed serialize issue */
function recursive_unserialize_replace( $from = '', $to = '', $data = '', $serialised = false ) {
// some unseriliased data cannot be re-serialised eg. SimpleXMLElements
@ -666,7 +666,7 @@ class MainWP_Clone_Install {
unset( $_tmp );
} elseif ( is_object( $data ) ) {
$_tmp = $data;
$props = get_object_vars( $data );
$props = get_object_vars( $data );
foreach ( $props as $key => $value ) {
$_tmp->{$key} = $this->recursive_unserialize_replace( $from, $to, $value, false );
}
@ -674,10 +674,10 @@ class MainWP_Clone_Install {
$data = $_tmp;
unset( $_tmp );
} elseif ( is_serialized_string($data) && is_serialized($data) ) {
// TODO: apply solution like phpmyadmin project have!
// TODO: apply solution like phpmyadmin project have!
if ( ( $data = @unserialize( $data ) ) !== false ) {
$data = str_replace( $from, $to, $data );
$data = serialize( $data );
$data = serialize( $data );
}
} else {
if ( is_string( $data ) ) {

File diff suppressed because it is too large Load diff

View file

@ -67,16 +67,16 @@ class MainWP_Custom_Post_Type {
if ( empty( $data ) || ! is_array( $data ) || ! isset( $data['post'] ) ) {
return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) );
}
$edit_id = ( isset($_POST['post_id']) && ! empty($_POST['post_id']) ) ? $_POST['post_id'] : 0;
$edit_id = ( isset($_POST['post_id']) && ! empty($_POST['post_id']) ) ? $_POST['post_id'] : 0;
$return = $this->_insert_post($data, $edit_id, $parent_id = 0);
if ( isset($return['success']) && $return['success'] == 1 ) {
if ( isset($data['product_variation']) && is_array($data['product_variation']) ) {
foreach ( $data['product_variation'] as $product_variation ) {
$return_variantion = $this->_insert_post($product_variation, 0, $return['post_id']);
}
}
}
return $return;
if ( isset($return['success']) && $return['success'] == 1 ) {
if ( isset($data['product_variation']) && is_array($data['product_variation']) ) {
foreach ( $data['product_variation'] as $product_variation ) {
$return_variantion = $this->_insert_post($product_variation, 0, $return['post_id']);
}
}
}
return $return;
}
@ -135,7 +135,7 @@ class MainWP_Custom_Post_Type {
return $post_content;
}
private function _insert_post( $data, $edit_id, $parent_id = 0 ) {
private function _insert_post( $data, $edit_id, $parent_id = 0 ) {
// Insert post
$data_insert = array();
@ -181,7 +181,7 @@ class MainWP_Custom_Post_Type {
$is_woocomerce = true;
}
$check_image_existed = false;
$check_image_existed = false;
// Support post_edit
if ( ! empty( $edit_id ) ) {
@ -197,7 +197,7 @@ class MainWP_Custom_Post_Type {
if ( get_post_status( $old_post_id ) == 'trash' ) {
return array( 'error' => __( 'This post is inside trash on child website. Please try publish it manually and try again.', $this->plugin_translate ) );
}
$check_image_existed = true;
$check_image_existed = true;
// Set id
$data_insert['ID'] = $old_post_id;
@ -213,11 +213,11 @@ class MainWP_Custom_Post_Type {
wp_delete_object_term_relationships( $old_post_id, get_object_taxonomies( $data_insert['post_type'] ) );
}
$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'], $check_image_existed );
$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'], $check_image_existed );
if ( ! empty($parent_id) ) {
$data_insert['post_parent'] = $parent_id; // for product variation
}
if ( ! empty($parent_id) ) {
$data_insert['post_parent'] = $parent_id; // for product variation
}
$post_id = wp_insert_post( $data_insert, true );
if ( is_wp_error( $post_id ) ) {
return array( 'error' => __( 'Error when insert new post:', $this->plugin_translate ) . ' ' . $post_id->get_error_message() );
@ -275,7 +275,7 @@ class MainWP_Custom_Post_Type {
}
}
$meta_value = maybe_unserialize( $key['meta_value'] );
$meta_value = maybe_unserialize( $key['meta_value'] );
if ( add_post_meta( $post_id, $key['meta_key'], $meta_value ) === false ) {
return array( 'error' => __( 'Error when adding post meta', $this->plugin_translate ) . ' `' . esc_html( $key['meta_key'] ) . '`' );
}

View file

@ -104,7 +104,7 @@ class MainWP_Helper {
$information['error'] = $error;
if ( null !== $code ) {
$information['error_code'] = $code;
}
}
self::write( $information );
}
@ -153,7 +153,7 @@ class MainWP_Helper {
if ( ! empty($selector) ) {
if ( ! isset($new[ $selector ]) ) {
$new[ $selector ] = array();
}
}
$rules = explode(';', $val[ ++$i ]);
foreach ( $rules as $rule ) {
$rule = trim($rule, " \r\n\t");
@ -166,7 +166,7 @@ class MainWP_Helper {
$new[ $selector ][ $property ] = $value;
} elseif ( preg_match('/!important/', $new[ $selector ][ $property ]) && preg_match('/!important/', $value) ) {
$new[ $selector ][ $property ] = $value;
}
}
}
}
}
@ -182,7 +182,7 @@ class MainWP_Helper {
$prefix = "\t";
} else {
$prefix = '';
}
}
foreach ( $content as $selector => $rules ) {
$output .= $prefix . $selector . " {\n";
@ -199,12 +199,12 @@ class MainWP_Helper {
return $output;
}
// $check_file_existed: to support checking if file existed
// $parent_id: optional
// $check_file_existed: to support checking if file existed
// $parent_id: optional
static function uploadImage( $img_url, $img_data = array(), $check_file_existed = false, $parent_id = 0 ) {
if ( ! is_array($img_data) ) {
$img_data = array();
}
}
include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
$upload_dir = wp_upload_dir();
// Download $img_url
@ -213,61 +213,61 @@ class MainWP_Helper {
if ( is_wp_error( $temporary_file ) ) {
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
} else {
$filename = basename( $img_url );
$filename = basename( $img_url );
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; // Local name
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
// $gen_unique_fn = true;
// $gen_unique_fn = true;
// to fix issue re-create new attachment
if ( $check_file_existed ) {
if ( file_exists( $local_img_path ) ) {
// to fix issue re-create new attachment
if ( $check_file_existed ) {
if ( file_exists( $local_img_path ) ) {
if ( filesize( $local_img_path ) == filesize( $temporary_file ) ) { // file exited
$result = self::get_maybe_existed_attached_id( $local_img_url );
if ( is_array($result) ) { // found attachment
$attach = current($result);
if ( is_object($attach) ) {
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array(
if ( filesize( $local_img_path ) == filesize( $temporary_file ) ) { // file exited
$result = self::get_maybe_existed_attached_id( $local_img_url );
if ( is_array($result) ) { // found attachment
$attach = current($result);
if ( is_object($attach) ) {
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array(
'id' => $attach->ID,
'url' => $local_img_url,
);
}
}
}
}
}
}
} else { // find in other path
$result = self::get_maybe_existed_attached_id( $filename, false );
$result = self::get_maybe_existed_attached_id( $filename, false );
if ( is_array( $result ) ) { // found attachment
$attach = current($result);
if ( is_object($attach) ) {
$basedir = $upload_dir['basedir'];
$baseurl = $upload_dir['baseurl'];
$local_img_path = str_replace( $baseurl, $basedir, $attach->guid );
if ( file_exists($local_img_path) && ( filesize( $local_img_path ) == filesize( $temporary_file ) ) ) { // file exited
if ( is_array( $result ) ) { // found attachment
$attach = current($result);
if ( is_object($attach) ) {
$basedir = $upload_dir['basedir'];
$baseurl = $upload_dir['baseurl'];
$local_img_path = str_replace( $baseurl, $basedir, $attach->guid );
if ( file_exists($local_img_path) && ( filesize( $local_img_path ) == filesize( $temporary_file ) ) ) { // file exited
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array(
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array(
'id' => $attach->ID,
'url' => $attach->guid,
);
}
}
}
}
}
}
}
}
}
// file exists, do not overwrite, generate unique file name
// file exists, do not overwrite, generate unique file name
// this may causing of issue incorrect source of image in post content
if ( file_exists( $local_img_path ) ) {
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
}
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
}
$moved = @rename( $temporary_file, $local_img_path );
@ -279,13 +279,13 @@ class MainWP_Helper {
'post_content' => isset( $img_data['description'] ) && ! empty( $img_data['description'] ) ? $img_data['description'] : '',
'post_excerpt' => isset( $img_data['caption'] ) && ! empty( $img_data['caption'] ) ? $img_data['caption'] : '',
'post_status' => 'inherit',
'guid' => $local_img_url, // to fix
'guid' => $local_img_url, // to fix
);
// for post attachments, thumbnail
if ( $parent_id ) {
$attachment['post_parent'] = $parent_id;
}
// for post attachments, thumbnail
if ( $parent_id ) {
$attachment['post_parent'] = $parent_id;
}
$attach_id = wp_insert_attachment( $attachment, $local_img_path ); // Insert the image in the database
require_once ABSPATH . 'wp-admin/includes/image.php';
@ -293,7 +293,7 @@ class MainWP_Helper {
wp_update_attachment_metadata( $attach_id, $attach_data ); // Update generated metadata
if ( isset( $img_data['alt'] ) && ! empty( $img_data['alt'] ) ) {
update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] );
}
}
return array(
'id' => $attach_id,
'url' => $local_img_url,
@ -308,23 +308,23 @@ class MainWP_Helper {
}
static function get_maybe_existed_attached_id( $filename, $full_guid = true ) {
global $wpdb;
if ( $full_guid ) {
$sql = $wpdb->prepare(
"SELECT ID,guid FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s",
$filename
);
} else {
$sql = "SELECT ID,guid FROM $wpdb->posts WHERE post_type = 'attachment' AND guid LIKE '%/" . $filename . "'";
}
return $wpdb->get_results( $sql );
global $wpdb;
if ( $full_guid ) {
$sql = $wpdb->prepare(
"SELECT ID,guid FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s",
$filename
);
} else {
$sql = "SELECT ID,guid FROM $wpdb->posts WHERE post_type = 'attachment' AND guid LIKE '%/" . $filename . "'";
}
return $wpdb->get_results( $sql );
}
static function uploadFile( $file_url, $path, $file_name ) {
// to fix uploader extension rename htaccess file issue
if ( $file_name != '.htaccess' && $file_name != '.htpasswd' ) {
$file_name = sanitize_file_name( $file_name );
}
// to fix uploader extension rename htaccess file issue
if ( $file_name != '.htaccess' && $file_name != '.htpasswd' ) {
$file_name = sanitize_file_name( $file_name );
}
$full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; // Local name
@ -361,18 +361,18 @@ class MainWP_Helper {
static function createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others = array() ) {
global $current_user;
/**
* Hook: `mainwp_before_post_update`
*
* Runs before creating or updating a post via MainWP dashboard.
*
* @param array $new_post Post data array.
* @param array $post_custom Post custom meta data.
* @param string $post_category Post categories.
* @param string $post_tags Post tags.
*/
/**
* Hook: `mainwp_before_post_update`
*
* Runs before creating or updating a post via MainWP dashboard.
*
* @param array $new_post Post data array.
* @param array $post_custom Post custom meta data.
* @param string $post_category Post categories.
* @param string $post_tags Post tags.
*/
do_action( 'mainwp_before_post_update', $new_post, $post_custom, $post_category, $post_tags );
do_action( 'mainwp_before_post_update', $new_post, $post_custom, $post_category, $post_tags );
// Options fields.
$wprocket_fields = array(
@ -408,8 +408,8 @@ class MainWP_Helper {
}
}
// current user may be connected admin or alternative admin
$current_uid = $current_user->ID;
// current user may be connected admin or alternative admin
$current_uid = $current_user->ID;
// Set up a new post (adding addition information)
// $usr = get_user_by( 'login', $_POST['user'] );
// $new_post['post_author'] = $current_user->ID;
@ -469,12 +469,12 @@ class MainWP_Helper {
if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) {
$edit_post_id = current($post_custom['_mainwp_edit_post_id']);
} elseif ( isset( $new_post['ID'] ) && $new_post['ID'] ) {
$edit_post_id = $new_post['ID'];
}
} elseif ( isset( $new_post['ID'] ) && $new_post['ID'] ) {
$edit_post_id = $new_post['ID'];
}
require_once ABSPATH . 'wp-admin/includes/post.php';
if ( $edit_post_id ) {
require_once ABSPATH . 'wp-admin/includes/post.php';
if ( $edit_post_id ) {
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
$user = get_userdata( $user_id );
$error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name );
@ -482,10 +482,10 @@ class MainWP_Helper {
}
}
$check_image_existed = false;
if ( $edit_post_id ) {
$check_image_existed = true; // if editing post then will check if image existed
}
$check_image_existed = false;
if ( $edit_post_id ) {
$check_image_existed = true; // if editing post then will check if image existed
}
// Search for all the images added to the new post
// some images have a href tag to click to navigate to the image.. we need to replace this too
@ -648,7 +648,7 @@ class MainWP_Helper {
'ID' => $new_post_id,
'post_status' => $post_status,
) );
}
}
if ( ! empty( $terms ) ) {
wp_set_object_terms( $new_post_id, array_map( intval, $terms ), 'category' );
@ -672,9 +672,9 @@ class MainWP_Helper {
'_categories',
'_edit_last',
'_sticky',
'_mainwp_post_dripper',
'_bulkpost_do_not_del',
'_mainwp_spin_me',
'_mainwp_post_dripper',
'_bulkpost_do_not_del',
'_mainwp_spin_me',
);
$not_allowed[] = '_mainwp_boilerplate_sites_posts';
$not_allowed[] = '_ezine_post_keyword';
@ -701,8 +701,8 @@ class MainWP_Helper {
$post_to_only_existing_categories = false;
if ( is_array($post_custom) ) {
foreach ( $post_custom as $meta_key => $meta_values ) {
if ( is_array($post_custom) ) {
foreach ( $post_custom as $meta_key => $meta_values ) {
if ( ! in_array( $meta_key, $not_allowed ) ) {
foreach ( $meta_values as $meta_value ) {
if ( strpos($meta_key, '_mainwp_spinner_') === 0 ) {
@ -730,7 +730,7 @@ class MainWP_Helper {
}
}
}
}
}
// yoast seo extension
if ( $seo_ext_activated ) {
@ -784,17 +784,17 @@ class MainWP_Helper {
if ( null !== $upload ) {
update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); // Add the thumbnail to the post!
$featured_image_exist = true;
if ( isset($others['featured_image_data']) ) {
$_image_data = $others['featured_image_data'];
update_post_meta( $upload['id'], '_wp_attachment_image_alt', $_image_data['alt'] );
wp_update_post( array(
if ( isset($others['featured_image_data']) ) {
$_image_data = $others['featured_image_data'];
update_post_meta( $upload['id'], '_wp_attachment_image_alt', $_image_data['alt'] );
wp_update_post( array(
'ID' => $upload['id'],
'post_excerpt' => $_image_data['caption'],
'post_content' => $_image_data['description'],
'post_title' => $_image_data['title'],
)
);
}
);
}
}
} catch ( Exception $e ) {
@ -867,10 +867,10 @@ class MainWP_Helper {
MainWP_Child_Robot::Instance()->wpr_insertcomments( $new_post_id, $all_comments );
}
// unlock if edit post
if ( $edit_post_id ) {
update_post_meta( $edit_post_id, '_edit_lock', '' );
}
// unlock if edit post
if ( $edit_post_id ) {
update_post_meta( $edit_post_id, '_edit_lock', '' );
}
$ret['success'] = true;
$ret['link'] = $permalink;
@ -1098,7 +1098,7 @@ class MainWP_Helper {
if ( ! is_array( $postdata ) ) {
$postdata = array();
}
}
$postdata['json_result'] = true; // forced all response in json format
@ -1311,7 +1311,7 @@ class MainWP_Helper {
if ( ! in_array($by, $backup_by) ) {
return false;
}
}
$lasttime = get_option('mainwp_lasttime_backup_' . $by);
if ( $time > $lasttime ) {
@ -1324,7 +1324,7 @@ class MainWP_Helper {
static function get_lasttime_backup( $by ) {
if ( $by == 'backupwp' ) { // to compatible
$by = 'backupwordpress';
}
}
switch ( $by ) {
case 'backupbuddy':
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' ) ) {
@ -1523,7 +1523,7 @@ class MainWP_Helper {
public static function sanitize_filename( $filename ) {
if ( ! function_exists('mb_ereg_replace') ) {
return sanitize_file_name($filename);
}
}
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_~,;:[]().
@ -1596,33 +1596,33 @@ class MainWP_Helper {
public static function isSSLEnabled() {
if ( defined( 'MAINWP_NOSSL' ) ) {
return ! MAINWP_NOSSL;
}
}
return function_exists( 'openssl_verify' );
}
public static function is_screen_with_update() {
public static function is_screen_with_update() {
if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined('DOING_CRON') && DOING_CRON ) ) {
return false;
}
if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined('DOING_CRON') && DOING_CRON ) ) {
return false;
}
if ( function_exists('get_current_screen') ) {
$screen = get_current_screen();
if ( $screen ) {
if ( $screen->base == 'update-core' && $screen->parent_file == 'index.php' ) {
return true;
}
}
}
return false;
}
if ( function_exists('get_current_screen') ) {
$screen = get_current_screen();
if ( $screen ) {
if ( $screen->base == 'update-core' && $screen->parent_file == 'index.php' ) {
return true;
}
}
}
return false;
}
public static function is_wp_engine() {
return function_exists( 'is_wpe' ) && is_wpe();
}
public static function is_wp_engine() {
return function_exists( 'is_wpe' ) && is_wpe();
}
public static function check_files_exists( $files = array(), $return = false ) {
$missing = array();
public static function check_files_exists( $files = array(), $return = false ) {
$missing = array();
if ( is_array($files) ) {
foreach ( $files as $name ) {
if ( ! file_exists( $name ) ) {
@ -1643,11 +1643,11 @@ class MainWP_Helper {
throw new Exception( $message );
}
}
return true;
return true;
}
public static function check_classes_exists( $classes = array(), $return = false ) {
$missing = array();
$missing = array();
if ( is_array($classes) ) {
foreach ( $classes as $name ) {
if ( ! class_exists( $name ) ) {
@ -1668,11 +1668,11 @@ class MainWP_Helper {
throw new Exception( $message );
}
}
return true;
return true;
}
public static function check_methods( $object, $methods = array(), $return = false ) {
$missing = array();
public static function check_methods( $object, $methods = array(), $return = false ) {
$missing = array();
if ( is_array($methods) ) {
$missing = array();
foreach ( $methods as $name ) {
@ -1695,11 +1695,11 @@ class MainWP_Helper {
}
}
return true;
return true;
}
public static function check_properties( $object, $properties = array(), $return = false ) {
$missing = array();
public static function check_properties( $object, $properties = array(), $return = false ) {
$missing = array();
if ( is_array($properties) ) {
foreach ( $properties as $name ) {
if ( ! property_exists($object, $name) ) {
@ -1721,11 +1721,11 @@ class MainWP_Helper {
}
}
return true;
return true;
}
public static function check_functions( $funcs = array(), $return = false ) {
$missing = array();
public static function check_functions( $funcs = array(), $return = false ) {
$missing = array();
if ( is_array($funcs) ) {
foreach ( $funcs as $name ) {
if ( ! function_exists( $name) ) {
@ -1747,33 +1747,33 @@ class MainWP_Helper {
}
}
return true;
}
return true;
}
/**
/**
* Handle fatal error for requests from the dashboard
* mwp_action requests
* wordpress_seo requests
* This will do not handle fatal error for sync request from the dashboard
* mwp_action requests
* wordpress_seo requests
* This will do not handle fatal error for sync request from the dashboard
*/
public static function handle_fatal_error() {
public static function handle_fatal_error() {
function handle_shutdown() {
// handle fatal errors and compile errors
$error = error_get_last();
if ( isset( $error['type'] ) && isset( $error['message'] ) &&
( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] )
) {
function handle_shutdown() {
// handle fatal errors and compile errors
$error = error_get_last();
if ( isset( $error['type'] ) && isset( $error['message'] ) &&
( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] )
) {
self::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
}
}
}
}
if ( isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
( isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function'] ) // wordpress_seo for WordPress SEO
) {
register_shutdown_function( 'handle_shutdown' );
}
}
if ( isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
( isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function'] ) // wordpress_seo for WordPress SEO
) {
register_shutdown_function( 'handle_shutdown' );
}
}
}

View file

@ -344,7 +344,7 @@ class MainWP_Keyword_Links {
$this->link_case_sensitive = $link->case_sensitive;
$keywords = $this->explode_multi( $link->keyword );
// usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
usort( $keywords, array( $this, 'usort_callback_func' ) );
usort( $keywords, array( $this, 'usort_callback_func' ) );
$replace_cs = $link->case_sensitive ? 's' : 'is';
// print_r($keywords);
foreach ( $keywords as $keyword ) {
@ -387,7 +387,7 @@ class MainWP_Keyword_Links {
return $content;
}
private function usort_callback_func( $a, $b ) {
private function usort_callback_func( $a, $b ) {
return strlen($a) < strlen($b);
}

View file

@ -273,18 +273,18 @@ class MainWP_Security {
}
public static function remove_registered_versions() {
if ( self::get_security_option( 'registered_versions' ) ) {
if ( self::get_security_option( 'registered_versions' ) ) {
global $wp_styles;
if ( $wp_styles instanceof WP_Styles ) {
foreach ( $wp_styles->registered as $handle => $style ) {
$wp_styles->registered[ $handle ]->ver = null;
}
$wp_styles->registered[ $handle ]->ver = null;
}
}
global $wp_scripts;
global $wp_scripts;
if ( $wp_scripts instanceof WP_Scripts ) {
foreach ( $wp_scripts->registered as $handle => $script ) {
$wp_scripts->registered[ $handle ]->ver = null;
}
$wp_scripts->registered[ $handle ]->ver = null;
}
}
}
}
@ -317,12 +317,12 @@ class MainWP_Security {
return $src;
}
public static function remove_readme( $force = false ) {
public static function remove_readme( $force = false ) {
// to prevent remove readme.html file on WPE hosts
if ( MainWP_Helper::is_wp_engine() ) {
return true;
}
// to prevent remove readme.html file on WPE hosts
if ( MainWP_Helper::is_wp_engine() ) {
return true;
}
if ( $force || self::get_security_option( 'readme' ) ) {
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
@ -354,7 +354,7 @@ class MainWP_Security {
$user = get_user_by( 'login', 'admin' );
if ( ! $user ) {
return true;
}
}
if ( 10 !== $user->wp_user_level && ( ! isset( $user->user_level ) || 10 !== $user->user_level ) && ! user_can( $user, 'level_10' ) ) {
return true;
@ -367,7 +367,7 @@ class MainWP_Security {
$security = get_option( 'mainwp_security' );
if ( ! empty($key) ) {
$security[ $key ] = $value;
}
}
MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
}
}

View file

@ -53,38 +53,38 @@ class MainWP_Wordpress_SEO {
}
public function import_settings() {
// to compatible
if ( isset($_POST['file_url']) ) {
$file_url = base64_decode( $_POST['file_url'] );
$temporary_file = '';
try {
include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
$temporary_file = download_url( $file_url );
// to compatible
if ( isset($_POST['file_url']) ) {
$file_url = base64_decode( $_POST['file_url'] );
$temporary_file = '';
try {
include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
$temporary_file = download_url( $file_url );
if ( is_wp_error( $temporary_file ) ) {
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.', 'wordpress-seo' ) );
}
}
} catch ( Exception $e ) {
$information['error'] = $e->getMessage();
}
if ( is_wp_error( $temporary_file ) ) {
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.', 'wordpress-seo' ) );
}
}
} catch ( Exception $e ) {
$information['error'] = $e->getMessage();
}
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
} elseif ( isset( $_POST['settings'] ) ) {
try {
$settings = base64_decode( $_POST['settings'] );
try {
$settings = base64_decode( $_POST['settings'] );
// @codingStandardsIgnoreLine
$options = parse_ini_string( $settings, true, INI_SCANNER_RAW ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.parse_ini_stringFound -- We won't get to this function if PHP < 5.3 due to the WPSEO_NAMESPACES check above.
if ( is_array( $options ) && array() !== $options ) {
$options = parse_ini_string( $settings, true, INI_SCANNER_RAW ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.parse_ini_stringFound -- We won't get to this function if PHP < 5.3 due to the WPSEO_NAMESPACES check above.
if ( is_array( $options ) && array() !== $options ) {
$old_wpseo_version = null;
$old_wpseo_version = null;
if ( isset( $options['wpseo']['version'] ) && '' !== $options['wpseo']['version'] ) {
$old_wpseo_version = $options['wpseo']['version'];
}
@ -98,15 +98,15 @@ class MainWP_Wordpress_SEO {
$optgroup = $option_instance->import( $optgroup, $old_wpseo_version, $options );
}
}
$information['success'] = true;
$information['success'] = true;
} else {
throw new Exception( __( 'Settings could not be imported:', 'wordpress-seo' ) );
}
} catch ( Exception $e ) {
$information['error'] = $e->getMessage();
$information['error'] = $e->getMessage();
}
}
}
MainWP_Helper::write( $information );
}