* Fixed: WordPress 5.3 compatibility problems

* Fixed: an issue with managing BackWPup backups
* Updated: multiple error messages
* Removed: unused code
This commit is contained in:
thanghv 2019-11-11 23:17:10 +07:00
parent 912fb297e2
commit 4d0c30d883
6 changed files with 77 additions and 31 deletions

View file

@ -72,7 +72,13 @@ class MainWP_Child_Back_WP_Up {
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) { if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php'; $file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php'; $file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/Pro/class-pro.php';
// to fix
if ( ! file_exists( $file_path2 ) ) {
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
}
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 )); MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
require_once( $file_path1 ); require_once( $file_path1 );
require_once( $file_path2 ); require_once( $file_path2 );
@ -90,7 +96,8 @@ class MainWP_Child_Back_WP_Up {
MainWP_Helper::check_methods('get_instance'); MainWP_Helper::check_methods('get_instance');
BackWPup::get_instance(); BackWPup::get_instance();
add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) ); //add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
add_action( 'admin_init', array( $this, 'init_download_backup' ) );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
} }
} catch ( Exception $e) { } catch ( Exception $e) {
@ -748,6 +755,17 @@ class MainWP_Child_Back_WP_Up {
'&', '&',
admin_url( 'admin-ajax.php' ) . '?action=mainwp_backwpup_download_backup&type=', admin_url( 'admin-ajax.php' ) . '?action=mainwp_backwpup_download_backup&type=',
), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' ) ); ), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' ) );
$temp_array['downloadurl_id'] = '/wp-admin/admin.php?page=backwpupbackups';
if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches )) {
if ( !empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
$temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1];
}
error_log('did match' . print_r($matches, true));
} else {
error_log('not match');
}
$temp_array['website_id'] = $website_id; $temp_array['website_id'] = $website_id;
if ( ! isset( $without_dupes[ $temp_array['file'] ] ) ) { if ( ! isset( $without_dupes[ $temp_array['file'] ] ) ) {
@ -765,6 +783,22 @@ class MainWP_Child_Back_WP_Up {
return array( 'success' => 1, 'response' => $array ); return array( 'success' => 1, 'response' => $array );
} }
public function init_download_backup() {
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'backwpupbackups' || !isset( $_GET['download_click_id'] ) || empty( $_GET['download_click_id'] )) {
return;
}
?>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
var downloadLink = document.querySelector( 'a.backup-download-link[data-jobid="<?php echo intval($_GET['download_click_id']); ?>"' );
if (typeof(downloadLink) !== 'undefined' && downloadLink !== null) {
downloadLink.click();
}
});
</script>
<?php
}
public function download_backup() { public function download_backup() {
if ( ! isset( $_GET['type'] ) || empty( $_GET['type'] ) || ! isset( $_GET['_wpnonce'] ) || empty( $_GET['_wpnonce'] ) ) { if ( ! isset( $_GET['type'] ) || empty( $_GET['type'] ) || ! isset( $_GET['_wpnonce'] ) || empty( $_GET['_wpnonce'] ) ) {
die( '-1' ); die( '-1' );
@ -788,10 +822,10 @@ class MainWP_Child_Back_WP_Up {
$dest_class->file_download( (int) $_GET['jobid'], $_GET['file'] ); $dest_class->file_download( (int) $_GET['jobid'], $_GET['file'] );
} else { } else {
die( '-5' ); die( '-5' );
} }
die(); die();
} }
protected function create_nonce_without_session( $action = - 1 ) { protected function create_nonce_without_session( $action = - 1 ) {
$user = wp_get_current_user(); $user = wp_get_current_user();

View file

@ -115,7 +115,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
} }
class MainWP_Child { class MainWP_Child {
public static $version = '4.0.3'; public static $version = '4.0.4';
private $update_version = '1.5'; private $update_version = '1.5';
private $callableFunctions = array( private $callableFunctions = array(
@ -1442,11 +1442,11 @@ class MainWP_Child {
$auth = $this->auth( isset( $_POST['mainwpsignature'] ) ? $_POST['mainwpsignature'] : '', isset( $_POST['function'] ) ? $_POST['function'] : '', isset( $_POST['nonce'] ) ? $_POST['nonce'] : '', isset( $_POST['nossl'] ) ? $_POST['nossl'] : 0 ); $auth = $this->auth( isset( $_POST['mainwpsignature'] ) ? $_POST['mainwpsignature'] : '', isset( $_POST['function'] ) ? $_POST['function'] : '', isset( $_POST['nonce'] ) ? $_POST['nonce'] : '', isset( $_POST['nossl'] ) ? $_POST['nossl'] : 0 );
if ( ! $auth && isset( $_POST['mainwpsignature'] ) ) { if ( ! $auth && isset( $_POST['mainwpsignature'] ) ) {
MainWP_Helper::error( __( 'Authentication failed! Please deactivate and re-activate the MainWP Child plugin on this site.', 'mainwp-child' ) ); MainWP_Helper::error( __( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this site and try again.', 'mainwp-child' ) );
} }
if ( ! $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) && ! isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) { if ( ! $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) && ! isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
MainWP_Helper::error( __( 'Authentication failed! Please deactivate and re-activate the MainWP Child plugin on this site.', 'mainwp-child' ) ); MainWP_Helper::error( __( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this site and try again.', 'mainwp-child' ) );
} }
$auth_user = false; $auth_user = false;
@ -1470,11 +1470,11 @@ class MainWP_Child {
} }
if ( ! $user ) { if ( ! $user ) {
MainWP_Helper::error( __( 'That administrator username was not found on this child site. Please verify that it is an existing administrator.', 'mainwp-child' ) ); MainWP_Helper::error( __( 'Unexising administrator username. Please verify that it is an existing administrator.', 'mainwp-child' ) );
} }
if ( 10 != $user->wp_user_level && ( ! isset( $user->user_level ) || 10 != $user->user_level ) && ! $user->has_cap( 'level_10' ) ) { if ( 10 != $user->wp_user_level && ( ! isset( $user->user_level ) || 10 != $user->user_level ) && ! $user->has_cap( 'level_10' ) ) {
MainWP_Helper::error( __( 'That user is not an administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ) ); MainWP_Helper::error( __( 'Invalid user. Please verify that the user has administrator privileges.', 'mainwp-child' ) );
} }
$this->login( $auth_user ); $this->login( $auth_user );
@ -2404,7 +2404,7 @@ class MainWP_Child {
// set disconnect status to yes here, it will empty after reconnected // set disconnect status to yes here, it will empty after reconnected
MainWP_Child_Branding::Instance()->save_branding_options('branding_disconnected', 'yes'); MainWP_Child_Branding::Instance()->save_branding_options('branding_disconnected', 'yes');
MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', 'yes', 'yes' ); // to compatible with old client reports MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', 'yes', 'yes' ); // to compatible with old client reports
MainWP_Helper::error( __( 'Public key already set. Please reset the MainWP Child plugin on the child site and try again.', 'mainwp-child' ) ); MainWP_Helper::error( __( 'Public key already set. Please deactivate & reactivate the MainWP Child plugin and try again.', 'mainwp-child' ) );
} }
@ -3032,6 +3032,12 @@ class MainWP_Child {
//Read form data //Read form data
$new_user = maybe_unserialize( base64_decode( $_POST['new_user'] ) ); $new_user = maybe_unserialize( base64_decode( $_POST['new_user'] ) );
$send_password = $_POST['send_password']; $send_password = $_POST['send_password'];
// check role existed
if (isset( $new_user['role'] )) {
if ( !get_role( $new_user['role'] ) ) {
$new_user['role'] = 'subscriber';
}
}
$new_user_id = wp_insert_user( $new_user ); $new_user_id = wp_insert_user( $new_user );
@ -4926,17 +4932,17 @@ class MainWP_Child {
function search_users() { function search_users() {
$search_user_role = array(); $search_user_role = array();
$check_users_role = false; $check_users_role = false;
if (isset($_POST['role']) && !empty($_POST['role'])) { if (isset($_POST['role']) && !empty($_POST['role'])) {
$check_users_role = true; $check_users_role = true;
$all_users_role = $this->get_all_users(true); $all_users_role = $this->get_all_users(true);
foreach($all_users_role as $user) { foreach($all_users_role as $user) {
$search_user_role[] = $user['id']; $search_user_role[] = $user['id'];
} }
unset($all_users_role); unset($all_users_role);
} }
$columns = explode( ',', $_POST['search_columns'] ); $columns = explode( ',', $_POST['search_columns'] );
$allusers = array(); $allusers = array();

View file

@ -887,9 +887,9 @@ class MainWP_Helper {
if ( empty( $wp_filesystem ) ) { if ( empty( $wp_filesystem ) ) {
ob_start(); ob_start();
if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) { // if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) {
include_once( ABSPATH . '/wp-admin/includes/deprecated.php' ); // include_once( ABSPATH . '/wp-admin/includes/deprecated.php' );
} // }
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
include_once( ABSPATH . '/wp-admin/includes/screen.php' ); include_once( ABSPATH . '/wp-admin/includes/screen.php' );
} }

View file

@ -38,7 +38,7 @@ class MainWP_Keyword_Links {
public function keywordLinksJS() { public function keywordLinksJS() {
if ( ! is_admin() && get_option( 'mainwp_kwl_enable_statistic' ) ) { if ( ! is_admin() && get_option( 'mainwp_kwl_enable_statistic' ) && !empty($this->keyword_links) ) {
wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'keywordLinks', plugins_url( '/js/keywordlinks.js', dirname( __FILE__ ) ) ); wp_enqueue_script( 'keywordLinks', plugins_url( '/js/keywordlinks.js', dirname( __FILE__ ) ) );
add_action( 'wp_head', array( $this, 'head_loading' ), 1 ); add_action( 'wp_head', array( $this, 'head_loading' ), 1 );

View file

@ -6,7 +6,7 @@
Author: MainWP Author: MainWP
Author URI: https://mainwp.com Author URI: https://mainwp.com
Text Domain: mainwp-child Text Domain: mainwp-child
Version: 4.0.3 Version: 4.0.4
*/ */
include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from wordpress include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from wordpress

View file

@ -5,9 +5,9 @@ Author: mainwp
Author URI: https://mainwp.com Author URI: https://mainwp.com
Plugin URI: https://mainwp.com Plugin URI: https://mainwp.com
Requires at least: 3.6 Requires at least: 3.6
Tested up to: 5.2.3 Tested up to: 5.3
Requires PHP: 5.6 Requires PHP: 5.6
Stable tag: 4.0.3 Stable tag: 4.0.4
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -71,6 +71,12 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
== Changelog == == Changelog ==
= 4.0.4 - 11-11-19 =
* Fixed: WordPress 5.3 compatibility problems
* Fixed: an issue with managing BackWPup backups
* Updated: multiple error messages
* Removed: unused code
= 4.0.3 - 10-1-19 = = 4.0.3 - 10-1-19 =
* Added: 'mainwp_child_branding_init_options' filter for disabling custom branding * Added: 'mainwp_child_branding_init_options' filter for disabling custom branding
* Updated: support for the WPVulnDB API v3 * Updated: support for the WPVulnDB API v3