*/ protected function input_properties(): array { return array( 'settings' => array( 'type' => 'object', 'description' => __( 'Field id => value. Writable fields are bing_post_types (a list of post type names) and indexnow_api_key (a string). Read the current values with rank-math/get-settings-panel panel=general-instant-indexing.', 'acrossai-abilities-manager' ), 'additionalProperties' => true, ), ); } /** * @return array */ protected function output_properties(): array { return array( 'updated' => array( 'type' => 'object' ), 'key_location' => array( 'type' => 'string' ), 'notifications' => array( 'type' => 'array' ), ); } /** * @return string[] */ protected function required_input(): array { return array( 'settings' ); } /** * @return array{readonly:bool,destructive:bool,idempotent:bool} */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { $settings = isset( $input['settings'] ) && is_array( $input['settings'] ) ? $input['settings'] : array(); if ( array() === $settings ) { return new WP_Error( 'invalid_input', __( 'The settings object is empty. Nothing to write.', 'acrossai-abilities-manager' ) ); } $result = Settings_Writer::save( 'general-instant-indexing', '', $settings ); if ( is_wp_error( $result ) ) { return $result; } $count = count( $result['updated'] ); return array( 'updated' => $result['updated'], 'key_location' => Instant_Indexing_Repository::key_location(), 'notifications' => $result['notifications'], 'message' => sprintf( /* translators: %d: number of settings written */ _n( 'Wrote %d Instant Indexing setting.', 'Wrote %d Instant Indexing settings.', $count, 'acrossai-abilities-manager' ), $count ), ); } }