mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-05 09:19:53 +08:00
parent
6467036af9
commit
c037098788
3 changed files with 266 additions and 278 deletions
|
@ -4,7 +4,7 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) {
|
|||
@ini_set( 'display_errors', true );
|
||||
@ini_set( 'display_startup_errors', true );
|
||||
} else {
|
||||
if (isset($_REQUEST['mainwpsignature'])) {
|
||||
if ( isset($_REQUEST['mainwpsignature']) ) {
|
||||
@ini_set( 'display_errors', false );
|
||||
@error_reporting( 0 );
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|||
// To fix verify nonce conflict #1
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce()
|
||||
// just return false to unverify nonce, does not exit
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) {
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|||
// To fix verify nonce conflict #2
|
||||
// this is fake nonce to fix some conflict of wp_verify_nonce()
|
||||
// just return false to unverify nonce, does not exit
|
||||
if ($nonce == 'mainwp-bsm-unverify-nonce') {
|
||||
if ( $nonce == 'mainwp-bsm-unverify-nonce' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|||
// To fix verify nonce conflict #3
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce()
|
||||
// just return false to unverify nonce, does not exit
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) {
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -211,10 +211,10 @@ class MainWP_Child {
|
|||
public function __construct( $plugin_file ) {
|
||||
$this->update();
|
||||
$this->load_all_options();
|
||||
$this->filterFunction = function( $a) {
|
||||
if ($a == null) {
|
||||
$this->filterFunction = function( $a ) {
|
||||
if ( $a == null ) {
|
||||
return false; }
|
||||
if (is_object($a) && property_exists($a, 'last_checked') && ! property_exists($a, 'checked')) {
|
||||
if ( is_object($a) && property_exists($a, 'last_checked') && ! property_exists($a, 'checked') ) {
|
||||
return false;
|
||||
}
|
||||
return $a;
|
||||
|
@ -321,7 +321,7 @@ class MainWP_Child {
|
|||
'mainwp_child_plugintheme_days_outdate',
|
||||
);
|
||||
$query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
|
||||
foreach ($options as $option) {
|
||||
foreach ( $options as $option ) {
|
||||
$query .= "'" . $option . "', ";
|
||||
}
|
||||
$query = substr($query, 0, strlen($query) - 2);
|
||||
|
@ -337,7 +337,7 @@ class MainWP_Child {
|
|||
$alloptions[ $o->option_name ] = $o->option_value;
|
||||
unset($options[ array_search($o->option_name, $options) ]);
|
||||
}
|
||||
foreach ($options as $option ) {
|
||||
foreach ( $options as $option ) {
|
||||
$notoptions[ $option ] = true;
|
||||
}
|
||||
if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
|
||||
|
@ -514,7 +514,6 @@ class MainWP_Child {
|
|||
}
|
||||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $convertBranding );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
|
||||
|
@ -570,7 +569,7 @@ class MainWP_Child {
|
|||
|
||||
public function detect_premium_themesplugins_updates() {
|
||||
|
||||
if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] == 'yes') {
|
||||
if ( isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] == 'yes' ) {
|
||||
// to fix some premium plugins update notification
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
set_site_transient( 'update_plugins', $current );
|
||||
|
@ -584,7 +583,7 @@ class MainWP_Child {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_GET['_detect_themes_updates']) && $_GET['_detect_themes_updates'] == 'yes') {
|
||||
if ( isset($_GET['_detect_themes_updates']) && $_GET['_detect_themes_updates'] == 'yes' ) {
|
||||
add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
|
||||
$themes = get_theme_updates();
|
||||
remove_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
|
||||
|
@ -603,7 +602,7 @@ class MainWP_Child {
|
|||
$_POST['list'] = $list;
|
||||
|
||||
$function = 'upgradeplugintheme';
|
||||
if (isset($this->callableFunctions[ $function ])) {
|
||||
if ( isset($this->callableFunctions[ $function ]) ) {
|
||||
call_user_func( array( $this, $this->callableFunctions[ $function ] ) );
|
||||
}
|
||||
// wp_destroy_current_session(); // to fix issue multi user session
|
||||
|
@ -766,7 +765,7 @@ class MainWP_Child {
|
|||
global $submenu;
|
||||
if ( isset( $submenu['options-general.php'] ) ) {
|
||||
foreach ( $submenu['options-general.php'] as $index => $item ) {
|
||||
if ( 'mainwp-reports-page' === $item[2] || 'mainwp-reports-settings' === $item[2]) {
|
||||
if ( 'mainwp-reports-page' === $item[2] || 'mainwp-reports-settings' === $item[2] ) {
|
||||
unset( $submenu['options-general.php'][ $index ] );
|
||||
}
|
||||
}
|
||||
|
@ -774,7 +773,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
function render_pages( $shownPage) {
|
||||
function render_pages( $shownPage ) {
|
||||
$shownPage = '';
|
||||
if ( isset($_GET['tab']) ) {
|
||||
$shownPage = $_GET['tab'];
|
||||
|
@ -788,14 +787,14 @@ class MainWP_Child {
|
|||
|
||||
$hide_style = 'style="display:none"';
|
||||
|
||||
if ($shownPage == '') {
|
||||
if ( $shownPage == '' ) {
|
||||
if ( ! $hide_settings ) {
|
||||
$shownPage = 'settings';
|
||||
} elseif ( ! $hide_restore) {
|
||||
} elseif ( ! $hide_restore ) {
|
||||
$shownPage = 'restore-clone';
|
||||
} elseif ( ! $hide_server_info) {
|
||||
} elseif ( ! $hide_server_info ) {
|
||||
$shownPage = 'server-info';
|
||||
} elseif ( ! $hide_connection_detail) {
|
||||
} elseif ( ! $hide_connection_detail ) {
|
||||
$shownPage = 'connection-detail';
|
||||
}
|
||||
}
|
||||
|
@ -829,13 +828,13 @@ class MainWP_Child {
|
|||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! $hide_server_info ) { ?>
|
||||
<?php if ( ! $hide_server_info ) { ?>
|
||||
<div class="mainwp-child-setting-tab server-info" <?php echo ( 'server-info' !== $shownPage ) ? $hide_style : ''; ?>>
|
||||
<?php MainWP_Child_Server_Information::renderPage(); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! $hide_connection_detail ) { ?>
|
||||
<?php if ( ! $hide_connection_detail ) { ?>
|
||||
<div class="mainwp-child-setting-tab connection-detail" <?php echo ( 'connection-detail' !== $shownPage ) ? $hide_style : ''; ?>>
|
||||
<?php MainWP_Child_Server_Information::renderConnectionDetails(); ?>
|
||||
</div>
|
||||
|
@ -847,12 +846,12 @@ class MainWP_Child {
|
|||
self::render_footer();
|
||||
}
|
||||
|
||||
public static function render_header( $shownPage, $subpage = true) {
|
||||
public static function render_header( $shownPage, $subpage = true ) {
|
||||
if ( isset($_GET['tab']) ) {
|
||||
$shownPage = $_GET['tab'];
|
||||
}
|
||||
|
||||
if (empty($shownPage)) {
|
||||
if ( empty($shownPage) ) {
|
||||
$shownPage = 'settings';
|
||||
}
|
||||
|
||||
|
@ -1012,7 +1011,7 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
function admin_head() {
|
||||
if (isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab') {
|
||||
if ( isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab' ) {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.mainwp-postbox-actions-top {
|
||||
|
@ -1196,7 +1195,7 @@ class MainWP_Child {
|
|||
|
||||
if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
|
||||
|
||||
if (empty($auth_user)) {
|
||||
if ( empty($auth_user) ) {
|
||||
$auth_user = $_POST['user'];
|
||||
}
|
||||
|
||||
|
@ -1520,7 +1519,7 @@ class MainWP_Child {
|
|||
|
||||
if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
|
||||
|
||||
if (empty($auth_user)) {
|
||||
if ( empty($auth_user) ) {
|
||||
$auth_user = $_POST['user'];
|
||||
}
|
||||
|
||||
|
@ -1556,7 +1555,7 @@ class MainWP_Child {
|
|||
MainWP_Child_Links_Checker::Instance()->init();
|
||||
MainWP_Child_WPvivid_BackupRestore::Instance()->init();
|
||||
global $_wp_submenu_nopriv;
|
||||
if ($_wp_submenu_nopriv === null) {
|
||||
if ( $_wp_submenu_nopriv === null ) {
|
||||
$_wp_submenu_nopriv = array(); // fix warning
|
||||
}
|
||||
|
||||
|
@ -1574,7 +1573,7 @@ class MainWP_Child {
|
|||
define( 'DOING_CRON', true );
|
||||
self::fix_for_custom_themes();
|
||||
call_user_func( array( $this, $this->callableFunctionsNoAuth[ $_POST['function'] ] ) );
|
||||
} elseif (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && ! isset($this->callableFunctions[ $_POST['function'] ]) && ! isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
||||
} elseif ( isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && ! isset($this->callableFunctions[ $_POST['function'] ]) && ! isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
||||
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' ) );
|
||||
}
|
||||
|
||||
|
@ -1637,7 +1636,7 @@ class MainWP_Child {
|
|||
$auth = hash_equals( md5( $func . $nonce . get_option( 'mainwp_child_nossl_key' ) ), base64_decode( $signature ) );
|
||||
} else {
|
||||
$auth = openssl_verify( $func . $nonce, base64_decode( $signature ), base64_decode( get_option( 'mainwp_child_pubkey' ) ) );
|
||||
if ($auth !== 1) {
|
||||
if ( $auth !== 1 ) {
|
||||
$auth = false;
|
||||
}
|
||||
}
|
||||
|
@ -1747,7 +1746,7 @@ class MainWP_Child {
|
|||
) );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0) {
|
||||
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) {
|
||||
// retry
|
||||
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 );
|
||||
$ssl_verify = false;
|
||||
|
@ -1806,7 +1805,7 @@ class MainWP_Child {
|
|||
do_action( 'mainwp_child_installPluginTheme', $args );
|
||||
if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) {
|
||||
// to fix activate issue
|
||||
if ('quotes-collection/quotes-collection.php' == $args['slug']) {
|
||||
if ( 'quotes-collection/quotes-collection.php' == $args['slug'] ) {
|
||||
activate_plugin( $path . $fileName, '', false, true );
|
||||
} else {
|
||||
activate_plugin( $path . $fileName, '' /* false, true */ );
|
||||
|
@ -2039,8 +2038,8 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
// to fix: smart-manager-for-wp-e-commerce update
|
||||
if (in_array('smart-manager-for-wp-e-commerce/smart-manager.php', $plugins)) {
|
||||
if (file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php') && file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php')) {
|
||||
if ( in_array('smart-manager-for-wp-e-commerce/smart-manager.php', $plugins) ) {
|
||||
if ( file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php') && file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php') ) {
|
||||
include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php';
|
||||
include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php';
|
||||
}
|
||||
|
@ -2091,7 +2090,7 @@ class MainWP_Child {
|
|||
// try to fix if that is premiums update
|
||||
$api = apply_filters( 'plugins_api', false, 'plugin_information', array( 'slug' => $plugin ) );
|
||||
|
||||
if ( ! is_wp_error( $api ) && ! empty($api)) {
|
||||
if ( ! is_wp_error( $api ) && ! empty($api) ) {
|
||||
if ( isset($api->download_link) ) {
|
||||
$res = $upgrader->install($api->download_link);
|
||||
if ( ! is_wp_error( $res ) && ! ( is_null( $res ) ) ) {
|
||||
|
@ -2099,8 +2098,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
$information['upgrades'][ $plugin ] = true;
|
||||
// to fix logging update
|
||||
// if (isset($information['plugin_updates']) && isset($information['plugin_updates'][$plugin])) {
|
||||
|
@ -2119,7 +2117,7 @@ class MainWP_Child {
|
|||
$failed = false;
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
if ( $failed ) {
|
||||
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
|
||||
}
|
||||
}
|
||||
|
@ -2233,7 +2231,7 @@ class MainWP_Child {
|
|||
$failed = false;
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
if ( $failed ) {
|
||||
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
|
||||
}
|
||||
|
||||
|
@ -2249,7 +2247,6 @@ class MainWP_Child {
|
|||
'hookFixOptimizePressThemeUpdate',
|
||||
), 99 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
remove_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ), 10 );
|
||||
|
@ -2366,7 +2363,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($pre == false) {
|
||||
if ( $pre == false ) {
|
||||
return $false;
|
||||
}
|
||||
|
||||
|
@ -2390,7 +2387,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($pre == false) {
|
||||
if ( $pre == false ) {
|
||||
return $false;
|
||||
}
|
||||
|
||||
|
@ -2504,13 +2501,13 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
$others = array();
|
||||
if ( isset( $_POST['featured_image_data'] ) && ! empty($_POST['featured_image_data'])) {
|
||||
if ( isset( $_POST['featured_image_data'] ) && ! empty($_POST['featured_image_data']) ) {
|
||||
$others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] ));
|
||||
}
|
||||
|
||||
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
|
||||
|
||||
if (is_array($res) && isset($res['error'])) {
|
||||
if ( is_array($res) && isset($res['error']) ) {
|
||||
MainWP_Helper::error( $res['error'] );
|
||||
}
|
||||
|
||||
|
@ -2602,7 +2599,7 @@ class MainWP_Child {
|
|||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
function get_post_edit( $id) {
|
||||
function get_post_edit( $id ) {
|
||||
$post = get_post( $id );
|
||||
if ( $post ) {
|
||||
$categoryObjects = get_the_category( $post->ID );
|
||||
|
@ -2689,7 +2686,7 @@ class MainWP_Child {
|
|||
return false;
|
||||
}
|
||||
|
||||
function get_page_edit( $id) {
|
||||
function get_page_edit( $id ) {
|
||||
$post = get_post( $id );
|
||||
if ( $post ) {
|
||||
$post_custom = get_post_custom( $id );
|
||||
|
@ -2779,21 +2776,21 @@ class MainWP_Child {
|
|||
wp_update_user( $my_user );
|
||||
} elseif ( 'edit' === $action ) {
|
||||
$user_data = $this->get_user_to_edit($userId);
|
||||
if ( ! empty($user_data)) {
|
||||
if ( ! empty($user_data) ) {
|
||||
$information['user_data'] = $user_data;
|
||||
} else {
|
||||
$failed = true;
|
||||
}
|
||||
} elseif ( 'update_user' === $action ) {
|
||||
$my_user = $_POST['extra'];
|
||||
if (is_array($my_user)) {
|
||||
foreach ($my_user as $idx => $val) {
|
||||
if ($val === 'donotupdate' || ( empty($val) && $idx !== 'role' )) {
|
||||
if ( is_array($my_user) ) {
|
||||
foreach ( $my_user as $idx => $val ) {
|
||||
if ( $val === 'donotupdate' || ( empty($val) && $idx !== 'role' ) ) {
|
||||
unset($my_user[ $idx ]);
|
||||
}
|
||||
}
|
||||
$result = $this->edit_user( $userId, $my_user );
|
||||
if (is_array($result) && isset($result['error'])) {
|
||||
if ( is_array($result) && isset($result['error']) ) {
|
||||
$information['error'] = $result['error'];
|
||||
}
|
||||
} else {
|
||||
|
@ -2803,21 +2800,20 @@ class MainWP_Child {
|
|||
$failed = true;
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
if ( $failed ) {
|
||||
$information['status'] = 'FAIL';
|
||||
}
|
||||
|
||||
if ( ! isset( $information['status'] ) && ! isset($information['error']) ) {
|
||||
$information['status'] = 'SUCCESS';
|
||||
if ('update_user' === $action && isset($_POST['optimize']) && ! empty($_POST['optimize'])) {
|
||||
if ( 'update_user' === $action && isset($_POST['optimize']) && ! empty($_POST['optimize']) ) {
|
||||
$information['users'] = $this->get_all_users_int(500); // to fix
|
||||
}
|
||||
|
||||
}
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
function edit_user( $user_id, $data) {
|
||||
function edit_user( $user_id, $data ) {
|
||||
$wp_roles = wp_roles();
|
||||
$user = new stdClass();
|
||||
|
||||
|
@ -2882,7 +2878,7 @@ class MainWP_Child {
|
|||
if ( isset( $data['last_name'] ) ) {
|
||||
$user->last_name = sanitize_text_field( $data['last_name'] );
|
||||
}
|
||||
if ( isset( $data['nickname'] ) && ! empty($data['nickname'])) {
|
||||
if ( isset( $data['nickname'] ) && ! empty($data['nickname']) ) {
|
||||
$user->nickname = sanitize_text_field( $data['nickname'] );
|
||||
}
|
||||
if ( isset( $data['display_name'] ) ) {
|
||||
|
@ -2901,7 +2897,7 @@ class MainWP_Child {
|
|||
|
||||
do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
|
||||
|
||||
if ( ! empty($pass1) || ! empty($pass2)) {
|
||||
if ( ! empty($pass1) || ! empty($pass2) ) {
|
||||
// Check for blank password when adding a user.
|
||||
if ( ! $update && empty( $pass1 ) ) {
|
||||
$errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter a password.' ), array( 'form-field' => 'pass1' ) );
|
||||
|
@ -2948,7 +2944,6 @@ class MainWP_Child {
|
|||
if ( is_string( $message ) ) {
|
||||
$error_str .= ' ' . esc_html( strip_tags( $message ) );
|
||||
}
|
||||
|
||||
}
|
||||
return array( 'error' => $error_str );
|
||||
}
|
||||
|
@ -2963,7 +2958,7 @@ class MainWP_Child {
|
|||
$profileuser = get_user_to_edit($user_id);
|
||||
|
||||
$edit_data = array();
|
||||
if (is_object($profileuser)) {
|
||||
if ( is_object($profileuser) ) {
|
||||
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
|
||||
$user_role = reset( $user_roles );
|
||||
$edit_data['role'] = $user_role;
|
||||
|
@ -3097,7 +3092,7 @@ class MainWP_Child {
|
|||
$new_user = maybe_unserialize( base64_decode( $_POST['new_user'] ) );
|
||||
$send_password = $_POST['send_password'];
|
||||
// check role existed
|
||||
if (isset( $new_user['role'] )) {
|
||||
if ( isset( $new_user['role'] ) ) {
|
||||
if ( ! get_role( $new_user['role'] ) ) {
|
||||
$new_user['role'] = 'subscriber';
|
||||
}
|
||||
|
@ -3831,7 +3826,7 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
// to fix incorrect info
|
||||
if ( ! property_exists( $plugin_update, 'update' ) || ! property_exists( $plugin_update->update, 'new_version' ) || empty($plugin_update->update->new_version)) {
|
||||
if ( ! property_exists( $plugin_update, 'update' ) || ! property_exists( $plugin_update->update, 'new_version' ) || empty($plugin_update->update->new_version) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3846,7 +3841,7 @@ class MainWP_Child {
|
|||
// to fix premium plugs update
|
||||
$cached_plugins_update = get_site_transient( 'mainwp_update_plugins_cached' );
|
||||
if ( is_array( $cached_plugins_update ) && ( count( $cached_plugins_update ) > 0 ) ) {
|
||||
if ( ! isset($information['plugin_updates'])) {
|
||||
if ( ! isset($information['plugin_updates']) ) {
|
||||
$information['plugin_updates'] = array();
|
||||
}
|
||||
foreach ( $cached_plugins_update as $slug => $plugin_update ) {
|
||||
|
@ -3861,8 +3856,7 @@ class MainWP_Child {
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset( $information['plugin_updates'][ $slug ] ) ) {
|
||||
$information['plugin_updates'][ $slug ] = $plugin_update;
|
||||
|
@ -3895,7 +3889,7 @@ class MainWP_Child {
|
|||
// to fix premium themes update
|
||||
$cached_themes_update = get_site_transient( 'mainwp_update_themes_cached' );
|
||||
if ( is_array( $cached_themes_update ) && ( count( $cached_themes_update ) > 0 ) ) {
|
||||
if ( ! isset($information['theme_updates'])) {
|
||||
if ( ! isset($information['theme_updates']) ) {
|
||||
$information['theme_updates'] = array();
|
||||
}
|
||||
|
||||
|
@ -3914,7 +3908,7 @@ class MainWP_Child {
|
|||
$translation_updates = wp_get_translation_updates();
|
||||
if ( ! empty( $translation_updates ) ) {
|
||||
$information['translation_updates'] = array();
|
||||
foreach ($translation_updates as $translation_update) {
|
||||
foreach ( $translation_updates as $translation_update ) {
|
||||
$new_translation_update = array(
|
||||
'type' => $translation_update->type,
|
||||
'slug' => $translation_update->slug,
|
||||
|
@ -3944,16 +3938,16 @@ class MainWP_Child {
|
|||
|
||||
$recent_number = 5;
|
||||
|
||||
if (isset($_POST) && isset( $_POST['recent_number'] )) {
|
||||
if ( isset($_POST) && isset( $_POST['recent_number'] ) ) {
|
||||
$recent_number = $_POST['recent_number'];
|
||||
if ($recent_number != get_option('mainwp_child_recent_number', 5)) {
|
||||
if ( $recent_number != get_option('mainwp_child_recent_number', 5) ) {
|
||||
update_option( 'mainwp_child_recent_number', $recent_number );
|
||||
}
|
||||
} else {
|
||||
$recent_number = get_option('mainwp_child_recent_number', 5);
|
||||
}
|
||||
|
||||
if ($recent_number <= 0 || $recent_number > 30) {
|
||||
if ( $recent_number <= 0 || $recent_number > 30 ) {
|
||||
$recent_number = 5;
|
||||
}
|
||||
|
||||
|
@ -4019,7 +4013,7 @@ class MainWP_Child {
|
|||
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
|
||||
if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) {
|
||||
$max_exe = ini_get( 'max_execution_time' ); // to fix issue of some hosts have limit of execution time
|
||||
if ($max_exe > 20) {
|
||||
if ( $max_exe > 20 ) {
|
||||
$information['totalsize'] = $this->getTotalFileSize();
|
||||
}
|
||||
}
|
||||
|
@ -4037,7 +4031,7 @@ class MainWP_Child {
|
|||
$information['users'] = $this->get_all_users_int(500); // to fix
|
||||
}
|
||||
|
||||
if (isset($_POST['primaryBackup']) && ! empty($_POST['primaryBackup'])) {
|
||||
if ( isset($_POST['primaryBackup']) && ! empty($_POST['primaryBackup']) ) {
|
||||
$primary_bk = $_POST['primaryBackup'];
|
||||
$information['primaryLasttimeBackup'] = MainWP_Helper::get_lasttime_backup($primary_bk);
|
||||
}
|
||||
|
@ -4054,9 +4048,9 @@ class MainWP_Child {
|
|||
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
|
||||
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
|
||||
|
||||
if (isset( $_POST['user'] )) {
|
||||
if ( isset( $_POST['user'] ) ) {
|
||||
$user = get_user_by( 'login', $_POST['user'] );
|
||||
if ( $user && property_exists($user, 'ID') && $user->ID) {
|
||||
if ( $user && property_exists($user, 'ID') && $user->ID ) {
|
||||
$information['admin_nicename'] = $user->data->user_nicename;
|
||||
$information['admin_useremail'] = $user->data->user_email;
|
||||
}
|
||||
|
@ -4064,7 +4058,7 @@ class MainWP_Child {
|
|||
|
||||
try {
|
||||
do_action('mainwp_child_site_stats');
|
||||
} catch (Exception $e) {
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -4083,7 +4077,7 @@ class MainWP_Child {
|
|||
|
||||
try {
|
||||
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
||||
} catch (Exception $e) {
|
||||
} catch ( Exception $e ) {
|
||||
// do not exit
|
||||
}
|
||||
}
|
||||
|
@ -4130,9 +4124,9 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($parse_page) {
|
||||
if ( $parse_page ) {
|
||||
// try to parse page
|
||||
if (empty($favi_url)) {
|
||||
if ( empty($favi_url) ) {
|
||||
$request = wp_remote_get( $site_url, array( 'timeout' => 50 ) );
|
||||
$favi = '';
|
||||
if ( is_array( $request ) && isset( $request['body'] ) ) {
|
||||
|
@ -4148,9 +4142,9 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
if ( ! empty( $favi ) ) {
|
||||
if ( false === strpos( $favi, 'http' )) {
|
||||
if (0 === strpos( $favi, '//' )) {
|
||||
if (0 === strpos( $site_url, 'https' )) {
|
||||
if ( false === strpos( $favi, 'http' ) ) {
|
||||
if ( 0 === strpos( $favi, '//' ) ) {
|
||||
if ( 0 === strpos( $site_url, 'https' ) ) {
|
||||
$favi_url = 'https:' . $favi;
|
||||
} else {
|
||||
$favi_url = 'http:' . $favi;
|
||||
|
@ -4295,15 +4289,15 @@ class MainWP_Child {
|
|||
*/
|
||||
|
||||
$wp_seo_enabled = false;
|
||||
if ( isset( $_POST['WPSEOEnabled'] ) && $_POST['WPSEOEnabled']) {
|
||||
if (is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count') && class_exists('WPSEO_Meta')) {
|
||||
if ( isset( $_POST['WPSEOEnabled'] ) && $_POST['WPSEOEnabled'] ) {
|
||||
if ( is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count') && class_exists('WPSEO_Meta') ) {
|
||||
$wp_seo_enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
$posts = get_posts( $args );
|
||||
if ( is_array( $posts ) ) {
|
||||
if ($wp_seo_enabled) {
|
||||
if ( $wp_seo_enabled ) {
|
||||
$post_ids = array();
|
||||
foreach ( $posts as $post ) {
|
||||
$post_ids[] = $post->ID;
|
||||
|
@ -4326,7 +4320,7 @@ class MainWP_Child {
|
|||
$outPost['dts'] = strtotime( $post->post_modified_gmt );
|
||||
}
|
||||
|
||||
if ($post->post_status == 'future') {
|
||||
if ( $post->post_status == 'future' ) {
|
||||
$outPost['dts'] = strtotime( $post->post_date_gmt );
|
||||
}
|
||||
|
||||
|
@ -4366,7 +4360,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($wp_seo_enabled) {
|
||||
if ( $wp_seo_enabled ) {
|
||||
$post_id = $post->ID;
|
||||
$outPost['seo_data'] = array(
|
||||
'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ),
|
||||
|
@ -4577,23 +4571,23 @@ class MainWP_Child {
|
|||
} else {
|
||||
if ( isset( $_POST['keyword'] ) ) {
|
||||
$search_on = isset($_POST['search_on']) ? $_POST['search_on'] : '';
|
||||
if ($search_on == 'title') {
|
||||
if ( $search_on == 'title' ) {
|
||||
$this->posts_where_suffix .= " AND ( $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )";
|
||||
} elseif ($search_on == 'content') {
|
||||
} elseif ( $search_on == 'content' ) {
|
||||
$this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' )";
|
||||
} else {
|
||||
$this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' OR $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )";
|
||||
}
|
||||
}
|
||||
if ( isset( $_POST['dtsstart'] ) && '' !== $_POST['dtsstart'] ) {
|
||||
if ($where_post_date) {
|
||||
if ( $where_post_date ) {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_date > '" . $_POST['dtsstart'] . "'";
|
||||
} else {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_modified > '" . $_POST['dtsstart'] . "'";
|
||||
}
|
||||
}
|
||||
if ( isset( $_POST['dtsstop'] ) && '' !== $_POST['dtsstop'] ) {
|
||||
if ($where_post_date) {
|
||||
if ( $where_post_date ) {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_date < '" . $_POST['dtsstop'] . "'";
|
||||
} else {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_modified < '" . $_POST['dtsstop'] . "'";
|
||||
|
@ -4690,9 +4684,9 @@ class MainWP_Child {
|
|||
$outComment['author_url'] = get_comment_author_url( $comment->comment_ID );
|
||||
$outComment['author_ip'] = get_comment_author_IP( $comment->comment_ID );
|
||||
$outComment['author_email'] = $email = apply_filters( 'comment_email', $comment->comment_author_email );
|
||||
// if ( ( ! empty( $outComment['author_email'] ) ) && ( '@' !== $outComment['author_email'] ) ) {
|
||||
// $outComment['author_email'] = '<a href="mailto:' . $outComment['author_email'] . '">' . $outComment['author_email'] . '</a>';
|
||||
// }
|
||||
// if ( ( ! empty( $outComment['author_email'] ) ) && ( '@' !== $outComment['author_email'] ) ) {
|
||||
// $outComment['author_email'] = '<a href="mailto:' . $outComment['author_email'] . '">' . $outComment['author_email'] . '</a>';
|
||||
// }
|
||||
$outComment['postId'] = $comment->comment_post_ID;
|
||||
$outComment['postName'] = $post->post_title;
|
||||
$outComment['comment_count'] = $post->comment_count;
|
||||
|
@ -4739,7 +4733,7 @@ class MainWP_Child {
|
|||
$theme_name = wp_get_theme()->get( 'Name' );
|
||||
$themes = explode( '||', $theme );
|
||||
|
||||
if (count($themes) == 1) {
|
||||
if ( count($themes) == 1 ) {
|
||||
$themeToDelete = current($themes);
|
||||
if ( $themeToDelete == $theme_name ) {
|
||||
$information['error'] = 'IsActivatedTheme';
|
||||
|
@ -4827,7 +4821,7 @@ class MainWP_Child {
|
|||
$thePlugin = get_plugin_data( $plugin );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||
// to fix activate issue
|
||||
if ('quotes-collection/quotes-collection.php' == $plugin) {
|
||||
if ( 'quotes-collection/quotes-collection.php' == $plugin ) {
|
||||
activate_plugin( $plugin, '', false, true );
|
||||
// do_action( 'activate_plugin', $plugin, null );
|
||||
} else {
|
||||
|
@ -4870,7 +4864,7 @@ class MainWP_Child {
|
|||
foreach ( $plugins as $idx => $plugin ) {
|
||||
if ( $plugin !== $this->plugin_slug ) {
|
||||
if ( isset( $all_plugins[ $plugin ] ) ) {
|
||||
if (is_plugin_active($plugin)) {
|
||||
if ( is_plugin_active($plugin) ) {
|
||||
$thePlugin = get_plugin_data( $plugin );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||
deactivate_plugins( $plugin );
|
||||
|
@ -4962,7 +4956,7 @@ class MainWP_Child {
|
|||
return $rslt;
|
||||
}
|
||||
|
||||
function get_all_users( $return = false) {
|
||||
function get_all_users( $return = false ) {
|
||||
$roles = explode( ',', $_POST['role'] );
|
||||
$allusers = array();
|
||||
if ( is_array( $roles ) ) {
|
||||
|
@ -4985,17 +4979,17 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $allusers;
|
||||
}
|
||||
MainWP_Helper::write( $allusers );
|
||||
}
|
||||
|
||||
function get_all_users_int( $number = false) {
|
||||
function get_all_users_int( $number = false ) {
|
||||
$allusers = array();
|
||||
|
||||
$params = array();
|
||||
if ($number) {
|
||||
if ( $number ) {
|
||||
$params['number'] = $number;
|
||||
}
|
||||
|
||||
|
@ -5027,10 +5021,10 @@ class MainWP_Child {
|
|||
$search_user_role = array();
|
||||
$check_users_role = false;
|
||||
|
||||
if (isset($_POST['role']) && ! empty($_POST['role'])) {
|
||||
if ( isset($_POST['role']) && ! empty($_POST['role']) ) {
|
||||
$check_users_role = 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'];
|
||||
}
|
||||
unset($all_users_role);
|
||||
|
@ -5054,8 +5048,8 @@ class MainWP_Child {
|
|||
) );
|
||||
if ( ! empty( $user_query->results ) ) {
|
||||
foreach ( $user_query->results as $new_user ) {
|
||||
if ($check_users_role) {
|
||||
if ( ! in_array($new_user->ID, $search_user_role )) {
|
||||
if ( $check_users_role ) {
|
||||
if ( ! in_array($new_user->ID, $search_user_role ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -5110,7 +5104,7 @@ class MainWP_Child {
|
|||
|
||||
function activation() {
|
||||
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
||||
if ($mu_plugin_enabled) {
|
||||
if ( $mu_plugin_enabled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5135,10 +5129,10 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
function deactivation( $deact = true) {
|
||||
function deactivation( $deact = true ) {
|
||||
|
||||
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
||||
if ($mu_plugin_enabled) {
|
||||
if ( $mu_plugin_enabled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5160,7 +5154,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($deact) {
|
||||
if ( $deact ) {
|
||||
do_action( 'mainwp_child_deactivation' );
|
||||
}
|
||||
}
|
||||
|
@ -5270,7 +5264,7 @@ class MainWP_Child {
|
|||
// to fix for window host, performance not good?
|
||||
if ( class_exists( 'RecursiveIteratorIterator' ) ) {
|
||||
$size = 0;
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
|
||||
foreach ( new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file ) {
|
||||
$size += $file->getSize();
|
||||
}
|
||||
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
|
||||
|
|
|
@ -339,65 +339,63 @@ class MainWP_Client_Report {
|
|||
if ( ! is_array( $records ) ) {
|
||||
$records = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// to fix invalid data, or skip records
|
||||
$skip_records = array();
|
||||
|
||||
// to fix for incorrect posts created logging
|
||||
// query created posts from WP posts data to simulate records logging for created posts
|
||||
if ( isset($_POST['direct_posts']) && !empty($_POST['direct_posts']) ) {
|
||||
|
||||
// to fix for incorrect posts created logging
|
||||
// query created posts from WP posts data to simulate records logging for created posts
|
||||
if ( isset($_POST['direct_posts']) && ! empty($_POST['direct_posts']) ) {
|
||||
$query_string = array(
|
||||
'post_type' => 'post',
|
||||
'date_query' => array(
|
||||
'column' => 'post_date',
|
||||
'after' => $args['date_from'],
|
||||
'before' => $args['date_to']
|
||||
),
|
||||
'post_status' => 'publish'
|
||||
);
|
||||
'post_type' => 'post',
|
||||
'date_query' => array(
|
||||
'column' => 'post_date',
|
||||
'after' => $args['date_from'],
|
||||
'before' => $args['date_to'],
|
||||
),
|
||||
'post_status' => 'publish',
|
||||
);
|
||||
|
||||
$records_created_posts = query_posts( $query_string );
|
||||
|
||||
if ($records_created_posts) {
|
||||
|
||||
for( $i = 0; $i < count($records); $i++ ) {
|
||||
$record = $records[$i];
|
||||
if ($record->connector == 'posts' && $record->context == 'post' && $record->action == 'created') {
|
||||
if (!in_array($record->ID, $skip_records)) {
|
||||
|
||||
if ( $records_created_posts ) {
|
||||
|
||||
for ( $i = 0; $i < count($records); $i++ ) {
|
||||
$record = $records[ $i ];
|
||||
if ( $record->connector == 'posts' && $record->context == 'post' && $record->action == 'created' ) {
|
||||
if ( ! in_array($record->ID, $skip_records) ) {
|
||||
$skip_records[] = $record->ID; // so avoid this created logging, will use logging query from posts data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$post_authors = array();
|
||||
|
||||
foreach( $records_created_posts as $_post){
|
||||
|
||||
foreach ( $records_created_posts as $_post ) {
|
||||
$au_id = $_post->post_author;
|
||||
if ( !isset($post_authors[$au_id]) ) {
|
||||
$au = get_user_by( 'id', $au_id );
|
||||
$post_authors[$au_id] = $au->display_name;
|
||||
if ( ! isset($post_authors[ $au_id ]) ) {
|
||||
$au = get_user_by( 'id', $au_id );
|
||||
$post_authors[ $au_id ] = $au->display_name;
|
||||
}
|
||||
$au_name = $post_authors[$au_id];
|
||||
|
||||
//simulate logging created posts record
|
||||
$stdObj = new stdClass;
|
||||
$stdObj->ID = 0; // simulate ID value
|
||||
$au_name = $post_authors[ $au_id ];
|
||||
|
||||
// simulate logging created posts record
|
||||
$stdObj = new stdClass();
|
||||
$stdObj->ID = 0; // simulate ID value
|
||||
$stdObj->connector = 'posts';
|
||||
$stdObj->context = 'post';
|
||||
$stdObj->action = 'created';
|
||||
$stdObj->created = $_post->post_date;
|
||||
$stdObj->meta = array(
|
||||
$stdObj->context = 'post';
|
||||
$stdObj->action = 'created';
|
||||
$stdObj->created = $_post->post_date;
|
||||
$stdObj->meta = array(
|
||||
'post_title' => array( $_post->post_title ),
|
||||
'user_meta' => array( $au_name )
|
||||
);
|
||||
|
||||
'user_meta' => array( $au_name ),
|
||||
);
|
||||
|
||||
$records[] = $stdObj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $other_tokens['header'] ) && is_array( $other_tokens['header'] ) ) {
|
||||
$other_tokens_data['header'] = $this->get_other_tokens_data( $records, $other_tokens['header'], $skip_records);
|
||||
}
|
||||
|
@ -484,22 +482,23 @@ class MainWP_Client_Report {
|
|||
case 'count':
|
||||
$count = 0;
|
||||
foreach ( $records as $record ) {
|
||||
|
||||
// check connector
|
||||
if ( $record->connector == 'editor' ) {
|
||||
if ( !in_array( $context, array('plugins', 'themes') ) || $action !== 'updated' )
|
||||
continue;
|
||||
} else if ( $connector !== $record->connector ) {
|
||||
|
||||
// check connector
|
||||
if ( $record->connector == 'editor' ) {
|
||||
if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $connector !== $record->connector ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check context
|
||||
if ( $context == 'comments' ) { // multi values
|
||||
$comment_contexts = array( 'post', 'page' );
|
||||
}
|
||||
|
||||
// check context
|
||||
if ( $context == 'comments' ) { // multi values
|
||||
$comment_contexts = array( 'post', 'page' );
|
||||
if ( ! in_array( $record->context, $comment_contexts ) ) {
|
||||
continue;
|
||||
}
|
||||
} else if ( 'post' === $context && 'created' === $action ) {
|
||||
} elseif ( 'post' === $context && 'created' === $action ) {
|
||||
if ( in_array($record->ID, $skip_records) ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -562,8 +561,8 @@ class MainWP_Client_Report {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$count ++;
|
||||
}
|
||||
|
@ -882,8 +881,8 @@ class MainWP_Client_Report {
|
|||
|
||||
if ( isset( $meta[ $meta_key ] ) ) {
|
||||
$value = $meta[ $meta_key ];
|
||||
$value = ( $meta_key == 'user_meta' && isset($value[1]) ) ? $value[1] : current( $value ); // display name
|
||||
|
||||
$value = ( $meta_key == 'user_meta' && isset($value[1]) ) ? $value[1] : current( $value ); // display name
|
||||
|
||||
// to compatible with old meta data
|
||||
if ( 'author_meta' === $meta_key ) {
|
||||
$value = maybe_unserialize( $value );
|
||||
|
|
|
@ -2,26 +2,26 @@
|
|||
|
||||
class MainWP_Helper {
|
||||
|
||||
static function write( $val ) {
|
||||
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
|
||||
$output = self::safe_json_encode( $val );
|
||||
else:
|
||||
static function write( $val ) {
|
||||
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true ) :
|
||||
$output = self::safe_json_encode( $val );
|
||||
else :
|
||||
$output = serialize( $val );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
die( '<mainwp>' . base64_encode( $output ) . '</mainwp>');
|
||||
}
|
||||
|
||||
|
||||
public static function json_valid_check( $data ) {
|
||||
|
||||
if (is_array( $data )) {
|
||||
|
||||
if ( is_array( $data ) ) {
|
||||
$output = array();
|
||||
foreach ( $data as $key => $value) {
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( is_string( $key ) ) {
|
||||
$id = self::json_convert_string( $key );
|
||||
} else {
|
||||
$id = $key;
|
||||
}
|
||||
}
|
||||
if ( is_array( $value ) || is_object( $value ) ) {
|
||||
$output[ $id ] = self::json_valid_check( $value );
|
||||
} elseif ( is_string( $value ) ) {
|
||||
|
@ -30,9 +30,9 @@ class MainWP_Helper {
|
|||
$output[ $id ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( is_object( $data ) ) {
|
||||
$output = new stdClass;
|
||||
$output = new stdClass();
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( is_string( $key ) ) {
|
||||
$id = self::json_convert_string( $key );
|
||||
|
@ -47,39 +47,39 @@ class MainWP_Helper {
|
|||
$output->$id = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (is_string( $data )) {
|
||||
}
|
||||
elseif ( is_string( $data ) ) {
|
||||
return self::json_convert_string( $data );
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function json_convert_string( $str ) {
|
||||
if ( function_exists( 'mb_convert_encoding' )) {
|
||||
$encoding = mb_detect_encoding( $str, mb_detect_order(), true );
|
||||
if ( $encoding ) {
|
||||
return mb_convert_encoding( $str, 'UTF-8', $encoding );
|
||||
} else {
|
||||
return mb_convert_encoding( $str, 'UTF-8', 'UTF-8' );
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function safe_json_encode( $value, $options = 0, $depth = 512) {
|
||||
$encoded = @json_encode($value, $options, $depth);
|
||||
if ($encoded === false && !empty( $value ) && json_last_error() == JSON_ERROR_UTF8 ) {
|
||||
$encoded = @json_encode(self::json_valid_check($value), $options, $depth);
|
||||
public function json_convert_string( $str ) {
|
||||
if ( function_exists( 'mb_convert_encoding' ) ) {
|
||||
$encoding = mb_detect_encoding( $str, mb_detect_order(), true );
|
||||
if ( $encoding ) {
|
||||
return mb_convert_encoding( $str, 'UTF-8', $encoding );
|
||||
} else {
|
||||
return mb_convert_encoding( $str, 'UTF-8', 'UTF-8' );
|
||||
}
|
||||
}
|
||||
return $encoded ;
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function safe_json_encode( $value, $options = 0, $depth = 512 ) {
|
||||
$encoded = @json_encode($value, $options, $depth);
|
||||
if ( $encoded === false && ! empty( $value ) && json_last_error() == JSON_ERROR_UTF8 ) {
|
||||
$encoded = @json_encode(self::json_valid_check($value), $options, $depth);
|
||||
}
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
static function close_connection( $val = null ) {
|
||||
|
||||
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
|
||||
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true ) :
|
||||
$output = self::safe_json_encode( $val );
|
||||
else :
|
||||
$output = serialize( $val );
|
||||
|
@ -102,7 +102,7 @@ class MainWP_Helper {
|
|||
|
||||
static function error( $error, $code = null ) {
|
||||
$information['error'] = $error;
|
||||
if (null !== $code) {
|
||||
if ( null !== $code ) {
|
||||
$information['error_code'] = $code;
|
||||
}
|
||||
self::write( $information );
|
||||
|
@ -114,7 +114,7 @@ class MainWP_Helper {
|
|||
* CSSPARSER
|
||||
* Copyright (C) 2009 Peter Kröner
|
||||
*/
|
||||
public static function parse_css( $css) {
|
||||
public static function parse_css( $css ) {
|
||||
|
||||
// Remove CSS-Comments
|
||||
$css = preg_replace('/\/\*.*?\*\//ms', '', $css);
|
||||
|
@ -125,14 +125,14 @@ class MainWP_Helper {
|
|||
// Append the rest to $blocks
|
||||
array_push($blocks[0], preg_replace('/@.+?\}[^\}]*?\}/ms', '', $css));
|
||||
$ordered = array();
|
||||
for ($i = 0;$i < count($blocks[0]);$i++) {
|
||||
for ( $i = 0;$i < count($blocks[0]);$i++ ) {
|
||||
// If @media-block, strip declaration and parenthesis
|
||||
if (substr($blocks[0][ $i ], 0, 6) === '@media') {
|
||||
if ( substr($blocks[0][ $i ], 0, 6) === '@media' ) {
|
||||
$ordered_key = preg_replace('/^(@media[^\{]+)\{.*\}$/ms', '$1', $blocks[0][ $i ]);
|
||||
$ordered_value = preg_replace('/^@media[^\{]+\{(.*)\}$/ms', '$1', $blocks[0][ $i ]);
|
||||
}
|
||||
// Rule-blocks of the sort @import or @font-face
|
||||
elseif (substr($blocks[0][ $i ], 0, 1) === '@') {
|
||||
elseif ( substr($blocks[0][ $i ], 0, 1) === '@' ) {
|
||||
$ordered_key = $blocks[0][ $i ];
|
||||
$ordered_value = $blocks[0][ $i ];
|
||||
} else {
|
||||
|
@ -144,27 +144,27 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
// Beginning to rebuild new slim CSS-Array
|
||||
foreach ($ordered as $key => $val) {
|
||||
foreach ( $ordered as $key => $val ) {
|
||||
$new = array();
|
||||
for ($i = 0; $i < count($val); $i++) {
|
||||
for ( $i = 0; $i < count($val); $i++ ) {
|
||||
// Split selectors and rules and split properties and values
|
||||
$selector = trim($val[ $i ], " \r\n\t");
|
||||
|
||||
if ( ! empty($selector)) {
|
||||
if ( ! isset($new[ $selector ])) {
|
||||
if ( ! empty($selector) ) {
|
||||
if ( ! isset($new[ $selector ]) ) {
|
||||
$new[ $selector ] = array();
|
||||
}
|
||||
$rules = explode(';', $val[ ++$i ]);
|
||||
foreach ($rules as $rule) {
|
||||
foreach ( $rules as $rule ) {
|
||||
$rule = trim($rule, " \r\n\t");
|
||||
if ( ! empty($rule)) {
|
||||
if ( ! empty($rule) ) {
|
||||
$rule = array_reverse(explode(':', $rule));
|
||||
$property = trim(array_pop($rule), " \r\n\t");
|
||||
$value = implode(':', array_reverse($rule));
|
||||
|
||||
if ( ! isset($new[ $selector ][ $property ]) || ! preg_match('/!important/', $new[ $selector ][ $property ])) {
|
||||
if ( ! isset($new[ $selector ][ $property ]) || ! preg_match('/!important/', $new[ $selector ][ $property ]) ) {
|
||||
$new[ $selector ][ $property ] = $value;
|
||||
} elseif (preg_match('/!important/', $new[ $selector ][ $property ]) && preg_match('/!important/', $value)) {
|
||||
} elseif ( preg_match('/!important/', $new[ $selector ][ $property ]) && preg_match('/!important/', $value) ) {
|
||||
$new[ $selector ][ $property ] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -176,23 +176,23 @@ class MainWP_Helper {
|
|||
$parsed = $ordered;
|
||||
|
||||
$output = '';
|
||||
foreach ($parsed as $media => $content) {
|
||||
if (substr($media, 0, 6) === '@media') {
|
||||
foreach ( $parsed as $media => $content ) {
|
||||
if ( substr($media, 0, 6) === '@media' ) {
|
||||
$output .= $media . " {\n";
|
||||
$prefix = "\t";
|
||||
} else {
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
foreach ($content as $selector => $rules) {
|
||||
foreach ( $content as $selector => $rules ) {
|
||||
$output .= $prefix . $selector . " {\n";
|
||||
foreach ($rules as $property => $value) {
|
||||
foreach ( $rules as $property => $value ) {
|
||||
$output .= $prefix . "\t" . $property . ': ' . $value;
|
||||
$output .= ";\n";
|
||||
}
|
||||
$output .= $prefix . "}\n\n";
|
||||
}
|
||||
if (substr($media, 0, 6) === '@media') {
|
||||
if ( substr($media, 0, 6) === '@media' ) {
|
||||
$output .= "}\n\n";
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ class MainWP_Helper {
|
|||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; // Local name
|
||||
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
|
||||
|
||||
//$gen_unique_fn = true;
|
||||
// $gen_unique_fn = true;
|
||||
|
||||
// to fix issue re-create new attachment
|
||||
if ( $check_file_existed ) {
|
||||
|
@ -227,7 +227,7 @@ class MainWP_Helper {
|
|||
$result = self::get_maybe_existed_attached_id( $local_img_url );
|
||||
if ( is_array($result) ) { // found attachment
|
||||
$attach = current($result);
|
||||
if (is_object($attach)) {
|
||||
if ( is_object($attach) ) {
|
||||
if ( file_exists( $temporary_file ) ) {
|
||||
unlink( $temporary_file );
|
||||
}
|
||||
|
@ -238,13 +238,12 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else { // find in other path
|
||||
} else { // find in other path
|
||||
$result = self::get_maybe_existed_attached_id( $filename, false );
|
||||
|
||||
if ( is_array( $result ) ) { // found attachment
|
||||
$attach = current($result);
|
||||
if (is_object($attach)) {
|
||||
if ( is_object($attach) ) {
|
||||
$basedir = $upload_dir['basedir'];
|
||||
$baseurl = $upload_dir['baseurl'];
|
||||
$local_img_path = str_replace( $baseurl, $basedir, $attach->guid );
|
||||
|
@ -259,13 +258,13 @@ class MainWP_Helper {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// file exists, do not overwrite, generate unique file name
|
||||
// this may causing of issue incorrect source of image in post content
|
||||
if ( file_exists( $local_img_path ) ) {
|
||||
if ( file_exists( $local_img_path ) ) {
|
||||
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
|
||||
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
|
||||
}
|
||||
|
@ -470,12 +469,12 @@ class MainWP_Helper {
|
|||
|
||||
if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) {
|
||||
$edit_post_id = current($post_custom['_mainwp_edit_post_id']);
|
||||
} elseif (isset( $new_post['ID'] ) && $new_post['ID']) {
|
||||
} elseif ( isset( $new_post['ID'] ) && $new_post['ID'] ) {
|
||||
$edit_post_id = $new_post['ID'];
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/post.php';
|
||||
if ($edit_post_id) {
|
||||
if ( $edit_post_id ) {
|
||||
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
|
||||
$user = get_userdata( $user_id );
|
||||
$error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name );
|
||||
|
@ -544,9 +543,9 @@ class MainWP_Helper {
|
|||
$replaceAttachedIds = array();
|
||||
if ( isset( $_POST['post_gallery_images'] ) ) {
|
||||
$post_gallery_images = unserialize(base64_decode( $_POST['post_gallery_images'] ));
|
||||
if (is_array($post_gallery_images)) {
|
||||
foreach ($post_gallery_images as $gallery) {
|
||||
if (isset($gallery['src'])) {
|
||||
if ( is_array($post_gallery_images) ) {
|
||||
foreach ( $post_gallery_images as $gallery ) {
|
||||
if ( isset($gallery['src']) ) {
|
||||
try {
|
||||
$upload = self::uploadImage( $gallery['src'], $gallery ); // Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
|
@ -559,18 +558,18 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (count($replaceAttachedIds) > 0) {
|
||||
if ( count($replaceAttachedIds) > 0 ) {
|
||||
foreach ( $matches as $match ) {
|
||||
$idsToReplace = $match[1];
|
||||
$idsToReplaceWith = '';
|
||||
$originalIds = explode(',', $idsToReplace);
|
||||
foreach ($originalIds as $attached_id) {
|
||||
if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) {
|
||||
foreach ( $originalIds as $attached_id ) {
|
||||
if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ]) ) {
|
||||
$idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ',';
|
||||
}
|
||||
}
|
||||
$idsToReplaceWith = rtrim($idsToReplaceWith, ',');
|
||||
if ( ! empty($idsToReplaceWith)) {
|
||||
if ( ! empty($idsToReplaceWith) ) {
|
||||
$new_post['post_content'] = str_replace( '"' . $idsToReplace . '"', '"' . $idsToReplaceWith . '"', $new_post['post_content'] );
|
||||
}
|
||||
}
|
||||
|
@ -702,11 +701,11 @@ class MainWP_Helper {
|
|||
|
||||
$post_to_only_existing_categories = false;
|
||||
|
||||
if (is_array($post_custom)) {
|
||||
if ( is_array($post_custom) ) {
|
||||
foreach ( $post_custom as $meta_key => $meta_values ) {
|
||||
if ( ! in_array( $meta_key, $not_allowed ) ) {
|
||||
foreach ( $meta_values as $meta_value ) {
|
||||
if (strpos($meta_key, '_mainwp_spinner_') === 0) {
|
||||
if ( strpos($meta_key, '_mainwp_spinner_') === 0 ) {
|
||||
continue; // not save
|
||||
}
|
||||
|
||||
|
@ -753,7 +752,6 @@ class MainWP_Helper {
|
|||
} catch ( Exception $e ) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,7 +784,7 @@ class MainWP_Helper {
|
|||
if ( null !== $upload ) {
|
||||
update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); // Add the thumbnail to the post!
|
||||
$featured_image_exist = true;
|
||||
if (isset($others['featured_image_data'])) {
|
||||
if ( isset($others['featured_image_data']) ) {
|
||||
$_image_data = $others['featured_image_data'];
|
||||
update_post_meta( $upload['id'], '_wp_attachment_image_alt', $_image_data['alt'] );
|
||||
wp_update_post( array(
|
||||
|
@ -870,7 +868,7 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
// unlock if edit post
|
||||
if ($edit_post_id) {
|
||||
if ( $edit_post_id ) {
|
||||
update_post_meta( $edit_post_id, '_edit_lock', '' );
|
||||
}
|
||||
|
||||
|
@ -1098,7 +1096,7 @@ class MainWP_Helper {
|
|||
// $agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
$agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)';
|
||||
|
||||
if ( ! is_array( $postdata )) {
|
||||
if ( ! is_array( $postdata ) ) {
|
||||
$postdata = array();
|
||||
}
|
||||
|
||||
|
@ -1311,7 +1309,7 @@ class MainWP_Helper {
|
|||
static function update_lasttime_backup( $by, $time ) {
|
||||
$backup_by = array( 'backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule' );
|
||||
|
||||
if ( ! in_array($by, $backup_by)) {
|
||||
if ( ! in_array($by, $backup_by) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1324,17 +1322,17 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
static function get_lasttime_backup( $by ) {
|
||||
if ($by == 'backupwp') { // to compatible
|
||||
if ( $by == 'backupwp' ) { // to compatible
|
||||
$by = 'backupwordpress';
|
||||
}
|
||||
switch ($by) {
|
||||
switch ( $by ) {
|
||||
case 'backupbuddy':
|
||||
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' )) {
|
||||
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'backupwordpress':
|
||||
if ( ! is_plugin_active( 'backupwordpress/backupwordpress.php' )) {
|
||||
if ( ! is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -1344,12 +1342,12 @@ class MainWP_Helper {
|
|||
}
|
||||
break;
|
||||
case 'updraftplus':
|
||||
if ( ! is_plugin_active( 'updraftplus/updraftplus.php' )) {
|
||||
if ( ! is_plugin_active( 'updraftplus/updraftplus.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'wptimecapsule':
|
||||
if ( ! is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' )) {
|
||||
if ( ! is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -1523,7 +1521,7 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
public static function sanitize_filename( $filename ) {
|
||||
if ( ! function_exists('mb_ereg_replace')) {
|
||||
if ( ! function_exists('mb_ereg_replace') ) {
|
||||
return sanitize_file_name($filename);
|
||||
}
|
||||
|
||||
|
@ -1608,10 +1606,10 @@ class MainWP_Helper {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (function_exists('get_current_screen')) {
|
||||
if ( function_exists('get_current_screen') ) {
|
||||
$screen = get_current_screen();
|
||||
if ( $screen ) {
|
||||
if ( $screen->base == 'update-core' && $screen->parent_file == 'index.php' ) {
|
||||
if ( $screen->base == 'update-core' && $screen->parent_file == 'index.php' ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1625,21 +1623,21 @@ class MainWP_Helper {
|
|||
|
||||
public static function check_files_exists( $files = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $name) {
|
||||
if ( ! file_exists( $name )) {
|
||||
if ( is_array($files) ) {
|
||||
foreach ( $files as $name ) {
|
||||
if ( ! file_exists( $name ) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( ! file_exists( $files )) {
|
||||
if ( ! file_exists( $files ) ) {
|
||||
$missing[] = $files;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty($missing)) {
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing file(s): ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1648,11 +1646,11 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_classes_exists( $classes = array(), $return = false) {
|
||||
public static function check_classes_exists( $classes = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($classes)) {
|
||||
foreach ($classes as $name) {
|
||||
if ( ! class_exists( $name )) {
|
||||
if ( is_array($classes) ) {
|
||||
foreach ( $classes as $name ) {
|
||||
if ( ! class_exists( $name ) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
|
@ -1664,7 +1662,7 @@ class MainWP_Helper {
|
|||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing classes: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1673,25 +1671,24 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_methods( $object, $methods = array(), $return = false) {
|
||||
public static function check_methods( $object, $methods = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($methods)) {
|
||||
if ( is_array($methods) ) {
|
||||
$missing = array();
|
||||
foreach ($methods as $name) {
|
||||
foreach ( $methods as $name ) {
|
||||
if ( ! method_exists($object, $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty($methods)) {
|
||||
} elseif ( ! empty($methods) ) {
|
||||
if ( ! method_exists($object, $methods) ) {
|
||||
$missing[] = $methods;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing method: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1701,24 +1698,23 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_properties( $object, $properties = array(), $return = false) {
|
||||
public static function check_properties( $object, $properties = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($properties)) {
|
||||
foreach ($properties as $name) {
|
||||
if ( is_array($properties) ) {
|
||||
foreach ( $properties as $name ) {
|
||||
if ( ! property_exists($object, $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty($properties)) {
|
||||
} elseif ( ! empty($properties) ) {
|
||||
if ( ! property_exists($object, $properties) ) {
|
||||
$missing[] = $properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing properties: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1728,24 +1724,23 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_functions( $funcs = array(), $return = false) {
|
||||
public static function check_functions( $funcs = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($funcs)) {
|
||||
foreach ($funcs as $name) {
|
||||
if ( is_array($funcs) ) {
|
||||
foreach ( $funcs as $name ) {
|
||||
if ( ! function_exists( $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty($funcs)) {
|
||||
} elseif ( ! empty($funcs) ) {
|
||||
if ( ! function_exists($funcs) ) {
|
||||
$missing[] = $funcs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing functions: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1774,7 +1769,7 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
|
||||
if ( isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
|
||||
( isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function'] ) // wordpress_seo for WordPress SEO
|
||||
) {
|
||||
register_shutdown_function( 'handle_shutdown' );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue