mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-08-17 20:29:32 +08:00
Fixed: stagging compatible update issue
Fixed: file size error for some host Added: reconnect with user pw
This commit is contained in:
parent
7d246b77b6
commit
3d888cea6e
5 changed files with 60 additions and 24 deletions
|
@ -440,6 +440,8 @@ class MainWP_Child_Staging { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
|
||||
if ( file_exists( WPSTG_PLUGIN_DIR . 'app/Backend/views/clone/ajax/start.php' ) ) {
|
||||
ob_start();
|
||||
require_once WPSTG_PLUGIN_DIR . 'app/Backend/views/clone/ajax/start.php'; // NOSONAR - WP compatible.
|
||||
|
@ -468,6 +470,22 @@ class MainWP_Child_Staging { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
require_once WPSTG_PLUGIN_DIR . 'Backend/views/clone/ajax/start.php'; // NOSONAR - WP compatible.
|
||||
$result = ob_get_clean();
|
||||
}
|
||||
} elseif ( defined( 'WPSTG_VIEWS_DIR' ) && file_exists( WPSTG_VIEWS_DIR . 'clone/ajax/scan.php' ) ) { // new version >= 3.8.4.
|
||||
if ( file_exists( WPSTG_PLUGIN_DIR . 'Core/WPStaging.php' ) ) {
|
||||
include_once WPSTG_PLUGIN_DIR . 'Core/WPStaging.php'; // NOSONAR -- WP compatible.
|
||||
$this->assets = \WPStaging\Core\WPStaging::make( \WPStaging\Framework\Assets\Assets::class ); // to fix error since ver 3.1.3.
|
||||
|
||||
$subDirectory = str_replace( get_home_path(), '', ABSPATH );
|
||||
$urlsHelper = \WPStaging\Core\WPStaging::make( \WPStaging\Framework\Utils\Urls::class );
|
||||
$url = $urlsHelper->getHomeUrl() . str_replace( '/', '', $subDirectory );
|
||||
$result = array(
|
||||
'url' => $url,
|
||||
'blog_name' => get_bloginfo( 'name' ),
|
||||
'clone' => $cloning->getOptions()->clone,
|
||||
'img_src' => $this->assets->getAssetsUrl( 'img/admin_dashboard.png' ),
|
||||
'version3' => 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -631,6 +649,12 @@ class MainWP_Child_Staging { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
require_once WPSTG_PLUGIN_DIR . 'Backend/views/clone/ajax/update.php'; // NOSONAR - WP compatible.
|
||||
$result = ob_get_clean();
|
||||
}
|
||||
} elseif ( defined( 'WPSTG_VIEWS_DIR' ) && file_exists( WPSTG_VIEWS_DIR . 'clone/ajax/scan.php' ) ) { // new version >= 3.8.4.
|
||||
$result = array(
|
||||
'clone' => $cloning->getOptions()->clone,
|
||||
'mainJob' => $cloning->getOptions()->mainJob,
|
||||
'version3' => 1,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -879,7 +879,11 @@ class MainWP_Child_Stats { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
if ( class_exists( '\RecursiveIteratorIterator' ) ) {
|
||||
$size = 0;
|
||||
foreach ( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $directory ) ) as $file ) {
|
||||
$size += $file->getSize();
|
||||
try {
|
||||
$size += $file->getSize();
|
||||
} catch ( \Exception $e ) {
|
||||
// prevent error some hosts.
|
||||
}
|
||||
}
|
||||
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
|
||||
return $size / 1024 / 1024;
|
||||
|
|
|
@ -86,51 +86,53 @@ class MainWP_Connect { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
// phpcs:disable WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
// Check if the user is valid & login.
|
||||
if ( ! isset( $_POST['user'] ) || ! isset( $_POST['pubkey'] ) ) {
|
||||
MainWP_Helper::instance()->error( sprintf( esc_html__( 'Public key could not be set. Please make sure that the OpenSSL library has been configured correctly on your MainWP Dashboard. For additional help, please check this %1$shelp document%2$s.', 'mainwp-child' ), '<strong><a href="https://kb.mainwp.com/docs/cant-connect-website-getting-the-invalid-request-error-message/" target="_blank">', '</a></strong>' ) );
|
||||
MainWP_Helper::instance()->error( sprintf( esc_html__( 'Public key could not be set. Please make sure that the OpenSSL library has been configured correctly on your MainWP Dashboard. For additional help, please check this %1$shelp document%2$s.', 'mainwp-child' ), '<strong><a href="https://kb.mainwp.com/docs/cant-connect-website-getting-the-invalid-request-error-message/" target="_blank">', '</a></strong>' ), 'REG_ERROR1' );
|
||||
}
|
||||
|
||||
// Already added - can't readd. Deactivate plugin.
|
||||
if ( get_option( 'mainwp_child_pubkey' ) ) {
|
||||
|
||||
// Set disconnect status to yes here, it will empty after reconnected.
|
||||
MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Public key already set. Please deactivate & reactivate the MainWP Child plugin on the child site and try again.', 'mainwp-child' ) );
|
||||
// if register verified, then go to next step.
|
||||
if ( ! $this->is_verified_register( wp_unslash( $_POST['user'] ) ) ) {
|
||||
// Set disconnect status to yes here, it will empty after reconnected.
|
||||
MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Public key already set. Please deactivate & reactivate the MainWP Child plugin on the child site and try again.', 'mainwp-child' ), 'REG_ERROR2' );
|
||||
}
|
||||
}
|
||||
|
||||
$uniqueId = MainWP_Helper::get_site_unique_id();
|
||||
// Check the Unique Security ID.
|
||||
if ( '' !== $uniqueId ) {
|
||||
if ( ! isset( $_POST['uniqueId'] ) || ( '' === $_POST['uniqueId'] ) ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'This child site is set to require a unique security ID. Please enter it before the connection can be established.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'This child site is set to require a unique security ID. Please enter it before the connection can be established.', 'mainwp-child' ), 'REG_ERROR3' );
|
||||
} elseif ( $uniqueId !== $_POST['uniqueId'] ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'The unique security ID mismatch! Please correct it before the connection can be established.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'The unique security ID mismatch! Please correct it before the connection can be established.', 'mainwp-child' ), 'REG_ERROR4' );
|
||||
}
|
||||
}
|
||||
|
||||
// Check SSL Requirement.
|
||||
if ( ! MainWP_Helper::is_ssl_enabled() && ( ! defined( 'MAINWP_ALLOW_NOSSL_CONNECT' ) || ! MAINWP_ALLOW_NOSSL_CONNECT ) ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'OpenSSL library is required on the child site to set up a secure connection.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'OpenSSL library is required on the child site to set up a secure connection.', 'mainwp-child' ), 'REG_ERROR5' );
|
||||
}
|
||||
|
||||
// Check Curl SSL Requirement.
|
||||
if ( ! MainWP_Child_Server_Information_Base::get_curl_support() ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'cURL Extension not enabled on the child site server. Please contact your host support and have them enabled it for you.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'cURL Extension not enabled on the child site server. Please contact your host support and have them enabled it for you.', 'mainwp-child' ), 'REG_ERROR6' );
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['user'] ) && ! $this->is_verified_register( wp_unslash( $_POST['user'] ) ) ) {
|
||||
if ( isset( $_POST['regverify'] ) ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Failed to reconnect to the site. Please remove the site and add it again.', 'mainwp-child' ), 'reconnect_failed' );
|
||||
} else {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Unable to connect to the site. Please verify that your Admin Username and Password are correct and try again.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Unable to connect to the site. Please verify that your Admin Username and Password are correct and try again.', 'mainwp-child' ), 'REG_ERROR7' );
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the user exists and if yes, check if it's administartor user.
|
||||
if ( empty( $_POST['user'] ) || ! $this->login( wp_unslash( $_POST['user'] ) ) ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Administrator user does not exist. Please verify that the user is an existing administrator.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Administrator user does not exist. Please verify that the user is an existing administrator.', 'mainwp-child' ), 'REG_ERROR8' );
|
||||
}
|
||||
if ( ! MainWP_Helper::is_admin() ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'User is not an administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'User is not an administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ), 'REG_ERROR9' );
|
||||
}
|
||||
|
||||
// Update the mainwp_child_pubkey option.
|
||||
|
@ -396,7 +398,7 @@ class MainWP_Connect { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
public function parse_init_auth( $auth = false ) { // phpcs:ignore -- NOSONAR - Current complexity is the only way to achieve desired results, pull request solutions appreciated.
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if ( ! $auth && isset( $_POST['mainwpsignature'] ) ) { // with 'mainwpsignature' then need to callable functions.
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this child site and try again.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this child site and try again.', 'mainwp-child' ), 'PARSE_ERROR1' );
|
||||
}
|
||||
|
||||
if ( ! $auth && isset( $_POST['function'] ) ) {
|
||||
|
@ -405,7 +407,7 @@ class MainWP_Connect { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
$callable_no_auth = MainWP_Child_Callable::get_instance()->is_callable_function_no_auth( $func );
|
||||
|
||||
if ( $callable && ! $callable_no_auth && isset( $_POST['mainwpsignature'] ) ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this site and try again.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this site and try again.', 'mainwp-child' ), 'PARSE_ERROR2' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,11 +435,11 @@ class MainWP_Connect { //phpcs:ignore -- NOSONAR - multi methods.
|
|||
}
|
||||
|
||||
if ( ! $user ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Unexisting administrator user. Please verify that it is an existing administrator.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Unexisting administrator user. Please verify that it is an existing administrator.', 'mainwp-child' ), 'PARSE_ERROR3' );
|
||||
}
|
||||
|
||||
if ( ! MainWP_Helper::is_admin( $user ) ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'User not administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ) );
|
||||
MainWP_Helper::instance()->error( esc_html__( 'User not administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ), 'PARSE_ERROR4' );
|
||||
}
|
||||
|
||||
// try to login.
|
||||
|
|
15
phpcs.xml
15
phpcs.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<!-- Check all PHP files in directory tree by default. -->
|
||||
<file>.</file>
|
||||
|
||||
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>*/bin/*</exclude-pattern>
|
||||
<exclude-pattern>*/.github/*</exclude-pattern>
|
||||
|
@ -23,8 +23,8 @@
|
|||
<rule ref="WordPress">
|
||||
<exclude name="WordPress.NamingConventions.ValidVariableName" />
|
||||
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
|
||||
|
||||
<!-- Disable Strict comparison in array check. Not applicable in the mojority of cases. -->
|
||||
|
||||
<!-- Disable Strict comparison in array check. Not applicable in the mojority of cases. -->
|
||||
<exclude name="WordPress.PHP.StrictInArray" />
|
||||
|
||||
<exclude name="WordPress.WP.I18n" />
|
||||
|
@ -38,20 +38,21 @@
|
|||
<exclude name="Universal.ControlStructures.IfElseDeclaration.NoNewLine" />
|
||||
<exclude name="Universal.Classes.RequireFinalClass.NonFinalClassFound" />
|
||||
<exclude name="Universal.Namespaces.EnforceCurlyBraceSyntax.Forbidden" />
|
||||
|
||||
|
||||
<exclude name="Generic.Commenting.Todo" />
|
||||
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
|
||||
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch" />
|
||||
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent" />
|
||||
<exclude name="WordPress.WP.CapitalPDangit.Misspelled" />
|
||||
</rule>
|
||||
|
||||
|
||||
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||
<properties>
|
||||
<property name="indent" value="4"/>
|
||||
<property name="tabIndent" value="false"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent" />
|
||||
|
||||
|
||||
</ruleset>
|
||||
|
|
|
@ -125,3 +125,8 @@ We have an extensive FAQ with more questions and answers [here](https://mainwp.c
|
|||
[See Video Changelog](https://youtu.be/DF0vC1RiCVI)
|
||||
|
||||
[See changelog for all versions.](https://mainwp.com/mainwp-child-changelog.txt)
|
||||
|
||||
= 5.2.1 - 11-20-2024 =
|
||||
|
||||
* Added: After activating the MainWP plugin, users are now redirected to the MainWP Settings page for a smoother onboarding experience.
|
||||
* Updated: The Unique Security ID option is now enabled by default to enhance security for all MainWP installations.
|
Loading…
Add table
Add a link
Reference in a new issue