| 1 |
<?php |
| 2 |
/** |
| 3 |
* Get llms.txt status 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\LLMs_Txt_Manager; |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Reports the current status of the published llms.txt file. |
| 21 |
*/ |
| 22 |
class Get_Llms_Txt_Status extends Ability_Base { |
| 23 |
/** |
| 24 |
* Constructor. |
| 25 |
*/ |
| 26 |
public function __construct() { |
| 27 |
$this->id = 'thinkrank/get-llms-txt-status'; |
| 28 |
$this->label = __( 'Get ThinkRank llms.txt Status', 'thinkrank' ); |
| 29 |
$this->description = __( 'Report the current status of the published llms.txt file, including existence, path, URL, writability, last modified time, size, and a content preview.', 'thinkrank' ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* {@inheritDoc} |
| 34 |
* |
| 35 |
* @return array<string, bool|float|string> |
| 36 |
*/ |
| 37 |
public function get_annotations() { |
| 38 |
return [ |
| 39 |
'readonly' => true, |
| 40 |
'destructive' => false, |
| 41 |
'idempotent' => true, |
| 42 |
'priority' => 1.0, |
| 43 |
'openWorldHint' => false, |
| 44 |
]; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* {@inheritDoc} |
| 49 |
* |
| 50 |
* @return array<string, mixed> |
| 51 |
*/ |
| 52 |
public function get_input_schema() { |
| 53 |
return [ |
| 54 |
'type' => 'object', |
| 55 |
'additionalProperties' => false, |
| 56 |
'properties' => [], |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* {@inheritDoc} |
| 62 |
* |
| 63 |
* @return array<string, mixed> |
| 64 |
*/ |
| 65 |
public function get_output_schema() { |
| 66 |
return [ |
| 67 |
'type' => 'object', |
| 68 |
'properties' => [ |
| 69 |
'file_exists' => [ 'type' => 'boolean' ], |
| 70 |
'published' => [ 'type' => 'boolean' ], |
| 71 |
'delivery_mode' => [ 'type' => 'string' ], |
| 72 |
'file_path' => [ 'type' => 'string' ], |
| 73 |
'file_url' => [ 'type' => 'string' ], |
| 74 |
'writable' => [ 'type' => 'boolean' ], |
| 75 |
'last_modified' => [ 'type' => [ 'string', 'integer', 'null' ] ], |
| 76 |
'file_size' => [ 'type' => [ 'integer', 'null' ] ], |
| 77 |
'content_preview' => [ 'type' => 'string' ], |
| 78 |
], |
| 79 |
]; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Execute ability. |
| 84 |
* |
| 85 |
* @param array<string, mixed> $input Ability input payload. |
| 86 |
* @return array<string, mixed> |
| 87 |
*/ |
| 88 |
public function execute( $input ) { |
| 89 |
$manager = new LLMs_Txt_Manager(); |
| 90 |
|
| 91 |
return $manager->get_llms_txt_status( false ); |
| 92 |
} |
| 93 |
} |
| 94 |
|