diff --git a/class/class-mainwp-child-misc.php b/class/class-mainwp-child-misc.php index 1979147..1dc12bb 100644 --- a/class/class-mainwp-child-misc.php +++ b/class/class-mainwp-child-misc.php @@ -183,9 +183,11 @@ class MainWP_Child_Misc { * * Get security issues information. * + * @param bool $return Either return or not. + * * @uses MainWP_Helper::write() Write response data to be sent to the MainWP Dashboard. */ - public function get_security_stats() { + public function get_security_stats( $return = false ) { $information = array(); $information['listing'] = ( ! MainWP_Security::prevent_listing_ok() ? 'N' : 'Y' ); @@ -199,6 +201,10 @@ class MainWP_Child_Misc { $information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' ); $information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' ); + if ( $return ) { + return $information; + } + MainWP_Helper::write( $information ); } @@ -233,6 +239,11 @@ class MainWP_Child_Misc { $sync = true; } + $skips = isset( $_POST['skip_features'] ) ? $_POST['skip_features'] : array(); + if ( ! is_array( $skips ) ) { + $skips = array(); + } + $information = array(); $security = get_option( 'mainwp_security' ); if ( ! is_array( $security ) ) { @@ -240,50 +251,66 @@ class MainWP_Child_Misc { } if ( 'all' === $_POST['feature'] || 'listing' === $_POST['feature'] ) { - MainWP_Security::prevent_listing(); + if ( ! in_array( 'listing', $skips ) ) { + MainWP_Security::prevent_listing(); + } $information['listing'] = ( ! MainWP_Security::prevent_listing_ok() ? 'N' : 'Y' ); } if ( 'all' === $_POST['feature'] || 'wp_version' === $_POST['feature'] ) { - $security['wp_version'] = true; - MainWP_Security::remove_wp_version( true ); + if ( ! in_array( 'wp_version', $skips ) ) { + $security['wp_version'] = true; + MainWP_Security::remove_wp_version( true ); + } $information['wp_version'] = ( ! MainWP_Security::remove_wp_version_ok() ? 'N' : 'Y' ); } if ( 'all' === $_POST['feature'] || 'rsd' === $_POST['feature'] ) { - $security['rsd'] = true; - MainWP_Security::remove_rsd( true ); + if ( ! in_array( 'rsd', $skips ) ) { + $security['rsd'] = true; + MainWP_Security::remove_rsd( true ); + } $information['rsd'] = ( ! MainWP_Security::remove_rsd_ok() ? 'N' : 'Y' ); } if ( 'all' === $_POST['feature'] || 'wlw' === $_POST['feature'] ) { - $security['wlw'] = true; - MainWP_Security::remove_wlw( true ); + if ( ! in_array( 'wlw', $skips ) ) { + $security['wlw'] = true; + MainWP_Security::remove_wlw( true ); + } $information['wlw'] = ( ! MainWP_Security::remove_wlw_ok() ? 'N' : 'Y' ); } if ( 'all' === $_POST['feature'] || 'db_reporting' === $_POST['feature'] ) { - MainWP_Security::remove_database_reporting(); + if ( ! in_array( 'db_reporting', $skips ) ) { + MainWP_Security::remove_database_reporting(); + } $information['db_reporting'] = ( ! MainWP_Security::remove_database_reporting_ok() ? 'N' : 'Y' ); } if ( 'all' === $_POST['feature'] || 'php_reporting' === $_POST['feature'] ) { - $security['php_reporting'] = true; - MainWP_Security::remove_php_reporting( true ); + if ( ! in_array( 'php_reporting', $skips ) ) { + $security['php_reporting'] = true; + MainWP_Security::remove_php_reporting( true ); + } $information['php_reporting'] = ( ! MainWP_Security::remove_php_reporting_ok() ? 'N' : 'Y' ); } if ( 'all' === $_POST['feature'] || 'versions' === $_POST['feature'] ) { - $security['scripts_version'] = true; - $security['styles_version'] = true; - $security['generator_version'] = true; - MainWP_Security::remove_generator_version( true ); - $information['versions'] = 'Y'; + if ( ! in_array( 'versions', $skips ) ) { + $security['scripts_version'] = true; + $security['styles_version'] = true; + $security['generator_version'] = true; + MainWP_Security::remove_generator_version( true ); + $information['versions'] = 'Y'; + } } if ( 'all' === $_POST['feature'] || 'registered_versions' === $_POST['feature'] ) { - $security['registered_versions'] = true; - $information['registered_versions'] = 'Y'; + if ( ! in_array( 'registered_versions', $skips ) ) { + $security['registered_versions'] = true; + $information['registered_versions'] = 'Y'; + } } if ( 'all' === $_POST['feature'] || 'admin' === $_POST['feature'] ) { @@ -291,8 +318,10 @@ class MainWP_Child_Misc { } if ( 'all' === $_POST['feature'] || 'readme' === $_POST['feature'] ) { - $security['readme'] = true; - MainWP_Security::remove_readme( true ); + if ( ! in_array( 'readme', $skips ) ) { + $security['readme'] = true; + MainWP_Security::remove_readme( true ); + } $information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' ); } diff --git a/class/class-mainwp-child-posts.php b/class/class-mainwp-child-posts.php index b7896b3..41dd7bf 100644 --- a/class/class-mainwp-child-posts.php +++ b/class/class-mainwp-child-posts.php @@ -207,6 +207,10 @@ class MainWP_Child_Posts { $outPost['dts'] = strtotime( $post->post_modified_gmt ); } + if ( 'page' == $post->post_type ) { + $outPost['dts'] = strtotime( $post->post_modified_gmt ); // to order by modified date. + } + if ( 'future' == $post->post_status ) { $outPost['dts'] = strtotime( $post->post_date_gmt ); } @@ -419,9 +423,9 @@ class MainWP_Child_Posts { wp_publish_post( $postId ); wp_update_post( array( - 'ID' => $postId, - 'post_date' => current_time( 'mysql', false ), - 'post_date_gmt' => current_time( 'mysql', true ), + 'ID' => $postId, + 'post_date' => current_time( 'mysql', false ), + 'post_date_gmt' => current_time( 'mysql', true ), ) ); } else { diff --git a/class/class-mainwp-child-stats.php b/class/class-mainwp-child-stats.php index db8e293..be33131 100644 --- a/class/class-mainwp-child-stats.php +++ b/class/class-mainwp-child-stats.php @@ -209,6 +209,7 @@ class MainWP_Child_Stats { $information['recent_posts'] = MainWP_Child_Posts::get_instance()->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number ); $information['recent_pages'] = MainWP_Child_Posts::get_instance()->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number, 'page' ); $information['securityIssues'] = MainWP_Security::get_stats_security(); + $information['securityStats'] = MainWP_Child_Misc::get_security_stats( true ); // Directory listings! $information['directories'] = $this->scan_dir( ABSPATH, 3 ); @@ -585,8 +586,8 @@ class MainWP_Child_Stats { // Fixes incorrect info. if ( ! property_exists( $plugin_update, 'update' ) || ! property_exists( $plugin_update->update, 'new_version' ) || empty( $plugin_update->update->new_version ) ) { continue; - } - + } + $plugin_update->active = is_plugin_active( $slug ) ? 1 : 0; $results[ $slug ] = $plugin_update; } } @@ -613,6 +614,7 @@ class MainWP_Child_Stats { } if ( ! isset( $results[ $slug ] ) ) { + $plugin_update->active = is_plugin_active( $slug ) ? 1 : 0; $results[ $slug ] = $plugin_update; } } diff --git a/class/class-mainwp-child-updates.php b/class/class-mainwp-child-updates.php index 8982120..76250f1 100644 --- a/class/class-mainwp-child-updates.php +++ b/class/class-mainwp-child-updates.php @@ -532,12 +532,14 @@ class MainWP_Child_Updates { public function upgrade_get_theme_updates() { $themeUpdates = get_theme_updates(); $newThemeUpdates = array(); + $theme_name = wp_get_theme()->get( 'Name' ); if ( is_array( $themeUpdates ) ) { foreach ( $themeUpdates as $slug => $themeUpdate ) { $newThemeUpdate = array(); $newThemeUpdate['update'] = $themeUpdate->update; $newThemeUpdate['Name'] = MainWP_Helper::search( $themeUpdate, 'Name' ); $newThemeUpdate['Version'] = MainWP_Helper::search( $themeUpdate, 'Version' ); + $newThemeUpdate['active'] = ( $newThemeUpdate['Name'] === $theme_name ) ? 1 : 0; $newThemeUpdates[ $slug ] = $newThemeUpdate; } }