Version Description
- 9-27-18 =
- Fixed: compatibility issues caused by the recent UpdraftPlus update
- Fixed: issues with the WooCommerce Status information
- Fixed: issues with Bulk Settings Manager for specific plugins
- Added: mainwp_child_mu_plugin_enabled hook to allow MainWP Child usage as a must-use plugin
- Added: support for recording WP Time Capsule backups for Client Reports
- Added: mainwp_branding_role_cap_enable_contact_form hook to allow users to show Support Form (Branding extension option) to specific roles
- Added: support to for the new BackUpWordPrress Extension feature
- Added: support for the new MainWP Buddy Extension feature
- Updated: reporting system to determine backup type for BackWPup backups
- Improved: connection stability for sites hosted on hosts with small execution time limits
- Improved: detecting updates for premium plugins
Download this release
Release Info
Developer | mainwp |
Plugin | MainWP Child |
Version | 3.5 |
Comparing to | |
See all releases |
Code changes from version 3.4.9 to 3.5
- class/class-mainwp-child-back-up-buddy.php +73 -49
- class/class-mainwp-child-back-up-wordpress.php +67 -34
- class/class-mainwp-child-back-wp-up.php +54 -31
- class/class-mainwp-child-branding.php +44 -62
- class/class-mainwp-child-plugins-check.php +2 -18
- class/class-mainwp-child-themes-check.php +1 -20
- class/class-mainwp-child-timecapsule.php +55 -37
- class/class-mainwp-child-updraft-plus-backups.php +71 -57
- class/class-mainwp-child-woocommerce-status.php +36 -22
- class/class-mainwp-child.php +207 -132
- class/class-mainwp-client-report.php +18 -15
- class/class-mainwp-keyword-links.php +6 -1
- class/class-mainwp-security.php +22 -66
- mainwp-child.php +1 -1
- readme.txt +15 -2
class/class-mainwp-child-back-up-buddy.php
CHANGED
@@ -28,7 +28,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
28 |
}
|
29 |
|
30 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
31 |
-
|
32 |
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
|
33 |
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
34 |
|
@@ -74,7 +74,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
74 |
}
|
75 |
|
76 |
|
77 |
-
function do_site_stats() {
|
78 |
if (has_action('mainwp_child_reports_log')) {
|
79 |
do_action( 'mainwp_child_reports_log', 'backupbuddy');
|
80 |
} else {
|
@@ -89,9 +89,9 @@ class MainWP_Child_Back_Up_Buddy {
|
|
89 |
if (!$this->is_backupbuddy_installed) {
|
90 |
return;
|
91 |
}
|
92 |
-
|
93 |
try {
|
94 |
-
|
95 |
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
|
96 |
|
97 |
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
@@ -102,9 +102,9 @@ class MainWP_Child_Back_Up_Buddy {
|
|
102 |
if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'))
|
103 |
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
|
104 |
|
105 |
-
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' ));
|
106 |
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
|
107 |
-
|
108 |
// Backup type.
|
109 |
$pretty_type = array(
|
110 |
'full' => 'Full',
|
@@ -112,7 +112,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
112 |
'files' => 'Files',
|
113 |
);
|
114 |
|
115 |
-
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
|
116 |
|
117 |
|
118 |
foreach( $recentBackups_list as $backup_fileoptions ) {
|
@@ -136,7 +136,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
136 |
|
137 |
$backupType = '';
|
138 |
if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) {
|
139 |
-
if (true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true)) {
|
140 |
if (true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true)) {
|
141 |
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
|
142 |
}
|
@@ -152,42 +152,40 @@ class MainWP_Child_Back_Up_Buddy {
|
|
152 |
}
|
153 |
|
154 |
$finish_time = $backup['finish_time'];
|
155 |
-
$message = 'BackupBuddy ' . $backupType . ' finished';
|
156 |
if (!empty($finish_time)) {
|
157 |
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
158 |
-
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
|
159 |
}
|
160 |
}
|
161 |
|
162 |
if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) {
|
163 |
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' );
|
164 |
-
|
165 |
-
MainWP_Helper::check_classes_exists(array( 'backupbuddy_live_periodic' ));
|
166 |
MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats');
|
167 |
-
|
168 |
$state = backupbuddy_live_periodic::get_stats();
|
169 |
if (is_array($state) && isset($state['stats'])) {
|
170 |
|
171 |
if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] )) {
|
172 |
if (isset( $state['stats']['last_remote_snapshot_response'] )) {
|
173 |
-
$resp = $state['stats']['last_remote_snapshot_response'];
|
174 |
if ( isset( $resp['success'] ) && $resp['success']) {
|
175 |
-
$finish_time = $state['stats']['last_remote_snapshot'];
|
176 |
$backupType = 'Live Backup to cloud';
|
177 |
-
$message = 'BackupBuddy ' . $backupType . ' finished';
|
178 |
if (!empty($finish_time)) {
|
179 |
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
180 |
-
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
|
181 |
}
|
182 |
|
183 |
-
}
|
184 |
}
|
185 |
}
|
186 |
|
187 |
}
|
188 |
}
|
189 |
} catch( Exception $e ) {
|
190 |
-
|
191 |
}
|
192 |
}
|
193 |
|
@@ -723,47 +721,73 @@ class MainWP_Child_Back_Up_Buddy {
|
|
723 |
}
|
724 |
|
725 |
// ok
|
726 |
-
public function syncOthersData( $information, $data = array() ) {
|
727 |
-
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
|
728 |
try {
|
729 |
$information['syncBackupBuddy'] = $this->get_sync_data();
|
730 |
} catch(Exception $e) {
|
731 |
-
|
732 |
}
|
733 |
-
}
|
734 |
return $information;
|
735 |
}
|
736 |
-
|
737 |
-
// ok
|
738 |
public function get_sync_data() {
|
739 |
-
|
740 |
-
try {
|
741 |
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
742 |
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
743 |
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
|
744 |
-
|
745 |
$plugin_path = pb_backupbuddy::plugin_path();
|
746 |
if (file_exists($plugin_path . '/classes/core.php'))
|
747 |
-
require_once( $plugin_path . '/classes/core.php' );
|
748 |
}
|
749 |
|
750 |
-
MainWP_Helper::check_classes_exists('backupbuddy_core');
|
751 |
-
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
|
752 |
-
|
|
|
|
|
|
|
753 |
$data = array();
|
754 |
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
|
755 |
$data['themes_root'] = backupbuddy_core::get_themes_root();
|
756 |
$data['media_root'] = backupbuddy_core::get_media_root();
|
757 |
$data['additional_tables'] = $this->pb_additional_tables();
|
758 |
$data['abspath'] = ABSPATH;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
759 |
return $data;
|
760 |
} catch(Exception $e) {
|
761 |
-
// not exit here
|
762 |
-
}
|
763 |
-
|
764 |
return false;
|
765 |
}
|
766 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
767 |
function backup_list() {
|
768 |
require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
|
769 |
$information = array();
|
@@ -838,7 +862,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
838 |
// This will identify the backup zip file we want to list
|
839 |
$serial = $_POST[ 'serial' ];
|
840 |
$alerts = array();
|
841 |
-
// The fileoptions file that contains the file tree information
|
842 |
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
|
843 |
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '-filetree.txt';
|
844 |
|
@@ -852,7 +876,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
852 |
pb_backupbuddy::status( 'details', 'Fileoptions instance #28.' );
|
853 |
$fileoptions = new pb_backupbuddy_fileoptions( $fileoptions_file );
|
854 |
$zip_viewer = $_POST[ 'zip_viewer' ];
|
855 |
-
// Either we are getting cached file tree information or we need to create afresh
|
856 |
if ( true !== ( $result = $fileoptions->is_ok() ) ) {
|
857 |
// Get file listing.
|
858 |
require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' );
|
@@ -1018,13 +1042,13 @@ class MainWP_Child_Back_Up_Buddy {
|
|
1018 |
|
1019 |
// ok
|
1020 |
function pb_additional_tables( $display_size = false ) {
|
1021 |
-
|
1022 |
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
1023 |
-
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
|
1024 |
-
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
|
1025 |
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
|
1026 |
-
|
1027 |
-
|
1028 |
$return = '';
|
1029 |
$size_string = '';
|
1030 |
|
@@ -1890,9 +1914,9 @@ class MainWP_Child_Back_Up_Buddy {
|
|
1890 |
function remote_save() {
|
1891 |
$data = isset($_POST['data']) ? $_POST['data'] : false;
|
1892 |
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0;
|
1893 |
-
|
1894 |
if (is_array($data) && isset($data['do_not_override'])) {
|
1895 |
-
|
1896 |
if (true == $data['do_not_override']) {
|
1897 |
if (($data['type'] == 's32' || $data['type'] == 's33')) {
|
1898 |
$not_override = array(
|
@@ -1903,16 +1927,16 @@ class MainWP_Child_Back_Up_Buddy {
|
|
1903 |
);
|
1904 |
foreach($not_override as $opt) {
|
1905 |
if (isset($data[$opt])) {
|
1906 |
-
unset($data[$opt]);
|
1907 |
-
}
|
1908 |
}
|
1909 |
}
|
1910 |
}
|
1911 |
-
|
1912 |
unset($data['do_not_override']);
|
1913 |
}
|
1914 |
-
|
1915 |
-
|
1916 |
if (is_array($data)) {
|
1917 |
if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update
|
1918 |
pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data );
|
28 |
}
|
29 |
|
30 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
31 |
+
|
32 |
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
|
33 |
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
34 |
|
74 |
}
|
75 |
|
76 |
|
77 |
+
function do_site_stats() {
|
78 |
if (has_action('mainwp_child_reports_log')) {
|
79 |
do_action( 'mainwp_child_reports_log', 'backupbuddy');
|
80 |
} else {
|
89 |
if (!$this->is_backupbuddy_installed) {
|
90 |
return;
|
91 |
}
|
92 |
+
|
93 |
try {
|
94 |
+
|
95 |
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
|
96 |
|
97 |
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
102 |
if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'))
|
103 |
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
|
104 |
|
105 |
+
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' ));
|
106 |
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
|
107 |
+
|
108 |
// Backup type.
|
109 |
$pretty_type = array(
|
110 |
'full' => 'Full',
|
112 |
'files' => 'Files',
|
113 |
);
|
114 |
|
115 |
+
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
|
116 |
|
117 |
|
118 |
foreach( $recentBackups_list as $backup_fileoptions ) {
|
136 |
|
137 |
$backupType = '';
|
138 |
if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) {
|
139 |
+
if (true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true)) {
|
140 |
if (true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true)) {
|
141 |
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
|
142 |
}
|
152 |
}
|
153 |
|
154 |
$finish_time = $backup['finish_time'];
|
155 |
+
$message = 'BackupBuddy ' . $backupType . ' finished';
|
156 |
if (!empty($finish_time)) {
|
157 |
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
|
|
158 |
}
|
159 |
}
|
160 |
|
161 |
if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) {
|
162 |
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' );
|
163 |
+
|
164 |
+
MainWP_Helper::check_classes_exists(array( 'backupbuddy_live_periodic' ));
|
165 |
MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats');
|
166 |
+
|
167 |
$state = backupbuddy_live_periodic::get_stats();
|
168 |
if (is_array($state) && isset($state['stats'])) {
|
169 |
|
170 |
if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] )) {
|
171 |
if (isset( $state['stats']['last_remote_snapshot_response'] )) {
|
172 |
+
$resp = $state['stats']['last_remote_snapshot_response'];
|
173 |
if ( isset( $resp['success'] ) && $resp['success']) {
|
174 |
+
$finish_time = $state['stats']['last_remote_snapshot'];
|
175 |
$backupType = 'Live Backup to cloud';
|
176 |
+
$message = 'BackupBuddy ' . $backupType . ' finished';
|
177 |
if (!empty($finish_time)) {
|
178 |
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
|
|
179 |
}
|
180 |
|
181 |
+
}
|
182 |
}
|
183 |
}
|
184 |
|
185 |
}
|
186 |
}
|
187 |
} catch( Exception $e ) {
|
188 |
+
|
189 |
}
|
190 |
}
|
191 |
|
721 |
}
|
722 |
|
723 |
// ok
|
724 |
+
public function syncOthersData( $information, $data = array() ) {
|
725 |
+
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
|
726 |
try {
|
727 |
$information['syncBackupBuddy'] = $this->get_sync_data();
|
728 |
} catch(Exception $e) {
|
729 |
+
|
730 |
}
|
731 |
+
}
|
732 |
return $information;
|
733 |
}
|
734 |
+
|
735 |
+
// ok
|
736 |
public function get_sync_data() {
|
737 |
+
|
738 |
+
try {
|
739 |
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
740 |
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
741 |
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
|
742 |
+
|
743 |
$plugin_path = pb_backupbuddy::plugin_path();
|
744 |
if (file_exists($plugin_path . '/classes/core.php'))
|
745 |
+
require_once( $plugin_path . '/classes/core.php' );
|
746 |
}
|
747 |
|
748 |
+
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' ));
|
749 |
+
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
|
750 |
+
MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) );
|
751 |
+
|
752 |
+
|
753 |
+
|
754 |
$data = array();
|
755 |
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
|
756 |
$data['themes_root'] = backupbuddy_core::get_themes_root();
|
757 |
$data['media_root'] = backupbuddy_core::get_media_root();
|
758 |
$data['additional_tables'] = $this->pb_additional_tables();
|
759 |
$data['abspath'] = ABSPATH;
|
760 |
+
|
761 |
+
$getOverview = backupbuddy_api::getOverview();
|
762 |
+
$data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'] ;
|
763 |
+
|
764 |
+
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
|
765 |
+
$finish_time = $getOverview['lastBackupStats']['finish'] ;
|
766 |
+
$time = $this->localize_time( $finish_time );
|
767 |
+
$data['lastBackupStats'] = date("M j - g:i A", $time);
|
768 |
+
$data['lasttime_backup'] = $finish_time;
|
769 |
+
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature
|
770 |
+
} else {
|
771 |
+
$data['lastBackupStats'] = 'Unknown';
|
772 |
+
}
|
773 |
+
|
774 |
return $data;
|
775 |
} catch(Exception $e) {
|
776 |
+
// not exit here
|
777 |
+
}
|
778 |
+
|
779 |
return false;
|
780 |
}
|
781 |
|
782 |
+
function localize_time( $timestamp ) {
|
783 |
+
if ( function_exists( 'get_option' ) ) {
|
784 |
+
$gmt_offset = get_option( 'gmt_offset' );
|
785 |
+
} else {
|
786 |
+
$gmt_offset = 0;
|
787 |
+
}
|
788 |
+
return $timestamp + ( $gmt_offset * 3600 );
|
789 |
+
}
|
790 |
+
|
791 |
function backup_list() {
|
792 |
require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
|
793 |
$information = array();
|
862 |
// This will identify the backup zip file we want to list
|
863 |
$serial = $_POST[ 'serial' ];
|
864 |
$alerts = array();
|
865 |
+
// The fileoptions file that contains the file tree information
|
866 |
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
|
867 |
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '-filetree.txt';
|
868 |
|
876 |
pb_backupbuddy::status( 'details', 'Fileoptions instance #28.' );
|
877 |
$fileoptions = new pb_backupbuddy_fileoptions( $fileoptions_file );
|
878 |
$zip_viewer = $_POST[ 'zip_viewer' ];
|
879 |
+
// Either we are getting cached file tree information or we need to create afresh
|
880 |
if ( true !== ( $result = $fileoptions->is_ok() ) ) {
|
881 |
// Get file listing.
|
882 |
require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' );
|
1042 |
|
1043 |
// ok
|
1044 |
function pb_additional_tables( $display_size = false ) {
|
1045 |
+
|
1046 |
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
1047 |
+
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
|
1048 |
+
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
|
1049 |
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
|
1050 |
+
|
1051 |
+
|
1052 |
$return = '';
|
1053 |
$size_string = '';
|
1054 |
|
1914 |
function remote_save() {
|
1915 |
$data = isset($_POST['data']) ? $_POST['data'] : false;
|
1916 |
$destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0;
|
1917 |
+
|
1918 |
if (is_array($data) && isset($data['do_not_override'])) {
|
1919 |
+
|
1920 |
if (true == $data['do_not_override']) {
|
1921 |
if (($data['type'] == 's32' || $data['type'] == 's33')) {
|
1922 |
$not_override = array(
|
1927 |
);
|
1928 |
foreach($not_override as $opt) {
|
1929 |
if (isset($data[$opt])) {
|
1930 |
+
unset($data[$opt]);
|
1931 |
+
}
|
1932 |
}
|
1933 |
}
|
1934 |
}
|
1935 |
+
|
1936 |
unset($data['do_not_override']);
|
1937 |
}
|
1938 |
+
|
1939 |
+
|
1940 |
if (is_array($data)) {
|
1941 |
if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update
|
1942 |
pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data );
|
class/class-mainwp-child-back-up-wordpress.php
CHANGED
@@ -10,16 +10,16 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
10 |
|
11 |
return MainWP_Child_Back_Up_Wordpress::$instance;
|
12 |
}
|
13 |
-
|
14 |
public function __construct() {
|
15 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
17 |
-
$this->is_plugin_installed = true;
|
18 |
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
|
19 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
}
|
24 |
|
25 |
public function init() {
|
@@ -100,6 +100,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
100 |
case 'exclude_remove_rule':
|
101 |
$information = $this->hmbkp_remove_exclude_rule();
|
102 |
break;
|
|
|
|
|
|
|
103 |
}
|
104 |
}
|
105 |
MainWP_Helper::write( $information );
|
@@ -124,29 +127,29 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
124 |
}
|
125 |
// ok
|
126 |
public function syncOthersData( $information, $data = array() ) {
|
127 |
-
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
|
128 |
try {
|
129 |
$information['syncBackUpWordPress'] = $this->get_sync_data();
|
130 |
} catch(Exception $e) {
|
131 |
-
|
132 |
}
|
133 |
-
}
|
134 |
return $information;
|
135 |
}
|
136 |
-
|
137 |
// ok
|
138 |
private function get_sync_data() {
|
139 |
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
140 |
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
141 |
-
|
142 |
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
143 |
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
144 |
$backups_time = array();
|
145 |
-
|
146 |
if (is_array($schedules) && count($schedules)) {
|
147 |
$check = current($schedules);
|
148 |
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
|
149 |
-
|
150 |
foreach ( $schedules as $sche ) {
|
151 |
$existing_backup = $sche->get_backups();
|
152 |
if ( ! empty( $existing_backup ) ) {
|
@@ -164,7 +167,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
164 |
|
165 |
return $return;
|
166 |
}
|
167 |
-
|
168 |
function do_site_stats() {
|
169 |
if (has_action('mainwp_child_reports_log')) {
|
170 |
do_action( 'mainwp_child_reports_log', 'backupwordpress');
|
@@ -172,23 +175,23 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
172 |
$this->do_reports_log('backupwordpress');
|
173 |
}
|
174 |
}
|
175 |
-
|
176 |
-
// ok
|
177 |
public function do_reports_log($ext = '') {
|
178 |
if ( $ext !== 'backupwordpress' ) return;
|
179 |
if (!$this->is_plugin_installed) return;
|
180 |
-
|
181 |
try {
|
182 |
-
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
183 |
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ));
|
184 |
-
|
185 |
// Refresh the schedules from the database to make sure we have the latest changes
|
186 |
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
187 |
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
188 |
if (is_array($schedules) && count($schedules) > 0) {
|
189 |
$check = current($schedules);
|
190 |
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
191 |
-
|
192 |
foreach($schedules as $schedule) {
|
193 |
foreach ( $schedule->get_backups() as $file ) {
|
194 |
$backup_type = $schedule->get_type();
|
@@ -206,9 +209,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
206 |
}
|
207 |
} catch(Exception $e) {
|
208 |
|
209 |
-
}
|
210 |
}
|
211 |
-
|
212 |
function set_showhide() {
|
213 |
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
214 |
MainWP_Helper::update_option( 'mainwp_backupwordpress_hide_plugin', $hide );
|
@@ -625,7 +628,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
625 |
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'backupwordpress' ); ?></p>
|
626 |
|
627 |
<?php
|
628 |
-
// The directory to display
|
629 |
$directory = $root_dir;
|
630 |
|
631 |
if ( isset( $browse_dir ) ) {
|
@@ -1047,28 +1050,58 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
1047 |
return $out;
|
1048 |
}
|
1049 |
|
1050 |
-
function remove_exclude_rule() {
|
1051 |
|
1052 |
-
|
1053 |
|
1054 |
-
|
1055 |
-
|
1056 |
-
}
|
1057 |
|
1058 |
-
|
|
|
|
|
|
|
|
|
|
|
1059 |
|
1060 |
-
|
1061 |
-
|
1062 |
|
1063 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1064 |
|
1065 |
-
$schedule->save();
|
1066 |
|
1067 |
-
|
|
|
1068 |
|
1069 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1070 |
|
1071 |
-
}
|
1072 |
|
1073 |
function update_schedule() {
|
1074 |
$sch_id = isset( $_POST['schedule_id'] ) ? $_POST['schedule_id'] : 0;
|
@@ -1105,7 +1138,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
1105 |
}
|
1106 |
|
1107 |
update_option( 'hmbkp_schedule_' . $sch_id, $options );
|
1108 |
-
|
1109 |
$out['result'] = 'SUCCESS';
|
1110 |
} else {
|
1111 |
$out['result'] = 'NOTCHANGE';
|
10 |
|
11 |
return MainWP_Child_Back_Up_Wordpress::$instance;
|
12 |
}
|
13 |
+
|
14 |
public function __construct() {
|
15 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
17 |
+
$this->is_plugin_installed = true;
|
18 |
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
|
19 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
20 |
}
|
21 |
}
|
22 |
+
|
23 |
}
|
24 |
|
25 |
public function init() {
|
100 |
case 'exclude_remove_rule':
|
101 |
$information = $this->hmbkp_remove_exclude_rule();
|
102 |
break;
|
103 |
+
case 'general_exclude_add_rule':
|
104 |
+
$information = $this->general_exclude_add_rule();
|
105 |
+
break;
|
106 |
}
|
107 |
}
|
108 |
MainWP_Helper::write( $information );
|
127 |
}
|
128 |
// ok
|
129 |
public function syncOthersData( $information, $data = array() ) {
|
130 |
+
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
|
131 |
try {
|
132 |
$information['syncBackUpWordPress'] = $this->get_sync_data();
|
133 |
} catch(Exception $e) {
|
134 |
+
|
135 |
}
|
136 |
+
}
|
137 |
return $information;
|
138 |
}
|
139 |
+
|
140 |
// ok
|
141 |
private function get_sync_data() {
|
142 |
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
143 |
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
144 |
+
|
145 |
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
146 |
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
147 |
$backups_time = array();
|
148 |
+
|
149 |
if (is_array($schedules) && count($schedules)) {
|
150 |
$check = current($schedules);
|
151 |
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
|
152 |
+
|
153 |
foreach ( $schedules as $sche ) {
|
154 |
$existing_backup = $sche->get_backups();
|
155 |
if ( ! empty( $existing_backup ) ) {
|
167 |
|
168 |
return $return;
|
169 |
}
|
170 |
+
|
171 |
function do_site_stats() {
|
172 |
if (has_action('mainwp_child_reports_log')) {
|
173 |
do_action( 'mainwp_child_reports_log', 'backupwordpress');
|
175 |
$this->do_reports_log('backupwordpress');
|
176 |
}
|
177 |
}
|
178 |
+
|
179 |
+
// ok
|
180 |
public function do_reports_log($ext = '') {
|
181 |
if ( $ext !== 'backupwordpress' ) return;
|
182 |
if (!$this->is_plugin_installed) return;
|
183 |
+
|
184 |
try {
|
185 |
+
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
186 |
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ));
|
187 |
+
|
188 |
// Refresh the schedules from the database to make sure we have the latest changes
|
189 |
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
190 |
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
191 |
if (is_array($schedules) && count($schedules) > 0) {
|
192 |
$check = current($schedules);
|
193 |
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
194 |
+
|
195 |
foreach($schedules as $schedule) {
|
196 |
foreach ( $schedule->get_backups() as $file ) {
|
197 |
$backup_type = $schedule->get_type();
|
209 |
}
|
210 |
} catch(Exception $e) {
|
211 |
|
212 |
+
}
|
213 |
}
|
214 |
+
|
215 |
function set_showhide() {
|
216 |
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
217 |
MainWP_Helper::update_option( 'mainwp_backupwordpress_hide_plugin', $hide );
|
628 |
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'backupwordpress' ); ?></p>
|
629 |
|
630 |
<?php
|
631 |
+
// The directory to display
|
632 |
$directory = $root_dir;
|
633 |
|
634 |
if ( isset( $browse_dir ) ) {
|
1050 |
return $out;
|
1051 |
}
|
1052 |
|
|
|
1053 |
|
1054 |
+
function general_exclude_add_rule() {
|
1055 |
|
1056 |
+
$sch_id = $this->check_schedule();
|
1057 |
+
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
|
|
1058 |
|
1059 |
+
$exclude_paths = urldecode( $_POST['exclude_paths'] );
|
1060 |
+
$exclude_paths = explode("\n", $exclude_paths);
|
1061 |
+
if (is_array($exclude_paths) && count($exclude_paths) > 0) {
|
1062 |
+
foreach ( $exclude_paths as $excl_rule ) {
|
1063 |
+
$excl_rule = trim($excl_rule);
|
1064 |
+
$excl_rule = trim($excl_rule, '/');
|
1065 |
|
1066 |
+
if (empty($excl_rule))
|
1067 |
+
continue;
|
1068 |
|
1069 |
+
$exclude_rule = ABSPATH . $excl_rule;
|
1070 |
+
$path = realpath($exclude_rule);
|
1071 |
+
// If it exist
|
1072 |
+
if($path !== false)
|
1073 |
+
{
|
1074 |
+
$schedule->set_excludes( $exclude_rule, true );
|
1075 |
+
$schedule->save();
|
1076 |
+
}
|
1077 |
+
}
|
1078 |
+
}
|
1079 |
|
|
|
1080 |
|
1081 |
+
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
|
1082 |
+
$un_exclude_paths = explode("\n", $un_exclude_paths);
|
1083 |
|
1084 |
+
if (is_array($un_exclude_paths) && count(get_user_excludes) > 0) {
|
1085 |
+
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
|
1086 |
+
$exclude_rule_to_remove = trim($exclude_rule_to_remove);
|
1087 |
+
$exclude_rule_to_remove = trim($exclude_rule_to_remove, '/');
|
1088 |
+
|
1089 |
+
if (empty($exclude_rule_to_remove))
|
1090 |
+
continue;
|
1091 |
+
|
1092 |
+
$excludes = $schedule->get_excludes();
|
1093 |
+
if (method_exists($excludes, 'get_user_excludes')) {
|
1094 |
+
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
1095 |
+
} else {
|
1096 |
+
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
1097 |
+
}
|
1098 |
+
$schedule->save();
|
1099 |
+
}
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
return array('result' => 'SUCCESS');
|
1103 |
+
}
|
1104 |
|
|
|
1105 |
|
1106 |
function update_schedule() {
|
1107 |
$sch_id = isset( $_POST['schedule_id'] ) ? $_POST['schedule_id'] : 0;
|
1138 |
}
|
1139 |
|
1140 |
update_option( 'hmbkp_schedule_' . $sch_id, $options );
|
1141 |
+
delete_transient( 'hmbkp_schedules' );
|
1142 |
$out['result'] = 'SUCCESS';
|
1143 |
} else {
|
1144 |
$out['result'] = 'NOTCHANGE';
|
class/class-mainwp-child-back-wp-up.php
CHANGED
@@ -51,20 +51,20 @@ class MainWP_Child_Back_WP_Up {
|
|
51 |
|
52 |
public function __construct() {
|
53 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
54 |
-
|
55 |
-
try {
|
56 |
-
|
57 |
-
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
|
58 |
-
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
|
59 |
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
|
60 |
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
61 |
require_once( $file_path1 );
|
62 |
-
require_once( $file_path2 );
|
63 |
$this->is_backwpup_installed = true;
|
64 |
$this->is_backwpup_pro = true;
|
65 |
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
66 |
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
|
67 |
-
MainWP_Helper::check_files_exists(array( $file_path ));
|
68 |
require_once( $file_path );
|
69 |
$this->is_backwpup_installed = true;
|
70 |
}
|
@@ -72,17 +72,17 @@ class MainWP_Child_Back_WP_Up {
|
|
72 |
if ($this->is_backwpup_installed) {
|
73 |
MainWP_Helper::check_classes_exists('BackWPup');
|
74 |
MainWP_Helper::check_methods('get_instance');
|
75 |
-
BackWPup::get_instance();
|
76 |
-
|
77 |
add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
78 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
79 |
}
|
80 |
} catch ( Exception $e) {
|
81 |
-
// do not exit()
|
82 |
-
$this->is_backwpup_installed = false;
|
83 |
-
}
|
84 |
}
|
85 |
-
|
86 |
public function action() {
|
87 |
if ( ! $this->is_backwpup_installed ) {
|
88 |
MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', $this->plugin_translate ) ) );
|
@@ -221,18 +221,42 @@ class MainWP_Child_Back_WP_Up {
|
|
221 |
if ( $ext !== 'backwpup' ) return;
|
222 |
if (!$this->is_backwpup_installed)
|
223 |
return;
|
224 |
-
|
225 |
-
try {
|
226 |
MainWP_Helper::check_classes_exists(array('BackWPup'));
|
227 |
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
228 |
-
|
|
|
229 |
$destinations = BackWPup::get_registered_destinations();
|
230 |
$jobdests = $this->get_destinations_list();
|
231 |
|
232 |
if ( !empty( $jobdests ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
foreach ($jobdests as $jobdest) {
|
234 |
list( $jobid, $dest ) = explode( '_', $jobdest );
|
235 |
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
$dest_object = BackWPup::get_destination( $dest );
|
237 |
$items = $dest_object->file_get_list( $jobdest );
|
238 |
//if no items brake
|
@@ -240,8 +264,7 @@ class MainWP_Child_Back_WP_Up {
|
|
240 |
foreach ( $items as $ma ) {
|
241 |
if (isset($ma['time'])) {
|
242 |
$backup_time = $ma[ "time" ];
|
243 |
-
$message = 'BackWPup backup finished';
|
244 |
-
$backup_type = 'BackWPup';
|
245 |
$destination = "N/A";
|
246 |
if (!empty($backup_time)) {
|
247 |
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
|
@@ -254,30 +277,30 @@ class MainWP_Child_Back_WP_Up {
|
|
254 |
}
|
255 |
}
|
256 |
} catch (Exception $ex) {
|
257 |
-
|
258 |
}
|
259 |
}
|
260 |
-
|
261 |
// ok
|
262 |
function syncOthersData( $information, $data = array() ) {
|
263 |
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
|
264 |
try{
|
265 |
-
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
|
266 |
$information['syncBackwpupData'] = array(
|
267 |
'lastbackup' => $lastbackup
|
268 |
-
);
|
269 |
} catch(Exception $e) {
|
270 |
-
|
271 |
}
|
272 |
}
|
273 |
return $information;
|
274 |
}
|
275 |
-
|
276 |
function get_destinations_list() {
|
277 |
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
|
278 |
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
279 |
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
|
280 |
-
|
281 |
$jobdest = array();
|
282 |
$jobids = BackWPup_Option::get_job_ids();
|
283 |
$destinations = BackWPup::get_registered_destinations();
|
@@ -290,7 +313,7 @@ class MainWP_Child_Back_WP_Up {
|
|
290 |
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
291 |
continue;
|
292 |
}
|
293 |
-
|
294 |
$dest_class = BackWPup::get_destination( $dest );
|
295 |
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
|
296 |
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
|
@@ -396,9 +419,9 @@ class MainWP_Child_Back_WP_Up {
|
|
396 |
echo '</td></tr>';
|
397 |
|
398 |
echo '<tr><td>' . __( 'Log folder:', 'backwpup' ) . '</td><td>';
|
399 |
-
|
400 |
$log_folder = BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) );
|
401 |
-
|
402 |
if ( ! is_dir( $log_folder ) ) {
|
403 |
echo sprintf( __( 'Logs folder %s not exist.', 'backwpup' ), esc_html( $log_folder ) );
|
404 |
} elseif ( ! is_writable( $log_folder ) ) {
|
@@ -474,7 +497,7 @@ class MainWP_Child_Back_WP_Up {
|
|
474 |
|
475 |
$dir = get_site_option( 'backwpup_cfg_logfolder' );
|
476 |
$dir = BackWPup_File::get_absolute_path( $dir );
|
477 |
-
|
478 |
foreach ( $_POST['settings']['logfile'] as $logfile ) {
|
479 |
$logfile = basename( $logfile );
|
480 |
|
@@ -591,7 +614,7 @@ class MainWP_Child_Back_WP_Up {
|
|
591 |
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
|
592 |
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
|
593 |
$log_folder = untrailingslashit( $log_folder );
|
594 |
-
|
595 |
if ( ! is_dir( $log_folder ) ) {
|
596 |
return array( 'success' => 1, 'response' => $array );
|
597 |
}
|
@@ -619,7 +642,7 @@ class MainWP_Child_Back_WP_Up {
|
|
619 |
if ( is_null($dest_class) ) {
|
620 |
continue;
|
621 |
}
|
622 |
-
$items = $dest_class->file_get_list( $jobid . '_' . $dest );
|
623 |
if ( ! empty( $items ) ) {
|
624 |
foreach ( $items as $item ) {
|
625 |
$temp_single_item = $item;
|
51 |
|
52 |
public function __construct() {
|
53 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
54 |
+
|
55 |
+
try {
|
56 |
+
|
57 |
+
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
|
58 |
+
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
|
59 |
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
|
60 |
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
61 |
require_once( $file_path1 );
|
62 |
+
require_once( $file_path2 );
|
63 |
$this->is_backwpup_installed = true;
|
64 |
$this->is_backwpup_pro = true;
|
65 |
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
66 |
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
|
67 |
+
MainWP_Helper::check_files_exists(array( $file_path ));
|
68 |
require_once( $file_path );
|
69 |
$this->is_backwpup_installed = true;
|
70 |
}
|
72 |
if ($this->is_backwpup_installed) {
|
73 |
MainWP_Helper::check_classes_exists('BackWPup');
|
74 |
MainWP_Helper::check_methods('get_instance');
|
75 |
+
BackWPup::get_instance();
|
76 |
+
|
77 |
add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
78 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
79 |
}
|
80 |
} catch ( Exception $e) {
|
81 |
+
// do not exit()
|
82 |
+
$this->is_backwpup_installed = false;
|
83 |
+
}
|
84 |
}
|
85 |
+
|
86 |
public function action() {
|
87 |
if ( ! $this->is_backwpup_installed ) {
|
88 |
MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', $this->plugin_translate ) ) );
|
221 |
if ( $ext !== 'backwpup' ) return;
|
222 |
if (!$this->is_backwpup_installed)
|
223 |
return;
|
224 |
+
|
225 |
+
try {
|
226 |
MainWP_Helper::check_classes_exists(array('BackWPup'));
|
227 |
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
228 |
+
|
229 |
+
|
230 |
$destinations = BackWPup::get_registered_destinations();
|
231 |
$jobdests = $this->get_destinations_list();
|
232 |
|
233 |
if ( !empty( $jobdests ) ) {
|
234 |
+
$job_types = array(
|
235 |
+
'DBDUMP' => __('Database backup', 'mainwp-child'),
|
236 |
+
'FILE' => __('File backup', 'mainwp-child'),
|
237 |
+
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
|
238 |
+
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
|
239 |
+
'DBCHECK' => __('Check database tables', 'mainwp-child')
|
240 |
+
);
|
241 |
+
|
242 |
foreach ($jobdests as $jobdest) {
|
243 |
list( $jobid, $dest ) = explode( '_', $jobdest );
|
244 |
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
|
245 |
+
|
246 |
+
$job_job_types = BackWPup_Option::get( $jobid, 'type' );
|
247 |
+
|
248 |
+
$backup_type = '';
|
249 |
+
foreach($job_job_types as $typeid) {
|
250 |
+
if (isset( $job_types[$typeid] )) {
|
251 |
+
$backup_type .= ' + ' . $job_types[$typeid];
|
252 |
+
}
|
253 |
+
}
|
254 |
+
if (empty($backup_type))
|
255 |
+
$backup_type = 'BackWPup';
|
256 |
+
else {
|
257 |
+
$backup_type = ltrim($backup_type, ' + ');
|
258 |
+
}
|
259 |
+
|
260 |
$dest_object = BackWPup::get_destination( $dest );
|
261 |
$items = $dest_object->file_get_list( $jobdest );
|
262 |
//if no items brake
|
264 |
foreach ( $items as $ma ) {
|
265 |
if (isset($ma['time'])) {
|
266 |
$backup_time = $ma[ "time" ];
|
267 |
+
$message = 'BackWPup backup finished (' . $backup_type . ')';
|
|
|
268 |
$destination = "N/A";
|
269 |
if (!empty($backup_time)) {
|
270 |
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
|
277 |
}
|
278 |
}
|
279 |
} catch (Exception $ex) {
|
280 |
+
|
281 |
}
|
282 |
}
|
283 |
+
|
284 |
// ok
|
285 |
function syncOthersData( $information, $data = array() ) {
|
286 |
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
|
287 |
try{
|
288 |
+
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
|
289 |
$information['syncBackwpupData'] = array(
|
290 |
'lastbackup' => $lastbackup
|
291 |
+
);
|
292 |
} catch(Exception $e) {
|
293 |
+
|
294 |
}
|
295 |
}
|
296 |
return $information;
|
297 |
}
|
298 |
+
|
299 |
function get_destinations_list() {
|
300 |
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
|
301 |
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
302 |
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
|
303 |
+
|
304 |
$jobdest = array();
|
305 |
$jobids = BackWPup_Option::get_job_ids();
|
306 |
$destinations = BackWPup::get_registered_destinations();
|
313 |
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
314 |
continue;
|
315 |
}
|
316 |
+
|
317 |
$dest_class = BackWPup::get_destination( $dest );
|
318 |
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
|
319 |
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
|
419 |
echo '</td></tr>';
|
420 |
|
421 |
echo '<tr><td>' . __( 'Log folder:', 'backwpup' ) . '</td><td>';
|
422 |
+
|
423 |
$log_folder = BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) );
|
424 |
+
|
425 |
if ( ! is_dir( $log_folder ) ) {
|
426 |
echo sprintf( __( 'Logs folder %s not exist.', 'backwpup' ), esc_html( $log_folder ) );
|
427 |
} elseif ( ! is_writable( $log_folder ) ) {
|
497 |
|
498 |
$dir = get_site_option( 'backwpup_cfg_logfolder' );
|
499 |
$dir = BackWPup_File::get_absolute_path( $dir );
|
500 |
+
|
501 |
foreach ( $_POST['settings']['logfile'] as $logfile ) {
|
502 |
$logfile = basename( $logfile );
|
503 |
|
614 |
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
|
615 |
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
|
616 |
$log_folder = untrailingslashit( $log_folder );
|
617 |
+
|
618 |
if ( ! is_dir( $log_folder ) ) {
|
619 |
return array( 'success' => 1, 'response' => $array );
|
620 |
}
|
642 |
if ( is_null($dest_class) ) {
|
643 |
continue;
|
644 |
}
|
645 |
+
$items = $dest_class->file_get_list( $jobid . '_' . $dest );
|
646 |
if ( ! empty( $items ) ) {
|
647 |
foreach ( $items as $item ) {
|
648 |
$temp_single_item = $item;
|
class/class-mainwp-child-branding.php
CHANGED
@@ -238,13 +238,13 @@ class MainWP_Child_Branding {
|
|
238 |
}
|
239 |
|
240 |
static function uploadImage( $img_url ) {
|
241 |
-
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
242 |
global $mainWPChild;
|
243 |
-
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
244 |
//Download $img_url
|
245 |
-
$temporary_file = download_url( $img_url );
|
246 |
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
247 |
-
|
248 |
if ( is_wp_error( $temporary_file ) ) {
|
249 |
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
250 |
} else {
|
@@ -286,12 +286,12 @@ class MainWP_Child_Branding {
|
|
286 |
}
|
287 |
|
288 |
add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
|
289 |
-
|
290 |
if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
291 |
-
|
292 |
-
// Disable the wordpress plugin update notifications
|
293 |
remove_action('load-update-core.php', 'wp_update_plugins');
|
294 |
-
add_filter('pre_site_transient_update_plugins', '__return_null');
|
295 |
|
296 |
// Disable the wordpress theme update notifications
|
297 |
remove_action('load-update-core.php', 'wp_update_themes');
|
@@ -299,40 +299,22 @@ class MainWP_Child_Branding {
|
|
299 |
|
300 |
// Disable the wordpress core update notifications
|
301 |
add_action('after_setup_theme', 'remove_core_updates');
|
302 |
-
function remove_core_updates() {
|
303 |
add_action('init', ( $func = function($a){ remove_action( 'wp_version_check', 'wp_version_check' );} ), 2);
|
304 |
add_filter('pre_option_update_core', '__return_null');
|
305 |
add_filter('pre_site_transient_update_core', '__return_null');
|
306 |
}
|
307 |
-
|
308 |
-
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
|
309 |
add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
|
310 |
}
|
311 |
|
312 |
// to fix
|
313 |
-
add_action( 'admin_menu', array( &$this, 'admin_menu' ) )
|
314 |
-
// if ( 'T' === get_option( 'mainwp_branding_show_support' ) ) {
|
315 |
-
// $title = $this->settings['contact_support_label'];
|
316 |
-
// if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
|
317 |
-
// $title = $this->settings['contact_support_label'];
|
318 |
-
// add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
|
319 |
-
// $this,
|
320 |
-
// 'contact_support',
|
321 |
-
// ), '', '2.0001' );
|
322 |
-
// }
|
323 |
-
//
|
324 |
-
// if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
|
325 |
-
// add_submenu_page( null, $title, $this->settings['contact_support_label'], 'read', 'ContactSupport', array(
|
326 |
-
// $this,
|
327 |
-
// 'contact_support',
|
328 |
-
// ) );
|
329 |
-
// add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
|
330 |
-
// }
|
331 |
-
// }
|
332 |
if ( get_option( 'mainwp_branding_disable_wp_branding' ) !== 'Y' ) {
|
333 |
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
|
334 |
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
|
335 |
-
// branding site generator
|
336 |
$types = array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export' );
|
337 |
foreach ( $types as $type ) {
|
338 |
add_filter( 'get_the_generator_' . $type, array( &$this, 'custom_the_generator' ), 999, 2 );
|
@@ -341,17 +323,17 @@ class MainWP_Child_Branding {
|
|
341 |
add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) );
|
342 |
add_filter( 'gettext', array( &$this, 'custom_gettext' ), 99, 3 );
|
343 |
add_action( 'login_head', array( &$this, 'custom_login_logo' ) );
|
344 |
-
add_filter( 'login_headerurl', array( &$this, 'custom_login_headerurl' ) );
|
345 |
-
add_filter( 'login_headertitle', array( &$this, 'custom_login_headertitle' ) );
|
346 |
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
347 |
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
348 |
//remove_filter( 'update_footer', 'core_update_footer' );
|
349 |
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
|
350 |
-
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
|
351 |
}
|
352 |
|
353 |
-
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
|
354 |
-
add_action( 'admin_init', array($this, 'admin_init'));
|
355 |
}
|
356 |
|
357 |
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
|
@@ -359,14 +341,17 @@ class MainWP_Child_Branding {
|
|
359 |
}
|
360 |
}
|
361 |
|
362 |
-
|
363 |
public function admin_init() {
|
364 |
-
remove_action( 'admin_notices', 'update_nag', 3 );
|
365 |
}
|
366 |
-
|
367 |
// to fix conflict with other plugin
|
368 |
function admin_menu() {
|
369 |
-
|
|
|
|
|
|
|
370 |
return false;
|
371 |
}
|
372 |
$extra_setting = $this->settings['extra_settings'];
|
@@ -522,27 +507,27 @@ class MainWP_Child_Branding {
|
|
522 |
if ( false !== $pos1 || false !== $pos2 ) {
|
523 |
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
524 |
exit();
|
525 |
-
}
|
526 |
}
|
527 |
-
|
528 |
function admin_head_hide_elements() {
|
529 |
-
?><script type="text/javascript">
|
530 |
-
document.addEventListener("DOMContentLoaded", function(event) {
|
531 |
document.getElementById("wp-admin-bar-updates").outerHTML = '';
|
532 |
document.getElementById("menu-plugins").outerHTML = '';
|
533 |
var els_core = document.querySelectorAll("a[href='update-core.php']");
|
534 |
for (var i = 0, l = els_core.length; i < l; i++) {
|
535 |
-
var el = els_core[i];
|
536 |
el.parentElement.innerHTML = '';
|
537 |
}
|
538 |
});
|
539 |
-
</script><?php
|
540 |
}
|
541 |
-
|
542 |
function core_update_footer() {
|
543 |
-
echo ''; // it clear version text
|
544 |
}
|
545 |
-
|
546 |
function admin_footer_text() {
|
547 |
$extra_setting = $this->settings['extra_settings'];
|
548 |
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
@@ -569,25 +554,25 @@ class MainWP_Child_Branding {
|
|
569 |
}
|
570 |
|
571 |
function custom_login_headerurl( $value ) {
|
572 |
-
|
573 |
$extra_setting = $this->settings['extra_settings'];
|
574 |
if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
|
575 |
return $extra_setting['login_image_link'];
|
576 |
}
|
577 |
-
|
578 |
return $value;
|
579 |
}
|
580 |
-
|
581 |
function custom_login_headertitle( $value ) {
|
582 |
-
|
583 |
$extra_setting = $this->settings['extra_settings'];
|
584 |
if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
|
585 |
return $extra_setting['login_image_title'];
|
586 |
}
|
587 |
-
|
588 |
return $value;
|
589 |
-
}
|
590 |
-
|
591 |
function custom_gettext( $translations, $text, $domain = 'default' ) {
|
592 |
$extra_setting = $this->settings['extra_settings'];
|
593 |
$texts_replace = $extra_setting['texts_replace'];
|
@@ -725,9 +710,6 @@ class MainWP_Child_Branding {
|
|
725 |
}
|
726 |
|
727 |
function contact_support() {
|
728 |
-
if ( !current_user_can('administrator') ) {
|
729 |
-
return false;
|
730 |
-
}
|
731 |
?>
|
732 |
<style>
|
733 |
.mainwp_info-box-yellow {
|
@@ -756,10 +738,10 @@ class MainWP_Child_Branding {
|
|
756 |
if ( ! empty( $send_email_message ) ) {
|
757 |
$send_email_message = stripslashes( $send_email_message );
|
758 |
} else {
|
759 |
-
$send_email_message = 'Message has been submitted successfully.';
|
760 |
}
|
761 |
} else {
|
762 |
-
$send_email_message = __( 'Sending email failed!' );
|
763 |
}
|
764 |
?>
|
765 |
<div
|
@@ -875,7 +857,7 @@ class MainWP_Child_Branding {
|
|
875 |
}
|
876 |
|
877 |
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
878 |
-
|
879 |
// this is causing of some plugin's menu not added
|
880 |
// if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
881 |
// // disable: edit, update, install, active themes and plugins
|
238 |
}
|
239 |
|
240 |
static function uploadImage( $img_url ) {
|
241 |
+
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
242 |
global $mainWPChild;
|
243 |
+
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
244 |
//Download $img_url
|
245 |
+
$temporary_file = download_url( $img_url );
|
246 |
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
247 |
+
|
248 |
if ( is_wp_error( $temporary_file ) ) {
|
249 |
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
250 |
} else {
|
286 |
}
|
287 |
|
288 |
add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
|
289 |
+
|
290 |
if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
291 |
+
|
292 |
+
// Disable the wordpress plugin update notifications
|
293 |
remove_action('load-update-core.php', 'wp_update_plugins');
|
294 |
+
add_filter('pre_site_transient_update_plugins', '__return_null');
|
295 |
|
296 |
// Disable the wordpress theme update notifications
|
297 |
remove_action('load-update-core.php', 'wp_update_themes');
|
299 |
|
300 |
// Disable the wordpress core update notifications
|
301 |
add_action('after_setup_theme', 'remove_core_updates');
|
302 |
+
function remove_core_updates() {
|
303 |
add_action('init', ( $func = function($a){ remove_action( 'wp_version_check', 'wp_version_check' );} ), 2);
|
304 |
add_filter('pre_option_update_core', '__return_null');
|
305 |
add_filter('pre_site_transient_update_core', '__return_null');
|
306 |
}
|
307 |
+
|
308 |
+
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
|
309 |
add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
|
310 |
}
|
311 |
|
312 |
// to fix
|
313 |
+
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
if ( get_option( 'mainwp_branding_disable_wp_branding' ) !== 'Y' ) {
|
315 |
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
|
316 |
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
|
317 |
+
// branding site generator
|
318 |
$types = array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export' );
|
319 |
foreach ( $types as $type ) {
|
320 |
add_filter( 'get_the_generator_' . $type, array( &$this, 'custom_the_generator' ), 999, 2 );
|
323 |
add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) );
|
324 |
add_filter( 'gettext', array( &$this, 'custom_gettext' ), 99, 3 );
|
325 |
add_action( 'login_head', array( &$this, 'custom_login_logo' ) );
|
326 |
+
add_filter( 'login_headerurl', array( &$this, 'custom_login_headerurl' ) );
|
327 |
+
add_filter( 'login_headertitle', array( &$this, 'custom_login_headertitle' ) );
|
328 |
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
329 |
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
330 |
//remove_filter( 'update_footer', 'core_update_footer' );
|
331 |
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
|
332 |
+
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
|
333 |
}
|
334 |
|
335 |
+
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
|
336 |
+
add_action( 'admin_init', array($this, 'admin_init'));
|
337 |
}
|
338 |
|
339 |
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
|
341 |
}
|
342 |
}
|
343 |
|
344 |
+
|
345 |
public function admin_init() {
|
346 |
+
remove_action( 'admin_notices', 'update_nag', 3 );
|
347 |
}
|
348 |
+
|
349 |
// to fix conflict with other plugin
|
350 |
function admin_menu() {
|
351 |
+
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
|
352 |
+
if ( $allow_contact ) {
|
353 |
+
; // ok
|
354 |
+
} else if ( !current_user_can( 'administrator' ) ) {
|
355 |
return false;
|
356 |
}
|
357 |
$extra_setting = $this->settings['extra_settings'];
|
507 |
if ( false !== $pos1 || false !== $pos2 ) {
|
508 |
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
509 |
exit();
|
510 |
+
}
|
511 |
}
|
512 |
+
|
513 |
function admin_head_hide_elements() {
|
514 |
+
?><script type="text/javascript">
|
515 |
+
document.addEventListener("DOMContentLoaded", function(event) {
|
516 |
document.getElementById("wp-admin-bar-updates").outerHTML = '';
|
517 |
document.getElementById("menu-plugins").outerHTML = '';
|
518 |
var els_core = document.querySelectorAll("a[href='update-core.php']");
|
519 |
for (var i = 0, l = els_core.length; i < l; i++) {
|
520 |
+
var el = els_core[i];
|
521 |
el.parentElement.innerHTML = '';
|
522 |
}
|
523 |
});
|
524 |
+
</script><?php
|
525 |
}
|
526 |
+
|
527 |
function core_update_footer() {
|
528 |
+
echo ''; // it clear version text
|
529 |
}
|
530 |
+
|
531 |
function admin_footer_text() {
|
532 |
$extra_setting = $this->settings['extra_settings'];
|
533 |
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
554 |
}
|
555 |
|
556 |
function custom_login_headerurl( $value ) {
|
557 |
+
|
558 |
$extra_setting = $this->settings['extra_settings'];
|
559 |
if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
|
560 |
return $extra_setting['login_image_link'];
|
561 |
}
|
562 |
+
|
563 |
return $value;
|
564 |
}
|
565 |
+
|
566 |
function custom_login_headertitle( $value ) {
|
567 |
+
|
568 |
$extra_setting = $this->settings['extra_settings'];
|
569 |
if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
|
570 |
return $extra_setting['login_image_title'];
|
571 |
}
|
572 |
+
|
573 |
return $value;
|
574 |
+
}
|
575 |
+
|
576 |
function custom_gettext( $translations, $text, $domain = 'default' ) {
|
577 |
$extra_setting = $this->settings['extra_settings'];
|
578 |
$texts_replace = $extra_setting['texts_replace'];
|
710 |
}
|
711 |
|
712 |
function contact_support() {
|
|
|
|
|
|
|
713 |
?>
|
714 |
<style>
|
715 |
.mainwp_info-box-yellow {
|
738 |
if ( ! empty( $send_email_message ) ) {
|
739 |
$send_email_message = stripslashes( $send_email_message );
|
740 |
} else {
|
741 |
+
$send_email_message = __( 'Message has been submitted successfully.', 'mainwp-child' );
|
742 |
}
|
743 |
} else {
|
744 |
+
$send_email_message = __( 'Sending email failed!', 'mainwp-child' );
|
745 |
}
|
746 |
?>
|
747 |
<div
|
857 |
}
|
858 |
|
859 |
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
860 |
+
|
861 |
// this is causing of some plugin's menu not added
|
862 |
// if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
|
863 |
// // disable: edit, update, install, active themes and plugins
|
class/class-mainwp-child-plugins-check.php
CHANGED
@@ -257,16 +257,8 @@ class MainWP_Child_Plugins_Check {
|
|
257 |
}
|
258 |
}
|
259 |
|
260 |
-
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
261 |
-
define( 'MINUTE_IN_SECONDS', 60 );
|
262 |
-
}
|
263 |
-
|
264 |
-
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
265 |
-
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
266 |
-
}
|
267 |
-
|
268 |
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
269 |
-
define( 'DAY_IN_SECONDS', 24 *
|
270 |
}
|
271 |
|
272 |
//Store the master response for usage in the plugin table
|
@@ -274,7 +266,6 @@ class MainWP_Child_Plugins_Check {
|
|
274 |
|
275 |
if ( 0 === count( $all_plugins ) ) {
|
276 |
delete_transient( $this->tran_name_plugins_to_batch );
|
277 |
-
//wp_schedule_single_event( time() + DAY_IN_SECONDS, $this->cron_name_daily );
|
278 |
} else {
|
279 |
set_transient( $this->tran_name_plugins_to_batch, $all_plugins, DAY_IN_SECONDS );
|
280 |
wp_schedule_single_event( time(), $this->cron_name_batching );
|
@@ -287,18 +278,11 @@ class MainWP_Child_Plugins_Check {
|
|
287 |
//Get the WordPress current version to be polite in the API call
|
288 |
include( ABSPATH . WPINC . '/version.php' );
|
289 |
|
290 |
-
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
291 |
-
define( 'MINUTE_IN_SECONDS', 60 );
|
292 |
-
}
|
293 |
-
|
294 |
-
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
295 |
-
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
296 |
-
}
|
297 |
global $wp_version;
|
298 |
|
299 |
//General options to be passed to wp_remote_get
|
300 |
$options = array(
|
301 |
-
'timeout' => HOUR_IN_SECONDS
|
302 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
303 |
);
|
304 |
|
257 |
}
|
258 |
}
|
259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
261 |
+
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
262 |
}
|
263 |
|
264 |
//Store the master response for usage in the plugin table
|
266 |
|
267 |
if ( 0 === count( $all_plugins ) ) {
|
268 |
delete_transient( $this->tran_name_plugins_to_batch );
|
|
|
269 |
} else {
|
270 |
set_transient( $this->tran_name_plugins_to_batch, $all_plugins, DAY_IN_SECONDS );
|
271 |
wp_schedule_single_event( time(), $this->cron_name_batching );
|
278 |
//Get the WordPress current version to be polite in the API call
|
279 |
include( ABSPATH . WPINC . '/version.php' );
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
global $wp_version;
|
282 |
|
283 |
//General options to be passed to wp_remote_get
|
284 |
$options = array(
|
285 |
+
'timeout' => 60 * 60, //HOUR_IN_SECONDS
|
286 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
287 |
);
|
288 |
|
class/class-mainwp-child-themes-check.php
CHANGED
@@ -202,16 +202,8 @@ class MainWP_Child_Themes_Check {
|
|
202 |
}
|
203 |
}
|
204 |
|
205 |
-
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
206 |
-
define( 'MINUTE_IN_SECONDS', 60 );
|
207 |
-
}
|
208 |
-
|
209 |
-
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
210 |
-
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
211 |
-
}
|
212 |
-
|
213 |
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
214 |
-
define( 'DAY_IN_SECONDS', 24 *
|
215 |
}
|
216 |
|
217 |
//Store the master response for usage in the plugin table
|
@@ -219,7 +211,6 @@ class MainWP_Child_Themes_Check {
|
|
219 |
|
220 |
if ( 0 === count( $all_themes ) ) {
|
221 |
delete_transient( $this->tran_name_themes_to_batch );
|
222 |
-
//wp_schedule_single_event( time() + DAY_IN_SECONDS, $this->cron_name_daily );
|
223 |
} else {
|
224 |
set_transient( $this->tran_name_themes_to_batch, $all_themes, DAY_IN_SECONDS );
|
225 |
wp_schedule_single_event( time(), $this->cron_name_batching );
|
@@ -229,19 +220,9 @@ class MainWP_Child_Themes_Check {
|
|
229 |
|
230 |
|
231 |
private function try_get_response_body( $theme ) {
|
232 |
-
//Some of this code is lifted from class-wp-upgrader
|
233 |
-
|
234 |
//Get the WordPress current version to be polite in the API call
|
235 |
include( ABSPATH . WPINC . '/version.php' );
|
236 |
|
237 |
-
if ( ! defined( 'MINUTE_IN_SECONDS' ) ) {
|
238 |
-
define( 'MINUTE_IN_SECONDS', 60 );
|
239 |
-
}
|
240 |
-
|
241 |
-
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
242 |
-
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
|
243 |
-
}
|
244 |
-
|
245 |
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
|
246 |
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
247 |
$url = set_url_scheme( $url, 'https' );
|
202 |
}
|
203 |
}
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
206 |
+
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
207 |
}
|
208 |
|
209 |
//Store the master response for usage in the plugin table
|
211 |
|
212 |
if ( 0 === count( $all_themes ) ) {
|
213 |
delete_transient( $this->tran_name_themes_to_batch );
|
|
|
214 |
} else {
|
215 |
set_transient( $this->tran_name_themes_to_batch, $all_themes, DAY_IN_SECONDS );
|
216 |
wp_schedule_single_event( time(), $this->cron_name_batching );
|
220 |
|
221 |
|
222 |
private function try_get_response_body( $theme ) {
|
|
|
|
|
223 |
//Get the WordPress current version to be polite in the API call
|
224 |
include( ABSPATH . WPINC . '/version.php' );
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
|
227 |
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
228 |
$url = set_url_scheme( $url, 'https' );
|
class/class-mainwp-child-timecapsule.php
CHANGED
@@ -33,7 +33,6 @@ class MainWP_Child_Timecapsule {
|
|
33 |
return;
|
34 |
|
35 |
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
36 |
-
add_action( 'record_auto_backup_complete', array( $this, 'do_report_backups_logging' ) );
|
37 |
|
38 |
if ( get_option( 'mainwp_time_capsule_hide_plugin' ) === 'hide' ) {
|
39 |
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
@@ -253,13 +252,25 @@ class MainWP_Child_Timecapsule {
|
|
253 |
MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in'));
|
254 |
MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info'));
|
255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
$return = array(
|
257 |
'main_account_email' => $main_account_email_var,
|
258 |
'signed_in_repos' => $wptc_settings->get_connected_cloud_info(),
|
259 |
'plan_name' => $options_helper->get_plan_interval_from_subs_info(),
|
260 |
'plan_interval' => $options_helper->get_plan_interval_from_subs_info(),
|
261 |
'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0,
|
262 |
-
'is_user_logged_in' => $options_helper->get_is_user_logged_in()
|
|
|
263 |
);
|
264 |
return $return;
|
265 |
} catch ( Exception $e) {
|
@@ -268,6 +279,21 @@ class MainWP_Child_Timecapsule {
|
|
268 |
return false;
|
269 |
}
|
270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
public function get_tables() {
|
272 |
$category = $_POST['category'];
|
273 |
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
@@ -653,13 +679,6 @@ function get_sibling_files_callback_wptc() {
|
|
653 |
die();
|
654 |
}
|
655 |
|
656 |
-
function do_report_backups_logging($backup_id) {
|
657 |
-
$backup_time = time(); // may be difference a bit with WTC logging
|
658 |
-
$message = 'WP Time Capsule backup finished';
|
659 |
-
$backup_type = 'WP Time Capsule';
|
660 |
-
do_action( 'mainwp_wptimecapsule_backup', $message, $backup_type, $backup_time );
|
661 |
-
}
|
662 |
-
|
663 |
function do_site_stats() {
|
664 |
if (has_action('mainwp_child_reports_log')) {
|
665 |
do_action( 'mainwp_child_reports_log', 'wptimecapsule');
|
@@ -670,20 +689,45 @@ function get_sibling_files_callback_wptc() {
|
|
670 |
|
671 |
// ok
|
672 |
public function do_reports_log($ext = '') {
|
|
|
673 |
if ( $ext !== 'wptimecapsule' ) return;
|
|
|
674 |
if (!$this->is_plugin_installed)
|
675 |
return;
|
|
|
676 |
try {
|
677 |
-
MainWP_Helper::check_classes_exists(array( '
|
678 |
|
679 |
-
$config =
|
680 |
|
681 |
MainWP_Helper::check_methods($config, 'get_option');
|
682 |
|
683 |
$backup_time = $config->get_option('last_backup_time');
|
|
|
684 |
if (!empty($backup_time)) {
|
685 |
MainWP_Helper::update_lasttime_backup( 'wptimecapsule', $backup_time ); // to support backup before update feature
|
686 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
} catch(Exception $e) {
|
688 |
|
689 |
}
|
@@ -1179,32 +1223,6 @@ function get_sibling_files_callback_wptc() {
|
|
1179 |
die();
|
1180 |
}
|
1181 |
|
1182 |
-
function send_response_wptc($status = null, $type = null, $data = null, $is_log =0) {
|
1183 |
-
if (!is_wptc_server_req() && !is_wptc_node_server_req()) {
|
1184 |
-
return false;
|
1185 |
-
}
|
1186 |
-
$config = WPTC_Factory::get('config');
|
1187 |
-
|
1188 |
-
if (empty($is_log)) {
|
1189 |
-
$post_arr['status'] = $status;
|
1190 |
-
$post_arr['type'] = $type;
|
1191 |
-
$post_arr['version'] = WPTC_VERSION;
|
1192 |
-
$post_arr['source'] = 'WPTC';
|
1193 |
-
$post_arr['scheduled_time'] = $config->get_option('schedule_time_str');
|
1194 |
-
$post_arr['timezone'] = $config->get_option('wptc_timezone');
|
1195 |
-
$post_arr['last_backup_time'] = $config->get_option('last_backup_time');
|
1196 |
-
if (!empty($data)) {
|
1197 |
-
$post_arr['progress'] = $data;
|
1198 |
-
}
|
1199 |
-
} else {
|
1200 |
-
$post_arr = $data;
|
1201 |
-
}
|
1202 |
-
|
1203 |
-
|
1204 |
-
return array( 'result' => 'success', 'data' => "<WPTC_START>".json_encode($post_arr)."<WPTC_END>" );
|
1205 |
-
}
|
1206 |
-
|
1207 |
-
|
1208 |
public function all_plugins( $plugins ) {
|
1209 |
foreach ( $plugins as $key => $value ) {
|
1210 |
$plugin_slug = basename( $key, '.php' );
|
33 |
return;
|
34 |
|
35 |
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
|
|
36 |
|
37 |
if ( get_option( 'mainwp_time_capsule_hide_plugin' ) === 'hide' ) {
|
38 |
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
252 |
MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in'));
|
253 |
MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info'));
|
254 |
|
255 |
+
$all_backups = $this->getBackups();
|
256 |
+
$backups_count = 0;
|
257 |
+
if (is_array($all_backups)) {
|
258 |
+
$formatted_backups = array();
|
259 |
+
foreach ($all_backups as $key => $value) {
|
260 |
+
$value_array = (array) $value;
|
261 |
+
$formatted_backups[$value_array['backupID']][] = $value_array;
|
262 |
+
}
|
263 |
+
$backups_count = count($formatted_backups);
|
264 |
+
}
|
265 |
+
|
266 |
$return = array(
|
267 |
'main_account_email' => $main_account_email_var,
|
268 |
'signed_in_repos' => $wptc_settings->get_connected_cloud_info(),
|
269 |
'plan_name' => $options_helper->get_plan_interval_from_subs_info(),
|
270 |
'plan_interval' => $options_helper->get_plan_interval_from_subs_info(),
|
271 |
'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0,
|
272 |
+
'is_user_logged_in' => $options_helper->get_is_user_logged_in(),
|
273 |
+
'backups_count' => $backups_count
|
274 |
);
|
275 |
return $return;
|
276 |
} catch ( Exception $e) {
|
279 |
return false;
|
280 |
}
|
281 |
|
282 |
+
protected function getBackups( $last_time = false ) {
|
283 |
+
if (empty($last_time)) {
|
284 |
+
$last_time = strtotime(date('Y-m-d', strtotime(date('Y-m-01'))));
|
285 |
+
}
|
286 |
+
global $wpdb;
|
287 |
+
$all_backups = $wpdb->get_results(
|
288 |
+
$wpdb->prepare("
|
289 |
+
SELECT *
|
290 |
+
FROM {$wpdb->base_prefix}wptc_processed_files
|
291 |
+
WHERE backupID > %s ", $last_time)
|
292 |
+
);
|
293 |
+
|
294 |
+
return $all_backups;
|
295 |
+
}
|
296 |
+
|
297 |
public function get_tables() {
|
298 |
$category = $_POST['category'];
|
299 |
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
679 |
die();
|
680 |
}
|
681 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
682 |
function do_site_stats() {
|
683 |
if (has_action('mainwp_child_reports_log')) {
|
684 |
do_action( 'mainwp_child_reports_log', 'wptimecapsule');
|
689 |
|
690 |
// ok
|
691 |
public function do_reports_log($ext = '') {
|
692 |
+
|
693 |
if ( $ext !== 'wptimecapsule' ) return;
|
694 |
+
|
695 |
if (!$this->is_plugin_installed)
|
696 |
return;
|
697 |
+
|
698 |
try {
|
699 |
+
MainWP_Helper::check_classes_exists(array( 'WPTC_Factory'));
|
700 |
|
701 |
+
$config = WPTC_Factory::get('config');
|
702 |
|
703 |
MainWP_Helper::check_methods($config, 'get_option');
|
704 |
|
705 |
$backup_time = $config->get_option('last_backup_time');
|
706 |
+
|
707 |
if (!empty($backup_time)) {
|
708 |
MainWP_Helper::update_lasttime_backup( 'wptimecapsule', $backup_time ); // to support backup before update feature
|
709 |
}
|
710 |
+
|
711 |
+
$last_time = time() - 24 * 7 * 2 * 60 * 60; // 2 weeks ago
|
712 |
+
$all_last_backups = $this->getBackups( $last_time );
|
713 |
+
|
714 |
+
if (is_array($all_last_backups)) {
|
715 |
+
$formatted_backups = array();
|
716 |
+
foreach ($all_last_backups as $key => $value) {
|
717 |
+
$value_array = (array) $value;
|
718 |
+
$formatted_backups[$value_array['backupID']][] = $value_array;
|
719 |
+
}
|
720 |
+
$message = 'WP Time Capsule backup finished';
|
721 |
+
$backup_type = 'WP Time Capsule backup';
|
722 |
+
if (count($formatted_backups) > 0) {
|
723 |
+
foreach($formatted_backups as $key => $value) {
|
724 |
+
$backup_time = $key;
|
725 |
+
do_action( 'mainwp_wptimecapsule_backup', $message, $backup_type, $backup_time );
|
726 |
+
}
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
|
731 |
} catch(Exception $e) {
|
732 |
|
733 |
}
|
1223 |
die();
|
1224 |
}
|
1225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1226 |
public function all_plugins( $plugins ) {
|
1227 |
foreach ( $plugins as $key => $value ) {
|
1228 |
$plugin_slug = basename( $key, '.php' );
|
class/class-mainwp-child-updraft-plus-backups.php
CHANGED
@@ -11,15 +11,15 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
11 |
return MainWP_Child_Updraft_Plus_Backups::$instance;
|
12 |
}
|
13 |
|
14 |
-
public function __construct() {
|
15 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) {
|
17 |
-
$this->is_plugin_installed = true;
|
18 |
-
}
|
19 |
-
|
20 |
if (!$this->is_plugin_installed)
|
21 |
-
return;
|
22 |
-
|
23 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
24 |
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
|
25 |
}
|
@@ -30,7 +30,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
30 |
|
31 |
if (isset($last_backup['backup_time'])) {
|
32 |
$backup_time = $last_backup['backup_time'];
|
33 |
-
|
|
|
|
|
34 |
}
|
35 |
return $last_backup;
|
36 |
}
|
@@ -48,9 +50,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
48 |
}
|
49 |
}
|
50 |
} catch(Exception $e) {
|
51 |
-
|
52 |
}
|
53 |
-
|
54 |
return $information;
|
55 |
}
|
56 |
|
@@ -62,7 +64,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
62 |
}
|
63 |
|
64 |
$this->required_files();
|
65 |
-
|
66 |
global $updraftplus;
|
67 |
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
|
68 |
$updraftplus = new UpdraftPlus();
|
@@ -71,13 +73,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
71 |
$information['error'] = 'Error empty updraftplus';
|
72 |
MainWP_Helper::write( $information );
|
73 |
}
|
74 |
-
|
75 |
if ( isset( $_POST['mwp_action'] ) ) {
|
76 |
|
77 |
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
|
78 |
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
|
79 |
}
|
80 |
-
|
81 |
try {
|
82 |
switch ( $_POST['mwp_action'] ) {
|
83 |
case 'set_showhide':
|
@@ -249,7 +251,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
249 |
private function connected_html() {
|
250 |
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
251 |
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
252 |
-
|
253 |
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
254 |
if ( !is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
|
255 |
return '';
|
@@ -382,13 +384,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
382 |
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
|
383 |
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
|
384 |
}
|
385 |
-
|
386 |
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
|
387 |
require_once( UPDRAFTPLUS_DIR . '/options.php' );
|
388 |
}
|
389 |
}
|
390 |
}
|
391 |
-
|
392 |
function save_settings() {
|
393 |
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
394 |
|
@@ -539,8 +541,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
539 |
if(is_array($opts) && isset($opts['settings'])) {
|
540 |
$settings_key = key($opts['settings']);
|
541 |
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
|
|
542 |
} else {
|
543 |
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
|
|
544 |
}
|
545 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
546 |
} else if ( 'updraft_ftp' === $key ) {
|
@@ -595,15 +599,15 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
595 |
}
|
596 |
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
|
597 |
} else if ( 'updraft_backblaze' === $key ) {
|
598 |
-
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
|
599 |
if (!is_array($opts))
|
600 |
$opts = array();
|
601 |
if (is_array($opts) && isset($opts['settings'])) {
|
602 |
-
$settings_key = key($opts['settings']);
|
603 |
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
|
604 |
$opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
|
605 |
$opts['settings'][$settings_key]['bucket_name'] = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
|
606 |
-
$opts['settings'][$settings_key]['backup_path'] = $this->replace_tokens( $settings[ $key ]['backup_path'] );
|
607 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
608 |
}
|
609 |
} else {
|
@@ -612,13 +616,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
612 |
$updated = true;
|
613 |
}
|
614 |
}
|
615 |
-
|
616 |
-
|
617 |
if (!isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) {
|
618 |
-
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
|
619 |
}
|
620 |
-
|
621 |
-
|
622 |
global $updraftplus;
|
623 |
if ( isset( $settings['updraft_interval'] ) ) {
|
624 |
// fix for premium version
|
@@ -666,7 +670,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
666 |
|
667 |
function addons_connect() {
|
668 |
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
|
669 |
-
|
|
|
|
|
|
|
670 |
}
|
671 |
|
672 |
$addons_options = maybe_unserialize( base64_decode( $_POST['addons_options'] ) );
|
@@ -742,8 +749,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
742 |
$ehash = substr( md5( $input['email'] ), 0, 23 );
|
743 |
delete_site_transient( 'udaddons_connect_' . $ehash );
|
744 |
|
745 |
-
// add_settings_error( UDADDONS2_SLUG."_options", UDADDONS2_SLUG."_options_nodb", "Whinge, whinge", "error" );
|
746 |
-
|
747 |
return $input;
|
748 |
}
|
749 |
|
@@ -829,7 +834,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
829 |
$ret_info = '';
|
830 |
if ( ! $failed ) {
|
831 |
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N );
|
832 |
-
|
|
|
|
|
833 |
if ( empty( $_POST['prefix'] ) ) {
|
834 |
$ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) );
|
835 |
} else {
|
@@ -869,6 +876,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
869 |
return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after );
|
870 |
}
|
871 |
|
|
|
|
|
|
|
872 |
|
873 |
function backup_now() {
|
874 |
global $updraftplus;
|
@@ -1024,7 +1034,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1024 |
if ( empty( $updraftplus ) ) {
|
1025 |
return false;
|
1026 |
}
|
1027 |
-
|
1028 |
// UNIX timestamp
|
1029 |
$next_scheduled_backup = wp_next_scheduled( 'updraft_backup' );
|
1030 |
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
@@ -1037,11 +1047,12 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1037 |
$next_scheduled_backup = 'Nothing currently scheduled';
|
1038 |
}
|
1039 |
|
1040 |
-
|
1041 |
-
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
1042 |
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
1043 |
-
MainWP_Helper::check_methods(
|
1044 |
-
|
|
|
1045 |
$next_scheduled_backup_database = wp_next_scheduled( 'updraft_backup_database' );
|
1046 |
if ( UpdraftPlus_Options::get_updraft_option( 'updraft_interval_database', UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) === UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) {
|
1047 |
$next_scheduled_backup_database = ( 'Nothing currently scheduled' === $next_scheduled_backup ) ? $next_scheduled_backup : __( 'At the same time as the files backup', 'updraftplus' );
|
@@ -1057,7 +1068,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1057 |
}
|
1058 |
|
1059 |
$updraft_dir = $updraftplus->backups_dir_location();
|
1060 |
-
|
1061 |
|
1062 |
$current_timegmt = time();
|
1063 |
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
@@ -1092,7 +1103,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1092 |
|
1093 |
private function next_scheduled_backups() {
|
1094 |
global $updraftplus;
|
1095 |
-
|
1096 |
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
1097 |
|
1098 |
// UNIX timestamp
|
@@ -1107,7 +1118,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1107 |
$next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus');
|
1108 |
$files_not_scheduled = true;
|
1109 |
}
|
1110 |
-
|
1111 |
$next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database');
|
1112 |
if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database',UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) {
|
1113 |
if (isset($files_not_scheduled)) {
|
@@ -1129,7 +1140,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1129 |
$database_not_scheduled = true;
|
1130 |
}
|
1131 |
}
|
1132 |
-
|
1133 |
$current_timegmt = time();
|
1134 |
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
1135 |
|
@@ -1142,8 +1153,11 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1142 |
<td style="width: 124px; vertical-align:top; margin: 0px; padding: 0px;">' . __( 'Time now', 'updraftplus' ) . ': </td><td style="color:blue; margin: 0px; padding: 0px;">' . $current_time . '</td>
|
1143 |
</table>';
|
1144 |
|
|
|
|
|
|
|
1145 |
$updraft_dir = $updraftplus->backups_dir_location();
|
1146 |
-
$backup_disabled = (
|
1147 |
|
1148 |
$out = array(
|
1149 |
'n' => $html,
|
@@ -1167,7 +1181,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1167 |
|
1168 |
private function deleteset() {
|
1169 |
global $updraftplus;
|
1170 |
-
|
1171 |
if (method_exists($updraftplus, 'get_backup_history')) {
|
1172 |
$backups = $updraftplus->get_backup_history();
|
1173 |
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
@@ -1301,12 +1315,12 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1301 |
}
|
1302 |
|
1303 |
public function build_historystatus() {
|
1304 |
-
|
1305 |
-
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
|
1306 |
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
|
1307 |
-
|
1308 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1309 |
-
|
1310 |
$output = $this->existing_backup_table( $backup_history );
|
1311 |
|
1312 |
if ( ! empty( $messages ) && is_array( $messages ) ) {
|
@@ -1392,13 +1406,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1392 |
$updraftplus->jobdata_set( 'job_type', 'download' );
|
1393 |
$updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms );
|
1394 |
|
1395 |
-
// Retrieve the information from our backup history
|
1396 |
if (method_exists($updraftplus, 'get_backup_history')) {
|
1397 |
$backup_history = $updraftplus->get_backup_history();
|
1398 |
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
1399 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1400 |
}
|
1401 |
-
|
1402 |
// Base name
|
1403 |
$file = $backup_history[ $timestamp ][ $type ];
|
1404 |
|
@@ -1554,13 +1568,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1554 |
|
1555 |
public function restore_alldownloaded() {
|
1556 |
global $updraftplus;
|
1557 |
-
|
1558 |
if (method_exists($updraftplus, 'get_backup_history')) {
|
1559 |
$backups = $updraftplus->get_backup_history();
|
1560 |
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
1561 |
$backups = UpdraftPlus_Backup_History::get_history();
|
1562 |
}
|
1563 |
-
|
1564 |
$updraft_dir = $updraftplus->backups_dir_location();
|
1565 |
|
1566 |
$timestamp = (int) $_POST['timestamp'];
|
@@ -1701,7 +1715,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1701 |
);
|
1702 |
}
|
1703 |
}
|
1704 |
-
|
1705 |
// not used
|
1706 |
public function restoreBackup() {
|
1707 |
|
@@ -2116,7 +2130,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
2116 |
|
2117 |
return true;
|
2118 |
}
|
2119 |
-
|
2120 |
public function option_filter_template( $val ) {
|
2121 |
global $updraftplus;
|
2122 |
|
@@ -2487,10 +2501,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
2487 |
|
2488 |
}
|
2489 |
|
2490 |
-
|
2491 |
public function analyse_db_file($timestamp, $res, $db_file = false, $header_only = false) {
|
2492 |
global $updraftplus;
|
2493 |
-
|
2494 |
$mess = array();
|
2495 |
$warn = array();
|
2496 |
$err = array();
|
@@ -2853,9 +2867,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
2853 |
$collate_select_html .= '<option value="'.esc_attr($collate).'" '.selected($collate, $similar_type_collate, $echo = false).' '.implode(' ', $option_other_attr).'>'.esc_html($collate).'</option>';
|
2854 |
}
|
2855 |
$collate_select_html .= '</select>';
|
2856 |
-
|
2857 |
$info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'].'<br>'.$collate_select_html;
|
2858 |
-
|
2859 |
if ($db_charset_forbidden) {
|
2860 |
$collate_change_on_charset_selection_data = array(
|
2861 |
'db_supported_collations' => $db_supported_collations,
|
@@ -2921,7 +2935,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
2921 |
return array($mess, $warn, $err, $info);
|
2922 |
}
|
2923 |
|
2924 |
-
|
2925 |
private function gzopen_for_read( $file, &$warn, &$err ) {
|
2926 |
if ( ! function_exists( 'gzopen' ) || ! function_exists( 'gzread' ) ) {
|
2927 |
$missing = '';
|
@@ -3014,13 +3028,13 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
3014 |
if ( false === $backup_history ) {
|
3015 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
3016 |
}
|
3017 |
-
|
3018 |
if ( empty( $backup_history ) ) {
|
3019 |
return '<p><em>' . __( 'You have not yet made any backups.', 'updraftplus' ) . '</em></p>';
|
3020 |
}
|
3021 |
|
3022 |
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'get_backupable_file_entities' ));
|
3023 |
-
|
3024 |
$updraft_dir = $updraftplus->backups_dir_location();
|
3025 |
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
|
3026 |
|
@@ -3094,7 +3108,7 @@ ENDHERE;
|
|
3094 |
} else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
|
3095 |
$entities .= '/dbcrypted=1/';
|
3096 |
}
|
3097 |
-
|
3098 |
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
|
3099 |
}
|
3100 |
|
@@ -3959,7 +3973,7 @@ ENDHERE;
|
|
3959 |
return $value;
|
3960 |
}
|
3961 |
|
3962 |
-
public function get_sync_data() {
|
3963 |
$this->required_files();
|
3964 |
return $this->get_updraft_data();
|
3965 |
}
|
11 |
return MainWP_Child_Updraft_Plus_Backups::$instance;
|
12 |
}
|
13 |
|
14 |
+
public function __construct() {
|
15 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) {
|
17 |
+
$this->is_plugin_installed = true;
|
18 |
+
}
|
19 |
+
|
20 |
if (!$this->is_plugin_installed)
|
21 |
+
return;
|
22 |
+
|
23 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
24 |
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
|
25 |
}
|
30 |
|
31 |
if (isset($last_backup['backup_time'])) {
|
32 |
$backup_time = $last_backup['backup_time'];
|
33 |
+
if ($last_backup['success']) {
|
34 |
+
MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time);
|
35 |
+
}
|
36 |
}
|
37 |
return $last_backup;
|
38 |
}
|
50 |
}
|
51 |
}
|
52 |
} catch(Exception $e) {
|
53 |
+
|
54 |
}
|
55 |
+
|
56 |
return $information;
|
57 |
}
|
58 |
|
64 |
}
|
65 |
|
66 |
$this->required_files();
|
67 |
+
|
68 |
global $updraftplus;
|
69 |
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
|
70 |
$updraftplus = new UpdraftPlus();
|
73 |
$information['error'] = 'Error empty updraftplus';
|
74 |
MainWP_Helper::write( $information );
|
75 |
}
|
76 |
+
|
77 |
if ( isset( $_POST['mwp_action'] ) ) {
|
78 |
|
79 |
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
|
80 |
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
|
81 |
}
|
82 |
+
|
83 |
try {
|
84 |
switch ( $_POST['mwp_action'] ) {
|
85 |
case 'set_showhide':
|
251 |
private function connected_html() {
|
252 |
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
253 |
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
254 |
+
|
255 |
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
256 |
if ( !is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
|
257 |
return '';
|
384 |
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
|
385 |
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
|
386 |
}
|
387 |
+
|
388 |
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
|
389 |
require_once( UPDRAFTPLUS_DIR . '/options.php' );
|
390 |
}
|
391 |
}
|
392 |
}
|
393 |
+
|
394 |
function save_settings() {
|
395 |
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
396 |
|
541 |
if(is_array($opts) && isset($opts['settings'])) {
|
542 |
$settings_key = key($opts['settings']);
|
543 |
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
544 |
+
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
|
545 |
} else {
|
546 |
$opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
547 |
+
$opts['endpoint'] = $settings[ $key ]['endpoint'];
|
548 |
}
|
549 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
550 |
} else if ( 'updraft_ftp' === $key ) {
|
599 |
}
|
600 |
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
|
601 |
} else if ( 'updraft_backblaze' === $key ) {
|
602 |
+
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
|
603 |
if (!is_array($opts))
|
604 |
$opts = array();
|
605 |
if (is_array($opts) && isset($opts['settings'])) {
|
606 |
+
$settings_key = key($opts['settings']);
|
607 |
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
|
608 |
$opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
|
609 |
$opts['settings'][$settings_key]['bucket_name'] = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
|
610 |
+
$opts['settings'][$settings_key]['backup_path'] = $this->replace_tokens( $settings[ $key ]['backup_path'] );
|
611 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
612 |
}
|
613 |
} else {
|
616 |
$updated = true;
|
617 |
}
|
618 |
}
|
619 |
+
|
620 |
+
|
621 |
if (!isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) {
|
622 |
+
UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] );
|
623 |
}
|
624 |
+
|
625 |
+
|
626 |
global $updraftplus;
|
627 |
if ( isset( $settings['updraft_interval'] ) ) {
|
628 |
// fix for premium version
|
670 |
|
671 |
function addons_connect() {
|
672 |
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
|
673 |
+
if (is_file(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php')) require_once(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php');
|
674 |
+
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
|
675 |
+
return array( 'error' => 'NO_PREMIUM' );
|
676 |
+
}
|
677 |
}
|
678 |
|
679 |
$addons_options = maybe_unserialize( base64_decode( $_POST['addons_options'] ) );
|
749 |
$ehash = substr( md5( $input['email'] ), 0, 23 );
|
750 |
delete_site_transient( 'udaddons_connect_' . $ehash );
|
751 |
|
|
|
|
|
752 |
return $input;
|
753 |
}
|
754 |
|
834 |
$ret_info = '';
|
835 |
if ( ! $failed ) {
|
836 |
$all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N );
|
837 |
+
//$all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables );
|
838 |
+
$all_tables = array_map(array($this, 'cb_get_name_base_type'), $all_tables);
|
839 |
+
|
840 |
if ( empty( $_POST['prefix'] ) ) {
|
841 |
$ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) );
|
842 |
} else {
|
876 |
return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after );
|
877 |
}
|
878 |
|
879 |
+
private function cb_get_name_base_type($a) {
|
880 |
+
return $a[0];
|
881 |
+
}
|
882 |
|
883 |
function backup_now() {
|
884 |
global $updraftplus;
|
1034 |
if ( empty( $updraftplus ) ) {
|
1035 |
return false;
|
1036 |
}
|
1037 |
+
|
1038 |
// UNIX timestamp
|
1039 |
$next_scheduled_backup = wp_next_scheduled( 'updraft_backup' );
|
1040 |
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
1047 |
$next_scheduled_backup = 'Nothing currently scheduled';
|
1048 |
}
|
1049 |
|
1050 |
+
|
1051 |
+
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Options', 'UpdraftPlus_Filesystem_Functions' )) ;
|
1052 |
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
1053 |
+
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
|
1054 |
+
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location' ));
|
1055 |
+
|
1056 |
$next_scheduled_backup_database = wp_next_scheduled( 'updraft_backup_database' );
|
1057 |
if ( UpdraftPlus_Options::get_updraft_option( 'updraft_interval_database', UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) === UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) {
|
1058 |
$next_scheduled_backup_database = ( 'Nothing currently scheduled' === $next_scheduled_backup ) ? $next_scheduled_backup : __( 'At the same time as the files backup', 'updraftplus' );
|
1068 |
}
|
1069 |
|
1070 |
$updraft_dir = $updraftplus->backups_dir_location();
|
1071 |
+
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
|
1072 |
|
1073 |
$current_timegmt = time();
|
1074 |
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
1103 |
|
1104 |
private function next_scheduled_backups() {
|
1105 |
global $updraftplus;
|
1106 |
+
|
1107 |
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
1108 |
|
1109 |
// UNIX timestamp
|
1118 |
$next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus');
|
1119 |
$files_not_scheduled = true;
|
1120 |
}
|
1121 |
+
|
1122 |
$next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database');
|
1123 |
if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database',UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) {
|
1124 |
if (isset($files_not_scheduled)) {
|
1140 |
$database_not_scheduled = true;
|
1141 |
}
|
1142 |
}
|
1143 |
+
|
1144 |
$current_timegmt = time();
|
1145 |
$current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' );
|
1146 |
|
1153 |
<td style="width: 124px; vertical-align:top; margin: 0px; padding: 0px;">' . __( 'Time now', 'updraftplus' ) . ': </td><td style="color:blue; margin: 0px; padding: 0px;">' . $current_time . '</td>
|
1154 |
</table>';
|
1155 |
|
1156 |
+
MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Filesystem_Functions' ) ) ;
|
1157 |
+
MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable');
|
1158 |
+
|
1159 |
$updraft_dir = $updraftplus->backups_dir_location();
|
1160 |
+
$backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1;
|
1161 |
|
1162 |
$out = array(
|
1163 |
'n' => $html,
|
1181 |
|
1182 |
private function deleteset() {
|
1183 |
global $updraftplus;
|
1184 |
+
|
1185 |
if (method_exists($updraftplus, 'get_backup_history')) {
|
1186 |
$backups = $updraftplus->get_backup_history();
|
1187 |
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
1315 |
}
|
1316 |
|
1317 |
public function build_historystatus() {
|
1318 |
+
|
1319 |
+
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
|
1320 |
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
|
1321 |
+
|
1322 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1323 |
+
|
1324 |
$output = $this->existing_backup_table( $backup_history );
|
1325 |
|
1326 |
if ( ! empty( $messages ) && is_array( $messages ) ) {
|
1406 |
$updraftplus->jobdata_set( 'job_type', 'download' );
|
1407 |
$updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms );
|
1408 |
|
1409 |
+
// Retrieve the information from our backup history
|
1410 |
if (method_exists($updraftplus, 'get_backup_history')) {
|
1411 |
$backup_history = $updraftplus->get_backup_history();
|
1412 |
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
1413 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1414 |
}
|
1415 |
+
|
1416 |
// Base name
|
1417 |
$file = $backup_history[ $timestamp ][ $type ];
|
1418 |
|
1568 |
|
1569 |
public function restore_alldownloaded() {
|
1570 |
global $updraftplus;
|
1571 |
+
|
1572 |
if (method_exists($updraftplus, 'get_backup_history')) {
|
1573 |
$backups = $updraftplus->get_backup_history();
|
1574 |
} else if (class_exists('UpdraftPlus_Backup_History')) {
|
1575 |
$backups = UpdraftPlus_Backup_History::get_history();
|
1576 |
}
|
1577 |
+
|
1578 |
$updraft_dir = $updraftplus->backups_dir_location();
|
1579 |
|
1580 |
$timestamp = (int) $_POST['timestamp'];
|
1715 |
);
|
1716 |
}
|
1717 |
}
|
1718 |
+
|
1719 |
// not used
|
1720 |
public function restoreBackup() {
|
1721 |
|
2130 |
|
2131 |
return true;
|
2132 |
}
|
2133 |
+
|
2134 |
public function option_filter_template( $val ) {
|
2135 |
global $updraftplus;
|
2136 |
|
2501 |
|
2502 |
}
|
2503 |
|
2504 |
+
|
2505 |
public function analyse_db_file($timestamp, $res, $db_file = false, $header_only = false) {
|
2506 |
global $updraftplus;
|
2507 |
+
|
2508 |
$mess = array();
|
2509 |
$warn = array();
|
2510 |
$err = array();
|
2867 |
$collate_select_html .= '<option value="'.esc_attr($collate).'" '.selected($collate, $similar_type_collate, $echo = false).' '.implode(' ', $option_other_attr).'>'.esc_html($collate).'</option>';
|
2868 |
}
|
2869 |
$collate_select_html .= '</select>';
|
2870 |
+
|
2871 |
$info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'].'<br>'.$collate_select_html;
|
2872 |
+
|
2873 |
if ($db_charset_forbidden) {
|
2874 |
$collate_change_on_charset_selection_data = array(
|
2875 |
'db_supported_collations' => $db_supported_collations,
|
2935 |
return array($mess, $warn, $err, $info);
|
2936 |
}
|
2937 |
|
2938 |
+
|
2939 |
private function gzopen_for_read( $file, &$warn, &$err ) {
|
2940 |
if ( ! function_exists( 'gzopen' ) || ! function_exists( 'gzread' ) ) {
|
2941 |
$missing = '';
|
3028 |
if ( false === $backup_history ) {
|
3029 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
3030 |
}
|
3031 |
+
|
3032 |
if ( empty( $backup_history ) ) {
|
3033 |
return '<p><em>' . __( 'You have not yet made any backups.', 'updraftplus' ) . '</em></p>';
|
3034 |
}
|
3035 |
|
3036 |
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'get_backupable_file_entities' ));
|
3037 |
+
|
3038 |
$updraft_dir = $updraftplus->backups_dir_location();
|
3039 |
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
|
3040 |
|
3108 |
} else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
|
3109 |
$entities .= '/dbcrypted=1/';
|
3110 |
}
|
3111 |
+
|
3112 |
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
|
3113 |
}
|
3114 |
|
3973 |
return $value;
|
3974 |
}
|
3975 |
|
3976 |
+
public function get_sync_data() {
|
3977 |
$this->required_files();
|
3978 |
return $this->get_updraft_data();
|
3979 |
}
|
class/class-mainwp-child-woocommerce-status.php
CHANGED
@@ -26,7 +26,7 @@ class MainWP_Child_WooCommerce_Status {
|
|
26 |
$information['error'] = 'NO_WOOCOMMERCE';
|
27 |
MainWP_Helper::write( $information );
|
28 |
}
|
29 |
-
|
30 |
$is_ver220 = $this->is_version_220();
|
31 |
if ( isset( $_POST['mwp_action'] ) ) {
|
32 |
switch ( $_POST['mwp_action'] ) {
|
@@ -35,7 +35,7 @@ class MainWP_Child_WooCommerce_Status {
|
|
35 |
break;
|
36 |
case 'report_data':
|
37 |
$information = ! $is_ver220 ? $this->report_data() : $this->report_data_two();
|
38 |
-
break;
|
39 |
case 'update_wc_db':
|
40 |
$information = $this->update_wc_db();
|
41 |
break;
|
@@ -178,6 +178,10 @@ class MainWP_Child_WooCommerce_Status {
|
|
178 |
$reports = new WC_Admin_Report();
|
179 |
$start_date = $_POST['start_date'];
|
180 |
$end_date = $_POST['end_date'];
|
|
|
|
|
|
|
|
|
181 |
// Get sales
|
182 |
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
|
183 |
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
|
@@ -193,10 +197,13 @@ class MainWP_Child_WooCommerce_Status {
|
|
193 |
'on-hold',
|
194 |
) ) ) . "' )
|
195 |
AND postmeta.meta_key = '_order_total'
|
196 |
-
AND posts.post_date >=
|
197 |
-
AND posts.post_date <=
|
198 |
" );
|
199 |
|
|
|
|
|
|
|
200 |
// Get top seller
|
201 |
$top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
202 |
FROM {$wpdb->posts} as posts
|
@@ -216,8 +223,8 @@ class MainWP_Child_WooCommerce_Status {
|
|
216 |
) ) ) . "' )
|
217 |
AND order_item_meta.meta_key = '_qty'
|
218 |
AND order_item_meta_2.meta_key = '_product_id'
|
219 |
-
AND posts.post_date >=
|
220 |
-
AND posts.post_date <=
|
221 |
GROUP BY product_id
|
222 |
ORDER BY qty DESC
|
223 |
LIMIT 1
|
@@ -284,9 +291,12 @@ class MainWP_Child_WooCommerce_Status {
|
|
284 |
}
|
285 |
|
286 |
function sync_data_two() {
|
287 |
-
// sync data
|
288 |
-
|
289 |
-
|
|
|
|
|
|
|
290 |
|
291 |
return $this->get_woocom_data( $start_date, $end_date );
|
292 |
}
|
@@ -297,14 +307,14 @@ class MainWP_Child_WooCommerce_Status {
|
|
297 |
|
298 |
return $this->get_woocom_data( $start_date, $end_date );
|
299 |
}
|
300 |
-
|
301 |
function check_db_update() {
|
302 |
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
|
303 |
return true;
|
304 |
}
|
305 |
return false;
|
306 |
}
|
307 |
-
|
308 |
function get_woocom_data( $start_date, $end_date ) {
|
309 |
global $wpdb;
|
310 |
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
|
@@ -313,6 +323,10 @@ class MainWP_Child_WooCommerce_Status {
|
|
313 |
} else {
|
314 |
return false;
|
315 |
}
|
|
|
|
|
|
|
|
|
316 |
$reports = new WC_Admin_Report();
|
317 |
// Sales
|
318 |
$query = array();
|
@@ -325,8 +339,8 @@ class MainWP_Child_WooCommerce_Status {
|
|
325 |
'on-hold',
|
326 |
) ) ) . "' ) ";
|
327 |
$query['where'] .= "AND postmeta.meta_key = '_order_total' ";
|
328 |
-
$query['where'] .= "AND posts.post_date >=
|
329 |
-
$query['where'] .= "AND posts.post_date <=
|
330 |
|
331 |
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );
|
332 |
|
@@ -345,13 +359,13 @@ class MainWP_Child_WooCommerce_Status {
|
|
345 |
) ) ) . "' ) ";
|
346 |
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
|
347 |
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
348 |
-
$query['where'] .= "AND posts.post_date >= %s ";
|
349 |
-
$query['where'] .= "AND posts.post_date <= %s ";
|
350 |
$query['groupby'] = 'GROUP BY product_id';
|
351 |
$query['orderby'] = 'ORDER BY qty DESC';
|
352 |
$query['limits'] = 'LIMIT 1';
|
353 |
|
354 |
-
$top_seller = $wpdb->get_row(
|
355 |
|
356 |
|
357 |
if ( ! empty( $top_seller ) ) {
|
@@ -413,17 +427,17 @@ class MainWP_Child_WooCommerce_Status {
|
|
413 |
'stock' => $stock,
|
414 |
'nostock' => $nostock,
|
415 |
'lowstock' => $lowinstock_count,
|
416 |
-
'outstock' => $outofstock_count
|
417 |
);
|
418 |
$information['data'] = $data;
|
419 |
-
$information['need_db_update'] = $this->check_db_update();
|
420 |
return $information;
|
421 |
}
|
422 |
-
|
423 |
private static function update_wc_db() {
|
424 |
include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' );
|
425 |
$background_updater = new WC_Background_Updater();
|
426 |
-
|
427 |
$current_db_version = get_option( 'woocommerce_db_version' );
|
428 |
$logger = wc_get_logger();
|
429 |
$update_queued = false;
|
@@ -444,9 +458,9 @@ class MainWP_Child_WooCommerce_Status {
|
|
444 |
if ( $update_queued ) {
|
445 |
$background_updater->save()->dispatch();
|
446 |
}
|
447 |
-
|
448 |
return array('result' => 'success');
|
449 |
}
|
450 |
-
|
451 |
}
|
452 |
|
26 |
$information['error'] = 'NO_WOOCOMMERCE';
|
27 |
MainWP_Helper::write( $information );
|
28 |
}
|
29 |
+
|
30 |
$is_ver220 = $this->is_version_220();
|
31 |
if ( isset( $_POST['mwp_action'] ) ) {
|
32 |
switch ( $_POST['mwp_action'] ) {
|
35 |
break;
|
36 |
case 'report_data':
|
37 |
$information = ! $is_ver220 ? $this->report_data() : $this->report_data_two();
|
38 |
+
break;
|
39 |
case 'update_wc_db':
|
40 |
$information = $this->update_wc_db();
|
41 |
break;
|
178 |
$reports = new WC_Admin_Report();
|
179 |
$start_date = $_POST['start_date'];
|
180 |
$end_date = $_POST['end_date'];
|
181 |
+
|
182 |
+
$start_date = date( 'Y-m-d H:i:s', $start_date );
|
183 |
+
$end_date = date( 'Y-m-d H:i:s', $end_date );
|
184 |
+
|
185 |
// Get sales
|
186 |
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
|
187 |
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
|
197 |
'on-hold',
|
198 |
) ) ) . "' )
|
199 |
AND postmeta.meta_key = '_order_total'
|
200 |
+
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
201 |
+
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
|
202 |
" );
|
203 |
|
204 |
+
|
205 |
+
|
206 |
+
|
207 |
// Get top seller
|
208 |
$top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
209 |
FROM {$wpdb->posts} as posts
|
223 |
) ) ) . "' )
|
224 |
AND order_item_meta.meta_key = '_qty'
|
225 |
AND order_item_meta_2.meta_key = '_product_id'
|
226 |
+
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
227 |
+
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
|
228 |
GROUP BY product_id
|
229 |
ORDER BY qty DESC
|
230 |
LIMIT 1
|
291 |
}
|
292 |
|
293 |
function sync_data_two() {
|
294 |
+
// sync data for current month
|
295 |
+
$start_date = date( 'Y-m-01 00:00:00', time() );
|
296 |
+
$end_date = date( 'Y-m-d H:i:s', time() );
|
297 |
+
|
298 |
+
$start_date = strtotime( $start_date );
|
299 |
+
$end_date = strtotime( $end_date );
|
300 |
|
301 |
return $this->get_woocom_data( $start_date, $end_date );
|
302 |
}
|
307 |
|
308 |
return $this->get_woocom_data( $start_date, $end_date );
|
309 |
}
|
310 |
+
|
311 |
function check_db_update() {
|
312 |
if ( version_compare( get_option( 'woocommerce_db_version' ), WC_VERSION, '<' ) ) {
|
313 |
return true;
|
314 |
}
|
315 |
return false;
|
316 |
}
|
317 |
+
|
318 |
function get_woocom_data( $start_date, $end_date ) {
|
319 |
global $wpdb;
|
320 |
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
|
323 |
} else {
|
324 |
return false;
|
325 |
}
|
326 |
+
|
327 |
+
$start_date = date( 'Y-m-d H:i:s', $start_date );
|
328 |
+
$end_date = date( 'Y-m-d H:i:s', $end_date );
|
329 |
+
|
330 |
$reports = new WC_Admin_Report();
|
331 |
// Sales
|
332 |
$query = array();
|
339 |
'on-hold',
|
340 |
) ) ) . "' ) ";
|
341 |
$query['where'] .= "AND postmeta.meta_key = '_order_total' ";
|
342 |
+
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
343 |
+
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
344 |
|
345 |
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );
|
346 |
|
359 |
) ) ) . "' ) ";
|
360 |
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
|
361 |
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
362 |
+
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
363 |
+
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
364 |
$query['groupby'] = 'GROUP BY product_id';
|
365 |
$query['orderby'] = 'ORDER BY qty DESC';
|
366 |
$query['limits'] = 'LIMIT 1';
|
367 |
|
368 |
+
$top_seller = $wpdb->get_row( implode( ' ', $query ) );
|
369 |
|
370 |
|
371 |
if ( ! empty( $top_seller ) ) {
|
427 |
'stock' => $stock,
|
428 |
'nostock' => $nostock,
|
429 |
'lowstock' => $lowinstock_count,
|
430 |
+
'outstock' => $outofstock_count
|
431 |
);
|
432 |
$information['data'] = $data;
|
433 |
+
$information['need_db_update'] = $this->check_db_update();
|
434 |
return $information;
|
435 |
}
|
436 |
+
|
437 |
private static function update_wc_db() {
|
438 |
include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' );
|
439 |
$background_updater = new WC_Background_Updater();
|
440 |
+
|
441 |
$current_db_version = get_option( 'woocommerce_db_version' );
|
442 |
$logger = wc_get_logger();
|
443 |
$update_queued = false;
|
458 |
if ( $update_queued ) {
|
459 |
$background_updater->save()->dispatch();
|
460 |
}
|
461 |
+
|
462 |
return array('result' => 'success');
|
463 |
}
|
464 |
+
|
465 |
}
|
466 |
|
class/class-mainwp-child.php
CHANGED
@@ -60,6 +60,14 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|
60 |
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action ) ) ) . '</mainwp>' );
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
$token = wp_get_session_token();
|
64 |
$i = wp_nonce_tick();
|
65 |
|
@@ -75,8 +83,19 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|
75 |
return 2;
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
// Invalid nonce
|
79 |
-
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action ) ) ) . '</mainwp>' );
|
80 |
}
|
81 |
endif;
|
82 |
}
|
@@ -84,7 +103,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|
84 |
}
|
85 |
|
86 |
class MainWP_Child {
|
87 |
-
public static $version = '3.
|
88 |
private $update_version = '1.3';
|
89 |
|
90 |
private $callableFunctions = array(
|
@@ -149,10 +168,11 @@ class MainWP_Child {
|
|
149 |
'custom_post_type' => 'custom_post_type',
|
150 |
'backup_buddy' => 'backup_buddy',
|
151 |
'get_site_icon' => 'get_site_icon',
|
152 |
-
'vulner_checker' => 'vulner_checker',
|
153 |
-
'wp_staging' => 'wp_staging',
|
154 |
'disconnect' => 'disconnect',
|
155 |
'time_capsule' => 'time_capsule',
|
|
|
156 |
);
|
157 |
|
158 |
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
|
@@ -179,11 +199,11 @@ class MainWP_Child {
|
|
179 |
$this->update();
|
180 |
$this->load_all_options();
|
181 |
$this->filterFunction = function($a) {
|
182 |
-
if ($a == null) { return false; }
|
183 |
-
if (is_object($a) && property_exists($a, "last_checked") && !property_exists($a, "checked"))
|
184 |
-
return false;
|
185 |
return $a;
|
186 |
-
};
|
187 |
$this->plugin_dir = dirname( $plugin_file );
|
188 |
$this->plugin_slug = plugin_basename( $plugin_file );
|
189 |
list ( $t1, $t2 ) = explode( '/', $this->plugin_slug );
|
@@ -193,7 +213,7 @@ class MainWP_Child {
|
|
193 |
$this->comments_and_clauses = '';
|
194 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
195 |
add_action( 'init', array( &$this, 'check_login' ), 1 );
|
196 |
-
add_action( 'init', array( &$this, 'parse_init' ), 9999 );
|
197 |
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
198 |
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
199 |
add_action( 'admin_head', array( &$this, 'admin_head' ) );
|
@@ -503,17 +523,15 @@ class MainWP_Child {
|
|
503 |
}
|
504 |
|
505 |
public function pre_current_active_plugins() {
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
set_site_transient( 'tofix_update_plugins', $fix_update_plugins);
|
516 |
-
}
|
517 |
|
518 |
function checkOtherAuth() {
|
519 |
$auths = get_option( 'mainwp_child_auth' );
|
@@ -734,7 +752,7 @@ class MainWP_Child {
|
|
734 |
|
735 |
<?php if ( !$hide_connection_detail ) { ?>
|
736 |
<div class="mainwp-child-setting-tab connection-detail" <?php echo ('connection-detail' !== $shownPage) ? $hide_style : '' ; ?>>
|
737 |
-
<?php MainWP_Child_Server_Information::renderConnectionDetails(); ?>
|
738 |
</div>
|
739 |
<?php } ?>
|
740 |
|
@@ -873,12 +891,12 @@ class MainWP_Child {
|
|
873 |
<?php
|
874 |
}
|
875 |
|
876 |
-
function admin_init() {
|
877 |
if ( MainWP_Helper::isAdmin() && is_admin() ) {
|
878 |
MainWP_Clone::get()->init_ajax();
|
879 |
}
|
880 |
}
|
881 |
-
|
882 |
function admin_head() {
|
883 |
if (isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab') {
|
884 |
?>
|
@@ -914,7 +932,7 @@ class MainWP_Child {
|
|
914 |
MainWP_Helper::update_option( 'mainwp_child_uniqueId', '' );
|
915 |
}
|
916 |
}
|
917 |
-
|
918 |
?>
|
919 |
<div class="postbox">
|
920 |
<h2 class="hndle"><span><?php esc_html_e( 'Connection settings', 'mainwp-child' ); ?></span></h2>
|
@@ -1323,7 +1341,7 @@ class MainWP_Child {
|
|
1323 |
|
1324 |
remove_action( 'admin_init', 'send_frame_options_header' );
|
1325 |
remove_action( 'login_init', 'send_frame_options_header' );
|
1326 |
-
|
1327 |
// Call Heatmap
|
1328 |
if ( 'yes' === get_option( 'heatMapExtensionLoaded' ) ) {
|
1329 |
if ( ( '1' !== get_option( 'heatMapsIndividualOverrideSetting' ) && '0' !== get_option( 'heatMapEnabled' ) ) ||
|
@@ -1385,7 +1403,7 @@ class MainWP_Child {
|
|
1385 |
die();
|
1386 |
}
|
1387 |
}
|
1388 |
-
|
1389 |
// Init extensions
|
1390 |
// Handle fatal errors for those init if needed
|
1391 |
// OK
|
@@ -1393,28 +1411,28 @@ class MainWP_Child {
|
|
1393 |
MainWP_Child_Updraft_Plus_Backups::Instance()->updraftplus_init();
|
1394 |
MainWP_Child_Back_Up_Wordpress::Instance()->init();
|
1395 |
MainWP_Child_WP_Rocket::Instance()->init();
|
1396 |
-
MainWP_Child_Back_WP_Up::Instance()->init();
|
1397 |
MainWP_Child_Back_Up_Buddy::Instance();
|
1398 |
-
MainWP_Child_Wordfence::Instance()->wordfence_init();
|
1399 |
MainWP_Child_Timecapsule::Instance()->init();
|
1400 |
-
MainWP_Child_Staging::Instance()->init();
|
1401 |
MainWP_Child_Branding::Instance()->branding_init();
|
1402 |
MainWP_Client_Report::Instance()->creport_init();
|
1403 |
MainWP_Child_Pagespeed::Instance()->init();
|
1404 |
MainWP_Child_Links_Checker::Instance()->init();
|
1405 |
-
|
1406 |
global $_wp_submenu_nopriv;
|
1407 |
if ($_wp_submenu_nopriv === null)
|
1408 |
$_wp_submenu_nopriv = array(); // fix warning
|
1409 |
-
|
1410 |
//Call the function required
|
1411 |
if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) {
|
1412 |
define( 'DOING_CRON', true );
|
1413 |
// ob_start();
|
1414 |
// require_once( ABSPATH . 'wp-admin/admin.php' );
|
1415 |
-
// ob_end_clean();
|
1416 |
-
|
1417 |
-
MainWP_Helper::handle_fatal_error();
|
1418 |
MainWP_Child::fix_for_custom_themes();
|
1419 |
call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) );
|
1420 |
} else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
|
@@ -1424,8 +1442,8 @@ class MainWP_Child {
|
|
1424 |
} else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
1425 |
MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) );
|
1426 |
}
|
1427 |
-
|
1428 |
-
// going to retire soon
|
1429 |
if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) {
|
1430 |
new MainWP_Keyword_Links();
|
1431 |
if ( ! is_admin() ) {
|
@@ -1457,7 +1475,7 @@ class MainWP_Child {
|
|
1457 |
$nossl = get_option( 'mainwp_child_nossl' );
|
1458 |
$serverNoSsl = ( isset( $pNossl ) && 1 === (int) $pNossl );
|
1459 |
|
1460 |
-
if ( ( 1 === (int) $nossl ) || $serverNoSsl ) {
|
1461 |
$auth = hash_equals( md5( $func . $nonce . get_option( 'mainwp_child_nossl_key' ) ), base64_decode( $signature ) );
|
1462 |
} else {
|
1463 |
$auth = openssl_verify( $func . $nonce, base64_decode( $signature ), base64_decode( get_option( 'mainwp_child_pubkey' ) ) );
|
@@ -1508,14 +1526,14 @@ class MainWP_Child {
|
|
1508 |
}
|
1509 |
|
1510 |
public function http_request_reject_unsafe_urls( $r, $url ) {
|
1511 |
-
$r['reject_unsafe_urls'] = false;
|
1512 |
if ( isset($_POST['wpadmin_user']) && !empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && !empty($_POST['wpadmin_passwd']) ) {
|
1513 |
$auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] );
|
1514 |
$r['headers']['Authorization'] = "Basic $auth";
|
1515 |
-
}
|
1516 |
return $r;
|
1517 |
}
|
1518 |
-
|
1519 |
/**
|
1520 |
* Functions to support core functionality
|
1521 |
*/
|
@@ -1623,7 +1641,7 @@ class MainWP_Child {
|
|
1623 |
// to fix activate issue
|
1624 |
if ('quotes-collection/quotes-collection.php' == $args['slug']) {
|
1625 |
activate_plugin( $path . $fileName, '', false, true );
|
1626 |
-
} else {
|
1627 |
activate_plugin( $path . $fileName, '' /* false, true */ );
|
1628 |
}
|
1629 |
do_action( 'activate_plugin', $args['slug'], null );
|
@@ -1766,6 +1784,11 @@ class MainWP_Child {
|
|
1766 |
|
1767 |
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
1768 |
|
|
|
|
|
|
|
|
|
|
|
1769 |
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
|
1770 |
$translations = explode( ',', urldecode( $_POST['list'] ) );
|
1771 |
$all_language_updates = wp_get_translation_updates();
|
@@ -1818,6 +1841,8 @@ class MainWP_Child {
|
|
1818 |
}
|
1819 |
include_once( ABSPATH . '/wp-admin/includes/file.php' );
|
1820 |
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
|
|
|
|
1821 |
$information = array();
|
1822 |
$information['upgrades'] = array();
|
1823 |
$mwp_premium_updates_todo = array();
|
@@ -1857,11 +1882,10 @@ class MainWP_Child {
|
|
1857 |
global $wp_current_filter;
|
1858 |
$wp_current_filter[] = 'load-plugins.php';
|
1859 |
@wp_update_plugins();
|
1860 |
-
|
1861 |
// trick to prevent some premium plugins re-create update info
|
1862 |
remove_all_filters('pre_set_site_transient_update_plugins');
|
1863 |
-
|
1864 |
-
|
1865 |
$information['plugin_updates'] = get_plugin_updates();
|
1866 |
|
1867 |
$plugins = explode( ',', urldecode( $_POST['list'] ) );
|
@@ -1882,13 +1906,30 @@ class MainWP_Child {
|
|
1882 |
if ( count( $plugins ) > 0 ) {
|
1883 |
//@see wp-admin/update.php
|
1884 |
$failed = true;
|
|
|
|
|
|
|
|
|
1885 |
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
|
1886 |
$result = $upgrader->bulk_upgrade( $plugins );
|
1887 |
|
1888 |
if ( ! empty( $result ) ) {
|
1889 |
foreach ( $result as $plugin => $info ) {
|
1890 |
if ( empty( $info ) ) {
|
|
|
1891 |
$information['upgrades'][ $plugin ] = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1892 |
} else {
|
1893 |
$information['upgrades'][ $plugin ] = true;
|
1894 |
// to fix logging update
|
@@ -2231,12 +2272,12 @@ class MainWP_Child {
|
|
2231 |
if ( isset( $_POST['_ezin_post_category'] ) ) {
|
2232 |
$new_post['_ezin_post_category'] = maybe_unserialize( base64_decode( $_POST['_ezin_post_category'] ) );
|
2233 |
}
|
2234 |
-
|
2235 |
-
$others = array();
|
2236 |
if ( isset( $_POST['featured_image_data'] ) && !empty($_POST['featured_image_data'])) {
|
2237 |
$others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] ));
|
2238 |
-
}
|
2239 |
-
|
2240 |
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
|
2241 |
|
2242 |
if (is_array($res) && isset($res['error'])) {
|
@@ -2473,10 +2514,10 @@ class MainWP_Child {
|
|
2473 |
$extra = $_POST['extra'];
|
2474 |
$userId = $_POST['id'];
|
2475 |
$user_pass = $_POST['user_pass'];
|
2476 |
-
|
2477 |
-
|
2478 |
global $current_user;
|
2479 |
-
$reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0;
|
2480 |
include_once( ABSPATH . '/wp-admin/includes/user.php' );
|
2481 |
|
2482 |
if ( 'delete' === $action ) {
|
@@ -2498,25 +2539,25 @@ class MainWP_Child {
|
|
2498 |
} else {
|
2499 |
$failed = true;
|
2500 |
}
|
2501 |
-
} else if ( 'update_user' === $action ) {
|
2502 |
-
$my_user = $_POST['extra'];
|
2503 |
if (is_array($my_user)) {
|
2504 |
foreach($my_user as $idx => $val) {
|
2505 |
if ($val === 'donotupdate' || (empty($val) && $idx !== 'role')) {
|
2506 |
unset($my_user[$idx]);
|
2507 |
-
}
|
2508 |
-
}
|
2509 |
-
$result = $this->edit_user( $userId, $my_user );
|
2510 |
if (is_array($result) && isset($result['error'])) {
|
2511 |
$information['error'] = $result['error'];
|
2512 |
-
}
|
2513 |
} else {
|
2514 |
$failed = true;
|
2515 |
}
|
2516 |
} else {
|
2517 |
$failed = true;
|
2518 |
}
|
2519 |
-
|
2520 |
if ($failed)
|
2521 |
$information['status'] = 'FAIL';
|
2522 |
|
@@ -2525,7 +2566,7 @@ class MainWP_Child {
|
|
2525 |
if ('update_user' === $action && isset($_POST['optimize']) && !empty($_POST['optimize'])) {
|
2526 |
$information['users'] = $this->get_all_users_int(500); // to fix
|
2527 |
}
|
2528 |
-
|
2529 |
}
|
2530 |
MainWP_Helper::write( $information );
|
2531 |
}
|
@@ -2533,12 +2574,12 @@ class MainWP_Child {
|
|
2533 |
function edit_user( $user_id, $data) {
|
2534 |
$wp_roles = wp_roles();
|
2535 |
$user = new stdClass;
|
2536 |
-
|
2537 |
$update = true;
|
2538 |
-
|
2539 |
-
if ( $user_id ) {
|
2540 |
$user->ID = (int) $user_id;
|
2541 |
-
$userdata = get_userdata( $user_id );
|
2542 |
$user->user_login = wp_slash( $userdata->user_login );
|
2543 |
} else {
|
2544 |
return array('error' => 'ERROR: Empty user id.');
|
@@ -2561,8 +2602,8 @@ class MainWP_Child {
|
|
2561 |
// If the new role isn't editable by the logged-in user die with error
|
2562 |
$editable_roles = get_editable_roles();
|
2563 |
if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) )
|
2564 |
-
return array('error' => 'You can’t give users that role.');
|
2565 |
-
}
|
2566 |
|
2567 |
$email = '';
|
2568 |
if ( isset( $data['email'] ) )
|
@@ -2571,8 +2612,8 @@ class MainWP_Child {
|
|
2571 |
if ( !empty( $email ) )
|
2572 |
$user->user_email = sanitize_text_field( wp_unslash( $email ) );
|
2573 |
else
|
2574 |
-
$user->user_email = $userdata->user_email;
|
2575 |
-
|
2576 |
if ( isset( $data['url'] ) ) {
|
2577 |
if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) {
|
2578 |
$user->user_url = '';
|
@@ -2582,18 +2623,18 @@ class MainWP_Child {
|
|
2582 |
$user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
|
2583 |
}
|
2584 |
}
|
2585 |
-
|
2586 |
if ( isset( $data['first_name'] ) )
|
2587 |
-
$user->first_name = sanitize_text_field( $data['first_name'] );
|
2588 |
if ( isset( $data['last_name'] ) )
|
2589 |
-
$user->last_name = sanitize_text_field( $data['last_name'] );
|
2590 |
if ( isset( $data['nickname'] ) && !empty($data['nickname']))
|
2591 |
-
$user->nickname = sanitize_text_field( $data['nickname'] );
|
2592 |
if ( isset( $data['display_name'] ) )
|
2593 |
$user->display_name = sanitize_text_field( $data['display_name'] );
|
2594 |
if ( isset( $data['description'] ) )
|
2595 |
$user->description = trim( $data['description'] );
|
2596 |
-
|
2597 |
$errors = new WP_Error();
|
2598 |
|
2599 |
/* checking that username has been typed */
|
@@ -2601,7 +2642,7 @@ class MainWP_Child {
|
|
2601 |
$errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) );
|
2602 |
|
2603 |
do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
|
2604 |
-
|
2605 |
if (!empty($pass1) || !empty($pass2)) {
|
2606 |
// Check for blank password when adding a user.
|
2607 |
if ( ! $update && empty( $pass1 ) ) {
|
@@ -2623,7 +2664,7 @@ class MainWP_Child {
|
|
2623 |
} else {
|
2624 |
$user->user_pass = $userdata->user_pass;
|
2625 |
}
|
2626 |
-
|
2627 |
/** This filter is documented in wp-includes/user.php */
|
2628 |
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
2629 |
|
@@ -2647,20 +2688,20 @@ class MainWP_Child {
|
|
2647 |
foreach ( $errors->get_error_messages() as $message ) {
|
2648 |
if ( is_string( $message ) )
|
2649 |
$error_str .= ' ' . esc_html( strip_tags( $message ) );
|
2650 |
-
|
2651 |
}
|
2652 |
return array( 'error' => $error_str );
|
2653 |
}
|
2654 |
|
2655 |
$user_id = wp_update_user( $user );
|
2656 |
-
|
2657 |
return $user_id;
|
2658 |
}
|
2659 |
-
|
2660 |
function get_user_to_edit( $user_id ) {
|
2661 |
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
2662 |
-
$profileuser = get_user_to_edit($user_id);
|
2663 |
-
|
2664 |
$edit_data = array();
|
2665 |
if (is_object($profileuser)) {
|
2666 |
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
|
@@ -2669,7 +2710,7 @@ class MainWP_Child {
|
|
2669 |
$edit_data['first_name'] = $profileuser->first_name;
|
2670 |
$edit_data['last_name'] = $profileuser->last_name;
|
2671 |
$edit_data['nickname'] = $profileuser->nickname;
|
2672 |
-
|
2673 |
$public_display = array();
|
2674 |
$public_display['display_nickname'] = $profileuser->nickname;
|
2675 |
$public_display['display_username'] = $profileuser->user_login;
|
@@ -2694,15 +2735,15 @@ class MainWP_Child {
|
|
2694 |
$edit_data['public_display'] = $public_display;
|
2695 |
$edit_data['display_name'] = $profileuser->display_name;
|
2696 |
$edit_data['user_email'] = $profileuser->user_email;
|
2697 |
-
$edit_data['user_url'] = $profileuser->user_url;
|
2698 |
foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
|
2699 |
$edit_data['contact_methods'][$name] = $profileuser->$name;
|
2700 |
-
}
|
2701 |
$edit_data['description'] = $profileuser->description;
|
2702 |
}
|
2703 |
return $edit_data;
|
2704 |
}
|
2705 |
-
|
2706 |
//todo: backwards compatible: wp_set_comment_status ?
|
2707 |
function comment_action() {
|
2708 |
//Read form data
|
@@ -3222,12 +3263,15 @@ class MainWP_Child {
|
|
3222 |
$security['scripts_version'] = true;
|
3223 |
$security['styles_version'] = true;
|
3224 |
$security['generator_version'] = true;
|
3225 |
-
MainWP_Security::remove_scripts_version( true );
|
3226 |
-
MainWP_Security::remove_styles_version( true );
|
3227 |
MainWP_Security::remove_generator_version( true );
|
3228 |
$information['versions'] = 'Y';
|
3229 |
}
|
3230 |
|
|
|
|
|
|
|
|
|
|
|
3231 |
if ( 'all' === $_POST['feature'] || 'admin' === $_POST['feature'] ) {
|
3232 |
$information['admin'] = ( ! MainWP_Security::admin_user_ok() ? 'N' : 'Y' );
|
3233 |
}
|
@@ -3283,6 +3327,10 @@ class MainWP_Child {
|
|
3283 |
$information['versions'] = 'N';
|
3284 |
}
|
3285 |
|
|
|
|
|
|
|
|
|
3286 |
if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) {
|
3287 |
$security['readme'] = false;
|
3288 |
$information['readme'] = MainWP_Security::remove_readme_ok();
|
@@ -3312,6 +3360,7 @@ class MainWP_Child {
|
|
3312 |
$information['php_reporting'] = ( ! MainWP_Security::remove_php_reporting_ok() ? 'N' : 'Y' );
|
3313 |
$information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok()
|
3314 |
? 'N' : 'Y' );
|
|
|
3315 |
$information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' );
|
3316 |
$information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' );
|
3317 |
|
@@ -3508,6 +3557,7 @@ class MainWP_Child {
|
|
3508 |
|
3509 |
@wp_update_plugins();
|
3510 |
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
|
|
3511 |
$plugin_updates = get_plugin_updates();
|
3512 |
if ( is_array( $plugin_updates ) ) {
|
3513 |
$information['plugin_updates'] = array();
|
@@ -3519,19 +3569,22 @@ class MainWP_Child {
|
|
3519 |
|
3520 |
$information['plugin_updates'][ $slug ] = $plugin_update;
|
3521 |
}
|
3522 |
-
|
3523 |
-
// to fix bug
|
3524 |
-
$fix_update_plugins = get_site_transient( 'tofix_update_plugins' );
|
3525 |
-
if ( is_array( $fix_update_plugins ) && ( count( $fix_update_plugins ) > 0 ) ) {
|
3526 |
-
foreach( $fix_update_plugins as $slug => $plugin_update ) {
|
3527 |
-
if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
|
3528 |
-
$information['plugin_updates'][ $slug ] = $plugin_update;
|
3529 |
-
}
|
3530 |
-
}
|
3531 |
-
}
|
3532 |
-
// end fix
|
3533 |
}
|
3534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3535 |
if ( null !== $this->filterFunction ) {
|
3536 |
remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
|
3537 |
}
|
@@ -3620,6 +3673,9 @@ class MainWP_Child {
|
|
3620 |
if ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() ) {
|
3621 |
$securityIssuess ++;
|
3622 |
}
|
|
|
|
|
|
|
3623 |
if ( ! MainWP_Security::admin_user_ok() ) {
|
3624 |
$securityIssuess ++;
|
3625 |
}
|
@@ -3639,7 +3695,10 @@ class MainWP_Child {
|
|
3639 |
$information['categories'] = $categories;
|
3640 |
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
|
3641 |
if ($get_file_size) {
|
3642 |
-
$
|
|
|
|
|
|
|
3643 |
}
|
3644 |
$information['dbsize'] = MainWP_Child_DB::get_size();
|
3645 |
|
@@ -3671,21 +3730,21 @@ class MainWP_Child {
|
|
3671 |
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
|
3672 |
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
|
3673 |
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
|
3674 |
-
|
3675 |
try {
|
3676 |
do_action('mainwp_child_site_stats');
|
3677 |
} catch(Exception $e) {
|
3678 |
-
|
3679 |
}
|
3680 |
-
|
3681 |
if ( isset( $_POST['othersData'] ) ) {
|
3682 |
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
|
3683 |
if ( ! is_array( $othersData ) ) {
|
3684 |
$othersData = array();
|
3685 |
-
}
|
3686 |
-
|
3687 |
try{
|
3688 |
-
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
3689 |
} catch(Exception $e) {
|
3690 |
// do not exit
|
3691 |
}
|
@@ -3720,7 +3779,7 @@ class MainWP_Child {
|
|
3720 |
$favi = $favi_url = get_site_icon_url();
|
3721 |
}
|
3722 |
|
3723 |
-
if ( empty( $favi ) ) {
|
3724 |
if ( file_exists( ABSPATH . 'favicon.ico' ) ) {
|
3725 |
$favi = 'favicon.ico';
|
3726 |
} else if ( file_exists( ABSPATH . 'favicon.png' ) ) {
|
@@ -3890,7 +3949,7 @@ class MainWP_Child {
|
|
3890 |
$link_count = new WPSEO_Link_Column_Count();
|
3891 |
$link_count->set( $post_ids );
|
3892 |
}
|
3893 |
-
foreach ( $posts as $post ) {
|
3894 |
$outPost = array();
|
3895 |
$outPost['id'] = $post->ID;
|
3896 |
$outPost['post_type'] = $post->post_type;
|
@@ -3904,11 +3963,11 @@ class MainWP_Child {
|
|
3904 |
} else {
|
3905 |
$outPost['dts'] = strtotime( $post->post_modified_gmt );
|
3906 |
}
|
3907 |
-
|
3908 |
if ($post->post_status == 'future') {
|
3909 |
$outPost['dts'] = strtotime( $post->post_date_gmt );
|
3910 |
}
|
3911 |
-
|
3912 |
$usr = get_user_by( 'id', $post->post_author );
|
3913 |
$outPost['author'] = ! empty( $usr ) ? $usr->user_nicename : 'removed';
|
3914 |
$categoryObjects = get_the_category( $post->ID );
|
@@ -4148,7 +4207,7 @@ class MainWP_Child {
|
|
4148 |
global $wpdb;
|
4149 |
|
4150 |
add_filter( 'posts_where', array( &$this, 'posts_where' ) );
|
4151 |
-
$where_post_date = isset($_POST['where_post_date']) && !empty($_POST['where_post_date']) ? true : false;
|
4152 |
if ( isset( $_POST['postId'] ) ) {
|
4153 |
$this->posts_where_suffix .= " AND $wpdb->posts.ID = " . $_POST['postId'];
|
4154 |
} else if ( isset( $_POST['userId'] ) ) {
|
@@ -4326,7 +4385,7 @@ class MainWP_Child {
|
|
4326 |
return;
|
4327 |
}
|
4328 |
}
|
4329 |
-
|
4330 |
foreach ( $themes as $idx => $themeToDelete ) {
|
4331 |
if ( $themeToDelete !== $theme_name ) {
|
4332 |
$theTheme = wp_get_theme( $themeToDelete );
|
@@ -4406,7 +4465,7 @@ class MainWP_Child {
|
|
4406 |
if ('quotes-collection/quotes-collection.php' == $plugin) {
|
4407 |
activate_plugin( $plugin, '', false, true );
|
4408 |
do_action( 'activate_plugin', $plugin, null );
|
4409 |
-
} else {
|
4410 |
activate_plugin( $plugin );
|
4411 |
}
|
4412 |
}
|
@@ -4445,7 +4504,7 @@ class MainWP_Child {
|
|
4445 |
$all_plugins = get_plugins();
|
4446 |
foreach ( $plugins as $idx => $plugin ) {
|
4447 |
if ( $plugin !== $this->plugin_slug ) {
|
4448 |
-
if ( isset( $all_plugins[ $plugin ] ) ) {
|
4449 |
if (is_plugin_active($plugin)) {
|
4450 |
$thePlugin = get_plugin_data( $plugin );
|
4451 |
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
@@ -4565,11 +4624,11 @@ class MainWP_Child {
|
|
4565 |
|
4566 |
function get_all_users_int($number = false) {
|
4567 |
$allusers = array();
|
4568 |
-
|
4569 |
$params = array();
|
4570 |
if ($number)
|
4571 |
$params['number'] = $number;
|
4572 |
-
|
4573 |
$new_users = get_users($params);
|
4574 |
if ( is_array( $new_users ) ) {
|
4575 |
foreach ( $new_users as $new_user ) {
|
@@ -4593,24 +4652,24 @@ class MainWP_Child {
|
|
4593 |
return $allusers;
|
4594 |
}
|
4595 |
|
4596 |
-
function search_users() {
|
4597 |
-
|
4598 |
$search_user_role = array();
|
4599 |
$check_users_role = false;
|
4600 |
-
|
4601 |
if (isset($_POST['role']) && !empty($_POST['role'])) {
|
4602 |
$check_users_role = true;
|
4603 |
$all_users_role = $this->get_all_users(true);
|
4604 |
foreach($all_users_role as $user) {
|
4605 |
-
$search_user_role[] = $user['id'];
|
4606 |
}
|
4607 |
unset($all_users_role);
|
4608 |
-
}
|
4609 |
-
|
4610 |
$columns = explode( ',', $_POST['search_columns'] );
|
4611 |
$allusers = array();
|
4612 |
$exclude = array();
|
4613 |
-
|
4614 |
foreach ( $columns as $col ) {
|
4615 |
if ( empty( $col ) ) {
|
4616 |
continue;
|
@@ -4622,7 +4681,7 @@ class MainWP_Child {
|
|
4622 |
'search_columns' => array( $col ),
|
4623 |
'query_orderby' => array( $col ),
|
4624 |
'exclude' => $exclude,
|
4625 |
-
) );
|
4626 |
if ( ! empty( $user_query->results ) ) {
|
4627 |
foreach ( $user_query->results as $new_user ) {
|
4628 |
if ($check_users_role) {
|
@@ -4649,7 +4708,7 @@ class MainWP_Child {
|
|
4649 |
}
|
4650 |
}
|
4651 |
}
|
4652 |
-
|
4653 |
MainWP_Helper::write( $allusers );
|
4654 |
}
|
4655 |
|
@@ -4680,6 +4739,10 @@ class MainWP_Child {
|
|
4680 |
}
|
4681 |
|
4682 |
function activation() {
|
|
|
|
|
|
|
|
|
4683 |
$to_delete = array(
|
4684 |
'mainwp_child_pubkey',
|
4685 |
'mainwp_child_nonce',
|
@@ -4702,6 +4765,11 @@ class MainWP_Child {
|
|
4702 |
}
|
4703 |
|
4704 |
function deactivation( $deact = true) {
|
|
|
|
|
|
|
|
|
|
|
4705 |
$to_delete = array(
|
4706 |
'mainwp_child_pubkey',
|
4707 |
'mainwp_child_nonce',
|
@@ -4719,7 +4787,7 @@ class MainWP_Child {
|
|
4719 |
wp_cache_delete( $delete, 'options' );
|
4720 |
}
|
4721 |
}
|
4722 |
-
|
4723 |
if ($deact)
|
4724 |
do_action( 'mainwp_child_deactivation' );
|
4725 |
}
|
@@ -4826,12 +4894,12 @@ class MainWP_Child {
|
|
4826 |
}
|
4827 |
}
|
4828 |
}
|
4829 |
-
// to fix for window host, performance not good?
|
4830 |
-
if ( class_exists( 'RecursiveIteratorIterator' ) ) {
|
4831 |
$size = 0;
|
4832 |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
|
4833 |
$size+=$file->getSize();
|
4834 |
-
}
|
4835 |
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
|
4836 |
return $size / 1024 / 1024;
|
4837 |
}
|
@@ -5429,20 +5497,27 @@ class MainWP_Child {
|
|
5429 |
function vulner_checker() {
|
5430 |
MainWP_Child_Vulnerability_Checker::Instance()->action();
|
5431 |
}
|
5432 |
-
|
5433 |
function time_capsule() {
|
5434 |
MainWP_Child_Timecapsule::Instance()->action();
|
5435 |
}
|
5436 |
-
|
5437 |
function wp_staging() {
|
5438 |
MainWP_Child_Staging::Instance()->action();
|
5439 |
}
|
5440 |
-
|
5441 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5442 |
$this->deactivation(false);
|
5443 |
-
MainWP_Helper::write( array( 'result' => 'success' ) );
|
5444 |
}
|
5445 |
-
|
5446 |
static function fix_for_custom_themes() {
|
5447 |
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
|
5448 |
include_once( ABSPATH . '/wp-admin/includes/screen.php' );
|
60 |
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action ) ) ) . '</mainwp>' );
|
61 |
}
|
62 |
|
63 |
+
// To fix verify nonce conflict #1
|
64 |
+
// this is fake nonce to fix some conflict of wp_verify_nonce
|
65 |
+
// just return false to unverify nonce, does not exit
|
66 |
+
if ($nonce == 'mainwp-bsm-unverify-nonce') {
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
$token = wp_get_session_token();
|
72 |
$i = wp_nonce_tick();
|
73 |
|
83 |
return 2;
|
84 |
}
|
85 |
|
86 |
+
// To fix verify nonce conflict #2
|
87 |
+
// this is fake post field to fix some conflict of wp_verify_nonce
|
88 |
+
// just return false to unverify nonce, does not exit
|
89 |
+
if ( isset($_POST[$action]) && ($_POST[$action] == 'mainwp-bsm-unverify-nonce')) {
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
@ob_start();
|
94 |
+
@debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
95 |
+
$stackTrace = "\n" . @ob_get_clean();
|
96 |
+
|
97 |
// Invalid nonce
|
98 |
+
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '<br/>Trace: ' .$stackTrace) ) ) . '</mainwp>' );
|
99 |
}
|
100 |
endif;
|
101 |
}
|
103 |
}
|
104 |
|
105 |
class MainWP_Child {
|
106 |
+
public static $version = '3.5';
|
107 |
private $update_version = '1.3';
|
108 |
|
109 |
private $callableFunctions = array(
|
168 |
'custom_post_type' => 'custom_post_type',
|
169 |
'backup_buddy' => 'backup_buddy',
|
170 |
'get_site_icon' => 'get_site_icon',
|
171 |
+
'vulner_checker' => 'vulner_checker',
|
172 |
+
'wp_staging' => 'wp_staging',
|
173 |
'disconnect' => 'disconnect',
|
174 |
'time_capsule' => 'time_capsule',
|
175 |
+
'extra_excution' => 'extra_execution',
|
176 |
);
|
177 |
|
178 |
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
|
199 |
$this->update();
|
200 |
$this->load_all_options();
|
201 |
$this->filterFunction = function($a) {
|
202 |
+
if ($a == null) { return false; }
|
203 |
+
if (is_object($a) && property_exists($a, "last_checked") && !property_exists($a, "checked"))
|
204 |
+
return false;
|
205 |
return $a;
|
206 |
+
};
|
207 |
$this->plugin_dir = dirname( $plugin_file );
|
208 |
$this->plugin_slug = plugin_basename( $plugin_file );
|
209 |
list ( $t1, $t2 ) = explode( '/', $this->plugin_slug );
|
213 |
$this->comments_and_clauses = '';
|
214 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
215 |
add_action( 'init', array( &$this, 'check_login' ), 1 );
|
216 |
+
add_action( 'init', array( &$this, 'parse_init' ), 9999 );
|
217 |
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
218 |
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
219 |
add_action( 'admin_head', array( &$this, 'admin_head' ) );
|
523 |
}
|
524 |
|
525 |
public function pre_current_active_plugins() {
|
526 |
+
if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] = 'yes') {
|
527 |
+
// to fix some premium plugins update notification
|
528 |
+
$current = get_site_transient( 'update_plugins' );
|
529 |
+
set_site_transient( 'update_plugins', $current );
|
530 |
+
|
531 |
+
$plugin_updates = get_plugin_updates();
|
532 |
+
set_site_transient( 'mainwp_update_plugins_cached', $plugin_updates, DAY_IN_SECONDS);
|
533 |
+
}
|
534 |
+
}
|
|
|
|
|
535 |
|
536 |
function checkOtherAuth() {
|
537 |
$auths = get_option( 'mainwp_child_auth' );
|
752 |
|
753 |
<?php if ( !$hide_connection_detail ) { ?>
|
754 |
<div class="mainwp-child-setting-tab connection-detail" <?php echo ('connection-detail' !== $shownPage) ? $hide_style : '' ; ?>>
|
755 |
+
<?php MainWP_Child_Server_Information::renderConnectionDetails(); ?>
|
756 |
</div>
|
757 |
<?php } ?>
|
758 |
|
891 |
<?php
|
892 |
}
|
893 |
|
894 |
+
function admin_init() {
|
895 |
if ( MainWP_Helper::isAdmin() && is_admin() ) {
|
896 |
MainWP_Clone::get()->init_ajax();
|
897 |
}
|
898 |
}
|
899 |
+
|
900 |
function admin_head() {
|
901 |
if (isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab') {
|
902 |
?>
|
932 |
MainWP_Helper::update_option( 'mainwp_child_uniqueId', '' );
|
933 |
}
|
934 |
}
|
935 |
+
|
936 |
?>
|
937 |
<div class="postbox">
|
938 |
<h2 class="hndle"><span><?php esc_html_e( 'Connection settings', 'mainwp-child' ); ?></span></h2>
|
1341 |
|
1342 |
remove_action( 'admin_init', 'send_frame_options_header' );
|
1343 |
remove_action( 'login_init', 'send_frame_options_header' );
|
1344 |
+
|
1345 |
// Call Heatmap
|
1346 |
if ( 'yes' === get_option( 'heatMapExtensionLoaded' ) ) {
|
1347 |
if ( ( '1' !== get_option( 'heatMapsIndividualOverrideSetting' ) && '0' !== get_option( 'heatMapEnabled' ) ) ||
|
1403 |
die();
|
1404 |
}
|
1405 |
}
|
1406 |
+
|
1407 |
// Init extensions
|
1408 |
// Handle fatal errors for those init if needed
|
1409 |
// OK
|
1411 |
MainWP_Child_Updraft_Plus_Backups::Instance()->updraftplus_init();
|
1412 |
MainWP_Child_Back_Up_Wordpress::Instance()->init();
|
1413 |
MainWP_Child_WP_Rocket::Instance()->init();
|
1414 |
+
MainWP_Child_Back_WP_Up::Instance()->init();
|
1415 |
MainWP_Child_Back_Up_Buddy::Instance();
|
1416 |
+
MainWP_Child_Wordfence::Instance()->wordfence_init();
|
1417 |
MainWP_Child_Timecapsule::Instance()->init();
|
1418 |
+
MainWP_Child_Staging::Instance()->init();
|
1419 |
MainWP_Child_Branding::Instance()->branding_init();
|
1420 |
MainWP_Client_Report::Instance()->creport_init();
|
1421 |
MainWP_Child_Pagespeed::Instance()->init();
|
1422 |
MainWP_Child_Links_Checker::Instance()->init();
|
1423 |
+
|
1424 |
global $_wp_submenu_nopriv;
|
1425 |
if ($_wp_submenu_nopriv === null)
|
1426 |
$_wp_submenu_nopriv = array(); // fix warning
|
1427 |
+
|
1428 |
//Call the function required
|
1429 |
if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) {
|
1430 |
define( 'DOING_CRON', true );
|
1431 |
// ob_start();
|
1432 |
// require_once( ABSPATH . 'wp-admin/admin.php' );
|
1433 |
+
// ob_end_clean();
|
1434 |
+
|
1435 |
+
MainWP_Helper::handle_fatal_error();
|
1436 |
MainWP_Child::fix_for_custom_themes();
|
1437 |
call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) );
|
1438 |
} else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
|
1442 |
} else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
1443 |
MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) );
|
1444 |
}
|
1445 |
+
|
1446 |
+
// going to retire soon
|
1447 |
if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) {
|
1448 |
new MainWP_Keyword_Links();
|
1449 |
if ( ! is_admin() ) {
|
1475 |
$nossl = get_option( 'mainwp_child_nossl' );
|
1476 |
$serverNoSsl = ( isset( $pNossl ) && 1 === (int) $pNossl );
|
1477 |
|
1478 |
+
if ( ( 1 === (int) $nossl ) || $serverNoSsl ) {
|
1479 |
$auth = hash_equals( md5( $func . $nonce . get_option( 'mainwp_child_nossl_key' ) ), base64_decode( $signature ) );
|
1480 |
} else {
|
1481 |
$auth = openssl_verify( $func . $nonce, base64_decode( $signature ), base64_decode( get_option( 'mainwp_child_pubkey' ) ) );
|
1526 |
}
|
1527 |
|
1528 |
public function http_request_reject_unsafe_urls( $r, $url ) {
|
1529 |
+
$r['reject_unsafe_urls'] = false;
|
1530 |
if ( isset($_POST['wpadmin_user']) && !empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && !empty($_POST['wpadmin_passwd']) ) {
|
1531 |
$auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] );
|
1532 |
$r['headers']['Authorization'] = "Basic $auth";
|
1533 |
+
}
|
1534 |
return $r;
|
1535 |
}
|
1536 |
+
|
1537 |
/**
|
1538 |
* Functions to support core functionality
|
1539 |
*/
|
1641 |
// to fix activate issue
|
1642 |
if ('quotes-collection/quotes-collection.php' == $args['slug']) {
|
1643 |
activate_plugin( $path . $fileName, '', false, true );
|
1644 |
+
} else {
|
1645 |
activate_plugin( $path . $fileName, '' /* false, true */ );
|
1646 |
}
|
1647 |
do_action( 'activate_plugin', $args['slug'], null );
|
1784 |
|
1785 |
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
1786 |
|
1787 |
+
// to fix
|
1788 |
+
@wp_version_check();
|
1789 |
+
@wp_update_themes();
|
1790 |
+
@wp_update_plugins();
|
1791 |
+
|
1792 |
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
|
1793 |
$translations = explode( ',', urldecode( $_POST['list'] ) );
|
1794 |
$all_language_updates = wp_get_translation_updates();
|
1841 |
}
|
1842 |
include_once( ABSPATH . '/wp-admin/includes/file.php' );
|
1843 |
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
1844 |
+
include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
|
1845 |
+
|
1846 |
$information = array();
|
1847 |
$information['upgrades'] = array();
|
1848 |
$mwp_premium_updates_todo = array();
|
1882 |
global $wp_current_filter;
|
1883 |
$wp_current_filter[] = 'load-plugins.php';
|
1884 |
@wp_update_plugins();
|
1885 |
+
|
1886 |
// trick to prevent some premium plugins re-create update info
|
1887 |
remove_all_filters('pre_set_site_transient_update_plugins');
|
1888 |
+
|
|
|
1889 |
$information['plugin_updates'] = get_plugin_updates();
|
1890 |
|
1891 |
$plugins = explode( ',', urldecode( $_POST['list'] ) );
|
1906 |
if ( count( $plugins ) > 0 ) {
|
1907 |
//@see wp-admin/update.php
|
1908 |
$failed = true;
|
1909 |
+
// to fix update of Yithemes premiums plugins that hooked to upgrader_pre_download
|
1910 |
+
$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
|
1911 |
+
$nonce = 'bulk-update-plugins';
|
1912 |
+
|
1913 |
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
|
1914 |
$result = $upgrader->bulk_upgrade( $plugins );
|
1915 |
|
1916 |
if ( ! empty( $result ) ) {
|
1917 |
foreach ( $result as $plugin => $info ) {
|
1918 |
if ( empty( $info ) ) {
|
1919 |
+
|
1920 |
$information['upgrades'][ $plugin ] = false;
|
1921 |
+
// try to fix if that is premiums update
|
1922 |
+
$api = apply_filters( 'plugins_api', false, 'plugin_information', array( 'slug' => $plugin ) );
|
1923 |
+
|
1924 |
+
if ( !is_wp_error( $api ) && !empty($api)) {
|
1925 |
+
if ( isset($api->download_link) ) {
|
1926 |
+
$res = $upgrader->install($api->download_link);
|
1927 |
+
if ( !is_wp_error( $res ) && !(is_null( $res )) ) {
|
1928 |
+
$information['upgrades'][ $plugin ] = true;
|
1929 |
+
}
|
1930 |
+
}
|
1931 |
+
}
|
1932 |
+
|
1933 |
} else {
|
1934 |
$information['upgrades'][ $plugin ] = true;
|
1935 |
// to fix logging update
|
2272 |
if ( isset( $_POST['_ezin_post_category'] ) ) {
|
2273 |
$new_post['_ezin_post_category'] = maybe_unserialize( base64_decode( $_POST['_ezin_post_category'] ) );
|
2274 |
}
|
2275 |
+
|
2276 |
+
$others = array();
|
2277 |
if ( isset( $_POST['featured_image_data'] ) && !empty($_POST['featured_image_data'])) {
|
2278 |
$others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] ));
|
2279 |
+
}
|
2280 |
+
|
2281 |
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
|
2282 |
|
2283 |
if (is_array($res) && isset($res['error'])) {
|
2514 |
$extra = $_POST['extra'];
|
2515 |
$userId = $_POST['id'];
|
2516 |
$user_pass = $_POST['user_pass'];
|
2517 |
+
$failed = false;
|
2518 |
+
|
2519 |
global $current_user;
|
2520 |
+
$reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0;
|
2521 |
include_once( ABSPATH . '/wp-admin/includes/user.php' );
|
2522 |
|
2523 |
if ( 'delete' === $action ) {
|
2539 |
} else {
|
2540 |
$failed = true;
|
2541 |
}
|
2542 |
+
} else if ( 'update_user' === $action ) {
|
2543 |
+
$my_user = $_POST['extra'];
|
2544 |
if (is_array($my_user)) {
|
2545 |
foreach($my_user as $idx => $val) {
|
2546 |
if ($val === 'donotupdate' || (empty($val) && $idx !== 'role')) {
|
2547 |
unset($my_user[$idx]);
|
2548 |
+
}
|
2549 |
+
}
|
2550 |
+
$result = $this->edit_user( $userId, $my_user );
|
2551 |
if (is_array($result) && isset($result['error'])) {
|
2552 |
$information['error'] = $result['error'];
|
2553 |
+
}
|
2554 |
} else {
|
2555 |
$failed = true;
|
2556 |
}
|
2557 |
} else {
|
2558 |
$failed = true;
|
2559 |
}
|
2560 |
+
|
2561 |
if ($failed)
|
2562 |
$information['status'] = 'FAIL';
|
2563 |
|
2566 |
if ('update_user' === $action && isset($_POST['optimize']) && !empty($_POST['optimize'])) {
|
2567 |
$information['users'] = $this->get_all_users_int(500); // to fix
|
2568 |
}
|
2569 |
+
|
2570 |
}
|
2571 |
MainWP_Helper::write( $information );
|
2572 |
}
|
2574 |
function edit_user( $user_id, $data) {
|
2575 |
$wp_roles = wp_roles();
|
2576 |
$user = new stdClass;
|
2577 |
+
|
2578 |
$update = true;
|
2579 |
+
|
2580 |
+
if ( $user_id ) {
|
2581 |
$user->ID = (int) $user_id;
|
2582 |
+
$userdata = get_userdata( $user_id );
|
2583 |
$user->user_login = wp_slash( $userdata->user_login );
|
2584 |
} else {
|
2585 |
return array('error' => 'ERROR: Empty user id.');
|
2602 |
// If the new role isn't editable by the logged-in user die with error
|
2603 |
$editable_roles = get_editable_roles();
|
2604 |
if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) )
|
2605 |
+
return array('error' => 'You can’t give users that role.');
|
2606 |
+
}
|
2607 |
|
2608 |
$email = '';
|
2609 |
if ( isset( $data['email'] ) )
|
2612 |
if ( !empty( $email ) )
|
2613 |
$user->user_email = sanitize_text_field( wp_unslash( $email ) );
|
2614 |
else
|
2615 |
+
$user->user_email = $userdata->user_email;
|
2616 |
+
|
2617 |
if ( isset( $data['url'] ) ) {
|
2618 |
if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) {
|
2619 |
$user->user_url = '';
|
2623 |
$user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
|
2624 |
}
|
2625 |
}
|
2626 |
+
|
2627 |
if ( isset( $data['first_name'] ) )
|
2628 |
+
$user->first_name = sanitize_text_field( $data['first_name'] );
|
2629 |
if ( isset( $data['last_name'] ) )
|
2630 |
+
$user->last_name = sanitize_text_field( $data['last_name'] );
|
2631 |
if ( isset( $data['nickname'] ) && !empty($data['nickname']))
|
2632 |
+
$user->nickname = sanitize_text_field( $data['nickname'] );
|
2633 |
if ( isset( $data['display_name'] ) )
|
2634 |
$user->display_name = sanitize_text_field( $data['display_name'] );
|
2635 |
if ( isset( $data['description'] ) )
|
2636 |
$user->description = trim( $data['description'] );
|
2637 |
+
|
2638 |
$errors = new WP_Error();
|
2639 |
|
2640 |
/* checking that username has been typed */
|
2642 |
$errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) );
|
2643 |
|
2644 |
do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
|
2645 |
+
|
2646 |
if (!empty($pass1) || !empty($pass2)) {
|
2647 |
// Check for blank password when adding a user.
|
2648 |
if ( ! $update && empty( $pass1 ) ) {
|
2664 |
} else {
|
2665 |
$user->user_pass = $userdata->user_pass;
|
2666 |
}
|
2667 |
+
|
2668 |
/** This filter is documented in wp-includes/user.php */
|
2669 |
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
2670 |
|
2688 |
foreach ( $errors->get_error_messages() as $message ) {
|
2689 |
if ( is_string( $message ) )
|
2690 |
$error_str .= ' ' . esc_html( strip_tags( $message ) );
|
2691 |
+
|
2692 |
}
|
2693 |
return array( 'error' => $error_str );
|
2694 |
}
|
2695 |
|
2696 |
$user_id = wp_update_user( $user );
|
2697 |
+
|
2698 |
return $user_id;
|
2699 |
}
|
2700 |
+
|
2701 |
function get_user_to_edit( $user_id ) {
|
2702 |
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
2703 |
+
$profileuser = get_user_to_edit($user_id);
|
2704 |
+
|
2705 |
$edit_data = array();
|
2706 |
if (is_object($profileuser)) {
|
2707 |
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
|
2710 |
$edit_data['first_name'] = $profileuser->first_name;
|
2711 |
$edit_data['last_name'] = $profileuser->last_name;
|
2712 |
$edit_data['nickname'] = $profileuser->nickname;
|
2713 |
+
|
2714 |
$public_display = array();
|
2715 |
$public_display['display_nickname'] = $profileuser->nickname;
|
2716 |
$public_display['display_username'] = $profileuser->user_login;
|
2735 |
$edit_data['public_display'] = $public_display;
|
2736 |
$edit_data['display_name'] = $profileuser->display_name;
|
2737 |
$edit_data['user_email'] = $profileuser->user_email;
|
2738 |
+
$edit_data['user_url'] = $profileuser->user_url;
|
2739 |
foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
|
2740 |
$edit_data['contact_methods'][$name] = $profileuser->$name;
|
2741 |
+
}
|
2742 |
$edit_data['description'] = $profileuser->description;
|
2743 |
}
|
2744 |
return $edit_data;
|
2745 |
}
|
2746 |
+
|
2747 |
//todo: backwards compatible: wp_set_comment_status ?
|
2748 |
function comment_action() {
|
2749 |
//Read form data
|
3263 |
$security['scripts_version'] = true;
|
3264 |
$security['styles_version'] = true;
|
3265 |
$security['generator_version'] = true;
|
|
|
|
|
3266 |
MainWP_Security::remove_generator_version( true );
|
3267 |
$information['versions'] = 'Y';
|
3268 |
}
|
3269 |
|
3270 |
+
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
|
3271 |
+
$security['registered_versions'] = true;
|
3272 |
+
$information['registered_versions'] = 'Y';
|
3273 |
+
}
|
3274 |
+
|
3275 |
if ( 'all' === $_POST['feature'] || 'admin' === $_POST['feature'] ) {
|
3276 |
$information['admin'] = ( ! MainWP_Security::admin_user_ok() ? 'N' : 'Y' );
|
3277 |
}
|
3327 |
$information['versions'] = 'N';
|
3328 |
}
|
3329 |
|
3330 |
+
if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) {
|
3331 |
+
$security['registered_versions'] = false;
|
3332 |
+
$information['registered_versions'] = 'N';
|
3333 |
+
}
|
3334 |
if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) {
|
3335 |
$security['readme'] = false;
|
3336 |
$information['readme'] = MainWP_Security::remove_readme_ok();
|
3360 |
$information['php_reporting'] = ( ! MainWP_Security::remove_php_reporting_ok() ? 'N' : 'Y' );
|
3361 |
$information['versions'] = ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok()
|
3362 |
? 'N' : 'Y' );
|
3363 |
+
$information['registered_versions'] = ( MainWP_Security::remove_registered_versions_ok() ? 'Y' : 'N' );
|
3364 |
$information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' );
|
3365 |
$information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' );
|
3366 |
|
3557 |
|
3558 |
@wp_update_plugins();
|
3559 |
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
3560 |
+
|
3561 |
$plugin_updates = get_plugin_updates();
|
3562 |
if ( is_array( $plugin_updates ) ) {
|
3563 |
$information['plugin_updates'] = array();
|
3569 |
|
3570 |
$information['plugin_updates'][ $slug ] = $plugin_update;
|
3571 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3572 |
}
|
3573 |
|
3574 |
+
// to fix bug
|
3575 |
+
$info_update_plugins_cached = get_site_transient( 'mainwp_update_plugins_cached' );
|
3576 |
+
if ( is_array( $info_update_plugins_cached ) && ( count( $info_update_plugins_cached ) > 0 ) ) {
|
3577 |
+
if (!isset($information['plugin_updates'])) {
|
3578 |
+
$information['plugin_updates'] = array();
|
3579 |
+
}
|
3580 |
+
foreach( $info_update_plugins_cached as $slug => $plugin_update ) {
|
3581 |
+
if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
|
3582 |
+
$information['plugin_updates'][ $slug ] = $plugin_update;
|
3583 |
+
}
|
3584 |
+
}
|
3585 |
+
}
|
3586 |
+
// end fix
|
3587 |
+
|
3588 |
if ( null !== $this->filterFunction ) {
|
3589 |
remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
|
3590 |
}
|
3673 |
if ( ! MainWP_Security::remove_scripts_version_ok() || ! MainWP_Security::remove_styles_version_ok() || ! MainWP_Security::remove_generator_version_ok() ) {
|
3674 |
$securityIssuess ++;
|
3675 |
}
|
3676 |
+
if ( ! MainWP_Security::remove_registered_versions_ok() ) {
|
3677 |
+
$securityIssuess ++;
|
3678 |
+
}
|
3679 |
if ( ! MainWP_Security::admin_user_ok() ) {
|
3680 |
$securityIssuess ++;
|
3681 |
}
|
3695 |
$information['categories'] = $categories;
|
3696 |
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
|
3697 |
if ($get_file_size) {
|
3698 |
+
$max_exe = ini_get( 'max_execution_time' ); // to fix issue of some hosts have limit of execution time
|
3699 |
+
if ($max_exe > 20) {
|
3700 |
+
$information['totalsize'] = $this->getTotalFileSize();
|
3701 |
+
}
|
3702 |
}
|
3703 |
$information['dbsize'] = MainWP_Child_DB::get_size();
|
3704 |
|
3730 |
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
|
3731 |
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
|
3732 |
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
|
3733 |
+
|
3734 |
try {
|
3735 |
do_action('mainwp_child_site_stats');
|
3736 |
} catch(Exception $e) {
|
3737 |
+
|
3738 |
}
|
3739 |
+
|
3740 |
if ( isset( $_POST['othersData'] ) ) {
|
3741 |
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
|
3742 |
if ( ! is_array( $othersData ) ) {
|
3743 |
$othersData = array();
|
3744 |
+
}
|
3745 |
+
|
3746 |
try{
|
3747 |
+
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
3748 |
} catch(Exception $e) {
|
3749 |
// do not exit
|
3750 |
}
|
3779 |
$favi = $favi_url = get_site_icon_url();
|
3780 |
}
|
3781 |
|
3782 |
+
if ( empty( $favi ) ) {
|
3783 |
if ( file_exists( ABSPATH . 'favicon.ico' ) ) {
|
3784 |
$favi = 'favicon.ico';
|
3785 |
} else if ( file_exists( ABSPATH . 'favicon.png' ) ) {
|
3949 |
$link_count = new WPSEO_Link_Column_Count();
|
3950 |
$link_count->set( $post_ids );
|
3951 |
}
|
3952 |
+
foreach ( $posts as $post ) {
|
3953 |
$outPost = array();
|
3954 |
$outPost['id'] = $post->ID;
|
3955 |
$outPost['post_type'] = $post->post_type;
|
3963 |
} else {
|
3964 |
$outPost['dts'] = strtotime( $post->post_modified_gmt );
|
3965 |
}
|
3966 |
+
|
3967 |
if ($post->post_status == 'future') {
|
3968 |
$outPost['dts'] = strtotime( $post->post_date_gmt );
|
3969 |
}
|
3970 |
+
|
3971 |
$usr = get_user_by( 'id', $post->post_author );
|
3972 |
$outPost['author'] = ! empty( $usr ) ? $usr->user_nicename : 'removed';
|
3973 |
$categoryObjects = get_the_category( $post->ID );
|
4207 |
global $wpdb;
|
4208 |
|
4209 |
add_filter( 'posts_where', array( &$this, 'posts_where' ) );
|
4210 |
+
$where_post_date = isset($_POST['where_post_date']) && !empty($_POST['where_post_date']) ? true : false;
|
4211 |
if ( isset( $_POST['postId'] ) ) {
|
4212 |
$this->posts_where_suffix .= " AND $wpdb->posts.ID = " . $_POST['postId'];
|
4213 |
} else if ( isset( $_POST['userId'] ) ) {
|
4385 |
return;
|
4386 |
}
|
4387 |
}
|
4388 |
+
|
4389 |
foreach ( $themes as $idx => $themeToDelete ) {
|
4390 |
if ( $themeToDelete !== $theme_name ) {
|
4391 |
$theTheme = wp_get_theme( $themeToDelete );
|
4465 |
if ('quotes-collection/quotes-collection.php' == $plugin) {
|
4466 |
activate_plugin( $plugin, '', false, true );
|
4467 |
do_action( 'activate_plugin', $plugin, null );
|
4468 |
+
} else {
|
4469 |
activate_plugin( $plugin );
|
4470 |
}
|
4471 |
}
|
4504 |
$all_plugins = get_plugins();
|
4505 |
foreach ( $plugins as $idx => $plugin ) {
|
4506 |
if ( $plugin !== $this->plugin_slug ) {
|
4507 |
+
if ( isset( $all_plugins[ $plugin ] ) ) {
|
4508 |
if (is_plugin_active($plugin)) {
|
4509 |
$thePlugin = get_plugin_data( $plugin );
|
4510 |
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
4624 |
|
4625 |
function get_all_users_int($number = false) {
|
4626 |
$allusers = array();
|
4627 |
+
|
4628 |
$params = array();
|
4629 |
if ($number)
|
4630 |
$params['number'] = $number;
|
4631 |
+
|
4632 |
$new_users = get_users($params);
|
4633 |
if ( is_array( $new_users ) ) {
|
4634 |
foreach ( $new_users as $new_user ) {
|
4652 |
return $allusers;
|
4653 |
}
|
4654 |
|
4655 |
+
function search_users() {
|
4656 |
+
|
4657 |
$search_user_role = array();
|
4658 |
$check_users_role = false;
|
4659 |
+
|
4660 |
if (isset($_POST['role']) && !empty($_POST['role'])) {
|
4661 |
$check_users_role = true;
|
4662 |
$all_users_role = $this->get_all_users(true);
|
4663 |
foreach($all_users_role as $user) {
|
4664 |
+
$search_user_role[] = $user['id'];
|
4665 |
}
|
4666 |
unset($all_users_role);
|
4667 |
+
}
|
4668 |
+
|
4669 |
$columns = explode( ',', $_POST['search_columns'] );
|
4670 |
$allusers = array();
|
4671 |
$exclude = array();
|
4672 |
+
|
4673 |
foreach ( $columns as $col ) {
|
4674 |
if ( empty( $col ) ) {
|
4675 |
continue;
|
4681 |
'search_columns' => array( $col ),
|
4682 |
'query_orderby' => array( $col ),
|
4683 |
'exclude' => $exclude,
|
4684 |
+
) );
|
4685 |
if ( ! empty( $user_query->results ) ) {
|
4686 |
foreach ( $user_query->results as $new_user ) {
|
4687 |
if ($check_users_role) {
|
4708 |
}
|
4709 |
}
|
4710 |
}
|
4711 |
+
|
4712 |
MainWP_Helper::write( $allusers );
|
4713 |
}
|
4714 |
|
4739 |
}
|
4740 |
|
4741 |
function activation() {
|
4742 |
+
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
4743 |
+
if ($mu_plugin_enabled)
|
4744 |
+
return;
|
4745 |
+
|
4746 |
$to_delete = array(
|
4747 |
'mainwp_child_pubkey',
|
4748 |
'mainwp_child_nonce',
|
4765 |
}
|
4766 |
|
4767 |
function deactivation( $deact = true) {
|
4768 |
+
|
4769 |
+
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
4770 |
+
if ($mu_plugin_enabled)
|
4771 |
+
return;
|
4772 |
+
|
4773 |
$to_delete = array(
|
4774 |
'mainwp_child_pubkey',
|
4775 |
'mainwp_child_nonce',
|
4787 |
wp_cache_delete( $delete, 'options' );
|
4788 |
}
|
4789 |
}
|
4790 |
+
|
4791 |
if ($deact)
|
4792 |
do_action( 'mainwp_child_deactivation' );
|
4793 |
}
|
4894 |
}
|
4895 |
}
|
4896 |
}
|
4897 |
+
// to fix for window host, performance not good?
|
4898 |
+
if ( class_exists( 'RecursiveIteratorIterator' ) ) {
|
4899 |
$size = 0;
|
4900 |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
|
4901 |
$size+=$file->getSize();
|
4902 |
+
}
|
4903 |
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
|
4904 |
return $size / 1024 / 1024;
|
4905 |
}
|
5497 |
function vulner_checker() {
|
5498 |
MainWP_Child_Vulnerability_Checker::Instance()->action();
|
5499 |
}
|
5500 |
+
|
5501 |
function time_capsule() {
|
5502 |
MainWP_Child_Timecapsule::Instance()->action();
|
5503 |
}
|
5504 |
+
|
5505 |
function wp_staging() {
|
5506 |
MainWP_Child_Staging::Instance()->action();
|
5507 |
}
|
5508 |
+
|
5509 |
+
function extra_execution() {
|
5510 |
+
$post = $_POST;
|
5511 |
+
$information = array();
|
5512 |
+
$information = apply_filters('mainwp_child_extra_execution', $information, $post);
|
5513 |
+
MainWP_Helper::write( $information );
|
5514 |
+
}
|
5515 |
+
|
5516 |
+
function disconnect() {
|
5517 |
$this->deactivation(false);
|
5518 |
+
MainWP_Helper::write( array( 'result' => 'success' ) );
|
5519 |
}
|
5520 |
+
|
5521 |
static function fix_for_custom_themes() {
|
5522 |
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
|
5523 |
include_once( ABSPATH . '/wp-admin/includes/screen.php' );
|
class/class-mainwp-client-report.php
CHANGED
@@ -12,27 +12,27 @@ class MainWP_Client_Report {
|
|
12 |
}
|
13 |
|
14 |
public function init() {
|
15 |
-
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
16 |
add_filter( 'wp_stream_connectors', array( 'MainWP_Client_Report', 'init_stream_connectors' ), 10, 1 );
|
17 |
add_filter( 'mainwp_client_reports_connectors', array( 'MainWP_Client_Report', 'init_report_connectors' ), 10, 1 );
|
18 |
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
|
19 |
}
|
20 |
|
21 |
// ok
|
22 |
-
public function syncOthersData( $information, $data = array() ) {
|
23 |
-
if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) {
|
24 |
$creport_sync_data = array();
|
25 |
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
26 |
$creport_sync_data['firsttime_activated'] = $firsttime;
|
27 |
}
|
28 |
if ( !empty( $creport_sync_data ) ) {
|
29 |
$information['syncClientReportData'] = $creport_sync_data;
|
30 |
-
}
|
31 |
-
}
|
32 |
return $information;
|
33 |
}
|
34 |
|
35 |
-
|
36 |
public static function init_stream_connectors( $classes ) {
|
37 |
$connectors = array(
|
38 |
'Backups',
|
@@ -87,6 +87,9 @@ class MainWP_Client_Report {
|
|
87 |
case 'wordfence':
|
88 |
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
|
89 |
break;
|
|
|
|
|
|
|
90 |
}
|
91 |
}
|
92 |
|
@@ -377,7 +380,7 @@ class MainWP_Client_Report {
|
|
377 |
continue;
|
378 |
}
|
379 |
} else if ( 'mainwp_backups' === $context ) {
|
380 |
-
if ( $record->context !== 'mainwp_backups' && $record->context !== 'backwpup_backups' && $record->context !== 'updraftplus_backups' && $record->context !== 'backupwordpress_backups' && $record->context !== 'backupbuddy_backups' ) {
|
381 |
continue;
|
382 |
}
|
383 |
} else if ( 'mainwp_sucuri' === $context ) {
|
@@ -669,28 +672,28 @@ class MainWP_Client_Report {
|
|
669 |
case 'status': // sucuri cases
|
670 |
case 'webtrust':
|
671 |
if ( 'mainwp_sucuri' === $context ) {
|
672 |
-
|
673 |
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
|
674 |
if (!empty($scan_data)) {
|
675 |
-
$scan_data = maybe_unserialize( base64_decode( $scan_data ) );
|
676 |
if ( is_array( $scan_data ) ) {
|
677 |
-
|
678 |
$blacklisted = $scan_data['blacklisted'];
|
679 |
$malware_exists = $scan_data['malware_exists'];
|
680 |
-
|
681 |
$status = array();
|
682 |
if ( $blacklisted ) {
|
683 |
$status[] = __( 'Site Blacklisted', 'mainwp-child' ); }
|
684 |
if ( $malware_exists ) {
|
685 |
$status[] = __( 'Site With Warnings', 'mainwp-child' ); }
|
686 |
-
|
687 |
if ($data == 'status') {
|
688 |
$token_values[$token] = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' );
|
689 |
} else if ($data == 'webtrust') {
|
690 |
$token_values[$token] = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' );
|
691 |
-
}
|
692 |
-
}
|
693 |
-
|
694 |
} else {
|
695 |
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
|
696 |
}
|
12 |
}
|
13 |
|
14 |
public function init() {
|
15 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
16 |
add_filter( 'wp_stream_connectors', array( 'MainWP_Client_Report', 'init_stream_connectors' ), 10, 1 );
|
17 |
add_filter( 'mainwp_client_reports_connectors', array( 'MainWP_Client_Report', 'init_report_connectors' ), 10, 1 );
|
18 |
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
|
19 |
}
|
20 |
|
21 |
// ok
|
22 |
+
public function syncOthersData( $information, $data = array() ) {
|
23 |
+
if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) {
|
24 |
$creport_sync_data = array();
|
25 |
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
26 |
$creport_sync_data['firsttime_activated'] = $firsttime;
|
27 |
}
|
28 |
if ( !empty( $creport_sync_data ) ) {
|
29 |
$information['syncClientReportData'] = $creport_sync_data;
|
30 |
+
}
|
31 |
+
}
|
32 |
return $information;
|
33 |
}
|
34 |
|
35 |
+
|
36 |
public static function init_stream_connectors( $classes ) {
|
37 |
$connectors = array(
|
38 |
'Backups',
|
87 |
case 'wordfence':
|
88 |
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
|
89 |
break;
|
90 |
+
case 'wptimecapsule':
|
91 |
+
MainWP_Child_Timecapsule::Instance()->do_reports_log( $ext );
|
92 |
+
break;
|
93 |
}
|
94 |
}
|
95 |
|
380 |
continue;
|
381 |
}
|
382 |
} else if ( 'mainwp_backups' === $context ) {
|
383 |
+
if ( $record->context !== 'mainwp_backups' && $record->context !== 'backwpup_backups' && $record->context !== 'updraftplus_backups' && $record->context !== 'backupwordpress_backups' && $record->context !== 'backupbuddy_backups' && $record->context !== 'wptimecapsule_backups') {
|
384 |
continue;
|
385 |
}
|
386 |
} else if ( 'mainwp_sucuri' === $context ) {
|
672 |
case 'status': // sucuri cases
|
673 |
case 'webtrust':
|
674 |
if ( 'mainwp_sucuri' === $context ) {
|
675 |
+
|
676 |
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
|
677 |
if (!empty($scan_data)) {
|
678 |
+
$scan_data = maybe_unserialize( base64_decode( $scan_data ) );
|
679 |
if ( is_array( $scan_data ) ) {
|
680 |
+
|
681 |
$blacklisted = $scan_data['blacklisted'];
|
682 |
$malware_exists = $scan_data['malware_exists'];
|
683 |
+
|
684 |
$status = array();
|
685 |
if ( $blacklisted ) {
|
686 |
$status[] = __( 'Site Blacklisted', 'mainwp-child' ); }
|
687 |
if ( $malware_exists ) {
|
688 |
$status[] = __( 'Site With Warnings', 'mainwp-child' ); }
|
689 |
+
|
690 |
if ($data == 'status') {
|
691 |
$token_values[$token] = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' );
|
692 |
} else if ($data == 'webtrust') {
|
693 |
$token_values[$token] = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' );
|
694 |
+
}
|
695 |
+
}
|
696 |
+
|
697 |
} else {
|
698 |
$token_values[ $token ] = $this->get_stream_meta_data( $record, $data );
|
699 |
}
|
class/class-mainwp-keyword-links.php
CHANGED
@@ -343,7 +343,8 @@ class MainWP_Keyword_Links {
|
|
343 |
$this->link_exact_match = $link->exact_match;
|
344 |
$this->link_case_sensitive = $link->case_sensitive;
|
345 |
$keywords = $this->explode_multi( $link->keyword );
|
346 |
-
usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
|
|
347 |
$replace_cs = $link->case_sensitive ? 's' : 'is';
|
348 |
//print_r($keywords);
|
349 |
foreach ( $keywords as $keyword ) {
|
@@ -386,6 +387,10 @@ class MainWP_Keyword_Links {
|
|
386 |
return $content;
|
387 |
}
|
388 |
|
|
|
|
|
|
|
|
|
389 |
public function keyword_mark( $matches ) {
|
390 |
|
391 |
if ( preg_match( '/^[<{].*?[>}]$/is', $matches[1] ) ) {
|
343 |
$this->link_exact_match = $link->exact_match;
|
344 |
$this->link_case_sensitive = $link->case_sensitive;
|
345 |
$keywords = $this->explode_multi( $link->keyword );
|
346 |
+
//usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
347 |
+
usort( $keywords, array($this, 'usort_callback_func') );
|
348 |
$replace_cs = $link->case_sensitive ? 's' : 'is';
|
349 |
//print_r($keywords);
|
350 |
foreach ( $keywords as $keyword ) {
|
387 |
return $content;
|
388 |
}
|
389 |
|
390 |
+
private function usort_callback_func($a, $b) {
|
391 |
+
return strlen($a)<strlen($b);
|
392 |
+
}
|
393 |
+
|
394 |
public function keyword_mark( $matches ) {
|
395 |
|
396 |
if ( preg_match( '/^[<{].*?[>}]$/is', $matches[1] ) ) {
|
class/class-mainwp-security.php
CHANGED
@@ -9,8 +9,7 @@ class MainWP_Security {
|
|
9 |
// MainWP_Security::remove_plugin_update();
|
10 |
// MainWP_Security::remove_theme_update();
|
11 |
MainWP_Security::remove_php_reporting();
|
12 |
-
MainWP_Security::
|
13 |
-
MainWP_Security::remove_styles_version();
|
14 |
MainWP_Security::remove_generator_version();
|
15 |
MainWP_Security::remove_readme();
|
16 |
|
@@ -256,20 +255,6 @@ class MainWP_Security {
|
|
256 |
//Removed version information for scripts/stylesheets
|
257 |
public static function remove_scripts_version_ok() {
|
258 |
return self::get_security_option( 'scripts_version' );
|
259 |
-
|
260 |
-
// global $wp_scripts;
|
261 |
-
// if (!is_a($wp_scripts, 'WP_Scripts'))
|
262 |
-
// {
|
263 |
-
// return true;
|
264 |
-
// }
|
265 |
-
// foreach ($wp_scripts->registered as $handle => $script)
|
266 |
-
// {
|
267 |
-
// if ($wp_scripts->registered[$handle]->ver != null)
|
268 |
-
// {
|
269 |
-
// return false;
|
270 |
-
// }
|
271 |
-
// }
|
272 |
-
// return true;
|
273 |
}
|
274 |
|
275 |
public static function remove_script_versions( $src ) {
|
@@ -280,13 +265,29 @@ class MainWP_Security {
|
|
280 |
|
281 |
return $src;
|
282 |
}
|
283 |
-
// else if ( false === strpos( $src, '?ver=' ) ) {
|
284 |
-
// self::update_security_option('scripts_version', true);
|
285 |
-
// }
|
286 |
-
|
287 |
return $src;
|
288 |
}
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
public static function remove_generator_version_ok() {
|
292 |
return self::get_security_option( 'generator_version' );
|
@@ -313,27 +314,10 @@ class MainWP_Security {
|
|
313 |
|
314 |
return $src;
|
315 |
}
|
316 |
-
// else if ( false === strpos( $src, '?ver=' ) ) {
|
317 |
-
// self::update_security_option('styles_version', true);
|
318 |
-
// }
|
319 |
-
|
320 |
return $src;
|
321 |
}
|
322 |
|
323 |
-
|
324 |
-
if ( $force || self::get_security_option( 'scripts_version' ) ) {
|
325 |
-
global $wp_scripts;
|
326 |
-
if ( !( $wp_scripts instanceof WP_Scripts ) ) {
|
327 |
-
return;
|
328 |
-
}
|
329 |
-
|
330 |
-
foreach ( $wp_scripts->registered as $handle => $script ) {
|
331 |
-
$wp_scripts->registered[ $handle ]->ver = null;
|
332 |
-
}
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
public static function remove_readme( $force = false ) {
|
337 |
if ( $force || self::get_security_option( 'readme' ) ) {
|
338 |
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
|
339 |
if ( ! @unlink( ABSPATH . 'readme.html' ) ) {
|
@@ -357,34 +341,6 @@ class MainWP_Security {
|
|
357 |
|
358 |
public static function remove_styles_version_ok() {
|
359 |
return self::get_security_option( 'styles_version' );
|
360 |
-
|
361 |
-
// global $wp_styles;
|
362 |
-
// if (!is_a($wp_styles, 'WP_Styles'))
|
363 |
-
// {
|
364 |
-
// return true;
|
365 |
-
// }
|
366 |
-
//
|
367 |
-
// foreach ($wp_styles->registered as $handle => $style)
|
368 |
-
// {
|
369 |
-
// if ($wp_styles->registered[$handle]->ver != null)
|
370 |
-
// {
|
371 |
-
// return false;
|
372 |
-
// }
|
373 |
-
// }
|
374 |
-
// return true;
|
375 |
-
}
|
376 |
-
|
377 |
-
public static function remove_styles_version( $force = true ) {
|
378 |
-
if ( $force || self::get_security_option( 'styles_version' ) ) {
|
379 |
-
global $wp_styles;
|
380 |
-
if ( !( $wp_styles instanceof WP_Styles ) ) {
|
381 |
-
return;
|
382 |
-
}
|
383 |
-
|
384 |
-
foreach ( $wp_styles->registered as $handle => $style ) {
|
385 |
-
$wp_styles->registered[ $handle ]->ver = null;
|
386 |
-
}
|
387 |
-
}
|
388 |
}
|
389 |
|
390 |
//Admin user name is not admin
|
9 |
// MainWP_Security::remove_plugin_update();
|
10 |
// MainWP_Security::remove_theme_update();
|
11 |
MainWP_Security::remove_php_reporting();
|
12 |
+
MainWP_Security::remove_registered_versions();
|
|
|
13 |
MainWP_Security::remove_generator_version();
|
14 |
MainWP_Security::remove_readme();
|
15 |
|
255 |
//Removed version information for scripts/stylesheets
|
256 |
public static function remove_scripts_version_ok() {
|
257 |
return self::get_security_option( 'scripts_version' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
}
|
259 |
|
260 |
public static function remove_script_versions( $src ) {
|
265 |
|
266 |
return $src;
|
267 |
}
|
|
|
|
|
|
|
|
|
268 |
return $src;
|
269 |
}
|
270 |
|
271 |
+
public static function remove_registered_versions_ok() {
|
272 |
+
return self::get_security_option( 'registered_versions' );
|
273 |
+
}
|
274 |
+
|
275 |
+
public static function remove_registered_versions() {
|
276 |
+
if ( self::get_security_option( 'registered_versions' ) ) {
|
277 |
+
global $wp_styles;
|
278 |
+
if ( $wp_styles instanceof WP_Styles ) {
|
279 |
+
foreach ( $wp_styles->registered as $handle => $style ) {
|
280 |
+
$wp_styles->registered[ $handle ]->ver = null;
|
281 |
+
}
|
282 |
+
}
|
283 |
+
global $wp_scripts;
|
284 |
+
if ( $wp_scripts instanceof WP_Scripts ) {
|
285 |
+
foreach ( $wp_scripts->registered as $handle => $script ) {
|
286 |
+
$wp_scripts->registered[ $handle ]->ver = null;
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}
|
291 |
|
292 |
public static function remove_generator_version_ok() {
|
293 |
return self::get_security_option( 'generator_version' );
|
314 |
|
315 |
return $src;
|
316 |
}
|
|
|
|
|
|
|
|
|
317 |
return $src;
|
318 |
}
|
319 |
|
320 |
+
public static function remove_readme( $force = false ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
if ( $force || self::get_security_option( 'readme' ) ) {
|
322 |
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
|
323 |
if ( ! @unlink( ABSPATH . 'readme.html' ) ) {
|
341 |
|
342 |
public static function remove_styles_version_ok() {
|
343 |
return self::get_security_option( 'styles_version' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
}
|
345 |
|
346 |
//Admin user name is not admin
|
mainwp-child.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
Author: MainWP
|
7 |
Author URI: https://mainwp.com
|
8 |
Text Domain: mainwp-child
|
9 |
-
Version: 3.
|
10 |
*/
|
11 |
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
|
12 |
header( 'X-Frame-Options: ALLOWALL' );
|
6 |
Author: MainWP
|
7 |
Author URI: https://mainwp.com
|
8 |
Text Domain: mainwp-child
|
9 |
+
Version: 3.5
|
10 |
*/
|
11 |
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
|
12 |
header( 'X-Frame-Options: ALLOWALL' );
|
readme.txt
CHANGED
@@ -6,8 +6,8 @@ Author: mainwp
|
|
6 |
Author URI: https://mainwp.com
|
7 |
Plugin URI: https://mainwp.com
|
8 |
Requires at least: 3.6
|
9 |
-
Tested up to: 4.9.
|
10 |
-
Stable tag: 3.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -71,6 +71,19 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
|
|
71 |
|
72 |
== Changelog ==
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
= 3.4.9 - 7-23-18 =
|
75 |
* Fixed: MainWP iThemes Security Extension issues caused by the latest iThemes Security plugin version
|
76 |
|
6 |
Author URI: https://mainwp.com
|
7 |
Plugin URI: https://mainwp.com
|
8 |
Requires at least: 3.6
|
9 |
+
Tested up to: 4.9.8
|
10 |
+
Stable tag: 3.5
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
71 |
|
72 |
== Changelog ==
|
73 |
|
74 |
+
= 3.5 - 9-27-18 =
|
75 |
+
* Fixed: compatibility issues caused by the recent UpdraftPlus update
|
76 |
+
* Fixed: issues with the WooCommerce Status information
|
77 |
+
* Fixed: issues with Bulk Settings Manager for specific plugins
|
78 |
+
* Added: mainwp_child_mu_plugin_enabled hook to allow MainWP Child usage as a must-use plugin
|
79 |
+
* Added: support for recording WP Time Capsule backups for Client Reports
|
80 |
+
* Added: mainwp_branding_role_cap_enable_contact_form hook to allow users to show Support Form (Branding extension option) to specific roles
|
81 |
+
* Added: support to for the new BackUpWordPrress Extension feature
|
82 |
+
* Added: support for the new MainWP Buddy Extension feature
|
83 |
+
* Updated: reporting system to determine backup type for BackWPup backups
|
84 |
+
* Improved: connection stability for sites hosted on hosts with small execution time limits
|
85 |
+
* Improved: detecting updates for premium plugins
|
86 |
+
|
87 |
= 3.4.9 - 7-23-18 =
|
88 |
* Fixed: MainWP iThemes Security Extension issues caused by the latest iThemes Security plugin version
|
89 |
|