Refactoring

This commit is contained in:
thanghv 2020-05-06 00:47:59 +07:00
parent 831e02d77d
commit bde725888e
24 changed files with 365 additions and 375 deletions

View file

@ -35,7 +35,7 @@ class MainWP_Backup {
$this->file_descriptors = $file_descriptors; $this->file_descriptors = $file_descriptors;
$this->loadFilesBeforeZip = $loadFilesBeforeZip; $this->loadFilesBeforeZip = $loadFilesBeforeZip;
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
if ( ! defined( 'PCLZIP_TEMPORARY_DIR' ) ) { if ( ! defined( 'PCLZIP_TEMPORARY_DIR' ) ) {
define( 'PCLZIP_TEMPORARY_DIR', $backupdir ); define( 'PCLZIP_TEMPORARY_DIR', $backupdir );
@ -233,9 +233,9 @@ class MainWP_Backup {
'xmlrpc.php', 'xmlrpc.php',
); );
foreach ( $nodes as $key => $node ) { foreach ( $nodes as $key => $node ) {
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { if ( MainWP_Helper::starts_with( $node, ABSPATH . WPINC ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { } elseif ( MainWP_Helper::starts_with( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} else { } else {
foreach ( $coreFiles as $coreFile ) { foreach ( $coreFiles as $coreFile ) {
@ -259,12 +259,12 @@ class MainWP_Backup {
foreach ( $nodes as $node ) { foreach ( $nodes as $node ) {
if ( $excludenonwp && is_dir( $node ) ) { if ( $excludenonwp && is_dir( $node ) ) {
if ( ! MainWP_Helper::startsWith( $node, WP_CONTENT_DIR ) && ! MainWP_Helper::startsWith( $node, ABSPATH . 'wp-admin' ) && ! MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { if ( ! MainWP_Helper::starts_with( $node, WP_CONTENT_DIR ) && ! MainWP_Helper::starts_with( $node, ABSPATH . 'wp-admin' ) && ! MainWP_Helper::starts_with( $node, ABSPATH . WPINC ) ) {
continue; continue;
} }
} }
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) { if ( ! MainWP_Helper::in_excludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) {
if ( is_dir( $node ) ) { if ( is_dir( $node ) ) {
$this->zipAddDir( $node, $excludes ); $this->zipAddDir( $node, $excludes );
} elseif ( is_file( $node ) ) { } elseif ( is_file( $node ) ) {
@ -371,9 +371,9 @@ class MainWP_Backup {
'xmlrpc.php', 'xmlrpc.php',
); );
foreach ( $nodes as $key => $node ) { foreach ( $nodes as $key => $node ) {
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { if ( MainWP_Helper::starts_with( $node, ABSPATH . WPINC ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { } elseif ( MainWP_Helper::starts_with( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} else { } else {
foreach ( $coreFiles as $coreFile ) { foreach ( $coreFiles as $coreFile ) {
@ -450,12 +450,12 @@ class MainWP_Backup {
foreach ( $nodes as $node ) { foreach ( $nodes as $node ) {
if ( $excludenonwp && is_dir( $node ) ) { if ( $excludenonwp && is_dir( $node ) ) {
if ( ! MainWP_Helper::startsWith( $node, WP_CONTENT_DIR ) && ! MainWP_Helper::startsWith( $node, ABSPATH . 'wp-admin' ) && ! MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { if ( ! MainWP_Helper::starts_with( $node, WP_CONTENT_DIR ) && ! MainWP_Helper::starts_with( $node, ABSPATH . 'wp-admin' ) && ! MainWP_Helper::starts_with( $node, ABSPATH . WPINC ) ) {
continue; continue;
} }
} }
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) { if ( ! MainWP_Helper::in_excludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) {
if ( is_dir( $node ) ) { if ( is_dir( $node ) ) {
if ( ! file_exists( str_replace( ABSPATH, $backupfolder, $node ) ) ) { if ( ! file_exists( str_replace( ABSPATH, $backupfolder, $node ) ) ) {
mkdir( str_replace( ABSPATH, $backupfolder, $node ) ); // phpcs:ignore mkdir( str_replace( ABSPATH, $backupfolder, $node ) ); // phpcs:ignore
@ -465,7 +465,7 @@ class MainWP_Backup {
$this->copy_dir( $newnodes, $excludes, $backupfolder, $excludenonwp, false ); $this->copy_dir( $newnodes, $excludes, $backupfolder, $excludenonwp, false );
unset( $newnodes ); unset( $newnodes );
} elseif ( is_file( $node ) ) { } elseif ( is_file( $node ) ) {
if ( $this->excludeZip && MainWP_Helper::endsWith( $node, '.zip' ) ) { if ( $this->excludeZip && MainWP_Helper::ends_with( $node, '.zip' ) ) {
continue; continue;
} }
@ -511,9 +511,9 @@ class MainWP_Backup {
'xmlrpc.php', 'xmlrpc.php',
); );
foreach ( $nodes as $key => $node ) { foreach ( $nodes as $key => $node ) {
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { if ( MainWP_Helper::starts_with( $node, ABSPATH . WPINC ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { } elseif ( MainWP_Helper::starts_with( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} else { } else {
foreach ( $coreFiles as $coreFile ) { foreach ( $coreFiles as $coreFile ) {
@ -578,7 +578,7 @@ class MainWP_Backup {
continue; continue;
} }
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $name ) ) ) { if ( ! MainWP_Helper::in_excludes( $excludes, str_replace( ABSPATH, '', $name ) ) ) {
if ( $path->isDir() ) { if ( $path->isDir() ) {
$this->zipAddDir( $name, $excludes ); $this->zipAddDir( $name, $excludes );
} else { } else {
@ -655,7 +655,7 @@ class MainWP_Backup {
$this->lastRun = time(); $this->lastRun = time();
} }
if ( $this->excludeZip && MainWP_Helper::endsWith( $path, '.zip' ) ) { if ( $this->excludeZip && MainWP_Helper::ends_with( $path, '.zip' ) ) {
return false; return false;
} }

View file

@ -36,7 +36,7 @@ class MainWP_Child_Back_Up_Buddy {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) ); add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@ -748,7 +748,7 @@ class MainWP_Child_Back_Up_Buddy {
return $information; return $information;
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) { if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
try { try {
$information['syncBackupBuddy'] = $this->get_sync_data(); $information['syncBackupBuddy'] = $this->get_sync_data();

View file

@ -32,7 +32,7 @@ class MainWP_Child_Back_Up_Wordpress {
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) { if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
$this->is_plugin_installed = true; $this->is_plugin_installed = true;
if ( version_compare( phpversion(), '5.3', '>=' ) ) { if ( version_compare( phpversion(), '5.3', '>=' ) ) {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
} }
} }
} }
@ -150,7 +150,7 @@ class MainWP_Child_Back_Up_Wordpress {
return $schedule_id; return $schedule_id;
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) { if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
try { try {
$information['syncBackUpWordPress'] = $this->get_sync_data(); $information['syncBackUpWordPress'] = $this->get_sync_data();

View file

@ -95,7 +95,7 @@ class MainWP_Child_Back_WP_Up {
BackWPup::get_instance(); BackWPup::get_instance();
add_action( 'admin_init', array( $this, 'init_download_backup' ) ); add_action( 'admin_init', array( $this, 'init_download_backup' ) );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
} }
} catch ( Exception $e ) { } catch ( Exception $e ) {
$this->is_backwpup_installed = false; $this->is_backwpup_installed = false;
@ -327,7 +327,7 @@ class MainWP_Child_Back_WP_Up {
} }
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) { if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
try { try {
$lastbackup = MainWP_Helper::get_lasttime_backup( 'backwpup' ); $lastbackup = MainWP_Helper::get_lasttime_backup( 'backwpup' );

View file

@ -246,7 +246,7 @@ class MainWP_Child_Branding {
$extra_setting['login_image'] = array(); $extra_setting['login_image'] = array();
} else { } else {
try { try {
$upload = $this->uploadImage( $settings['child_login_image_url'] ); $upload = $this->upload_image( $settings['child_login_image_url'] );
if ( null !== $upload ) { if ( null !== $upload ) {
$extra_setting['login_image'] = array( $extra_setting['login_image'] = array(
'path' => $upload['path'], 'path' => $upload['path'],
@ -272,7 +272,7 @@ class MainWP_Child_Branding {
$extra_setting['favico_image'] = array(); $extra_setting['favico_image'] = array();
} else { } else {
try { try {
$upload = $this->uploadImage( $settings['child_favico_image_url'] ); $upload = $this->upload_image( $settings['child_favico_image_url'] );
if ( null !== $upload ) { if ( null !== $upload ) {
$extra_setting['favico_image'] = array( $extra_setting['favico_image'] = array(
'path' => $upload['path'], 'path' => $upload['path'],
@ -313,7 +313,7 @@ class MainWP_Child_Branding {
return $information; return $information;
} }
public static function uploadImage( $img_url ) { public static function upload_image( $img_url ) {
include_once ABSPATH . 'wp-admin/includes/file.php'; include_once ABSPATH . 'wp-admin/includes/file.php';
global $mainWPChild; 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 );

View file

@ -36,10 +36,10 @@ class MainWP_Child_IThemes_Security {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) { if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
try { try {
$information['syncIThemeData'] = array( $information['syncIThemeData'] = array(

View file

@ -34,7 +34,7 @@ class MainWP_Child_Links_Checker {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
} }
public function action() { public function action() {
@ -204,7 +204,7 @@ class MainWP_Child_Links_Checker {
return $information; return $information;
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) { if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
try { try {
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data(); $information['syncBrokenLinksCheckerData'] = $this->get_sync_data();

View file

@ -37,7 +37,7 @@ class MainWP_Child_Pagespeed {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) ); add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
} }
@ -275,7 +275,7 @@ class MainWP_Child_Pagespeed {
return $information; return $information;
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) { if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
try { try {
$information['syncPageSpeedData'] = $this->get_sync_data(); $information['syncPageSpeedData'] = $this->get_sync_data();

View file

@ -10,12 +10,12 @@ class MainWP_Child_Server_Information {
'wp_ajax_mainwp-child_dismiss_warnings', 'wp_ajax_mainwp-child_dismiss_warnings',
array( array(
'MainWP_Child_Server_Information', 'MainWP_Child_Server_Information',
'dismissWarnings', 'dismiss_warnings',
) )
); );
} }
public static function dismissWarnings() { public static function dismiss_warnings() {
if ( isset( $_POST['what'] ) ) { if ( isset( $_POST['what'] ) ) {
$dismissWarnings = get_option( 'mainwp_child_dismiss_warnings' ); $dismissWarnings = get_option( 'mainwp_child_dismiss_warnings' );
if ( ! is_array( $dismissWarnings ) ) { if ( ! is_array( $dismissWarnings ) ) {
@ -589,7 +589,7 @@ class MainWP_Child_Server_Information {
self::renderRowSec( 'cURL Extension Enabled', '=', true, 'getCurlSupport', '', '', null, '', null, self::ERROR ); self::renderRowSec( 'cURL Extension Enabled', '=', true, 'getCurlSupport', '', '', null, '', null, self::ERROR );
self::renderRowSec( 'cURL Timeout', '>=', '300', 'getCurlTimeout', 'seconds', '=', '0' ); self::renderRowSec( 'cURL Timeout', '>=', '300', 'getCurlTimeout', 'seconds', '=', '0' );
if ( function_exists( 'curl_version' ) ) { if ( function_exists( 'curl_version' ) ) {
self::renderRowSec( 'cURL Version', '>=', '7.18.1', 'getCurlVersion', '', '', null ); self::renderRowSec( 'cURL Version', '>=', '7.18.1', 'get_curl_version', '', '', null );
self::renderRowSec( self::renderRowSec(
'cURL SSL Version', 'cURL SSL Version',
'>=', '>=',
@ -597,7 +597,7 @@ class MainWP_Child_Server_Information {
'version_number' => 0x009080cf, 'version_number' => 0x009080cf,
'version' => 'OpenSSL/0.9.8l', 'version' => 'OpenSSL/0.9.8l',
), ),
'getCurlSSLVersion', 'get_curl_ssl_version',
'', '',
'', '',
null, null,
@ -760,7 +760,7 @@ class MainWP_Child_Server_Information {
<tr> <tr>
<td></td> <td></td>
<td><?php esc_html_e( 'PHP Disabled Functions', 'mainwp-child' ); ?></td> <td><?php esc_html_e( 'PHP Disabled Functions', 'mainwp-child' ); ?></td>
<td colspan="3"><?php self::mainwpRequiredFunctions(); ?></td> <td colspan="3"><?php self::mainwp_required_functions(); ?></td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
@ -821,7 +821,7 @@ class MainWP_Child_Server_Information {
return ini_get( 'default_socket_timeout' ); return ini_get( 'default_socket_timeout' );
} }
protected static function getCurlVersion() { protected static function get_curl_version() {
$curlversion = curl_version(); $curlversion = curl_version();
return $curlversion['version']; return $curlversion['version'];
@ -835,13 +835,13 @@ class MainWP_Child_Server_Information {
return false; return false;
} }
protected static function getCurlSSLVersion() { protected static function get_curl_ssl_version() {
$curlversion = curl_version(); $curlversion = curl_version();
return $curlversion['ssl_version']; return $curlversion['ssl_version'];
} }
public static function mainwpRequiredFunctions() { public static function mainwp_required_functions() {
$disabled_functions = ini_get( 'disable_functions' ); $disabled_functions = ini_get( 'disable_functions' );
if ( '' !== $disabled_functions ) { if ( '' !== $disabled_functions ) {
$arr = explode( ',', $disabled_functions ); $arr = explode( ',', $disabled_functions );
@ -913,7 +913,7 @@ class MainWP_Child_Server_Information {
foreach ( $cron_info as $key => $schedule ) { foreach ( $cron_info as $key => $schedule ) {
?> ?>
<tr> <tr>
<td><?php echo esc_html( MainWP_Helper::formatTimestamp( MainWP_Helper::getTimestamp( $time ) ) ); ?></td> <td><?php echo esc_html( MainWP_Helper::format_timestamp( MainWP_Helper::get_timestamp( $time ) ) ); ?></td>
<td><?php echo esc_html( ( isset( $schedule['schedule'] ) && isset( $schedules[ $schedule['schedule'] ] ) && isset( $schedules[ $schedule['schedule'] ]['display'] ) ) ? $schedules[ $schedule['schedule'] ]['display'] : '' ); ?> </td> <td><?php echo esc_html( ( isset( $schedule['schedule'] ) && isset( $schedules[ $schedule['schedule'] ] ) && isset( $schedules[ $schedule['schedule'] ]['display'] ) ) ? $schedules[ $schedule['schedule'] ]['display'] : '' ); ?> </td>
<td><?php echo esc_html( $hook ); ?></td> <td><?php echo esc_html( $hook ); ?></td>
</tr> </tr>
@ -936,7 +936,7 @@ class MainWP_Child_Server_Information {
$branding_title .= ' Upload Directory'; $branding_title .= ' Upload Directory';
try { try {
$dirs = MainWP_Helper::getMainWPDir( null, false ); $dirs = MainWP_Helper::get_mainwp_dir( null, false );
$path = $dirs[0]; $path = $dirs[0];
} catch ( Exception $e ) { } catch ( Exception $e ) {
return self::renderDirectoryRow( $branding_title, '', 'Writable', $e->getMessage(), false ); return self::renderDirectoryRow( $branding_title, '', 'Writable', $e->getMessage(), false );
@ -950,7 +950,7 @@ class MainWP_Child_Server_Information {
} }
} }
$hasWPFileSystem = MainWP_Helper::getWPFilesystem(); $hasWPFileSystem = MainWP_Helper::get_wp_filesystem();
global $wp_filesystem; global $wp_filesystem;

View file

@ -38,7 +38,7 @@ class MainWP_Child_Staging {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
} }
@ -59,7 +59,7 @@ class MainWP_Child_Staging {
} }
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) { if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
try { try {
$information['syncWPStaging'] = $this->get_sync_data(); $information['syncWPStaging'] = $this->get_sync_data();

View file

@ -34,7 +34,7 @@ class MainWP_Child_Timecapsule {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
} }
@ -233,7 +233,7 @@ class MainWP_Child_Timecapsule {
return $information; return $information;
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncWPTimeCapsule'] ) && $data['syncWPTimeCapsule'] ) { if ( isset( $data['syncWPTimeCapsule'] ) && $data['syncWPTimeCapsule'] ) {
$information['syncWPTimeCapsule'] = $this->get_sync_data(); $information['syncWPTimeCapsule'] = $this->get_sync_data();
if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) { if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) {

View file

@ -35,11 +35,11 @@ class MainWP_Child_Updraft_Plus_Backups {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
add_filter( 'updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ) ); add_filter( 'updraftplus_save_last_backup', array( __CLASS__, 'hook_updraft_plus_save_last_backup' ) );
} }
public static function hookUpdraftplusSaveLastBackup( $last_backup ) { public static function hook_updraft_plus_save_last_backup( $last_backup ) {
if ( ! is_array( $last_backup ) ) { if ( ! is_array( $last_backup ) ) {
return $last_backup; return $last_backup;
} }
@ -53,7 +53,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return $last_backup; return $last_backup;
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
try { try {
if ( isset( $data['syncUpdraftData'] ) ) { if ( isset( $data['syncUpdraftData'] ) ) {
$info = $data['syncUpdraftData']; $info = $data['syncUpdraftData'];
@ -126,7 +126,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$information = $this->next_scheduled_backups(); $information = $this->next_scheduled_backups();
break; break;
case 'forcescheduledresumption': case 'forcescheduledresumption':
$information = $this->forceScheduledResumption(); $information = $this->force_scheduled_resumption();
break; break;
case 'fetch_updraft_log': case 'fetch_updraft_log':
$information = $this->fetch_updraft_log(); $information = $this->fetch_updraft_log();
@ -147,7 +147,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$information = $this->restore_alldownloaded(); $information = $this->restore_alldownloaded();
break; break;
case 'restorebackup': // not used! case 'restorebackup': // not used!
$information = $this->restoreBackup(); $information = $this->restore_backup();
break; break;
case 'extradbtestconnection': case 'extradbtestconnection':
$information = $this->extradb_testconnection(); $information = $this->extradb_testconnection();
@ -1349,7 +1349,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$rescan = ( null !== $rescan ) ? $rescan : $_POST['rescan']; $rescan = ( null !== $rescan ) ? $rescan : $_POST['rescan'];
if ( $rescan ) { if ( $rescan ) {
$messages = $this->rebuildBackupHistory( $remotescan ); $messages = $this->rebuild_backup_history( $remotescan );
} }
$backup_history = UpdraftPlus_Backup_History::get_history(); $backup_history = UpdraftPlus_Backup_History::get_history();
@ -1735,7 +1735,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} }
// not used. // not used.
public function restoreBackup() { public function restore_backup() {
global $updraftplus_admin, $updraftplus; global $updraftplus_admin, $updraftplus;
if ( empty( $updraftplus_admin ) ) { if ( empty( $updraftplus_admin ) ) {
@ -1745,7 +1745,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$backup_success = $this->restore_backup( $_REQUEST['backup_timestamp'] ); $backup_success = $this->restore_backup( $_REQUEST['backup_timestamp'] );
if ( empty( $updraftplus->errors ) && true === $backup_success ) { if ( empty( $updraftplus->errors ) && true === $backup_success ) {
// If we restored the database, then that will have out-of-date information which may confuse the user - so automatically re-scan for them. // If we restored the database, then that will have out-of-date information which may confuse the user - so automatically re-scan for them.
$this->rebuildBackupHistory(); $this->rebuild_backup_history();
echo '<p><strong>'; echo '<p><strong>';
$updraftplus->log_e( 'Restore successful!' ); $updraftplus->log_e( 'Restore successful!' );
echo '</strong></p>'; echo '</strong></p>';
@ -3322,7 +3322,7 @@ ENDHERE;
} }
} }
private function rebuildBackupHistory( $remotescan = false ) { private function rebuild_backup_history( $remotescan = false ) {
global $updraftplus_admin, $updraftplus; global $updraftplus_admin, $updraftplus;
$messages = null; $messages = null;
if ( method_exists( $updraftplus, 'rebuild_backup_history' ) ) { if ( method_exists( $updraftplus, 'rebuild_backup_history' ) ) {
@ -3334,7 +3334,7 @@ ENDHERE;
return $messages; return $messages;
} }
private function forceScheduledResumption() { private function force_scheduled_resumption() {
global $updraftplus; global $updraftplus;
// Casting $resumption to int is absolutely necessary, as the WP cron system uses a hashed serialisation of the parameters for identifying jobs. Different type => different hash => does not match. // Casting $resumption to int is absolutely necessary, as the WP cron system uses a hashed serialisation of the parameters for identifying jobs. Different type => different hash => does not match.
$resumption = (int) $_REQUEST['resumption']; $resumption = (int) $_REQUEST['resumption'];

View file

@ -190,7 +190,7 @@ class MainWP_Child_Wordfence {
} }
if ( $this->is_wordfence_installed ) { if ( $this->is_wordfence_installed ) {
add_action( 'wp_ajax_mainwp_wordfence_download_htaccess', array( $this, 'downloadHtaccess' ) ); add_action( 'wp_ajax_mainwp_wordfence_download_htaccess', array( $this, 'download_htaccess' ) );
} }
} }
@ -222,10 +222,10 @@ class MainWP_Child_Wordfence {
$information = $this->kill_scan(); $information = $this->kill_scan();
break; break;
case 'requestScan': case 'requestScan':
$information = $this->requestScan(); $information = $this->request_scan();
break; break;
case 'killScan': case 'killScan':
$information = $this->killScan(); $information = $this->kill_scan();
break; break;
case 'set_showhide': case 'set_showhide':
$information = $this->set_showhide(); $information = $this->set_showhide();
@ -240,10 +240,10 @@ class MainWP_Child_Wordfence {
$information = $this->load_issues(); $information = $this->load_issues();
break; break;
case 'loadIssues': case 'loadIssues':
$information = $this->ajax_loadIssues_callback(); $information = $this->ajax_load_issues_callback();
break; break;
case 'load_wafData': case 'load_wafData':
$information = $this->load_wafData(); $information = $this->load_waf_data();
break; break;
case 'update_all_issues': case 'update_all_issues':
$information = $this->update_all_issues(); $information = $this->update_all_issues();
@ -252,7 +252,7 @@ class MainWP_Child_Wordfence {
$information = $this->update_issues_status(); $information = $this->update_issues_status();
break; break;
case 'updateIssueStatus': case 'updateIssueStatus':
$information = $this->updateIssueStatus(); $information = $this->update_issue_status();
break; break;
case 'delete_issues': case 'delete_issues':
$information = $this->delete_issues(); $information = $this->delete_issues();
@ -261,7 +261,7 @@ class MainWP_Child_Wordfence {
$information = $this->bulk_operation(); $information = $this->bulk_operation();
break; break;
case 'bulkOperation': case 'bulkOperation':
$information = $this->bulkOperation(); $information = $this->bulk_operation();
break; break;
case 'delete_file': case 'delete_file':
$information = $this->delete_file(); $information = $this->delete_file();
@ -276,10 +276,10 @@ class MainWP_Child_Wordfence {
$information = $this->save_settings_new(); $information = $this->save_settings_new();
break; break;
case 'saveOptions': case 'saveOptions':
$information = $this->saveOptions(); $information = $this->save_options();
break; break;
case 'recentTraffic': case 'recentTraffic':
$information = $this->recentTraffic(); $information = $this->recent_traffic();
break; break;
case 'ticker': case 'ticker':
$information = $this->ticker(); $information = $this->ticker();
@ -288,22 +288,22 @@ class MainWP_Child_Wordfence {
$information = $this->reverse_lookup(); $information = $this->reverse_lookup();
break; break;
case 'block_ip': case 'block_ip':
$information = $this->ajax_blockIP_callback(); $information = $this->ajax_block_ip_callback();
break; break;
case 'whois': case 'whois':
$information = $this->whois(); $information = $this->whois();
break; break;
case 'createBlock': case 'createBlock':
$information = $this->ajax_createBlock_callback(); $information = $this->ajax_create_block_callback();
break; break;
case 'getBlocks': case 'getBlocks':
$information = $this->ajax_getBlocks_callback(); $information = $this->ajax_get_blocks_callback();
break; break;
case 'deleteBlocks': case 'deleteBlocks':
$information = $this->ajax_deleteBlocks_callback(); $information = $this->ajax_delete_blocks_callback();
break; break;
case 'makePermanentBlocks': case 'makePermanentBlocks':
$information = $this->ajax_makePermanentBlocks_callback(); $information = $this->ajax_make_permanent_blocks_callback();
break; break;
case 'unblock_ip': case 'unblock_ip':
$information = $this->unblock_ip(); $information = $this->unblock_ip();
@ -321,106 +321,106 @@ class MainWP_Child_Wordfence {
$information = $this->export_settings(); $information = $this->export_settings();
break; break;
case 'save_cache_config': case 'save_cache_config':
$information = $this->saveCacheConfig(); $information = $this->save_cache_config();
break; break;
case 'check_falcon_htaccess': case 'check_falcon_htaccess':
$information = $this->checkFalconHtaccess(); $information = self::check_falcon_htaccess();
break; break;
case 'checkHtaccess': case 'checkHtaccess':
$information = $this->checkHtaccess(); $information = $this->check_htaccess();
break; break;
case 'save_cache_options': case 'save_cache_options':
$information = $this->saveCacheOptions(); $information = $this->save_cache_options();
break; break;
case 'clear_page_cache': case 'clear_page_cache':
$information = $this->clearPageCache(); $information = $this->clear_page_cache();
break; break;
case 'get_cache_stats': case 'get_cache_stats':
$information = $this->getCacheStats(); $information = $this->get_cache_stats();
break; break;
case 'add_cache_exclusion': case 'add_cache_exclusion':
$information = $this->addCacheExclusion(); $information = $this->add_cache_exclusion();
break; break;
case 'load_cache_exclusions': case 'load_cache_exclusions':
$information = $this->loadCacheExclusions(); $information = $this->load_cache_exclusions();
break; break;
case 'remove_cache_exclusion': case 'remove_cache_exclusion':
$information = $this->removeCacheExclusion(); $information = $this->remove_cache_exclusion();
break; break;
case 'get_diagnostics': case 'get_diagnostics':
$information = $this->getDiagnostics(); $information = $this->get_diagnostics();
break; break;
case 'update_waf_rules': case 'update_waf_rules':
$information = $this->updateWAFRules(); $information = $this->update_waf_rules();
break; break;
case 'update_waf_rules_new': case 'update_waf_rules_new':
$information = $this->updateWAFRules_New(); $information = $this->update_waf_rules_new();
break; break;
case 'save_debugging_config': case 'save_debugging_config':
$information = $this->save_debugging_config(); $information = $this->save_debugging_config();
break; break;
case 'load_live_traffic': case 'load_live_traffic':
$information = $this->loadLiveTraffic(); $information = $this->load_live_traffic();
break; break;
case 'white_list_waf': case 'white_list_waf':
$information = $this->whitelistWAFParamKey(); $information = $this->whitelist_waf_param_key();
break; break;
case 'hide_file_htaccess': case 'hide_file_htaccess':
$information = $this->hideFileHtaccess(); $information = $this->hide_file_htaccess();
break; break;
case 'fix_fpd': case 'fix_fpd':
$information = $this->fixFPD(); $information = $this->fix_fpd();
break; break;
case 'disable_directory_listing': case 'disable_directory_listing':
$information = $this->disableDirectoryListing(); $information = $this->disable_directory_listing();
break; break;
case 'delete_database_option': case 'delete_database_option':
$information = $this->deleteDatabaseOption(); $information = $this->delete_database_option();
break; break;
case 'misconfigured_howget_ips_choice': case 'misconfigured_howget_ips_choice':
$information = $this->misconfiguredHowGetIPsChoice(); $information = $this->mis_configured_how_get_ips_choice();
break; break;
case 'delete_admin_user': case 'delete_admin_user':
$information = $this->deleteAdminUser(); $information = $this->delete_admin_user();
break; break;
case 'revoke_admin_user': case 'revoke_admin_user':
$information = $this->revokeAdminUser(); $information = $this->revoke_admin_user();
break; break;
case 'clear_all_blocked': case 'clear_all_blocked':
$information = $this->clearAllBlocked(); $information = $this->clear_all_blocked();
break; break;
case 'permanently_block_all_ips': case 'permanently_block_all_ips':
$information = $this->permanentlyBlockAllIPs(); $information = $this->permanently_block_all_ips();
break; break;
case 'unlockout_ip': case 'unlockout_ip':
$information = $this->unlockOutIP(); $information = $this->unlock_out_ip();
break; break;
case 'unblock_range': case 'unblock_range':
$information = $this->unblockRange(); $information = $this->unblock_range();
break; break;
case 'block_ip_ua_range': case 'block_ip_ua_range':
$information = $this->blockIPUARange(); $information = $this->block_ip_ua_range();
break; break;
case 'load_block_ranges': case 'load_block_ranges':
$information = $this->loadBlockRanges(); $information = $this->load_block_ranges();
break; break;
case 'save_waf_config': case 'save_waf_config':
$information = $this->saveWAFConfig(); $information = $this->save_waf_config();
break; break;
case 'whitelist_bulk_delete': case 'whitelist_bulk_delete':
$information = $this->whitelistBulkDelete(); $information = $this->whitelist_bulk_delete();
break; break;
case 'whitelist_bulk_enable': case 'whitelist_bulk_enable':
$information = $this->whitelistBulkEnable(); $information = $this->whitelist_bulk_enable();
break; break;
case 'whitelist_bulk_disable': case 'whitelist_bulk_disable':
$information = $this->whitelistBulkDisable(); $information = $this->whitelist_bulk_disable();
break; break;
case 'update_config': case 'update_config':
$information = $this->updateConfig(); $information = $this->update_config();
break; break;
case 'save_country_blocking': case 'save_country_blocking':
$information = $this->saveCountryBlocking(); $information = $this->save_country_blocking();
break; break;
} }
} }
@ -428,7 +428,7 @@ class MainWP_Child_Wordfence {
} }
public static function getSectionSettings( $section ) { public static function get_section_settings( $section ) {
$general_opts = array( $general_opts = array(
'scheduleScan', 'scheduleScan',
'apiKey', 'apiKey',
@ -622,11 +622,11 @@ class MainWP_Child_Wordfence {
); );
} }
private function requestScan() { private function request_scan() {
return wordfence::ajax_scan_callback(); return wordfence::ajax_scan_callback();
} }
private function killScan() { private function kill_scan() {
return wordfence::ajax_killScan_callback(); return wordfence::ajax_killScan_callback();
} }
@ -790,11 +790,11 @@ class MainWP_Child_Wordfence {
'todayAttBlocked' => $this->count_attacks_blocked( 1 ), 'todayAttBlocked' => $this->count_attacks_blocked( 1 ),
'weekAttBlocked' => $this->count_attacks_blocked( 7 ), 'weekAttBlocked' => $this->count_attacks_blocked( 7 ),
'monthAttBlocked' => $this->count_attacks_blocked( 30 ), 'monthAttBlocked' => $this->count_attacks_blocked( 30 ),
'wafData' => $this->_getWAFData(), 'wafData' => self::get_waf_data(),
); );
} }
public static function ajax_loadIssues_callback() { public static function ajax_load_issues_callback() {
$offset = isset( $_POST['offset'] ) ? intval( $_POST['offset'] ) : 0; $offset = isset( $_POST['offset'] ) ? intval( $_POST['offset'] ) : 0;
$limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : WORDFENCE_SCAN_ISSUES_PER_PAGE; $limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : WORDFENCE_SCAN_ISSUES_PER_PAGE;
@ -816,9 +816,9 @@ class MainWP_Child_Wordfence {
return $return; return $return;
} }
public function load_wafData() { public function load_waf_data() {
$return = array( $return = array(
'wafData' => $this->_getWAFData(), 'wafData' => self::get_waf_data(),
'ip' => wfUtils::getIP(), 'ip' => wfUtils::getIP(),
'ajaxWatcherDisabled_front' => (bool) wfConfig::get( 'ajaxWatcherDisabled_front' ), 'ajaxWatcherDisabled_front' => (bool) wfConfig::get( 'ajaxWatcherDisabled_front' ),
'ajaxWatcherDisabled_admin' => (bool) wfConfig::get( 'ajaxWatcherDisabled_admin' ), 'ajaxWatcherDisabled_admin' => (bool) wfConfig::get( 'ajaxWatcherDisabled_admin' ),
@ -865,7 +865,7 @@ SQL
return array( 'ok' => 1 ); return array( 'ok' => 1 );
} }
public function updateIssueStatus() { public function update_issue_status() {
$wfIssues = new wfIssues(); $wfIssues = new wfIssues();
$status = $_POST['status']; $status = $_POST['status'];
$issueID = $_POST['id']; $issueID = $_POST['id'];
@ -996,7 +996,7 @@ SQL
} }
} }
public function bulkOperation() { public function bulk_operation() {
return wordfence::ajax_bulkOperation_callback(); return wordfence::ajax_bulkOperation_callback();
} }
@ -1110,7 +1110,7 @@ SQL
} }
$section = isset( $_POST['savingSection'] ) ? $_POST['savingSection'] : ''; $section = isset( $_POST['savingSection'] ) ? $_POST['savingSection'] : '';
$saving_opts = self::getSectionSettings( $section ); $saving_opts = self::get_section_settings( $section );
$result = array(); $result = array();
@ -1361,7 +1361,7 @@ SQL
return $result; return $result;
} }
public static function recentTraffic() { public static function recent_traffic() {
return wordfence::ajax_recentTraffic_callback(); return wordfence::ajax_recentTraffic_callback();
} }
@ -1671,7 +1671,7 @@ SQL
return $jsonData; return $jsonData;
} }
public static function loadLiveTraffic() { public static function load_live_traffic() {
$wfdb = new wfDB(); $wfdb = new wfDB();
$serverTime = $wfdb->querySingle( 'select unix_timestamp()' ); $serverTime = $wfdb->querySingle( 'select unix_timestamp()' );
$return = wordfence::ajax_loadLiveTraffic_callback(); $return = wordfence::ajax_loadLiveTraffic_callback();
@ -1680,77 +1680,77 @@ SQL
return $return; return $return;
} }
public function whitelistWAFParamKey() { public function whitelist_waf_param_key() {
$return = wordfence::ajax_whitelistWAFParamKey_callback(); $return = wordfence::ajax_whitelistWAFParamKey_callback();
return $return; return $return;
} }
public function hideFileHtaccess() { public function hide_file_htaccess() {
$return = wordfence::ajax_hideFileHtaccess_callback(); $return = wordfence::ajax_hideFileHtaccess_callback();
return $return; return $return;
} }
public static function fixFPD() { public static function fix_fpd() {
$return = wordfence::ajax_fixFPD_callback(); $return = wordfence::ajax_fixFPD_callback();
return $return; return $return;
} }
public static function disableDirectoryListing() { public static function disable_directory_listing() {
$return = wordfence::ajax_disableDirectoryListing_callback(); $return = wordfence::ajax_disableDirectoryListing_callback();
return $return; return $return;
} }
public static function deleteDatabaseOption() { public static function delete_database_option() {
$return = wordfence::ajax_deleteDatabaseOption_callback(); $return = wordfence::ajax_deleteDatabaseOption_callback();
return $return; return $return;
} }
public static function misconfiguredHowGetIPsChoice() { public static function mis_configured_how_get_ips_choice() {
$return = wordfence::ajax_misconfiguredHowGetIPsChoice_callback(); $return = wordfence::ajax_misconfiguredHowGetIPsChoice_callback();
return $return; return $return;
} }
public static function deleteAdminUser() { public static function delete_admin_user() {
$return = wordfence::ajax_deleteAdminUser_callback(); $return = wordfence::ajax_deleteAdminUser_callback();
return $return; return $return;
} }
public static function revokeAdminUser() { public static function revoke_admin_user() {
$return = wordfence::ajax_revokeAdminUser_callback(); $return = wordfence::ajax_revokeAdminUser_callback();
return $return; return $return;
} }
public static function clearAllBlocked() { public static function clear_all_blocked() {
$return = wordfence::ajax_clearAllBlocked_callback(); $return = wordfence::ajax_clearAllBlocked_callback();
return $return; return $return;
} }
public static function permanentlyBlockAllIPs() { public static function permanently_block_all_ips() {
$return = wordfence::ajax_permanentlyBlockAllIPs_callback(); $return = wordfence::ajax_permanentlyBlockAllIPs_callback();
return $return; return $return;
} }
public static function unlockOutIP() { public static function unlock_out_ip() {
$return = wordfence::ajax_unlockOutIP_callback(); $return = wordfence::ajax_unlockOutIP_callback();
return $return; return $return;
} }
public static function unblockRange() { public static function unblock_range() {
$return = wordfence::ajax_unblockRange_callback(); $return = wordfence::ajax_unblockRange_callback();
return $return; return $return;
} }
public static function blockIPUARange() { public static function block_ip_ua_range() {
$return = wordfence::ajax_blockIPUARange_callback(); $return = wordfence::ajax_blockIPUARange_callback();
return $return; return $return;
} }
public static function loadBlockRanges() { public static function load_block_ranges() {
$return = wordfence::ajax_loadBlockRanges_callback(); $return = wordfence::ajax_loadBlockRanges_callback();
return $return; return $return;
} }
public static function saveWAFConfig() { public static function save_waf_config() {
$return = wordfence::ajax_saveWAFConfig_callback(); $return = wordfence::ajax_saveWAFConfig_callback();
if ( is_array( $return ) && isset( $return['data'] ) ) { if ( is_array( $return ) && isset( $return['data'] ) ) {
$return['learningModeGracePeriod'] = wfWAF::getInstance()->getStorageEngine()->getConfig( 'learningModeGracePeriod' ); $return['learningModeGracePeriod'] = wfWAF::getInstance()->getStorageEngine()->getConfig( 'learningModeGracePeriod' );
@ -1758,26 +1758,26 @@ SQL
return $return; return $return;
} }
public static function whitelistBulkDelete() { public static function whitelist_bulk_delete() {
$return = wordfence::ajax_whitelistBulkDelete_callback(); $return = wordfence::ajax_whitelistBulkDelete_callback();
return $return; return $return;
} }
public static function whitelistBulkEnable() { public static function whitelist_bulk_enable() {
$return = wordfence::ajax_whitelistBulkEnable_callback(); $return = wordfence::ajax_whitelistBulkEnable_callback();
return $return; return $return;
} }
public static function whitelistBulkDisable() { public static function whitelist_bulk_disable() {
$return = wordfence::ajax_whitelistBulkDisable_callback(); $return = wordfence::ajax_whitelistBulkDisable_callback();
return $return; return $return;
} }
public static function updateConfig() { public static function update_config() {
$return = wordfence::ajax_updateConfig_callback(); $return = wordfence::ajax_updateConfig_callback();
return $return; return $return;
} }
private static function _getWAFData( $updated = null ) { private static function get_waf_data( $updated = null ) {
if ( ! class_exists( 'wfWAF' ) ) { if ( ! class_exists( 'wfWAF' ) ) {
return false; return false;
} }
@ -1848,7 +1848,7 @@ SQL
} }
public function saveOptions() { public function save_options() {
$changes = json_decode( stripslashes( $_POST['changes'] ), true ); $changes = json_decode( stripslashes( $_POST['changes'] ), true );
if ( ! empty( $_POST['changes'] ) && false !== $changes ) { if ( ! empty( $_POST['changes'] ) && false !== $changes ) {
try { try {
@ -1907,26 +1907,26 @@ SQL
); );
} }
public function ajax_getBlocks_callback() { public function ajax_get_blocks_callback() {
$information = wordfence::ajax_getBlocks_callback(); $information = wordfence::ajax_getBlocks_callback();
return $information; return $information;
} }
public function ajax_createBlock_callback() { public function ajax_create_block_callback() {
return wordfence::ajax_createBlock_callback(); return wordfence::ajax_createBlock_callback();
} }
public static function ajax_deleteBlocks_callback() { public static function ajax_delete_blocks_callback() {
$information = wordfence::ajax_deleteBlocks_callback(); $information = wordfence::ajax_deleteBlocks_callback();
return $information; return $information;
} }
public static function ajax_makePermanentBlocks_callback() { public static function ajax_make_permanent_blocks_callback() {
$information = wordfence::ajax_makePermanentBlocks_callback(); $information = wordfence::ajax_makePermanentBlocks_callback();
return $information; return $information;
} }
public function ajax_blockIP_callback() { public function ajax_block_ip_callback() {
return wordfence::ajax_blockIP_callback(); return wordfence::ajax_blockIP_callback();
} }
@ -1942,7 +1942,7 @@ SQL
} }
} }
public static function saveCountryBlocking() { public static function save_country_blocking() {
if ( ! wfConfig::get( 'isPaid' ) ) { if ( ! wfConfig::get( 'isPaid' ) ) {
return array( 'error' => 'Sorry but this feature is only available for paid customers.' ); return array( 'error' => 'Sorry but this feature is only available for paid customers.' );
} }
@ -2003,10 +2003,10 @@ SQL
return $return; return $return;
} }
public static function saveCacheConfig() { public static function save_cache_config() {
$noEditHtaccess = '1'; $noEditHtaccess = '1';
if ( isset( $_POST['needToCheckFalconHtaccess'] ) && ! empty( $_POST['needToCheckFalconHtaccess'] ) ) { if ( isset( $_POST['needToCheckFalconHtaccess'] ) && ! empty( $_POST['needToCheckFalconHtaccess'] ) ) {
$checkHtaccess = self::checkFalconHtaccess(); $checkHtaccess = self::check_falcon_htaccess();
if ( isset( $checkHtaccess['ok'] ) ) { if ( isset( $checkHtaccess['ok'] ) ) {
$noEditHtaccess = '0'; $noEditHtaccess = '0';
} }
@ -2109,7 +2109,7 @@ SQL
return array( 'errorMsg' => 'An error occurred.' ); return array( 'errorMsg' => 'An error occurred.' );
} }
public static function checkFalconHtaccess() { public static function check_falcon_htaccess() {
if ( wfUtils::isNginx() ) { if ( wfUtils::isNginx() ) {
return array( 'nginx' => 1 ); return array( 'nginx' => 1 );
} }
@ -2135,7 +2135,7 @@ SQL
); );
} }
public static function checkHtaccess() { public static function check_htaccess() {
if ( wfUtils::isNginx() ) { if ( wfUtils::isNginx() ) {
return array( 'nginx' => 1 ); return array( 'nginx' => 1 );
} }
@ -2151,7 +2151,7 @@ SQL
return array( 'ok' => 1 ); return array( 'ok' => 1 );
} }
public static function downloadHtaccess() { public static function download_htaccess() {
if ( ! isset( $_GET['_wpnonce'] ) || empty( $_GET['_wpnonce'] ) ) { if ( ! isset( $_GET['_wpnonce'] ) || empty( $_GET['_wpnonce'] ) ) {
die( '-1' ); die( '-1' );
} }
@ -2172,7 +2172,7 @@ SQL
die(); die();
} }
public static function saveCacheOptions() { public static function save_cache_options() {
$changed = false; $changed = false;
if ( wfConfig::get( 'allowHTTPSCaching', false ) != $_POST['allowHTTPSCaching'] ) { if ( wfConfig::get( 'allowHTTPSCaching', false ) != $_POST['allowHTTPSCaching'] ) {
$changed = true; $changed = true;
@ -2192,7 +2192,7 @@ SQL
return array( 'ok' => 1 ); return array( 'ok' => 1 );
} }
public static function clearPageCache() { public static function clear_page_cache() {
$stats = wfCache::clearPageCache(); $stats = wfCache::clearPageCache();
if ( $stats['error'] ) { if ( $stats['error'] ) {
$body = 'A total of ' . $stats['totalErrors'] . ' errors occurred while trying to clear your cache. The last error was: ' . $stats['error']; $body = 'A total of ' . $stats['totalErrors'] . ' errors occurred while trying to clear your cache. The last error was: ' . $stats['error'];
@ -2213,7 +2213,7 @@ SQL
); );
} }
public static function getCacheStats() { public static function get_cache_stats() {
$s = wfCache::getCacheStats(); $s = wfCache::getCacheStats();
if ( 0 == $s['files'] ) { if ( 0 == $s['files'] ) {
return array( return array(
@ -2258,7 +2258,7 @@ SQL
); );
} }
public static function addCacheExclusion() { public static function add_cache_exclusion() {
$ex = wfConfig::get( 'cacheExclusions', false ); $ex = wfConfig::get( 'cacheExclusions', false );
if ( $ex ) { if ( $ex ) {
$ex = unserialize( $ex ); $ex = unserialize( $ex );
@ -2290,7 +2290,7 @@ SQL
); );
} }
public static function loadCacheExclusions() { public static function load_cache_exclusions() {
$ex = wfConfig::get( 'cacheExclusions', false ); $ex = wfConfig::get( 'cacheExclusions', false );
if ( ! $ex ) { if ( ! $ex ) {
return array( 'ex' => false ); return array( 'ex' => false );
@ -2302,7 +2302,7 @@ SQL
); );
} }
public static function removeCacheExclusion() { public static function remove_cache_exclusion() {
$id = $_POST['id']; $id = $_POST['id'];
$ex = wfConfig::get( 'cacheExclusions', false ); $ex = wfConfig::get( 'cacheExclusions', false );
if ( ! $ex ) { if ( ! $ex ) {
@ -2338,7 +2338,7 @@ SQL
return $return; return $return;
} }
public function getDiagnostics() { public function get_diagnostics() {
$diagnostic = new wfDiagnostic(); $diagnostic = new wfDiagnostic();
$plugins = get_plugins(); $plugins = get_plugins();
@ -3038,7 +3038,7 @@ SQL
); );
} }
public static function updateWAFRules() { public static function update_waf_rules() {
$event = new wfWAFCronFetchRulesEvent( time() - 2 ); $event = new wfWAFCronFetchRulesEvent( time() - 2 );
$event->setWaf( wfWAF::getInstance() ); $event->setWaf( wfWAF::getInstance() );
$event->fire(); $event->fire();
@ -3049,12 +3049,12 @@ SQL
); );
} }
public static function updateWAFRules_New() { public static function update_waf_rules_new() {
$event = new wfWAFCronFetchRulesEvent( time() - 2 ); $event = new wfWAFCronFetchRulesEvent( time() - 2 );
$event->setWaf( wfWAF::getInstance() ); $event->setWaf( wfWAF::getInstance() );
$success = $event->fire(); $success = $event->fire();
return self::_getWAFData( $success ); return self::get_waf_data( $success );
} }
public static function save_debugging_config() { public static function save_debugging_config() {

View file

@ -37,7 +37,7 @@ class MainWP_Child_WP_Rocket {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
if ( 'hide' === get_option( 'mainwp_wprocket_hide_plugin' ) ) { if ( 'hide' === get_option( 'mainwp_wprocket_hide_plugin' ) ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
@ -123,7 +123,7 @@ class MainWP_Child_WP_Rocket {
); );
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) { if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
try { try {
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) ); $data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) );

View file

@ -25,14 +25,14 @@ class MainWP_Child_WPvivid_BackupRestore {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
$this->public_intetface = new WPvivid_Public_Interface(); $this->public_intetface = new WPvivid_Public_Interface();
} }
public function init() { public function init() {
} }
function syncOthersData( $information, $data = array() ) { function sync_others_data( $information, $data = array() ) {
try { try {
if ( isset( $data['syncWPvividData'] ) ) { if ( isset( $data['syncWPvividData'] ) ) {

View file

@ -21,21 +21,21 @@ class MainWP_Child {
private $update_version = '1.5'; private $update_version = '1.5';
private $callableFunctions = array( private $callableFunctions = array(
'stats' => 'getSiteStats', 'stats' => 'get_site_stats',
'upgrade' => 'upgradeWP', 'upgrade' => 'upgrade_wp',
'newpost' => 'newPost', 'newpost' => 'new_post',
'deactivate' => 'deactivate', 'deactivate' => 'deactivate',
'newuser' => 'newUser', 'newuser' => 'new_user',
'newadminpassword' => 'newAdminPassword', 'newadminpassword' => 'new_admin_password',
'installplugintheme' => 'installPluginTheme', 'installplugintheme' => 'install_plugin_theme',
'upgradeplugintheme' => 'upgradePluginTheme', 'upgradeplugintheme' => 'upgrade_plugin_theme',
'upgradetranslation' => 'upgradeTranslation', 'upgradetranslation' => 'upgrade_translation',
'backup' => 'backup', 'backup' => 'backup',
'backup_checkpid' => 'backup_checkpid', 'backup_checkpid' => 'backup_checkpid',
'cloneinfo' => 'cloneinfo', 'cloneinfo' => 'cloneinfo',
'security' => 'getSecurityStats', 'security' => 'get_security_stats',
'securityFix' => 'doSecurityFix', 'securityFix' => 'do_security_fix',
'securityUnFix' => 'doSecurityUnFix', 'securityUnFix' => 'do_security_un_fix',
'post_action' => 'post_action', 'post_action' => 'post_action',
'get_all_posts' => 'get_all_posts', 'get_all_posts' => 'get_all_posts',
'comment_action' => 'comment_action', 'comment_action' => 'comment_action',
@ -56,7 +56,7 @@ class MainWP_Child {
'get_total_ezine_post' => 'get_total_ezine_post', 'get_total_ezine_post' => 'get_total_ezine_post',
'get_next_time_to_post' => 'get_next_time_to_post', 'get_next_time_to_post' => 'get_next_time_to_post',
'cancel_scheduled_post' => 'cancel_scheduled_post', 'cancel_scheduled_post' => 'cancel_scheduled_post',
'serverInformation' => 'serverInformation', 'serverInformation' => 'server_information',
'maintenance_site' => 'maintenance_site', 'maintenance_site' => 'maintenance_site',
'keyword_links_action' => 'keyword_links_action', 'keyword_links_action' => 'keyword_links_action',
'branding_child_plugin' => 'branding_child_plugin', 'branding_child_plugin' => 'branding_child_plugin',
@ -64,7 +64,7 @@ class MainWP_Child {
'uploader_action' => 'uploader_action', 'uploader_action' => 'uploader_action',
'wordpress_seo' => 'wordpress_seo', 'wordpress_seo' => 'wordpress_seo',
'client_report' => 'client_report', 'client_report' => 'client_report',
'createBackupPoll' => 'backupPoll', 'createBackupPoll' => 'backup_poll',
'page_speed' => 'page_speed', 'page_speed' => 'page_speed',
'woo_com_status' => 'woo_com_status', 'woo_com_status' => 'woo_com_status',
'links_checker' => 'links_checker', 'links_checker' => 'links_checker',
@ -93,7 +93,7 @@ class MainWP_Child {
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.'; private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
private $callableFunctionsNoAuth = array( private $callableFunctionsNoAuth = array(
'stats' => 'getSiteStatsNoAuth', 'stats' => 'get_site_stats_no_auth',
); );
private $posts_where_suffix; private $posts_where_suffix;
@ -141,7 +141,7 @@ class MainWP_Child {
MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' );
} }
$this->checkOtherAuth(); $this->check_other_auth();
MainWP_Clone::get()->init(); MainWP_Clone::get()->init();
MainWP_Child_Server_Information::init(); MainWP_Child_Server_Information::init();
@ -405,7 +405,7 @@ class MainWP_Child {
public function admin_notice() { public function admin_notice() {
// Admin Notice... // Admin Notice...
if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::isAdmin() && is_admin() ) { if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::is_admin() && is_admin() ) {
$branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
$child_name = ( '' === $branding_opts['branding_preserve_title'] ) ? 'MainWP Child' : $branding_opts['branding_preserve_title']; $child_name = ( '' === $branding_opts['branding_preserve_title'] ) ? 'MainWP Child' : $branding_opts['branding_preserve_title'];
$dashboard_name = ( '' === $branding_opts['branding_preserve_title'] ) ? 'MainWP Dashboard' : $branding_opts['branding_preserve_title'] . ' Dashboard'; $dashboard_name = ( '' === $branding_opts['branding_preserve_title'] ) ? 'MainWP Dashboard' : $branding_opts['branding_preserve_title'] . ' Dashboard';
@ -459,7 +459,7 @@ class MainWP_Child {
if ( 'plugin' == $type || 'theme' == $type ) { if ( 'plugin' == $type || 'theme' == $type ) {
$list = isset( $_GET['list'] ) ? $_GET['list'] : ''; $list = isset( $_GET['list'] ) ? $_GET['list'] : '';
if ( ! empty( $list ) ) { if ( ! empty( $list ) ) {
// to call function upgradePluginTheme(). // to call function upgrade_plugin_theme().
$_POST['type'] = $type; $_POST['type'] = $type;
$_POST['list'] = $list; $_POST['list'] = $list;
@ -471,7 +471,7 @@ class MainWP_Child {
} }
} }
public function checkOtherAuth() { public function check_other_auth() {
$auths = get_option( 'mainwp_child_auth' ); $auths = get_option( 'mainwp_child_auth' );
if ( ! $auths ) { if ( ! $auths ) {
@ -491,13 +491,13 @@ class MainWP_Child {
while ( isset( $auths[ $newI ] ) ) { while ( isset( $auths[ $newI ] ) ) {
unset( $auths[ $newI ++ ] ); unset( $auths[ $newI ++ ] );
} }
$auths[ $this->maxHistory ] = md5( MainWP_Helper::randString( 14 ) ); $auths[ $this->maxHistory ] = md5( MainWP_Helper::rand_string( 14 ) );
$auths['last'] = time(); $auths['last'] = time();
MainWP_Helper::update_option( 'mainwp_child_auth', $auths, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_auth', $auths, 'yes' );
} }
} }
public function isValidAuth( $key ) { public function is_valid_auth( $key ) {
$auths = get_option( 'mainwp_child_auth' ); $auths = get_option( 'mainwp_child_auth' );
if ( ! $auths ) { if ( ! $auths ) {
return false; return false;
@ -863,7 +863,7 @@ class MainWP_Child {
} }
public function admin_init() { public function admin_init() {
if ( MainWP_Helper::isAdmin() && is_admin() ) { if ( MainWP_Helper::is_admin() && is_admin() ) {
MainWP_Clone::get()->init_ajax(); MainWP_Clone::get()->init_ajax();
} }
} }
@ -898,7 +898,7 @@ class MainWP_Child {
public function settings() { public function settings() {
if ( isset( $_POST['submit'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'child-settings' ) ) { if ( isset( $_POST['submit'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'child-settings' ) ) {
if ( isset( $_POST['requireUniqueSecurityId'] ) ) { if ( isset( $_POST['requireUniqueSecurityId'] ) ) {
MainWP_Helper::update_option( 'mainwp_child_uniqueId', MainWP_Helper::randString( 8 ) ); MainWP_Helper::update_option( 'mainwp_child_uniqueId', MainWP_Helper::rand_string( 8 ) );
} else { } else {
MainWP_Helper::update_option( 'mainwp_child_uniqueId', '' ); MainWP_Helper::update_option( 'mainwp_child_uniqueId', '' );
} }
@ -1071,15 +1071,15 @@ class MainWP_Child {
if ( ! isset( $_REQUEST['f'] ) || ( '' === $_REQUEST['f'] ) ) { if ( ! isset( $_REQUEST['f'] ) || ( '' === $_REQUEST['f'] ) ) {
return; return;
} }
if ( ! $this->isValidAuth( $_REQUEST['key'] ) ) { if ( ! $this->is_valid_auth( $_REQUEST['key'] ) ) {
return; return;
} }
if ( 'dl' === $_REQUEST['cloneFunc'] ) { if ( 'dl' === $_REQUEST['cloneFunc'] ) {
$this->uploadFile( $_REQUEST['f'] ); $this->upload_file( $_REQUEST['f'] );
exit; exit;
} elseif ( 'deleteCloneBackup' === $_POST['cloneFunc'] ) { } elseif ( 'deleteCloneBackup' === $_POST['cloneFunc'] ) {
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$result = glob( $backupdir . $_POST['f'] ); $result = glob( $backupdir . $_POST['f'] );
if ( 0 === count( $result ) ) { if ( 0 === count( $result ) ) {
@ -1089,12 +1089,12 @@ class MainWP_Child {
unlink( $result[0] ); unlink( $result[0] );
MainWP_Helper::write( array( 'result' => 'ok' ) ); MainWP_Helper::write( array( 'result' => 'ok' ) );
} elseif ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) { } elseif ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) {
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$result = glob( $backupdir . 'backup-' . $_POST['f'] . '-*' ); $result = glob( $backupdir . 'backup-' . $_POST['f'] . '-*' );
$archiveFile = false; $archiveFile = false;
foreach ( $result as $file ) { foreach ( $result as $file ) {
if ( MainWP_Helper::isArchive( $file, 'backup-' . $_POST['f'] . '-' ) ) { if ( MainWP_Helper::is_archive( $file, 'backup-' . $_POST['f'] . '-' ) ) {
$archiveFile = $file; $archiveFile = $file;
break; break;
} }
@ -1105,7 +1105,7 @@ class MainWP_Child {
MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) ); MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) );
} elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) { } elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) {
MainWP_Helper::endSession(); MainWP_Helper::end_session();
$files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' ); $files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' );
foreach ( $files as $file ) { foreach ( $files as $file ) {
@ -1123,7 +1123,7 @@ class MainWP_Child {
$includeCoreFiles = ( $wpversion !== $wp_version ); $includeCoreFiles = ( $wpversion !== $wp_version );
$excludes = ( isset( $_POST['exclude'] ) ? explode( ',', $_POST['exclude'] ) : array() ); $excludes = ( isset( $_POST['exclude'] ) ? explode( ',', $_POST['exclude'] ) : array() );
$excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/uploads/mainwp'; $excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/uploads/mainwp';
$uploadDir = MainWP_Helper::getMainWPDir(); $uploadDir = MainWP_Helper::get_mainwp_dir();
$uploadDir = $uploadDir[0]; $uploadDir = $uploadDir[0];
$excludes[] = str_replace( ABSPATH, '', $uploadDir ); $excludes[] = str_replace( ABSPATH, '', $uploadDir );
$excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/object-cache.php'; $excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/object-cache.php';
@ -1262,7 +1262,7 @@ class MainWP_Child {
return; return;
} }
$this->uploadFile( $_REQUEST['fdl'], isset( $_REQUEST['foffset'] ) ? $_REQUEST['foffset'] : 0 ); $this->upload_file( $_REQUEST['fdl'], isset( $_REQUEST['foffset'] ) ? $_REQUEST['foffset'] : 0 );
exit; exit;
} }
@ -1322,7 +1322,7 @@ class MainWP_Child {
if ( isset( $_POST['function'] ) && 'register' === $_POST['function'] ) { if ( isset( $_POST['function'] ) && 'register' === $_POST['function'] ) {
define( 'DOING_CRON', true ); define( 'DOING_CRON', true );
self::fix_for_custom_themes(); self::fix_for_custom_themes();
$this->registerSite(); $this->register_site();
} }
$auth = $this->auth( isset( $_POST['mainwpsignature'] ) ? $_POST['mainwpsignature'] : '', isset( $_POST['function'] ) ? $_POST['function'] : '', isset( $_POST['nonce'] ) ? $_POST['nonce'] : '', isset( $_POST['nossl'] ) ? $_POST['nossl'] : 0 ); $auth = $this->auth( isset( $_POST['mainwpsignature'] ) ? $_POST['mainwpsignature'] : '', isset( $_POST['function'] ) ? $_POST['function'] : '', isset( $_POST['nonce'] ) ? $_POST['nonce'] : '', isset( $_POST['nossl'] ) ? $_POST['nossl'] : 0 );
@ -1526,7 +1526,7 @@ class MainWP_Child {
return false; return false;
} }
public function noSSLFilterFunction( $r, $url ) { public function no_ssl_filter_function( $r, $url ) {
$r['sslverify'] = false; $r['sslverify'] = false;
return $r; return $r;
@ -1544,8 +1544,8 @@ class MainWP_Child {
/** /**
* Functions to support core functionality * Functions to support core functionality
*/ */
public function installPluginTheme() { public function install_plugin_theme() {
$wp_filesystem = $this->getWPFilesystem(); $wp_filesystem = $this->get_wp_filesystem();
if ( ! isset( $_POST['type'] ) || ! isset( $_POST['url'] ) || ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) || '' === $_POST['url'] ) { if ( ! isset( $_POST['type'] ) || ! isset( $_POST['url'] ) || ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) || '' === $_POST['url'] ) {
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) ); MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
@ -1573,7 +1573,7 @@ class MainWP_Child {
$ssl_verify = true; $ssl_verify = true;
// @see wp-admin/includes/class-wp-upgrader.php // @see wp-admin/includes/class-wp-upgrader.php
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) { if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 ); add_filter( 'http_request_args', array( &$this, 'no_ssl_filter_function' ), 99, 2 );
$ssl_verify = false; $ssl_verify = false;
} }
add_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 ); add_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 );
@ -1590,7 +1590,7 @@ class MainWP_Child {
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) { if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) {
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 ); add_filter( 'http_request_args', array( &$this, 'no_ssl_filter_function' ), 99, 2 );
$ssl_verify = false; $ssl_verify = false;
$result = $installer->run( $result = $installer->run(
array( array(
@ -1616,7 +1616,7 @@ class MainWP_Child {
remove_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 ); remove_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 );
if ( false == $ssl_verify ) { if ( false == $ssl_verify ) {
remove_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99 ); remove_filter( 'http_request_args', array( &$this, 'no_ssl_filter_function' ), 99 );
} }
$args = array( $args = array(
@ -1666,9 +1666,9 @@ class MainWP_Child {
} }
// This will upgrade WP! // This will upgrade WP!
public function upgradeWP() { public function upgrade_wp() {
global $wp_version; global $wp_version;
$wp_filesystem = $this->getWPFilesystem(); $wp_filesystem = $this->get_wp_filesystem();
$information = array(); $information = array();
@ -1753,11 +1753,11 @@ class MainWP_Child {
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function upgradeTranslation() { public function upgrade_translation() {
// Prevent disable/re-enable at upgrade. // Prevent disable/re-enable at upgrade.
define( 'DOING_CRON', true ); define( 'DOING_CRON', true );
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
include_once ABSPATH . '/wp-admin/includes/screen.php'; include_once ABSPATH . '/wp-admin/includes/screen.php';
@ -1801,17 +1801,17 @@ class MainWP_Child {
$information['upgrades'] = array(); // to fix error message when translations updated. $information['upgrades'] = array(); // to fix error message when translations updated.
} }
$information['sync'] = $this->getSiteStats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function upgradePluginTheme() { public function upgrade_plugin_theme() {
// Prevent disable/re-enable at upgrade. // Prevent disable/re-enable at upgrade.
if ( ! defined( 'DOING_CRON' ) ) { if ( ! defined( 'DOING_CRON' ) ) {
define( 'DOING_CRON', true ); define( 'DOING_CRON', true );
} }
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
@ -1986,7 +1986,7 @@ class MainWP_Child {
$addFilterToFixUpdate_optimizePressTheme = false; $addFilterToFixUpdate_optimizePressTheme = false;
if ( in_array( 'optimizePressTheme', $themes ) ) { if ( in_array( 'optimizePressTheme', $themes ) ) {
$addFilterToFixUpdate_optimizePressTheme = true; $addFilterToFixUpdate_optimizePressTheme = true;
add_filter( 'site_transient_update_themes', array( $this, 'hookFixOptimizePressThemeUpdate' ), 99 ); add_filter( 'site_transient_update_themes', array( $this, 'hook_fix_optimize_press_theme_update' ), 99 );
} }
if ( null !== $this->filterFunction ) { if ( null !== $this->filterFunction ) {
@ -2025,7 +2025,7 @@ class MainWP_Child {
'site_transient_update_themes', 'site_transient_update_themes',
array( array(
$this, $this,
'hookFixOptimizePressThemeUpdate', 'hook_fix_optimize_press_theme_update',
), ),
99 99
); );
@ -2117,7 +2117,7 @@ class MainWP_Child {
} }
} }
} }
$information['sync'] = $this->getSiteStats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
@ -2169,7 +2169,7 @@ class MainWP_Child {
return $_transient_data; return $_transient_data;
} }
public function hookFixOptimizePressThemeUpdate( $transient ) { public function hook_fix_optimize_press_theme_update( $transient ) {
if ( ! defined( 'OP_FUNC' ) ) { if ( ! defined( 'OP_FUNC' ) ) {
return $transient; return $transient;
} }
@ -2202,7 +2202,7 @@ class MainWP_Child {
} }
// This will register the current wp - thus generating the public key etc. // This will register the current wp - thus generating the public key etc.
public function registerSite() { public function register_site() {
global $current_user; global $current_user;
$information = array(); $information = array();
@ -2229,7 +2229,7 @@ class MainWP_Child {
} }
// Check SSL Requirement. // Check SSL Requirement.
if ( ! MainWP_Helper::isSSLEnabled() && ( ! defined( 'MAINWP_ALLOW_NOSSL_CONNECT' ) || ! MAINWP_ALLOW_NOSSL_CONNECT ) ) { if ( ! MainWP_Helper::is_ssl_enabled() && ( ! defined( 'MAINWP_ALLOW_NOSSL_CONNECT' ) || ! MAINWP_ALLOW_NOSSL_CONNECT ) ) {
MainWP_Helper::error( __( 'SSL is required on the child site to set up a secure connection.', 'mainwp-child' ) ); MainWP_Helper::error( __( 'SSL is required on the child site to set up a secure connection.', 'mainwp-child' ) );
} }
@ -2249,8 +2249,8 @@ class MainWP_Child {
MainWP_Helper::update_option( 'mainwp_child_server', $_POST['server'] ); // Save the public key. MainWP_Helper::update_option( 'mainwp_child_server', $_POST['server'] ); // Save the public key.
MainWP_Helper::update_option( 'mainwp_child_nonce', 0 ); // Save the nonce. MainWP_Helper::update_option( 'mainwp_child_nonce', 0 ); // Save the nonce.
MainWP_Helper::update_option( 'mainwp_child_nossl', ( '-1' === $_POST['pubkey'] || ! MainWP_Helper::isSSLEnabled() ? 1 : 0 ), 'yes' ); MainWP_Helper::update_option( 'mainwp_child_nossl', ( '-1' === $_POST['pubkey'] || ! MainWP_Helper::is_ssl_enabled() ? 1 : 0 ), 'yes' );
$information['nossl'] = ( '-1' === $_POST['pubkey'] || ! MainWP_Helper::isSSLEnabled() ? 1 : 0 ); $information['nossl'] = ( '-1' === $_POST['pubkey'] || ! MainWP_Helper::is_ssl_enabled() ? 1 : 0 );
if ( function_exists( 'random_bytes' ) ) { if ( function_exists( 'random_bytes' ) ) {
$nossl_key = random_bytes( 32 ); $nossl_key = random_bytes( 32 );
$nossl_key = bin2hex( $nossl_key ); $nossl_key = bin2hex( $nossl_key );
@ -2264,10 +2264,10 @@ class MainWP_Child {
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' ); $information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
$information['user'] = $_POST['user']; $information['user'] = $_POST['user'];
$this->getSiteStats( $information ); $this->get_site_stats( $information );
} }
public function newPost() { public function new_post() {
$new_post = maybe_unserialize( base64_decode( $_POST['new_post'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. $new_post = maybe_unserialize( base64_decode( $_POST['new_post'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
$post_custom = maybe_unserialize( base64_decode( $_POST['post_custom'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. $post_custom = maybe_unserialize( base64_decode( $_POST['post_custom'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
$post_category = rawurldecode( isset( $_POST['post_category'] ) ? base64_decode( $_POST['post_category'] ) : null ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. $post_category = rawurldecode( isset( $_POST['post_category'] ) ? base64_decode( $_POST['post_category'] ) : null ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
@ -2284,7 +2284,7 @@ class MainWP_Child {
$others['featured_image_data'] = unserialize( base64_decode( $_POST['featured_image_data'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. $others['featured_image_data'] = unserialize( base64_decode( $_POST['featured_image_data'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
} }
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others ); $res = MainWP_Helper::create_post( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
if ( is_array( $res ) && isset( $res['error'] ) ) { if ( is_array( $res ) && isset( $res['error'] ) ) {
MainWP_Helper::error( $res['error'] ); MainWP_Helper::error( $res['error'] );
@ -2839,7 +2839,7 @@ class MainWP_Child {
} }
public function newAdminPassword() { public function new_admin_password() {
$new_password = maybe_unserialize( base64_decode( $_POST['new_password'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. $new_password = maybe_unserialize( base64_decode( $_POST['new_password'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
$user = get_user_by( 'login', $_POST['user'] ); $user = get_user_by( 'login', $_POST['user'] );
require_once ABSPATH . WPINC . '/registration.php'; require_once ABSPATH . WPINC . '/registration.php';
@ -2862,7 +2862,7 @@ class MainWP_Child {
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function newUser() { public function new_user() {
$new_user = maybe_unserialize( base64_decode( $_POST['new_user'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. $new_user = maybe_unserialize( base64_decode( $_POST['new_user'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
$send_password = $_POST['send_password']; $send_password = $_POST['send_password'];
if ( isset( $new_user['role'] ) ) { if ( isset( $new_user['role'] ) ) {
@ -2911,7 +2911,7 @@ class MainWP_Child {
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function backupPoll() { public function backup_poll() {
$fileNameUID = ( isset( $_POST['fileNameUID'] ) ? $_POST['fileNameUID'] : '' ); $fileNameUID = ( isset( $_POST['fileNameUID'] ) ? $_POST['fileNameUID'] : '' );
$fileName = ( isset( $_POST['fileName'] ) ? $_POST['fileName'] : '' ); $fileName = ( isset( $_POST['fileName'] ) ? $_POST['fileName'] : '' );
@ -2922,12 +2922,12 @@ class MainWP_Child {
$backupFile = 'backup-' . $fileNameUID . '-'; $backupFile = 'backup-' . $fileNameUID . '-';
} }
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$result = glob( $backupdir . $backupFile . '*' ); $result = glob( $backupdir . $backupFile . '*' );
$archiveFile = false; $archiveFile = false;
foreach ( $result as $file ) { foreach ( $result as $file ) {
if ( MainWP_Helper::isArchive( $file, $backupFile, '(.*)' ) ) { if ( MainWP_Helper::is_archive( $file, $backupFile, '(.*)' ) ) {
$archiveFile = $file; $archiveFile = $file;
break; break;
} }
@ -2940,7 +2940,7 @@ class MainWP_Child {
} else { } else {
$backupFile = 'dbBackup-' . $fileNameUID . '-*.sql'; $backupFile = 'dbBackup-' . $fileNameUID . '-*.sql';
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$result = glob( $backupdir . $backupFile . '*' ); $result = glob( $backupdir . $backupFile . '*' );
if ( 0 === count( $result ) ) { if ( 0 === count( $result ) ) {
@ -2959,7 +2959,7 @@ class MainWP_Child {
public function backup_checkpid() { public function backup_checkpid() {
$pid = $_POST['pid']; $pid = $_POST['pid'];
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$information = array(); $information = array();
@ -2967,7 +2967,7 @@ class MainWP_Child {
/** @var $wp_filesystem WP_Filesystem_Base */ /** @var $wp_filesystem WP_Filesystem_Base */
global $wp_filesystem; global $wp_filesystem;
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
$pidFile = trailingslashit( $backupdir ) . 'backup-' . $pid . '.pid'; $pidFile = trailingslashit( $backupdir ) . 'backup-' . $pid . '.pid';
$doneFile = trailingslashit( $backupdir ) . 'backup-' . $pid . '.done'; $doneFile = trailingslashit( $backupdir ) . 'backup-' . $pid . '.done';
@ -3009,20 +3009,20 @@ class MainWP_Child {
$timeout = 20 * 60 * 60; $timeout = 20 * 60 * 60;
set_time_limit( $timeout ); set_time_limit( $timeout );
ini_set( 'max_execution_time', $timeout ); ini_set( 'max_execution_time', $timeout );
MainWP_Helper::endSession(); MainWP_Helper::end_session();
// Cleanup pid files! // Cleanup pid files!
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = trailingslashit( $dirs[0] ); $backupdir = trailingslashit( $dirs[0] );
/** @var $wp_filesystem WP_Filesystem_Base */ /** @var $wp_filesystem WP_Filesystem_Base */
global $wp_filesystem; global $wp_filesystem;
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
$files = glob( $backupdir . '*' ); $files = glob( $backupdir . '*' );
foreach ( $files as $file ) { foreach ( $files as $file ) {
if ( MainWP_Helper::endsWith( $file, '/index.php' ) | MainWP_Helper::endsWith( $file, '/.htaccess' ) ) { if ( MainWP_Helper::ends_with( $file, '/index.php' ) | MainWP_Helper::ends_with( $file, '/.htaccess' ) ) {
continue; continue;
} }
@ -3035,7 +3035,7 @@ class MainWP_Child {
if ( 'full' === $_POST['type'] ) { if ( 'full' === $_POST['type'] ) {
$excludes = ( isset( $_POST['exclude'] ) ? explode( ',', $_POST['exclude'] ) : array() ); $excludes = ( isset( $_POST['exclude'] ) ? explode( ',', $_POST['exclude'] ) : array() );
$excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/uploads/mainwp'; $excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/uploads/mainwp';
$uploadDir = MainWP_Helper::getMainWPDir(); $uploadDir = MainWP_Helper::get_mainwp_dir();
$uploadDir = $uploadDir[0]; $uploadDir = $uploadDir[0];
$excludes[] = str_replace( ABSPATH, '', $uploadDir ); $excludes[] = str_replace( ABSPATH, '', $uploadDir );
$excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/object-cache.php'; $excludes[] = str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '/object-cache.php';
@ -3137,7 +3137,7 @@ class MainWP_Child {
$ext = $_POST['ext']; $ext = $_POST['ext'];
} }
$res = $this->backupDB( $fileName, $ext ); $res = $this->backup_db( $fileName, $ext );
if ( ! $res ) { if ( ! $res ) {
$information['db'] = false; $information['db'] = false;
} else { } else {
@ -3157,8 +3157,8 @@ class MainWP_Child {
return $information; return $information;
} }
protected function backupDB( $fileName = '', $ext = 'zip' ) { protected function backup_db( $fileName = '', $ext = 'zip' ) {
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$dir = $dirs[0]; $dir = $dirs[0];
$timestamp = time(); $timestamp = time();
@ -3190,7 +3190,7 @@ class MainWP_Child {
); );
} }
public function doSecurityFix() { public function do_security_fix() {
$sync = false; $sync = false;
if ( 'all' === $_POST['feature'] ) { if ( 'all' === $_POST['feature'] ) {
$sync = true; $sync = true;
@ -3262,12 +3262,12 @@ class MainWP_Child {
MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' ); MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
if ( $sync ) { if ( $sync ) {
$information['sync'] = $this->getSiteStats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
} }
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function doSecurityUnFix() { public function do_security_un_fix() {
$information = array(); $information = array();
$sync = false; $sync = false;
@ -3316,13 +3316,13 @@ class MainWP_Child {
MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' ); MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
if ( $sync ) { if ( $sync ) {
$information['sync'] = $this->getSiteStats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
} }
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function getSecurityStats() { public function get_security_stats() {
$information = array(); $information = array();
$information['listing'] = ( ! MainWP_Security::prevent_listing_ok() ? 'N' : 'Y' ); $information['listing'] = ( ! MainWP_Security::prevent_listing_ok() ? 'N' : 'Y' );
@ -3339,7 +3339,7 @@ class MainWP_Child {
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function updateExternalSettings() { public function update_external_settings() {
$update_htaccess = false; $update_htaccess = false;
if ( isset( $_POST['cloneSites'] ) ) { if ( isset( $_POST['cloneSites'] ) ) {
@ -3371,11 +3371,11 @@ class MainWP_Child {
} }
// Show stats. // Show stats.
public function getSiteStats( $information = array(), $exit = true ) { public function get_site_stats( $information = array(), $exit = true ) {
global $wp_version; global $wp_version;
if ( $exit ) { if ( $exit ) {
$this->updateExternalSettings(); $this->update_external_settings();
} }
MainWP_Child_Branding::Instance()->save_branding_options( 'branding_disconnected', '' ); MainWP_Child_Branding::Instance()->save_branding_options( 'branding_disconnected', '' );
@ -3414,7 +3414,7 @@ class MainWP_Child {
$pubkey = get_option( 'mainwp_child_pubkey' ); $pubkey = get_option( 'mainwp_child_pubkey' );
$nossl = get_option( 'mainwp_child_nossl' ); $nossl = get_option( 'mainwp_child_nossl' );
if ( 1 == $nossl ) { if ( 1 == $nossl ) {
if ( isset( $pubkey ) && MainWP_Helper::isSSLEnabled() ) { if ( isset( $pubkey ) && MainWP_Helper::is_ssl_enabled() ) {
MainWP_Helper::update_option( 'mainwp_child_nossl', 0, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_nossl', 0, 'yes' );
$nossl = 0; $nossl = 0;
} }
@ -3694,7 +3694,7 @@ class MainWP_Child {
$information['securityIssues'] = $securityIssuess; $information['securityIssues'] = $securityIssuess;
// Directory listings! // Directory listings!
$information['directories'] = $this->scanDir( ABSPATH, 3 ); $information['directories'] = $this->scan_dir( ABSPATH, 3 );
$cats = get_categories( $cats = get_categories(
array( array(
'hide_empty' => 0, 'hide_empty' => 0,
@ -3711,7 +3711,7 @@ class MainWP_Child {
if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) { if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) {
$max_exe = ini_get( 'max_execution_time' ); $max_exe = ini_get( 'max_execution_time' );
if ( $max_exe > 20 ) { if ( $max_exe > 20 ) {
$information['totalsize'] = $this->getTotalFileSize(); $information['totalsize'] = $this->get_total_file_size();
} }
} }
$information['dbsize'] = MainWP_Child_DB::get_size(); $information['dbsize'] = MainWP_Child_DB::get_size();
@ -3740,7 +3740,7 @@ class MainWP_Child {
if ( isset( $last_post ) && isset( $last_post['post_modified_gmt'] ) ) { if ( isset( $last_post ) && isset( $last_post['post_modified_gmt'] ) ) {
$information['last_post_gmt'] = strtotime( $last_post['post_modified_gmt'] ); $information['last_post_gmt'] = strtotime( $last_post['post_modified_gmt'] );
} }
$information['mainwpdir'] = ( MainWP_Helper::validateMainWPDir() ? 1 : - 1 ); $information['mainwpdir'] = ( MainWP_Helper::validate_mainwp_dir() ? 1 : - 1 );
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' ); $information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info(); $information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info(); $information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
@ -3864,7 +3864,7 @@ class MainWP_Child {
} }
} }
public function scanDir( $pDir, $pLvl ) { public function scan_dir( $pDir, $pLvl ) {
$output = array(); $output = array();
if ( file_exists( $pDir ) && is_dir( $pDir ) ) { if ( file_exists( $pDir ) && is_dir( $pDir ) ) {
if ( 'logs' === basename( $pDir ) ) { if ( 'logs' === basename( $pDir ) ) {
@ -3873,7 +3873,7 @@ class MainWP_Child {
if ( 0 === $pLvl ) { if ( 0 === $pLvl ) {
return empty( $output ) ? null : $output; return empty( $output ) ? null : $output;
} }
$files = $this->intScanDir( $pDir ); $files = $this->int_scan_dir( $pDir );
if ( $files ) { if ( $files ) {
foreach ( $files as $file ) { foreach ( $files as $file ) {
if ( ( '.' === $file ) || ( '..' === $file ) ) { if ( ( '.' === $file ) || ( '..' === $file ) ) {
@ -3881,7 +3881,7 @@ class MainWP_Child {
} }
$newDir = $pDir . $file . DIRECTORY_SEPARATOR; $newDir = $pDir . $file . DIRECTORY_SEPARATOR;
if ( is_dir( $newDir ) ) { if ( is_dir( $newDir ) ) {
$output[ $file ] = $this->scanDir( $newDir, $pLvl - 1, false ); $output[ $file ] = $this->scan_dir( $newDir, $pLvl - 1, false );
} }
} }
@ -3893,7 +3893,7 @@ class MainWP_Child {
return empty( $output ) ? null : $output; return empty( $output ) ? null : $output;
} }
public function intScanDir( $dir ) { public function int_scan_dir( $dir ) {
$dh = opendir( $dir ); $dh = opendir( $dir );
if ( is_dir( $dir ) && $dh ) { if ( is_dir( $dir ) && $dh ) {
$cnt = 0; $cnt = 0;
@ -4430,7 +4430,7 @@ class MainWP_Child {
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
$wp_filesystem = $this->getWPFilesystem(); $wp_filesystem = $this->get_wp_filesystem();
if ( empty( $wp_filesystem ) ) { if ( empty( $wp_filesystem ) ) {
$wp_filesystem = new WP_Filesystem_Direct( null ); $wp_filesystem = new WP_Filesystem_Direct( null );
} }
@ -4470,7 +4470,7 @@ class MainWP_Child {
if ( ! isset( $information['status'] ) ) { if ( ! isset( $information['status'] ) ) {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
$information['sync'] = $this->getSiteStats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
@ -4556,7 +4556,7 @@ class MainWP_Child {
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
$wp_filesystem = $this->getWPFilesystem(); $wp_filesystem = $this->get_wp_filesystem();
if ( null === $wp_filesystem ) { if ( null === $wp_filesystem ) {
$wp_filesystem = new WP_Filesystem_Direct( null ); $wp_filesystem = new WP_Filesystem_Direct( null );
} }
@ -4590,7 +4590,7 @@ class MainWP_Child {
if ( ! isset( $information['status'] ) ) { if ( ! isset( $information['status'] ) ) {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
$information['sync'] = $this->getSiteStats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
@ -4780,7 +4780,7 @@ class MainWP_Child {
} }
// Show stats without login - only allowed while no account is added yet. // Show stats without login - only allowed while no account is added yet.
public function getSiteStatsNoAuth( $information = array() ) { public function get_site_stats_no_auth( $information = array() ) {
if ( get_option( 'mainwp_child_pubkey' ) ) { if ( get_option( 'mainwp_child_pubkey' ) ) {
$hint = '<br/>' . __( 'Hint: Go to the child site, deactivate and reactivate the MainWP Child plugin and try again.', 'mainwp-child' ); $hint = '<br/>' . __( 'Hint: Go to the child site, deactivate and reactivate the MainWP Child plugin and try again.', 'mainwp-child' );
MainWP_Helper::error( __( 'This site already contains a link. Please deactivate and reactivate the MainWP plugin.', 'mainwp-child' ) . $hint ); MainWP_Helper::error( __( 'This site already contains a link. Please deactivate and reactivate the MainWP plugin.', 'mainwp-child' ) . $hint );
@ -4862,7 +4862,7 @@ class MainWP_Child {
} }
} }
public function getWPFilesystem() { public function get_wp_filesystem() {
global $wp_filesystem; global $wp_filesystem;
if ( empty( $wp_filesystem ) ) { if ( empty( $wp_filesystem ) ) {
@ -4893,10 +4893,10 @@ class MainWP_Child {
return $wp_filesystem; return $wp_filesystem;
} }
public function getTotalFileSize( $directory = WP_CONTENT_DIR ) { public function get_total_file_size( $directory = WP_CONTENT_DIR ) {
try { try {
if ( MainWP_Helper::function_exists( 'popen' ) ) { if ( MainWP_Helper::function_exists( 'popen' ) ) {
$uploadDir = MainWP_Helper::getMainWPDir(); $uploadDir = MainWP_Helper::get_mainwp_dir();
$uploadDir = $uploadDir[0]; $uploadDir = $uploadDir[0];
$popenHandle = popen( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"', 'r' ); $popenHandle = popen( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"', 'r' );
if ( 'resource' === gettype( $popenHandle ) ) { if ( 'resource' === gettype( $popenHandle ) ) {
@ -4910,7 +4910,7 @@ class MainWP_Child {
} }
if ( MainWP_Helper::function_exists( 'shell_exec' ) ) { if ( MainWP_Helper::function_exists( 'shell_exec' ) ) {
$uploadDir = MainWP_Helper::getMainWPDir(); $uploadDir = MainWP_Helper::get_mainwp_dir();
$uploadDir = $uploadDir[0]; $uploadDir = $uploadDir[0];
$size = shell_exec( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"' ); $size = shell_exec( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"' );
if ( null !== $size ) { if ( null !== $size ) {
@ -4950,7 +4950,7 @@ class MainWP_Child {
} }
} }
public function serverInformation() { public function server_information() {
ob_start(); ob_start();
MainWP_Child_Server_Information::render(); MainWP_Child_Server_Information::render();
$output['information'] = ob_get_contents(); $output['information'] = ob_get_contents();
@ -5020,8 +5020,8 @@ class MainWP_Child {
// to fix issue of meta_value short length. // to fix issue of meta_value short length.
$performed_what[] = 'revisions'; // 'Posts revisions deleted'. $performed_what[] = 'revisions'; // 'Posts revisions deleted'.
} else { } else {
$results = MainWP_Helper::getRevisions( $max_revisions ); $results = MainWP_Helper::get_revisions( $max_revisions );
$count_deleted = MainWP_Helper::deleteRevisions( $results, $max_revisions ); $count_deleted = MainWP_Helper::delete_revisions( $results, $max_revisions );
$performed_what[] = 'revisions'; // 'Posts revisions deleted'. $performed_what[] = 'revisions'; // 'Posts revisions deleted'.
} }
@ -5188,7 +5188,7 @@ class MainWP_Child {
wp_mail( wp_mail(
$email, $email,
'MainWP - 404 Alert: ' . $blog, 'MainWP - 404 Alert: ' . $blog,
MainWP_Helper::formatEmail( $email, $mail ), MainWP_Helper::format_email( $email, $mail ),
array( array(
'content-type: text/html', 'content-type: text/html',
) )
@ -5224,7 +5224,7 @@ class MainWP_Child {
} }
if ( 'C' === $type ) { // save into wp-config file. if ( 'C' === $type ) { // save into wp-config file.
if ( false !== $this->snippetUpdateWPConfig( 'save', $slug, $code ) ) { if ( false !== $this->snippet_update_wp_config( 'save', $slug, $code ) ) {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
} else { } else {
@ -5243,7 +5243,7 @@ class MainWP_Child {
$snippets = array(); $snippets = array();
} }
if ( 'C' === $type ) { // delete in wp-config file. if ( 'C' === $type ) { // delete in wp-config file.
if ( false !== $this->snippetUpdateWPConfig( 'delete', $slug ) ) { if ( false !== $this->snippet_update_wp_config( 'delete', $slug ) ) {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
} else { } else {
@ -5260,7 +5260,7 @@ class MainWP_Child {
MainWP_Helper::write( $information ); MainWP_Helper::write( $information );
} }
public function snippetUpdateWPConfig( $action, $slug, $code = '' ) { public function snippet_update_wp_config( $action, $slug, $code = '' ) {
$config_file = ''; $config_file = '';
if ( file_exists( ABSPATH . 'wp-config.php' ) ) { if ( file_exists( ABSPATH . 'wp-config.php' ) ) {
@ -5343,7 +5343,7 @@ class MainWP_Child {
} }
try { try {
$upload = MainWP_Helper::uploadFile( $file_url, $dir, $filename ); $upload = MainWP_Helper::upload_file( $file_url, $dir, $filename );
if ( null !== $upload ) { if ( null !== $upload ) {
$information['success'] = true; $information['success'] = true;
} }
@ -5408,7 +5408,7 @@ class MainWP_Child {
public function delete_backup() { public function delete_backup() {
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$file = $_REQUEST['del']; $file = $_REQUEST['del'];
@ -5426,14 +5426,14 @@ class MainWP_Child {
MainWP_Helper::write( array( 'result' => 'ok' ) ); MainWP_Helper::write( array( 'result' => 'ok' ) );
} }
public function uploadFile( $file, $offset = 0 ) { public function upload_file( $file, $offset = 0 ) {
$dirs = MainWP_Helper::getMainWPDir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
header( 'Content-Description: File Transfer' ); header( 'Content-Description: File Transfer' );
header( 'Content-Description: File Transfer' ); header( 'Content-Description: File Transfer' );
if ( MainWP_Helper::endsWith( $file, '.tar.gz' ) ) { if ( MainWP_Helper::ends_with( $file, '.tar.gz' ) ) {
header( 'Content-Type: application/x-gzip' ); header( 'Content-Type: application/x-gzip' );
header( 'Content-Encoding: gzip' ); header( 'Content-Encoding: gzip' );
} else { } else {

View file

@ -19,7 +19,7 @@ class MainWP_Client_Report {
} }
public function init() { public function init() {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 );
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) ); add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
} }
@ -30,7 +30,7 @@ class MainWP_Client_Report {
return $agent; return $agent;
} }
public function syncOthersData( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) { if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) {
$creport_sync_data = array(); $creport_sync_data = array();
$firsttime = get_option( 'mainwp_creport_first_time_activated' ); $firsttime = get_option( 'mainwp_creport_first_time_activated' );
@ -487,25 +487,30 @@ class MainWP_Client_Report {
continue; continue;
} }
$valid_context = false;
// check context. // check context.
if ( 'comments' == $context ) { // multi values. if ( 'comments' == $context ) { // multi values.
$comment_contexts = array( 'post', 'page' ); $comment_contexts = array( 'post', 'page' );
if ( ! in_array( $record->context, $comment_contexts ) ) { if ( ! in_array( $record->context, $comment_contexts ) ) {
continue; continue;
} }
$valid_context = true;
} elseif ( 'post' === $context && 'created' === $action ) { } elseif ( 'post' === $context && 'created' === $action ) {
if ( in_array( $record->ID, $skip_records ) ) { if ( in_array( $record->ID, $skip_records ) ) {
continue; continue;
} }
$valid_context = true;
} elseif ( 'menus' == $context ) { } elseif ( 'menus' == $context ) {
// ok, pass, don't check context. $valid_context = true; // ok, pass, don't check context.
} elseif ( 'editor' == $record->connector ) { } elseif ( 'editor' == $record->connector ) {
// ok, pass, checked above. $valid_context = true; // ok, pass, checked above.
} elseif ( 'media' == $connector && 'media' == $record->connector ) { } elseif ( 'media' == $connector && 'media' == $record->connector ) {
// ok, pass, do not check context. $valid_context = true; // ok, pass, do not check context.
} elseif ( 'widgets' == $connector && 'widgets' == $record->connector ) { } elseif ( 'widgets' == $connector && 'widgets' == $record->connector ) {
// ok, pass, don't check context. $valid_context = true; // ok, pass, don't check context.
} elseif ( strtolower( $record->context ) !== $context ) { }
if ( ! $valid_context || strtolower( $record->context ) !== $context ) {
continue; continue;
} }
@ -707,10 +712,10 @@ class MainWP_Client_Report {
$tok_value = $record->ID; $tok_value = $record->ID;
break; break;
case 'date': case 'date':
$tok_value = MainWP_Helper::formatDate( MainWP_Helper::getTimestamp( strtotime( $record->created ) ) ); $tok_value = MainWP_Helper::format_date( MainWP_Helper::get_timestamp( strtotime( $record->created ) ) );
break; break;
case 'time': case 'time':
$tok_value = MainWP_Helper::formatTime( MainWP_Helper::getTimestamp( strtotime( $record->created ) ) ); $tok_value = MainWP_Helper::format_time( MainWP_Helper::get_timestamp( strtotime( $record->created ) ) );
break; break;
case 'area': case 'area':
$data = 'sidebar_name'; $data = 'sidebar_name';

View file

@ -176,12 +176,12 @@ class MainWP_Clone_Install {
} }
try { try {
$dirs = MainWP_Helper::getMainWPDir( 'backup', false ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup', false );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$files = glob( $backupdir . '*' ); $files = glob( $backupdir . '*' );
foreach ( $files as $file ) { foreach ( $files as $file ) {
if ( MainWP_Helper::isArchive( $file ) ) { if ( MainWP_Helper::is_archive( $file ) ) {
unlink( $file ); unlink( $file );
} }
} }
@ -448,7 +448,7 @@ class MainWP_Clone_Install {
} }
public function extractWPZipBackup() { public function extractWPZipBackup() {
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
global $wp_filesystem; global $wp_filesystem;
$tmpdir = ABSPATH; $tmpdir = ABSPATH;

View file

@ -47,7 +47,7 @@ class MainWP_Clone {
} }
public function secure_request( $action = '', $query_arg = 'security' ) { public function secure_request( $action = '', $query_arg = 'security' ) {
if ( ! MainWP_Helper::isAdmin() ) { if ( ! MainWP_Helper::is_admin() ) {
die( 0 ); die( 0 );
} }
if ( '' == $action ) { if ( '' == $action ) {
@ -105,7 +105,7 @@ class MainWP_Clone {
global $wp_scripts; global $wp_scripts;
$ui = $wp_scripts->query( 'jquery-ui-core' ); $ui = $wp_scripts->query( 'jquery-ui-core' );
$version = $ui->ver; $version = $ui->ver;
if ( MainWP_Helper::startsWith( $version, '1.10' ) ) { if ( MainWP_Helper::starts_with( $version, '1.10' ) ) {
wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.10.4/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.10', 'all' ); wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.10.4/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.10', 'all' );
} else { } else {
wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.11.1/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.11', 'all' ); wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.11.1/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.11', 'all' );
@ -153,7 +153,7 @@ class MainWP_Clone {
return; return;
} }
$error = false; $error = false;
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
global $wp_filesystem; global $wp_filesystem;
if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) { if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) {
echo '<div class="mainwp-child_info-box-red"><strong>' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')</strong></div>'; echo '<div class="mainwp-child_info-box-red"><strong>' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')</strong></div>';
@ -193,10 +193,10 @@ class MainWP_Clone {
<?php <?php
foreach ( $sitesToClone as $siteId => $siteToClone ) { foreach ( $sitesToClone as $siteId => $siteToClone ) {
?> ?>
<div class="clonesite_select_site_item" id="<?php echo esc_attr( $siteId ); ?>" rand="<?php echo esc_attr( MainWP_Helper::randString( 5 ) ); ?>"> <div class="clonesite_select_site_item" id="<?php echo esc_attr( $siteId ); ?>" rand="<?php echo esc_attr( MainWP_Helper::rand_string( 5 ) ); ?>">
<div class="mainwp-child_size_label" size="<?php echo esc_attr( $siteToClone['size'] ); ?>"><?php echo esc_html( $siteToClone['size'] ); ?>MB</div> <div class="mainwp-child_size_label" size="<?php echo esc_attr( $siteToClone['size'] ); ?>"><?php echo esc_html( $siteToClone['size'] ); ?>MB</div>
<div class="mainwp-child_name_label"><?php echo esc_html( $siteToClone['name'] ); ?></div> <div class="mainwp-child_name_label"><?php echo esc_html( $siteToClone['name'] ); ?></div>
<div class="mainwp-child_url_label"><?php echo esc_html( MainWP_Helper::getNiceURL( $siteToClone['url'] ) ); ?></div> <div class="mainwp-child_url_label"><?php echo esc_html( MainWP_Helper::get_nice_url( $siteToClone['url'] ) ); ?></div>
</div> </div>
<?php <?php
} }
@ -273,7 +273,7 @@ class MainWP_Clone {
<h2 class="hndle"><span><strong><?php esc_html_e( 'Option 1:', 'mainwp-child' ); ?></strong> <?php esc_html_e( 'Restore', 'mainwp-child' ); ?></span></h2> <h2 class="hndle"><span><strong><?php esc_html_e( 'Option 1:', 'mainwp-child' ); ?></strong> <?php esc_html_e( 'Restore', 'mainwp-child' ); ?></span></h2>
<div class="inside"> <div class="inside">
<?php <?php
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
global $wp_filesystem; global $wp_filesystem;
if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) { if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) {
echo '<div class="mainwp-child_info-box-red"><strong>' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')</strong></div>'; echo '<div class="mainwp-child_info-box-red"><strong>' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')</strong></div>';
@ -337,7 +337,7 @@ class MainWP_Clone {
$page = $_REQUEST['page']; $page = $_REQUEST['page'];
$sitesToClone = get_option( 'mainwp_child_clone_sites' ); $sitesToClone = get_option( 'mainwp_child_clone_sites' );
$url = admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone#title_03' ); $url = admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone#title_03' );
$dirs = MainWP_Helper::getMainWPDir( 'backup', false ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup', false );
$current_dir = $dirs[0]; $current_dir = $dirs[0];
$backup_dir = $current_dir; $backup_dir = $current_dir;
@ -420,7 +420,7 @@ class MainWP_Clone {
if ( is_dir( $current_dir . '/' . $file ) ) { if ( is_dir( $current_dir . '/' . $file ) ) {
$directories[] = $file; $directories[] = $file;
} else { } else {
if ( ! MainWP_Helper::isArchive( $file ) ) { if ( ! MainWP_Helper::is_archive( $file ) ) {
$rejected_files[] = $file; $rejected_files[] = $file;
} else { } else {
$files[] = $file; $files[] = $file;
@ -1156,11 +1156,11 @@ class MainWP_Clone {
$url = $siteToClone['url']; $url = $siteToClone['url'];
$key = $siteToClone['extauth']; $key = $siteToClone['extauth'];
MainWP_Helper::endSession(); MainWP_Helper::end_session();
// Send request to the childsite! // Send request to the childsite!
global $wp_version; global $wp_version;
$method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' ); $method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' );
$result = MainWP_Helper::fetchUrl( $result = MainWP_Helper::fetch_url(
$url, $url,
array( array(
'cloneFunc' => 'createCloneBackup', 'cloneFunc' => 'createCloneBackup',
@ -1211,9 +1211,9 @@ class MainWP_Clone {
$key = $siteToClone['extauth']; $key = $siteToClone['extauth'];
MainWP_Helper::endSession(); MainWP_Helper::end_session();
// Send request to the childsite! // Send request to the childsite!
$result = MainWP_Helper::fetchUrl( $result = MainWP_Helper::fetch_url(
$url, $url,
array( array(
'cloneFunc' => 'createCloneBackupPoll', 'cloneFunc' => 'createCloneBackupPoll',
@ -1259,18 +1259,18 @@ class MainWP_Clone {
} else { } else {
$url = $file; $url = $file;
} }
MainWP_Helper::endSession(); MainWP_Helper::end_session();
// Send request to the childsite! // Send request to the childsite!
$split = explode( '=', $file ); $split = explode( '=', $file );
$file = urldecode( $split[ count( $split ) - 1 ] ); $file = urldecode( $split[ count( $split ) - 1 ] );
$filename = 'download-' . basename( $file ); $filename = 'download-' . basename( $file );
$dirs = MainWP_Helper::getMainWPDir( 'backup', false ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup', false );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$dh = opendir( $backupdir ); $dh = opendir( $backupdir );
if ( $dh ) { if ( $dh ) {
$file = readdir( $dh ); $file = readdir( $dh );
while ( false !== $file ) { while ( false !== $file ) {
if ( '.' !== $file && '..' !== $file && MainWP_Helper::isArchive( $file, 'download-' ) ) { if ( '.' !== $file && '..' !== $file && MainWP_Helper::is_archive( $file, 'download-' ) ) {
unlink( $backupdir . $file ); unlink( $backupdir . $file );
} }
} }
@ -1310,7 +1310,7 @@ class MainWP_Clone {
if ( is_array( $sitesToClone ) && isset( $sitesToClone[ $siteId ] ) ) { if ( is_array( $sitesToClone ) && isset( $sitesToClone[ $siteId ] ) ) {
$siteToClone = $sitesToClone[ $siteId ]; $siteToClone = $sitesToClone[ $siteId ];
MainWP_Helper::fetchUrl( MainWP_Helper::fetch_url(
$siteToClone['url'], $siteToClone['url'],
array( array(
'cloneFunc' => 'deleteCloneBackup', 'cloneFunc' => 'deleteCloneBackup',
@ -1335,15 +1335,15 @@ class MainWP_Clone {
try { try {
$this->secure_request( 'mainwp-child_clone_backupdownloadpoll' ); $this->secure_request( 'mainwp-child_clone_backupdownloadpoll' );
MainWP_Helper::endSession(); MainWP_Helper::end_session();
$dirs = MainWP_Helper::getMainWPDir( 'backup', false ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup', false );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$files = glob( $backupdir . 'download-*' ); $files = glob( $backupdir . 'download-*' );
$archiveFile = false; $archiveFile = false;
foreach ( $files as $file ) { foreach ( $files as $file ) {
if ( MainWP_Helper::isArchive( $file, 'download-' ) ) { if ( MainWP_Helper::is_archive( $file, 'download-' ) ) {
$archiveFile = $file; $archiveFile = $file;
break; break;
} }
@ -1362,18 +1362,18 @@ class MainWP_Clone {
try { try {
$this->secure_request( 'mainwp-child_clone_backupextract' ); $this->secure_request( 'mainwp-child_clone_backupextract' );
MainWP_Helper::endSession(); MainWP_Helper::end_session();
$file = ( isset( $_POST['f'] ) ? $_POST['f'] : $_POST['file'] ); $file = ( isset( $_POST['f'] ) ? $_POST['f'] : $_POST['file'] );
$testFull = false; $testFull = false;
if ( '' === $file ) { if ( '' === $file ) {
$dirs = MainWP_Helper::getMainWPDir( 'backup', false ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup', false );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$files = glob( $backupdir . 'download-*' ); $files = glob( $backupdir . 'download-*' );
$archiveFile = false; $archiveFile = false;
foreach ( $files as $file ) { foreach ( $files as $file ) {
if ( MainWP_Helper::isArchive( $file, 'download-' ) ) { if ( MainWP_Helper::is_archive( $file, 'download-' ) ) {
$archiveFile = $file; $archiveFile = $file;
break; break;
} }
@ -1428,7 +1428,7 @@ class MainWP_Clone {
MainWP_Helper::update_option( 'mainwp_child_nossl', $nossl, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_nossl', $nossl, 'yes' );
MainWP_Helper::update_option( 'mainwp_child_nossl_key', $nossl_key ); MainWP_Helper::update_option( 'mainwp_child_nossl_key', $nossl_key );
MainWP_Helper::update_option( 'mainwp_child_clone_sites', $sitesToClone ); MainWP_Helper::update_option( 'mainwp_child_clone_sites', $sitesToClone );
if ( ! MainWP_Helper::startsWith( basename( $file ), 'download-backup-' ) ) { if ( ! MainWP_Helper::starts_with( basename( $file ), 'download-backup-' ) ) {
MainWP_Helper::update_option( 'mainwp_child_restore_permalink', true, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_restore_permalink', true, 'yes' );
} else { } else {
MainWP_Helper::update_option( 'mainwp_child_clone_permalink', true, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_clone_permalink', true, 'yes' );

View file

@ -102,7 +102,7 @@ class MainWP_Custom_Post_Type {
} }
try { try {
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl, array(), $check_image ); $downloadfile = MainWP_Helper::upload_image( $originalImgUrl, array(), $check_image );
$localUrl = $downloadfile['url']; $localUrl = $downloadfile['url'];
$linkToReplaceWith = dirname( $localUrl ); $linkToReplaceWith = dirname( $localUrl );
if ( '' !== $hrefLink ) { if ( '' !== $hrefLink ) {
@ -231,7 +231,7 @@ class MainWP_Custom_Post_Type {
if ( isset( $data['extras']['woocommerce']['product_images'] ) ) { if ( isset( $data['extras']['woocommerce']['product_images'] ) ) {
foreach ( $data['extras']['woocommerce']['product_images'] as $product_image ) { foreach ( $data['extras']['woocommerce']['product_images'] as $product_image ) {
try { try {
$upload_featured_image = MainWP_Helper::uploadImage( $product_image, array(), $check_image_existed ); $upload_featured_image = MainWP_Helper::upload_image( $product_image, array(), $check_image_existed );
if ( null !== $upload_featured_image ) { if ( null !== $upload_featured_image ) {
$product_image_gallery[] = $upload_featured_image['id']; $product_image_gallery[] = $upload_featured_image['id'];
@ -252,7 +252,7 @@ class MainWP_Custom_Post_Type {
if ( '_thumbnail_id' == $key['meta_key'] ) { if ( '_thumbnail_id' == $key['meta_key'] ) {
if ( isset( $data['extras']['featured_image'] ) ) { if ( isset( $data['extras']['featured_image'] ) ) {
try { try {
$upload_featured_image = MainWP_Helper::uploadImage( $data['extras']['featured_image'], array(), $check_image_existed ); $upload_featured_image = MainWP_Helper::upload_image( $data['extras']['featured_image'], array(), $check_image_existed );
if ( null !== $upload_featured_image ) { if ( null !== $upload_featured_image ) {
$key['meta_value'] = $upload_featured_image['id']; $key['meta_value'] = $upload_featured_image['id'];

View file

@ -25,7 +25,7 @@ class MainWP_Debug {
} elseif ( 'test' == $_GET['mainwpdebug'] ) { } elseif ( 'test' == $_GET['mainwpdebug'] ) {
print_r( get_included_files() ); print_r( get_included_files() );
} else { } else {
print_r( $mainwpChild->getSiteStats( array(), false ) ); print_r( $mainwpChild->get_site_stats( array(), false ) );
} }
$stop = microtime( true ); $stop = microtime( true );

View file

@ -201,7 +201,7 @@ class MainWP_Helper {
// $check_file_existed: to support checking if file existed. // $check_file_existed: to support checking if file existed.
// $parent_id: optional. // $parent_id: optional.
public static function uploadImage( $img_url, $img_data = array(), $check_file_existed = false, $parent_id = 0 ) { public static function upload_image( $img_url, $img_data = array(), $check_file_existed = false, $parent_id = 0 ) {
if ( ! is_array( $img_data ) ) { if ( ! is_array( $img_data ) ) {
$img_data = array(); $img_data = array();
} }
@ -318,7 +318,7 @@ class MainWP_Helper {
return $wpdb->get_results( $sql ); return $wpdb->get_results( $sql );
} }
public static function uploadFile( $file_url, $path, $file_name ) { public static function upload_file( $file_url, $path, $file_name ) {
// to fix uploader extension rename htaccess file issue. // to fix uploader extension rename htaccess file issue.
if ( '.htaccess' != $file_name && '.htpasswd' != $file_name ) { if ( '.htaccess' != $file_name && '.htpasswd' != $file_name ) {
$file_name = sanitize_file_name( $file_name ); $file_name = sanitize_file_name( $file_name );
@ -359,7 +359,7 @@ class MainWP_Helper {
return array( 'path' => $full_file_name ); return array( 'path' => $full_file_name );
} }
public static function createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others = array() ) { public static function create_post( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others = array() ) {
global $current_user; global $current_user;
/** /**
@ -487,7 +487,7 @@ class MainWP_Helper {
} }
try { try {
$downloadfile = self::uploadImage( $originalImgUrl, array(), $check_image_existed ); $downloadfile = self::upload_image( $originalImgUrl, array(), $check_image_existed );
$localUrl = $downloadfile['url']; $localUrl = $downloadfile['url'];
$linkToReplaceWith = dirname( $localUrl ); $linkToReplaceWith = dirname( $localUrl );
if ( '' !== $hrefLink ) { if ( '' !== $hrefLink ) {
@ -518,7 +518,7 @@ class MainWP_Helper {
foreach ( $post_gallery_images as $gallery ) { foreach ( $post_gallery_images as $gallery ) {
if ( isset( $gallery['src'] ) ) { if ( isset( $gallery['src'] ) ) {
try { try {
$upload = self::uploadImage( $gallery['src'], $gallery ); // Upload image to WP. $upload = self::upload_image( $gallery['src'], $gallery ); // Upload image to WP.
if ( null !== $upload ) { if ( null !== $upload ) {
$replaceAttachedIds[ $gallery['id'] ] = $upload['id']; $replaceAttachedIds[ $gallery['id'] ] = $upload['id'];
} }
@ -716,7 +716,7 @@ class MainWP_Helper {
// upload image if it on the server. // upload image if it on the server.
if ( ! empty( $_seo_opengraph_image ) && false !== strpos( $_seo_opengraph_image, $_server_domain ) ) { if ( ! empty( $_seo_opengraph_image ) && false !== strpos( $_seo_opengraph_image, $_server_domain ) ) {
try { try {
$upload = self::uploadImage( $_seo_opengraph_image ); // Upload image to WP. $upload = self::upload_image( $_seo_opengraph_image ); // Upload image to WP.
if ( null !== $upload ) { if ( null !== $upload ) {
update_post_meta( $new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post! update_post_meta( $new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post!
} }
@ -752,7 +752,7 @@ class MainWP_Helper {
// If featured image exists - set it. // If featured image exists - set it.
if ( null !== $post_featured_image ) { if ( null !== $post_featured_image ) {
try { try {
$upload = self::uploadImage( $post_featured_image, array(), $check_image_existed, $new_post_id ); // Upload image to WP. $upload = self::upload_image( $post_featured_image, array(), $check_image_existed, $new_post_id ); // Upload image to WP.
if ( null !== $upload ) { if ( null !== $upload ) {
update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); // Add the thumbnail to the post! update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); // Add the thumbnail to the post!
$featured_image_exist = true; $featured_image_exist = true;
@ -851,10 +851,10 @@ class MainWP_Helper {
return $ret; return $ret;
} }
public static function getMainWPDir( $what = null, $dieOnError = true ) { public static function get_mainwp_dir( $what = null, $dieOnError = true ) {
$upload_dir = wp_upload_dir(); $upload_dir = wp_upload_dir();
$dir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'mainwp' . DIRECTORY_SEPARATOR; $dir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'mainwp' . DIRECTORY_SEPARATOR;
self::checkDir( $dir, $dieOnError ); self::check_dir( $dir, $dieOnError );
if ( ! file_exists( $dir . 'index.php' ) ) { if ( ! file_exists( $dir . 'index.php' ) ) {
touch( $dir . 'index.php' ); touch( $dir . 'index.php' );
} }
@ -862,7 +862,7 @@ class MainWP_Helper {
if ( 'backup' === $what ) { if ( 'backup' === $what ) {
$dir .= 'backup' . DIRECTORY_SEPARATOR; $dir .= 'backup' . DIRECTORY_SEPARATOR;
self::checkDir( $dir, $dieOnError ); self::check_dir( $dir, $dieOnError );
if ( ! file_exists( $dir . 'index.php' ) ) { if ( ! file_exists( $dir . 'index.php' ) ) {
touch( $dir . 'index.php' ); touch( $dir . 'index.php' );
} }
@ -879,8 +879,8 @@ class MainWP_Helper {
return array( $dir, $url ); return array( $dir, $url );
} }
public static function checkDir( $dir, $dieOnError, $chmod = 0755 ) { public static function check_dir( $dir, $dieOnError, $chmod = 0755 ) {
self::getWPFilesystem(); self::get_wp_filesystem();
global $wp_filesystem; global $wp_filesystem;
if ( ! file_exists( $dir ) ) { if ( ! file_exists( $dir ) ) {
if ( empty( $wp_filesystem ) ) { if ( empty( $wp_filesystem ) ) {
@ -907,14 +907,14 @@ class MainWP_Helper {
} }
} }
public static function validateMainWPDir() { public static function validate_mainwp_dir() {
$done = false; $done = false;
$dir = self::getMainWPDir(); $dir = self::get_mainwp_dir();
$dir = $dir[0]; $dir = $dir[0];
if ( self::getWPFilesystem() ) { if ( self::get_wp_filesystem() ) {
global $wp_filesystem; global $wp_filesystem;
try { try {
self::checkDir( $dir, false ); self::check_dir( $dir, false );
} catch ( Exception $e ) { } catch ( Exception $e ) {
// ok! // ok!
} }
@ -960,7 +960,7 @@ class MainWP_Helper {
/** /**
* @return WP_Filesystem_Base * @return WP_Filesystem_Base
*/ */
public static function getWPFilesystem() { public static function get_wp_filesystem() {
global $wp_filesystem; global $wp_filesystem;
if ( empty( $wp_filesystem ) ) { if ( empty( $wp_filesystem ) ) {
@ -987,11 +987,11 @@ class MainWP_Helper {
return $init; return $init;
} }
public static function startsWith( $haystack, $needle ) { public static function starts_with( $haystack, $needle ) {
return ! strncmp( $haystack, $needle, strlen( $needle ) ); return ! strncmp( $haystack, $needle, strlen( $needle ) );
} }
public static function endsWith( $haystack, $needle ) { public static function ends_with( $haystack, $needle ) {
$length = strlen( $needle ); $length = strlen( $needle );
if ( 0 == $length ) { if ( 0 == $length ) {
return true; return true;
@ -1000,14 +1000,14 @@ class MainWP_Helper {
return ( substr( $haystack, - $length ) == $needle ); return ( substr( $haystack, - $length ) == $needle );
} }
public static function getNiceURL( $pUrl, $showHttp = false ) { public static function get_nice_url( $pUrl, $showHttp = false ) {
$url = $pUrl; $url = $pUrl;
if ( self::startsWith( $url, 'http://' ) ) { if ( self::starts_with( $url, 'http://' ) ) {
if ( ! $showHttp ) { if ( ! $showHttp ) {
$url = substr( $url, 7 ); $url = substr( $url, 7 );
} }
} elseif ( self::startsWith( $pUrl, 'https://' ) ) { } elseif ( self::starts_with( $pUrl, 'https://' ) ) {
if ( ! $showHttp ) { if ( ! $showHttp ) {
$url = substr( $url, 8 ); $url = substr( $url, 8 );
} }
@ -1017,7 +1017,7 @@ class MainWP_Helper {
} }
} }
if ( self::endsWith( $url, '/' ) ) { if ( self::ends_with( $url, '/' ) ) {
if ( ! $showHttp ) { if ( ! $showHttp ) {
$url = substr( $url, 0, strlen( $url ) - 1 ); $url = substr( $url, 0, strlen( $url ) - 1 );
} }
@ -1036,29 +1036,29 @@ class MainWP_Helper {
return $string; return $string;
} }
public static function endSession() { public static function end_session() {
session_write_close(); session_write_close();
ob_end_flush(); ob_end_flush();
} }
public static function fetchUrl( $url, $postdata ) { public static function fetch_url( $url, $postdata ) {
try { try {
$tmpUrl = $url; $tmpUrl = $url;
if ( '/' !== substr( $tmpUrl, - 1 ) ) { if ( '/' !== substr( $tmpUrl, - 1 ) ) {
$tmpUrl .= '/'; $tmpUrl .= '/';
} }
return self::_fetchUrl( $tmpUrl . 'wp-admin/', $postdata ); return self::m_fetch_url( $tmpUrl . 'wp-admin/', $postdata );
} catch ( Exception $e ) { } catch ( Exception $e ) {
try { try {
return self::_fetchUrl( $url, $postdata ); return self::m_fetch_url( $url, $postdata );
} catch ( Exception $ex ) { } catch ( Exception $ex ) {
throw $e; throw $e;
} }
} }
} }
public static function _fetchUrl( $url, $postdata ) { public static function m_fetch_url( $url, $postdata ) {
$agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)'; $agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)';
if ( ! is_array( $postdata ) ) { if ( ! is_array( $postdata ) ) {
@ -1096,7 +1096,7 @@ class MainWP_Helper {
} }
public static function randString( $length, $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ) { public static function rand_string( $length, $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ) {
$str = ''; $str = '';
$count = strlen( $charset ); $count = strlen( $charset );
while ( $length -- ) { while ( $length -- ) {
@ -1172,25 +1172,25 @@ class MainWP_Helper {
return true; return true;
} }
public static function getTimestamp( $timestamp ) { public static function get_timestamp( $timestamp ) {
$gmtOffset = get_option( 'gmt_offset' ); $gmtOffset = get_option( 'gmt_offset' );
return ( $gmtOffset ? ( $gmtOffset * HOUR_IN_SECONDS ) + $timestamp : $timestamp ); return ( $gmtOffset ? ( $gmtOffset * HOUR_IN_SECONDS ) + $timestamp : $timestamp );
} }
public static function formatDate( $timestamp ) { public static function format_date( $timestamp ) {
return date_i18n( get_option( 'date_format' ), $timestamp ); return date_i18n( get_option( 'date_format' ), $timestamp );
} }
public static function formatTime( $timestamp ) { public static function format_time( $timestamp ) {
return date_i18n( get_option( 'time_format' ), $timestamp ); return date_i18n( get_option( 'time_format' ), $timestamp );
} }
public static function formatTimestamp( $timestamp ) { public static function format_timestamp( $timestamp ) {
return date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $timestamp ); return date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $timestamp );
} }
public static function formatEmail( $to, $body ) { public static function format_email( $to, $body ) {
return '<br> return '<br>
<div> <div>
<br> <br>
@ -1329,29 +1329,14 @@ class MainWP_Helper {
return get_option( 'mainwp_lasttime_backup_' . $by, 0 ); return get_option( 'mainwp_lasttime_backup_' . $by, 0 );
} }
public static function get_revisions( $max_revisions ) {
public static function containsAll( $haystack, $needle ) {
if ( ! is_array( $haystack ) || ! is_array( $needle ) ) {
return false;
}
foreach ( $needle as $item ) {
if ( ! in_array( $item, $haystack ) ) {
return false;
}
}
return true;
}
public static function getRevisions( $max_revisions ) {
global $wpdb; global $wpdb;
$sql = " SELECT `post_parent`, COUNT(*) cnt FROM $wpdb->posts WHERE `post_type` = 'revision' GROUP BY `post_parent` HAVING COUNT(*) > " . $max_revisions; $sql = " SELECT `post_parent`, COUNT(*) cnt FROM $wpdb->posts WHERE `post_type` = 'revision' GROUP BY `post_parent` HAVING COUNT(*) > " . $max_revisions;
return $wpdb->get_results( $sql ); return $wpdb->get_results( $sql );
} }
public static function deleteRevisions( $results, $max_revisions ) { public static function delete_revisions( $results, $max_revisions ) {
global $wpdb; global $wpdb;
if ( ! is_array( $results ) || 0 === count( $results ) ) { if ( ! is_array( $results ) || 0 === count( $results ) ) {
@ -1382,20 +1367,20 @@ class MainWP_Helper {
return $count_deleted; return $count_deleted;
} }
public static function inExcludes( $excludes, $value ) { public static function in_excludes( $excludes, $value ) {
if ( empty( $value ) ) { if ( empty( $value ) ) {
return false; return false;
} }
if ( null != $excludes ) { if ( null != $excludes ) {
foreach ( $excludes as $exclude ) { foreach ( $excludes as $exclude ) {
if ( self::endsWith( $exclude, '*' ) ) { if ( self::ends_with( $exclude, '*' ) ) {
if ( self::startsWith( $value, substr( $exclude, 0, strlen( $exclude ) - 1 ) ) ) { if ( self::starts_with( $value, substr( $exclude, 0, strlen( $exclude ) - 1 ) ) ) {
return true; return true;
} }
} elseif ( $value == $exclude ) { } elseif ( $value == $exclude ) {
return true; return true;
} elseif ( self::startsWith( $value, $exclude . '/' ) ) { } elseif ( self::starts_with( $value, $exclude . '/' ) ) {
return true; return true;
} }
} }
@ -1404,7 +1389,7 @@ class MainWP_Helper {
return false; return false;
} }
public static function isArchive( $pFileName, $pPrefix = '', $pSuffix = '' ) { public static function is_archive( $pFileName, $pPrefix = '', $pSuffix = '' ) {
return preg_match( '/' . $pPrefix . '(.*).(zip|tar|tar.gz|tar.bz2)' . $pSuffix . '$/', $pFileName ); return preg_match( '/' . $pPrefix . '(.*).(zip|tar|tar.gz|tar.bz2)' . $pSuffix . '$/', $pFileName );
} }
@ -1538,7 +1523,7 @@ class MainWP_Helper {
return false; return false;
} }
public static function isAdmin() { public static function is_admin() {
global $current_user; global $current_user;
if ( 0 == $current_user->ID ) { if ( 0 == $current_user->ID ) {
return false; return false;
@ -1551,7 +1536,7 @@ class MainWP_Helper {
return false; return false;
} }
public static function isSSLEnabled() { public static function is_ssl_enabled() {
if ( defined( 'MAINWP_NOSSL' ) ) { if ( defined( 'MAINWP_NOSSL' ) ) {
return ! MAINWP_NOSSL; return ! MAINWP_NOSSL;
} }

View file

@ -232,7 +232,7 @@ class MainWP_Security {
if ( $force || self::get_security_option( 'readme' ) ) { if ( $force || self::get_security_option( 'readme' ) ) {
if ( file_exists( ABSPATH . 'readme.html' ) ) { if ( file_exists( ABSPATH . 'readme.html' ) ) {
if ( ! unlink( ABSPATH . 'readme.html' ) ) { if ( ! unlink( ABSPATH . 'readme.html' ) ) {
MainWP_Helper::getWPFilesystem(); MainWP_Helper::get_wp_filesystem();
global $wp_filesystem; global $wp_filesystem;
if ( ! empty( $wp_filesystem ) ) { if ( ! empty( $wp_filesystem ) ) {
$wp_filesystem->delete( ABSPATH . 'readme.html' ); $wp_filesystem->delete( ABSPATH . 'readme.html' );

View file

@ -166,9 +166,9 @@ class Tar_Archiver {
'xmlrpc.php', 'xmlrpc.php',
); );
foreach ( $nodes as $key => $node ) { foreach ( $nodes as $key => $node ) {
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { if ( MainWP_Helper::starts_with( $node, ABSPATH . WPINC ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { } elseif ( MainWP_Helper::starts_with( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
unset( $nodes[ $key ] ); unset( $nodes[ $key ] );
} else { } else {
foreach ( $coreFiles as $coreFile ) { foreach ( $coreFiles as $coreFile ) {
@ -193,12 +193,12 @@ class Tar_Archiver {
foreach ( $nodes as $node ) { foreach ( $nodes as $node ) {
if ( $excludenonwp && is_dir( $node ) ) { if ( $excludenonwp && is_dir( $node ) ) {
if ( ! MainWP_Helper::startsWith( $node, WP_CONTENT_DIR ) && ! MainWP_Helper::startsWith( $node, ABSPATH . 'wp-admin' ) && ! MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { if ( ! MainWP_Helper::starts_with( $node, WP_CONTENT_DIR ) && ! MainWP_Helper::starts_with( $node, ABSPATH . 'wp-admin' ) && ! MainWP_Helper::starts_with( $node, ABSPATH . WPINC ) ) {
continue; continue;
} }
} }
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) { if ( ! MainWP_Helper::in_excludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) {
if ( is_dir( $node ) ) { if ( is_dir( $node ) ) {
$this->addDir( $node, $excludes ); $this->addDir( $node, $excludes );
} elseif ( is_file( $node ) ) { } elseif ( is_file( $node ) ) {
@ -293,7 +293,7 @@ class Tar_Archiver {
continue; continue;
} }
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $name ) ) ) { if ( ! MainWP_Helper::in_excludes( $excludes, str_replace( ABSPATH, '', $name ) ) ) {
if ( $path->isDir() ) { if ( $path->isDir() ) {
$this->addEmptyDir( $name, str_replace( ABSPATH, '', $name ) ); $this->addEmptyDir( $name, str_replace( ABSPATH, '', $name ) );
} else { } else {
@ -460,7 +460,7 @@ class Tar_Archiver {
return false; return false;
} }
if ( $this->excludeZip && MainWP_Helper::endsWith( $path, '.zip' ) ) { if ( $this->excludeZip && MainWP_Helper::ends_with( $path, '.zip' ) ) {
$this->log( 'Skipping ' . $path ); $this->log( 'Skipping ' . $path );
return false; return false;
@ -1267,9 +1267,9 @@ if ( class_exists( 'SplHeap' ) ) {
return strcmp( $pathA, $pathB ); return strcmp( $pathA, $pathB );
} elseif ( $dirnameA == $dirnameB ) { } elseif ( $dirnameA == $dirnameB ) {
return strcmp( $pathA, $pathB ); return strcmp( $pathA, $pathB );
} elseif ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) { } elseif ( MainWP_Helper::starts_with( $dirnameA, $dirnameB ) ) {
return 1; return 1;
} elseif ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) { } elseif ( MainWP_Helper::starts_with( $dirnameB, $dirnameA ) ) {
return - 1; return - 1;
} else { } else {
$cmp = strcmp( $dirnameA, $dirnameB ); $cmp = strcmp( $dirnameA, $dirnameB );