Merge pull request #136 from mainwp/bogdan01-cf-autofix

Apply fixes from CodeFactor
This commit is contained in:
Thang Hoang Van 2020-05-09 01:07:34 +07:00 committed by GitHub
commit c8c8d8afa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 23 deletions

View file

@ -151,7 +151,7 @@ class MainWP_Child {
$this->run_saved_snippets();
if ( ! get_option( 'mainwp_child_pubkey' ) ) {
MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
}
add_action( 'admin_notices', array( &$this, 'admin_notice' ) );
@ -347,7 +347,7 @@ class MainWP_Child {
if ( ! is_array( get_option( 'mainwp_child_branding_settings' ) ) ) {
$brandingOptions = array(
'hide' => 'mainwp_branding_child_hide',
'extra_settings' => 'mainwp_branding_extra_settings',
'extra_settings' => 'mainwp_branding_extra_settings',
'preserve_branding' => 'mainwp_branding_preserve_branding',
'branding_header' => 'mainwp_branding_plugin_header',
'support_email' => 'mainwp_branding_support_email',
@ -2215,10 +2215,10 @@ class MainWP_Child {
if ( ! isset( $_POST['user'] ) || ! isset( $_POST['pubkey'] ) ) {
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
}
$hint_miss_user = __( 'That administrator username was not found on this child site. Please verify that it is an existing administrator.', 'mainwp-child' ) . '<br/>' . __( 'Hint: Check if the administrator user exists on the child site, if not, you need to use an existing administrator.', 'mainwp-child' );
$user = get_user_by( 'login', $_POST['user'] );
$user = get_user_by( 'login', $_POST['user'] );
if ( empty( $user ) ) {
MainWP_Helper::error( $hint_miss_user );
}
@ -2226,7 +2226,7 @@ class MainWP_Child {
// 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_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
MainWP_Helper::error( __( 'Public key already set. Please deactivate & reactivate the MainWP Child plugin and try again.', 'mainwp-child' ) );
}
@ -2245,7 +2245,7 @@ class MainWP_Child {
// Login.
if ( isset( $_POST['user'] ) ) {
if ( ! $this->login( $_POST['user'] ) ) {
if ( ! $this->login( $_POST['user'] ) ) {
MainWP_Helper::error( $hint_miss_user );
}
@ -3388,7 +3388,7 @@ class MainWP_Child {
$this->update_external_settings();
}
MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', '' );
MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', '' );
if ( isset( $_POST['server'] ) ) {
MainWP_Helper::update_option( 'mainwp_child_server', $_POST['server'] );
}
@ -4925,7 +4925,7 @@ class MainWP_Child {
}
$performed_what = array();
if ( in_array( 'revisions', $maint_options ) ) {
if ( empty( $max_revisions ) ) {
$sql_clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'";
@ -4938,7 +4938,7 @@ class MainWP_Child {
$performed_what[] = 'revisions_max'; // 'Posts revisions deleted'.
}
}
if ( in_array( 'autodraft', $maint_options ) ) {
$sql_clean = "DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'";
$wpdb->query( $sql_clean ); // phpcs:ignore -- safe sql.

View file

@ -580,16 +580,16 @@ class MainWP_Client_Report {
public function get_section_loop_data( $records, $tokens, $section, $skip_records = array() ) {
$maintenance_details = array(
'revisions' => __( 'Delete all post revisions', 'mainwp-child' ),
'revisions_max' => __( 'Delete all post revisions, except for the last:', 'mainwp-child' ),
'autodraft' => __( 'Delete all auto draft posts', 'mainwp-child' ),
'trashpost' => __( 'Delete trash posts', 'mainwp-child' ),
'spam' => __( 'Delete spam comments', 'mainwp-child' ),
'pending' => __( 'Delete pending comments', 'mainwp-child' ),
'trashcomment' => __( 'Delete trash comments', 'mainwp-child' ),
'tags' => __( 'Delete tags with 0 posts associated', 'mainwp-child' ),
'categories' => __( 'Delete categories with 0 posts associated', 'mainwp-child' ),
'optimize' => __( 'Optimize database tables', 'mainwp-child' ),
'revisions' => __( 'Delete all post revisions', 'mainwp-child' ),
'revisions_max' => __( 'Delete all post revisions, except for the last:', 'mainwp-child' ),
'autodraft' => __( 'Delete all auto draft posts', 'mainwp-child' ),
'trashpost' => __( 'Delete trash posts', 'mainwp-child' ),
'spam' => __( 'Delete spam comments', 'mainwp-child' ),
'pending' => __( 'Delete pending comments', 'mainwp-child' ),
'trashcomment' => __( 'Delete trash comments', 'mainwp-child' ),
'tags' => __( 'Delete tags with 0 posts associated', 'mainwp-child' ),
'categories' => __( 'Delete categories with 0 posts associated', 'mainwp-child' ),
'optimize' => __( 'Optimize database tables', 'mainwp-child' ),
);
$context = '';
@ -813,10 +813,10 @@ class MainWP_Client_Report {
if ( isset( $maintenance_details[ $mt ] ) ) {
if ( 'revisions_max' == $mt ) {
$max_revisions = $this->get_stream_meta_data( $record, 'revisions' );
$dtl = $maintenance_details['revisions_max'] . ' ' . $max_revisions;
$dtl = $maintenance_details['revisions_max'] . ' ' . $max_revisions;
} else {
$dtl = $maintenance_details[$mt];
}
$dtl = $maintenance_details[ $mt ];
}
$details[] = $dtl;
}
}