* Fixed: connection problems caused by issues with json_encode function

This commit is contained in:
thanghv 2020-02-03 22:55:50 +07:00
parent 197652ebcc
commit 329bd94989
4 changed files with 43 additions and 19 deletions

View file

@ -115,7 +115,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
}
class MainWP_Child {
public static $version = '4.0.6.1';
public static $version = '4.0.6.2';
private $update_version = '1.5';
private $callableFunctions = array(

View file

@ -4,7 +4,7 @@ class MainWP_Helper {
static function write( $val ) {
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
$output = json_encode( $val );
$output = self::safe_json_encode( $val );
else:
$output = serialize( $val );
endif;
@ -12,10 +12,31 @@ class MainWP_Helper {
die( '<mainwp>' . base64_encode( $output ) . '</mainwp>' );
}
public static function utf8ize($mixed) {
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = self::utf8ize($value);
}
} elseif (is_string($mixed)) {
if ( function_exists( 'mb_convert_encoding' )) {
return mb_convert_encoding($mixed, "UTF-8", "UTF-8");
}
}
return $mixed;
}
public static function safe_json_encode($value, $options = 0, $depth = 512) {
$encoded = @json_encode($value, $options, $depth);
if ($encoded === false && $value && json_last_error() == JSON_ERROR_UTF8) {
$encoded = @json_encode(self::utf8ize($value), $options, $depth);
}
return $encoded;
}
static function close_connection( $val = null ) {
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
$output = json_encode( $val );
$output = self::safe_json_encode( $val );
else:
$output = serialize( $val );
endif;

View file

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

View file

@ -7,7 +7,7 @@ Plugin URI: https://mainwp.com
Requires at least: 3.6
Tested up to: 5.3.2
Requires PHP: 5.6
Stable tag: 4.0.6.1
Stable tag: 4.0.6.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -71,6 +71,9 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
== Changelog ==
= 4.0.6.2 - 2-3-20 =
* Fixed: connection problems caused by issues with json_encode function
= 4.0.6.1 - 1-20-20 =
* Updated: MainWP_Child_WPvivid_BackupRestore class