| 1 |
<?php |
| 2 |
/** |
| 3 |
* Get sitemap settings ability. |
| 4 |
* |
| 5 |
* @package ThinkRank\Abilities\Settings |
| 6 |
*/ |
| 7 |
|
| 8 |
declare(strict_types=1); |
| 9 |
|
| 10 |
namespace ThinkRank\Abilities\Settings; |
| 11 |
|
| 12 |
use ThinkRank\Abilities\Ability_Base; |
| 13 |
use ThinkRank\SEO\Sitemap_Generator; |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Retrieves ThinkRank XML sitemap settings. |
| 21 |
* |
| 22 |
* Sitemap settings are stored via the Sitemap_Generator SEO manager and use |
| 23 |
* per-type inclusion toggles plus exclusion lists. |
| 24 |
*/ |
| 25 |
class Get_Sitemap_Settings extends Ability_Base { |
| 26 |
/** |
| 27 |
* Constructor. |
| 28 |
*/ |
| 29 |
public function __construct() { |
| 30 |
$this->id = 'thinkrank/get-sitemap-settings'; |
| 31 |
$this->label = __( 'Get ThinkRank Sitemap Settings', 'thinkrank' ); |
| 32 |
$this->description = __( 'Retrieve ThinkRank XML sitemap settings: per-type inclusion toggles, exclusion lists, and the index/splitting, styling, filename and search-engine ping options. Use update-sitemap-settings to change them.', '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' => self::empty_properties(), |
| 60 |
]; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* {@inheritDoc} |
| 65 |
* |
| 66 |
* @return array<string, mixed> |
| 67 |
*/ |
| 68 |
public function get_output_schema() { |
| 69 |
return [ |
| 70 |
'type' => 'object', |
| 71 |
'properties' => Settings_Key_Map::sitemap(), |
| 72 |
]; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Execute ability. |
| 77 |
* |
| 78 |
* @param array<string, mixed> $input Ability input payload. |
| 79 |
* @return array<string, mixed> |
| 80 |
*/ |
| 81 |
public function execute( $input ) { |
| 82 |
$gen = new Sitemap_Generator(); |
| 83 |
$s = $gen->get_settings( 'site', null ); |
| 84 |
|
| 85 |
return Settings_Key_Map::read( Settings_Key_Map::sitemap(), $s ); |
| 86 |
} |
| 87 |
} |
| 88 |
|