Opens in a new tab
Atomic Edge Proof of Concept automated generator using AI diff analysis
Published : November 15, 2026

CVE-2026-106468: Code Snippets < 4.1.0 Missing Authorization PoC, Patch Analysis & Rule

Plugin code-snippets
Severity Low (CVSS 2.7)
CWE 862
Vulnerable Version 4.1.0
Patched Version 4.1.0
Disclosed November 10, 2026

Analysis Overview

Atomic Edge analysis of CVE-2026-106468:nnThe Code Snippets plugin for WordPress, versions up to 4.1.0, contains a missing authorization vulnerability in the snippet rendering shortcode and related REST endpoints. The issue allows authenticated attackers with administrator-level access to perform unauthorized actions, such as viewing or executing snippet source code that they should not have access to. The CVSS score is 2.7, indicating low severity due to the high privileges required.nnRoot Cause: The vulnerability stems from insufficient capability checks in the `Shortcodes` class (php/Integration/Shortcodes.php) and missing network scope checks in REST controllers (php/REST_API/Import/File_Import_REST_Controller.php, Plugins_Import_REST_Controller.php). The `can_render_snippet_source` method was introduced in the patch but absent in vulnerable versions. Prior to the patch, the shortcode handler `render_shortcode` directly rendered snippet source without verifying if the current post author had the capability to manage snippets. Similarly, REST endpoints for importing files and plugins did not properly validate network scope, allowing users with site-level permissions to perform network-level imports. The `permission_callback` methods only checked `current_user_can()` without considering network scope.nnExploitation: An attacker with administrator-level access (e.g., a site admin on a multisite installation) can craft a malicious request to the shortcode endpoint or REST API. For shortcodes, an attacker could embed a `[code_snippet]` shortcode in a post they author, specifying a snippet ID they do not own. Due to the missing capability check, the snippet source is rendered, potentially exposing sensitive code. For REST endpoints, an attacker could send a POST request to `/wp-json/code-snippets/v1/import/file` with a `network` parameter set to true, bypassing network capability checks and importing snippets at the network level.nnPatch Analysis: The patch introduces a new method `can_render_snippet_source` in the `Shortcodes` class, which checks the post author’s capability to manage snippets via `user_can_manage_snippets`. It also adds the `Network_Scope` trait to REST controllers, which validates the `network` parameter and enforces network capability checks. Additionally, the `permission_callback` methods now use `is_network_scoped_request` and `has_shared_network_snippets` to determine if network-level permissions are required. The patch also includes a new `user_can_manage_snippets` method in the `Plugin` class to centralize capability checks.nnImpact: Successful exploitation allows an attacker with administrator-level access to view snippet source code they should not access, potentially leading to information disclosure of sensitive code. On multisite installations, a site admin could perform network-level imports, escalating privileges to network admin. The low CVSS score reflects the high privileges required, but the vulnerability still poses a risk in multi-admin environments.

Differential between vulnerable and patched code

Below is a differential between the unpatched vulnerable code and the patched update, for reference.

Code Diff
--- a/code-snippets/code-snippets.php
+++ b/code-snippets/code-snippets.php
@@ -8,11 +8,11 @@
  * License:      GPL-2.0-or-later
  * License URI:  license.txt
  * Text Domain:  code-snippets
- * Version:      4.0.0
+ * Version:      4.1.0
  * Requires PHP: 7.4
  * Requires at least: 5.5
  *
- * @version   4.0.0
+ * @version   4.1.0
  * @package   Code_Snippets
  * @author    Shea Bunge <shea@codesnippets.pro>
  * @copyright 2012-2026 Code Snippets Pro
@@ -37,7 +37,7 @@
 	 *
 	 * @const string
 	 */
-	define( 'CODE_SNIPPETS_VERSION', '4.0.0' );
+	define( 'CODE_SNIPPETS_VERSION', '4.1.0' );

 	/**
 	 * The full path to the main file of this plugin.
--- a/code-snippets/php/Admin/Contextual_Help.php
+++ b/code-snippets/php/Admin/Contextual_Help.php
@@ -66,6 +66,14 @@
 				$this->load_ai_agent_help();
 				break;

+			case 'unified-snippets':
+				$this->load_unified_snippets_help();
+				break;
+
+			case 'preview':
+				$this->load_preview_help();
+				break;
+
 			case 'stats':
 				$this->load_stats_help();
 				break;
@@ -286,6 +294,44 @@
 			]
 		);
 	}
+
+	/**
+	 * Register and handle the help tabs for the Unified Snippets demo page.
+	 */
+	private function load_unified_snippets_help() {
+		$this->add_help_tab(
+			'overview',
+			__( 'Overview', 'code-snippets' ),
+			[
+				$this->get_intro_text(),
+				__( 'Unified Snippets finds custom code stored outside Code Snippets, such as in themes, the Customizer, plugins, page content and page builders.', 'code-snippets' ),
+			]
+		);
+
+		$this->add_help_tab(
+			'importing-code',
+			__( 'Importing Code', 'code-snippets' ),
+			[
+				__( 'Each item shows where it was found. Import items individually or in bulk; imported snippets are switched off until you activate them.', 'code-snippets' ),
+				__( 'Items that cannot safely run as a snippet are listed as view only.', 'code-snippets' ),
+			]
+		);
+	}
+
+	/**
+	 * Register and handle the help tabs for the snippet preview demo page.
+	 */
+	private function load_preview_help() {
+		$this->add_help_tab(
+			'overview',
+			__( 'Overview', 'code-snippets' ),
+			[
+				$this->get_intro_text(),
+				__( 'Preview tests a PHP, CSS, JavaScript or HTML snippet on a real page or admin screen before it is saved or activated.', 'code-snippets' ),
+				__( 'The preview is private to the person testing it, and visitors are not shown the draft.', 'code-snippets' ),
+			]
+		);
+	}

 	/**
 	 * Register and handle the help tabs for the Stats admin page.
--- a/code-snippets/php/Admin/Menus/Edit_Menu.php
+++ b/code-snippets/php/Admin/Menus/Edit_Menu.php
@@ -115,10 +115,26 @@

 		if ( $hook ) {
 			add_action( 'load-' . $hook, array( $this, 'load' ) );
+			add_action( 'load-' . $hook, array( $this, 'set_page_title' ) );
 		}
 	}

 	/**
+	 * Give the edit screen its title.
+	 *
+	 * WordPress looks a page's title up in the admin menu, where this page is not
+	 * registered, and the admin header requires one.
+	 *
+	 * @return void
+	 */
+	public function set_page_title(): void {
+		global $title;
+
+		// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- the admin header reads the page title from this global.
+		$title = $this->title;
+	}
+
+	/**
 	 * Mark the snippet being edited in the menu.
 	 *
 	 * Added as a plain link rather than a second registration of the page: a
--- a/code-snippets/php/Admin/Menus/Manage/Manage_Menu.php
+++ b/code-snippets/php/Admin/Menus/Manage/Manage_Menu.php
@@ -347,7 +347,7 @@
 		if ( $this->screen_options->is_upsell_view() ) {
 			$subpage = $this->screen_options->get_current_subpage();

-			if ( in_array( $subpage, [ 'cloud-library', 'blueprints', 'ai-agent' ], true ) ) {
+			if ( in_array( $subpage, [ 'cloud-library', 'blueprints', 'ai-agent', 'unified-snippets', 'preview' ], true ) ) {
 				$contextual_help = new Contextual_Help( $subpage );
 				$contextual_help->load();
 			}
--- a/code-snippets/php/Admin/Menus/Manage/Manage_Menu_Assets.php
+++ b/code-snippets/php/Admin/Menus/Manage/Manage_Menu_Assets.php
@@ -141,6 +141,15 @@
 			];
 		}

+		if ( $this->screen_options->is_preview_demo_view() ) {
+			// The preview demo draws a mock of this site's front page, so it
+			// carries the site's own name and address.
+			$localized['previewDemo'] = [
+				'siteName' => get_bloginfo( 'name' ),
+				'homeUrl'  => home_url( '/' ),
+			];
+		}
+
 		wp_localize_script( self::JS_HANDLE, 'CODE_SNIPPETS_MANAGE', $localized );
 	}
 }
--- a/code-snippets/php/Admin/Menus/Manage/Manage_Menu_Screen_Options.php
+++ b/code-snippets/php/Admin/Menus/Manage/Manage_Menu_Screen_Options.php
@@ -143,6 +143,18 @@
 	}

 	/**
+	 * Whether the current request renders the snippet preview demo.
+	 *
+	 * Like the AI Agent, the subpage remains an upsell view for {@see load()};
+	 * this detection exists only so its runtime data can be localized.
+	 *
+	 * @return bool
+	 */
+	public function is_preview_demo_view(): bool {
+		return 'preview' === $this->get_current_subpage();
+	}
+
+	/**
 	 * Whether the current request renders Community Cloud.
 	 *
 	 * The "Bundles" tab within Community Cloud is a Pro-only upsell rather than
--- a/code-snippets/php/Admin/Menus/Settings_Menu.php
+++ b/code-snippets/php/Admin/Menus/Settings_Menu.php
@@ -241,7 +241,7 @@
 			<?php $this->render_section_tabs(); ?>

 			<div class="snippets-page-header">
-				<h1><?php esc_html_e( 'Snippets Settings', 'code-snippets' ); ?></h1>
+				<h1 id="snippets-settings-heading"><?php esc_html_e( 'Snippets Settings', 'code-snippets' ); ?></h1>
 			</div>

 			<?php
@@ -270,7 +270,7 @@

 			<?php settings_errors( OPTION_NAME ); ?>

-			<form action="<?php echo esc_url( $update_url ); ?>" method="post">
+			<form aria-labelledby="snippets-settings-heading" action="<?php echo esc_url( $update_url ); ?>" method="post">
 				<input type="hidden" name="section" value="<?php echo esc_attr( $current_section ); ?>">
 				<?php

--- a/code-snippets/php/Client/Cloud_Public_Client.php
+++ b/code-snippets/php/Client/Cloud_Public_Client.php
@@ -22,6 +22,16 @@
 	private const SEARCH_REQUEST_TIMEOUT = 15;

 	/**
+	 * Seconds to wait for the remaining public API requests.
+	 *
+	 * Each is made while an admin screen is waiting on it, so it gives up
+	 * before the screen stalls, whatever the site's default timeout.
+	 *
+	 * @var int
+	 */
+	private const REQUEST_TIMEOUT = 5;
+
+	/**
 	 * Maximum number of cloud search results allowed per page.
 	 */
 	public const MAX_RESULTS_PER_PAGE = 100;
