*/ protected function input_properties(): array { return array( 'id' => array( 'type' => 'integer', 'description' => __( 'Local snippet id, from list-snippet-updates.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'id' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'snippet' => array( 'type' => 'object', 'additionalProperties' => true ), 'in_cache' => array( 'type' => 'boolean' ), 'safe_mode' => array( 'type' => 'boolean' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => false ); } /** * @since 0.0.34 * @return bool */ protected function requires_confirmation(): bool { return true; } /** * @since 0.0.34 * @return string */ protected function confirmation_message(): string { return __( 'This replaces the snippet code with the library version. Any local edit to it will be lost. Pass confirm: true to proceed.', 'acrossai-abilities-manager' ); } /** * @since 0.0.34 * @return array> */ protected function suggested_abilities(): array { return array( array( 'slug' => 'snippets/list-snippet-updates', 'reason' => __( 'Lists which installed snippets actually have a newer version, so you update only what is stale.', 'acrossai-abilities-manager' ), ), array( 'slug' => 'snippets/deactivate-snippet', 'reason' => __( 'If an update breaks something, switching the snippet off stops it running without deleting it.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $updated = Library_Repository::pull_update( (int) ( $input['id'] ?? 0 ) ); if ( is_wp_error( $updated ) ) { return $updated; } return array( 'snippet' => $updated, 'in_cache' => $updated['in_cache'], 'safe_mode' => WPCode_Guard::safe_mode(), 'message' => __( 'Snippet updated from the library. Its active state on this site was preserved.', 'acrossai-abilities-manager' ), ); } }