From 02c5599e1b130ad7a4d5eb8fb0a38dc5cdb6b0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Thu, 12 Nov 2026 20:09:02 +0200 Subject: [PATCH 1/5] feat: opt into the Themeisle SDK Support Hub --- composer.json | 2 +- composer.lock | 4 +- otter-blocks.php | 39 +++++++ readme.md | 2 +- readme.txt | 2 +- src/blocks/test/e2e/blocks/dashboard.spec.js | 17 +++ src/dashboard/components/Sidebar.js | 14 ++- tests/test-support-hub.php | 111 +++++++++++++++++++ 8 files changed, 182 insertions(+), 9 deletions(-) create mode 100644 tests/test-support-hub.php diff --git a/composer.json b/composer.json index a06437e3c..e2bfee152 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ }, "minimum-stability": "dev", "require": { - "codeinwp/themeisle-sdk": "^3.3.65", + "codeinwp/themeisle-sdk": "^3.3.70", "tubalmartin/cssmin": "^4.1", "wptt/webfont-loader": "^1.1", "sabberworm/php-css-parser": "^8.4", diff --git a/composer.lock b/composer.lock index 0a27b7e3a..67a965ca1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c01ca8d521c97d9b29fb7fce95c0002f", + "content-hash": "f7d4a66bc361fcc3052821cc86d88804", "packages": [ { "name": "codeinwp/themeisle-sdk", @@ -3143,5 +3143,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.9.0" + "plugin-api-version": "2.11.0" } diff --git a/otter-blocks.php b/otter-blocks.php index 71cb2b081..68c4958a9 100644 --- a/otter-blocks.php +++ b/otter-blocks.php @@ -90,6 +90,45 @@ function () { } ); +/* + * Opts into the SDK Support Hub: one Help button on Otter's screens and the + * deactivation window. The dashboard and Form Submissions screens already fire + * `themeisle_internal_page`, so no `pages` list is needed. + */ +add_filter( + 'otter_blocks_support_hub_metadata', + function () { + return array( + 'is_pro' => \ThemeIsle\GutenbergBlocks\Pro::is_pro_active(), + 'links' => array( + array( + 'icon' => 'book-alt', + 'text' => __( 'Documentation', 'otter-blocks' ), + 'url' => \ThemeIsle\GutenbergBlocks\Pro::get_docs_url(), + ), + array( + 'icon' => 'groups', + 'text' => __( 'Community Forum', 'otter-blocks' ), + 'url' => 'https://wordpress.org/support/plugin/otter-blocks/', + ), + ), + ); + } +); + +/* + * Otter also fires `themeisle_internal_page` in the block editor, which would put + * the Help button on every post, site and widget editor. Keep it to Otter's screens. + */ +add_filter( + 'otter_blocks_hide_support_hub', + function ( $hide ) { + global $pagenow; + + return $hide || in_array( $pagenow, array( 'post.php', 'post-new.php', 'site-editor.php', 'widgets.php' ), true ); + } +); + add_filter( 'themeisle_sdk_compatibilities/' . basename( OTTER_BLOCKS_PATH ), function ( $compatibilities ) { diff --git a/readme.md b/readme.md index a5832f3c9..89d85c1dc 100644 --- a/readme.md +++ b/readme.md @@ -330,7 +330,7 @@ Sure, Otter is compatible with any WordPress theme. ### Where can I get help? ### -If you encounter any difficulties or if you have questions about Otter, you can create a ticket on our [support forum](https://wordpress.org/support/plugin/otter-blocks/). Also, feel free to check our [documentation](https://docs.themeisle.com/article/1478-otter-blocks-documentation) to find out more about the features within the plugin and how to use it to its full potential. +If you encounter any difficulties or if you have questions about Otter, you can ask our support team from the **Help** button on the Otter dashboard, or create a ticket on our [support forum](https://wordpress.org/support/plugin/otter-blocks/). Also, feel free to check our [documentation](https://docs.themeisle.com/article/1478-otter-blocks-documentation) to find out more about the features within the plugin and how to use it to its full potential. ### What are the Patterns and how can I use them? ### diff --git a/readme.txt b/readme.txt index c8d29109e..b6775c199 100644 --- a/readme.txt +++ b/readme.txt @@ -330,7 +330,7 @@ Sure, Otter is compatible with any WordPress theme. = Where can I get help? = -If you encounter any difficulties or if you have questions about Otter, you can create a ticket on our [support forum](https://wordpress.org/support/plugin/otter-blocks/). Also, feel free to check our [documentation](https://docs.themeisle.com/article/1478-otter-blocks-documentation) to find out more about the features within the plugin and how to use it to its full potential. +If you encounter any difficulties or if you have questions about Otter, you can ask our support team from the **Help** button on the Otter dashboard, or create a ticket on our [support forum](https://wordpress.org/support/plugin/otter-blocks/). Also, feel free to check our [documentation](https://docs.themeisle.com/article/1478-otter-blocks-documentation) to find out more about the features within the plugin and how to use it to its full potential. = What are the Patterns and how can I use them? = diff --git a/src/blocks/test/e2e/blocks/dashboard.spec.js b/src/blocks/test/e2e/blocks/dashboard.spec.js index e10d35b24..b106609b3 100644 --- a/src/blocks/test/e2e/blocks/dashboard.spec.js +++ b/src/blocks/test/e2e/blocks/dashboard.spec.js @@ -170,4 +170,21 @@ test.describe( 'Dashboard', () => { await countdownCard.getByRole( 'checkbox' ).click(); await expect( countdownCard.getByRole( 'checkbox' ) ).toBeChecked(); }); + + test( 'free sidebar opens the Help panel and keeps the community forum', async({ page }) => { + const contact = page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Contact Support' }); + + await expect( contact ).toHaveAttribute( 'data-ti-support', 'dashboard' ); + await expect( page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Community Forum' }) ).toHaveAttribute( 'href', 'https://wordpress.org/support/plugin/otter-blocks/' ); + + await contact.click(); + + await expect( page.locator( '.ti-support-panel' ) ).toBeVisible(); + }); + + test( 'block editor shows no Help launcher', async({ admin, page }) => { + await admin.createNewPost(); + + await expect( page.locator( '.ti-support-launcher' ) ).toHaveCount( 0 ); + }); }); diff --git a/src/dashboard/components/Sidebar.js b/src/dashboard/components/Sidebar.js index 2c94f7f5e..482317428 100644 --- a/src/dashboard/components/Sidebar.js +++ b/src/dashboard/components/Sidebar.js @@ -76,9 +76,7 @@ const Sidebar = ({ setTab }) => { const isProLicenseActive = Boolean( window.otterObj.hasPro ) && 'valid' === window.otterObj?.license?.valid; - - const supportLink = isProLicenseActive ? 'https://store.themeisle.com/' : 'https://wordpress.org/support/plugin/otter-blocks'; - const supportLabel = isProLicenseActive ? __( 'Contact Pro Support', 'otter-blocks' ) : __( 'Support', 'otter-blocks' ); + const forumLink = 'https://wordpress.org/support/plugin/otter-blocks/'; return ( @@ -122,7 +120,15 @@ const Sidebar = ({ title={ __( 'Useful links', 'otter-blocks' ) } > diff --git a/tests/test-support-hub.php b/tests/test-support-hub.php new file mode 100644 index 000000000..4a8689fc0 --- /dev/null +++ b/tests/test-support-hub.php @@ -0,0 +1,111 @@ +assertIsArray( $data ); + $this->assertSame( array( 'is_pro', 'links' ), array_keys( $data ) ); + } + + /** + * The footer links point to Otter's docs and wordpress.org forum. + */ + public function test_links_point_to_otter() { + $links = apply_filters( 'otter_blocks_support_hub_metadata', array() )['links']; + + $this->assertSame( + array( + 'https://docs.themeisle.com/otter-page-builder-blocks-extensions/otter-blocks-documentation', + 'https://wordpress.org/support/plugin/otter-blocks/', + ), + wp_list_pluck( $links, 'url' ) + ); + foreach ( $links as $link ) { + $this->assertNotEmpty( $link['icon'] ); + $this->assertNotEmpty( $link['text'] ); + } + } + + /** + * Messages are tagged as Pro only while the Pro license is valid. + */ + public function test_is_pro_needs_a_valid_license() { + add_filter( 'product_otter_license_status', array( $this, 'expired_license' ) ); + $this->assertFalse( apply_filters( 'otter_blocks_support_hub_metadata', array() )['is_pro'] ); + remove_filter( 'product_otter_license_status', array( $this, 'expired_license' ) ); + + add_filter( 'product_otter_license_status', array( $this, 'valid_license' ) ); + $this->assertSame( Pro::is_pro_installed(), apply_filters( 'otter_blocks_support_hub_metadata', array() )['is_pro'] ); + remove_filter( 'product_otter_license_status', array( $this, 'valid_license' ) ); + } + + /** + * The Help button stays off the block editors, which also count as Otter screens. + * + * @dataProvider editor_screens + * + * @param string $pagenow Admin page file. + */ + public function test_hub_is_hidden_in_block_editors( $pagenow ) { + $GLOBALS['pagenow'] = $pagenow; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + + $this->assertTrue( apply_filters( 'otter_blocks_hide_support_hub', false ) ); + } + + /** + * Block editor admin pages. + * + * @return array> + */ + public function editor_screens() { + return array( + 'post editor' => array( 'post.php' ), + 'new post' => array( 'post-new.php' ), + 'site editor' => array( 'site-editor.php' ), + 'widget editor' => array( 'widgets.php' ), + ); + } + + /** + * The Help button shows on Otter's own screens, and a site can still hide it. + */ + public function test_hub_is_shown_on_otter_screens() { + $GLOBALS['pagenow'] = 'admin.php'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + + $this->assertFalse( apply_filters( 'otter_blocks_hide_support_hub', false ) ); + $this->assertTrue( apply_filters( 'otter_blocks_hide_support_hub', true ) ); + } + + /** + * A license status the SDK reports for an expired key. + * + * @return string + */ + public function expired_license() { + return 'expired'; + } + + /** + * A license status the SDK reports for a valid key. + * + * @return string + */ + public function valid_license() { + return 'valid'; + } +} From bb4cc90a1cad7dbb1e720167caa655a69d9fc2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Thu, 12 Nov 2026 20:16:15 +0200 Subject: [PATCH 2/5] fix: read the stored Pro license for the Support Hub Pro flag --- otter-blocks.php | 4 +++- tests/test-support-hub.php | 47 ++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/otter-blocks.php b/otter-blocks.php index 68c4958a9..e2f405d18 100644 --- a/otter-blocks.php +++ b/otter-blocks.php @@ -99,7 +99,9 @@ function () { 'otter_blocks_support_hub_metadata', function () { return array( - 'is_pro' => \ThemeIsle\GutenbergBlocks\Pro::is_pro_active(), + // The SDK reads this while loading Otter, before Otter Pro's Licenser adds the + // product_otter_license_status filter, so read the stored license directly. + 'is_pro' => defined( 'OTTER_PRO_BASEFILE' ) && class_exists( '\ThemeisleSDK\Modules\Licenser' ) && \ThemeisleSDK\Modules\Licenser::is_valid( OTTER_PRO_BASEFILE ), 'links' => array( array( 'icon' => 'book-alt', diff --git a/tests/test-support-hub.php b/tests/test-support-hub.php index 4a8689fc0..f06966a67 100644 --- a/tests/test-support-hub.php +++ b/tests/test-support-hub.php @@ -5,8 +5,6 @@ * @package gutenberg-blocks */ -use ThemeIsle\GutenbergBlocks\Pro; - /** * Support Hub opt-in tests. */ @@ -42,16 +40,29 @@ public function test_links_point_to_otter() { } /** - * Messages are tagged as Pro only while the Pro license is valid. + * Messages are tagged as Pro only while the stored Pro license is valid, whatever + * the order in which the SDK loads Otter and Otter Pro. + * + * @runInSeparateProcess + * @preserveGlobalState disabled */ - public function test_is_pro_needs_a_valid_license() { - add_filter( 'product_otter_license_status', array( $this, 'expired_license' ) ); + public function test_is_pro_reads_the_stored_pro_license() { + if ( ! defined( 'OTTER_PRO_BASEFILE' ) ) { + define( 'OTTER_PRO_BASEFILE', dirname( __DIR__ ) . '/plugins/otter-pro/otter-pro.php' ); + } + // The test bootstrap loads Composer before WordPress, so the SDK's load.php skips itself. + $sdk = dirname( __DIR__ ) . '/vendor/codeinwp/themeisle-sdk/src/'; + foreach ( array( 'Loader.php', 'Product.php', 'Common/Abstract_module.php', 'Modules/Licenser.php' ) as $file ) { + require_once $sdk . $file; + } + // No Licenser filter is registered, as when Otter loads before Otter Pro. + remove_all_filters( 'product_otter_license_status' ); + + update_option( 'otter_pro_license_data', (object) array( 'license' => 'expired' ) ); $this->assertFalse( apply_filters( 'otter_blocks_support_hub_metadata', array() )['is_pro'] ); - remove_filter( 'product_otter_license_status', array( $this, 'expired_license' ) ); - add_filter( 'product_otter_license_status', array( $this, 'valid_license' ) ); - $this->assertSame( Pro::is_pro_installed(), apply_filters( 'otter_blocks_support_hub_metadata', array() )['is_pro'] ); - remove_filter( 'product_otter_license_status', array( $this, 'valid_license' ) ); + update_option( 'otter_pro_license_data', (object) array( 'license' => 'valid' ) ); + $this->assertTrue( apply_filters( 'otter_blocks_support_hub_metadata', array() )['is_pro'] ); } /** @@ -90,22 +101,4 @@ public function test_hub_is_shown_on_otter_screens() { $this->assertFalse( apply_filters( 'otter_blocks_hide_support_hub', false ) ); $this->assertTrue( apply_filters( 'otter_blocks_hide_support_hub', true ) ); } - - /** - * A license status the SDK reports for an expired key. - * - * @return string - */ - public function expired_license() { - return 'expired'; - } - - /** - * A license status the SDK reports for a valid key. - * - * @return string - */ - public function valid_license() { - return 'valid'; - } } From 2fc146fe2e382e63401c5c0e2460ac85fba25770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Thu, 12 Nov 2026 20:33:24 +0200 Subject: [PATCH 3/5] test: run the Support Hub license test in the main process --- tests/test-support-hub.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test-support-hub.php b/tests/test-support-hub.php index f06966a67..c9fa03c88 100644 --- a/tests/test-support-hub.php +++ b/tests/test-support-hub.php @@ -42,9 +42,6 @@ public function test_links_point_to_otter() { /** * Messages are tagged as Pro only while the stored Pro license is valid, whatever * the order in which the SDK loads Otter and Otter Pro. - * - * @runInSeparateProcess - * @preserveGlobalState disabled */ public function test_is_pro_reads_the_stored_pro_license() { if ( ! defined( 'OTTER_PRO_BASEFILE' ) ) { From 5739406f4d0e01a35602900726f425616888997c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Thu, 12 Nov 2026 21:01:04 +0200 Subject: [PATCH 4/5] test: switch off the stubbed Pro license for the free sidebar case --- src/blocks/test/e2e/blocks/dashboard.spec.js | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/blocks/test/e2e/blocks/dashboard.spec.js b/src/blocks/test/e2e/blocks/dashboard.spec.js index b106609b3..1efecc109 100644 --- a/src/blocks/test/e2e/blocks/dashboard.spec.js +++ b/src/blocks/test/e2e/blocks/dashboard.spec.js @@ -171,15 +171,29 @@ test.describe( 'Dashboard', () => { await expect( countdownCard.getByRole( 'checkbox' ) ).toBeChecked(); }); - test( 'free sidebar opens the Help panel and keeps the community forum', async({ page }) => { - const contact = page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Contact Support' }); + test( 'free sidebar opens the Help panel and keeps the community forum', async({ admin, otterUtils, page }) => { + // Global setup stubs a valid Pro license, which shows Contact Pro Support instead. + await otterUtils.deactivatePro(); - await expect( contact ).toHaveAttribute( 'data-ti-support', 'dashboard' ); - await expect( page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Community Forum' }) ).toHaveAttribute( 'href', 'https://wordpress.org/support/plugin/otter-blocks/' ); + try { + await admin.visitAdminPage( 'admin.php?page=otter' ); + + const contact = page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Contact Support' }); + + await expect( contact ).toHaveAttribute( 'data-ti-support', 'dashboard' ); + await expect( page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Community Forum' }) ).toHaveAttribute( 'href', 'https://wordpress.org/support/plugin/otter-blocks/' ); + + await contact.click(); - await contact.click(); + await expect( page.locator( '.ti-support-panel' ) ).toBeVisible(); + } finally { + await otterUtils.activatePro(); + } + }); - await expect( page.locator( '.ti-support-panel' ) ).toBeVisible(); + test( 'licensed Pro sidebar keeps Contact Pro Support', async({ page }) => { + await expect( page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Contact Pro Support' }) ).toHaveAttribute( 'href', 'https://store.themeisle.com/' ); + await expect( page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Contact Support' }) ).toHaveCount( 0 ); }); test( 'block editor shows no Help launcher', async({ admin, page }) => { From a60d51ac7e9fe3746fa9373254955e6a78b7a7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Fri, 13 Nov 2026 09:49:44 +0200 Subject: [PATCH 5/5] test: make the Support Hub visibility checks fail without the change --- src/blocks/test/e2e/blocks/dashboard.spec.js | 7 ++-- tests/test-support-hub.php | 35 ++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/blocks/test/e2e/blocks/dashboard.spec.js b/src/blocks/test/e2e/blocks/dashboard.spec.js index 1efecc109..b62d72f18 100644 --- a/src/blocks/test/e2e/blocks/dashboard.spec.js +++ b/src/blocks/test/e2e/blocks/dashboard.spec.js @@ -196,9 +196,12 @@ test.describe( 'Dashboard', () => { await expect( page.locator( '.otter-info-links' ).getByRole( 'link', { name: 'Contact Support' }) ).toHaveCount( 0 ); }); - test( 'block editor shows no Help launcher', async({ admin, page }) => { + test( 'Help launcher shows on the dashboard but not in the block editor', async({ admin, page }) => { + await expect( page.locator( '.ti-support-launcher' ) ).toBeVisible(); + await admin.createNewPost(); - await expect( page.locator( '.ti-support-launcher' ) ).toHaveCount( 0 ); + // The SDK prints this container in admin_footer whenever the hub loads. + await expect( page.locator( '#ti-support-hub' ) ).toHaveCount( 0 ); }); }); diff --git a/tests/test-support-hub.php b/tests/test-support-hub.php index c9fa03c88..65159c621 100644 --- a/tests/test-support-hub.php +++ b/tests/test-support-hub.php @@ -63,39 +63,32 @@ public function test_is_pro_reads_the_stored_pro_license() { } /** - * The Help button stays off the block editors, which also count as Otter screens. + * The Help button stays off the block editors, which also count as Otter screens, and shows on Otter's own screens. * - * @dataProvider editor_screens + * @dataProvider admin_screens * * @param string $pagenow Admin page file. + * @param bool $hidden Whether the Help button is hidden there. */ - public function test_hub_is_hidden_in_block_editors( $pagenow ) { + public function test_hub_is_hidden_only_in_block_editors( $pagenow, $hidden ) { $GLOBALS['pagenow'] = $pagenow; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited - $this->assertTrue( apply_filters( 'otter_blocks_hide_support_hub', false ) ); + $this->assertSame( $hidden, apply_filters( 'otter_blocks_hide_support_hub', false ) ); } /** - * Block editor admin pages. + * Admin pages and whether the Help button is hidden on them. * - * @return array> + * @return array */ - public function editor_screens() { + public function admin_screens() { return array( - 'post editor' => array( 'post.php' ), - 'new post' => array( 'post-new.php' ), - 'site editor' => array( 'site-editor.php' ), - 'widget editor' => array( 'widgets.php' ), + 'post editor' => array( 'post.php', true ), + 'new post' => array( 'post-new.php', true ), + 'site editor' => array( 'site-editor.php', true ), + 'widget editor' => array( 'widgets.php', true ), + 'Otter screen' => array( 'admin.php', false ), + 'post list' => array( 'edit.php', false ), ); } - - /** - * The Help button shows on Otter's own screens, and a site can still hide it. - */ - public function test_hub_is_shown_on_otter_screens() { - $GLOBALS['pagenow'] = 'admin.php'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited - - $this->assertFalse( apply_filters( 'otter_blocks_hide_support_hub', false ) ); - $this->assertTrue( apply_filters( 'otter_blocks_hide_support_hub', true ) ); - } }