@@ -99,7 +109,8 @@
 	 */
 	public function get_cloud_snippet( int $cloud_id ): ?Cloud_Snippet {
 		$response = wp_remote_get(
-			sprintf( '%s/public/getsnippet/%s', $this->connection->get_api_url(), $cloud_id )
+			sprintf( '%s/public/getsnippet/%s', $this->connection->get_api_url(), $cloud_id ),
+			[ 'timeout' => self::REQUEST_TIMEOUT ]
 		);

 		$data = unpack_response_body( $response );
@@ -120,7 +131,8 @@
 	 */
 	public function get_cloud_snippet_revision( string $cloud_id ): ?string {
 		$response = wp_remote_get(
-			sprintf( '%s/public/getsnippetrevision/%s', $this->connection->get_api_url(), $cloud_id )
+			sprintf( '%s/public/getsnippetrevision/%s', $this->connection->get_api_url(), $cloud_id ),
+			[ 'timeout' => self::REQUEST_TIMEOUT ]
 		);

 		$body = unpack_response_body( $response );
@@ -150,7 +162,10 @@

 		$response = wp_remote_get(
 			add_query_arg( $params, sprintf( '%s/public/featured', $this->connection->get_api_url() ) ),
-			[ 'headers' => $this->connection->get_request_headers() ]
+			[
+				'headers' => $this->connection->get_request_headers(),
+				'timeout' => self::REQUEST_TIMEOUT,
+			]
 		);

 		return Cloud_Snippets::unpack_api_response( unpack_response_body( $response ), $page );
--- a/code-snippets/php/Client/Docs_Client.php
+++ b/code-snippets/php/Client/Docs_Client.php
@@ -0,0 +1,150 @@
+<?php
+
+namespace Code_SnippetsClient;
+
+use Code_SnippetsSearchSearch_Query;
+use function Code_SnippetsUtilsunpack_response_body;
+
+/**
+ * Loads the index of documentation articles published at codesnippets.pro/docs.
+ *
+ * Trust model: the index is a static JSON file read from codesnippets.pro over
+ * HTTPS, without credentials, and is treated as untrusted text. Titles, excerpts
+ * and category names are reduced to plain text before they are stored, and links
+ * are kept only when they lead back to codesnippets.pro. Nothing from the
+ * response is executed or rendered as markup.
+ *
+ * @package Code_Snippets
+ */
+class Docs_Client {
+
+	/**
+	 * Transient holding the cached index.
+	 */
+	public const CACHE_KEY = 'code_snippets_docs_index';
+
+	/**
+	 * URL of the documentation index.
+	 */
+	protected const INDEX_URL = 'https://codesnippets.pro/wp-content/uploads/cs_docs/cs-docs-index.json';
+
+	/**
+	 * Host that article links must belong to.
+	 */
+	private const DOCS_HOST = 'codesnippets.pro';
+
+	/**
+	 * How long a fetched index is reused for.
+	 */
+	private const CACHE_TTL = 12 * HOUR_IN_SECONDS;
+
+	/**
+	 * How long to wait before retrying after the index could not be fetched.
+	 */
+	private const FAILURE_TTL = 10 * MINUTE_IN_SECONDS;
+
+	/**
+	 * Request timeout, in seconds.
+	 */
+	private const REQUEST_TIMEOUT = 10;
+
+	/**
+	 * Largest number of articles kept from the index.
+	 */
+	private const MAX_ARTICLES = 500;
+
+	/**
+	 * Characters of each article's excerpt kept for matching.
+	 */
+	private const MAX_TEXT_LENGTH = 1000;
+
+	/**
+	 * Length of the identifier derived from an article's link.
+	 */
+	private const ID_LENGTH = 12;
+
+	/**
+	 * Retrieve the index of documentation articles, fetching it if it is not cached.
+	 *
+	 * @return array<int, array{id: string, title: string, url: string, text: string, category: string}>
+	 */
+	public function get_articles(): array {
+		$cached = get_transient( self::CACHE_KEY );
+
+		if ( is_array( $cached ) ) {
+			return $cached;
+		}
+
+		$articles = $this->fetch_articles();
+		set_transient( self::CACHE_KEY, $articles ?? [], is_null( $articles ) ? self::FAILURE_TTL : self::CACHE_TTL );
+
+		return $articles ?? [];
+	}
+
+	/**
+	 * Purge the cached index.
+	 *
+	 * @return void
+	 */
+	public static function clear_cache() {
+		delete_transient( self::CACHE_KEY );
+	}
+
+	/**
+	 * Reduce a value from the index to plain text.
+	 *
+	 * @param mixed $value Value, expected to be a string.
+	 *
+	 * @return string
+	 */
+	private static function text( $value ): string {
+		return is_string( $value ) ? Search_Query::plain_text( $value ) : '';
+	}
+
+	/**
+	 * Fetch the documentation index and keep the articles that are safe to show.
+	 *
+	 * @return array<int, array{id: string, title: string, url: string, text: string, category: string}>|null
+	 *         Index of articles, or null if it could not be fetched.
+	 */
+	private function fetch_articles(): ?array {
+		$response = wp_remote_get( self::INDEX_URL, [ 'timeout' => self::REQUEST_TIMEOUT ] );
+
+		if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
+			return null;
+		}
+
+		$body = unpack_response_body( $response );
+
+		if ( ! is_array( $body ) || ! is_array( $body['articles'] ?? null ) ) {
+			return null;
+		}
+
+		$articles = [];
+
+		foreach ( array_slice( $body['articles'], 0, self::MAX_ARTICLES ) as $article ) {
+			if ( ! is_array( $article ) ) {
+				continue;
+			}
+
+			$url = esc_url_raw( is_string( $article['url'] ?? null ) ? $article['url'] : '', [ 'https' ] );
+			$title = self::text( $article['title'] ?? null );
+
+			if ( '' === $title || self::DOCS_HOST !== wp_parse_url( $url, PHP_URL_HOST ) ) {
+				continue;
+			}
+
+			$categories = is_array( $article['category'] ?? null ) ? $article['category'] : [];
+
+			$articles[] = [
+				'id'       => substr( md5( $url ), 0, self::ID_LENGTH ),
+				'title'    => $title,
+				'url'      => $url,
+				'text'     => mb_substr( self::text( $article['excerpt'] ?? null ), 0, self::MAX_TEXT_LENGTH ),
+				'category' => self::text( reset( $categories ) ),
+			];
+		}
+
+		return $articles;
+	}
+}
--- a/code-snippets/php/Client/Welcome_Client.php
+++ b/code-snippets/php/Client/Welcome_Client.php
@@ -43,6 +43,17 @@
 	protected const CACHE_KEY = 'code_snippets_welcome_data';

 	/**
+	 * Seconds to wait for the remote welcome document.
+	 *
+	 * This is fetched while an admin screen is rendering, and nothing on the
+	 * screen depends on it, so it gives up sooner than a request the reader is
+	 * actually waiting on.
+	 *
+	 * @var int
+	 */
+	protected const REQUEST_TIMEOUT = 3;
+
+	/**
 	 * Data fetched from the remote API.
 	 *
 	 * @var array{
@@ -74,6 +85,16 @@
 	}

 	/**
+	 * Retrieve the welcome page data that is already cached, without fetching it.
+	 *
+	 * @return array<string, mixed> Cached data, or an empty array when nothing is cached.
+	 */
+	public static function get_cached_data(): array {
+		$stored_data = get_transient( self::CACHE_KEY );
+		return is_array( $stored_data ) ? $stored_data : [];
+	}
+
+	/**
 	 * Purge the welcome data cache.
 	 *
 	 * @return void
@@ -201,7 +222,10 @@
 	 * @return void
 	 */
 	protected function fetch_remote_welcome_data() {
-		$remote_welcome_data = wp_remote_get( self::WELCOME_JSON_URL );
+		$remote_welcome_data = wp_remote_get(
+			self::WELCOME_JSON_URL,
+			[ 'timeout' => self::REQUEST_TIMEOUT ]
+		);

 		if ( is_wp_error( $remote_welcome_data ) ) {
 			return;
@@ -225,6 +249,17 @@
 	 * @return void
 	 */
 	protected function build_changelog_data() {
+		$this->welcome_data['changelog'] = self::read_changelog();
+	}
+
+	/**
+	 * Read the latest releases from the plugin's changelog file.
+	 *
+	 * The file ships with the plugin, so this never makes a remote request.
+	 *
+	 * @return array<int, array{version: string, date: string, entries: array<string, array<string, string[]>>}>
+	 */
+	public static function read_changelog(): array {
 		require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
 		require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
 		$filesystem = new WP_Filesystem_Direct( null );
@@ -240,7 +275,7 @@
 		}

 		if ( ! $filesystem->exists( $changelog_dir . $changelog_filename ) ) {
-			return;
+			return [];
 		}

 		$changelog_contents = $filesystem->get_contents( $changelog_dir . $changelog_filename );
@@ -301,7 +336,7 @@
 			];
 		}

-		$this->welcome_data['changelog'] = $changelog;
+		return $changelog;
 	}

 	/**
--- a/code-snippets/php/Core/DB.php
+++ b/code-snippets/php/Core/DB.php
@@ -98,13 +98,27 @@

 	/**
 	 * Create the snippet tables, or upgrade them if they already exist
+	 *
+	 * @return bool Whether every table was created or upgraded.
 	 */
