array( 'type' => 'integer', 'description' => __( 'Crawler index from litespeed/list-crawlers.', 'acrossai-abilities-manager' ), ), 'enabled' => array( 'type' => 'boolean', 'description' => __( 'Desired state.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( 'index', 'enabled', ); } protected function output_properties(): array { return array( 'index' => array( 'type' => 'integer' ), 'enabled' => array( 'type' => 'boolean' ), ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true, ); } protected function run( array $input ) { $index = isset( $input['index'] ) ? (int) $input['index'] : -1; $state = Crawler_Repository::set_state( $index, ! empty( $input['enabled'] ) ); if ( is_wp_error( $state ) ) { return $state; } return array( 'index' => $index, 'enabled' => $state, 'message' => $state ? sprintf( /* translators: %d: crawler index */ __( 'Crawler %d enabled.', 'acrossai-abilities-manager' ), $index ) : sprintf( /* translators: %d: crawler index */ __( 'Crawler %d disabled.', 'acrossai-abilities-manager' ), $index ), ); } }