finding( 'screenshot', 'info', 'Homepage screenshot', $home, 'mShots: ' . $shot . ' — open this URL to view the rendered preview.' ); // Key pages we should be able to find $pages = [ 'Home' => $home, 'Login' => wp_login_url(), 'Posts page' => function_exists('get_post_type_archive_link') ? get_post_type_archive_link('post') : '', ]; if (function_exists('get_option')) { $page_for_posts = (int) get_option('page_for_posts'); if ($page_for_posts) $pages['Posts page'] = get_permalink($page_for_posts) ?: $pages['Posts page']; } // WooCommerce shop? if (class_exists('WooCommerce') && function_exists('wc_get_page_id')) { $shop_id = (int) wc_get_page_id('shop'); if ($shop_id > 0) $pages['WC shop'] = get_permalink($shop_id); $cart_id = (int) wc_get_page_id('cart'); if ($cart_id > 0) $pages['WC cart'] = get_permalink($cart_id); $checkout_id = (int) wc_get_page_id('checkout'); if ($checkout_id > 0) $pages['WC checkout'] = get_permalink($checkout_id); } foreach ($pages as $label => $url) { if (!$url) continue; $resp = wp_remote_head($url, ['timeout' => 5, 'redirection' => 3]); if (is_wp_error($resp)) { $f[] = $this->finding('page_' . sanitize_key($label), 'bad', $label, $url, $resp->get_error_message()); continue; } $code = wp_remote_retrieve_response_code($resp); $level = ($code >= 200 && $code < 400) ? 'ok' : 'bad'; $f[] = $this->finding('page_' . sanitize_key($label), $level, $label, 'HTTP ' . $code, $url); } // Mixed content quick check on homepage if (parse_url($home, PHP_URL_SCHEME) === 'https') { $body_resp = wp_remote_get($home, ['timeout' => 6]); if (!is_wp_error($body_resp)) { $body = (string) wp_remote_retrieve_body($body_resp); preg_match_all('/(?:src|href)\s*=\s*["\']http:\/\/[^"\']+["\']/i', $body, $m); $http_count = isset($m[0]) ? count($m[0]) : 0; $f[] = $this->finding( 'mixed_content', $http_count > 0 ? 'warn' : 'ok', 'Mixed content', $http_count . ' http:// reference(s) on homepage', $http_count ? 'Browsers will block or warn — replace with https:// or protocol-relative URLs.' : '' ); } } return $f; } };