From 6e8ff8f384a7dcb1c8095477c54fb5870871649c Mon Sep 17 00:00:00 2001 From: Kiro Agent <244629292+kiro-agent@users.noreply.github.com> Date: Sat, 23 May 2026 16:07:29 +0000 Subject: [PATCH] feat: use jsDelivr CDN as default CSS source for Bricks integration Co-authored-by: Jack Granatowski --- integrations/bricks/README.md | 25 ++++++++----------------- integrations/bricks/slashed-bricks.php | 22 +++++++--------------- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/integrations/bricks/README.md b/integrations/bricks/README.md index 8b7f3caf..648c200f 100644 --- a/integrations/bricks/README.md +++ b/integrations/bricks/README.md @@ -26,23 +26,12 @@ Copy the `integrations/bricks/` folder to your WordPress plugins directory: cp -r integrations/bricks /path/to/wp-content/plugins/slashed-bricks ``` -When using this method, the plugin cannot automatically locate the SLASHED CSS bundle. -You have two options: +The plugin loads CSS from jsDelivr by default, so no local file setup is needed. +Optionally, you can copy the `dist/` folder into the plugin directory for local/offline use: -1. **Copy the `dist/` folder** into the plugin directory so the bundle is available at - `wp-content/plugins/slashed-bricks/dist/slashed.optimal.css`: - - ```bash - cp -r dist /path/to/wp-content/plugins/slashed-bricks/dist - ``` - -2. **Use the filter** to point to a CDN or another location: - - ```php - add_filter( 'slashed_bricks/css_bundle_url', function() { - return 'https://cdn.example.com/slashed/slashed.optimal.css'; - } ); - ``` +```bash +cp -r dist /path/to/wp-content/plugins/slashed-bricks/dist +``` ### Option B: Symlink (for development) @@ -148,7 +137,9 @@ integrations/bricks/ ## CSS Bundle -By default, the plugin loads `dist/slashed.optimal.css` from the SLASHED framework directory (resolved relative to the plugin location). This is the recommended bundle that includes core tokens, layout primitives, states, and optional palette tokens. +By default, the plugin loads `dist/slashed.optimal.css` from the jsDelivr CDN (`https://cdn.jsdelivr.net/gh/codeslash-dev/SLASHED@main/dist/slashed.optimal.css`). This means the plugin works out of the box without copying any CSS files locally. + +If a local copy of the bundle is detected (symlink/in-repo mode or a `dist/` folder inside the plugin directory), the local file takes precedence for faster loads and offline development. To load a different bundle (e.g., the minimal `dist/slashed.essential.css` or the full `dist/slashed.full.css`), use the `slashed_bricks/css_bundle_url` filter. diff --git a/integrations/bricks/slashed-bricks.php b/integrations/bricks/slashed-bricks.php index 4ca465d0..c08cdd9a 100644 --- a/integrations/bricks/slashed-bricks.php +++ b/integrations/bricks/slashed-bricks.php @@ -26,19 +26,20 @@ /** * Get the URL for the SLASHED CSS bundle. * - * Resolves the path to dist/slashed.optimal.css by checking: - * 1. Symlink/in-repo mode: ../../dist/slashed.optimal.css relative to the plugin - * 2. Copy-install mode: dist/slashed.optimal.css within the plugin directory + * Defaults to the jsDelivr CDN (main branch latest) so the plugin works + * without any local file setup. If a local copy is detected (symlink/in-repo + * mode or copy-install mode), the local file takes precedence for faster loads + * and offline development. * - * Falls back to an empty string (with a PHP notice) if neither location exists. * Use the 'slashed_bricks/css_bundle_url' filter to override. * * @return string URL to the CSS bundle. */ function slashed_bricks_get_css_url() { - $default_url = ''; + // Default: jsDelivr CDN pointing to main branch latest. + $default_url = 'https://cdn.jsdelivr.net/gh/codeslash-dev/SLASHED@main/dist/slashed.optimal.css'; - // Check symlink/in-repo mode first (../../dist/ relative to plugin). + // Prefer local file if available (symlink/in-repo mode). $repo_path = SLASHED_BRICKS_PATH . '../../dist/slashed.optimal.css'; if ( file_exists( $repo_path ) ) { $default_url = SLASHED_BRICKS_URL . '../../dist/slashed.optimal.css'; @@ -47,15 +48,6 @@ function slashed_bricks_get_css_url() { elseif ( file_exists( SLASHED_BRICKS_PATH . 'dist/slashed.optimal.css' ) ) { $default_url = SLASHED_BRICKS_URL . 'dist/slashed.optimal.css'; } - // Neither location found. - else { - trigger_error( - 'SLASHED for Bricks: Could not locate slashed.optimal.css. ' - . 'Copy the dist/ folder into the plugin directory, or use the ' - . "'slashed_bricks/css_bundle_url' filter to specify the URL.", - E_USER_NOTICE - ); - } /** * Filter the SLASHED CSS bundle URL.