PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.7.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.7.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 / import / class-detect-import-sources.php

class-detect-import-sources.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.7.0, at includes/abilities/import/class-detect-import-sources.php

101 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Detect import sources ability.
4 *
5 * @package ThinkRank\Abilities\Import
6 */
7
8 declare(strict_types=1);
9
10 namespace ThinkRank\Abilities\Import;
11
12 use ThinkRank\Abilities\Ability_Base;
13 use ThinkRank\Admin\Importers\Import_Detector;
14 use ThinkRank\Admin\Importers\Snapshot_Store;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit if accessed directly.
18 }
19
20 /**
21 * Detects installed SEO plugins whose data can be imported into ThinkRank.
22 *
23 * Mirrors `GET /thinkrank/v1/import/detect`: returns the active source plugins
24 * (Yoast, RankMath, SEOPress, AIOSEO) with per-type available counts, alongside
25 * any snapshots already captured.
26 */
27 class Detect_Import_Sources extends Ability_Base {
28 /**
29 * Constructor.
30 */
31 public function __construct() {
32 $this->id = 'thinkrank/detect-import-sources';
33 $this->label = __( 'Detect SEO Import Sources', 'thinkrank' );
34 $this->description = __( 'Detect installed SEO plugins (Yoast, RankMath, SEOPress, AIOSEO) whose metadata can be imported into ThinkRank, with per-type available counts, plus any snapshots already captured. Start here: pass a detected source to preview-seo-import to see what an import would change, then run-seo-import to perform it.', 'thinkrank' );
35 }
36
37 /**
38 * {@inheritDoc}
39 *
40 * @return array<string, bool|float|string>
41 */
42 public function get_annotations() {
43 return [
44 'readonly' => true,
45 'destructive' => false,
46 'idempotent' => true,
47 'priority' => 1.0,
48 'openWorldHint' => false,
49 ];
50 }
51
52 /**
53 * {@inheritDoc}
54 *
55 * @return array<string, mixed>
56 */
57 public function get_input_schema() {
58 return [
59 'type' => 'object',
60 'additionalProperties' => false,
61 'properties' => self::empty_properties(),
62 ];
63 }
64
65 /**
66 * {@inheritDoc}
67 *
68 * @return array<string, mixed>
69 */
70 public function get_output_schema() {
71 return [
72 'type' => 'object',
73 'properties' => [
74 'detected' => [
75 'type' => 'object',
76 'additionalProperties' => true,
77 ],
78 'snapshots' => [
79 'type' => 'object',
80 'additionalProperties' => true,
81 ],
82 ],
83 ];
84 }
85
86 /**
87 * Execute ability.
88 *
89 * @param array<string, mixed> $input Ability input payload.
90 * @return array<string, mixed>
91 */
92 public function execute( $input ) {
93 $detector = new Import_Detector();
94
95 return [
96 'detected' => $detector->detect(),
97 'snapshots' => Snapshot_Store::get_available_snapshots(),
98 ];
99 }
100 }
101