function maintenance_site()
 {
     global $wpdb;
     $information = array();
     if (isset($_POST['action'])) {
         if ('save_settings' === $_POST['action']) {
             if (isset($_POST['enable_alert']) && '1' === $_POST['enable_alert']) {
                 MainWP_Helper::update_option('mainwp_maintenance_opt_alert_404', 1, 'yes');
             } else {
                 delete_option('mainwp_maintenance_opt_alert_404');
             }
             if (isset($_POST['email']) && !empty($_POST['email'])) {
                 MainWP_Helper::update_option('mainwp_maintenance_opt_alert_404_email', $_POST['email'], 'yes');
             } else {
                 delete_option('mainwp_maintenance_opt_alert_404_email');
             }
             $information['result'] = 'SUCCESS';
             MainWP_Helper::write($information);
             return;
         } else {
             if ('clear_settings' === $_POST['action']) {
                 delete_option('mainwp_maintenance_opt_alert_404');
                 delete_option('mainwp_maintenance_opt_alert_404_email');
                 $information['result'] = 'SUCCESS';
                 MainWP_Helper::write($information);
             }
         }
         MainWP_Helper::write($information);
     }
     $maint_options = $_POST['options'];
     $max_revisions = isset($_POST['revisions']) ? intval($_POST['revisions']) : 0;
     if (!is_array($maint_options)) {
         $information['status'] = 'FAIL';
         $maint_options = array();
     }
     if (empty($max_revisions)) {
         $sql_clean = "DELETE FROM {$wpdb->posts} WHERE post_type = 'revision'";
         $wpdb->query($sql_clean);
     } else {
         $results = MainWP_Helper::getRevisions($max_revisions);
         $count_deleted = MainWP_Helper::deleteRevisions($results, $max_revisions);
     }
     if (in_array('autodraft', $maint_options)) {
         $sql_clean = "DELETE FROM {$wpdb->posts} WHERE post_status = 'auto-draft'";
         $wpdb->query($sql_clean);
     }
     if (in_array('trashpost', $maint_options)) {
         $sql_clean = "DELETE FROM {$wpdb->posts} WHERE post_status = 'trash'";
         $wpdb->query($sql_clean);
     }
     if (in_array('spam', $maint_options)) {
         $sql_clean = "DELETE FROM {$wpdb->comments} WHERE comment_approved = 'spam'";
         $wpdb->query($sql_clean);
     }
     if (in_array('pending', $maint_options)) {
         $sql_clean = "DELETE FROM {$wpdb->comments} WHERE comment_approved = '0'";
         $wpdb->query($sql_clean);
     }
     if (in_array('trashcomment', $maint_options)) {
         $sql_clean = "DELETE FROM {$wpdb->comments} WHERE comment_approved = 'trash'";
         $wpdb->query($sql_clean);
     }
     if (in_array('tags', $maint_options)) {
         $post_tags = get_terms('post_tag', array('hide_empty' => false));
         if (is_array($post_tags)) {
             foreach ($post_tags as $tag) {
                 if (0 === $tag->count) {
                     wp_delete_term($tag->term_id, 'post_tag');
                 }
             }
         }
     }
     if (in_array('categories', $maint_options)) {
         $post_cats = get_terms('category', array('hide_empty' => false));
         if (is_array($post_cats)) {
             foreach ($post_cats as $cat) {
                 if (0 === $cat->count) {
                     wp_delete_term($cat->term_id, 'category');
                 }
             }
         }
     }
     if (in_array('optimize', $maint_options)) {
         $this->maintenance_optimize();
     }
     if (!isset($information['status'])) {
         $information['status'] = 'SUCCESS';
     }
     MainWP_Helper::write($information);
 }