| 1 |
<?php |
| 2 |
/** |
| 3 |
* Run Site SEO Analyzer audit ability. |
| 4 |
* |
| 5 |
* @package ThinkRank\Abilities\Analysis |
| 6 |
*/ |
| 7 |
|
| 8 |
declare(strict_types=1); |
| 9 |
|
| 10 |
namespace ThinkRank\Abilities\Analysis; |
| 11 |
|
| 12 |
use ThinkRank\SEO\SEO_Analyzer; |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; // Exit if accessed directly. |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Runs a fresh whole-site SEO audit (Site SEO Analyzer). |
| 20 |
* |
| 21 |
* Mirrors `POST /thinkrank/v1/seo-analyzer/run`: forces a fresh crawl-free |
| 22 |
* audit (bypassing and refreshing the hourly cache) and returns the same |
| 23 |
* payload shape as `get-seo-analyzer`. Idempotent — running it repeatedly |
| 24 |
* re-computes the current site state without side effects on content. |
| 25 |
*/ |
| 26 |
class Run_Seo_Analyzer extends Get_Seo_Analyzer { |
| 27 |
/** |
| 28 |
* Constructor. |
| 29 |
*/ |
| 30 |
public function __construct() { |
| 31 |
$this->id = 'thinkrank/run-seo-analyzer'; |
| 32 |
$this->label = __( 'Run Site SEO Analyzer Audit', 'thinkrank' ); |
| 33 |
$this->description = __( 'Run a fresh whole-site SEO audit (Site SEO Analyzer), bypassing and refreshing the hourly cache. Returns the same payload as get-seo-analyzer: overall 0-100 score, grade, summary counts, and per-check results across Basic, Advanced, Content, Performance, Security and GEO/AEO. A failing per-item check (meta descriptions, image alt text, and the content-sampled GEO checks) lists what fails it in affected_posts (id, title, type, edit_url, url), with affected_total counting every failing item when the list is capped.', 'thinkrank' ); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* {@inheritDoc} |
| 38 |
* |
| 39 |
* @return array<string, bool|float|string> |
| 40 |
*/ |
| 41 |
public function get_annotations() { |
| 42 |
return [ |
| 43 |
'readonly' => false, |
| 44 |
'destructive' => false, |
| 45 |
'idempotent' => true, |
| 46 |
'priority' => 2.0, |
| 47 |
'openWorldHint' => false, |
| 48 |
]; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Execute ability. |
| 53 |
* |
| 54 |
* @param array<string, mixed> $input Ability input payload. |
| 55 |
* @return array<string, mixed> |
| 56 |
*/ |
| 57 |
public function execute( $input ) { |
| 58 |
$analyzer = new SEO_Analyzer(); |
| 59 |
|
| 60 |
return $analyzer->run( true ); |
| 61 |
} |
| 62 |
} |
| 63 |
|