PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.9.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.9.0
2.9.0 2.8.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 All 50 releases
← All changes | includes/abilities/settings/class-update-sitemap-settings.php +13 -48 2.0.0 → 2.9.0 View file →
@@ -22,34 +22,14 @@
22 22 * Sitemap settings are persisted through the Sitemap_Generator SEO manager.
23 23 */
24 24 class Update_Sitemap_Settings extends Ability_Base {
25 25 /**
26 - * Boolean-typed sitemap keys.
27 - */
28 - private const BOOL_KEYS = [
29 - 'enabled',
30 - 'include_images',
31 - 'include_posts',
32 - 'include_pages',
33 - 'include_categories',
34 - 'include_tags',
35 - ];
36 -
37 - /**
38 - * String-typed sitemap keys.
39 - */
40 - private const STRING_KEYS = [
41 - 'exclude_posts',
42 - 'exclude_terms',
43 - ];
44 -
45 - /**
46 26 * Constructor.
47 27 */
48 28 public function __construct() {
49 29 $this->id = 'thinkrank/update-sitemap-settings';
50 30 $this->label = __( 'Update ThinkRank Sitemap Settings', 'thinkrank' );
51 - $this->description = __( 'Update ThinkRank XML sitemap settings, including per-type inclusion toggles and exclusion lists.', 'thinkrank' );
31 + $this->description = __( 'Update ThinkRank XML sitemap settings: per-type inclusion toggles, exclusion lists, and the index/splitting, styling, filename and search-engine ping options. Read the current values with get-sitemap-settings first; only the keys you pass are changed.', 'thinkrank' );
52 32 }
53 33
54 34 /**
55 35 * {@inheritDoc}
@@ -58,9 +38,16 @@
58 38 */
59 39 public function get_annotations() {
60 40 return [
61 41 'readonly' => false,
62 - 'destructive' => true,
42 + // Settings writes are recoverable: the matching get-* ability reads
43 + // the previous value, so nothing is lost that cannot be put back.
44 + // `destructive` is reserved for calls that lose data or reach
45 + // outside the site, and marking routine configuration with it made
46 + // MCP clients demand a human approval for every save — which users
47 + // reported as a permission bug, because the client's refusal reads
48 + // as "No approval received" (#675).
49 + 'destructive' => false,
63 50 'idempotent' => true,
64 51 'priority' => 2.0,
65 52 'openWorldHint' => false,
66 53 ];
@@ -78,18 +65,9 @@
78 65 'properties' => [
79 66 'settings' => [
80 67 'type' => 'object',
81 68 'description' => __( 'Sitemap settings to update.', 'thinkrank' ),
82 - 'properties' => [
83 - 'enabled' => [ 'type' => 'boolean' ],
84 - 'include_images' => [ 'type' => 'boolean' ],
85 - 'include_posts' => [ 'type' => 'boolean' ],
86 - 'include_pages' => [ 'type' => 'boolean' ],
87 - 'include_categories' => [ 'type' => 'boolean' ],
88 - 'include_tags' => [ 'type' => 'boolean' ],
89 - 'exclude_posts' => [ 'type' => 'string' ],
90 - 'exclude_terms' => [ 'type' => 'string' ],
91 - ],
69 + 'properties' => Settings_Key_Map::sitemap(),
92 70 ],
93 71 ],
94 72 'required' => [ 'settings' ],
95 73 ];
@@ -128,25 +106,12 @@
128 106 }
129 107
130 108 $gen = new Sitemap_Generator();
131 109 $merged = $gen->get_settings( 'site', null );
132 - $found = false;
110 + $patch = Settings_Key_Map::coerce( Settings_Key_Map::sitemap(), $settings );
111 + $merged = array_merge( $merged, $patch );
133 112
134 - foreach ( self::BOOL_KEYS as $key ) {
135 - if ( array_key_exists( $key, $settings ) ) {
136 - $merged[ $key ] = (bool) $settings[ $key ];
137 - $found = true;
138 - }
139 - }
140 -
141 - foreach ( self::STRING_KEYS as $key ) {
142 - if ( array_key_exists( $key, $settings ) ) {
143 - $merged[ $key ] = sanitize_text_field( (string) $settings[ $key ] );
144 - $found = true;
145 - }
146 - }
147 -
148 - if ( ! $found ) {
113 + if ( empty( $patch ) ) {
149 114 return new \WP_Error(
150 115 'thinkrank_no_valid_sitemap_setting_keys',
151 116 __( 'No valid sitemap setting keys were provided.', 'thinkrank' ),
152 117 [ 'status' => 400 ]