# thinkrank/2.1.0/includes/abilities/analysis/class-get-seo-analytics-data.php

ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console &amp; Local SEO, version 2.1.0. 102 lines.

- Page: https://pluginprobe.com/plugins/thinkrank/2.1.0/code/includes/abilities/analysis/class-get-seo-analytics-data.php
- Raw: https://pluginprobe.com/plugins/thinkrank/2.1.0/raw/includes/abilities/analysis/class-get-seo-analytics-data.php
- Modified: 2026-08-25T10:58:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/thinkrank/2.1.0/code/includes/abilities/analysis/class-get-seo-analytics-data.php#L10-L20`.

```php
<?php
/**
 * Get SEO analytics data ability.
 *
 * @package ThinkRank\Abilities\Analysis
 */

declare(strict_types=1);

namespace ThinkRank\Abilities\Analysis;

use ThinkRank\Abilities\Ability_Base;
use ThinkRank\SEO\Analytics_Manager;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Retrieves the ThinkRank SEO analytics dashboard data.
 *
 * Requires Google Search Console / Google Analytics to be connected. When no
 * Google connection is present, empty data is returned (this is expected and is
 * not an error).
 */
class Get_Seo_Analytics_Data extends Ability_Base {
	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->id          = 'thinkrank/get-seo-analytics-data';
		$this->label       = __( 'Get ThinkRank SEO Analytics Data', 'thinkrank' );
		$this->description = __( 'Retrieve the ThinkRank SEO analytics dashboard data. Requires Google Search Console / Analytics to be connected; returns empty data otherwise.', 'thinkrank' );
	}

	/**
	 * {@inheritDoc}
	 *
	 * @return array<string, bool|float|string>
	 */
	public function get_annotations() {
		return [
			'readonly'      => true,
			'destructive'   => false,
			'idempotent'    => true,
			'priority'      => 1.0,
			'openWorldHint' => false,
		];
	}

	/**
	 * {@inheritDoc}
	 *
	 * @return array<string, mixed>
	 */
	public function get_input_schema() {
		return [
			'type'                 => 'object',
			'additionalProperties' => false,
			'properties'           => [
				'date_range' => [
					'type'        => 'string',
					'description' => __( 'The reporting date range.', 'thinkrank' ),
					'enum'        => [ '7d', '30d', '90d' ],
					'default'     => '30d',
				],
			],
		];
	}

	/**
	 * {@inheritDoc}
	 *
	 * @return array<string, mixed>
	 */
	public function get_output_schema() {
		return [
			'type'                 => 'object',
			'additionalProperties' => true,
			'properties'           => self::empty_properties(),
		];
	}

	/**
	 * Execute ability.
	 *
	 * @param array<string, mixed> $input Ability input payload.
	 * @return array<string, mixed>
	 */
	public function execute( $input ) {
		$date_range = isset( $input['date_range'] ) ? (string) $input['date_range'] : '30d';

		if ( ! in_array( $date_range, [ '7d', '30d', '90d' ], true ) ) {
			$date_range = '30d';
		}

		$manager = new Analytics_Manager();

		return $manager->get_dashboard_data( $date_range );
	}
}

```