-	public function create_or_upgrade_tables() {
-		if ( is_multisite() ) {
-			$this->create_table( $this->ms_table );
-		}
+	public function create_or_upgrade_tables(): bool {
+		$network_okay = ! is_multisite() || $this->create_table( $this->ms_table );
+		return $this->create_table( $this->table ) && $network_okay;
+	}
+
+	/**
+	 * Upgrade a table that a write has just failed on because it lacks a column.
+	 *
+	 * A table that missed an upgrade fails every save that writes a column it does not have.
+	 *
+	 * @param string $table_name Table the write failed on.
+	 *
+	 * @return bool Whether the table was upgraded, so the write can be retried.
+	 */
+	public static function upgrade_after_unknown_column( string $table_name ): bool {
+		global $wpdb;

-		$this->create_table( $this->table );
+		return false !== stripos( (string) $wpdb->last_error, 'Unknown column' ) && self::create_table( $table_name );
 	}

 	/**
@@ -322,7 +336,7 @@
 			: 'AND active <> -1';

 		$snippets = $wpdb->get_results(
-			// phpcs:disable WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
+		// phpcs:disable WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
 			$wpdb->prepare(
 				"
 				SELECT id, code, scope, active, priority
--- a/code-snippets/php/Core/Uninstaller.php
+++ b/code-snippets/php/Core/Uninstaller.php
@@ -10,8 +10,11 @@
 namespace Code_SnippetsCore;

 use Code_SnippetsAdminFeedback_Panel;
+use Code_SnippetsClientDocs_Client;
 use Code_SnippetsClientFeedback_Client;
 use Code_SnippetsModelFeedback_Connection;
+use Code_SnippetsSearchUniversal_Search;
+use Code_SnippetsSettingsVersion_Switch;
 use function Code_Snippetsflush_versioned_cache_groups;

 /**
@@ -88,9 +91,16 @@
 		delete_transient( 'cs_codevault_snippets' );
 		delete_transient( 'cs_local_to_cloud_map' );

+		Docs_Client::clear_cache();
+		Universal_Search::clear_caches();
+
 		delete_option( Feedback_Connection::CREDENTIALS_OPTION );
 		delete_transient( Feedback_Panel::SUMMARY_TRANSIENT );
 		delete_transient( Feedback_Client::REGISTRATION_FAILURE_TRANSIENT );
+
+		// The switcher caches under a key belonging to whichever source is in
+		// force, so it has to do its own clearing rather than name the keys here.
+		Version_Switch::clear_version_caches();
 	}

 	/**
--- a/code-snippets/php/Core/Upgrader.php
+++ b/code-snippets/php/Core/Upgrader.php
@@ -134,6 +134,13 @@
 			$role->remove_cap( apply_filters( 'code_snippets_cap', 'manage_snippets' ) );
 		}

+		// The version switcher caches its catalogue under a key belonging to the
+		// source that produced it. A site whose source changed across this upgrade
+		// would otherwise keep serving the previous source's list until it expired.
+		if ( version_compare( $prev_version, '4.0.0', '<' ) ) {
+			delete_transient( 'code_snippets_available_versions' );
+		}
+
 		if ( false === $prev_version ) {
 			add_action( 'init', [ $this, 'create_sample_content' ] );
 		}
--- a/code-snippets/php/Integration/Evaluate_Functions.php
+++ b/code-snippets/php/Integration/Evaluate_Functions.php
@@ -39,10 +39,9 @@
 		// plugins are still being included, which is before WordPress loads
 		// pluggable.php, so a capability check at this point would call an
 		// undefined wp_get_current_user() and take the whole request down.
-		// The capability is checked in the callback instead, which never runs
-		// before URLs are being generated.
-		if ( $this->is_safe_mode_query_var_set() ) {
-			add_filter( 'home_url', [ $this, 'add_safe_mode_query_var' ] );
+		// Site URLs are left alone: callers append paths to them, REST URLs
+		// among them, and a query var in the middle breaks the result.
+		if ( self::is_safe_mode_query_var_set() ) {
 			add_filter( 'admin_url', [ $this, 'add_safe_mode_query_var' ] );
 		}
 	}
@@ -54,7 +53,7 @@
 	 *
 	 * @return bool
 	 */
-	public function is_safe_mode_query_var_set(): bool {
+	public static function is_safe_mode_query_var_set(): bool {
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
 		return ! empty( $_REQUEST['snippets-safe-mode'] );
 	}
@@ -68,7 +67,7 @@
 	 * @return bool
 	 */
 	public function is_safe_mode_requested(): bool {
-		return $this->is_safe_mode_query_var_set() && code_snippets()->current_user_can();
+		return self::is_safe_mode_query_var_set() && code_snippets()->current_user_can();
 	}

 	/**
@@ -81,9 +80,11 @@
 	public function add_safe_mode_query_var( $url ): string {
 		$url = is_string( $url ) ? $url : '';

-		return $this->is_safe_mode_requested() ?
-			add_query_arg( 'snippets-safe-mode', true, $url ) :
-			$url;
+		// No capability is checked here: doing so resolves the current user,
+		// and a plugin that builds a URL while that is under way would arrive
+		// back here and restart it. Snippets are only skipped for a user with
+		// the capability, which is checked where they are evaluated.
+		return add_query_arg( 'snippets-safe-mode', true, $url );
 	}

 	/**
--- a/code-snippets/php/Integration/Shortcodes.php
+++ b/code-snippets/php/Integration/Shortcodes.php
@@ -94,6 +94,26 @@
 	}

 	/**
+	 * Determine whether the author of the current post may reveal the given snippet.
+	 *
+	 * The author is checked rather than the viewer, as published posts are viewed anonymously.
+	 *
+	 * @param Snippet $snippet Snippet object.
+	 * @param bool    $network Whether the snippet was requested from the network table.
+	 *
+	 * @return bool
+	 */
+	protected function can_render_snippet_source( Snippet $snippet, bool $network ): bool {
+		$post = get_post();
+		$allowed = $post && code_snippets()->user_can_manage_snippets(
+			(int) $post->post_author,
+			validate_network_param( $network )
+		);
+
+		return (bool) apply_filters( 'code_snippets/shortcode_can_render_source', $allowed, $snippet, $post );
+	}
+
+	/**
 	 * Allow boolean attributes to be provided without a value, similar to how React works.
 	 *
 	 * @param array<string|number, mixed> $atts          Unfiltered shortcode attributes.
@@ -277,12 +297,18 @@

 		// Render the source code if this is not a shortcode snippet.
 		if ( 'content' !== $snippet->scope ) {
-			return $snippet->id ? $this->render_snippet_source( $snippet ) : $this->invalid_id_warning( $snippet->id );
+			if ( ! $snippet->id ) {
+				return $this->invalid_id_warning( $snippet->id );
+			}
+
+			return $this->can_render_snippet_source( $snippet, (bool) $atts['network'] )
+				? $this->render_snippet_source( $snippet )
+				: '';
 		}

 		// If the snippet is inactive, either display a message or render nothing.
 		if ( ! $snippet->active ) {
-			if ( $atts['debug'] ) {
+			if ( $atts['debug'] && $this->can_render_snippet_source( $snippet, (bool) $atts['network'] ) ) {
 				/* translators: 1: snippet name, 2: snippet edit link */
 				$text = __( '%1$s is currently inactive. You can <a href="%2$s">edit this snippet</a> to activate it and make it visible. This message will not appear in the published post.', 'code-snippets' );
 				$snippet_name = '<strong>' . $snippet->name . '</strong>';
@@ -418,6 +444,11 @@
 		}

 		$snippet = $this->get_snippet( $id, (bool) $atts['network'] );
+
+		if ( ! $this->can_render_snippet_source( $snippet, (bool) $atts['network'] ) ) {
+			return '';
+		}
+
 		return $this->render_snippet_source( $snippet, $atts );
 	}
 }
