Plugin Directory

Changeset 3799460


Ignore:
Timestamp:
11/13/2026 12:08:44 AM (5 days ago)
Author:
rankanysite
Message:

2.13.0: scans run in short steps with a live progress card instead of a spinner; slow pages get 15s; buttons show Working

Location:
clickflame-rank-any-site
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • clickflame-rank-any-site/tags/2.13.0/assets/admin.css

    r3794812 r3799460  
    234234.ras-blaze-form textarea { flex: 1 1 320px; min-height: 44px; font-size: 14px; }
    235235.ras-blaze-about { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--ras-mute); }
     236
     237/* Scan progress */
     238.ras-scan { margin: 0 0 16px; }
     239.ras-scan h2 { margin: 0 0 10px; }
     240.ras-scan-bar { height: 10px; border-radius: 99px; background: var(--ras-line); overflow: hidden; }
     241.ras-scan-bar span { display: block; height: 100%; width: 5%; border-radius: 99px; background: linear-gradient(90deg, var(--ras-brand), var(--ras-brand2)); transition: width .6s ease; }
     242.ras-scan p { margin: 10px 0 0; font-size: 14px; }
     243.ras-scan.is-bad .ras-scan-bar span { background: var(--ras-red); }
     244@media (prefers-reduced-motion: reduce) { .ras-scan-bar span { transition: none; } }
  • clickflame-rank-any-site/tags/2.13.0/assets/admin.js

    r3790523 r3799460  
    140140        }
    141141}());
     142
     143/* Licensed scan progress: drives the scan one step at a time and shows what it is doing. */
     144(function () {
     145        'use strict';
     146        var cfg = window.rankanysiteScan || null;
     147        var box = document.getElementById('ras-scan');
     148
     149        // Any Rank Any Site action button: show it is working instead of a silent page load.
     150        document.querySelectorAll('.ras-wrap form').forEach(function (f) {
     151                f.addEventListener('submit', function () {
     152                        var b = f.querySelector('button[type="submit"]');
     153                        if (b && cfg) {
     154                                b.disabled = true;
     155                                b.setAttribute('aria-busy', 'true');
     156                                b.textContent = cfg.working;
     157                        }
     158                });
     159        });
     160
     161        if (!box || !cfg) {
     162                return;
     163        }
     164        var text = document.getElementById('ras-scan-text');
     165        var fill = document.getElementById('ras-scan-fill');
     166        var fails = 0;
     167
     168        function fmt(s, a, b) {
     169                return s.replace('%1$d', a).replace('%2$d', b);
     170        }
     171
     172        function show(d) {
     173                var pct = 5, msg = cfg.start;
     174                if (d.phase === 'crawl') {
     175                        msg = fmt(cfg.crawl, d.read || 0, d.max || 0);
     176                        pct = 5 + 65 * Math.min(1, (d.read || 0) / Math.max(1, d.max || 1));
     177                } else if (d.phase === 'audit') {
     178                        msg = d.toCheck ? fmt(cfg.audit, d.checked || 0, d.toCheck) : cfg.build;
     179                        pct = 70 + 25 * (d.toCheck ? (d.checked || 0) / d.toCheck : 1);
     180                } else if (d.phase === 'build') {
     181                        msg = cfg.build;
     182                        pct = 96;
     183                } else if (d.phase === 'wait') {
     184                        msg = cfg.wait;
     185                }
     186                text.textContent = msg;
     187                if (d.phase !== 'wait') {
     188                        fill.style.width = Math.round(pct) + '%';
     189                }
     190        }
     191
     192        function step() {
     193                var fd = new FormData();
     194                fd.append('action', 'rankanysite_scan_step');
     195                fd.append('_ajax_nonce', cfg.nonce);
     196                fetch(cfg.ajax, { method: 'POST', body: fd, credentials: 'same-origin' })
     197                        .then(function (r) { return r.json(); })
     198                        .then(function (j) {
     199                                if (!j || !j.success) {
     200                                        text.textContent = (j && j.data && j.data.reason) || cfg.wait;
     201                                        box.classList.add('is-bad');
     202                                        return;
     203                                }
     204                                fails = 0;
     205                                if (j.data.done) {
     206                                        fill.style.width = '100%';
     207                                        text.textContent = cfg.done;
     208                                        window.location.reload();
     209                                        return;
     210                                }
     211                                show(j.data);
     212                                setTimeout(step, 1500);
     213                        })
     214                        .catch(function () {
     215                                fails += 1;
     216                                text.textContent = cfg.wait;
     217                                setTimeout(step, Math.min(30000, 3000 * fails));
     218                        });
     219        }
     220        step();
     221})();
     222
  • clickflame-rank-any-site/tags/2.13.0/clickflame-rank-any-site.php

    r3794812 r3799460  
    44 * Plugin URI:        https://rankanysite.com/how-it-works
    55 * Description:       Find and track your business listings across directories and check that each shows your right name, phone and place. Also checks what your live pages serve to Google and AI tools, and fixes it in one click.
    6  * Version:           2.12.0
     6 * Version:           2.13.0
    77 * Requires at least: 6.9
    88 * Requires PHP:      7.4
    … …  
    3636}
    3737
    38 define( 'RANKANYSITE_VERSION', '2.12.0' );
     38define( 'RANKANYSITE_VERSION', '2.13.0' );
    3939define( 'RANKANYSITE_FILE', __FILE__ );
    4040define( 'RANKANYSITE_API', 'https://rankanysite.com' );
  • clickflame-rank-any-site/tags/2.13.0/includes/admin.php

    r3794812 r3799460  
    3333                        wp_enqueue_style( 'rankanysite-admin', plugins_url( 'assets/admin.css', RANKANYSITE_FILE ), array(), RANKANYSITE_VERSION );
    3434                        wp_enqueue_script( 'rankanysite-admin', plugins_url( 'assets/admin.js', RANKANYSITE_FILE ), array(), RANKANYSITE_VERSION, true );
    35                 }
     35                        wp_localize_script(
     36                                'rankanysite-admin',
     37                                'rankanysiteScan',
     38                                array(
     39                                        'ajax'    => admin_url( 'admin-ajax.php' ),
     40                                        'nonce'   => wp_create_nonce( 'rankanysite_scan' ),
     41                                        'start'   => __( 'Starting the scan...', 'clickflame-rank-any-site' ),
     42                                        /* translators: 1: pages read so far, 2: most pages the plan reads. */
     43                                        'crawl'   => __( 'Reading your pages: %1$d of up to %2$d', 'clickflame-rank-any-site' ),
     44                                        /* translators: 1: sitemap addresses checked so far, 2: addresses to check. */
     45                                        'audit'   => __( 'Checking your sitemap: %1$d of %2$d addresses', 'clickflame-rank-any-site' ),
     46                                        'build'   => __( 'Building your fixes...', 'clickflame-rank-any-site' ),
     47                                        'wait'    => __( 'Still working, your site is a little slow to answer...', 'clickflame-rank-any-site' ),
     48                                        'done'    => __( 'Done. Loading your results...', 'clickflame-rank-any-site' ),
     49                                        'working' => __( 'Working...', 'clickflame-rank-any-site' ),
     50                                )
     51                        );
     52                }
     53        }
     54);
     55
     56// One step of a licensed scan, called every few seconds by the progress card (assets/admin.js).
     57add_action(
     58        'wp_ajax_rankanysite_scan_step',
     59        function () {
     60                if ( ! current_user_can( 'manage_options' ) ) {
     61                        wp_send_json_error( array( 'reason' => __( 'You are not allowed to do that.', 'clickflame-rank-any-site' ) ), 403 );
     62                }
     63                check_ajax_referer( 'rankanysite_scan' );
     64                // A step answers within about 20 seconds (STEP_MS on the service), under the usual 30 second PHP limit.
     65                $j = rankanysite_scan_step();
     66                if ( empty( $j['ok'] ) ) {
     67                        wp_send_json_error( $j );
     68                }
     69                wp_send_json_success( $j );
    3670        }
    3771);
    … …  
    215249        echo '</div></div></div>';
    216250
    217         if ( is_array( $s ) && empty( $s['ok'] ) ) {
     251        $scanning = $licensed && get_option( 'rankanysite_scanning' );
     252        if ( $scanning ) {
     253                echo '<div class="ras-card ras-scan" id="ras-scan" aria-live="polite"><h2>' . esc_html( $ok ? __( 'Rescanning your site', 'clickflame-rank-any-site' ) : __( 'Scanning your site', 'clickflame-rank-any-site' ) ) . '</h2>';
     254                echo '<div class="ras-scan-bar"><span id="ras-scan-fill"></span></div><p id="ras-scan-text">' . esc_html__( 'Starting the scan...', 'clickflame-rank-any-site' ) . '</p>';
     255                echo '<p class="ras-muted">' . esc_html__( 'This takes one to five minutes depending on how fast your site answers. You can leave this page; the scan keeps going and your results will be here when you come back.', 'clickflame-rank-any-site' ) . '</p></div>';
     256        }
     257
     258        if ( is_array( $s ) && empty( $s['ok'] ) && ! empty( $s['reason'] ) ) {
    218259                echo '<div class="ras-alert">' . esc_html( $s['reason'] ) . '</div>';
    219260        }
    … …  
    287328                }
    288329                echo '</section></div>';
    289         } elseif ( ! is_array( $s ) ) {
     330        } elseif ( ! is_array( $s ) && ! $scanning ) {
    290331                echo '<div class="ras-card ras-empty"><h2>' . esc_html__( 'How does this site score?', 'clickflame-rank-any-site' ) . '</h2><p>' . esc_html__( 'Rank Any Site reads your public pages the way search engines and AI tools do and lists what to fix: titles, descriptions, schema, llms.txt, alt text, sitemaps and more. Checking sends this site\'s address to rankanysite.com and takes up to a minute.', 'clickflame-rank-any-site' ) . '</p>';
    291332                rankanysite_button( 'free', __( 'Check My Site Free', 'clickflame-rank-any-site' ) );
  • clickflame-rank-any-site/tags/2.13.0/includes/service.php

    r3790523 r3799460  
    7272                        'rescan' => $rescan ? '1' : '0',
    7373                        'res'    => '1',
     74                        'bg'     => '1',
    7475                ),
    7576                RANKANYSITE_API . '/api/lic/sync'
    7677        );
    77         $r   = wp_remote_get( $url, array( 'timeout' => 120 ) );
     78        // bg=1: the service answers at once and scans in steps (rankanysite_scan_step), so this never waits on a crawl.
     79        $r   = wp_remote_get( $url, array( 'timeout' => 45 ) );
    7880        if ( is_wp_error( $r ) ) {
    7981                update_option( 'rankanysite_status', array( 'ok' => false, 'reason' => $r->get_error_message(), 'at' => time() ), false );
    … …  
    9395                }
    9496                return false;
     97        }
     98        if ( ! empty( $j['scanning'] ) ) {
     99                update_option( 'rankanysite_scanning', time(), false );
     100        } else {
     101                delete_option( 'rankanysite_scanning' );
     102        }
     103        // First scan still running: nothing to apply yet, keep whatever was there, and drop an old error so it does not show.
     104        if ( ! isset( $j['score'] ) ) {
     105                $old = get_option( 'rankanysite_status' );
     106                if ( is_array( $old ) && empty( $old['ok'] ) ) {
     107                        delete_option( 'rankanysite_status' );
     108                }
     109                return true;
    95110        }
    96111        $new_data = isset( $j['data'] ) && is_array( $j['data'] ) ? $j['data'] : array();
    … …  
    108123        update_option( 'rankanysite_last_ok', time(), false );
    109124        return true;
     125}
     126
     127/**
     128 * Run one step of this site's scan on rankanysite.com (about 20 seconds of work) and return the progress.
     129 * When the scan is done, pull the new results.
     130 *
     131 * @return array{ok:bool,done?:bool,phase?:string,read?:int,max?:int,checked?:int,toCheck?:int,reason?:string}
     132 */
     133function rankanysite_scan_step() {
     134        $key = rankanysite_key();
     135        if ( '' === $key ) {
     136                return array( 'ok' => false, 'reason' => __( 'No license key saved.', 'clickflame-rank-any-site' ) );
     137        }
     138        $r = wp_remote_post(
     139                RANKANYSITE_API . '/api/lic/scan',
     140                array(
     141                        'timeout' => 60,
     142                        'headers' => array( 'Content-Type' => 'application/json' ),
     143                        'body'    => wp_json_encode(
     144                                array(
     145                                        'key'  => $key,
     146                                        'site' => home_url( '/' ),
     147                                )
     148                        ),
     149                )
     150        );
     151        if ( is_wp_error( $r ) ) {
     152                // A slow answer is not a failure: the scan keeps its place, the next step carries on.
     153                return array( 'ok' => true, 'done' => false, 'phase' => 'wait' );
     154        }
     155        $j = json_decode( wp_remote_retrieve_body( $r ), true );
     156        if ( ! is_array( $j ) ) {
     157                return array( 'ok' => true, 'done' => false, 'phase' => 'wait' );
     158        }
     159        if ( empty( $j['ok'] ) ) {
     160                delete_option( 'rankanysite_scanning' );
     161                return array( 'ok' => false, 'reason' => ! empty( $j['error'] ) ? (string) $j['error'] : __( 'The scan stopped.', 'clickflame-rank-any-site' ) );
     162        }
     163        if ( ! empty( $j['done'] ) ) {
     164                delete_option( 'rankanysite_scanning' );
     165                rankanysite_sync( false );
     166        }
     167        return $j;
    110168}
    111169
  • clickflame-rank-any-site/tags/2.13.0/readme.txt

    r3794812 r3799460  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 2.12.0
     7Stable tag: 2.13.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    155155== Changelog ==
    156156
     157= 2.13.0 =
     158* Fixed: saving a license key or pressing Rescan Now no longer leaves the page loading for minutes on a slow site. The scan now runs in the background and the dashboard shows what it is doing, page by page, until your results are in.
     159* New: buttons show Working while they run.
     160
    157161= 2.12.0 =
    158162* New: Page Issues screen. Every page with its issues, broken links, View and Edit links, and a recommended SEO title, description, H1 and schema to use or copy.
  • clickflame-rank-any-site/trunk/assets/admin.css

    r3794812 r3799460  
    234234.ras-blaze-form textarea { flex: 1 1 320px; min-height: 44px; font-size: 14px; }
    235235.ras-blaze-about { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--ras-mute); }
     236
     237/* Scan progress */
     238.ras-scan { margin: 0 0 16px; }
     239.ras-scan h2 { margin: 0 0 10px; }
     240.ras-scan-bar { height: 10px; border-radius: 99px; background: var(--ras-line); overflow: hidden; }
     241.ras-scan-bar span { display: block; height: 100%; width: 5%; border-radius: 99px; background: linear-gradient(90deg, var(--ras-brand), var(--ras-brand2)); transition: width .6s ease; }
     242.ras-scan p { margin: 10px 0 0; font-size: 14px; }
     243.ras-scan.is-bad .ras-scan-bar span { background: var(--ras-red); }
     244@media (prefers-reduced-motion: reduce) { .ras-scan-bar span { transition: none; } }
  • clickflame-rank-any-site/trunk/assets/admin.js

    r3790523 r3799460  
    140140        }
    141141}());
     142
     143/* Licensed scan progress: drives the scan one step at a time and shows what it is doing. */
     144(function () {
     145        'use strict';
     146        var cfg = window.rankanysiteScan || null;
     147        var box = document.getElementById('ras-scan');
     148
     149        // Any Rank Any Site action button: show it is working instead of a silent page load.
     150        document.querySelectorAll('.ras-wrap form').forEach(function (f) {
     151                f.addEventListener('submit', function () {
     152                        var b = f.querySelector('button[type="submit"]');
     153                        if (b && cfg) {
     154                                b.disabled = true;
     155                                b.setAttribute('aria-busy', 'true');
     156                                b.textContent = cfg.working;
     157                        }
     158                });
     159        });
     160
     161        if (!box || !cfg) {
     162                return;
     163        }
     164        var text = document.getElementById('ras-scan-text');
     165        var fill = document.getElementById('ras-scan-fill');
     166        var fails = 0;
     167
     168        function fmt(s, a, b) {
     169                return s.replace('%1$d', a).replace('%2$d', b);
     170        }
     171
     172        function show(d) {
     173                var pct = 5, msg = cfg.start;
     174                if (d.phase === 'crawl') {
     175                        msg = fmt(cfg.crawl, d.read || 0, d.max || 0);
     176                        pct = 5 + 65 * Math.min(1, (d.read || 0) / Math.max(1, d.max || 1));
     177                } else if (d.phase === 'audit') {
     178                        msg = d.toCheck ? fmt(cfg.audit, d.checked || 0, d.toCheck) : cfg.build;
     179                        pct = 70 + 25 * (d.toCheck ? (d.checked || 0) / d.toCheck : 1);
     180                } else if (d.phase === 'build') {
     181                        msg = cfg.build;
     182                        pct = 96;
     183                } else if (d.phase === 'wait') {
     184                        msg = cfg.wait;
     185                }
     186                text.textContent = msg;
     187                if (d.phase !== 'wait') {
     188                        fill.style.width = Math.round(pct) + '%';
     189                }
     190        }
     191
     192        function step() {
     193                var fd = new FormData();
     194                fd.append('action', 'rankanysite_scan_step');
     195                fd.append('_ajax_nonce', cfg.nonce);
     196                fetch(cfg.ajax, { method: 'POST', body: fd, credentials: 'same-origin' })
     197                        .then(function (r) { return r.json(); })
     198                        .then(function (j) {
     199                                if (!j || !j.success) {
     200                                        text.textContent = (j && j.data && j.data.reason) || cfg.wait;
     201                                        box.classList.add('is-bad');
     202                                        return;
     203                                }
     204                                fails = 0;
     205                                if (j.data.done) {
     206                                        fill.style.width = '100%';
     207                                        text.textContent = cfg.done;
     208                                        window.location.reload();
     209                                        return;
     210                                }
     211                                show(j.data);
     212                                setTimeout(step, 1500);
     213                        })
     214                        .catch(function () {
     215                                fails += 1;
     216                                text.textContent = cfg.wait;
     217                                setTimeout(step, Math.min(30000, 3000 * fails));
     218                        });
     219        }
     220        step();
     221})();
     222
  • clickflame-rank-any-site/trunk/clickflame-rank-any-site.php

    r3794812 r3799460  
    44 * Plugin URI:        https://rankanysite.com/how-it-works
    55 * Description:       Find and track your business listings across directories and check that each shows your right name, phone and place. Also checks what your live pages serve to Google and AI tools, and fixes it in one click.
    6  * Version:           2.12.0
     6 * Version:           2.13.0
    77 * Requires at least: 6.9
    88 * Requires PHP:      7.4
    … …  
    3636}
    3737
    38 define( 'RANKANYSITE_VERSION', '2.12.0' );
     38define( 'RANKANYSITE_VERSION', '2.13.0' );
    3939define( 'RANKANYSITE_FILE', __FILE__ );
    4040define( 'RANKANYSITE_API', 'https://rankanysite.com' );
  • clickflame-rank-any-site/trunk/includes/admin.php

    r3794812 r3799460  
    3333                        wp_enqueue_style( 'rankanysite-admin', plugins_url( 'assets/admin.css', RANKANYSITE_FILE ), array(), RANKANYSITE_VERSION );
    3434                        wp_enqueue_script( 'rankanysite-admin', plugins_url( 'assets/admin.js', RANKANYSITE_FILE ), array(), RANKANYSITE_VERSION, true );
    35                 }
     35                        wp_localize_script(
     36                                'rankanysite-admin',
     37                                'rankanysiteScan',
     38                                array(
     39                                        'ajax'    => admin_url( 'admin-ajax.php' ),
     40                                        'nonce'   => wp_create_nonce( 'rankanysite_scan' ),
     41                                        'start'   => __( 'Starting the scan...', 'clickflame-rank-any-site' ),
     42                                        /* translators: 1: pages read so far, 2: most pages the plan reads. */
     43                                        'crawl'   => __( 'Reading your pages: %1$d of up to %2$d', 'clickflame-rank-any-site' ),
     44                                        /* translators: 1: sitemap addresses checked so far, 2: addresses to check. */
     45                                        'audit'   => __( 'Checking your sitemap: %1$d of %2$d addresses', 'clickflame-rank-any-site' ),
     46                                        'build'   => __( 'Building your fixes...', 'clickflame-rank-any-site' ),
     47                                        'wait'    => __( 'Still working, your site is a little slow to answer...', 'clickflame-rank-any-site' ),
     48                                        'done'    => __( 'Done. Loading your results...', 'clickflame-rank-any-site' ),
     49                                        'working' => __( 'Working...', 'clickflame-rank-any-site' ),
     50                                )
     51                        );
     52                }
     53        }
     54);
     55
     56// One step of a licensed scan, called every few seconds by the progress card (assets/admin.js).
     57add_action(
     58        'wp_ajax_rankanysite_scan_step',
     59        function () {
     60                if ( ! current_user_can( 'manage_options' ) ) {
     61                        wp_send_json_error( array( 'reason' => __( 'You are not allowed to do that.', 'clickflame-rank-any-site' ) ), 403 );
     62                }
     63                check_ajax_referer( 'rankanysite_scan' );
     64                // A step answers within about 20 seconds (STEP_MS on the service), under the usual 30 second PHP limit.
     65                $j = rankanysite_scan_step();
     66                if ( empty( $j['ok'] ) ) {
     67                        wp_send_json_error( $j );
     68                }
     69                wp_send_json_success( $j );
    3670        }
    3771);
    … …  
    215249        echo '</div></div></div>';
    216250
    217         if ( is_array( $s ) && empty( $s['ok'] ) ) {
     251        $scanning = $licensed && get_option( 'rankanysite_scanning' );
     252        if ( $scanning ) {
     253                echo '<div class="ras-card ras-scan" id="ras-scan" aria-live="polite"><h2>' . esc_html( $ok ? __( 'Rescanning your site', 'clickflame-rank-any-site' ) : __( 'Scanning your site', 'clickflame-rank-any-site' ) ) . '</h2>';
     254                echo '<div class="ras-scan-bar"><span id="ras-scan-fill"></span></div><p id="ras-scan-text">' . esc_html__( 'Starting the scan...', 'clickflame-rank-any-site' ) . '</p>';
     255                echo '<p class="ras-muted">' . esc_html__( 'This takes one to five minutes depending on how fast your site answers. You can leave this page; the scan keeps going and your results will be here when you come back.', 'clickflame-rank-any-site' ) . '</p></div>';
     256        }
     257
     258        if ( is_array( $s ) && empty( $s['ok'] ) && ! empty( $s['reason'] ) ) {
    218259                echo '<div class="ras-alert">' . esc_html( $s['reason'] ) . '</div>';
    219260        }
    … …  
    287328                }
    288329                echo '</section></div>';
    289         } elseif ( ! is_array( $s ) ) {
     330        } elseif ( ! is_array( $s ) && ! $scanning ) {
    290331                echo '<div class="ras-card ras-empty"><h2>' . esc_html__( 'How does this site score?', 'clickflame-rank-any-site' ) . '</h2><p>' . esc_html__( 'Rank Any Site reads your public pages the way search engines and AI tools do and lists what to fix: titles, descriptions, schema, llms.txt, alt text, sitemaps and more. Checking sends this site\'s address to rankanysite.com and takes up to a minute.', 'clickflame-rank-any-site' ) . '</p>';
    291332                rankanysite_button( 'free', __( 'Check My Site Free', 'clickflame-rank-any-site' ) );
  • clickflame-rank-any-site/trunk/includes/service.php

    r3790523 r3799460  
    7272                        'rescan' => $rescan ? '1' : '0',
    7373                        'res'    => '1',
     74                        'bg'     => '1',
    7475                ),
    7576                RANKANYSITE_API . '/api/lic/sync'
    7677        );
    77         $r   = wp_remote_get( $url, array( 'timeout' => 120 ) );
     78        // bg=1: the service answers at once and scans in steps (rankanysite_scan_step), so this never waits on a crawl.
     79        $r   = wp_remote_get( $url, array( 'timeout' => 45 ) );
    7880        if ( is_wp_error( $r ) ) {
    7981                update_option( 'rankanysite_status', array( 'ok' => false, 'reason' => $r->get_error_message(), 'at' => time() ), false );
    … …  
    9395                }
    9496                return false;
     97        }
     98        if ( ! empty( $j['scanning'] ) ) {
     99                update_option( 'rankanysite_scanning', time(), false );
     100        } else {
     101                delete_option( 'rankanysite_scanning' );
     102        }
     103        // First scan still running: nothing to apply yet, keep whatever was there, and drop an old error so it does not show.
     104        if ( ! isset( $j['score'] ) ) {
     105                $old = get_option( 'rankanysite_status' );
     106                if ( is_array( $old ) && empty( $old['ok'] ) ) {
     107                        delete_option( 'rankanysite_status' );
     108                }
     109                return true;
    95110        }
    96111        $new_data = isset( $j['data'] ) && is_array( $j['data'] ) ? $j['data'] : array();
    … …  
    108123        update_option( 'rankanysite_last_ok', time(), false );
    109124        return true;
     125}
     126
     127/**
     128 * Run one step of this site's scan on rankanysite.com (about 20 seconds of work) and return the progress.
     129 * When the scan is done, pull the new results.
     130 *
     131 * @return array{ok:bool,done?:bool,phase?:string,read?:int,max?:int,checked?:int,toCheck?:int,reason?:string}
     132 */
     133function rankanysite_scan_step() {
     134        $key = rankanysite_key();
     135        if ( '' === $key ) {
     136                return array( 'ok' => false, 'reason' => __( 'No license key saved.', 'clickflame-rank-any-site' ) );
     137        }
     138        $r = wp_remote_post(
     139                RANKANYSITE_API . '/api/lic/scan',
     140                array(
     141                        'timeout' => 60,
     142                        'headers' => array( 'Content-Type' => 'application/json' ),
     143                        'body'    => wp_json_encode(
     144                                array(
     145                                        'key'  => $key,
     146                                        'site' => home_url( '/' ),
     147                                )
     148                        ),
     149                )
     150        );
     151        if ( is_wp_error( $r ) ) {
     152                // A slow answer is not a failure: the scan keeps its place, the next step carries on.
     153                return array( 'ok' => true, 'done' => false, 'phase' => 'wait' );
     154        }
     155        $j = json_decode( wp_remote_retrieve_body( $r ), true );
     156        if ( ! is_array( $j ) ) {
     157                return array( 'ok' => true, 'done' => false, 'phase' => 'wait' );
     158        }
     159        if ( empty( $j['ok'] ) ) {
     160                delete_option( 'rankanysite_scanning' );
     161                return array( 'ok' => false, 'reason' => ! empty( $j['error'] ) ? (string) $j['error'] : __( 'The scan stopped.', 'clickflame-rank-any-site' ) );
     162        }
     163        if ( ! empty( $j['done'] ) ) {
     164                delete_option( 'rankanysite_scanning' );
     165                rankanysite_sync( false );
     166        }
     167        return $j;
    110168}
    111169
  • clickflame-rank-any-site/trunk/readme.txt

    r3794812 r3799460  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 2.12.0
     7Stable tag: 2.13.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    155155== Changelog ==
    156156
     157= 2.13.0 =
     158* Fixed: saving a license key or pressing Rescan Now no longer leaves the page loading for minutes on a slow site. The scan now runs in the background and the dashboard shows what it is doing, page by page, until your results are in.
     159* New: buttons show Working while they run.
     160
    157161= 2.12.0 =
    158162* New: Page Issues screen. Every page with its issues, broken links, View and Edit links, and a recommended SEO title, description, H1 and schema to use or copy.
Note: See TracChangeset for help on using the changeset viewer.