public function run()
 {
     $loaded_pages = 0;
     $urls = GRAV_TESTS::get_general_page_urls();
     $unique_errors = array();
     $errors = array();
     foreach ($urls as $url) {
         if ($contents = wp_remote_get(GRAV_TESTS::url_add_auth($url, $this->id), array('sslverify' => false, 'timeout' => 15))) {
             if (!empty($contents['body'])) {
                 preg_match_all('/(.+):(.+) in (\\/.+) on line ([0-9]+)/', $contents['body'], $matches);
                 if (!empty($matches[1]) && !empty($matches[2]) && !empty($matches[3]) && !empty($matches[4])) {
                     foreach ($matches[1] as $key => $error) {
                         $unique_errors[sanitize_title($matches[0][$key])] = array('message' => 'PHP ' . $matches[1][$key] . ' - ' . $matches[2][$key], 'location' => $matches[3][$key], 'line' => $matches[4][$key]);
                     }
                 }
             }
             if (strpos($contents['body'], '<html') !== false) {
                 $loaded_pages++;
             }
         }
     }
     if (!empty($unique_errors)) {
         foreach ($unique_errors as $key => $error) {
             $errors[] = $error;
         }
     }
     if (!empty($errors)) {
         return array('pass' => false, 'errors' => $errors, 'message' => 'There are (' . count($errors) . ') PHP Errors');
     }
     if (!$loaded_pages) {
         return array('pass' => null, 'message' => 'Error loading Pages');
     }
     return array('pass' => true, 'message' => 'No Errors found in (' . $loaded_pages . ') Pages');
 }
 public function run()
 {
     if (GRAV_TESTS::guess_environment() === 'local') {
         return array('pass' => null, 'message' => 'Cannot Validate when using Localhost. Try on a valid Hostname.', 'location' => $item->url);
     }
     $loaded_pages = 0;
     $urls = GRAV_TESTS::get_general_page_urls();
     $errors = array();
     foreach ($urls as $url) {
         if ($contents = wp_remote_get('https://validator.w3.org/nu/?doc=' . $url, array('sslverify' => false, 'timeout' => 15))) {
             if (!empty($contents['body'])) {
                 if (strpos($contents['body'], '<div id="results">') === false) {
                     return array('pass' => null, 'message' => 'Error loading W3C Validator', 'location' => '');
                 }
                 if (strpos($contents['body'], '<li class="error">') !== false) {
                     $errors[] = array('message' => 'Page (' . $url . ') is not HTML Valid. <a target="_blank" href="' . 'https://validator.w3.org/nu/?doc=' . $url . '">Learn More</a>', 'location' => $url);
                 }
                 $loaded_pages++;
             }
         }
     }
     if (!$loaded_pages) {
         return array('pass' => null, 'message' => 'Error loading W3C Validator');
     }
     if (!empty($errors)) {
         return array('pass' => false, 'errors' => $errors, 'message' => 'There are (' . count($errors) . ') Pages with Errors');
     }
     return array('pass' => true, 'message' => 'Successfully Validated (' . $loaded_pages . ') Pages');
 }
 public function js_urls()
 {
     $urls = GRAV_TESTS::get_general_page_urls();
     $js_urls = array();
     foreach ($urls as $url) {
         $js_urls[] = array('url' => $url, 'with_admin_bar' => false, 'width' => 800, 'height' => 600);
     }
     return $js_urls;
 }