PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.2.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.2.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / includes / abilities / analysis / class-get-seo-analyzer.php

class-get-seo-analyzer.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.2.0, at includes/abilities/analysis/class-get-seo-analyzer.php

122 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get 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\Abilities\Ability_Base;
13 use ThinkRank\SEO\SEO_Analyzer;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Returns the latest cached whole-site SEO audit (Site SEO Analyzer).
21 *
22 * Mirrors `GET /thinkrank/v1/seo-analyzer`: a crawl-free 0-100 audit with an
23 * overall score, letter grade, and per-check results across the Basic,
24 * Advanced, Content, Performance, and Security categories. Distinct from the
25 * per-post `get-seo-score` ability. Returns the cached result when available
26 * (refreshed hourly); use `run-seo-analyzer` to force a fresh audit.
27 */
28 class Get_Seo_Analyzer extends Ability_Base {
29 /**
30 * Constructor.
31 */
32 public function __construct() {
33 $this->id = 'thinkrank/get-seo-analyzer';
34 $this->label = __( 'Get Site SEO Analyzer Audit', 'thinkrank' );
35 $this->description = __( 'Retrieve the latest whole-site SEO audit (Site SEO Analyzer): overall 0-100 score, letter grade, summary counts, and per-check results across Basic, Advanced, Content, Performance, and Security. Returns the cached audit (refreshed hourly); use run-seo-analyzer for a fresh run.', 'thinkrank' );
36 }
37
38 /**
39 * {@inheritDoc}
40 *
41 * @return array<string, bool|float|string>
42 */
43 public function get_annotations() {
44 return [
45 'readonly' => true,
46 'destructive' => false,
47 'idempotent' => true,
48 'priority' => 1.0,
49 'openWorldHint' => false,
50 ];
51 }
52
53 /**
54 * {@inheritDoc}
55 *
56 * @return array<string, mixed>
57 */
58 public function get_input_schema() {
59 return [
60 'type' => 'object',
61 'additionalProperties' => false,
62 'properties' => self::empty_properties(),
63 ];
64 }
65
66 /**
67 * {@inheritDoc}
68 *
69 * @return array<string, mixed>
70 */
71 public function get_output_schema() {
72 return $this->audit_output_schema();
73 }
74
75 /**
76 * Execute ability.
77 *
78 * @param array<string, mixed> $input Ability input payload.
79 * @return array<string, mixed>
80 */
81 public function execute( $input ) {
82 $analyzer = new SEO_Analyzer();
83
84 return $analyzer->run( false );
85 }
86
87 /**
88 * Shared output schema for the audit payload.
89 *
90 * @return array<string, mixed>
91 */
92 protected function audit_output_schema() {
93 return [
94 'type' => 'object',
95 'additionalProperties' => true,
96 'properties' => [
97 'overall_score' => [ 'type' => 'integer' ],
98 'grade' => [ 'type' => 'string' ],
99 'summary' => [
100 'type' => 'object',
101 'additionalProperties' => true,
102 ],
103 'categories' => [
104 'type' => 'array',
105 'items' => [
106 'type' => 'object',
107 'additionalProperties' => true,
108 ],
109 ],
110 'checks' => [
111 'type' => 'array',
112 'items' => [
113 'type' => 'object',
114 'additionalProperties' => true,
115 ],
116 ],
117 'generated_at' => [ 'type' => 'string' ],
118 ],
119 ];
120 }
121 }
122