mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-08-31 03:53:15 +08:00
Merge with branch01
This commit is contained in:
parent
f586639d8b
commit
c232857821
9 changed files with 516 additions and 488 deletions
|
@ -571,7 +571,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$exclude_string = implode( '|', $excludes->get_excludes_for_regex() );
|
||||
|
||||
if (function_exists('HM\BackUpWordPress\list_directory_by_total_filesize'))
|
||||
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory );
|
||||
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes );
|
||||
|
||||
} else {
|
||||
$files = $schedule->list_directory_by_total_filesize( $directory );
|
||||
|
|
|
@ -132,7 +132,10 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
function save_settings() {
|
||||
$current_values = get_option( 'gpagespeedi_options' );
|
||||
if ( is_array( $current_values ) && false === $current_values['last_run_finished'] ) {
|
||||
require_once GPI_DIRECTORY . '/core/core.php';
|
||||
$googlePagespeedInsights = new googlePagespeedInsights( $current_values );
|
||||
$worker_status = $googlePagespeedInsights->google_pagespeed_insights_Check_Status();
|
||||
if ( $worker_status ) {
|
||||
return array( 'result' => 'RUNNING' );
|
||||
}
|
||||
|
||||
|
@ -229,13 +232,13 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
function do_check_pages($forceRecheck = false) {
|
||||
if ( defined( 'GPI_DIRECTORY' ) ) {
|
||||
$options = get_option( 'gpagespeedi_options' );
|
||||
require_once GPI_DIRECTORY . '/core/core.php';
|
||||
$googlePagespeedInsights = new googlePagespeedInsights( $options );
|
||||
if ( $googlePagespeedInsights ) {
|
||||
$googlePagespeedInsights->googlepagespeedinsightsworker( array(), true, $forceRecheck );
|
||||
return true;
|
||||
}
|
||||
$options = get_option( 'gpagespeedi_options' );
|
||||
require_once GPI_DIRECTORY . '/core/core.php';
|
||||
$googlePagespeedInsights = new googlePagespeedInsights( $options );
|
||||
if ( $googlePagespeedInsights ) {
|
||||
$googlePagespeedInsights->googlepagespeedinsightsworker( array(), true, $forceRecheck );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -244,9 +247,12 @@ class MainWP_Child_Pagespeed {
|
|||
if ( empty( $strategy ) ) {
|
||||
$strategy = 'both';
|
||||
}
|
||||
$current_values = get_option( 'gpagespeedi_options' );
|
||||
|
||||
if ( is_array( $current_values ) && false === $current_values['last_run_finished'] ) {
|
||||
$current_values = get_option( 'gpagespeedi_options' );
|
||||
require_once GPI_DIRECTORY . '/core/core.php';
|
||||
$googlePagespeedInsights = new googlePagespeedInsights( $current_values );
|
||||
$worker_status = $googlePagespeedInsights->google_pagespeed_insights_Check_Status();
|
||||
if ( $worker_status ) {
|
||||
return array( 'result' => 'RUNNING' );
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,7 @@ class MainWP_Child_Server_Information {
|
|||
$dismissWarnings = array();
|
||||
}
|
||||
|
||||
if ( $_POST['what'] == 'conflict' ) {
|
||||
$dismissWarnings['conflicts'] = self::getConflicts();
|
||||
} else if ( $_POST['what'] == 'warning' ) {
|
||||
if ( $_POST['what'] == 'warning' ) {
|
||||
$dismissWarnings['warnings'] = self::getWarnings();
|
||||
}
|
||||
|
||||
|
@ -33,7 +31,6 @@ class MainWP_Child_Server_Information {
|
|||
return;
|
||||
}
|
||||
|
||||
$conflicts = self::getConflicts();
|
||||
$warnings = self::getWarnings();
|
||||
|
||||
$dismissWarnings = get_option( 'mainwp_child_dismiss_warnings' );
|
||||
|
@ -44,11 +41,8 @@ class MainWP_Child_Server_Information {
|
|||
if ( isset( $dismissWarnings['warnings'] ) && $dismissWarnings['warnings'] >= $warnings ) {
|
||||
$warnings = 0;
|
||||
}
|
||||
if ( isset( $dismissWarnings['conflicts'] ) && MainWP_Helper::containsAll( $dismissWarnings['conflicts'], $conflicts ) ) {
|
||||
$conflicts = array();
|
||||
}
|
||||
|
||||
if ( 0 === $warnings && 0 === count( $conflicts ) ) {
|
||||
if ( 0 === $warnings ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,23 +50,7 @@ class MainWP_Child_Server_Information {
|
|||
$dismissWarnings['warnings'] = 0;
|
||||
}
|
||||
|
||||
if ( count( $conflicts ) > 0 ) {
|
||||
$dismissWarnings['conflicts'] = array();
|
||||
}
|
||||
MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings );
|
||||
|
||||
$itheme_ext_activated = ( 'Y' === get_option( 'mainwp_ithemes_ext_activated' ) ) ? true : false;
|
||||
if ( $itheme_ext_activated ) {
|
||||
foreach ( $conflicts as $key => $cf ) {
|
||||
if ( 'iThemes Security' === $cf ) {
|
||||
unset( $conflicts[ $key ] );
|
||||
}
|
||||
}
|
||||
if ( 0 === $warnings && 0 === count( $conflicts ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<script language="javascript">
|
||||
dismiss_warnings = function ( pElement, pAction ) {
|
||||
|
@ -144,17 +122,6 @@ class MainWP_Child_Server_Information {
|
|||
if ( $warnings > 0 ) {
|
||||
$warning .= '<tr><td colspan="2">This site may not connect to your dashboard or may have other issues. Check your <a href="admin.php?page=MainWP_Child_Server_Information">MainWP Server Information page</a> to review and <a href="http://docs.mainwp.com/child-site-issues/">check here for more information on possible fixes</a></td><td style="text-align: right;"><a href="#" id="mainwp-child-connect-warning-dismiss">Dismiss</a></td></tr>';
|
||||
}
|
||||
|
||||
if ( count( $conflicts ) > 0 ) {
|
||||
$warning .= '<tr><td colspan="2">';
|
||||
if ( 1 === count( $conflicts ) ) {
|
||||
$warning .= '"' . $conflicts[0] . '" is';
|
||||
} else {
|
||||
$warning .= '"' . join( '", "', $conflicts ) . '" are';
|
||||
}
|
||||
$warning .= ' installed on this site. This is known to have a potential conflict with MainWP functions. <a href="http://docs.mainwp.com/known-plugin-conflicts/">Please click this link for possible solutions</a></td><td style="text-align: right;"><a href="#" id="mainwp-child-all-pages-warning-dismiss">Dismiss</a></td></tr>';
|
||||
}
|
||||
|
||||
echo $warning;
|
||||
?>
|
||||
</tbody>
|
||||
|
@ -489,8 +456,6 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
</style>
|
||||
<div class="wrap">
|
||||
<h2><?php esc_html_e( 'Plugin Conflicts' ); ?></h2>
|
||||
<br/>
|
||||
<div class="updated below-h2">
|
||||
<p><?php _e( 'Please include this information when requesting support:', 'mainwp' ); ?></p>
|
||||
<span class="mwp_child_close_srv_info"><a href="#" id="mwp_child_download_srv_info"><?php _e( 'Download', 'mainwp' ); ?></a> | <a href="#" id="mwp_child_close_srv_info"><i class="fa fa-eye-slash"></i> <?php _e( 'Hide', 'mainwp' ); ?>
|
||||
|
@ -504,9 +469,7 @@ class MainWP_Child_Server_Information {
|
|||
</div>
|
||||
<br/>
|
||||
<div class="mwp_server_info_box">
|
||||
<?php
|
||||
MainWP_Child_Server_Information::renderConflicts();
|
||||
?><h2><?php esc_html_e( 'Server Information' ); ?></h2><?php
|
||||
<h2><?php esc_html_e( 'Server Information' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::render();
|
||||
?><h2><?php esc_html_e( 'Cron Schedules' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::renderCron();
|
||||
|
@ -551,110 +514,6 @@ class MainWP_Child_Server_Information {
|
|||
return $i;
|
||||
}
|
||||
|
||||
public static function getConflicts() {
|
||||
global $mainWPChild;
|
||||
|
||||
$pluginConflicts = array(
|
||||
'Better WP Security',
|
||||
'iThemes Security',
|
||||
'Secure WordPress',
|
||||
'Wordpress Firewall',
|
||||
'Bad Behavior',
|
||||
'SpyderSpanker',
|
||||
);
|
||||
$conflicts = array();
|
||||
if ( count( $pluginConflicts ) > 0 ) {
|
||||
$plugins = $mainWPChild->get_all_plugins_int( false );
|
||||
foreach ( $plugins as $plugin ) {
|
||||
foreach ( $pluginConflicts as $pluginConflict ) {
|
||||
if ( ( 1 === $plugin['active'] ) && ( ( $plugin['name'] === $pluginConflict ) || ( $plugin['slug'] === $pluginConflict ) ) ) {
|
||||
$conflicts[] = $plugin['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $conflicts;
|
||||
}
|
||||
|
||||
public static function renderConflicts() {
|
||||
$conflicts = self::getConflicts();
|
||||
$branding_title = 'MainWP';
|
||||
if ( MainWP_Child_Branding::is_branding() ) {
|
||||
$branding_title = MainWP_Child_Branding::get_branding();
|
||||
}
|
||||
|
||||
if ( count( $conflicts ) > 0 ) {
|
||||
$information['pluginConflicts'] = $conflicts;
|
||||
?>
|
||||
<style type="text/css">
|
||||
.mainwp-child_info-box-warning {
|
||||
background-color: rgba(187, 114, 57, 0.2) !important;
|
||||
border-bottom: 4px solid #bb7239 !important;
|
||||
border-top: 1px solid #bb7239 !important;
|
||||
border-left: 1px solid #bb7239 !important;
|
||||
border-right: 1px solid #bb7239 !important;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
<?php if ( ! MainWP_Child_Branding::is_branding() ) { ?> padding-left: 4.5em;
|
||||
background-image: url('<?php echo esc_url( plugins_url( 'images/mainwp-icon-orange.png', dirname( __FILE__ ) ) ); ?>') !important;
|
||||
<?php } ?> background-position: 1.5em 50% !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-size: 30px !important;
|
||||
}
|
||||
</style>
|
||||
<table id="mainwp-table" class="wp-list-table widefat mainwp-child_info-box-warning" cellspacing="0">
|
||||
<tbody id="the-sites-list" class="list:sites">
|
||||
<tr>
|
||||
<td colspan="2"><strong><?php echo count( $conflicts ); ?> plugin
|
||||
conflict<?php echo( count( $conflicts ) > 1 ? 's' : '' ); ?> found</strong></td>
|
||||
<td style="text-align: right;"></td>
|
||||
</tr>
|
||||
<?php foreach ( $conflicts as $conflict ) { ?>
|
||||
<tr>
|
||||
<td><strong><?php echo $conflict; ?></strong> is installed on this site. This plugin is known to
|
||||
have a potential conflict with <?php echo esc_html( stripslashes( $branding_title ) ); ?> functions. <a
|
||||
href="http://docs.mainwp.com/known-plugin-conflicts/">Please click this link for
|
||||
possible solutions</a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.mainwp-child_info-box {
|
||||
background-color: rgba(127, 177, 0, 0.2) !important;
|
||||
border-bottom: 4px solid #7fb100 !important;
|
||||
border-top: 1px solid #7fb100 !important;
|
||||
border-left: 1px solid #7fb100 !important;
|
||||
border-right: 1px solid #7fb100 !important;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
<?php if ( ! MainWP_Child_Branding::is_branding() ) { ?> padding-left: 4.5em;
|
||||
background-image: url('<?php echo plugins_url( 'images/mainwp-icon.png', dirname( __FILE__ ) ); ?>') !important;
|
||||
<?php } ?> background-position: 1.5em 50% !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-size: 30px !important;
|
||||
}
|
||||
</style>
|
||||
<table id="mainwp-table" class="wp-list-table widefat mainwp-child_info-box" cellspacing="0">
|
||||
<tbody id="the-sites-list" class="list:sites">
|
||||
<tr>
|
||||
<td>No conflicts found.</td>
|
||||
</td>
|
||||
<td style="text-align: right;"><a href="#" id="mainwp-child-info-dismiss">Dismiss</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?><br/><?php
|
||||
}
|
||||
|
||||
protected static function getFileSystemMethod() {
|
||||
if ( defined( 'MAINWP_SAVE_FS_METHOD' ) ) {
|
||||
return MAINWP_SAVE_FS_METHOD;
|
||||
|
|
|
@ -262,72 +262,72 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
|
||||
// Returns either true (in which case the Vault token will be stored), or false|WP_Error
|
||||
private function vault_connect( $email, $password ) {
|
||||
global $updraftplus;
|
||||
$vault_mothership = 'https://vault.updraftplus.com/plugin-info/';
|
||||
global $updraftplus;
|
||||
$vault_mothership = 'https://vault.updraftplus.com/plugin-info/';
|
||||
|
||||
// Use SSL to prevent snooping
|
||||
$result = wp_remote_post( $vault_mothership.'/?udm_action=vault_connect',
|
||||
array(
|
||||
'timeout' => 20,
|
||||
'body' => array(
|
||||
'e' => $email,
|
||||
'p' => base64_encode( $password ),
|
||||
'sid' => $updraftplus->siteid(),
|
||||
'su' => base64_encode( home_url() )
|
||||
)
|
||||
// Use SSL to prevent snooping
|
||||
$result = wp_remote_post( $vault_mothership.'/?udm_action=vault_connect',
|
||||
array(
|
||||
'timeout' => 20,
|
||||
'body' => array(
|
||||
'e' => $email,
|
||||
'p' => base64_encode( $password ),
|
||||
'sid' => $updraftplus->siteid(),
|
||||
'su' => base64_encode( home_url() )
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $result ) || ( false === $result ) ) return $result;
|
||||
if ( is_wp_error( $result ) || ( false === $result ) ) return $result;
|
||||
|
||||
$response = json_decode( $result['body'], true );
|
||||
$response = json_decode( $result['body'], true );
|
||||
|
||||
if ( !is_array( $response ) || !isset( $response['mothership'] ) || !isset( $response['loggedin'] ) ) {
|
||||
if ( preg_match( '/has banned your IP address \(([\.:0-9a-f]+)\)/', $result['body'], $matches ) ) {
|
||||
return new WP_Error( 'banned_ip', sprintf( __( "UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus' ) . '<br>' . __( "It appears that your web server's IP Address (%s) is blocked.", 'updraftplus' ) . ' ' . __( 'This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus' ) . '<br> <a href="https://updraftplus.com/unblock-ip-address/" target="_blank">' . __( 'To remove the block, please go here.', 'updraftplus' ) . '</a> ', $matches[1] ) );
|
||||
if ( !is_array( $response ) || !isset( $response['mothership'] ) || !isset( $response['loggedin'] ) ) {
|
||||
if ( preg_match( '/has banned your IP address \(([\.:0-9a-f]+)\)/', $result['body'], $matches ) ) {
|
||||
return new WP_Error( 'banned_ip', sprintf( __( "UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus' ) . '<br>' . __( "It appears that your web server's IP Address (%s) is blocked.", 'updraftplus' ) . ' ' . __( 'This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus' ) . '<br> <a href="https://updraftplus.com/unblock-ip-address/" target="_blank">' . __( 'To remove the block, please go here.', 'updraftplus' ) . '</a> ', $matches[1] ) );
|
||||
} else {
|
||||
return new WP_Error( 'unknown_response', sprintf( __( 'UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus' ), $result['body'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
switch ( $response['loggedin'] ) {
|
||||
case 'connected':
|
||||
if ( !empty( $response['token'] ) ) {
|
||||
// Store it
|
||||
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
||||
if ( !is_array( $vault_settings ) ) $vault_settings = array();
|
||||
$vault_settings['email'] = $email;
|
||||
$vault_settings['token'] = (string) $response['token'];
|
||||
$vault_settings['quota'] = -1;
|
||||
unset( $vault_settings['last_config'] );
|
||||
if ( isset($response['quota'] ) ) $vault_settings['quota'] = $response['quota'];
|
||||
UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings );
|
||||
} elseif ( isset( $response['quota'] ) && !$response['quota'] ) {
|
||||
return new WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) );
|
||||
} else {
|
||||
return new WP_Error( 'unknown_response', sprintf( __( 'UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus' ), $result['body'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
switch ( $response['loggedin'] ) {
|
||||
case 'connected':
|
||||
if ( !empty( $response['token'] ) ) {
|
||||
// Store it
|
||||
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
||||
if ( !is_array( $vault_settings ) ) $vault_settings = array();
|
||||
$vault_settings['email'] = $email;
|
||||
$vault_settings['token'] = (string) $response['token'];
|
||||
$vault_settings['quota'] = -1;
|
||||
unset( $vault_settings['last_config'] );
|
||||
if ( isset($response['quota'] ) ) $vault_settings['quota'] = $response['quota'];
|
||||
UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings );
|
||||
} elseif ( isset( $response['quota'] ) && !$response['quota'] ) {
|
||||
return new WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) );
|
||||
} else {
|
||||
return new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
|
||||
}
|
||||
break;
|
||||
case 'authfailed':
|
||||
|
||||
if ( !empty( $response['authproblem'] ) ) {
|
||||
if ( 'invalidpassword' == $response['authproblem'] ) {
|
||||
$authfail_error = new WP_Error( 'authfailed', __( 'Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus' ) . ' <a href="https://updraftplus.com/my-account/lost-password/">' . __( 'If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus' ) . '</a>' );
|
||||
return $authfail_error;
|
||||
} elseif ( 'invaliduser' == $response['authproblem'] ) {
|
||||
return new WP_Error( 'authfailed', __( 'You entered an email address that was not recognised by UpdraftPlus.Com', 'updraftplus' ) );
|
||||
}
|
||||
}
|
||||
|
||||
return new WP_Error( 'authfailed', __( 'Your email address and password were not recognised by UpdraftPlus.Com', 'updraftplus' ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
return new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'authfailed':
|
||||
|
||||
return true;
|
||||
if ( !empty( $response['authproblem'] ) ) {
|
||||
if ( 'invalidpassword' == $response['authproblem'] ) {
|
||||
$authfail_error = new WP_Error( 'authfailed', __( 'Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus' ) . ' <a href="https://updraftplus.com/my-account/lost-password/">' . __( 'If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus' ) . '</a>' );
|
||||
return $authfail_error;
|
||||
} elseif ( 'invaliduser' == $response['authproblem'] ) {
|
||||
return new WP_Error( 'authfailed', __( 'You entered an email address that was not recognised by UpdraftPlus.Com', 'updraftplus' ) );
|
||||
}
|
||||
}
|
||||
|
||||
return new WP_Error( 'authfailed', __( 'Your email address and password were not recognised by UpdraftPlus.Com', 'updraftplus' ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
return new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This method also gets called directly, so don't add code that assumes that it's definitely an AJAX situation
|
||||
|
@ -671,7 +671,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
$options['restrict_files_to_override'] = explode( ',', $_REQUEST['onlythisfileentity'] );
|
||||
}
|
||||
|
||||
do_action( $event, apply_filters( 'updraft_backupnow_options', $options ) );
|
||||
do_action( $event, apply_filters( 'updraft_backupnow_options', $options, array() ) );
|
||||
|
||||
// not used anymore
|
||||
// if (wp_schedule_single_event(time()+5, $event, array($backupnow_nocloud)) === false) {
|
||||
|
@ -2487,7 +2487,7 @@ ENDHERE;
|
|||
}
|
||||
|
||||
private function date_label( $pretty_date, $key, $backup, $jobdata, $nonce ) {
|
||||
$ret = apply_filters( 'updraftplus_showbackup_date', $pretty_date, $backup, $jobdata, (int) $key );
|
||||
$ret = apply_filters( 'updraftplus_showbackup_date', $pretty_date, $backup, $jobdata, (int) $key, false );
|
||||
if ( is_array( $jobdata ) && ! empty( $jobdata['resume_interval'] ) && ( empty( $jobdata['jobstatus'] ) || 'finished' !== $jobdata['jobstatus'] ) ) {
|
||||
$ret .= apply_filters( 'updraftplus_msg_unfinishedbackup', '<br><span title="' . esc_attr( __( 'If you are seeing more backups than you expect, then it is probably because the deletion of old backup sets does not happen until a fresh backup completes.', 'updraftplus' ) ) . '">' . __( '(Not finished)', 'updraftplus' ) . '</span>', $jobdata, $nonce );
|
||||
}
|
||||
|
@ -3220,20 +3220,20 @@ ENDHERE;
|
|||
|
||||
function remove_notices() {
|
||||
$remove_hooks['all_admin_notices'] = array(
|
||||
// 'UpdraftPlus_Admin' => array(
|
||||
// 'show_admin_notice_upgradead' => 10,
|
||||
// 'show_admin_warning_googledrive' => 10,
|
||||
// 'show_admin_warning_dropbox' => 10,
|
||||
// 'show_admin_warning_bitcasa' => 10,
|
||||
// 'show_admin_warning_copycom' => 10,
|
||||
// 'show_admin_warning_onedrive' => 10,
|
||||
// 'show_admin_warning_updraftvault' => 10,
|
||||
// 'show_admin_warning_diskspace' => 10,
|
||||
// 'show_admin_warning_disabledcron' => 10,
|
||||
// 'show_admin_nosettings_warning' => 10,
|
||||
// 'show_admin_warning_execution_time' => 10,
|
||||
// 'show_admin_warning_litespeed' => 10,
|
||||
// ),
|
||||
// 'UpdraftPlus_Admin' => array(
|
||||
// 'show_admin_notice_upgradead' => 10,
|
||||
// 'show_admin_warning_googledrive' => 10,
|
||||
// 'show_admin_warning_dropbox' => 10,
|
||||
// 'show_admin_warning_bitcasa' => 10,
|
||||
// 'show_admin_warning_copycom' => 10,
|
||||
// 'show_admin_warning_onedrive' => 10,
|
||||
// 'show_admin_warning_updraftvault' => 10,
|
||||
// 'show_admin_warning_diskspace' => 10,
|
||||
// 'show_admin_warning_disabledcron' => 10,
|
||||
// 'show_admin_nosettings_warning' => 10,
|
||||
// 'show_admin_warning_execution_time' => 10,
|
||||
// 'show_admin_warning_litespeed' => 10,
|
||||
// ),
|
||||
'UpdraftPlus' => array(
|
||||
'show_admin_warning_unreadablelog' => 10,
|
||||
'show_admin_warning_nolog' => 10,
|
||||
|
|
|
@ -578,8 +578,38 @@ class MainWP_Child_Wordfence {
|
|||
);
|
||||
}
|
||||
|
||||
function simple_crypt($key, $data, $action = 'encrypt'){
|
||||
$res = '';
|
||||
if($action == 'encrypt'){
|
||||
$string = base64_encode( serialize($data) );
|
||||
} else {
|
||||
$string = $data;
|
||||
}
|
||||
for( $i = 0; $i < strlen($string); $i++){
|
||||
$c = ord(substr($string, $i));
|
||||
if($action == 'encrypt'){
|
||||
$c += ord(substr($key, (($i + 1) % strlen($key))));
|
||||
$res .= chr($c & 0xFF);
|
||||
}else{
|
||||
$c -= ord(substr($key, (($i + 1) % strlen($key))));
|
||||
$res .= chr(abs($c) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
if($action !== 'encrypt'){
|
||||
$res = unserialize( base64_decode($res) );
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
function save_setting() {
|
||||
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
||||
if (isset($_POST['encrypted']))
|
||||
$settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost
|
||||
else {
|
||||
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
||||
}
|
||||
|
||||
if ( is_array( $settings ) && count( $settings ) > 0 ) {
|
||||
$result = array();
|
||||
$reload = '';
|
||||
|
|
|
@ -162,9 +162,12 @@ class MainWP_Child {
|
|||
private $maxHistory = 5;
|
||||
|
||||
private $filterFunction = null;
|
||||
private $branding = 'MainWP';
|
||||
public static $brandingTitle = null;
|
||||
private $branding_robust = 'MainWP';
|
||||
|
||||
public static $subPages;
|
||||
public static $subPagesLoaded = false;
|
||||
|
||||
public function __construct( $plugin_file ) {
|
||||
$this->update();
|
||||
|
||||
|
@ -204,10 +207,8 @@ class MainWP_Child {
|
|||
MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', 'yes', 'yes' );
|
||||
}
|
||||
|
||||
$branding_robust = true;
|
||||
$cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
|
||||
|
||||
if ( $branding_robust && ! $cancelled_branding ) {
|
||||
if ( ! $cancelled_branding ) {
|
||||
$branding_header = get_option( 'mainwp_branding_plugin_header' );
|
||||
if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) {
|
||||
$this->branding_robust = stripslashes( $branding_header['name'] );
|
||||
|
@ -510,75 +511,236 @@ class MainWP_Child {
|
|||
$remove_all_child_menu = true;
|
||||
}
|
||||
|
||||
$restorePage = add_submenu_page( 'import.php', $this->branding . ' Restore', $this->branding . ' Restore', 'read', 'mainwp-child-restore', array(
|
||||
'MainWP_Clone',
|
||||
'renderRestore',
|
||||
) );
|
||||
add_action( 'admin_print_scripts-' . $restorePage, array( 'MainWP_Clone', 'print_scripts' ) );
|
||||
|
||||
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
|
||||
$mainwp_child_menu_slug = 'mainwp_child_tab';
|
||||
|
||||
if ( ! $cancelled_branding ) {
|
||||
if ( get_option( 'mainwp_branding_remove_setting' ) ) {
|
||||
if ( get_option( 'mainwp_branding_remove_server_info' ) ) {
|
||||
if ( 0 !== (int) $sitesToClone ) {
|
||||
$mainwp_child_menu_slug = 'MainWP_Clone';
|
||||
} else {
|
||||
$mainwp_child_menu_slug = 'MainWPRestore';
|
||||
}
|
||||
} else {
|
||||
$mainwp_child_menu_slug = 'MainWP_Child_Server_Information';
|
||||
}
|
||||
}
|
||||
}
|
||||
// if preserve branding do not hide menus
|
||||
// hide menu
|
||||
if ( ( ! $remove_all_child_menu && get_option( 'mainwp_branding_child_hide' ) !== 'T' ) || $cancelled_branding ) {
|
||||
$branding_header = get_option( 'mainwp_branding_plugin_header' );
|
||||
|
||||
if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) {
|
||||
$this->branding = $child_menu_name = stripslashes( $branding_header['name'] );
|
||||
$child_menu_icon = '';
|
||||
$child_page_title = $child_menu_name . ' Settings';
|
||||
self::$brandingTitle = $child_menu_title = stripslashes( $branding_header['name'] );
|
||||
$child_page_title = $child_menu_title . ' Settings';
|
||||
} else {
|
||||
$child_menu_name = 'MainWP Child';
|
||||
$child_menu_icon = 'data:image/png+xml;base64,' . base64_encode( file_get_contents( $this->plugin_dir . '/images/mainwpicon.png' ) );
|
||||
$child_menu_title = 'MainWP Child';
|
||||
$child_page_title = 'MainWPSettings';
|
||||
}
|
||||
|
||||
add_menu_page( $child_menu_name, $child_menu_name, 'manage_options', $mainwp_child_menu_slug, false, $child_menu_icon, '80.00001' );
|
||||
$settingsPage = add_submenu_page( 'options-general.php', $child_menu_title, $child_menu_title, 'manage_options', 'mainwp_child_tab', array( &$this, 'render_pages' ) );
|
||||
|
||||
if ( ! get_option( 'mainwp_branding_remove_setting' ) || $cancelled_branding ) {
|
||||
add_submenu_page( 'mainwp_child_tab', $child_page_title, __( $this->branding . ' Settings', 'mainwp-child' ), 'manage_options', 'mainwp_child_tab', array(
|
||||
&$this,
|
||||
'settings',
|
||||
) );
|
||||
add_action( 'admin_print_scripts-' . $settingsPage, array( 'MainWP_Clone', 'print_scripts' ) );
|
||||
$subpageargs = array(
|
||||
'child_slug' => 'options-general.php', // to backwards compatible
|
||||
'branding' => (self::$brandingTitle === null) ? 'MainWP' : self::$brandingTitle,
|
||||
'parent_menu' => $settingsPage
|
||||
);
|
||||
do_action( 'mainwp-child-subpages', $subpageargs ); // to compatible
|
||||
|
||||
$sub_pages = array();
|
||||
$all_subpages = apply_filters( 'mainwp-child-init-subpages', false );
|
||||
if (!self::$subPagesLoaded) {
|
||||
foreach($all_subpages as $page) {
|
||||
$slug = isset($page['slug']) ? $page['slug'] : '';
|
||||
if (empty($slug))
|
||||
continue;
|
||||
$subpage = array();
|
||||
$subpage['slug'] = $slug;
|
||||
$subpage['title'] = $page['title'];
|
||||
$subpage['page'] = 'mainwp-' . str_replace( ' ', '-', strtolower( str_replace( '-', ' ', $slug ) ) );
|
||||
if (isset($page['callback'])) {
|
||||
$subpage['callback'] = $page['callback'];
|
||||
$created_page = add_submenu_page( 'options-general.php', $subpage['title'], '<div class="mainwp-hidden">' . $subpage['title'] . '</div>', 'manage_options', $subpage['page'], $subpage['callback'] );
|
||||
if (isset($page['load_callback'])) {
|
||||
$subpage['load_callback'] = $page['load_callback'];
|
||||
add_action( 'load-' . $created_page, $subpage['load_callback'] );
|
||||
}
|
||||
}
|
||||
$sub_pages[] = $subpage;
|
||||
}
|
||||
self::$subPages = $sub_pages;
|
||||
self::$subPagesLoaded = true;
|
||||
MainWP_Helper::update_option( 'mainwp_child_subpages', self::$subPages );
|
||||
}
|
||||
add_action( 'mainwp-child-pageheader', array( __CLASS__, 'render_header' ) );
|
||||
add_action( 'mainwp-child-pagefooter', array( __CLASS__, 'render_footer' ) );
|
||||
|
||||
if ( ! get_option( 'mainwp_branding_remove_server_info' ) || $cancelled_branding ) {
|
||||
add_submenu_page( $mainwp_child_menu_slug, $child_page_title, __( $this->branding . ' Server Information', 'mainwp-child' ), 'manage_options', 'MainWP_Child_Server_Information', array(
|
||||
'MainWP_Child_Server_Information',
|
||||
'renderPage',
|
||||
) );
|
||||
}
|
||||
|
||||
if ( ! get_option( 'mainwp_branding_remove_restore' ) || $cancelled_branding ) {
|
||||
if ( 0 !== (int) $sitesToClone ) {
|
||||
MainWP_Clone::init_menu( $this->branding, $mainwp_child_menu_slug );
|
||||
} else {
|
||||
MainWP_Clone::init_restore_menu( $this->branding, $mainwp_child_menu_slug );
|
||||
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]) {
|
||||
unset( $submenu['options-general.php'][ $index ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
$subpageargs = array(
|
||||
'child_slug' => $mainwp_child_menu_slug,
|
||||
'branding' => $this->branding,
|
||||
);
|
||||
do_action( 'mainwp-child-subpages', $subpageargs );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function render_pages($shownPage) {
|
||||
if ( isset($_GET['tab']) ) {
|
||||
$shownPage = $_GET['tab'];
|
||||
}
|
||||
|
||||
if (empty($shownPage))
|
||||
$shownPage = 'settings';
|
||||
|
||||
$hide_settings = get_option( 'mainwp_branding_remove_setting' ) ? true : false;
|
||||
$hide_restore = get_option( 'mainwp_branding_remove_restore' ) ? true : false;
|
||||
$hide_server_info = get_option( 'mainwp_branding_remove_server_info' ) ? true : false;
|
||||
$hide_style = 'style="display:none"';
|
||||
|
||||
self::render_header($shownPage, false);
|
||||
?>
|
||||
<?php if (!$hide_settings ) { ?>
|
||||
<div class="mainwp-child-setting-tab settings" <?php echo ('settings' !== $shownPage) ? $hide_style : '' ; ?>>
|
||||
<?php $this->settings(); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( !$hide_restore ) { ?>
|
||||
<div class="mainwp-child-setting-tab restore-clone" <?php echo ('restore-clone' !== $shownPage) ? $hide_style : '' ; ?>>
|
||||
<?php
|
||||
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
|
||||
if ( 0 !== (int)$sitesToClone ) {
|
||||
MainWP_Clone::render();
|
||||
} else {
|
||||
MainWP_Clone::renderNormalRestore();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?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
|
||||
self::render_footer();
|
||||
}
|
||||
|
||||
public static function render_header($shownPage, $subpage = true) {
|
||||
if ( isset($_GET['tab']) ) {
|
||||
$shownPage = $_GET['tab'];
|
||||
}
|
||||
|
||||
if (empty($shownPage))
|
||||
$shownPage = 'settings';
|
||||
|
||||
$hide_settings = get_option( 'mainwp_branding_remove_setting' ) ? true : false;
|
||||
$hide_restore = get_option( 'mainwp_branding_remove_restore' ) ? true : false;
|
||||
$hide_server_info = get_option( 'mainwp_branding_remove_server_info' ) ? true : false;
|
||||
|
||||
$hide_style = 'style="display:none"';
|
||||
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
.mainwp-tabs
|
||||
{
|
||||
margin-top: 2em;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
#mainwp-tabs {
|
||||
clear: both ;
|
||||
}
|
||||
#mainwp-tabs .nav-tab-active {
|
||||
background: #fafafa ;
|
||||
border-top: 1px solid #7fb100 !important;
|
||||
border-left: 1px solid #e5e5e5;
|
||||
border-right: 1px solid #e5e5e5;
|
||||
border-bottom: 1px solid #fafafa !important ;
|
||||
color: #7fb100;
|
||||
}
|
||||
|
||||
#mainwp-tabs .nav-tab {
|
||||
border-top: 1px solid #e5e5e5;
|
||||
border-left: 1px solid #e5e5e5;
|
||||
border-right: 1px solid #e5e5e5;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
padding: 10px 16px;
|
||||
font-size: 14px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#mainwp_wrap-inside {
|
||||
min-height: 80vh;
|
||||
height: 100% ;
|
||||
margin-top: 0em ;
|
||||
padding: 10px ;
|
||||
background: #fafafa ;
|
||||
border-top: none ;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
border-left: 1px solid #e5e5e5;
|
||||
border-right: 1px solid #e5e5e5;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#mainwp_wrap-inside h2.hndle {
|
||||
font-size: 14px;
|
||||
padding: 8px 12px;
|
||||
margin: 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.mainwp-hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><i class="fa fa-file"></i> <?php echo ( self::$brandingTitle === null ? 'MainWP Child' : self::$brandingTitle ); ?></h2>
|
||||
<div style="clear: both;"></div><br/>
|
||||
<div class="mainwp-tabs" id="mainwp-tabs">
|
||||
<?php if ( !$hide_settings ) { ?>
|
||||
<a class="nav-tab pos-nav-tab <?php if ( $shownPage === 'settings' ) { echo 'nav-tab-active'; } ?>" tab-slug="settings" href="<?php echo $subpage ? 'options-general.php?page=mainwp_child_tab&tab=settings' : '#'; ?>" style="margin-left: 0 !important;"><?php _e( 'Settings','mainwp-child' ); ?></a>
|
||||
<?php } ?>
|
||||
<?php if ( !$hide_restore ) { ?>
|
||||
<a class="nav-tab pos-nav-tab <?php if ( $shownPage === 'restore-clone' ) { echo 'nav-tab-active'; } ?>" tab-slug="restore-clone" href="<?php echo $subpage ? 'options-general.php?page=mainwp_child_tab&tab=restore-clone' : '#'; ?>"><?php echo ( 0 !== (int) $sitesToClone ) ? __( 'Restore / Clone','mainwp-child' ) : __( 'Restore','mainwp-child' ); ?></a>
|
||||
<?php } ?>
|
||||
<?php if (!$hide_server_info ) { ?>
|
||||
<a class="nav-tab pos-nav-tab <?php if ( $shownPage === 'server-info' ) { echo 'nav-tab-active'; } ?>" tab-slug="server-info" href="<?php echo $subpage ? 'options-general.php?page=mainwp_child_tab&tab=server-info' : '#'; ?>"><?php _e( 'Server information','mainwp-child' ); ?></a>
|
||||
<?php } ?>
|
||||
<?php
|
||||
if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
|
||||
foreach ( self::$subPages as $subPage ) {
|
||||
?>
|
||||
<a class="nav-tab pos-nav-tab <?php if ( $shownPage == $subPage['slug'] ) { echo 'nav-tab-active'; } ?>" tab-slug="<?php echo $subPage['slug']; ?>" href="options-general.php?page=<?php echo $subPage['page']; ?>"><?php echo $subPage['title']; ?></a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
<script type="text/javascript">
|
||||
jQuery( document ).ready( function () {
|
||||
$hideMenu = jQuery('#menu-settings li a .mainwp-hidden');
|
||||
$hideMenu.each(function(){jQuery(this).closest('li').hide();})
|
||||
|
||||
var $tabs = jQuery( '.mainwp-tabs' );
|
||||
$tabs.on('click', 'a', function () {
|
||||
if (jQuery(this).attr('href') !=='#' )
|
||||
return true;
|
||||
jQuery('.mainwp-tabs > a').removeClass('nav-tab-active');
|
||||
jQuery(this).addClass('nav-tab-active');
|
||||
jQuery('.mainwp-child-setting-tab').hide();
|
||||
var _tab = jQuery(this).attr('tab-slug');
|
||||
jQuery('.mainwp-child-setting-tab.' + _tab ).show();
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<div id="mainwp_wrap-inside">
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function render_footer() {
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function admin_init() {
|
||||
MainWP_Child_Branding::admin_init();
|
||||
}
|
||||
|
@ -591,41 +753,39 @@ class MainWP_Child {
|
|||
MainWP_Helper::update_option( 'mainwp_child_uniqueId', '' );
|
||||
}
|
||||
}
|
||||
//self::render_header('setting');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<div id="icon-options-general" class="icon32"><br></div>
|
||||
<h2><?php esc_html_e( $this->branding . ' Settings', 'mainwp-child' ); ?></h2>
|
||||
|
||||
<div class="postbox" style="margin-top: 6em;">
|
||||
<h3 class="hndle" style="margin: 0 !important; padding: .5em 1em;">
|
||||
<span><?php esc_html_e( 'Connection Settings', 'mainwp-child' ); ?></span></h3>
|
||||
|
||||
<div class="inside">
|
||||
<form method="post" action="">
|
||||
<div
|
||||
class="howto"><?php esc_html_e( 'The Unique Security ID adds additional protection between the Child plugin and your Main Dashboard. The Unique Security ID will need to match when being added to the Main Dashboard. This is additional security and should not be needed in most situations.', 'mainwp-child' ); ?></div>
|
||||
<div style="margin: 1em 0 4em 0;">
|
||||
<input name="requireUniqueSecurityId" type="checkbox"
|
||||
id="requireUniqueSecurityId" <?php if ( '' != get_option( 'mainwp_child_uniqueId' ) ) {
|
||||
echo 'checked';
|
||||
} ?> /> <label for="requireUniqueSecurityId"
|
||||
style="font-size: 15px;"><?php esc_html_e( 'Require Unique Security ID', 'mainwp-child' ); ?></label>
|
||||
</div>
|
||||
<div>
|
||||
<?php if ( '' != get_option( 'mainwp_child_uniqueId' ) ) {
|
||||
echo '<span style="border: 1px dashed #e5e5e5; background: #fafafa; font-size: 24px; padding: 1em 2em;">' . esc_html__( 'Your Unique Security ID is:', 'mainwp-child' ) . ' <span style="font-weight: bold; color: #7fb100;">' . esc_html( get_option( 'mainwp_child_uniqueId' ) ) . '</span></span>';
|
||||
} ?>
|
||||
</div>
|
||||
<p class="submit" style="margin-top: 4em;">
|
||||
<input type="submit" name="submit" id="submit" class="button button-primary"
|
||||
value="<?php esc_html_e( 'Save Changes', 'mainwp-child' ); ?>">
|
||||
</p>
|
||||
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( 'child-settings' );?>">
|
||||
</form>
|
||||
</div>
|
||||
<div class="postbox">
|
||||
<h2 class="hndle"><span><?php esc_html_e( 'Connection Settings', 'mainwp-child' ); ?></span></h2>
|
||||
<div class="inside">
|
||||
<form method="post" action="options-general.php?page=mainwp_child_tab">
|
||||
<div class="howto"><?php esc_html_e( 'The Unique Security ID adds additional protection between the Child plugin and your Main Dashboard. The Unique Security ID will need to match when being added to the Main Dashboard. This is additional security and should not be needed in most situations.', 'mainwp-child' ); ?></div>
|
||||
<div style="margin: 1em 0 4em 0;">
|
||||
<input name="requireUniqueSecurityId"
|
||||
type="checkbox"
|
||||
id="requireUniqueSecurityId" <?php if ( '' != get_option( 'mainwp_child_uniqueId' ) ) { echo 'checked'; } ?> />
|
||||
<label for="requireUniqueSecurityId"
|
||||
style="font-size: 15px;"><?php esc_html_e( 'Require Unique Security ID', 'mainwp-child' ); ?></label>
|
||||
</div>
|
||||
<div>
|
||||
<?php if ( '' != get_option( 'mainwp_child_uniqueId' ) ) {
|
||||
echo '<span style="border: 1px dashed #e5e5e5; background: #fafafa; font-size: 24px; padding: 1em 2em;">' . esc_html__( 'Your Unique Security ID is:', 'mainwp-child' ) . ' <span style="font-weight: bold; color: #7fb100;">' . esc_html( get_option( 'mainwp_child_uniqueId' ) ) . '</span></span>';
|
||||
} ?>
|
||||
</div>
|
||||
<p class="submit" style="margin-top: 4em;">
|
||||
<input type="submit"
|
||||
name="submit"
|
||||
id="submit"
|
||||
class="button button-primary button-hero"
|
||||
value="<?php esc_html_e( 'Save Changes', 'mainwp-child' ); ?>">
|
||||
</p>
|
||||
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( 'child-settings' );?>">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
//self::render_footer('setting');
|
||||
}
|
||||
|
||||
function mod_rewrite_rules( $pRules ) {
|
||||
|
@ -2857,44 +3017,6 @@ class MainWP_Child {
|
|||
$information['users'] = $this->get_all_users_int();
|
||||
}
|
||||
|
||||
if ( isset( $_POST['pluginConflicts'] ) && ( '' !== $_POST['pluginConflicts'] ) ) {
|
||||
$pluginConflicts = json_decode( stripslashes( $_POST['pluginConflicts'] ), true );
|
||||
$conflicts = array();
|
||||
if ( count( $pluginConflicts ) > 0 ) {
|
||||
if ( ! $plugins ) {
|
||||
$plugins = $this->get_all_plugins_int( false );
|
||||
}
|
||||
if ( is_array( $plugins ) && is_array( $pluginConflicts ) ) {
|
||||
foreach ( $plugins as $plugin ) {
|
||||
foreach ( $pluginConflicts as $pluginConflict ) {
|
||||
if ( ( '1' === $plugin['active'] ) && ( ( $plugin['name'] === $pluginConflict ) || ( $plugin['slug'] === $pluginConflict ) ) ) {
|
||||
$conflicts[] = $plugin['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( count( $conflicts ) > 0 ) {
|
||||
$information['pluginConflicts'] = $conflicts;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_POST['themeConflicts'] ) && ( '' !== $_POST['themeConflicts'] ) ) {
|
||||
$themeConflicts = json_decode( stripslashes( $_POST['themeConflicts'] ), true );
|
||||
$conflicts = array();
|
||||
if ( is_array( $themeConflicts ) && count( $themeConflicts ) > 0 ) {
|
||||
$theme = wp_get_theme()->get( 'Name' );
|
||||
foreach ( $themeConflicts as $themeConflict ) {
|
||||
if ( $theme === $themeConflict ) {
|
||||
$conflicts[] = $theme;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( count( $conflicts ) > 0 ) {
|
||||
$information['themeConflicts'] = $conflicts;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_POST['othersData'] ) ) {
|
||||
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
|
||||
if ( ! is_array( $othersData ) ) {
|
||||
|
|
|
@ -10,32 +10,6 @@ class MainWP_Clone {
|
|||
}
|
||||
}
|
||||
|
||||
public static function init_menu( $the_branding, $childMenuSlug = '' ) {
|
||||
if ( empty( $the_branding ) ) {
|
||||
$the_branding = 'MainWP';
|
||||
}
|
||||
$page_title = $the_branding . 'Clone';
|
||||
//$page = add_options_page('MainWP_Clone', __($the_branding . ' Clone','mainwp-child'), 'manage_options', 'MainWP_Clone', array('MainWP_Clone', 'render'));
|
||||
$page = add_submenu_page( $childMenuSlug, $page_title, __( $the_branding . ' Clone', 'mainwp-child' ), 'manage_options', 'MainWP_Clone', array(
|
||||
'MainWP_Clone',
|
||||
'render',
|
||||
) );
|
||||
add_action( 'admin_print_scripts-' . $page, array( 'MainWP_Clone', 'print_scripts' ) );
|
||||
}
|
||||
|
||||
public static function init_restore_menu( $the_branding, $childMenuSlug = '' ) {
|
||||
if ( empty( $the_branding ) ) {
|
||||
$the_branding = 'MainWP';
|
||||
}
|
||||
$page_title = $the_branding . 'Clone';
|
||||
//$page = add_options_page('MainWP_Clone', __($the_branding . ' Restore','mainwp-child'), 'manage_options', 'MainWPRestore', array('MainWP_Clone', 'renderNormalRestore'));
|
||||
$page = add_submenu_page( $childMenuSlug, $page_title, __( $the_branding . ' Restore', 'mainwp-child' ), 'manage_options', 'MainWPRestore', array(
|
||||
'MainWP_Clone',
|
||||
'renderNormalRestore',
|
||||
) );
|
||||
add_action( 'admin_print_scripts-' . $page, array( 'MainWP_Clone', 'print_scripts' ) );
|
||||
}
|
||||
|
||||
public static function print_scripts() {
|
||||
wp_enqueue_script( 'jquery-ui-tooltip' );
|
||||
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
||||
|
@ -52,20 +26,6 @@ class MainWP_Clone {
|
|||
}
|
||||
}
|
||||
|
||||
public static function renderHeader() {
|
||||
self::renderStyle();
|
||||
?>
|
||||
<div class="mainwp-child-container">
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function renderFooter() {
|
||||
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function upload_mimes( $mime_types = array() ) {
|
||||
if ( ! isset( $mime_types['tar.bz2'] ) ) {
|
||||
$mime_types['tar.bz2'] = 'application/x-tar';
|
||||
|
@ -99,11 +59,7 @@ class MainWP_Clone {
|
|||
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
|
||||
$uploadSizeInBytes = min( MainWP_Helper::return_bytes( ini_get( 'upload_max_filesize' ) ), MainWP_Helper::return_bytes( ini_get( 'post_max_size' ) ) );
|
||||
$uploadSize = MainWP_Helper::human_filesize( $uploadSizeInBytes );
|
||||
self::renderHeader();
|
||||
|
||||
?>
|
||||
<div id="icon-options-general" class="icon32"><br></div>
|
||||
<h2><?php esc_html_e( 'Clone or Restore', 'mainwp-child' ); ?></h2><?php
|
||||
self::renderStyle();
|
||||
|
||||
if ( '0' === $sitesToClone ) {
|
||||
echo '<div class="mainwp-child_info-box-red"><strong>' . esc_html__( 'Cloning is currently off - To turn on return to your main dashboard and turn cloning on on the Migrate/Clone page.', 'mainwp-child' ) . '</strong></div>';
|
||||
|
@ -141,13 +97,13 @@ class MainWP_Clone {
|
|||
<form method="post" action="">
|
||||
<div class="mainwp-child_select_sites_box">
|
||||
<div class="postbox">
|
||||
|
||||
<div class="mainwp-child_displayby"><?php esc_html_e( 'Display by:', 'mainwp-child' ); ?> <a
|
||||
class="mainwp-child_action left mainwp-child_action_down" href="#"
|
||||
id="mainwp-child_displayby_sitename"><?php esc_html_e( 'Site Name', 'mainwp-child' ); ?></a><a
|
||||
class="mainwp-child_action right" href="#"
|
||||
id="mainwp-child_displayby_url"><?php esc_html_e( 'URL', 'mainwp-child' ); ?></a></div>
|
||||
<h2><?php esc_html_e( 'Clone Options', 'mainwp-child' ); ?></h2>
|
||||
|
||||
<h2 class="hndle"><?php esc_html_e( 'Clone Options', 'mainwp-child' ); ?></h2>
|
||||
<div class="inside">
|
||||
<div id="mainwp-child_clonesite_select_site">
|
||||
<?php
|
||||
|
@ -182,22 +138,29 @@ class MainWP_Clone {
|
|||
}
|
||||
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
|
||||
?>
|
||||
<div id="icon-options-general" class="icon32"><br></div><h2>
|
||||
<strong><?php esc_html_e( 'Option 1:', 'mainwp-child' ); ?></strong> <?php esc_html_e( 'Restore/Clone From Backup', 'mainwp-child' ); ?>
|
||||
</h2>
|
||||
<br/>
|
||||
<div
|
||||
class="mainwp-child_info-box-green"><?php esc_html_e( 'Upload backup in .zip format (Maximum filesize for your server settings: ', 'mainwp-child' ); ?><?php echo esc_html( $uploadSize ); ?>
|
||||
)
|
||||
</div>
|
||||
<i><?php esc_html_e( 'If you have a FULL backup created by your Network dashboard you may restore it by uploading here.', 'mainwp-child' ); ?>
|
||||
<div class="postbox">
|
||||
<h2 class="hndle"><strong><?php esc_html_e( 'Option 1:', 'mainwp-child' ); ?></strong> <?php esc_html_e( 'Restore/Clone From Backup', 'mainwp-child' ); ?></h2>
|
||||
<div class="inside">
|
||||
<p><?php esc_html_e( 'Upload backup in .zip format (Maximum filesize for your server settings: ', 'mainwp-child' ); ?><?php echo esc_html( $uploadSize ); ?>)</p>
|
||||
<em><?php esc_html_e( 'If you have a FULL backup created by the default MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' ); ?>
|
||||
<br/>
|
||||
<?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></em>
|
||||
<br/>
|
||||
<br/>
|
||||
<?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></i><br/><br/>
|
||||
<form
|
||||
action="<?php echo esc_attr( admin_url( 'admin.php?page=' . ( 0 !== $sitesToClone ? 'MainWP_Clone' : 'MainWPRestore' ) . '&upload=yes' ) ); ?>"
|
||||
method="post" enctype="multipart/form-data"><input type="file" name="file" id="file"/> <input
|
||||
type="submit" name="submit" id="filesubmit" disabled="disabled"
|
||||
value="<?php esc_attr_e( 'Clone/Restore Website', 'mainwp-child' ); ?>"/></form>
|
||||
method="post"
|
||||
enctype="multipart/form-data">
|
||||
<input type="file" name="file" id="file"/>
|
||||
<input type="submit"
|
||||
name="submit"
|
||||
id="filesubmit"
|
||||
class="button button-primary"
|
||||
disabled="disabled"
|
||||
value="<?php esc_attr_e( 'Clone/Restore Website', 'mainwp-child' ); ?>"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
@ -229,52 +192,57 @@ class MainWP_Clone {
|
|||
|
||||
$uploadSizeInBytes = min( MainWP_Helper::return_bytes( ini_get( 'upload_max_filesize' ) ), MainWP_Helper::return_bytes( ini_get( 'post_max_size' ) ) );
|
||||
$uploadSize = MainWP_Helper::human_filesize( $uploadSizeInBytes );
|
||||
self::renderHeader();
|
||||
self::renderStyle();
|
||||
|
||||
?>
|
||||
<div id="icon-options-general" class="icon32"><br></div><h2>
|
||||
<strong><?php esc_html_e( 'Option 1:', 'mainwp-child' ); ?></strong> <?php esc_html_e( 'Restore', 'mainwp-child' ); ?></h2><?php
|
||||
<div class="postbox">
|
||||
<h2 class="hndle"><span><strong><?php esc_html_e( 'Option 1:', 'mainwp-child' ); ?></strong> <?php esc_html_e( 'Restore', 'mainwp-child' ); ?></span></h2>
|
||||
<div class="inside">
|
||||
|
||||
MainWP_Helper::getWPFilesystem();
|
||||
global $wp_filesystem;
|
||||
if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) {
|
||||
echo '<div class="mainwp-child_info-box-red"><strong>' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')</strong></div>';
|
||||
$error = true;
|
||||
}
|
||||
?>
|
||||
<div class="mainwp-child_info-box-green"
|
||||
style="display: none;"><?php esc_html_e( 'Restore process completed successfully! You will now need to click ', 'mainwp-child' ); ?>
|
||||
<a href="<?php echo esc_attr( admin_url( 'options-permalink.php' ) ); ?>"><?php esc_html_e( 'here', 'mainwp-child' ); ?></a><?php esc_html_e( ' to re-login to the admin and re-save permalinks.', 'mainwp-child' ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ( $uploadFile ) {
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#" id="mainwp-child_uploadclonebutton"
|
||||
class="button-primary"
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a><?php
|
||||
} else {
|
||||
<?php
|
||||
MainWP_Helper::getWPFilesystem();
|
||||
global $wp_filesystem;
|
||||
if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) {
|
||||
echo '<div class="mainwp-child_info-box-red"><strong>' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')</strong></div>';
|
||||
$error = true;
|
||||
}
|
||||
?>
|
||||
<div class="mainwp-child_info-box-green" style="display: none;"><?php esc_html_e( 'Restore process completed successfully! You will now need to click ', 'mainwp-child' ); ?>
|
||||
<a href="<?php echo esc_attr( admin_url( 'options-permalink.php' ) ); ?>"><?php esc_html_e( 'here', 'mainwp-child' ); ?></a><?php esc_html_e( ' to re-login to the admin and re-save permalinks.', 'mainwp-child' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
if ( $uploadFile ) {
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#"
|
||||
id="mainwp-child_uploadclonebutton"
|
||||
class="button-primary"
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a><?php
|
||||
} else {
|
||||
if ( $uploadError ) {
|
||||
?>
|
||||
<div class="mainwp-child_info-box-red"><?php echo esc_html( $uploadError ); ?></div><?php
|
||||
<div class="mainwp-child_info-box-red"><?php echo esc_html( $uploadError ); ?></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php esc_html_e( 'Upload backup in .zip format (Maximum filesize for your server settings: ', 'mainwp-child' ); ?><?php echo esc_html( $uploadSize ); ?>)
|
||||
<br/>
|
||||
<i><?php esc_html_e( 'If you have a FULL backup created by your Network dashboard you may restore it by uploading here.', 'mainwp-child' ); ?>
|
||||
<p><?php esc_html_e( 'Upload backup in .zip format (Maximum filesize for your server settings: ', 'mainwp-child' ); ?><?php echo esc_html( $uploadSize ); ?>)</p>
|
||||
<em><?php esc_html_e( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' ); ?>
|
||||
<br/>
|
||||
<?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></i><br/><br/>
|
||||
<form action="<?php echo esc_attr( admin_url( 'admin.php?page=MainWPRestore&upload=yes' ) ); ?>" method="post"
|
||||
enctype="multipart/form-data"><input type="file" name="file" id="file"/> <input type="submit"
|
||||
name="submit"
|
||||
id="filesubmit"
|
||||
disabled="disabled"
|
||||
value="<?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?>"/>
|
||||
<?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></em><br/><br/>
|
||||
<form action="<?php echo esc_attr( admin_url( 'admin.php?page=MainWPRestore&upload=yes' ) ); ?>"
|
||||
method="post"
|
||||
enctype="multipart/form-data">
|
||||
<input type="file" name="file" id="file"/>
|
||||
<input type="submit"
|
||||
name="submit"
|
||||
class="button button-primary"
|
||||
id="filesubmit"
|
||||
disabled="disabled"
|
||||
value="<?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?>"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
self::renderCloneFromServer();
|
||||
|
||||
self::renderJavaScript();
|
||||
}
|
||||
|
||||
|
@ -291,8 +259,8 @@ class MainWP_Clone {
|
|||
|
||||
$page = $_REQUEST['page'];
|
||||
|
||||
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
|
||||
$url = admin_url( 'admin.php?page=' . ( '0' !== $sitesToClone ? 'MainWP_Clone' : 'MainWPRestore' ) . '#title_03' );
|
||||
$sitesToClone = get_option( 'mainwp_child_clone_sites' );
|
||||
$url = admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone#title_03' );
|
||||
|
||||
$dirs = MainWP_Helper::getMainWPDir( 'backup', false );
|
||||
$current_dir = $backup_dir = $dirs[0];
|
||||
|
@ -314,10 +282,10 @@ class MainWP_Clone {
|
|||
if ( strlen( $current_dir ) > 1 ) {
|
||||
$current_dir = untrailingslashit( $current_dir );
|
||||
}
|
||||
|
||||
echo '<br /><hr /><br />';
|
||||
echo '<h2 id="title_03"><strong>' . esc_html__( 'Option 2:', 'mainwp-child' ) . '</strong> ' . esc_html__( 'Restore/Clone From Server', 'mainwp-child' ) . '</h2>';
|
||||
echo '<div class="mainwp-child_info-box-green">' . esc_html__( 'If you have uploaded a FULL backup to your server (via FTP or other means) you can use this section to locate the zip file and select it. A database only backup will not work.', 'mainwp-child' ) . '</div>';
|
||||
echo '<div class="postbox">';
|
||||
echo '<h2 id="title_03" class="hndle"><span><strong>' . esc_html__( 'Option 2:', 'mainwp-child' ) . '</strong> ' . esc_html__( 'Restore/Clone From Server', 'mainwp-child' ) . '</span></h2>';
|
||||
echo '<div class="inside">';
|
||||
echo '<em>' . esc_html__( 'If you have uploaded a FULL backup to your server (via FTP or other means) you can use this section to locate the zip file and select it. A database only backup will not work.', 'mainwp-child' ) . '</em>';
|
||||
|
||||
if ( ! is_readable( $current_dir ) ) {
|
||||
echo '<div class="mainwp-child_info-box-yellow"><strong>' . esc_html__( 'Root directory is not readable. Please contact with site administrator to correct.', 'mainwp-child' ) . '</strong></div>';
|
||||
|
@ -338,7 +306,7 @@ class MainWP_Clone {
|
|||
$dirparts = '<a href="' . $durl . '">' . $part . DIRECTORY_SEPARATOR . '</a>' . $dirparts;
|
||||
}
|
||||
|
||||
echo '<p>' . __( '<strong>Current Directory:</strong> <span>' . $dirparts . '</span>', 'mainwp' ) . '</p>';
|
||||
echo '<div style="padding: 8px 12px; background-color: #e5e5e5; margin-top: 1em;">' . __( '<strong>Current Directory:</strong> <span>' . $dirparts . '</span>', 'mainwp' ) . '</div>';
|
||||
$quick_dirs = array();
|
||||
$quick_dirs[] = array( __( 'Site Root', 'mainwp' ), ABSPATH );
|
||||
$quick_dirs[] = array( __( 'Backup', 'mainwp' ), $backup_dir );
|
||||
|
@ -359,7 +327,7 @@ class MainWP_Clone {
|
|||
}
|
||||
|
||||
if ( ! empty( $quick_links ) ) {
|
||||
echo '<p><strong>' . esc_html__( 'Quick Jump:', 'mainwp' ) . '</strong> ' . __( implode( ' | ', $quick_links ) ) . '</p>';
|
||||
echo '<div style="padding: 8px 12px; border-bottom: 1px solid #e5e5e5; margin-bottom: 1em;"><strong>' . esc_html__( 'Quick Jump:', 'mainwp' ) . '</strong> ' . __( implode( ' | ', $quick_links ) ) . '</div>';
|
||||
}
|
||||
|
||||
$dir_files = scandir( $current_dir );
|
||||
|
@ -389,7 +357,7 @@ class MainWP_Clone {
|
|||
<form method="post" action="">
|
||||
<div class="mainwp-child_select_sites_box" id="mainwp_child_select_files_from_server_box">
|
||||
<div class="postbox">
|
||||
<h2><?php esc_html_e( 'Select File', 'mainwp-child' ); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e( 'Select File', 'mainwp-child' ); ?></h2>
|
||||
|
||||
<div class="inside">
|
||||
<div id="mainwp-child_clonesite_select_site">
|
||||
|
@ -438,13 +406,15 @@ class MainWP_Clone {
|
|||
</div>
|
||||
<div class="mainwp-child_clonebutton_container"><a href="#"
|
||||
id="mainwp-child_clonebutton_from_server"
|
||||
class="button-primary"><?php esc_html_e( 'Clone/Restore Website', 'mainwp-child' ); ?></a>
|
||||
class="button-primary button"><?php esc_html_e( 'Clone/Restore Website', 'mainwp-child' ); ?></a>
|
||||
</div>
|
||||
<div style="clear:both"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<input type="hidden" id="clonesite_from_server_current_dir" value="<?php echo esc_attr( $current_dir ); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
@ -816,8 +786,7 @@ class MainWP_Clone {
|
|||
} );
|
||||
|
||||
</script>
|
||||
<?php
|
||||
self::renderFooter();
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function renderStyle() {
|
||||
|
@ -826,12 +795,6 @@ class MainWP_Clone {
|
|||
#mainwp-child_clone_status {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mainwp-child-container {
|
||||
padding-right: 10px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.mainwp-child_info-box-yellow {
|
||||
margin: 5px 0 15px;
|
||||
padding: .6em;
|
||||
|
@ -863,14 +826,14 @@ class MainWP_Clone {
|
|||
}
|
||||
|
||||
.mainwp-child_select_sites_box {
|
||||
width: 505px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#mainwp-child_clonesite_select_site {
|
||||
max-height: 585px !important;
|
||||
overflow: auto;
|
||||
background: #fff;
|
||||
width: 480px;
|
||||
width: 100%;
|
||||
border: 1px solid #DDDDDD;
|
||||
height: 300px;
|
||||
overflow-y: scroll;
|
||||
|
@ -940,6 +903,7 @@ class MainWP_Clone {
|
|||
float: right;
|
||||
padding-top: 15px;
|
||||
padding-right: 10px;
|
||||
margin-top: -8px;
|
||||
}
|
||||
|
||||
.mainwp-child_url_label {
|
||||
|
@ -954,10 +918,7 @@ class MainWP_Clone {
|
|||
}
|
||||
|
||||
.mainwp-child_clonebutton_container {
|
||||
float: right;
|
||||
padding-right: 10px;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.ui-dialog {
|
||||
|
|
|
@ -121,7 +121,9 @@ class MainWP_Helper {
|
|||
|
||||
}
|
||||
|
||||
static function uploadImage( $img_url ) {
|
||||
static function uploadImage( $img_url, $img_data = array() ) {
|
||||
if (!is_array($img_data))
|
||||
$img_data = array();
|
||||
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
||||
//Download $img_url
|
||||
$temporary_file = download_url( $img_url );
|
||||
|
@ -137,15 +139,17 @@ class MainWP_Helper {
|
|||
$wp_filetype = wp_check_filetype( basename( $img_url ), null ); //Get the filetype to set the mimetype
|
||||
$attachment = array(
|
||||
'post_mime_type' => $wp_filetype['type'],
|
||||
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $img_url ) ),
|
||||
'post_content' => '',
|
||||
'post_title' => isset( $img_data['title'] ) && !empty( $img_data['title'] ) ? $img_data['title'] : preg_replace( '/\.[^.]+$/', '', basename( $img_url ) ),
|
||||
'post_content' => isset( $img_data['description'] ) && !empty( $img_data['description'] ) ? $img_data['description'] : '',
|
||||
'post_excerpt' => isset( $img_data['caption'] ) && !empty( $img_data['caption'] ) ? $img_data['caption'] : '',
|
||||
'post_status' => 'inherit',
|
||||
);
|
||||
$attach_id = wp_insert_attachment( $attachment, $local_img_path ); //Insert the image in the database
|
||||
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
||||
$attach_data = wp_generate_attachment_metadata( $attach_id, $local_img_path );
|
||||
wp_update_attachment_metadata( $attach_id, $attach_data ); //Update generated metadata
|
||||
|
||||
if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) )
|
||||
update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] );
|
||||
return array( 'id' => $attach_id, 'url' => $local_img_url );
|
||||
}
|
||||
}
|
||||
|
@ -300,14 +304,15 @@ class MainWP_Helper {
|
|||
$serverHref = 'href="' . $serverHost;
|
||||
$replaceServerHref = 'href="' . parse_url( $localUrl, PHP_URL_SCHEME ) . '://' . parse_url( $localUrl, PHP_URL_HOST );
|
||||
$new_post['post_content'] = str_replace( $serverHref, $replaceServerHref, $new_post['post_content'] );
|
||||
} else if ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
$lnkToReplace = dirname( $hrefLink );
|
||||
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
$new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] );
|
||||
}
|
||||
}
|
||||
// To fix bug
|
||||
// else if ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
// $lnkToReplace = dirname( $hrefLink );
|
||||
// if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
// $new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
$lnkToReplace = dirname( $imgUrl );
|
||||
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
$new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] );
|
||||
|
@ -318,6 +323,45 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
|
||||
if ( has_shortcode( $new_post['post_content'], 'gallery' ) ) {
|
||||
if ( preg_match_all( '/\[gallery[^\]]+ids=\"(.*?)\"[^\]]*\]/ix', $new_post['post_content'], $matches, PREG_SET_ORDER ) ) {
|
||||
$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'])) {
|
||||
try {
|
||||
$upload = MainWP_Helper::uploadImage( $gallery['src'], $gallery ); //Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
$replaceAttachedIds[$gallery['id']] = $upload['id'];
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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])) {
|
||||
$idsToReplaceWith .= $replaceAttachedIds[$attached_id].",";
|
||||
}
|
||||
}
|
||||
$idsToReplaceWith = rtrim($idsToReplaceWith,",");
|
||||
if (!empty($idsToReplaceWith)) {
|
||||
$new_post['post_content'] = str_replace( '"' . $idsToReplace . '"', '"'.$idsToReplaceWith.'"', $new_post['post_content'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_post_plus ) {
|
||||
$random_publish_date = isset( $post_custom['_saved_draft_random_publish_date'] ) ? $post_custom['_saved_draft_random_publish_date'] : false;
|
||||
$random_publish_date = is_array( $random_publish_date ) ? current( $random_publish_date ) : null;
|
||||
|
|
|
@ -277,9 +277,10 @@ class MainWP_Security {
|
|||
}
|
||||
|
||||
return $src;
|
||||
} else if ( false === strpos( $src, '?ver=' ) ) {
|
||||
self::update_security_option('scripts_version', true);
|
||||
}
|
||||
// else if ( false === strpos( $src, '?ver=' ) ) {
|
||||
// self::update_security_option('scripts_version', true);
|
||||
// }
|
||||
|
||||
return $src;
|
||||
}
|
||||
|
@ -309,9 +310,10 @@ class MainWP_Security {
|
|||
}
|
||||
|
||||
return $src;
|
||||
} else if ( false === strpos( $src, '?ver=' ) ) {
|
||||
self::update_security_option('styles_version', true);
|
||||
}
|
||||
// else if ( false === strpos( $src, '?ver=' ) ) {
|
||||
// self::update_security_option('styles_version', true);
|
||||
// }
|
||||
|
||||
return $src;
|
||||
}
|
||||
|
@ -337,6 +339,10 @@ class MainWP_Security {
|
|||
global $wp_filesystem;
|
||||
if ( ! empty( $wp_filesystem ) ) {
|
||||
$wp_filesystem->delete( ABSPATH . 'readme.html' );
|
||||
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
|
||||
// prevent repeat delete
|
||||
self::update_security_option('readme', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue