Plugin Directory

Changeset 3846572


Ignore:
Timestamp:
12/05/2026 04:56:48 PM (4 hours ago)
Author:
oliversech
Message:

Version 1.4.4: new free checks, update reminder, dashboard widget

Location:
secherit-site-health-monitor/trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • secherit-site-health-monitor/trunk/assets/admin.css

    r3845057 r3846572  
    204204.sp-trialbar__close{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:6px;color:#8c8f94;font-size:20px;line-height:1;text-decoration:none}
    205205.sp-trialbar__close:hover,.sp-trialbar__close:focus{background:#f0f0f1;color:#1d2327}
     206
     207.sp-pages-setup__explain{margin:0 25px 18px;padding:14px 16px;border:1px solid #e6ecf5;border-radius:10px;background:#f8fafd;color:#3e506a;font-size:12px;line-height:1.6}
     208.sp-pages-setup__explain p{margin:0 0 6px}.sp-pages-setup__explain p:last-child{margin:8px 0 0}
     209.sp-pages-setup__explain ul{margin:0 0 0 18px;list-style:disc}.sp-pages-setup__explain li{margin:2px 0}
     210.sp-pages-setup__suggest{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 25px 16px;font-size:12px;color:#3e506a}
     211.sp-chip{border:1px solid #c5d9ed;background:#fff;color:#2271b1;border-radius:999px;padding:5px 12px;font-size:12px;font-weight:600;cursor:pointer}
     212.sp-chip:hover,.sp-chip:focus{background:#f0f6fc;border-color:#2271b1}
     213.sp-chip[disabled]{opacity:.5;cursor:default}
  • secherit-site-health-monitor/trunk/assets/admin.js

    r3805959 r3846572  
    4747  });
    4848})();
     49
  • secherit-site-health-monitor/trunk/includes/admin-view.php

    r3843620 r3846572  
    113113    <?php do_action( 'sitepilot_dashboard_notices', $tab ); ?>
    114114    <?php if ( isset( $_GET['notice'] ) ) : $notice = sanitize_key( wp_unslash( $_GET['notice'] ) ); ?>
    115 <div class="sp-alert" role="status"><?php echo esc_html( array( 'saved' => 'Settings saved successfully.', 'repaired' => 'Selected safe repair completed.' )[ $notice ] ?? 'Action completed.' ); ?></div>
     115<div class="sp-alert" role="status"><?php echo esc_html( array( 'saved' => __( 'Settings saved successfully.', 'secherit-site-health-monitor' ), 'repaired' => __( 'Selected safe repair completed.', 'secherit-site-health-monitor' ), 'update_check_done' => __( 'Checks finished. Your results after the update are below.', 'secherit-site-health-monitor' ), 'update_check_failed' => __( 'The checks could not finish. Try Run checks again in a moment.', 'secherit-site-health-monitor' ) )[ $notice ] ?? 'Action completed.' ); ?></div>
    116116    <?php endif; ?>
    117117    <div class="sp-toast" id="sp-toast" role="status" aria-live="polite" hidden></div>
    … …  
    200200      <section class="sp-page-heading"><div><span class="sp-kicker"><?php esc_html_e( 'YOUR WORKSPACE', 'secherit-site-health-monitor' ); ?></span><h1><?php esc_html_e( 'Settings', 'secherit-site-health-monitor' ); ?></h1><p><?php esc_html_e( 'Configure your monitored pages.', 'secherit-site-health-monitor' ); ?></p></div></section>
    201201      <form class="sp-settings" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"><input type="hidden" name="action" value="sitepilot_settings"><?php wp_nonce_field( 'sitepilot_settings' ); ?>
    202       <section class="sp-panel"><div class="sp-panel__head"><div><h3><?php esc_html_e( 'Priority website pages', 'secherit-site-health-monitor' ); ?></h3><p><?php esc_html_e( 'One full URL or site-relative path per line, on your own domain only', 'secherit-site-health-monitor' ); ?></p></div></div><label for="sp-watch"><?php esc_html_e( 'Pages to monitor', 'secherit-site-health-monitor' ); ?></label><textarea id="sp-watch" name="watch_urls" rows="5"><?php echo esc_textarea( implode( "\n", $s['watch_urls'] ) ); ?></textarea><small class="sp-help">Configure up to <?php echo esc_html( $sp->page_limit() ); ?> pages. Home is always supported.</small></section>
     202      <section class="sp-panel sp-pages-setup"><div class="sp-panel__head"><div><h3><?php esc_html_e( 'Pages to check', 'secherit-site-health-monitor' ); ?></h3><p><?php esc_html_e( 'Choose the pages that would cost you visitors, customers or sales if they broke.', 'secherit-site-health-monitor' ); ?></p></div></div>
     203        <div class="sp-pages-setup__explain">
     204          <p><strong><?php esc_html_e( 'What happens to these pages', 'secherit-site-health-monitor' ); ?></strong></p>
     205          <ul>
     206            <li><?php esc_html_e( 'Each check opens them like a visitor and makes sure they load.', 'secherit-site-health-monitor' ); ?></li>
     207            <li><?php esc_html_e( 'Every link on them to the rest of your site is tested for errors.', 'secherit-site-health-monitor' ); ?></li>
     208            <li><?php esc_html_e( 'Forms and buttons are looked for, so you notice when one disappears.', 'secherit-site-health-monitor' ); ?></li>
     209            <li><?php esc_html_e( 'Google visibility, page title, meta description and insecure files are checked.', 'secherit-site-health-monitor' ); ?></li>
     210          </ul>
     211          <p><strong><?php esc_html_e( 'Good pages to add:', 'secherit-site-health-monitor' ); ?></strong> <?php esc_html_e( 'your home page, contact page, pricing or main product page, checkout, and the page most visitors land on.', 'secherit-site-health-monitor' ); ?></p>
     212        </div>
     213        <?php $sitepilot_suggestions = array_diff( $sp->suggested_pages(), (array) $s['watch_urls'] ); ?>
     214        <?php if ( $sitepilot_suggestions ) : ?>
     215        <div class="sp-pages-setup__suggest"><span><?php esc_html_e( 'Suggested from your site:', 'secherit-site-health-monitor' ); ?></span>
     216          <?php foreach ( $sitepilot_suggestions as $sitepilot_label => $sitepilot_url ) : ?>
     217            <button type="button" class="sp-chip" data-sp-add-url="<?php echo esc_attr( $sitepilot_url ); ?>" title="<?php echo esc_attr( $sitepilot_url ); ?>">+ <?php echo esc_html( $sitepilot_label ); ?></button>
     218          <?php endforeach; ?>
     219        </div>
     220        <?php endif; ?>
     221        <label for="sp-watch"><?php esc_html_e( 'Pages to check (one per line)', 'secherit-site-health-monitor' ); ?></label>
     222        <textarea id="sp-watch" name="watch_urls" rows="5" data-sp-limit="<?php echo esc_attr( $sp->page_limit() ); ?>" placeholder="<?php echo esc_attr( home_url( '/' ) . "\n" . home_url( '/contact/' ) . "\n/pricing/" ); ?>"><?php echo esc_textarea( implode( "\n", $s['watch_urls'] ) ); ?></textarea>
     223        <small class="sp-help"><?php
     224            echo esc_html( sprintf(
     225                /* translators: 1: maximum number of pages, 2: example address. */
     226                __( 'Up to %1$d pages on this website. Paste the full address (for example %2$s) or just the part after the domain (/contact/). Click a suggestion above to add it, then Save settings.', 'secherit-site-health-monitor' ),
     227                $sp->page_limit(),
     228                home_url( '/contact/' )
     229            ) );
     230        ?></small>
     231      </section>
    203232      <section class="sp-panel"><div class="sp-panel__head"><div><h3><?php esc_html_e( 'Data on removal', 'secherit-site-health-monitor' ); ?></h3><p><?php esc_html_e( 'By default your history and settings are kept, so a reinstall starts where you left off.', 'secherit-site-health-monitor' ); ?></p></div></div><input type="hidden" name="sitepilot_uninstall_field" value="1"><label class="sp-toggle-row"><span><strong><?php esc_html_e( 'Delete all data when the plugin is deleted', 'secherit-site-health-monitor' ); ?></strong><small><?php esc_html_e( 'Removes check history, settings and scheduled tasks. Kept automatically while the Premium add-on is installed.', 'secherit-site-health-monitor' ); ?></small></span><input type="checkbox" name="sitepilot_delete_data" value="1" <?php checked( '1', get_option( 'sitepilot_delete_data_on_uninstall' ) ); ?>></label></section>
    204233      <div class="sp-form-footer"><button type="submit" class="sp-btn sp-btn--primary"><span class="dashicons dashicons-saved"></span> <?php esc_html_e( 'Save settings', 'secherit-site-health-monitor' ); ?></button></div></form>
    … …  
    214243<section class="sp-page-heading"><div><span class="sp-kicker"><?php esc_html_e( 'PLANS', 'secherit-site-health-monitor' ); ?></span><h1>Plans &amp; license</h1><p><?php esc_html_e( 'Compare the plans and learn how to activate the separate Premium add-on.', 'secherit-site-health-monitor' ); ?></p></div></section>
    215244<div class="sp-plan-options">
    216 <section class="sp-plan-option"><div class="sp-plan-option__labels"><span class="sp-tier sp-tier--free"><?php esc_html_e( 'Free', 'secherit-site-health-monitor' ); ?></span><span class="sp-current-plan"><?php esc_html_e( 'Current plan', 'secherit-site-health-monitor' ); ?></span></div><h2><?php esc_html_e( 'Site Health Monitor Free', 'secherit-site-health-monitor' ); ?></h2><p><?php esc_html_e( 'Run checks on demand. No account or license required.', 'secherit-site-health-monitor' ); ?></p><ul class="sp-plan-list"><li><?php esc_html_e( 'Monitor up to 3 selected pages', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Manual HTTP and internal link checks', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Detect rendered forms and buttons', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Check history and CSV export', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Website optimization audit', 'secherit-site-health-monitor' ); ?></li></ul></section>
     245<section class="sp-plan-option"><div class="sp-plan-option__labels"><span class="sp-tier sp-tier--free"><?php esc_html_e( 'Free', 'secherit-site-health-monitor' ); ?></span><span class="sp-current-plan"><?php esc_html_e( 'Current plan', 'secherit-site-health-monitor' ); ?></span></div><h2><?php esc_html_e( 'Site Health Monitor Free', 'secherit-site-health-monitor' ); ?></h2><p><?php esc_html_e( 'Run checks on demand. No account or license required.', 'secherit-site-health-monitor' ); ?></p><ul class="sp-plan-list"><li><?php esc_html_e( 'Monitor up to 5 selected pages', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Manual HTTP and internal link checks', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Detect rendered forms and buttons', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Check history and CSV export', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Website optimization audit', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Google visibility, mixed content, SEO basics and redirect checks', 'secherit-site-health-monitor' ); ?></li></ul></section>
    217246<section class="sp-plan-option sp-plan-option--pro"><div class="sp-plan-option__labels"><span class="sp-tier sp-tier--pro"><?php esc_html_e( 'Premium', 'secherit-site-health-monitor' ); ?></span></div><h2><?php esc_html_e( 'Site Health Monitor Premium', 'secherit-site-health-monitor' ); ?></h2><p><?php esc_html_e( 'All Free features plus automated monitoring and advanced tools.', 'secherit-site-health-monitor' ); ?></p><ul class="sp-plan-list"><li><?php esc_html_e( 'Scheduled monitoring for up to 20 pages', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Email alerts and weekly reports', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'PHP and JavaScript error monitoring', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Important element monitoring and after-update checks', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Internal link repair, preview and undo', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'SSL expiry, response time and broken image checks', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'WooCommerce payment-method availability checks', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Optional update file backups and recovery', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Visual comparisons with a configured browser worker', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'One-click Optimize for speed, database and security', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Action center', 'secherit-site-health-monitor' ); ?></li><li><?php esc_html_e( 'Smart Fix with supported repairs and opt-in schedule recovery', 'secherit-site-health-monitor' ); ?></li></ul><a class="sp-upgrade-button" href="<?php echo esc_url( $upgrade_url ); ?>"><?php esc_html_e( 'Learn about Premium', 'secherit-site-health-monitor' ); ?> <span aria-hidden="true">↗</span></a></section>
    218247</div>
  • secherit-site-health-monitor/trunk/includes/class-sitepilot-growth.php

    r3845057 r3846572  
    4242        if ( ! empty( $state['done'] ) || (int) ( $state['until'] ?? 0 ) > time() ) { return false; }
    4343        $first = (int) get_option( 'sitepilot_first_scan_at', 0 );
    44         return (int) get_option( 'sitepilot_scan_count', 0 ) >= 3 && $first && time() - $first >= 7 * DAY_IN_SECONDS
     44        return (int) get_option( 'sitepilot_scan_count', 0 ) >= 2 && $first && time() - $first >= 3 * DAY_IN_SECONDS
    4545            && ! get_option( 'sitepilot_scan_error' ) && ! get_option( 'sitepilot_history_error' );
    4646    }
    … …  
    7272        }
    7373        if ( count( (array) $sp->get_settings()['watch_urls'] ) >= $sp->page_limit() ) {
    74             $candidates['page-limit'] = __( 'You are monitoring the 3 pages included in Free. Premium monitors up to 20 pages.', 'secherit-site-health-monitor' );
     74            $candidates['page-limit'] = __( 'You are monitoring the 5 pages included in Free. Premium monitors up to 20 pages.', 'secherit-site-health-monitor' );
    7575        }
    7676        foreach ( $sp->current_checks( 50, 'health' ) as $row ) {
  • secherit-site-health-monitor/trunk/includes/class-sitepilot.php

    r3843620 r3846572  
    153153    public function has_pro_addon() { return false; }
    154154    // The separately installed add-on supplies pro(); Free alone always returns false.
    155     public function page_limit() { return $this->pro() ? 20 : 3; }
     155    public function page_limit() { return $this->pro() ? 20 : 5; }
    156156    public function get_settings() { $s = $this->settings; $s['watch_urls'] = array_values( array_unique( array_filter( array_map( array( $this, 'clean_public_url' ), array_slice( (array) $s['watch_urls'], 0, $this->page_limit() ) ) ) ) ); return $s; }
    157157    const UPGRADE_URL = 'https://secherit.dk/product/secherit-sitepilot/';
    … …  
    282282        wp_enqueue_style( 'sitepilot-optimize', SITEPILOT_URL . 'assets/optimize.css', array( 'sitepilot-admin' ), SITEPILOT_VERSION . '.' . (int) filemtime( SITEPILOT_DIR . 'assets/optimize.css' ) );
    283283        wp_enqueue_script( 'sitepilot-admin', apply_filters( 'sitepilot_admin_script_url', SITEPILOT_URL . 'assets/admin.js' ), array(), apply_filters( 'sitepilot_admin_script_version', SITEPILOT_VERSION ), true );
     284        wp_enqueue_script( 'sitepilot-settings', SITEPILOT_URL . 'assets/settings.js', array(), SITEPILOT_VERSION . '.' . (int) filemtime( SITEPILOT_DIR . 'assets/settings.js' ), true );
    284285        wp_localize_script( 'sitepilot-admin', 'SitePilotAdmin', array( 'root' => esc_url_raw( rest_url( 'sitepilot/v1/' ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'running' => __( 'Running checks…', 'secherit-site-health-monitor' ) ) );
    285286    }
    … …  
    324325    }
    325326
    326     public function render_first_scan() {
     327    /** Pages suggested for the first scan: home, plus contact and checkout when they exist. */
     328    public function suggested_watch() {
    327329        $watch = $this->get_settings()['watch_urls'];
    328330        if ( $watch === array( $this->clean_public_url( home_url( '/' ) ) ) ) {
    … …  
    341343            $watch = $this->parse_urls( implode( "\n", $watch ), $this->page_limit() );
    342344        }
     345        return $watch;
     346    }
     347
     348    /** Pages on this site worth monitoring, as label => URL, for the settings screen. */
     349    public function suggested_pages() {
     350        $out = array( __( 'Home page', 'secherit-site-health-monitor' ) => home_url( '/' ) );
     351        $groups = array(
     352            __( 'Contact', 'secherit-site-health-monitor' ) => array( 'contact', 'contact-us', 'kontakt' ),
     353            __( 'Pricing', 'secherit-site-health-monitor' ) => array( 'pricing', 'prices', 'priser' ),
     354            __( 'About', 'secherit-site-health-monitor' ) => array( 'about', 'about-us', 'om-os', 'om' ),
     355        );
     356        foreach ( $groups as $label => $slugs ) {
     357            foreach ( $slugs as $slug ) {
     358                $page = get_page_by_path( $slug, OBJECT, 'page' );
     359                if ( $page && 'publish' === $page->post_status && ! $page->post_password ) { $out[ $label ] = get_permalink( $page ); break; }
     360            }
     361        }
     362        if ( function_exists( 'wc_get_page_id' ) ) {
     363            foreach ( array( 'shop' => __( 'Shop', 'secherit-site-health-monitor' ), 'cart' => __( 'Cart', 'secherit-site-health-monitor' ), 'checkout' => __( 'Checkout', 'secherit-site-health-monitor' ) ) as $key => $label ) {
     364                $id = wc_get_page_id( $key );
     365                $page = $id > 0 ? get_post( $id ) : null;
     366                if ( $page && 'publish' === $page->post_status && ! $page->post_password ) { $out[ $label ] = get_permalink( $page ); }
     367            }
     368        }
     369        $posts_page = (int) get_option( 'page_for_posts' );
     370        if ( $posts_page && 'publish' === get_post_status( $posts_page ) ) { $out[ __( 'Blog', 'secherit-site-health-monitor' ) ] = get_permalink( $posts_page ); }
     371        return array_filter( array_map( array( $this, 'clean_public_url' ), $out ) );
     372    }
     373
     374    /** Runs a scan from outside the dashboard (first-run and after-update checks). */
     375    public function run_background_scan( $watch = null ) {
     376        return $this->run_scan( $watch );
     377    }
     378
     379    public function render_first_scan() {
     380        $watch = $this->suggested_watch();
    343381        require SITEPILOT_DIR . 'includes/first-scan-view.php';
    344382    }
    … …  
    429467                'headers' => array( 'User-Agent' => 'SitePilot/' . SITEPILOT_VERSION . ' (+site-monitor)', 'Cache-Control' => 'no-cache' ), 'cookies' => array() ) );
    430468            if ( is_wp_error( $response ) ) { return $response; }
    431             if ( ! in_array( (int) wp_remote_retrieve_response_code( $response ), array( 301, 302, 303, 307, 308 ), true ) ) { $response['sitepilot_final_url'] = $url; return $response; }
     469            if ( ! in_array( (int) wp_remote_retrieve_response_code( $response ), array( 301, 302, 303, 307, 308 ), true ) ) { $response['sitepilot_final_url'] = $url; $response['sitepilot_hops'] = $i; return $response; }
    432470            $location = wp_remote_retrieve_header( $response, 'location' );
    433471            $next = is_string( $location ) && '' !== $location ? $this->clean_public_url( $this->resolve_link( $url, $location ) ) : '';
    … …  
    500538                'why' => 'Without it, your site is not checked automatically and you will not get alerts.',
    501539                'fix' => 'Deactivate and reactivate the plugin, or use the repair button. If it keeps disappearing, ask your host whether WordPress Cron is disabled.',
     540            ),
     541            'search_visibility' => array(
     542                'what' => 'The setting "Discourage search engines from indexing this site" is turned on, so Google is asked to leave your whole site out of search results.',
     543                'why' => 'Nobody can find you on Google. This setting is often left on by mistake after a site was built or moved.',
     544                'fix' => 'Go to Settings > Reading, untick "Discourage search engines from indexing this site" and save. Then ask Google to index your home page in Search Console.',
     545            ),
     546            'page_noindex' => array(
     547                'what' => 'This page contains a "noindex" instruction, so Google will not show it in search results.',
     548                'why' => 'If this is one of your important pages, people cannot find it on Google.',
     549                'fix' => 'In your SEO plugin, open the page and allow it in search results (in Yoast: Advanced > Allow search engines to show this page). If the instruction comes from your host or a security plugin, remove it there. Ignore this if the page should be private.',
     550            ),
     551            'mixed_content' => array(
     552                'what' => 'Some images, scripts or styles on this secure https page are still loaded over insecure http.',
     553                'why' => 'Browsers may block these files or show "Not secure", which can break the layout and scare visitors.',
     554                'fix' => 'Change the addresses to https:// in the page or theme settings. A search-and-replace plugin can update old http:// addresses in the database. Back up first.',
     555            ),
     556            'seo_basics' => array(
     557                'what' => 'This page has no title or no meta description for search results.',
     558                'why' => 'Google then writes its own text, which is often less clear, and fewer people click your result.',
     559                'fix' => 'Add a page title and a short description (about 150 characters) in your SEO plugin, for example in the Yoast box below the page editor.',
     560            ),
     561            'redirect_chain' => array(
     562                'what' => 'Some links on this page go through two or more redirects before they reach the right page.',
     563                'why' => 'Every redirect makes the page slower to open, and search engines may stop following long chains.',
     564                'fix' => 'Edit the links so they point straight to the final address. You can see the final address by opening the link in your browser.',
    502565            ),
    503566            'php_dom' => array(
    … …  
    543606        } elseif ( 'health' === $row->kind && isset( self::health_explanations()[ $details['check'] ?? '' ] ) && 'plugin_updates' !== ( $details['check'] ?? '' ) ) {
    544607            $e = self::health_explanations()[ $details['check'] ];
     608            $examples = array_map( 'esc_url_raw', array_slice( (array) ( $details['examples'] ?? array() ), 0, 3 ) );
     609            if ( $examples ) { $e['what'] .= ' ' . __( 'For example:', 'secherit-site-health-monitor' ) . ' ' . implode( ', ', $examples ) . '.'; }
    545610            $out = array_merge( $out, $e, array( 'message' => $e['what'] . ' ' . $e['why'] . ' ' . $e['fix'] ) );
    546611        } elseif ( 'health' === $row->kind && 'plugin_updates' === ( $details['check'] ?? '' ) ) {
    … …  
    603668            if ( ! $parsed ) { $this->record_unverified_elements( $url ); continue; }
    604669            $this->log_check( 'health', $url, 'info', 'HTML parsing available.', array( 'check' => 'php_dom' ) );
     670            $this->page_quality_checks( $url, $response, $dom );
    605671            $forms = $dom->getElementsByTagName( 'form' );
    606672            $buttons = $dom->getElementsByTagName( 'button' );
    … …  
    640706        }
    641707        $links = array_slice( $links, 0, 60 );
     708        $chains = array();
     709        $chain_checked = array();
    642710        foreach ( $links as $link ) {
    643711            if ( microtime( true ) - $start > 22 ) { break; }
    … …  
    648716            if ( 'fail' === $status ) { $results['broken']++; }
    649717            if ( 'warning' === $status ) { $results['unverified_links']++; }
     718            if ( 'pass' === $status ) {
     719                $chain_checked[ $link_queue[ $link ] ] = true;
     720                if ( (int) ( $r['sitepilot_hops'] ?? 0 ) >= 2 ) { $chains[ $link_queue[ $link ] ][] = $link; }
     721            }
    650722            $this->log_check( 'link', $link, $status, $message, array( 'code' => $code, 'source_url' => $link_queue[ $link ], 'error' => is_wp_error( $r ) ? mb_substr( $r->get_error_message(), 0, 200 ) : '' ) );
     723        }
     724        foreach ( array_keys( $chain_checked ) as $source ) {
     725            $found = $chains[ $source ] ?? array();
     726            $n = count( $found );
     727            $this->log_check( 'health', $source, $n ? 'warning' : 'pass',
     728                $n ? sprintf( /* translators: %d: number of links. */ _n( '%d link on this page goes through several redirects.', '%d links on this page go through several redirects.', $n, 'secherit-site-health-monitor' ), $n ) : __( 'Checked links reach their page without redirect chains.', 'secherit-site-health-monitor' ),
     729                array( 'check' => 'redirect_chain', 'count' => $n, 'examples' => array_slice( $found, 0, 5 ) ), $n );
    651730        }
    652731        $this->health_checks();
    … …  
    665744        return $results;
    666745    }
     746    /** Free checks on a loaded page: hidden from Google, mixed content and missing title or description. */
     747    private function page_quality_checks( $url, $response, DOMDocument $dom ) {
     748        $robots = '';
     749        foreach ( $dom->getElementsByTagName( 'meta' ) as $meta ) {
     750            $name = strtolower( trim( $meta->getAttribute( 'name' ) ) );
     751            if ( in_array( $name, array( 'robots', 'googlebot' ), true ) ) { $robots .= ' ' . strtolower( $meta->getAttribute( 'content' ) ); }
     752        }
     753        $header = wp_remote_retrieve_header( $response, 'x-robots-tag' );
     754        $header = strtolower( is_array( $header ) ? implode( ' ', $header ) : (string) $header );
     755        $noindex = false !== strpos( $robots, 'noindex' ) || preg_match( '/(^|[\s,])none([\s,]|$)/', trim( $robots ) ) || false !== strpos( $header, 'noindex' );
     756        // WooCommerce hides cart, checkout and account pages from Google on purpose.
     757        $private = $this->is_private_shop_page( $url );
     758        $this->log_check( 'health', $url, $noindex ? ( $private ? 'info' : 'fail' ) : 'pass',
     759            $noindex ? ( $private ? __( 'Hidden from Google on purpose. WooCommerce does this for cart, checkout and account pages, and that is normal.', 'secherit-site-health-monitor' ) : __( 'This page tells Google not to show it in search results (noindex).', 'secherit-site-health-monitor' ) ) : __( 'Search engines are allowed to show this page.', 'secherit-site-health-monitor' ),
     760            array( 'check' => 'page_noindex', 'source' => false !== strpos( $header, 'noindex' ) ? 'header' : ( $noindex ? 'meta' : '' ) ) );
     761
     762        if ( 'https' === wp_parse_url( $url, PHP_URL_SCHEME ) ) {
     763            $insecure = array();
     764            $attrs = array( 'img' => array( 'src' ), 'script' => array( 'src' ), 'iframe' => array( 'src' ), 'source' => array( 'src' ), 'video' => array( 'src', 'poster' ), 'audio' => array( 'src' ), 'embed' => array( 'src' ), 'link' => array( 'href' ) );
     765            foreach ( $attrs as $tag => $names ) {
     766                foreach ( $dom->getElementsByTagName( $tag ) as $el ) {
     767                    if ( 'link' === $tag && ! in_array( strtolower( $el->getAttribute( 'rel' ) ), array( 'stylesheet', 'icon', 'preload' ), true ) ) { continue; }
     768                    foreach ( $names as $attr ) {
     769                        $value = trim( $el->getAttribute( $attr ) );
     770                        if ( 0 === stripos( $value, 'http://' ) ) { $insecure[ $value ] = true; }
     771                    }
     772                }
     773            }
     774            $n = count( $insecure );
     775            $this->log_check( 'health', $url, $n ? 'warning' : 'pass',
     776                $n ? sprintf( /* translators: %d: number of files. */ _n( '%d file on this secure page is loaded over insecure http.', '%d files on this secure page are loaded over insecure http.', $n, 'secherit-site-health-monitor' ), $n ) : __( 'All images, scripts and styles load over https.', 'secherit-site-health-monitor' ),
     777                array( 'check' => 'mixed_content', 'count' => $n, 'examples' => array_slice( array_keys( $insecure ), 0, 5 ) ), $n );
     778        }
     779
     780        $titles = $dom->getElementsByTagName( 'title' );
     781        $title = $titles->length ? trim( $titles->item( 0 )->textContent ) : '';
     782        $description = '';
     783        foreach ( $dom->getElementsByTagName( 'meta' ) as $meta ) {
     784            if ( 'description' === strtolower( trim( $meta->getAttribute( 'name' ) ) ) ) { $description = trim( $meta->getAttribute( 'content' ) ); break; }
     785        }
     786        if ( $private ) { // Search results text does not matter for pages Google never shows.
     787            $this->log_check( 'health', $url, 'info', __( 'Not needed: this page is not shown in search results.', 'secherit-site-health-monitor' ), array( 'check' => 'seo_basics', 'missing' => array() ) );
     788            return;
     789        }
     790        $missing = array();
     791        if ( '' === $title ) { $missing[] = __( 'page title', 'secherit-site-health-monitor' ); }
     792        if ( '' === $description ) { $missing[] = __( 'meta description', 'secherit-site-health-monitor' ); }
     793        $this->log_check( 'health', $url, $missing ? 'warning' : 'pass',
     794            /* translators: %s: missing items, such as "meta description". */
     795            $missing ? sprintf( __( 'Missing for search results: %s.', 'secherit-site-health-monitor' ), implode( ', ', $missing ) ) : __( 'Page title and meta description are set.', 'secherit-site-health-monitor' ),
     796            array( 'check' => 'seo_basics', 'title' => mb_substr( $title, 0, 120 ), 'missing' => $missing ) );
     797    }
     798    /** Cart, checkout and account pages are meant to stay out of search results. */
     799    private function is_private_shop_page( $url ) {
     800        if ( ! function_exists( 'wc_get_page_id' ) ) { return false; }
     801        foreach ( array( 'cart', 'checkout', 'myaccount' ) as $key ) {
     802            $id = wc_get_page_id( $key );
     803            if ( $id > 0 && $this->clean_public_url( get_permalink( $id ) ) === $this->clean_public_url( $url ) ) { return true; }
     804        }
     805        return false;
     806    }
    667807    private function record_unverified_elements( $url ) {
    668808        foreach ( array( 'form', 'button' ) as $kind ) {
    … …  
    676816    }
    677817    protected function health_checks() {
     818        $hidden = '0' === (string) get_option( 'blog_public', '1' );
     819        $this->log_check( 'health', home_url(), $hidden ? 'fail' : 'pass', $hidden ? __( 'The whole site asks search engines not to index it (Settings > Reading).', 'secherit-site-health-monitor' ) : __( 'Search engines are allowed to index the site.', 'secherit-site-health-monitor' ), array( 'check' => 'search_visibility' ) );
    678820        $ssl = is_ssl() || 'https' === wp_parse_url( home_url(), PHP_URL_SCHEME );
    679821        $this->log_check( 'health', home_url(), $ssl ? 'pass' : 'fail', $ssl ? 'HTTPS is configured.' : 'HTTPS is not configured.', array( 'check' => 'https' ) );
    … …  
    776918                if ( $observed && ! isset( $referenced[ $row->target ] ) && $complete_since >= $observed ) { return false; }
    777919            }
    778             if ( 'health' === $row->kind && 'php_dom' === ( $details['check'] ?? '' ) && ! in_array( $row->target, $pages, true ) ) { return false; }
     920            if ( 'health' === $row->kind && in_array( $details['check'] ?? '', array( 'php_dom', 'page_noindex', 'mixed_content', 'seo_basics', 'redirect_chain' ), true ) && ! in_array( $row->target, $pages, true ) ) { return false; }
    779921            if ( 'element' === $row->kind && ! isset( $rules[ $details['rule_id'] ?? '' ] ) ) { return false; }
    780922            if ( in_array( $row->kind, array( 'visual', 'performance' ), true ) && ! in_array( $row->target, $visual, true ) ) { return false; }
    … …  
    8601002                $all += $weight;
    8611003                if ( 'page' === $kind ) { $page_down = true; }
     1004                // A site or key page hidden from Google is as serious as a page that is down.
     1005                if ( 'health' === $kind && in_array( (string) ( json_decode( $row->details ?? '', true )['check'] ?? '' ), array( 'search_visibility', 'page_noindex' ), true ) ) { $page_down = true; }
    8621006            } elseif ( 'warning' === $row->status ) { $out['warnings']++; }
    8631007        }
  • secherit-site-health-monitor/trunk/readme.txt

    r3845057 r3846572  
    1 === Secherit Site Health Monitor ===
     1=== Secherit Site Health Monitor – Broken Links, Page & Form Checker ===
    22Contributors: oliversech
    33Tags: broken link checker, broken links, 404, site health, website monitoring
    … …  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.4.3
     7Stable tag: 1.4.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    1919= What the free plugin checks =
    2020
    21 * **Page errors:** HTTP status and response time for up to three important pages, such as your home, contact and checkout pages.
     21* **Page errors:** HTTP status and response time for up to five important pages, such as your home, contact, pricing and checkout pages.
    2222* **Broken internal links:** up to 60 internal links per scan, with the page each broken link was found on and a direct link to edit it.
    2323* **Forms and buttons:** whether forms and buttons are still present in the page HTML, so you notice when a contact form disappears after an update.
     24* **Hidden from Google:** warns when the whole site or an important page tells search engines not to show it (noindex).
     25* **Mixed content, SEO basics and redirects:** finds insecure http files on https pages, missing page titles or meta descriptions, and links that go through several redirects.
    2426* **Basic site health:** HTTPS, public PHP error display, PHP version and pending plugin updates.
    2527* **History and export:** keep a history of every check and export it as CSV.
    … …  
    42442. Search for Secherit Site Health Monitor, install it and activate it.
    43453. Open Site Health Monitor in the admin menu.
    44 4. Choose up to three important pages, for example your home, contact and checkout pages.
     464. Choose up to five important pages, for example your home, contact and checkout pages.
    45475. Select Run checks and review the results.
    4648
    … …  
    5355= Does it slow down my website? =
    5456
    55 No. Checks only run when you start them from the dashboard. Nothing runs for your visitors.
     57No. Checks run once in the background right after you activate the plugin, and after that only when you start them. Nothing runs for your visitors.
    5658
    5759= Does it work with WooCommerce? =
    … …  
    6769No. It detects forms and buttons in the HTML the page returns. It does not submit forms or test that messages are delivered.
    6870
     71= Can it tell if my site is hidden from Google? =
     72
     73Yes. Every check looks for the "Discourage search engines" setting and for noindex instructions on your important pages, and explains how to fix them.
     74
     75= Does it remind me to check after updates? =
     76
     77Yes. After you update plugins, a theme or WordPress, a small notice offers to run checks in one click. You can dismiss it, and it goes away by itself after two days.
     78
    6979= Do I need an account? =
    7080
    … …  
    7383= How many pages can I check? =
    7484
    75 Up to three pages in the free plugin, and up to 20 with Premium.
     85Up to five pages in the free plugin, and up to 20 with Premium.
    7686
    7787= Can I run checks automatically? =
    … …  
    102112
    103113== Changelog ==
     114
     115= 1.4.4 =
     116* New: The first check runs automatically in the background after activation, so your dashboard shows results right away.
     117* New: After you update plugins, a theme or WordPress, a dismissible notice offers to check your site in one click.
     118* Improved: The review request now appears after two successful checks and three days.
     119* Improved: Clearer plugin name in the plugin directory.
     120* New: Warns when your site or an important page is hidden from Google (Discourage search engines or noindex).
     121* New: Finds images, scripts and styles loaded over insecure http on https pages (mixed content).
     122* New: Flags important pages without a page title or meta description.
     123* New: Finds links that go through several redirects.
     124* New: Dashboard widget with your latest result and a Run checks button.
     125* Improved: The free plugin now checks up to five pages (was three).
     126* Improved: WooCommerce cart, checkout and account pages are recognised as hidden from Google on purpose, so they never lower your health score.
     127* Improved: The settings screen explains what is checked on each page and suggests pages from your site that you can add in one click.
    104128
    105129= 1.4.3 =
  • secherit-site-health-monitor/trunk/secherit-site-health-monitor.php

    r3845057 r3846572  
    11<?php
    22/**
    3  * Plugin Name: Secherit Site Health Monitor
     3 * Plugin Name: Secherit Site Health Monitor – Broken Links, Page & Form Checker
    44 * Description: Intelligent WordPress website health, link, form and experience monitoring with manual checks and local monitoring history.
    5  * Version: 1.4.3
     5 * Version: 1.4.4
    66 * Requires at least: 6.2
    77 * Requires PHP: 7.4
    … …  
    1313if ( ! defined( 'ABSPATH' ) ) { exit; }
    1414if ( class_exists( 'Secherit_SitePilot', false ) ) { return; }
    15 define( 'SITEPILOT_VERSION', '1.4.3' );
     15define( 'SITEPILOT_VERSION', '1.4.4' );
    1616define( 'SITEPILOT_FILE', __FILE__ );
    1717define( 'SITEPILOT_DIR', plugin_dir_path( __FILE__ ) );
    … …  
    1919require_once SITEPILOT_DIR . 'includes/class-sitepilot.php';
    2020require_once SITEPILOT_DIR . 'includes/class-sitepilot-optimizer.php';
     21require_once SITEPILOT_DIR . 'includes/class-sitepilot-onboarding.php';
     22// Loaded everywhere so background scans (cron) are counted too; hooks are only added in admin.
     23require_once SITEPILOT_DIR . 'includes/class-sitepilot-growth.php';
     24Secherit_SitePilot_Onboarding::init();
    2125if ( is_admin() ) {
    2226    require_once SITEPILOT_DIR . 'includes/class-sitepilot-feedback.php';
    2327    Secherit_SitePilot_Feedback::init();
    24     require_once SITEPILOT_DIR . 'includes/class-sitepilot-growth.php';
    2528    Secherit_SitePilot_Growth::init();
    2629    require_once SITEPILOT_DIR . 'includes/class-sitepilot-site-health.php';
    2730    Secherit_SitePilot_Site_Health::init();
    2831}
    29 register_activation_hook( __FILE__, array( 'Secherit_SitePilot', 'activate' ) );
    30 register_deactivation_hook( __FILE__, array( 'Secherit_SitePilot', 'deactivate' ) );
     32register_activation_hook( __FILE__, array( 'Secherit_SitePilot_Onboarding', 'activate' ) );
     33register_deactivation_hook( __FILE__, array( 'Secherit_SitePilot_Onboarding', 'deactivate' ) );
    3134add_action( 'plugins_loaded', array( 'Secherit_SitePilot', 'schedule_events' ), 20 );
  • secherit-site-health-monitor/trunk/uninstall.php

    r3843620 r3846572  
    1515// phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Remove only this plugin's options.
    1616$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like( 'sitepilot_' ) . '%' ) );
    17 foreach ( array( 'sitepilot_review_state', 'sitepilot_upsell_dismissed' ) as $sitepilot_meta ) {
     17foreach ( array( 'sitepilot_review_state', 'sitepilot_upsell_dismissed', 'sitepilot_trial_bar_until', 'sitepilot_trial_notice_done' ) as $sitepilot_meta ) {
    1818    delete_metadata( 'user', 0, $sitepilot_meta, '', true );
    1919}
    20 foreach ( array( 'sitepilot_scan_event', 'sitepilot_weekly_event', 'sitepilot_license_event', 'sitepilot_visual_event', 'sitepilot_advanced_event', 'sitepilot_after_update_event', 'sitepilot_backup_verify' ) as $sitepilot_hook ) {
     20foreach ( array( 'sitepilot_scan_event', 'sitepilot_weekly_event', 'sitepilot_license_event', 'sitepilot_visual_event', 'sitepilot_advanced_event', 'sitepilot_after_update_event', 'sitepilot_backup_verify', 'sitepilot_first_scan_event' ) as $sitepilot_hook ) {
    2121    wp_unschedule_hook( $sitepilot_hook );
    2222}
Note: See TracChangeset for help on using the changeset viewer.