Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"core": "WordPress/WordPress#6.8.2",
"phpVersion": "8.2",
"testsEnvironment": false,
"mappings": {
"wp-content/plugins/slick-engagement": "./svn/trunk"
}
}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
3 changes: 3 additions & 0 deletions svn/trunk/ActionsFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function getOptionMetaData(): array
'SlickServerUrl' => [
(string)__('Service URL (optional)', $domain)
],
'BundleUrl' => [
(string)__('Bundle URL', $domain)
],
];

if (function_exists('genesis')) {
Expand Down
17 changes: 16 additions & 1 deletion svn/trunk/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 '<script id="slick-bundle-url-script" class="' . esc_attr($this->scriptClass) .
'" src="' . esc_url($bundleUrl) . '"></script>' . "\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);
Expand All @@ -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();
Expand Down