diff --git a/.wp-env.json b/.wp-env.json new file mode 100644 index 0000000..43d0371 --- /dev/null +++ b/.wp-env.json @@ -0,0 +1,8 @@ +{ + "core": "WordPress/WordPress#6.8.2", + "phpVersion": "8.2", + "testsEnvironment": false, + "mappings": { + "wp-content/plugins/slick-engagement": "./svn/trunk" + } +} diff --git a/README.md b/README.md index 3430871..fd9f197 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,23 @@ Slickstream WordPress Plugin The `slick-engagement` folder within this project is the root folder for a WordPress plugin that is used to integrate Slickstream's engagement widgets. To create the plugin, zip the `slick-engagement` folder into `slick-engagement.zip`. This ZIP can then be uploaded to WordPress. + +## Local development + +Run with [`wp-env`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/): + +```sh +source ~/.zshrc && npx @wordpress/env start +source ~/.zshrc && npx @wordpress/env run cli wp plugin activate slick-engagement +source ~/.zshrc && npx @wordpress/env run cli wp theme activate twentytwentyone +``` + +Open `http://localhost:8888/wp-admin` and log in with `admin` / `password`. + +Plugin settings: `http://localhost:8888/wp-admin/options-general.php?page=SlickstreamSettings` + +Stop locally: + +```sh +source ~/.zshrc && npx @wordpress/env stop +``` diff --git a/svn/trunk/ActionsFilters.php b/svn/trunk/ActionsFilters.php index 1519128..a8fe37e 100644 --- a/svn/trunk/ActionsFilters.php +++ b/svn/trunk/ActionsFilters.php @@ -42,6 +42,9 @@ public function getOptionMetaData(): array 'SlickServerUrl' => [ (string)__('Service URL (optional)', $domain) ], + 'BundleUrl' => [ + (string)__('Bundle URL', $domain) + ], ]; if (function_exists('genesis')) { diff --git a/svn/trunk/Plugin.php b/svn/trunk/Plugin.php index 3756359..e894ca2 100644 --- a/svn/trunk/Plugin.php +++ b/svn/trunk/Plugin.php @@ -7,7 +7,7 @@ // NOTE: All inline JS scripts embedded by the plugin need to have the string `slickstream` somewhere in them; // This allows the string `slickstream` to be used in WP-Rocket lazy load exclusions; ideally $scriptClass is added to each script -require_once 'Widgets.php'; +require_once __DIR__ . '/Widgets.php'; require_once 'OptionsManager.php'; require_once 'PageBootData.php'; require_once 'Utils.php'; @@ -388,6 +388,20 @@ public function echoEmbedCode(): void return; } + private function echoBundleUrlScript(): void + { + $bundleUrl = trim($this->getOption('BundleUrl', '')); + + if ($bundleUrl === '') { + return; + } + + $this->utils->echoComment("Bundle URL", false, false, true); + echo '' . "\n"; + $this->utils->echoComment("END Bundle URL", false, false, true); + } + private function echoVersionMetaTag(): void { $this->utils->echoComment("Slickstream WordPress Plugin Version: " . self::PLUGIN_VERSION, true, true, false); @@ -413,6 +427,7 @@ public function addSlickPageHeader(): void $pageBootData = new PageBootData($this->serverUrlBase, $this->siteCode, $this->scriptClass); $pageBootData->handlePageBootData(); $this->echoEmbedCode(); + $this->echoBundleUrlScript(); // TODO: fetch, transient cache, and echo the contents of `boot-loader.js` $this->echoPageMetadata($post); $this->outputDebugInfo();