PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 1.26.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v1.26.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-opportunities.php

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

101 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get SEO opportunities 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\Analytics_Manager;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Retrieves ThinkRank SEO opportunities.
21 *
22 * Requires Google Search Console to be connected. When no Google connection is
23 * present, empty data is returned (this is expected and is not an error).
24 */
25 class Get_Seo_Opportunities extends Ability_Base {
26 /**
27 * Constructor.
28 */
29 public function __construct() {
30 $this->id = 'thinkrank/get-seo-opportunities';
31 $this->label = __( 'Get ThinkRank SEO Opportunities', 'thinkrank' );
32 $this->description = __( 'Retrieve ThinkRank SEO opportunities (e.g. striking-distance keywords). Requires Google Search Console to be connected; returns empty data otherwise.', 'thinkrank' );
33 }
34
35 /**
36 * {@inheritDoc}
37 *
38 * @return array<string, bool|float|string>
39 */
40 public function get_annotations() {
41 return [
42 'readonly' => true,
43 'destructive' => false,
44 'idempotent' => true,
45 'priority' => 1.0,
46 'openWorldHint' => false,
47 ];
48 }
49
50 /**
51 * {@inheritDoc}
52 *
53 * @return array<string, mixed>
54 */
55 public function get_input_schema() {
56 return [
57 'type' => 'object',
58 'additionalProperties' => false,
59 'properties' => [
60 'date_range' => [
61 'type' => 'string',
62 'description' => __( 'The reporting date range.', 'thinkrank' ),
63 'enum' => [ '7d', '30d', '90d' ],
64 'default' => '30d',
65 ],
66 ],
67 ];
68 }
69
70 /**
71 * {@inheritDoc}
72 *
73 * @return array<string, mixed>
74 */
75 public function get_output_schema() {
76 return [
77 'type' => 'object',
78 'additionalProperties' => true,
79 'properties' => [],
80 ];
81 }
82
83 /**
84 * Execute ability.
85 *
86 * @param array<string, mixed> $input Ability input payload.
87 * @return array<string, mixed>
88 */
89 public function execute( $input ) {
90 $date_range = isset( $input['date_range'] ) ? (string) $input['date_range'] : '30d';
91
92 if ( ! in_array( $date_range, [ '7d', '30d', '90d' ], true ) ) {
93 $date_range = '30d';
94 }
95
96 $manager = new Analytics_Manager();
97
98 return $manager->get_seo_opportunities( $date_range );
99 }
100 }
101