array( 'type' => 'boolean', 'description' => __( 'True to cache, false to stop caching.', 'acrossai-abilities-manager' ), ), 'confirm' => array( 'type' => 'boolean', 'default' => false, 'description' => __( 'Required only when disabling the cache.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( 'enabled', ); } protected function output_properties(): array { return array( 'enabled' => array( 'type' => 'boolean' ), 'changed' => array( 'type' => 'boolean' ), ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true, ); } protected function run( array $input ) { $enabled = ! empty( $input['enabled'] ); // Confirmation is required only for the direction that silently degrades the site. A generic // requires_confirmation() would also gate turning caching ON, which protects nothing. if ( ! $enabled && empty( $input['confirm'] ) ) { return new WP_Error( 'confirmation_required', __( 'Disabling the cache stops every page being cached, and nothing on the site will indicate that. Pass confirm: true to proceed.', 'acrossai-abilities-manager' ) ); } $updated = Settings_Repository::write( 'cache-general', array( 'cache' => $enabled ) ); if ( is_wp_error( $updated ) ) { return $updated; } return array( 'enabled' => (bool) Settings_Repository::value( 'cache' ), 'changed' => array() !== $updated, 'message' => $enabled ? __( 'LiteSpeed caching is on.', 'acrossai-abilities-manager' ) : __( 'LiteSpeed caching is now OFF. Nothing is being cached.', 'acrossai-abilities-manager' ), ); } }