--- a/code-snippets/php/Model/Cloud_Snippets.php
+++ b/code-snippets/php/Model/Cloud_Snippets.php
@@ -131,6 +131,12 @@
 		}

 		$result = new Cloud_Snippets();
+
+		// An error reply puts its details under `data`, where they would otherwise be read as snippets.
+		if ( false === ( $response['success'] ?? null ) ) {
+			return $result;
+		}
+
 		$snippets_data = $response['snippets'] ?? $response['data'] ?? null;

 		if ( is_array( $snippets_data ) ) {
--- a/code-snippets/php/Model/Snippet.php
+++ b/code-snippets/php/Model/Snippet.php
@@ -111,8 +111,11 @@
 	 */
 	protected function prepare_field( $value, string $field ) {
 		switch ( $field ) {
-			case 'id':
 			case 'priority':
+				// Stored as a SMALLINT; negative priorities are not supported.
+				return max( 0, min( 32767, intval( $value ) ) );
+
+			case 'id':
 			case 'condition_id':
 			case 'cloud_id':
 			case 'revision':
--- a/code-snippets/php/Plugin.php
+++ b/code-snippets/php/Plugin.php
@@ -6,6 +6,7 @@
 use Code_SnippetsAdminFeedback_Error_Capture;
 use Code_SnippetsAdminFeedback_Panel;
 use Code_SnippetsAdminMenusManageManage_Menu;
+use Code_SnippetsClientDocs_Client;
 use Code_SnippetsClientFeedback_Client;
 use Code_SnippetsControllerCloud_Search_Controller;
 use Code_SnippetsCoreDB;
@@ -26,8 +27,11 @@
 use Code_SnippetsREST_APIPreferencesDemos_Seen_REST_Controller;
 use Code_SnippetsREST_APIPreferencesStats_View_Rest_Controller;
 use Code_SnippetsREST_APIPreferencesSnippet_View_REST_Controller;
+use Code_SnippetsREST_APIREST_Cache_Bypass;
+use Code_SnippetsREST_APISearchSearch_REST_Controller;
 use Code_SnippetsREST_APISnippetsRecently_Active_REST_Controller;
 use Code_SnippetsREST_APISnippetsSnippets_REST_Controller;
+use Code_SnippetsSearchUniversal_Search;
 use function Code_SnippetsSettingsare_settings_unified;

 /**
@@ -155,6 +159,8 @@
 	public function init_rest_api() {
 		$cloud_search = new Cloud_Search_Controller( $this->cloud_connection );

+		new REST_Cache_Bypass();
+
 		new Snippets_REST_Controller();
 		new Recently_Active_REST_Controller();

@@ -168,6 +174,8 @@
 		new Cloud_Snippets_REST_Controller( $cloud_search );

 		new Feedback_REST_Controller( new Feedback_Client( new Feedback_Connection() ) );
+
+		new Search_REST_Controller( new Universal_Search( $cloud_search, new Docs_Client() ) );
 	}

 	/**
@@ -338,6 +346,22 @@
 	}

 	/**
+	 * Determine if a given user has the capability to manage snippets at the given scope.
+	 *
+	 * @param int  $user_id User ID.
+	 * @param bool $network Whether to check for network snippets.
+	 *
+	 * @return bool
+	 */
+	public function user_can_manage_snippets( int $user_id, bool $network = false ): bool {
+		if ( $network || ( is_multisite() && ! $this->is_subsite_menu_enabled() ) ) {
+			return is_super_admin( $user_id ) || user_can( $user_id, $this->get_network_cap_name() );
+		}
+
+		return user_can( $user_id, $this->get_cap_name() );
+	}
+
+	/**
 	 * Get the required capability to perform a certain action on snippets.
 	 * Does not check if the user has this capability or not.
 	 *
@@ -368,6 +392,7 @@
 			[
 				'debug'              => defined( 'WP_DEBUG' ) && WP_DEBUG,
 				'isLicensed'         => $this->licensing->is_licensed(),
+				'safeModeRequested'  => Evaluate_Functions::is_safe_mode_query_var_set() && $this->current_user_can(),
 				'isCloudConnected'   => $this->cloud_connection->is_authenticated(),
 				'hideUpsell'         => Settingsget_setting( 'general', 'hide_upgrade_menu' ),
 				'snippetView'        => Snippet_View_REST_Controller::get_snippet_view(),
@@ -387,6 +412,7 @@
 						'token'    => $this->cloud_connection->get_local_token(),
 						'snippets' => esc_url_raw( rest_url( Cloud_Snippets_REST_Controller::get_base_route() ) ),
 					],
+					'search'         => esc_url_raw( rest_url( Search_REST_Controller::get_base_route() ) ),
 				],
 				'urls'               => [
 					'plugin'    => esc_url_raw( plugins_url( '', PLUGIN_FILE ) ),
--- a/code-snippets/php/REST_API/Import/File_Import_REST_Controller.php
+++ b/code-snippets/php/REST_API/Import/File_Import_REST_Controller.php
@@ -3,6 +3,7 @@
 namespace Code_SnippetsREST_APIImport;

 use Code_SnippetsModelSnippet;
+use Code_SnippetsREST_APINetwork_Scope;
 use Code_SnippetsREST_APIREST_Controller;
 use DOMDocument;
 use WP_Error;
@@ -17,6 +18,8 @@
  * Manages the import of code snippets from uploaded files via REST API.
  */
 class File_Import_REST_Controller extends REST_Controller {
+	use Network_Scope;
+

 	/**
 	 * Current API version.
@@ -79,7 +82,32 @@
 	 * @return bool
 	 */
 	public function permission_callback( WP_REST_Request $request ): bool {
-		return code_snippets()->current_user_can();
+		return $this->is_network_scoped_request( $request ) || $this->has_shared_network_snippets( $request )
+			? code_snippets()->user_can_manage_network_snippets()
+			: code_snippets()->current_user_can();
+	}
+
+	/**
+	 * Determine whether any snippet in the request is marked as a shared network snippet.
+	 *
+	 * @param WP_REST_Request $request Incoming HTTP request.
+	 *
+	 * @return bool
+	 */
+	private function has_shared_network_snippets( WP_REST_Request $request ): bool {
+		$snippets = $request->get_param( 'snippets' );
+
+		if ( ! is_multisite() || ! is_array( $snippets ) ) {
+			return false;
+		}
+
+		foreach ( $snippets as $snippet ) {
+			if ( is_array( $snippet ) && ! empty( $snippet['shared_network'] ) ) {
+				return true;
+			}
+		}
+
+		return false;
 	}

 	/**
@@ -185,6 +213,18 @@
 			'message'     => sprintf( $message, count( $all_snippets ) ),
 		];

+		// Conditions are referenced by their ID on the site the snippet came from,
+		// which means nothing here, so they are left behind.
+		foreach ( $all_snippets as $snippet_data ) {
+			if ( absint( $snippet_data['condition_id'] ?? $snippet_data['conditionId'] ?? 0 ) ) {
+				$errors[] = sprintf(
+					/* translators: %s: snippet name */
+					__( '"%s" was limited by a condition on the site it came from. Conditions are not imported, so once activated it will run wherever its location allows.', 'code-snippets' ),
+					$snippet_data['name'] ?? __( 'Untitled Snippet', 'code-snippets' )
+				);
+			}
+		}
+
 		if ( ! empty( $errors ) ) {
 			$response['warnings'] = $errors;
 		}
--- a/code-snippets/php/REST_API/Import/Plugins_Import_REST_Controller.php
+++ b/code-snippets/php/REST_API/Import/Plugins_Import_REST_Controller.php
@@ -6,6 +6,7 @@
 use Code_SnippetsREST_APIImportPluginsInsert_Headers_And_Footers_Plugin_Importer;
 use Code_SnippetsREST_APIImportPluginsInsert_PHP_Code_Snippet_Plugin_Importer;
 use Code_SnippetsREST_APIImportPluginsPlugin_Importer;
+use Code_SnippetsREST_APINetwork_Scope;
 use Code_SnippetsREST_APIREST_Controller;
 use WP_REST_Request;
 use WP_REST_Response;
@@ -18,6 +19,8 @@
  * Handles registering REST API routes and providing information about available plugin importers.
  */
 class Plugins_Import_REST_Controller extends REST_Controller {
+	use Network_Scope;
+

 	/**
 	 * Current API version.
@@ -119,6 +122,8 @@
 	 * @return bool
 	 */
 	public function permission_callback( WP_REST_Request $request ): bool {
-		return code_snippets()->current_user_can();
+		return $this->is_network_scoped_request( $request )
+			? code_snippets()->user_can_manage_network_snippets()
+			: code_snippets()->current_user_can();
 	}
 }
--- a/code-snippets/php/REST_API/Network_Scope.php
+++ b/code-snippets/php/REST_API/Network_Scope.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Code_SnippetsREST_API;
+
+use WP_Error;
+use WP_REST_Request;
+
+/**
+ * Shared handling of the `network` request parameter for REST controllers.
+ */
+trait Network_Scope {
+
+	/**
+	 * Determine whether a request targets network-scoped snippets.
+	 *
+	 * Only the literal boolean `true` (or its common string/integer equivalents)
+	 * is treated as a network-scoped request. A missing or null `network` param
+	 * means "site-scoped", and must not be escalated to the network capability.
+	 *
+	 * @param WP_REST_Request|WP_Error $request Full data about the request.
+	 *
+	 * @return bool
+	 */
+	protected function is_network_scoped_request( $request ): bool {
+		if ( ! is_multisite() || ! $request instanceof WP_REST_Request || ! $request->has_param( 'network' ) ) {
+			return false;
+		}
+
+		$network = $request->get_param( 'network' );
+
+		if ( is_bool( $network ) ) {
+			return $network;
+		}
+
+		if ( is_string( $network ) ) {
+			return ! in_array( strtolower( $network ), [ '0', 'false', 'no', '' ], true );
+		}
+
+		return (bool) $network;
+	}
+}
--- a/code-snippets/php/REST_API/Preferences/Demos_Seen_REST_Controller.php
+++ b/code-snippets/php/REST_API/Preferences/Demos_Seen_REST_Controller.php
@@ -45,7 +45,7 @@
 	/**
 	 * Feature demos whose completion is recorded.
 	 */
-	public const DEMOS = [ 'ai-agent', 'blueprints' ];
+	public const DEMOS = [ 'ai-agent', 'blueprints', 'unified-snippets' ];

 	/**
 	 * Retrieve the feature demos that have been watched through to the end.
--- a/code-snippets/php/REST_API/REST_Cache_Bypass.php
+++ b/code-snippets/php/REST_API/REST_Cache_Bypass.php
@@ -0,0 +1,100 @@
+<?php
+
+namespace Code_SnippetsREST_API;
+
+use WP_HTTP_Response;
+use WP_REST_Request;
+use WP_REST_Server;
+use const Code_SnippetsREST_API_NAMESPACE;
+
+/**
+ * Keeps responses from this plugin's REST API routes out of page caches.
+ *
+ * Every route reports live state that the admin screens read again after each
+ * change, so a stored response replayed by a cache shows data that is no longer true.
+ */
+class REST_Cache_Bypass {
+
+	/**
+	 * Headers read by caches that sit in front of WordPress and never run its PHP hooks.
+	 *
+	 * @var array<string, string>
+	 */
+	public const HEADERS = [
+		// Browsers and any cache that follows the HTTP caching rules.
+		'Cache-Control'                => 'no-store, no-cache, must-revalidate, max-age=0, private',
+		'Pragma'                       => 'no-cache',
+		'Expires'                      => 'Wed, 11 Jan 1984 05:00:00 GMT',
+		// LiteSpeed and OpenLiteSpeed servers, which ignore Cache-Control.
+		'X-LiteSpeed-Cache-Control'    => 'no-cache',
+		// Nginx FastCGI and proxy caches.
+		'X-Accel-Expires'              => '0',
+		// Varnish, Fastly and other surrogate caches.
+		'Surrogate-Control'            => 'no-store',
+		// Cloudflare and CDNs that follow the targeted cache control standard.
+		'CDN-Cache-Control'            => 'no-store',
+		'Cloudflare-CDN-Cache-Control' => 'no-store',
+		// SiteGround dynamic cache.
+		'X-Cache-Enabled'              => 'False',
+	];
+
+	/**
+	 * Class constructor.
+	 */
+	public function __construct() {
+		add_filter( 'rest_post_dispatch', [ $this, 'bypass_cache' ], 10, 3 );
+	}
+
+	/**
+	 * Mark the response to a request for one of this plugin's routes as uncacheable.
+	 *
+	 * @param WP_HTTP_Response $response Response about to be served.
+	 * @param WP_REST_Server   $server   REST server instance.
+	 * @param WP_REST_Request  $request  Request the response answers.
+	 *
+	 * @return WP_HTTP_Response
+	 */
+	public function bypass_cache( $response, $server, $request ) {
+		if ( ! $response instanceof WP_HTTP_Response || ! $request instanceof WP_REST_Request ) {
+			return $response;
+		}
+
+		if ( 0 !== strpos( $request->get_route(), '/' . REST_API_NAMESPACE ) ) {
+			return $response;
+		}
+
+		/**
+		 * Filters whether responses from the Code Snippets REST API are kept out of page caches.
+		 *
+		 * @param bool            $bypass  Whether to mark the response as uncacheable.
+		 * @param WP_REST_Request $request Request the response answers.
+		 */
+		if ( ! apply_filters( 'code_snippets/rest_api/bypass_cache', true, $request ) ) {
+			return $response;
+		}
+
+		foreach ( self::HEADERS as $name => $value ) {
+			$response->header( $name, $value );
+		}
+
+		$this->signal_cache_plugins();
+
+		return $response;
+	}
+
+	/**
+	 * Tell caching plugins running inside WordPress not to store the current response.
+	 *
+	 * @return void
+	 */
+	private function signal_cache_plugins(): void {
+		// Honoured by WP Super Cache, W3 Total Cache, WP Rocket, WP Fastest Cache,
+		// WP-Optimize, Hummingbird, Cache Enabler, Breeze and LiteSpeed Cache.
+		if ( ! defined( 'DONOTCACHEPAGE' ) ) {
+			define( 'DONOTCACHEPAGE', true );
+		}
+
+		// LiteSpeed Cache decides from its own control API, and caches REST responses by default.
+		do_action( 'litespeed_control_set_nocache', 'Code Snippets REST API response' );
+	}
+}
--- a/code-snippets/php/REST_API/Search/Search_REST_Controller.php
+++ b/code-snippets/php/REST_API/Search/Search_REST_Controller.php
@@ -0,0 +1,161 @@
+<?php
+
+namespace Code_SnippetsREST_APISearch;
+
+use Code_SnippetsREST_APIREST_Controller;
+use Code_SnippetsSearchSearch_Query;
+use Code_SnippetsSearchUniversal_Search;
+use WP_REST_Request;
+use WP_REST_Response;
+use WP_REST_Server;
+use function Code_Snippetscode_snippets;
+
+/**
+ * Serves universal search results, grouped by the source they came from.
+ *
+ * The browser asks for the local sources and each remote source in separate
+ * requests, so a slow remote service delays only its own group.
+ *
+ * @package Code_Snippets
+ */
+final class Search_REST_Controller extends REST_Controller {
+
+	/**
+	 * Current API version.
+	 */
+	public const VERSION = 1;
+
+	/**
+	 * The base of this controller's route.
+	 */
+	public const BASE_ROUTE = 'search';
+
+	/**
+	 * Largest number of items returned for a single source.
+	 */
+	private const MAX_PER_SOURCE = 100;
+
+	/**
+	 * Search service.
+	 *
+	 * @var Universal_Search
+	 */
+	private Universal_Search $search;
+
+	/**
+	 * Class constructor.
+	 *
+	 * @param Universal_Search $search Search service.
+	 */
+	public function __construct( Universal_Search $search ) {
+		parent::__construct();
+		$this->search = $search;
+	}
+
+	/**
+	 * Register REST routes.
+	 */
+	public function register_routes() {
+		register_rest_route(
+			$this->namespace,
+			self::BASE_ROUTE,
+			[
+				[
+					'methods'             => WP_REST_Server::READABLE,
+					'callback'            => [ $this, 'get_results_callback' ],
+					'permission_callback' => [ $this, 'permission_callback' ],
+					'args'                => [
+						'q'          => [
+							'description'       => esc_html__( 'Text to search for.', 'code-snippets' ),
+							'type'              => 'string',
+							'required'          => true,
+							'sanitize_callback' => [ Search_Query::class, 'sanitize_term' ],
+						],
+						'sources'    => [
+							'description' => esc_html__( 'Sources to search. Defaults to every source.', 'code-snippets' ),
+							'type'        => 'array',
+							'items'       => [
+								'type' => 'string',
+								'enum' => Universal_Search::get_sources(),
+							],
+							'default'     => Universal_Search::get_sources(),
+						],
+						'fields'     => [
+							'description' => esc_html__( 'Fields to match the search text against. Defaults to every field.', 'code-snippets' ),
+							'type'        => 'array',
+							'items'       => [
+								'type' => 'string',
+								'enum' => Search_Query::FIELDS,
+							],
+							'default'     => Search_Query::FIELDS,
+						],
+						'method'     => [
+							'description' => esc_html__( 'How to search the cloud: by keyword, or with AI.', 'code-snippets' ),
+							'type'        => 'string',
+							'enum'        => Search_Query::METHODS,
+							'default'     => 'term',
+						],
+						'per_source' => [
+							'description' => esc_html__( 'Largest number of results to return for each source.', 'code-snippets' ),
+							'type'        => 'integer',
+							'default'     => 50,
+							'minimum'     => 1,
+							'maximum'     => self::MAX_PER_SOURCE,
+						],
+						'excerpts'   => [
+							'description' => esc_html__( 'Whether to shorten long descriptions to an excerpt around the match.', 'code-snippets' ),
+							'type'        => 'boolean',
+							'default'     => true,
+						],
+						'network'    => [
+							'description' => esc_html__( 'Search network-wide snippets instead of site-wide.', 'code-snippets' ),
+							'type'        => 'boolean',
+							'default'     => false,
+						],
+					],
+				],
+			]
+		);
+	}
+
+	/**
+	 * Determine whether the request has permission to search.
+	 *
+	 * @param WP_REST_Request $request Incoming HTTP request.
+	 *
+	 * @return bool
+	 */
+	public function permission_callback( WP_REST_Request $request ): bool {
+		return is_multisite() && $request->get_param( 'network' )
+			? code_snippets()->user_can_manage_network_snippets()
+			: code_snippets()->current_user_can();
+	}
+
+	/**
+	 * Callback for retrieving search results.
+	 *
+	 * @param WP_REST_Request $request The REST request object.
+	 *
+	 * @return WP_REST_Response Search results, grouped by source.
+	 */
+	public function get_results_callback( WP_REST_Request $request ): WP_REST_Response {
+		$query = new Search_Query(
+			(string) $request->get_param( 'q' ),
+			(array) $request->get_param( 'fields' ),
+			(bool) $request->get_param( 'excerpts' ),
+			(string) $request->get_param( 'method' )
+		);
+
+		return rest_ensure_response(
+			[
+				'query'  => $query->get_term(),
+				'groups' => $this->search->search(
+					$query,
+					(array) $request->get_param( 'sources' ),
+					is_multisite() && $request->get_param( 'network' ),
+					(int) $request->get_param( 'per_source' )
+				),
+			]
+		);
+	}
+}
--- a/code-snippets/php/REST_API/Snippets/Snippets_REST_Controller.php
+++ b/code-snippets/php/REST_API/Snippets/Snippets_REST_Controller.php
@@ -6,6 +6,7 @@
 use Code_SnippetsMigrationExportExport_Code;
 use Code_SnippetsMigrationExportExport_JSON;
 use Code_SnippetsModelSnippet;
+use Code_SnippetsREST_APINetwork_Scope;
 use Code_SnippetsREST_APIREST_Collection_Controller;
 use WP_Error;
 use WP_REST_Request;
@@ -30,6 +31,8 @@
  * @package Code_Snippets
  */
 final class Snippets_REST_Controller extends REST_Collection_Controller {
+	use Network_Scope;
+

 	/**
 	 * Current API version.
@@ -220,35 +223,6 @@
 	}

 	/**
-	 * Determine whether a request targets network-scoped snippets.
-	 *
-	 * Only the literal boolean `true` (or its common string/integer equivalents)
-	 * is treated as a network-scoped request. A missing or null `network` param
-	 * means "site-scoped", and must not be escalated to the network capability.
-	 *
-	 * @param WP_REST_Request|WP_Error $request Full data about the request.
-	 *
-	 * @return bool
-	 */
-	private function is_network_scoped_request( $request ): bool {
-		if ( ! is_multisite() || ! $request instanceof WP_REST_Request || ! $request->has_param( 'network' ) ) {
-			return false;
-		}
-
-		$network = $request->get_param( 'network' );
-
-		if ( is_bool( $network ) ) {
-			return $network;
-		}
-
-		if ( is_string( $network ) ) {
-			return ! in_array( strtolower( $network ), [ '0', 'false', 'no', '' ], true );
-		}
-
-		return (bool) $network;
-	}
-
-	/**
 	 * Verify the current user has permission for the scope implied by the request.
 	 *
 	 * @param WP_REST_Request $request Full data about the request.
@@ -533,6 +507,9 @@
 	 */
 	public function create_item( $request ) {
 		$snippet = $this->prepare_item_for_database( $request );
+
+		// An ID in the body names no snippet to create; saving it would overwrite that snippet.
+		$snippet->id = 0;
 		$result = save_snippet( $snippet );

 		return $result
@@ -594,6 +571,14 @@
 			);
 		}

+		if ( $snippet->locked ) {
+			return new WP_Error(
+				'rest_snippet_locked',
+				__( 'This snippet is locked. Unlock it before trashing or deleting it.', 'code-snippets' ),
+				[ 'status' => 409 ]
+			);
+		}
+
 		if ( $snippet->trashed ) {
 			return delete_snippet( $snippet->id, $snippet->network )
 				? new WP_REST_Response( null, 204 )
@@ -891,6 +876,7 @@
 				'scope'            => [
 					'description' => esc_html__( 'Context in which the snippet is executable.', 'code-snippets' ),
 					'type'        => 'string',
+					'enum'        => Snippet::get_all_scopes(),
 				],
 				'condition_id'     => [
 					'description' => esc_html__( 'Identifier of condition linked to this snippet.', 'code-snippets' ),
--- a/code-snippets/php/Search/Search_Index.php
+++ b/code-snippets/php/Search/Search_Index.php
@@ -0,0 +1,282 @@
+<?php
+
+namespace Code_SnippetsSearch;
+
+use Code_SnippetsClientWelcome_Client;
+use Code_SnippetsSettingsSettings_Fields;
+use Code_SnippetsSettingsSettings_Layout;
+use function Code_Snippetscode_snippets;
+
+/**
+ * Index of the plugin's own screens for universal search: every setting, the
+ * Stats reports and the sections of the welcome page.
+ *
+ * The entries are built from the same definitions the screens are rendered
+ * from rather than read out of the page, so they are available to a REST
+ * request that never loads those screens.
+ *
+ * Every entry has the shape `{ id, type, title, description, url, path }`.
+ *
+ * @package Code_Snippets
+ */
+final class Search_Index {
+
+	/**
+	 * Prefix of the element identifier given to each row of the settings table.
+	 */
+	public const SETTING_ANCHOR_PREFIX = 'setting-';
+
+	/**
+	 * Prefix of the element identifier given to each Stats report.
+	 */
+	public const STATS_ANCHOR_PREFIX = 'stats-chart-';
+
+	/**
+	 * Admin URL context that links are built for.
+	 *
+	 * @var string
+	 */
+	private string $url_context;
+
+	/**
+	 * Class constructor.
+	 *
+	 * @param bool $network Whether links should lead to the network admin.
+	 */
+	public function __construct( bool $network = false ) {
+		$this->url_context = $network ? 'network' : 'admin';
+	}
+
+	/**
+	 * Join the parts of a section path for display.
+	 *
+	 * @param string ...$parts Section names, outermost first.
+	 *
+	 * @return string
+	 */
+	public static function build_path( string ...$parts ): string {
+		return implode( ' › ', array_filter( $parts ) );
+	}
+
+	/**
+	 * Build the text describing a setting from its definition.
+	 *
+	 * A checkbox carries its explanation in its label, while the label of a
+	 * number field is only the unit shown beside it.
+	 *
+	 * @param array<string, mixed> $field Field definition.
+	 *
+	 * @return string
+	 */
+	private static function describe_setting( array $field ): string {
+		$parts = [];
+
+		if ( in_array( $field['type'] ?? '', [ 'checkbox', 'action' ], true ) && ! empty( $field['label'] ) ) {
+			$parts[] = (string) $field['label'];
+		}
+
+		if ( ! empty( $field['desc'] ) ) {
+			$parts[] = (string) $field['desc'];
+		}
+
+		if ( ! empty( $field['options'] ) && is_array( $field['options'] ) && 'checkboxes' === $field['type'] ) {
+			$parts[] = implode( ', ', array_map( 'strval', $field['options'] ) );
+		}
+
+		return Search_Query::plain_text( implode( ' ', $parts ) );
+	}
+
+	/**
+	 * Retrieve an entry for every setting shown on the settings screen.
+	 *
+	 * @return array<int, array<string, string>>
+	 */
+	public function get_settings_entries(): array {
+		$definitions = Settings_Fields::get_field_definitions();
+		$descriptions = Settings_Layout::get_descriptions();
+		$settings_url = code_snippets()->get_menu_url( 'settings', $this->url_context );
+		$settings_label = __( 'Settings', 'code-snippets' );
+		$entries = [];
+
+		foreach ( Settings_Layout::get_available_tabs() as $tab_id => $tab_label ) {
+			foreach ( Settings_Layout::get_visible_fields( $tab_id ) as $entry ) {
+				list( $section_id, $field_id ) = $entry;
+				$field = $definitions[ $section_id ][ $field_id ];
+
+				if ( empty( $field['name'] ) ) {
+					continue;
+				}
+
+				if ( isset( $descriptions[ $field_id ] ) ) {
+					$field['desc'] = $descriptions[ $field_id ];
+				}
+
+				$entries[] = [
+					'id'          => "$section_id-$field_id",
+					'type'        => 'setting',
+					'title'       => (string) $field['name'],
+					'description' => self::describe_setting( $field ),
+					'url'         => add_query_arg( 'section', $tab_id, $settings_url ) . '#' . self::SETTING_ANCHOR_PREFIX . $field_id,
+					'path'        => self::build_path( $settings_label, (string) $tab_label ),
+				];
+			}
+		}
+
+		return $entries;
+	}
+
+	/**
+	 * Retrieve an entry for every report on the Stats screen.
+	 *
+	 * @return array<int, array<string, string>>
+	 */
+	public function get_stats_entries(): array {
+		$stats_url = code_snippets()->get_menu_url( 'stats', $this->url_context );
+		$path = self::build_path( __( 'Stats', 'code-snippets' ), __( 'Reports', 'code-snippets' ) );
+
+		$reports = [
+			'total'      => [
+				__( 'Total snippets', 'code-snippets' ),
+				__( 'The number of snippets saved on this site.', 'code-snippets' ),
+			],
+			'type'       => [
+				__( 'Snippet type', 'code-snippets' ),
+				__( 'Snippets broken down by type: functions, content, styles, scripts and conditions.', 'code-snippets' ),
+			],
+			'activation' => [
+				__( 'Activation status', 'code-snippets' ),
+				__( 'How many snippets are active and how many are inactive.', 'code-snippets' ),
+			],
+			'conditions' => [
+				__( 'Condition usage', 'code-snippets' ),
+				__( 'How many snippets only run when a condition is met.', 'code-snippets' ),
+			],
+			'location'   => [
+				__( 'Location', 'code-snippets' ),
+				__( 'Where snippets run: everywhere, the administration area, the site front-end or a part of the page.', 'code-snippets' ),
+			],
+			'tags'       => [
+				__( 'Tags', 'code-snippets' ),
+				__( 'The tags used across snippets, and how often each one appears.', 'code-snippets' ),
+			],
+		];
+
+		$entries = [];
+
+		foreach ( $reports as $report_id => $report ) {
+			$entries[] = [
+				'id'          => "report-$report_id",
+				'type'        => 'stat',
+				'title'       => $report[0],
+				'description' => $report[1],
+				'url'         => $stats_url . '#' . self::STATS_ANCHOR_PREFIX . $report_id,
+				'path'        => $path,
+			];
+		}
+
+		return $entries;
+	}
+
+	/**
+	 * Flatten the changes of a release into a single line of text.
+	 *
+	 * @param array<string, mixed> $sections Changes keyed by section, then by plugin edition.
+	 *
+	 * @return string
+	 */
+	private static function flatten_changelog_entries( array $sections ): string {
+		$changes = [];
+
+		array_walk_recursive(
+			$sections,
+			function ( $change ) use ( &$changes ) {
+				if ( is_string( $change ) ) {
+					$changes[] = $change;
+				}
+			}
+		);
+
+		return Search_Query::plain_text( implode( ' ', $changes ) );
+	}
+
+	/**
+	 * Retrieve an entry for every section of the welcome screen, along with the
+	 * release notes and articles it lists.
+	 *
+	 * The articles come from data the welcome screen has already cached, and are
+	 * left out rather than fetched when it is missing, so a search never waits on
+	 * a remote request for a local result. Release notes are read from the
+	 * changelog shipped with the plugin when nothing is cached.
+	 *
+	 * @return array<int, array<string, string>>
+	 */
+	public function get_welcome_entries(): array {
+		$welcome_url = code_snippets()->get_menu_url( 'welcome', $this->url_context );
+		$welcome_label = __( 'Welcome', 'code-snippets' );
+		$whats_new_path = self::build_path( $welcome_label, __( "What's new", 'code-snippets' ) );
+		$getting_started_path = self::build_path( $welcome_label, __( 'Getting started', 'code-snippets' ) );
+
+		$entries = [
+			[
+				'id'          => 'latest-changes',
+				'type'        => 'guide',
+				'title'       => __( "What's new in Code Snippets", 'code-snippets' ),
+				'description' => __( 'Latest changes: the new features, improvements and bug fixes in recent releases.', 'code-snippets' ),
+				'url'         => $welcome_url . '#latest-changes',
+				'path'        => $whats_new_path,
+			],
+			[
+				'id'          => 'helpful-articles',
+				'type'        => 'guide',
+				'title'       => __( 'Helpful articles', 'code-snippets' ),
+				'description' => __( 'Guides and tutorials for getting started with snippets.', 'code-snippets' ),
+				'url'         => $welcome_url . '#helpful-articles',
+				'path'        => $getting_started_path,
+			],
+			[
+				'id'          => 'partner-deals',
+				'type'        => 'guide',
+				'title'       => __( 'Exclusive deals from our partners', 'code-snippets' ),
+				'description' => __( 'Offers on other WordPress products from Code Snippets partners.', 'code-snippets' ),
+				'url'         => $welcome_url . '#partner-deals',
+				'path'        => self::build_path( $welcome_label, __( 'Partners', 'code-snippets' ) ),
+			],
+		];
+
+		$cached = Welcome_Client::get_cached_data();
+		$changelog = is_array( $cached['changelog'] ?? null ) ? $cached['changelog'] : Welcome_Client::read_changelog();
+
+		foreach ( $changelog as $release ) {
+			if ( empty( $release['version'] ) || ! is_scalar( $release['version'] ) ) {
+				continue;
+			}
+
+			$entries[] = [
+				'id'          => 'release-' . sanitize_key( (string) $release['version'] ),
+				'type'        => 'guide',
+				// translators: %s: version number.
+				'title'       => sprintf( __( "What's new in version %s", 'code-snippets' ), $release['version'] ),
+				'description' => self::flatten_changelog_entries( is_array( $release['entries'] ?? null ) ? $release['entries'] : [] ),
+				'url'         => $welcome_url . '#latest-changes',
+				'path'        => $whats_new_path,
+			];
+		}
+
+		foreach ( is_array( $cached['features'] ?? null ) ? $cached['features'] : [] as $index => $article ) {
+			if ( empty( $article['title'] ) || ! is_scalar( $article['title'] ) ) {
+				continue;
+			}
+
+			$entries[] = [
+				'id'          => "article-$index",
+				'type'        => 'guide',
+				'title'       => Search_Query::plain_text( (string) $article['title'] ),
+				'description' => Search_Query::plain_text( is_scalar( $article['description'] ?? null ) ? (string) $article['description'] : '' ),
+				'url'         => $welcome_url . '#helpful-articles',
+				'path'        => $getting_started_path,
+			];
+		}
+
+		return $entries;
+	}
+}
--- a/code-snippets/php/Search/Search_Query.php
+++ b/code-snippets/php/Search/Search_Query.php
@@ -0,0 +1,325 @@
+<?php
+
+namespace Code_SnippetsSearch;
+
+/**
+ * A universal search term, and the fields it is matched against.
+ *
+ * The term is split into words, and a result matches when every word appears
+ * somewhere in the fields being searched, in any order and regardless of case.
+ * The browser highlights the same words, so a row is never returned without
+ * something in it to highlight.
+ *
+ * @package Code_Snippets
+ */
+final class Search_Query {
+
+	/**
+	 * Fields a result can be matched in.
+	 */
+	public const FIELDS = [ 'title', 'description', 'code' ];
+
+	/**
+	 * Ways a remote source can be searched: by keyword, or with AI, which matches by meaning.
+	 */
+	public const METHODS = [ 'term', 'ai' ];
+
+	/**
+	 * Shortest term worth searching for.
+	 */
+	public const MIN_LENGTH = 2;
+
+	/**
+	 * Longest term accepted, so a pasted document cannot become a search.
+	 */
+	public const MAX_LENGTH = 100;
+
+	/**
+	 * Largest number of words matched from a term.
+	 */
+	private const MAX_WORDS = 8;
+
+	/**
+	 * Length of a description excerpt, in characters.
+	 */
+	private const EXCERPT_LENGTH = 180;
+
+	/**
+	 * Characters of context kept ahead of a match that would otherwise fall outside the excerpt.
+	 */
+	private const EXCERPT_LEAD = 50;
+
+	/**
+	 * Search term.
+	 *
+	 * @var string
+	 */
+	private string $term;
+
+	/**
+	 * Fields to match the term against.
+	 *
+	 * @var string[]
+	 */
+	private array $fields;
+
+	/**
+	 * Whether long descriptions are shortened to an excerpt around the match.
+	 *
+	 * @var bool
+	 */
+	private bool $excerpts;
+
+	/**
+	 * How remote sources are searched.
+	 *
+	 * @var string
+	 */
+	private string $method;
+
+	/**
+	 * Words of the term, without duplicates.
+	 *
+	 * @var string[]
+	 */
+	private array $words;
+
+	/**
+	 * Regular expression matching any word of the term.
+	 *
+	 * @var string
+	 */
+	private string $pattern;
+
+	/**
+	 * Class constructor.
+	 *
+	 * @param string   $term     Search term.
+	 * @param string[] $fields   Fields to match the term against. Unrecognised fields are ignored.
+	 * @param bool     $excerpts Whether to shorten long descriptions to an excerpt around the match.
+	 * @param string   $method   How remote sources are searched: one of `METHODS`.
+	 */
+	public function __construct( string $term, array $fields = self::FIELDS, bool $excerpts = true, string $method = 'term' ) {
+		$this->term = mb_substr( trim( $term ), 0, self::MAX_LENGTH );
+		$this->fields = array_values( array_intersect( self::FIELDS, $fields ) );
+		$this->excerpts = $excerpts;
+		$this->method = in_array( $method, self::METHODS, true ) ? $method : 'term';
+
+		$words = preg_split( '/s+/u', $this->term, -1, PREG_SPLIT_NO_EMPTY );
+		$this->words = array_slice( array_values( array_unique( is_array( $words ) ? $words : [] ) ), 0, self::MAX_WORDS );
+
+		$quoted = array_map( fn( string $word ) => preg_quote( $word, '/' ), $this->words );
+		$this->pattern = '/' . implode( '|', $quoted ) . '/iu';
+	}
+
+	/**
+	 * Clean a search term received from a request.
+	 *
+	 * The term is only ever compared against text and is escaped wherever it is
+	 * displayed, so markup and code are kept intact: searching for `<?php` or
+	 * `<div class="x">` has to find snippets containing exactly that. Only
+	 * invalid UTF-8 and control characters are removed.
+	 *
+	 * @param mixed $term Raw search term.
+	 *
+	 * @return string
+	 */
+	public static function sanitize_term( $term ): string {
+		$term = wp_check_invalid_utf8( is_scalar( $term ) ? (string) $term : '', true );
+
+		return trim( (string) preg_replace( '/[x00-x1Fx7F]+/u', ' ', $term ) );
+	}
+
+	/**
+	 * Retrieve the search term.
+	 *
+	 * @return string
+	 */
+	public function get_term(): string {
+		return $this->term;
+	}
+
+	/**
+	 * Retrieve the fields the term is matched against.
+	 *
+	 * @return string[]
+	 */
+	public function get_fields(): array {
+		return $this->fields;
+	}
+
+	/**
+	 * Retrieve how remote sources are searched.
+	 *
+	 * @return string
+	 */
+	public function get_method(): string {
+		return $this->method;
+	}
+
+	/**
+	 * Determine whether remote sources are searched with AI.
+	 *
+	 * @return bool
+	 */
+	public function is_ai(): bool {
+		return 'ai' === $this->method;
+	}
+
+	/**
+	 * Determine whether the term is long enough to search for.
+	 *
+	 * @return bool
+	 */
+	public function is_searchable(): bool {
+		return mb_strlen( $this->term ) >= self::MIN_LENGTH && $this->words && $this->fields;
+	}
+
+	/**
+	 * Determine whether a piece of text contains a word.
+	 *
+	 * @param string $text Text to look in.
+	 * @param string $word Word to look for.
+	 *
+	 * @return bool
+	 */
+	private static function contains( string $text, string $word ): bool {
+		$result = preg_match( '/' . preg_quote( $word, '/' ) . '/iu', $text );
+
+		// The pattern fails outright on text that is not valid UTF-8.
+		return false === $result ? false !== stripos( $text, $word ) : 1 === $result;
+	}
+
+	/**
+	 * Determine which of the searched fields a result matches in.
+	 *
+	 * @param array<string, string> $values Text of each field, keyed by field name.
+	 *
+	 * @return string[] Names of the fields containing a word of the term, in the order of `FIELDS`.
+	 *                  Empty unless every word was found in one of the searched fields.
+	 */
+	public function matched_fields( array $values ): array {
+		$searched = array_intersect_key( $values, array_flip( $this->fields ) );
+		$matched = [];
+
+		foreach ( $this->words as $word ) {
+			$found = array_filter( $searched, fn( string $text ) => '' !== $text && self::contains( $text, $word ) );
+
+			if ( ! $found ) {
+				return [];
+			}
+
+			$matched += $found;
+		}
+
+		return array_values( array_intersect( $this->fields, array_keys( $matched ) ) );
+	}
+
+	/**
+	 * Count the distinct words of the term found in a piece of text.
+	 *
+	 * @param string $text Text to look in.
+	 *
+	 * @return int
+	 */
+	private function count_words_in( string $text ): int {
+		return count( array_filter( $this->words, fn( string $word ) => self::contains( $text, $word ) ) );
+	}
+
+	/**
+	 * Reduce markup to a single line of plain text.
+	 *
+	 * @param string $text Text, possibly containing markup.
+	 *
+	 * @return string
+	 */
+	public static function plain_text( string $text ): string {
+		$text = html_entity_decode( wp_strip_all_tags( $text ), ENT_QUOTES | ENT_HTML5, 'UTF-8' );
+		return trim( (string) preg_replace( '/s+/u', ' ', $text ) );
+	}
+
+	/**
+	 * Shorten plain text for display, keeping the first match in view.
+	 *
+	 * Text is returned whole when excerpts are turned off.
+	 *
+	 * @param string $text Plain text.
+	 *
+	 * @return string
+	 */
+	public function excerpt( string $text ): string {
+		return $this->excerpts ? $this->shorten( $text ) : wp_check_invalid_utf8( $text, true );
+	}
+
+	/**
+	 * Shorten text to a single excerpt length, keeping the first match in view.
+	 *
+	 * @param string $text Plain text.
+	 *
+	 * @return string
+	 */
+	private function shorten( string $text ): string {
+		// Invalid UTF-8 would make the match unfindable and the excerpt start at the beginning.
+		$text = wp_check_invalid_utf8( $text, true );
+
+		if ( mb_strlen( $text ) <= self::EXCERPT_LENGTH ) {
+			return $text;
+		}
+
+		$parts = $this->words ? preg_split( $this->pattern, $text, 2 ) : false;
+		$match_offset = is_array( $parts ) && 2 === count( $parts ) ? mb_strlen( $parts[0] ) : 0;
+
+		if ( $match_offset + self::EXCERPT_LEAD <= self::EXCERPT_LENGTH ) {
+			return rtrim( mb_substr( $text, 0, self::EXCERPT_LENGTH ) ) . '…';
+		}
+
+		$start = max( 0, $match_offset - self::EXCERPT_LEAD );
+		$excerpt = trim( mb_substr( $text, $start, self::EXCERPT_LENGTH ) );
+
+		return '…' . $excerpt . ( $start + self::EXCERPT_LENGTH < mb_strlen( $text ) ? '…' : '' );
+	}
+
+	/**
+	 * Shorten a line shown around a match, where it only gives a sense of th

ModSecurity Protection Against This CVE

Here you will find our ModSecurity compatible rule to protect against this particular CVE.

ModSecurity
SecRule REQUEST_URI "@rx ^/wp-json/code-snippets/v1/import/(file|plugins)" "id:2026106468,phase:2,deny,status:403,chain,msg:'CVE-2026-106468 via Code Snippets REST API import',severity:'CRITICAL',tag:'CVE-2026-106468'"
  SecRule ARGS:network "@streq true" "chain"
    SecRule REQUEST_METHOD "@streq POST" "t:none"

Frequently Asked Questions

Atomic Edge WAF security layer inspecting website traffic.

How Atomic Edge Works

Simple Setup. Powerful Security.

Atomic Edge acts as a security layer between your website & the internet. Our AI inspection and analysis engine auto blocks threats before traditional firewall services can inspect, research and build archaic regex filters.

Get Started

Trusted by Developers & Organizations

Trusted by Developers
Black & McDonald logo representing Enterprise tier security and support for Atomic Edge WAF.Covenant House Toronto logo featuring a dove and text for Atomic Edge Enterprise planAlzheimer Society Canada logo representing trusted organizations and security partners.University of Toronto logo representing trusted organizations using Atomic Edge WAFSpecsavvers logo, trusted developers and organizations using Atomic Edge securityHarvard Medical School logo representing trusted organizations using Atomic Edge WAF.