id = 'thinkrank/get-import-status'; $this->label = __( 'Get SEO Import Status', 'thinkrank' ); $this->description = __( 'Report the status of captured SEO import snapshots: export status (exporting/complete), per-type record and chunk totals, and migration timestamps. Optionally scope to a single source plugin. Reports on the snapshots captured by run-seo-import.', 'thinkrank' ); } /** * {@inheritDoc} * * @return array */ public function get_annotations() { return [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, 'priority' => 1.0, 'openWorldHint' => false, ]; } /** * {@inheritDoc} * * @return array */ public function get_input_schema() { return [ 'type' => 'object', 'additionalProperties' => false, 'properties' => [ 'plugin' => [ 'type' => 'string', 'description' => __( 'Optional source plugin to scope the status to.', 'thinkrank' ), 'enum' => self::ALLOWED_PLUGINS, ], ], ]; } /** * {@inheritDoc} * * @return array */ public function get_output_schema() { return [ 'type' => 'object', 'properties' => [ 'snapshots' => [ 'type' => 'object', 'additionalProperties' => true, ], ], ]; } /** * Execute ability. * * @param array $input Ability input payload. * @return array */ public function execute( $input ) { $plugin = isset( $input['plugin'] ) ? sanitize_key( (string) $input['plugin'] ) : ''; if ( '' !== $plugin && in_array( $plugin, self::ALLOWED_PLUGINS, true ) ) { $manifest = Snapshot_Store::get_manifest( $plugin ); return [ 'snapshots' => null === $manifest ? [] : [ $plugin => $manifest ], ]; } return [ 'snapshots' => Snapshot_Store::get_available_snapshots(), ]; } }