From 995c9e0069b08e30df0f37eb9d0adc105c55a6f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 20:02:10 +0200 Subject: [PATCH 01/20] chore(deps): bump codeinwp/themeisle-sdk from 3.3.67 to 3.3.68 (#1399) Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.67 to 3.3.68. - [Release notes](https://github.com/Codeinwp/themeisle-sdk/releases) - [Commits](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.67...v3.3.68) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-version: 3.3.68 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 47f7fb9d..cef0e73e 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.67", + "version": "3.3.68", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "e1dda44811660a65c3da6994349c054a46686d69" + "reference": "8477d5100ffdddd316a3e51129d775d8854d8a77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/e1dda44811660a65c3da6994349c054a46686d69", - "reference": "e1dda44811660a65c3da6994349c054a46686d69", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/8477d5100ffdddd316a3e51129d775d8854d8a77", + "reference": "8477d5100ffdddd316a3e51129d775d8854d8a77", "shasum": "" }, "require-dev": { @@ -43,9 +43,9 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.67" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.68" }, - "time": "2026-10-13T12:16:34+00:00" + "time": "2026-10-27T13:38:50+00:00" }, { "name": "neitanod/forceutf8", From 2ec5b492f85c1f1271f44e28f1eb960786daa4eb Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 2 Nov 2026 21:41:06 +0530 Subject: [PATCH 02/20] feat: opt into the ThemeIsle SDK Support Hub Registers the visualizer_support_hub_metadata filter so the SDK shows one Help button on the Chart Library, Settings and Support screens, a setup nudge while the site has no chart, and the new deactivation window on the Plugins screen. The Settings screen now fires themeisle_internal_page like the other two screens. Visualizer Pro registers nothing: it has no admin screens of its own, so the free plugin owns the hub and reports is_pro from the Pro license. Co-Authored-By: Claude Fable 5.1 --- classes/Visualizer/Module/Admin.php | 2 + index.php | 55 ++++++++++++ tests/test-support-hub.php | 124 ++++++++++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 tests/test-support-hub.php diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index e7ef36e5..0074a3b0 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -1119,6 +1119,8 @@ public function enqueueSettingsScripts( string $hook_suffix ): void { } wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker' ); + + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'settings' ); } /** diff --git a/index.php b/index.php index b5f21108..3d42a87d 100644 --- a/index.php +++ b/index.php @@ -189,6 +189,7 @@ function () { ); } ); + add_filter( 'visualizer_support_hub_metadata', 'visualizer_support_hub_metadata' ); add_filter( 'visualizer_ai_connect_metadata', function () { @@ -274,6 +275,60 @@ function visualizer_action_scheduler_store_class( $class_name ) { return 'ActionScheduler_DBStore' === $class_name ? 'Visualizer_ActionScheduler_Store' : $class_name; } +/** + * Opts into the SDK Support Hub: one Help button on the plugin's own screens, + * a setup nudge while the site has no chart, and the deactivation window. + * + * Visualizer Pro registers nothing here: it has no admin screens of its own + * and the SDK shows one Help button per screen, so the free plugin owns the + * hub for both and tags the message as pro from the Pro license status. + * + * The plugin screens need no `pages` entry: each one fires + * `themeisle_internal_page`, which the SDK already treats as a product screen. + * + * @return array{is_pro: bool, links: array, setup_complete: callable} + */ +function visualizer_support_hub_metadata() { + return array( + 'is_pro' => Visualizer_Module::is_pro(), + 'links' => array( + array( + 'icon' => 'book-alt', + 'text' => __( 'Docs', 'visualizer' ), + 'url' => VISUALIZER_MAIN_DOC, + ), + array( + 'icon' => 'groups', + 'text' => __( 'Forum', 'visualizer' ), + 'url' => 'https://wordpress.org/support/plugin/visualizer/', + ), + ), + 'setup_complete' => 'visualizer_support_hub_setup_complete', + ); +} + +/** + * Whether the site has at least one chart, in any status except auto-draft + * and trash. Runs on the plugin's own screens for administrators only. + * + * @return bool + */ +function visualizer_support_hub_setup_complete() { + $charts = get_posts( + array( + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, + 'post_status' => 'any', + 'posts_per_page' => 1, + 'fields' => 'ids', + 'no_found_rows' => true, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, + ) + ); + + return ! empty( $charts ); +} + /** * Registers with the SDK * diff --git a/tests/test-support-hub.php b/tests/test-support-hub.php new file mode 100644 index 00000000..f35d77fd --- /dev/null +++ b/tests/test-support-hub.php @@ -0,0 +1,124 @@ +assertNotFalse( has_filter( 'visualizer_support_hub_metadata', 'visualizer_support_hub_metadata' ) ); + + $data = apply_filters( 'visualizer_support_hub_metadata', array() ); + + $this->assertIsArray( $data ); + $this->assertArrayHasKey( 'is_pro', $data ); + $this->assertIsBool( $data['is_pro'] ); + $this->assertArrayHasKey( 'setup_complete', $data ); + $this->assertIsCallable( $data['setup_complete'] ); + $this->assertArrayNotHasKey( 'pages', $data, 'Screens are declared through themeisle_internal_page, not pages.' ); + $this->assertArrayNotHasKey( 'primary_color', $data, 'The hub keeps the shared SDK accent.' ); + } + + /** + * Every footer link has an icon, a text and a URL. + */ + public function test_links_are_complete() { + $data = apply_filters( 'visualizer_support_hub_metadata', array() ); + + $this->assertNotEmpty( $data['links'] ); + $this->assertLessThanOrEqual( 6, count( $data['links'] ) ); + foreach ( $data['links'] as $link ) { + $this->assertNotEmpty( $link['icon'] ); + $this->assertNotEmpty( $link['text'] ); + $this->assertNotFalse( filter_var( $link['url'], FILTER_VALIDATE_URL ) ); + } + $this->assertSame( VISUALIZER_MAIN_DOC, $data['links'][0]['url'] ); + } + + /** + * `is_pro` follows the `visualizer_is_pro` filter Pro answers from its license. + */ + public function test_is_pro_follows_the_license_filter() { + $this->assertFalse( apply_filters( 'visualizer_support_hub_metadata', array() )['is_pro'] ); + + add_filter( 'visualizer_is_pro', '__return_true' ); + $this->assertTrue( apply_filters( 'visualizer_support_hub_metadata', array() )['is_pro'] ); + remove_filter( 'visualizer_is_pro', '__return_true' ); + } + + /** + * Setup counts as complete once the site has one chart, in any live status. + */ + public function test_setup_complete_needs_one_chart() { + $this->assertFalse( visualizer_support_hub_setup_complete() ); + + $chart_id = self::factory()->post->create( + array( + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, + 'post_status' => 'draft', + ) + ); + $this->assertTrue( visualizer_support_hub_setup_complete() ); + + wp_trash_post( $chart_id ); + $this->assertFalse( visualizer_support_hub_setup_complete(), 'A trashed chart does not count.' ); + } + + /** + * Auto-drafts (the editor's placeholder posts) do not count as a chart. + */ + public function test_setup_complete_ignores_auto_drafts() { + self::factory()->post->create( + array( + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, + 'post_status' => 'auto-draft', + ) + ); + $this->assertFalse( visualizer_support_hub_setup_complete() ); + + self::factory()->post->create( + array( + 'post_type' => 'post', + 'post_status' => 'publish', + ) + ); + $this->assertFalse( visualizer_support_hub_setup_complete(), 'Other post types do not count.' ); + } + + /** + * The Settings screen declares itself a product screen like the Library and Support screens. + */ + public function test_settings_screen_fires_internal_page() { + wp_set_current_user( 1 ); + set_current_screen( 'dashboard' ); + + $admin = Visualizer_Plugin::instance()->getModule( Visualizer_Module_Admin::NAME ); + $admin->registerAdminMenu(); + + $fired = array(); + add_action( + 'themeisle_internal_page', + function ( $product, $page ) use ( &$fired ) { + $fired[] = array( $product, $page ); + }, + 10, + 2 + ); + + // The suffix add_submenu_page() returned, whatever menu state earlier tests left behind. + $admin->enqueueSettingsScripts( get_plugin_page_hookname( 'viz-settings', Visualizer_Plugin::NAME ) ); + $admin->enqueueSettingsScripts( 'edit-post' ); + + $this->assertSame( array( array( VISUALIZER_DIRNAME, 'settings' ) ), $fired ); + } +} From 054efd78de52e193fed67ab3dc06de7cc5394f01 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 2 Nov 2026 22:10:29 +0530 Subject: [PATCH 03/20] fix: clarify support hub metadata types --- index.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 3d42a87d..5dd9b144 100644 --- a/index.php +++ b/index.php @@ -286,12 +286,13 @@ function visualizer_action_scheduler_store_class( $class_name ) { * The plugin screens need no `pages` entry: each one fires * `themeisle_internal_page`, which the SDK already treats as a product screen. * - * @return array{is_pro: bool, links: array, setup_complete: callable} + * @return array{is_pro: bool, license_namespace: string, links: array, setup_complete: callable(): bool} */ function visualizer_support_hub_metadata() { return array( - 'is_pro' => Visualizer_Module::is_pro(), - 'links' => array( + 'is_pro' => Visualizer_Module::is_pro(), + 'license_namespace' => 'visualizer', + 'links' => array( array( 'icon' => 'book-alt', 'text' => __( 'Docs', 'visualizer' ), @@ -303,7 +304,7 @@ function visualizer_support_hub_metadata() { 'url' => 'https://wordpress.org/support/plugin/visualizer/', ), ), - 'setup_complete' => 'visualizer_support_hub_setup_complete', + 'setup_complete' => 'visualizer_support_hub_setup_complete', ); } From 0883f8492eaf5593799ee051131d93621009dd54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:02:12 +0200 Subject: [PATCH 04/20] chore(deps): bump codeinwp/themeisle-sdk from 3.3.68 to 3.3.69 (#1402) Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.68 to 3.3.69. - [Release notes](https://github.com/Codeinwp/themeisle-sdk/releases) - [Commits](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.68...v3.3.69) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-version: 3.3.69 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index cef0e73e..b33f39f8 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.68", + "version": "3.3.69", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "8477d5100ffdddd316a3e51129d775d8854d8a77" + "reference": "5b3c3e45f3ff385172539d330797df95172a06a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/8477d5100ffdddd316a3e51129d775d8854d8a77", - "reference": "8477d5100ffdddd316a3e51129d775d8854d8a77", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/5b3c3e45f3ff385172539d330797df95172a06a8", + "reference": "5b3c3e45f3ff385172539d330797df95172a06a8", "shasum": "" }, "require-dev": { @@ -43,9 +43,9 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.68" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.69" }, - "time": "2026-10-27T13:38:50+00:00" + "time": "2026-11-02T09:34:57+00:00" }, { "name": "neitanod/forceutf8", From fb76fba41696a93d2f4505fc17a4f1fa8c24c426 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:02:16 +0200 Subject: [PATCH 05/20] chore(deps-dev): bump phpstan/phpstan from 2.3.1 to 2.3.2 (#1401) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan-phar-composer-source) from 2.3.1 to 2.3.2. - [Commits](https://github.com/phpstan/phpstan-phar-composer-source/commits) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-version: 2.3.2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index b33f39f8..b32ad4b3 100644 --- a/composer.lock +++ b/composer.lock @@ -1066,11 +1066,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.3.1", + "version": "2.3.2", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6155239b488e95d26d1ebd95c6b4bb294d7f09db", - "reference": "6155239b488e95d26d1ebd95c6b4bb294d7f09db", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/18bc23a0682f08591529377d271b5c4dfe9ed1dd", + "reference": "18bc23a0682f08591529377d271b5c4dfe9ed1dd", "shasum": "" }, "require": { @@ -1126,7 +1126,7 @@ "type": "github" } ], - "time": "2026-10-08T21:09:11+00:00" + "time": "2026-10-24T11:36:00+00:00" }, { "name": "phpunit/php-code-coverage", From 93b02aaeadbcf41ed8806518fee0d93cea1fb928 Mon Sep 17 00:00:00 2001 From: Poonam Date: Tue, 3 Nov 2026 12:07:47 +0530 Subject: [PATCH 06/20] fix: point docs links to current pages and track them with UTMs Part of Codeinwp/docs-site#1596. Co-Authored-By: Claude Opus 5.5 --- classes/Visualizer/Module/Admin.php | 2 +- classes/Visualizer/Render/Layout.php | 29 ++++++++++++------- classes/Visualizer/Render/Sidebar.php | 2 +- classes/Visualizer/Render/Sidebar/ChartJS.php | 2 +- classes/Visualizer/Render/Sidebar/Google.php | 2 +- index.php | 6 ++-- templates/docs.php | 4 +-- tests/php/static-analysis-stubs/symbols.php | 6 ++-- 8 files changed, 31 insertions(+), 22 deletions(-) diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index e7ef36e5..c8e028c3 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -1409,7 +1409,7 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) { $is_black_friday = apply_filters( 'themeisle_sdk_is_black_friday_sale', false ); // knowledge base link $plugin_meta[] = sprintf( - '%s', + '%s', esc_html__( 'Docs', 'visualizer' ) ); if ( ! $is_black_friday ) { diff --git a/classes/Visualizer/Render/Layout.php b/classes/Visualizer/Render/Layout.php index dedce503..18e0aeb8 100644 --- a/classes/Visualizer/Render/Layout.php +++ b/classes/Visualizer/Render/Layout.php @@ -95,7 +95,7 @@ public static function _renderDbQuery( $args ) { echo sprintf( // translators: %1$s - HTML link tag, %2$s - HTML closing link tag. __( 'For examples of queries and links to resources that you can use with this feature, please click %1$shere%2$s', 'visualizer' ), - '', + '', '' ); ?> @@ -208,7 +208,7 @@ public static function _renderJsonScreen( $args ) { echo sprintf( // translators: %1$s - HTML link tag, %2$s - HTML closing link tag. __( 'If you want to add authentication or headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ), - '', + '', '' ); ?> @@ -621,7 +621,7 @@ private static function _renderPermissions( $args ) { array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' ) ); Visualizer_Render_Sidebar::_renderSectionEnd(); - echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions', 'https://docs.themeisle.com/article/1280-how-to-customize-permissions' ); + echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions', tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/how-to-customize-permissions', 'chart-permissions', 'chart-editor' ) ); echo ''; Visualizer_Render_Sidebar::_renderGroupEnd(); } @@ -689,15 +689,15 @@ public static function _renderTabHelp( $args ) { Visualizer_Render_Sidebar::_renderGroupStart( esc_html__( 'Documentation', 'visualizer' ), '', 'open' ); Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'General', 'visualizer' ), true ); ?> -

-

+

+

 " target="_blank">

-

+

', + '', '' ); ?> @@ -917,7 +917,16 @@ public static function _renderTabBasic( $args ) {
-

this tutorial', 'visualizer' ); ?>

+

+ ', + '' + ); + ?> +

- + @@ -1248,7 +1257,7 @@ class="dashicons dashicons-lock">

- + diff --git a/classes/Visualizer/Render/Sidebar.php b/classes/Visualizer/Render/Sidebar.php index 91e28a38..61cfd298 100644 --- a/classes/Visualizer/Render/Sidebar.php +++ b/classes/Visualizer/Render/Sidebar.php @@ -144,7 +144,7 @@ protected function _renderManualConfigDescription() { // translators: %1$s - HTML link tag, %2$s - HTML closing link tag, %3$s - HTML link tag, %4$s - HTML closing link tag. __( 'Configure the graph by providing configuration variables right from the %1$sGoogle Visualization API%2$s. You can refer to %3$sCommon Snippets%4$s for examples.', 'visualizer' ), '', '', - '', + '', '' ) . '' ); diff --git a/classes/Visualizer/Render/Sidebar/ChartJS.php b/classes/Visualizer/Render/Sidebar/ChartJS.php index 7d4a433a..a7021f71 100644 --- a/classes/Visualizer/Render/Sidebar/ChartJS.php +++ b/classes/Visualizer/Render/Sidebar/ChartJS.php @@ -393,7 +393,7 @@ protected function _renderManualConfigDescription() { __( 'Configure the graph by providing configuration variables right from the %1$sChartJS API%2$s. You can refer to %3$sCommon Snippets%4$s for examples.', 'visualizer' ), '', '', - '', + '', '' ) . '' ); diff --git a/classes/Visualizer/Render/Sidebar/Google.php b/classes/Visualizer/Render/Sidebar/Google.php index 2684e297..04a7d332 100644 --- a/classes/Visualizer/Render/Sidebar/Google.php +++ b/classes/Visualizer/Render/Sidebar/Google.php @@ -155,7 +155,7 @@ protected function _renderRoleField( $index ) { esc_html__( 'Determines whether the series has to be used for a special role as mentioned in %1$shere%2$s. You can view a few examples %3$shere%4$s.', 'visualizer' ), '', '', - '', + '', '' ) ); diff --git a/index.php b/index.php index b5f21108..7cd0c640 100644 --- a/index.php +++ b/index.php @@ -94,11 +94,11 @@ function visualizer_launch() { define( 'VISUALIZER_ENABLE_BETA_FEATURES', '' ); // the link to pre-build queries. - define( 'VISUALIZER_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/article/970-visualizer-sample-queries-to-generate-charts' ); - define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/category/657-visualizer' ); + define( 'VISUALIZER_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/visualizer-sample-queries-to-generate-charts' ); + define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' ); define( 'VISUALIZER_DOC_COLLECTION', 'https://docs.themeisle.com/visualizer-charts-and-graphs/?query=#' ); define( 'VISUALIZER_DEMO_URL', 'https://demo.themeisle.com/visualizer/#' ); - define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/category/726-visualizer' ); + define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' ); define( 'VISUALIZER_SUBSCRIBE_API', 'https://api.themeisle.com/tracking/subscribe' ); define( 'VISUALIZER_AGENTS_URL', 'https://ai.themeisle.com' ); diff --git a/templates/docs.php b/templates/docs.php index a094e05b..619addea 100644 --- a/templates/docs.php +++ b/templates/docs.php @@ -44,10 +44,10 @@

Documentation

-

To get started with Visualizer, we recommend you first bookmark our main documentation page here.

+

To get started with Visualizer, we recommend you first bookmark our main documentation page here.

- Notably, you could take a look at this first introductory tutorial: How to create my first chart. + Notably, you could take a look at this first introductory tutorial: How to create my first chart.

If you prefer learning through video, this could prove useful. It is a little dated however.

diff --git a/tests/php/static-analysis-stubs/symbols.php b/tests/php/static-analysis-stubs/symbols.php index 0e17329a..9df272ec 100644 --- a/tests/php/static-analysis-stubs/symbols.php +++ b/tests/php/static-analysis-stubs/symbols.php @@ -31,11 +31,11 @@ define( 'VISUALIZER_ENABLE_BETA_FEATURES', '' ); // the link to pre-build queries. -define( 'VISUALIZER_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/article/970-visualizer-sample-queries-to-generate-charts' ); -define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/category/657-visualizer' ); +define( 'VISUALIZER_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/visualizer-sample-queries-to-generate-charts' ); +define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' ); define( 'VISUALIZER_DOC_COLLECTION', 'https://docs.themeisle.com/search?collectionId=561ec249c69791452ed4bceb&query=#+visualizer' ); define( 'VISUALIZER_DEMO_URL', 'https://demo.themeisle.com/visualizer/#' ); -define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/category/726-visualizer' ); +define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' ); define( 'VISUALIZER_SUBSCRIBE_API', 'https://api.themeisle.com/tracking/subscribe' ); // to redirect all themeisle_log_event to error log. From 095acf742ed69a01e3bfb23a953139f938be5218 Mon Sep 17 00:00:00 2001 From: Soare Robert Daniel Date: Tue, 3 Nov 2026 14:16:18 +0200 Subject: [PATCH 07/20] fix(black-friday): treat active_expired licenses as expired (#1398) --- classes/Visualizer/Module/Admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index e7ef36e5..6cd32d6f 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -1609,7 +1609,7 @@ public function add_black_friday_data( $configs ) { $pro_product_slug = defined( 'VISUALIZER_PRO_BASEFILE' ) ? basename( dirname( VISUALIZER_PRO_BASEFILE ) ) : ''; $is_pro = 'valid' === $status; - $is_expired = 'expired' === $status || 'active-expired' === $status; + $is_expired = in_array( $status, array( 'expired', 'active_expired', 'active-expired' ), true ); if ( $is_pro ) { // translators: %s is the discount percentage. From 5191d4b12d26938045a63397b7c0dedd362e60ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Tue, 3 Nov 2026 14:23:20 +0200 Subject: [PATCH 08/20] fix: drop the support hub setup nudge for now --- index.php | 29 +++----------------------- tests/test-support-hub.php | 42 +------------------------------------- 2 files changed, 4 insertions(+), 67 deletions(-) diff --git a/index.php b/index.php index 5dd9b144..9e49ac8a 100644 --- a/index.php +++ b/index.php @@ -276,8 +276,8 @@ function visualizer_action_scheduler_store_class( $class_name ) { } /** - * Opts into the SDK Support Hub: one Help button on the plugin's own screens, - * a setup nudge while the site has no chart, and the deactivation window. + * Opts into the SDK Support Hub: one Help button on the plugin's own screens + * and the deactivation window. * * Visualizer Pro registers nothing here: it has no admin screens of its own * and the SDK shows one Help button per screen, so the free plugin owns the @@ -286,7 +286,7 @@ function visualizer_action_scheduler_store_class( $class_name ) { * The plugin screens need no `pages` entry: each one fires * `themeisle_internal_page`, which the SDK already treats as a product screen. * - * @return array{is_pro: bool, license_namespace: string, links: array, setup_complete: callable(): bool} + * @return array{is_pro: bool, license_namespace: string, links: array} */ function visualizer_support_hub_metadata() { return array( @@ -304,32 +304,9 @@ function visualizer_support_hub_metadata() { 'url' => 'https://wordpress.org/support/plugin/visualizer/', ), ), - 'setup_complete' => 'visualizer_support_hub_setup_complete', ); } -/** - * Whether the site has at least one chart, in any status except auto-draft - * and trash. Runs on the plugin's own screens for administrators only. - * - * @return bool - */ -function visualizer_support_hub_setup_complete() { - $charts = get_posts( - array( - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, - 'post_status' => 'any', - 'posts_per_page' => 1, - 'fields' => 'ids', - 'no_found_rows' => true, - 'update_post_meta_cache' => false, - 'update_post_term_cache' => false, - ) - ); - - return ! empty( $charts ); -} - /** * Registers with the SDK * diff --git a/tests/test-support-hub.php b/tests/test-support-hub.php index f35d77fd..312ca80e 100644 --- a/tests/test-support-hub.php +++ b/tests/test-support-hub.php @@ -23,8 +23,7 @@ public function test_metadata_has_the_contract_keys() { $this->assertIsArray( $data ); $this->assertArrayHasKey( 'is_pro', $data ); $this->assertIsBool( $data['is_pro'] ); - $this->assertArrayHasKey( 'setup_complete', $data ); - $this->assertIsCallable( $data['setup_complete'] ); + $this->assertArrayNotHasKey( 'setup_complete', $data, 'The setup nudge stays off for now.' ); $this->assertArrayNotHasKey( 'pages', $data, 'Screens are declared through themeisle_internal_page, not pages.' ); $this->assertArrayNotHasKey( 'primary_color', $data, 'The hub keeps the shared SDK accent.' ); } @@ -56,45 +55,6 @@ public function test_is_pro_follows_the_license_filter() { remove_filter( 'visualizer_is_pro', '__return_true' ); } - /** - * Setup counts as complete once the site has one chart, in any live status. - */ - public function test_setup_complete_needs_one_chart() { - $this->assertFalse( visualizer_support_hub_setup_complete() ); - - $chart_id = self::factory()->post->create( - array( - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, - 'post_status' => 'draft', - ) - ); - $this->assertTrue( visualizer_support_hub_setup_complete() ); - - wp_trash_post( $chart_id ); - $this->assertFalse( visualizer_support_hub_setup_complete(), 'A trashed chart does not count.' ); - } - - /** - * Auto-drafts (the editor's placeholder posts) do not count as a chart. - */ - public function test_setup_complete_ignores_auto_drafts() { - self::factory()->post->create( - array( - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, - 'post_status' => 'auto-draft', - ) - ); - $this->assertFalse( visualizer_support_hub_setup_complete() ); - - self::factory()->post->create( - array( - 'post_type' => 'post', - 'post_status' => 'publish', - ) - ); - $this->assertFalse( visualizer_support_hub_setup_complete(), 'Other post types do not count.' ); - } - /** * The Settings screen declares itself a product screen like the Library and Support screens. */ From 4e871a55e776839155ed77a4931bf60f96804671 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 20:02:08 +0200 Subject: [PATCH 09/20] chore(deps-dev): bump phpstan/phpstan from 2.3.2 to 2.3.3 (#1406) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan-phar-composer-source) from 2.3.2 to 2.3.3. - [Commits](https://github.com/phpstan/phpstan-phar-composer-source/commits) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-version: 2.3.3 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index b32ad4b3..ae5ee9c9 100644 --- a/composer.lock +++ b/composer.lock @@ -1066,11 +1066,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.3.2", + "version": "2.3.3", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/18bc23a0682f08591529377d271b5c4dfe9ed1dd", - "reference": "18bc23a0682f08591529377d271b5c4dfe9ed1dd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4b57dc8ca7456b635d1661845f44bc060b02c6b0", + "reference": "4b57dc8ca7456b635d1661845f44bc060b02c6b0", "shasum": "" }, "require": { @@ -1126,7 +1126,7 @@ "type": "github" } ], - "time": "2026-10-24T11:36:00+00:00" + "time": "2026-10-27T14:06:26+00:00" }, { "name": "phpunit/php-code-coverage", From 7963adfa63c3f7082ee73085808492a382c6a224 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 20:02:13 +0200 Subject: [PATCH 10/20] chore(deps): bump codeinwp/themeisle-sdk from 3.3.69 to 3.3.70 (#1405) Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.69 to 3.3.70. - [Release notes](https://github.com/Codeinwp/themeisle-sdk/releases) - [Commits](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.69...v3.3.70) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-version: 3.3.70 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index ae5ee9c9..5f3036d0 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.69", + "version": "3.3.70", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "5b3c3e45f3ff385172539d330797df95172a06a8" + "reference": "b46f386e5cd307b888c5760427ed127a751db18a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/5b3c3e45f3ff385172539d330797df95172a06a8", - "reference": "5b3c3e45f3ff385172539d330797df95172a06a8", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/b46f386e5cd307b888c5760427ed127a751db18a", + "reference": "b46f386e5cd307b888c5760427ed127a751db18a", "shasum": "" }, "require-dev": { @@ -43,9 +43,9 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.69" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.70" }, - "time": "2026-11-02T09:34:57+00:00" + "time": "2026-11-03T09:41:48+00:00" }, { "name": "neitanod/forceutf8", From a4eff7550b8c5030bfd7d432d554a488b403236b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 20:01:57 +0200 Subject: [PATCH 11/20] chore(deps): bump codeinwp/themeisle-sdk from 3.3.70 to 3.3.71 (#1408) Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.70 to 3.3.71. - [Release notes](https://github.com/Codeinwp/themeisle-sdk/releases) - [Commits](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.70...v3.3.71) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-version: 3.3.71 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 5f3036d0..dc6dc814 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.70", + "version": "3.3.71", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "b46f386e5cd307b888c5760427ed127a751db18a" + "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/b46f386e5cd307b888c5760427ed127a751db18a", - "reference": "b46f386e5cd307b888c5760427ed127a751db18a", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/cd7acfc0b01b8d5712736aa3721d689591ced991", + "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991", "shasum": "" }, "require-dev": { @@ -43,9 +43,9 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.70" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.71" }, - "time": "2026-11-03T09:41:48+00:00" + "time": "2026-11-04T20:22:53+00:00" }, { "name": "neitanod/forceutf8", From ab6afe6b4964736bde711734aeb5b0ceac3a644c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 20:02:02 +0200 Subject: [PATCH 12/20] chore(deps-dev): bump phpstan/phpstan from 2.3.3 to 2.3.4 (#1407) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan-phar-composer-source) from 2.3.3 to 2.3.4. - [Commits](https://github.com/phpstan/phpstan-phar-composer-source/commits) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-version: 2.3.4 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index dc6dc814..4e4f8000 100644 --- a/composer.lock +++ b/composer.lock @@ -1066,11 +1066,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.3.3", + "version": "2.3.4", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4b57dc8ca7456b635d1661845f44bc060b02c6b0", - "reference": "4b57dc8ca7456b635d1661845f44bc060b02c6b0", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f20ce6f3c82556cfcfc086b152445a12d1d64fff", + "reference": "f20ce6f3c82556cfcfc086b152445a12d1d64fff", "shasum": "" }, "require": { @@ -1126,7 +1126,7 @@ "type": "github" } ], - "time": "2026-10-27T14:06:26+00:00" + "time": "2026-10-28T22:38:53+00:00" }, { "name": "phpunit/php-code-coverage", From c7d432274c8e6f95c2acaa280e0e7aaa9c10ae8f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 13:03:33 +0000 Subject: [PATCH 13/20] chore(deps): bump codeinwp/themeisle-sdk from 3.3.71 to 3.3.72 Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.71 to 3.3.72. - [Release notes](https://github.com/Codeinwp/themeisle-sdk/releases) - [Commits](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.71...v3.3.72) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-version: 3.3.72 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 4e4f8000..51249cc7 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.71", + "version": "3.3.72", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991" + "reference": "66036fa0ef8168f7e5a3f7bf06dc88733e1d46db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/cd7acfc0b01b8d5712736aa3721d689591ced991", - "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/66036fa0ef8168f7e5a3f7bf06dc88733e1d46db", + "reference": "66036fa0ef8168f7e5a3f7bf06dc88733e1d46db", "shasum": "" }, "require-dev": { @@ -43,9 +43,9 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.71" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.72" }, - "time": "2026-11-04T20:22:53+00:00" + "time": "2026-11-06T13:01:52+00:00" }, { "name": "neitanod/forceutf8", From a7af6d173eb71edde327a0c6103f37d5c0ec9e83 Mon Sep 17 00:00:00 2001 From: Poonam Date: Mon, 9 Nov 2026 15:24:59 +0530 Subject: [PATCH 14/20] fix: stop the chart type rewrite from breaking the Common Snippets link frame.js replaced the first "?" in every span.viz-gvlink to put the chart type into the Google API link. On ChartJS charts that "?" is the start of the Common Snippets UTM query string, so the link became a 404. It also copied the first span's HTML into all of them, so on Google charts the Manual Configuration box showed the Data Filter text. Now only the Google API link's href is updated. Adds e2e checks for both libraries. Part of Codeinwp/docs-site#1596. Co-Authored-By: Claude Opus 5.5 --- js/frame.js | 8 +++++--- tests/e2e/specs/admin.spec.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/js/frame.js b/js/frame.js index 6fd62e26..9984a0b6 100644 --- a/js/frame.js +++ b/js/frame.js @@ -67,9 +67,11 @@ break; } - if($('span.viz-gvlink').length > 0) { - $('span.viz-gvlink').html($('span.viz-gvlink').html().replace('?', chart_type_in_api_link)); - } + // Only the Google API link has the "gallery/?" placeholder. Other links in the + // description (e.g. Common Snippets) carry UTM query strings and must stay as they are. + $('span.viz-gvlink a[href*="/chart/interactive/docs/gallery/?"]').attr('href', function (i, href) { + return href.replace('gallery/?', 'gallery/' + chart_type_in_api_link); + }); $('.type-radio').change(function () { $('.type-label-selected').removeClass('type-label-selected'); diff --git a/tests/e2e/specs/admin.spec.js b/tests/e2e/specs/admin.spec.js index 3534105a..3a6b9488 100644 --- a/tests/e2e/specs/admin.spec.js +++ b/tests/e2e/specs/admin.spec.js @@ -211,6 +211,41 @@ test.describe( 'Chart Library', () => { await expect( page.getByText(backendName) ).toBeVisible(); await expect( page.locator('g').filter({ hasText: 'Test Chart Name' }).locator('rect') ).toBeVisible(); } ); + + // frame.js rewrites the Google API link for the chart type. It must leave the + // "Common Snippets" docs link and its UTMs alone, on both libraries. + for ( const library of [ 'GoogleCharts', 'ChartJS' ] ) { + test( `manual configuration links (${ library })`, async ( { admin, page } ) => { + await admin.visitAdminPage( 'admin.php?page=visualizer&vaction=addnew' ); + await page.waitForURL( '**/admin.php?page=visualizer&vaction=addnew' ); + await expect( page.getByRole('button', { name: 'Classic Builder Step-by-step' }) ).toBeVisible({ timeout: 5000 }); + await page.getByRole('button', { name: 'Classic Builder Step-by-step' }).click(); + await page.waitForSelector('h1:text("Visualizer")'); + + const frame = page.frameLocator('iframe'); + await frame.getByRole('combobox').selectOption({ value: library }); + await selectChartAdmin( frame, CHART_JS_LABELS.pie ); + await expect( frame.getByRole('button', { name: 'Create Chart' }) ).toBeVisible({ timeout: 5000 }); + + const snippets = frame.locator('span.viz-gvlink a').filter({ hasText: 'Common Snippets' }); + await expect( snippets ).toHaveAttribute( + 'href', + 'https://docs.themeisle.com/visualizer-charts-and-graphs/manual-configuration?utm_source=wpadmin&utm_medium=chart-editor&utm_campaign=manual-configuration&utm_content=docsvisualizer-charts-and-graphsmanual-configuration' + ); + + if ( library === 'GoogleCharts' ) { + await expect( frame.locator('span.viz-gvlink a').filter({ hasText: 'Google Visualization API' }) ).toHaveAttribute( + 'href', + 'https://developers.google.com/chart/interactive/docs/gallery/piechart#configuration-options' + ); + // The data filter box keeps its own text and link. + await expect( frame.locator('span.viz-gvlink a').filter({ hasText: 'Chart Controls API' }) ).toHaveAttribute( + 'href', + 'https://developers.google.com/chart/interactive/docs/gallery/controls#controls-gallery' + ); + } + } ); + } } ); test.describe( 'Support', () => { From f2470bf0d5a8d9f05364de25f219ead2b545ed82 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:01:42 +0200 Subject: [PATCH 15/20] chore(deps-dev): bump phpstan/phpstan from 2.3.4 to 2.3.5 (#1410) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan-phar-composer-source) from 2.3.4 to 2.3.5. - [Commits](https://github.com/phpstan/phpstan-phar-composer-source/commits) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-version: 2.3.5 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 51249cc7..2d9c46c0 100644 --- a/composer.lock +++ b/composer.lock @@ -1066,11 +1066,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.3.4", + "version": "2.3.5", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f20ce6f3c82556cfcfc086b152445a12d1d64fff", - "reference": "f20ce6f3c82556cfcfc086b152445a12d1d64fff", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/645a1bd6bead15fc1b8474137467961d0fa30a79", + "reference": "645a1bd6bead15fc1b8474137467961d0fa30a79", "shasum": "" }, "require": { @@ -1126,7 +1126,7 @@ "type": "github" } ], - "time": "2026-10-28T22:38:53+00:00" + "time": "2026-11-03T12:14:22+00:00" }, { "name": "phpunit/php-code-coverage", From 6ee5e65c1955fadb1d6274aa9ce79c13085de447 Mon Sep 17 00:00:00 2001 From: selul Date: Thu, 12 Nov 2026 01:51:49 +0200 Subject: [PATCH 16/20] fix: normalize table rendering inputs --- classes/Visualizer/Gutenberg/Block.php | 9 +- classes/Visualizer/Module.php | 25 ++++- js/render-datatables.js | 15 +-- tests/js/render-datatables-settings.test.js | 100 ++++++++++++++++++++ tests/test-chart-data-sanitization.php | 40 ++++++++ 5 files changed, 180 insertions(+), 9 deletions(-) create mode 100644 tests/js/render-datatables-settings.test.js create mode 100644 tests/test-chart-data-sanitization.php diff --git a/classes/Visualizer/Gutenberg/Block.php b/classes/Visualizer/Gutenberg/Block.php index 5a152351..d8acb490 100644 --- a/classes/Visualizer/Gutenberg/Block.php +++ b/classes/Visualizer/Gutenberg/Block.php @@ -327,7 +327,14 @@ public function get_visualizer_data( $post ) { $data['visualizer-settings'] = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $data['visualizer-settings'], $post_id, $data['visualizer-chart-type'] ); // handle data filter hooks - $data['visualizer-data'] = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, Visualizer_Module::decode_content( html_entity_decode( get_post_field( 'post_content', $post_id, 'raw' ) ) ), $post_id, $data['visualizer-chart-type'] ); + $data['visualizer-data'] = Visualizer_Module::sanitize_chart_data( + apply_filters( + Visualizer_Plugin::FILTER_GET_CHART_DATA, + Visualizer_Module::decode_content( html_entity_decode( get_post_field( 'post_content', $post_id, 'raw' ) ) ), + $post_id, + $data['visualizer-chart-type'] + ) + ); // we are going to format only for tabular charts, because we are not sure of the effect on others. // this is to solve the case where boolean data shows up as all-ticks on gutenberg. diff --git a/classes/Visualizer/Module.php b/classes/Visualizer/Module.php index ff9fa2c3..49f9240b 100644 --- a/classes/Visualizer/Module.php +++ b/classes/Visualizer/Module.php @@ -912,9 +912,30 @@ function ( $matches ) { $altered = $data; } if ( $run_filter ) { - return apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, $altered, $chart->ID, $type ); + $altered = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, $altered, $chart->ID, $type ); } - return $altered; + + return self::sanitize_chart_data( $altered ); + } + + /** + * Sanitize chart data before passing it to HTML-capable renderers. + * + * @param mixed $data Chart data. + * @return mixed Sanitized chart data. + */ + public static function sanitize_chart_data( $data ) { + // Preserve normal text and supported formatting while removing active + // markup from imports, scheduled remote sources, and filtered data. + return map_deep( + $data, + static function ( $value ) { + if ( ! is_string( $value ) || ! preg_match( '/<\s*\/?\s*[a-zA-Z!][^>]*>/s', $value ) ) { + return $value; + } + return wp_kses_post( $value ); + } + ); } /** diff --git a/js/render-datatables.js b/js/render-datatables.js index 3a210694..1cb43fc7 100644 --- a/js/render-datatables.js +++ b/js/render-datatables.js @@ -108,6 +108,9 @@ var select = { info: false }; + var nestedSettings = { + select: select + }; // we cannot use { select } below because https://github.com/Codeinwp/visualizer/issues/357 $.extend( settings, { info: false } ); // jshint ignore:line @@ -163,15 +166,15 @@ // if the setting name has an '_' this means it is a sub-setting e.g. select_items means { select: { items: ... } }. var array = i.split('_'); - if(array.length === 2){ - i = eval( array[0] ); // jshint ignore:line - i[ array[1] ] = valoo; - additional[ array[0] ] = i; + if(array.length === 2 && Object.prototype.hasOwnProperty.call(nestedSettings, array[0])){ + var nestedSetting = nestedSettings[ array[0] ]; + nestedSetting[ array[1] ] = valoo; + additional[ array[0] ] = nestedSetting; if(array[0] === 'select' && array[1] === 'info' ){ // enable main info or the selection info will not show. $.extend( settings, {info: true} ); } - } else { + } else if(array.length === 1) { settings[i] = valoo; } } @@ -450,4 +453,4 @@ $.fn.dataTable.render.moment = function ( from, to, locale ) { })); -/* jshint ignore:end */ \ No newline at end of file +/* jshint ignore:end */ diff --git a/tests/js/render-datatables-settings.test.js b/tests/js/render-datatables-settings.test.js new file mode 100644 index 00000000..394e56a4 --- /dev/null +++ b/tests/js/render-datatables-settings.test.js @@ -0,0 +1,100 @@ +const assert = require( 'node:assert/strict' ); +const path = require( 'path' ); +const { afterEach, beforeEach, describe, it } = require( 'node:test' ); + +describe( 'DataTables nested settings', () => { + let handlers; + let capturedSettings; + let alertCalls; + + beforeEach( () => { + handlers = {}; + capturedSettings = null; + alertCalls = 0; + + global.window = {}; + global.document = { + getElementById: () => ( {} ), + }; + global.alert = () => { + alertCalls++; + }; + + const collection = { + length: 0, + hasClass: () => false, + children: () => ( { length: 0 } ), + find: () => ( { length: 0 } ), + empty() { + return this; + }, + append() { + return this; + }, + css: () => '400px', + addClass() { + return this; + }, + remove() { + return this; + }, + on( event, callback ) { + handlers[ event ] = callback; + return this; + }, + trigger() { + return this; + }, + DataTable( settings ) { + capturedSettings = settings; + return this; + }, + }; + + const jquery = () => collection; + jquery.extend = ( target, ...sources ) => Object.assign( target, ...sources ); + jquery.fn = { + dataTable: { + render: { + number: () => null, + }, + }, + }; + global.jQuery = jquery; + + const renderer = path.resolve( __dirname, '../../js/render-datatables.js' ); + delete require.cache[ renderer ]; + require( renderer ); + } ); + + afterEach( () => { + delete global.alert; + delete global.document; + delete global.jQuery; + delete global.window; + } ); + + function renderWithSettings( settings ) { + handlers[ 'visualizer:render:specificchart:start' ]( {}, { + id: 'chart', + chart: { + library: 'datatables', + settings, + series: [ { label: 'Value', type: 'string' } ], + data: [ [ 'Example' ] ], + }, + v: { page_type: 'frontend' }, + } ); + } + + it( 'does not execute an unsupported nested setting name', () => { + assert.doesNotThrow( () => renderWithSettings( { 'alert(1)_x': 'value' } ) ); + assert.equal( alertCalls, 0 ); + } ); + + it( 'continues to apply the supported select nested setting', () => { + renderWithSettings( { select_info: 'true' } ); + assert.equal( capturedSettings.select.info, true ); + assert.equal( capturedSettings.info, true ); + } ); +} ); diff --git a/tests/test-chart-data-sanitization.php b/tests/test-chart-data-sanitization.php new file mode 100644 index 00000000..a43c21b4 --- /dev/null +++ b/tests/test-chart-data-sanitization.php @@ -0,0 +1,40 @@ + 123, + 'post_content' => serialize( + array( + array( + 'Revenue', + '', + '', + 'Research & Development', + '3 < 5', + ), + ) + ), + ); + + $result = Visualizer_Module::get_chart_data( $chart, 'table', false ); + + $this->assertSame( 'Revenue', $result[0][0] ); + $this->assertStringNotContainsString( 'onerror', $result[0][1] ); + $this->assertStringNotContainsString( 'assertSame( 'Research & Development', $result[0][3] ); + $this->assertSame( '3 < 5', $result[0][4] ); + } +} From 396d4693045b905e6d8bb90a330375e84767a321 Mon Sep 17 00:00:00 2001 From: selul Date: Thu, 12 Nov 2026 12:40:17 +0200 Subject: [PATCH 17/20] fix: scope chart data access boundaries --- classes/Visualizer/Module/Chart.php | 11 +-- classes/Visualizer/Plugin.php | 1 + classes/Visualizer/Source/Json.php | 7 +- package-lock.json | 100 ++++++++++++++++++++-------- package.json | 4 +- tests/test-ajax.php | 56 ++++++++++++++++ tests/test-remote-fetch.php | 53 +++++++++++++++ 7 files changed, 196 insertions(+), 36 deletions(-) diff --git a/classes/Visualizer/Module/Chart.php b/classes/Visualizer/Module/Chart.php index bbe126e0..a49654af 100644 --- a/classes/Visualizer/Module/Chart.php +++ b/classes/Visualizer/Module/Chart.php @@ -138,16 +138,17 @@ public function setJsonSchedule() { ); if ( Visualizer_Module::is_pro() ) { - $is_woocommerce_report = filter_input( - INPUT_POST, - 'is_woocommerce_report', - FILTER_VALIDATE_BOOLEAN - ); + $is_woocommerce_report = isset( $_POST['is_woocommerce_report'] ) ? filter_var( wp_unslash( $_POST['is_woocommerce_report'] ), FILTER_VALIDATE_BOOLEAN ) : false; if ( $is_woocommerce_report ) { + if ( ! current_user_can( 'view_woocommerce_reports' ) ) { + wp_send_json_error( array( 'msg' => esc_html__( 'You do not have permission to access WooCommerce reports.', 'visualizer' ) ), 403 ); + } update_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, get_current_user_id() ); } else { delete_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE ); + delete_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER ); } } diff --git a/classes/Visualizer/Plugin.php b/classes/Visualizer/Plugin.php index 162672c0..8d632e2b 100644 --- a/classes/Visualizer/Plugin.php +++ b/classes/Visualizer/Plugin.php @@ -106,6 +106,7 @@ class Visualizer_Plugin { const CF_CHART_CACHE = 'visualizer-chart-cache'; const CF_JSON_WOOCOMMERCE_SOURCE = 'visualizer-woocommerce-source'; const CF_IS_WOOCOMMERCE_SOURCE = 'visualizer-is-woocommerce-source'; + const CF_WOOCOMMERCE_REPORT_USER = 'visualizer-woocommerce-report-user'; /** * Name of the option for WordPress DB. diff --git a/classes/Visualizer/Source/Json.php b/classes/Visualizer/Source/Json.php index 0da21be8..ba819ad8 100644 --- a/classes/Visualizer/Source/Json.php +++ b/classes/Visualizer/Source/Json.php @@ -457,8 +457,13 @@ function ( $headers ) { } } - // Check if this is a WooCommerce endpoint request and add verification token. + // Check if this is an authorized WooCommerce endpoint request and add a verification token. + $can_fetch_woocommerce_reports = false; if ( $this->is_woocommerce_request( $url ) ) { + $can_fetch_woocommerce_reports = current_user_can( 'view_woocommerce_reports' ); + $can_fetch_woocommerce_reports = apply_filters( 'visualizer_can_fetch_woocommerce_reports', $can_fetch_woocommerce_reports, $url ); + } + if ( ! empty( $can_fetch_woocommerce_reports ) ) { // Generate a unique token for this specific request. $token = wp_generate_password( 32, false ); set_transient( 'visualizer_wc_token_' . $token, time(), 60 ); diff --git a/package-lock.json b/package-lock.json index fd175637..176e26aa 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "visualizer", - "version": "3.11.15", + "version": "4.0.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "visualizer", - "version": "3.11.15", + "version": "4.0.10", "license": "GPL-2.0+", "dependencies": { "@chakra-ui/react": "^3.34.0", @@ -16,12 +16,11 @@ "@uiw/react-codemirror": "^4.23.6", "d3": "^7.9.0", "deep-filter": "^1.0.2", - "handsontable": "^13.0.0", "is-plain-object": "^2.0.4", - "merge": "^1.2.1", + "merge": "^2.1.1", "react-google-charts": "^3.0.8", "topojson-client": "^3.1.0", - "uuid": "^8.3.2" + "uuid": "^11.1.1" }, "devDependencies": { "@semantic-release/changelog": "^5.0.1", @@ -7633,6 +7632,7 @@ "resolved": "https://registry.npmjs.org/@types/pikaday/-/pikaday-1.7.4.tgz", "integrity": "sha512-0KsHVyw5pTG829nqG4IRu7m+BFQlFEBdbE/1i3S5182HeKUKv1uEW0gyEmkJVp5i4IV+9pyh23O83+KpRkSQbw==", "license": "MIT", + "peer": true, "dependencies": { "moment": ">=2.14.0" } @@ -12718,6 +12718,7 @@ "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-8.1.1.tgz", "integrity": "sha512-QD46ppGintwPGuL1KqmwhR0O+N2cZUg8JG/VzwI2e28sM9TqHjQB10lI4QAaMHVbLzwVLLAwEglpKPViWX+5NQ==", "license": "MIT", + "peer": true, "engines": { "node": "*" } @@ -13369,6 +13370,7 @@ "integrity": "sha512-BwqQ/AgmKJ8jcMEjaSnfMybnKMgGTrtDKowfTP3pX4jwVy0kNjRsT/AP6h+wC3+3NC+X8X15VWBnTCQlX+wQFg==", "license": "Apache-2.0", "optional": true, + "peer": true, "dependencies": { "regexp-to-ast": "0.4.0" } @@ -15879,7 +15881,8 @@ "version": "2.5.9", "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.9.tgz", "integrity": "sha512-i6mvVmWN4xo9LrhCOZrDgSs9noW6nOahbrmzjRbPF36YPyj5Ue5lgok0MHDWkG7xzpWFO2OYttXdzM7rJxHvNA==", - "license": "(MPL-2.0 OR Apache-2.0)" + "license": "(MPL-2.0 OR Apache-2.0)", + "peer": true }, "node_modules/domutils": { "version": "3.1.0", @@ -19108,6 +19111,7 @@ "resolved": "https://registry.npmjs.org/handsontable/-/handsontable-13.1.0.tgz", "integrity": "sha512-KqJtS3rJeOWsFWCffnDlM8fcLMTqmW+Vbc7OCVM4X7dYDpfefgFerjNLIxLfT9xohcQoUOS1jcvXwV8dwSppVQ==", "license": "SEE LICENSE IN LICENSE.txt", + "peer": true, "dependencies": { "@types/pikaday": "1.7.4", "core-js": "^3.31.1", @@ -19567,6 +19571,7 @@ "integrity": "sha512-mpVF5zOyNpksZzgTaCQyRAzdC/X43+taz5x1n7zNbs/PUUv0AuLmsy2yfihCr+vihUzN/pk+gXBbOfNpXKOpgA==", "license": "GPL-3.0-only", "optional": true, + "peer": true, "dependencies": { "chevrotain": "^6.5.0", "tiny-emitter": "^2.1.0" @@ -23120,9 +23125,9 @@ } }, "node_modules/merge": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", - "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/merge/-/merge-2.1.1.tgz", + "integrity": "sha512-jz+Cfrg9GWOZbQAnDQ4hlVnQky+341Yk5ru8bZSe6sIDTCIg8n9i/u7hSQGSVOF3C7lH6mGtqjkiT9G4wFLL0w==", "license": "MIT" }, "node_modules/merge-deep": { @@ -23465,6 +23470,7 @@ "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", "license": "MIT", + "peer": true, "engines": { "node": "*" } @@ -26857,6 +26863,7 @@ "resolved": "https://registry.npmjs.org/numbro/-/numbro-2.1.2.tgz", "integrity": "sha512-7w833BxZmKGLE9HI0aREtNVRVH6WTYUUlWf4qgA5gKNhPQ4F/MRZ14sc0v8eoLORprk9ZTVwYaLwj8N3Zgxwiw==", "license": "MIT", + "peer": true, "dependencies": { "bignumber.js": "^8.0.1" }, @@ -28167,7 +28174,8 @@ "version": "1.8.2", "resolved": "https://registry.npmjs.org/pikaday/-/pikaday-1.8.2.tgz", "integrity": "sha512-TNtsE+34BIax3WtkB/qqu5uepV1McKYEgvL3kWzU7aqPCpMEN6rBF3AOwu4WCwAealWlBGobXny/9kJb49C1ew==", - "license": "(0BSD OR MIT)" + "license": "(0BSD OR MIT)", + "peer": true }, "node_modules/pinkie": { "version": "2.0.4", @@ -29835,7 +29843,8 @@ "resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.4.0.tgz", "integrity": "sha512-4qf/7IsIKfSNHQXSwial1IFmfM1Cc/whNBQqRwe0V2stPe7KmN1U0tWQiIx6JiirgSrisjE0eECdNf7Tav1Ntw==", "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/regexp.prototype.flags": { "version": "1.5.2", @@ -31337,6 +31346,17 @@ "websocket-driver": "^0.7.4" } }, + "node_modules/sockjs/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "dev": true, + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/socks": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.1.tgz", @@ -32872,7 +32892,8 @@ "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/tmp": { "version": "0.2.1", @@ -33684,12 +33705,16 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.1.tgz", + "integrity": "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "license": "MIT", "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/v8-compile-cache": { @@ -40280,6 +40305,7 @@ "version": "1.7.4", "resolved": "https://registry.npmjs.org/@types/pikaday/-/pikaday-1.7.4.tgz", "integrity": "sha512-0KsHVyw5pTG829nqG4IRu7m+BFQlFEBdbE/1i3S5182HeKUKv1uEW0gyEmkJVp5i4IV+9pyh23O83+KpRkSQbw==", + "peer": true, "requires": { "moment": ">=2.14.0" } @@ -44064,7 +44090,8 @@ "bignumber.js": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-8.1.1.tgz", - "integrity": "sha512-QD46ppGintwPGuL1KqmwhR0O+N2cZUg8JG/VzwI2e28sM9TqHjQB10lI4QAaMHVbLzwVLLAwEglpKPViWX+5NQ==" + "integrity": "sha512-QD46ppGintwPGuL1KqmwhR0O+N2cZUg8JG/VzwI2e28sM9TqHjQB10lI4QAaMHVbLzwVLLAwEglpKPViWX+5NQ==", + "peer": true }, "binary-extensions": { "version": "2.2.0", @@ -44547,6 +44574,7 @@ "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-6.5.0.tgz", "integrity": "sha512-BwqQ/AgmKJ8jcMEjaSnfMybnKMgGTrtDKowfTP3pX4jwVy0kNjRsT/AP6h+wC3+3NC+X8X15VWBnTCQlX+wQFg==", "optional": true, + "peer": true, "requires": { "regexp-to-ast": "0.4.0" } @@ -46370,7 +46398,8 @@ "dompurify": { "version": "2.5.9", "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.9.tgz", - "integrity": "sha512-i6mvVmWN4xo9LrhCOZrDgSs9noW6nOahbrmzjRbPF36YPyj5Ue5lgok0MHDWkG7xzpWFO2OYttXdzM7rJxHvNA==" + "integrity": "sha512-i6mvVmWN4xo9LrhCOZrDgSs9noW6nOahbrmzjRbPF36YPyj5Ue5lgok0MHDWkG7xzpWFO2OYttXdzM7rJxHvNA==", + "peer": true }, "domutils": { "version": "3.1.0", @@ -48731,6 +48760,7 @@ "version": "13.1.0", "resolved": "https://registry.npmjs.org/handsontable/-/handsontable-13.1.0.tgz", "integrity": "sha512-KqJtS3rJeOWsFWCffnDlM8fcLMTqmW+Vbc7OCVM4X7dYDpfefgFerjNLIxLfT9xohcQoUOS1jcvXwV8dwSppVQ==", + "peer": true, "requires": { "@types/pikaday": "1.7.4", "core-js": "^3.31.1", @@ -49061,6 +49091,7 @@ "resolved": "https://registry.npmjs.org/hyperformula/-/hyperformula-2.7.1.tgz", "integrity": "sha512-mpVF5zOyNpksZzgTaCQyRAzdC/X43+taz5x1n7zNbs/PUUv0AuLmsy2yfihCr+vihUzN/pk+gXBbOfNpXKOpgA==", "optional": true, + "peer": true, "requires": { "chevrotain": "^6.5.0", "tiny-emitter": "^2.1.0" @@ -51711,9 +51742,9 @@ } }, "merge": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", - "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/merge/-/merge-2.1.1.tgz", + "integrity": "sha512-jz+Cfrg9GWOZbQAnDQ4hlVnQky+341Yk5ru8bZSe6sIDTCIg8n9i/u7hSQGSVOF3C7lH6mGtqjkiT9G4wFLL0w==" }, "merge-deep": { "version": "3.0.3", @@ -51968,7 +51999,8 @@ "moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", - "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "peer": true }, "mrmime": { "version": "2.0.0", @@ -54413,6 +54445,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/numbro/-/numbro-2.1.2.tgz", "integrity": "sha512-7w833BxZmKGLE9HI0aREtNVRVH6WTYUUlWf4qgA5gKNhPQ4F/MRZ14sc0v8eoLORprk9ZTVwYaLwj8N3Zgxwiw==", + "peer": true, "requires": { "bignumber.js": "^8.0.1" } @@ -55413,7 +55446,8 @@ "pikaday": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/pikaday/-/pikaday-1.8.2.tgz", - "integrity": "sha512-TNtsE+34BIax3WtkB/qqu5uepV1McKYEgvL3kWzU7aqPCpMEN6rBF3AOwu4WCwAealWlBGobXny/9kJb49C1ew==" + "integrity": "sha512-TNtsE+34BIax3WtkB/qqu5uepV1McKYEgvL3kWzU7aqPCpMEN6rBF3AOwu4WCwAealWlBGobXny/9kJb49C1ew==", + "peer": true }, "pinkie": { "version": "2.0.4", @@ -56557,7 +56591,8 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.4.0.tgz", "integrity": "sha512-4qf/7IsIKfSNHQXSwial1IFmfM1Cc/whNBQqRwe0V2stPe7KmN1U0tWQiIx6JiirgSrisjE0eECdNf7Tav1Ntw==", - "optional": true + "optional": true, + "peer": true }, "regexp.prototype.flags": { "version": "1.5.2", @@ -57644,6 +57679,14 @@ "faye-websocket": "^0.11.3", "uuid": "^8.3.2", "websocket-driver": "^0.7.4" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "socks": { @@ -58835,7 +58878,8 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", - "optional": true + "optional": true, + "peer": true }, "tmp": { "version": "0.2.1", @@ -59434,9 +59478,9 @@ "dev": true }, "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.1.tgz", + "integrity": "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==" }, "v8-compile-cache": { "version": "2.4.0", diff --git a/package.json b/package.json index 64f7d057..afe1b8bf 100755 --- a/package.json +++ b/package.json @@ -50,10 +50,10 @@ "d3": "^7.9.0", "deep-filter": "^1.0.2", "is-plain-object": "^2.0.4", - "merge": "^1.2.1", + "merge": "^2.1.1", "react-google-charts": "^3.0.8", "topojson-client": "^3.1.0", - "uuid": "^8.3.2" + "uuid": "^11.1.1" }, "devDependencies": { "@semantic-release/changelog": "^5.0.1", diff --git a/tests/test-ajax.php b/tests/test-ajax.php index 20a0ed8c..61e7dc18 100644 --- a/tests/test-ajax.php +++ b/tests/test-ajax.php @@ -1122,6 +1122,62 @@ public function test_json_schedule_denied_for_chart_user_cannot_edit() { $this->assertSame( '', get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true ) ); } + /** + * A chart editor without report access cannot schedule a WooCommerce report import. + * + * @group ajax + */ + public function test_woocommerce_json_schedule_denied_without_report_capability() { + $this->enable_pro(); + $chart_id = $this->create_chart_for_user( $this->contibutor_user_id ); + wp_set_current_user( $this->contibutor_user_id ); + $_POST = array( + 'chart' => $chart_id, + 'time' => 12, + 'is_woocommerce_report' => 'true', + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_SCHEDULE . Visualizer_Plugin::VERSION ), + ); + + try { + $this->_handleAjax( Visualizer_Plugin::ACTION_JSON_SET_SCHEDULE ); + } catch ( WPAjaxDieContinueException $e ) { + // Expected after the JSON response. + } + + $response = json_decode( $this->_last_response ); + $this->assertFalse( $response->success ); + $this->assertSame( '', get_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, true ) ); + } + + /** + * A report-capable chart editor can authorize future scheduled imports. + * + * @group ajax + */ + public function test_woocommerce_json_schedule_records_authorizing_user() { + $this->enable_pro(); + $chart_id = $this->create_chart_for_user( $this->admin_user_id ); + wp_set_current_user( $this->admin_user_id ); + wp_get_current_user()->add_cap( 'view_woocommerce_reports' ); + $this->assertTrue( current_user_can( 'view_woocommerce_reports' ) ); + $_POST = array( + 'chart' => $chart_id, + 'time' => 12, + 'is_woocommerce_report' => 'true', + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_SCHEDULE . Visualizer_Plugin::VERSION ), + ); + + try { + $this->_handleAjax( Visualizer_Plugin::ACTION_JSON_SET_SCHEDULE ); + } catch ( WPAjaxDieContinueException $e ) { + // Expected after the JSON response. + } + + $response = json_decode( $this->_last_response ); + $this->assertTrue( $response->success, $this->_last_response ); + $this->assertSame( $this->admin_user_id, (int) get_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, true ) ); + } + /** * A user cannot replace another user's JSON chart data. */ diff --git a/tests/test-remote-fetch.php b/tests/test-remote-fetch.php index 308ffc40..06f7931c 100644 --- a/tests/test-remote-fetch.php +++ b/tests/test-remote-fetch.php @@ -680,6 +680,59 @@ public function test_download_blocks_non_public_destination() { $this->assertSame( 0, $requests ); } + /** + * Chart editors without WooCommerce report access must not receive the internal token. + */ + public function test_json_source_does_not_mint_woocommerce_token_for_contributor() { + $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); + wp_set_current_user( $user_id ); + + $headers = $this->capture_woocommerce_request_headers(); + + $this->assertArrayNotHasKey( 'X-Visualizer-Token', $headers ); + } + + /** + * Shop users with report access retain the WooCommerce chart source feature. + */ + public function test_json_source_mints_woocommerce_token_for_authorized_user() { + $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); + $user = new WP_User( $user_id ); + $user->add_cap( 'view_woocommerce_reports' ); + wp_set_current_user( $user_id ); + + $headers = $this->capture_woocommerce_request_headers(); + + $this->assertArrayHasKey( 'X-Visualizer-Token', $headers ); + $this->assertNotSame( '', $headers['X-Visualizer-Token'] ); + delete_transient( 'visualizer_wc_token_' . $headers['X-Visualizer-Token'] ); + } + + /** + * Captures the headers generated for a same-site WooCommerce reports request. + * + * @return array + */ + private function capture_woocommerce_request_headers() { + $headers = array(); + $filter = function ( $preempt, $args ) use ( &$headers ) { + $headers = $args['headers']; + return $this->response( 200, array(), '[{"total_sales":"10.00"}]' ); + }; + add_filter( 'pre_http_request', $filter, 10, 2 ); + + $source = new Visualizer_Source_Json( + array( + 'url' => home_url( '/wp-json/wc/v3/reports/sales' ), + 'root' => 'root', + ) + ); + $source->fetchRoots(); + + remove_filter( 'pre_http_request', $filter, 10 ); + return $headers; + } + /** * Builds a WordPress HTTP response fixture. * From 6f437694858ca28ff116ca57050ff794c6ef163e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Fri, 13 Nov 2026 13:30:19 +0200 Subject: [PATCH 18/20] test: cover chart data sanitization in the block editor --- tests/test-chart-data-sanitization.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test-chart-data-sanitization.php b/tests/test-chart-data-sanitization.php index a43c21b4..0c4897cd 100644 --- a/tests/test-chart-data-sanitization.php +++ b/tests/test-chart-data-sanitization.php @@ -37,4 +37,29 @@ public function test_chart_data_removes_active_markup() { $this->assertSame( 'Research & Development', $result[0][3] ); $this->assertSame( '3 < 5', $result[0][4] ); } + + /** + * The block editor reads chart data through its own path, which gets the same sanitization. + */ + public function test_block_editor_chart_data_removes_active_markup() { + $author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); + // Stored as an administrator would, so post content filtering leaves the serialized data intact. + wp_set_current_user( $author_id ); + $chart_id = self::factory()->post->create( + array( + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, + 'post_status' => 'publish', + 'post_author' => $author_id, + 'post_content' => wp_slash( serialize( array( array( 'Revenue', '' ) ) ) ), + ) + ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, 'line' ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, array() ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, array( array( 'label' => 'Label', 'type' => 'string' ) ) ); + + $result = Visualizer_Gutenberg_Block::get_instance()->get_visualizer_data( array( 'id' => $chart_id ) ); + + $this->assertSame( 'Revenue', $result['visualizer-data'][0][0] ); + $this->assertStringNotContainsString( ' Date: Sat, 14 Nov 2026 02:34:35 +0200 Subject: [PATCH 19/20] fix: apply the chart cell boundary to previews and keep report data on failed refreshes Normalize every tag opening in rendered cells, sanitize import and query previews, and keep exports and the data editor on the stored values. Record the user who sets a JSON endpoint as its report user, and keep the stored data when a WooCommerce report fetch fails. --- classes/Visualizer/Module.php | 14 +- classes/Visualizer/Module/Chart.php | 29 ++++- classes/Visualizer/Render/Layout.php | 2 +- classes/Visualizer/Source/Json.php | 7 +- classes/Visualizer/Source/Query.php | 2 +- js/render-datatables.js | 2 +- tests/test-ajax.php | 172 +++++++++++++++++++++++-- tests/test-chart-data-sanitization.php | 92 +++++++++++-- tests/test-remote-fetch.php | 93 +++++++++++++ 9 files changed, 381 insertions(+), 32 deletions(-) diff --git a/classes/Visualizer/Module.php b/classes/Visualizer/Module.php index 49f9240b..8fbb8977 100644 --- a/classes/Visualizer/Module.php +++ b/classes/Visualizer/Module.php @@ -190,7 +190,7 @@ public function _getDataAs( $chart_id, $type ) { $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true ); $rows = array(); $series = get_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, true ); - $data = self::get_chart_data( $chart, $type, false ); + $data = self::get_chart_data( $chart, $type, false, 'print' === $type ); if ( ! empty( $series ) ) { $row = array(); foreach ( $series as $array ) { @@ -880,8 +880,14 @@ public static function maybe_decode_content( $value ) { /** * Gets the chart content after common manipulations. + * + * @param WP_Post|object $chart The chart post. + * @param string $type The chart type passed to the data filter. + * @param bool $run_filter Whether to run the chart data filter. + * @param bool $sanitize Whether to prepare the cells for HTML-capable renderers; exports and editors need the stored values. + * @return mixed The chart data. */ - public static function get_chart_data( $chart, $type, $run_filter = true ) { + public static function get_chart_data( $chart, $type, $run_filter = true, $sanitize = true ) { // change HTML entities $post_content = html_entity_decode( htmlentities( $chart->post_content ) ); $post_content = preg_replace_callback( @@ -915,7 +921,7 @@ function ( $matches ) { $altered = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, $altered, $chart->ID, $type ); } - return self::sanitize_chart_data( $altered ); + return $sanitize ? self::sanitize_chart_data( $altered ) : $altered; } /** @@ -930,7 +936,7 @@ public static function sanitize_chart_data( $data ) { return map_deep( $data, static function ( $value ) { - if ( ! is_string( $value ) || ! preg_match( '/<\s*\/?\s*[a-zA-Z!][^>]*>/s', $value ) ) { + if ( ! is_string( $value ) || ! preg_match( '/<\s*\/?\s*[a-zA-Z!]/', $value ) ) { return $value; } return wp_kses_post( $value ); diff --git a/classes/Visualizer/Module/Chart.php b/classes/Visualizer/Module/Chart.php index a49654af..c8f951e7 100644 --- a/classes/Visualizer/Module/Chart.php +++ b/classes/Visualizer/Module/Chart.php @@ -70,6 +70,26 @@ public function __construct( Visualizer_Plugin $plugin ) { $this->_addAjaxAction( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY, 'saveFilter' ); $this->_addFilter( 'visualizer_get_sidebar', 'getSidebar', 10, 2 ); + + $this->_addAction( 'added_post_meta', 'recordJsonSourceUser', null, 10, 3 ); + $this->_addAction( 'updated_post_meta', 'recordJsonSourceUser', null, 10, 3 ); + } + + /** + * Records the user who set a chart's JSON endpoint as its WooCommerce report user. + * + * A scheduled refresh of that endpoint then uses this user's report access, + * not the access of whoever authorized an earlier endpoint. + * + * @param int $meta_id The meta ID. + * @param int $object_id The post ID. + * @param string $meta_key The meta key. + * @return void + */ + public function recordJsonSourceUser( $meta_id, $object_id, $meta_key ) { + if ( Visualizer_Plugin::CF_JSON_URL === $meta_key ) { + update_post_meta( $object_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, get_current_user_id() ); + } } /** @@ -148,7 +168,6 @@ public function setJsonSchedule() { update_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, get_current_user_id() ); } else { delete_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE ); - delete_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER ); } } @@ -221,7 +240,7 @@ public function getJsonData() { wp_send_json_error( array( 'msg' => esc_html__( 'Unable to fetch data from the endpoint. Please try again.', 'visualizer' ) ) ); } - $data = Visualizer_Render_Layout::show( 'editor-table', $data, $chart_id, 'viz-json-table', false, false ); + $data = Visualizer_Render_Layout::show( 'editor-table', self::sanitize_chart_data( $data ), $chart_id, 'viz-json-table', false, false ); wp_send_json_success( array( 'table' => $data, 'root' => $params['root'], 'url' => $params['url'], 'paging' => $source->getPaginationElements() ) ); } @@ -305,7 +324,7 @@ public function setJsonData() { $render = new Visualizer_Render_Page_Update(); $render->id = $chart->ID; - $render->data = json_encode( $source->getRawData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) ); + $render->data = json_encode( self::sanitize_chart_data( $source->getRawData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) ) ); $render->series = json_encode( $source->getSeries() ); $render->render(); @@ -1421,7 +1440,7 @@ public function uploadData() { } $render->id = $chart->ID; - $render->data = json_encode( $source->getRawData( get_post_meta( $chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) ); + $render->data = json_encode( self::sanitize_chart_data( $source->getRawData( get_post_meta( $chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) ) ); $render->series = json_encode( $source->getSeries() ); $render->settings = json_encode( $settings ); } else { @@ -1683,7 +1702,7 @@ public function saveQuery() { 'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ), ) ); - $render->data = json_encode( $source->getRawData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) ); + $render->data = json_encode( self::sanitize_chart_data( $source->getRawData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) ) ); $render->series = json_encode( $source->getSeries() ); $render->id = $chart_id; } else { diff --git a/classes/Visualizer/Render/Layout.php b/classes/Visualizer/Render/Layout.php index 18e0aeb8..33a27edb 100644 --- a/classes/Visualizer/Render/Layout.php +++ b/classes/Visualizer/Render/Layout.php @@ -436,7 +436,7 @@ public static function _renderEditorTable( $args ) { } $chart = get_post( $chart_id ); $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true ); - $data = Visualizer_Module::get_chart_data( $chart, $type ); + $data = Visualizer_Module::get_chart_data( $chart, $type, true, ! $editable_data ); } else { $headers = array_keys( $data[0] ); } diff --git a/classes/Visualizer/Source/Json.php b/classes/Visualizer/Source/Json.php index ba819ad8..43147ae1 100644 --- a/classes/Visualizer/Source/Json.php +++ b/classes/Visualizer/Source/Json.php @@ -207,6 +207,7 @@ public function getPaginationElements() { * @since ? * * @access public + * @return bool False when a WooCommerce report request failed, true otherwise. */ public function fetch() { $url = $this->_url; @@ -285,7 +286,7 @@ public function fetch() { do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'JSON endpoint data parsed.', 'debug', __FILE__, __LINE__ ); - return true; + return empty( $this->_error ); } /** @@ -399,6 +400,10 @@ private function getJSON( $url = null ) { if ( is_wp_error( $response ) || ! in_array( intval( $response['response']['code'] ), array( 200, 201 ), true ) ) { $error_code = is_wp_error( $response ) ? $response->get_error_code() : (string) wp_remote_retrieve_response_code( $response ); do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Error while fetching JSON endpoint: %s', $error_code ), 'error', __FILE__, __LINE__ ); + if ( $this->is_woocommerce_request( $url ) ) { + // Report access can be missing for this request, so keep the stored chart data. + $this->_error = esc_html__( 'Unable to fetch the WooCommerce report. The user who saved this chart needs access to WooCommerce reports.', 'visualizer' ); + } return null; } diff --git a/classes/Visualizer/Source/Query.php b/classes/Visualizer/Source/Query.php index b08798c8..b72a142a 100644 --- a/classes/Visualizer/Source/Query.php +++ b/classes/Visualizer/Source/Query.php @@ -256,7 +256,7 @@ private function get_col_type( $col_num ) { * @return string */ private function html( $headers, $results ) { - return Visualizer_Render_Layout::show( 'db-wizard-results', $headers, $results ); + return Visualizer_Render_Layout::show( 'db-wizard-results', Visualizer_Module::sanitize_chart_data( $headers ), Visualizer_Module::sanitize_chart_data( $results ) ); } /** diff --git a/js/render-datatables.js b/js/render-datatables.js index 1cb43fc7..923156d0 100644 --- a/js/render-datatables.js +++ b/js/render-datatables.js @@ -138,7 +138,7 @@ } } - // remove this so that the eval does not fail. + // internal_title is the chart's admin label, not a DataTables option. delete chart.settings['internal_title']; var additional = []; diff --git a/tests/test-ajax.php b/tests/test-ajax.php index 61e7dc18..5d92294d 100644 --- a/tests/test-ajax.php +++ b/tests/test-ajax.php @@ -1124,8 +1124,6 @@ public function test_json_schedule_denied_for_chart_user_cannot_edit() { /** * A chart editor without report access cannot schedule a WooCommerce report import. - * - * @group ajax */ public function test_woocommerce_json_schedule_denied_without_report_capability() { $this->enable_pro(); @@ -1151,8 +1149,6 @@ public function test_woocommerce_json_schedule_denied_without_report_capability( /** * A report-capable chart editor can authorize future scheduled imports. - * - * @group ajax */ public function test_woocommerce_json_schedule_records_authorizing_user() { $this->enable_pro(); @@ -1178,6 +1174,158 @@ public function test_woocommerce_json_schedule_records_authorizing_user() { $this->assertSame( $this->admin_user_id, (int) get_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, true ) ); } + /** + * Switching a chart to another JSON source keeps the recorded report user. + */ + public function test_json_schedule_for_other_source_keeps_report_user() { + $this->enable_pro(); + $chart_id = $this->create_chart_for_user( $this->admin_user_id ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, $this->admin_user_id ); + wp_set_current_user( $this->admin_user_id ); + $_POST = array( + 'chart' => $chart_id, + 'time' => 12, + 'is_woocommerce_report' => 'false', + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_SCHEDULE . Visualizer_Plugin::VERSION ), + ); + + try { + $this->_handleAjax( Visualizer_Plugin::ACTION_JSON_SET_SCHEDULE ); + } catch ( WPAjaxDieContinueException $e ) { + // Expected after the JSON response. + } + + $this->assertSame( '', get_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true ) ); + $this->assertSame( $this->admin_user_id, (int) get_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, true ) ); + } + + /** + * Saving a new JSON endpoint makes the saving user the chart's report user. + */ + public function test_json_source_change_records_saving_user() { + $chart_id = $this->create_chart_for_user( $this->admin_user_id ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_URL, 'https://example.com/old.json' ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, $this->admin_user_id ); + $editor_id = $this->factory->user->create( array( 'role' => 'editor' ) ); + wp_set_current_user( $editor_id ); + + $this->handle_json_set_data( $chart_id, array( 'url' => 'https://example.com/new.json' ) ); + + $this->assertSame( 'https://example.com/new.json', get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_URL, true ) ); + $this->assertSame( $editor_id, (int) get_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, true ) ); + } + + /** + * The JSON import preview table carries no event attributes from the endpoint. + */ + public function test_json_preview_removes_event_attributes() { + $chart_id = $this->create_chart_for_user( $this->admin_user_id ); + wp_set_current_user( $this->admin_user_id ); + $filter = $this->mock_json_endpoint( array( array( 'name' => '' ) ) ); + + $_GET['security'] = wp_create_nonce( Visualizer_Plugin::ACTION_JSON_GET_DATA . Visualizer_Plugin::VERSION ); + $_POST['params'] = array( + 'url' => 'https://example.com/data.json', + 'method' => 'GET', + 'chart' => $chart_id, + 'root' => 'root', + ); + try { + $this->_handleAjax( Visualizer_Plugin::ACTION_JSON_GET_DATA ); + } catch ( WPAjaxDieContinueException $e ) { + // Expected after the JSON response. + } finally { + remove_filter( 'pre_http_request', $filter ); + } + + $response = json_decode( $this->_last_response ); + $this->assertTrue( $response->success, $this->_last_response ); + $this->assertStringContainsString( 'data->table ); + $this->assertStringNotContainsString( 'onerror', $response->data->table ); + } + + /** + * The preview rendered after saving a JSON import carries no event attributes. + */ + public function test_json_save_preview_removes_event_attributes() { + $chart_id = $this->create_chart_for_user( $this->admin_user_id ); + wp_set_current_user( $this->admin_user_id ); + + $this->handle_json_set_data( + $chart_id, + array( + 'header' => array( 'name' ), + 'type' => array( 'name' => 'string' ), + ), + array( array( 'name' => '' ) ) + ); + + $this->assertStringContainsString( 'canvas.data', $this->_last_response ); + $this->assertStringNotContainsString( 'onerror', $this->_last_response ); + } + + /** + * The preview rendered after a CSV upload carries no event attributes. + */ + public function test_csv_upload_preview_removes_event_attributes() { + $chart_id = $this->create_chart_for_user( $this->admin_user_id ); + wp_set_current_user( $this->admin_user_id ); + $file = wp_tempnam( 'visualizer.csv' ); + file_put_contents( $file, "Name,Value\nstring,number\n\"\",1\n" ); + $_FILES = array( + 'local_data' => array( + 'tmp_name' => $file, + 'name' => 'data.csv', + 'error' => 0, + ), + ); + $_GET = array( + 'nonce' => wp_create_nonce( 'visualizer-upload-data' ), + 'chart' => $chart_id, + ); + + try { + $this->_handleAjax( Visualizer_Plugin::ACTION_UPLOAD_DATA ); + } catch ( WPAjaxDieContinueException $e ) { + // Expected once the update page has rendered. + } catch ( WPAjaxDieStopException $e ) { + // Expected when the handler stops after rendering. + } finally { + unlink( $file ); + } + + $this->assertStringContainsString( 'canvas.data', $this->_last_response ); + $this->assertStringNotContainsString( 'onerror', $this->_last_response ); + } + + /** + * The database query preview table carries no event attributes from the results. + */ + public function test_query_preview_removes_event_attributes() { + $this->_setRole( 'administrator' ); + $this->enable_pro(); + $post_id = $this->factory->post->create( array( 'post_title' => '' ) ); + $this->assertStringContainsString( 'onerror', get_post_field( 'post_title', $post_id ) ); + + global $wpdb; + $_GET['security'] = wp_create_nonce( Visualizer_Plugin::ACTION_FETCH_DB_DATA . Visualizer_Plugin::VERSION ); + $_POST['params'] = array( + 'query' => 'SELECT post_title FROM ' . $wpdb->prefix . 'posts WHERE ID = ' . $post_id, + 'chart_id' => 1, + ); + try { + $this->_handleAjax( Visualizer_Plugin::ACTION_FETCH_DB_DATA ); + } catch ( WPAjaxDieContinueException $e ) { + // Expected after the JSON response. + } + + $response = json_decode( $this->_last_response ); + $this->assertTrue( $response->success, $this->_last_response ); + $this->assertStringContainsString( 'data->table ); + $this->assertStringNotContainsString( 'onerror', $response->data->table ); + } + /** * A user cannot replace another user's JSON chart data. */ @@ -1207,13 +1355,14 @@ public function test_json_set_data_denied_for_chart_user_cannot_edit() { /** * Mock the JSON endpoint so the set-data handler does not hit the network. * + * @param array> $rows The rows the endpoint returns. * @return callable The filter callback, for removal. */ - private function mock_json_endpoint() { - $filter = function () { + private function mock_json_endpoint( array $rows = array( array( 'name' => 'a', 'value' => 1 ) ) ) { + $filter = function () use ( $rows ) { return array( 'headers' => array(), - 'body' => wp_json_encode( array( array( 'name' => 'a', 'value' => 1 ) ) ), + 'body' => wp_json_encode( $rows ), 'response' => array( 'code' => 200, 'message' => '' ), 'cookies' => array(), 'filename' => null, @@ -1226,10 +1375,11 @@ private function mock_json_endpoint() { /** * Run the JSON set-data handler as the current user. * - * @param int $chart_id The chart being saved. - * @param array $post The POST fields to send on top of the defaults. + * @param int $chart_id The chart being saved. + * @param array $post The POST fields to send on top of the defaults. + * @param array> $rows The rows the endpoint returns. */ - private function handle_json_set_data( $chart_id, array $post ) { + private function handle_json_set_data( $chart_id, array $post, array $rows = array( array( 'name' => 'a', 'value' => 1 ) ) ) { $_GET = array( 'chart' => $chart_id, 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_DATA . Visualizer_Plugin::VERSION ), @@ -1246,7 +1396,7 @@ private function handle_json_set_data( $chart_id, array $post ) { $post ); - $filter = $this->mock_json_endpoint(); + $filter = $this->mock_json_endpoint( $rows ); try { $this->_handleAjax( Visualizer_Plugin::ACTION_JSON_SET_DATA ); } catch ( WPAjaxDieContinueException $e ) { diff --git a/tests/test-chart-data-sanitization.php b/tests/test-chart-data-sanitization.php index 0c4897cd..a9ddc067 100644 --- a/tests/test-chart-data-sanitization.php +++ b/tests/test-chart-data-sanitization.php @@ -24,6 +24,7 @@ public function test_chart_data_removes_active_markup() { '', 'Research & Development', '3 < 5', + 'assertStringNotContainsString( 'assertSame( 'Research & Development', $result[0][3] ); $this->assertSame( '3 < 5', $result[0][4] ); + $this->assertStringNotContainsString( ' 123, + 'post_content' => serialize( array( array( 'Revenue' ) ) ), + ); + $filter = array( $this, 'add_script_cell' ); + add_filter( Visualizer_Plugin::FILTER_GET_CHART_DATA, $filter ); + + $result = Visualizer_Module::get_chart_data( $chart, 'table' ); + + remove_filter( Visualizer_Plugin::FILTER_GET_CHART_DATA, $filter ); + $this->assertSame( 'Revenue', $result[0][0] ); + $this->assertStringNotContainsString( 'create_chart( array( array( 'Revenue', '' ) ) ); + $filter = array( $this, 'add_script_cell' ); + add_filter( Visualizer_Plugin::FILTER_GET_CHART_DATA, $filter ); + + $result = Visualizer_Gutenberg_Block::get_instance()->get_visualizer_data( array( 'id' => $chart_id ) ); + + remove_filter( Visualizer_Plugin::FILTER_GET_CHART_DATA, $filter ); + $this->assertSame( 'Revenue', $result['visualizer-data'][0][0] ); + $this->assertStringNotContainsString( 'assertStringNotContainsString( 'create_chart( array( array( 'Q1Q4', '' ) ) ); + $module = Visualizer_Plugin::instance()->getModule( Visualizer_Module_Chart::NAME ); + + $csv = $module->_getDataAs( $chart_id, 'csv' ); + $this->assertStringContainsString( 'Q1Q4', $csv['string'] ); + + $print = $module->_getDataAs( $chart_id, 'print' ); + $this->assertStringNotContainsString( 'onerror', $print['csv'] ); + + $editor = Visualizer_Render_Layout::show( 'editor-table', null, $chart_id, 'viz-html-table', false, true ); + $this->assertStringContainsString( esc_attr( 'Q1Q4' ), $editor ); + } + + /** + * Appends a row with a script cell. + * + * @param array> $data The chart data. + * @return array> + */ + public function add_script_cell( $data ) { + $data[] = array( '' ); + return $data; + } + + /** + * Creates a line chart with the given rows, stored as an administrator would. + * + * @param array> $rows The chart rows. + * @return int The chart ID. + */ + private function create_chart( $rows ) { $author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); - // Stored as an administrator would, so post content filtering leaves the serialized data intact. + // Post content filtering leaves the serialized data intact for an administrator. wp_set_current_user( $author_id ); $chart_id = self::factory()->post->create( array( 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, 'post_status' => 'publish', 'post_author' => $author_id, - 'post_content' => wp_slash( serialize( array( array( 'Revenue', '' ) ) ) ), + 'post_content' => wp_slash( serialize( $rows ) ), ) ); update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, 'line' ); update_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, array() ); - update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, array( array( 'label' => 'Label', 'type' => 'string' ) ) ); - - $result = Visualizer_Gutenberg_Block::get_instance()->get_visualizer_data( array( 'id' => $chart_id ) ); - - $this->assertSame( 'Revenue', $result['visualizer-data'][0][0] ); - $this->assertStringNotContainsString( ' 'Label', + 'type' => 'string', + ), + array( + 'label' => 'Value', + 'type' => 'string', + ), + ) + ); + return $chart_id; } } diff --git a/tests/test-remote-fetch.php b/tests/test-remote-fetch.php index 06f7931c..d487c130 100644 --- a/tests/test-remote-fetch.php +++ b/tests/test-remote-fetch.php @@ -708,6 +708,99 @@ public function test_json_source_mints_woocommerce_token_for_authorized_user() { delete_transient( 'visualizer_wc_token_' . $headers['X-Visualizer-Token'] ); } + /** + * The report access filter can grant the token to a user without the capability. + */ + public function test_report_access_filter_can_grant_token() { + $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); + wp_set_current_user( $user_id ); + add_filter( 'visualizer_can_fetch_woocommerce_reports', '__return_true' ); + + $headers = $this->capture_woocommerce_request_headers(); + + remove_filter( 'visualizer_can_fetch_woocommerce_reports', '__return_true' ); + $this->assertArrayHasKey( 'X-Visualizer-Token', $headers ); + delete_transient( 'visualizer_wc_token_' . $headers['X-Visualizer-Token'] ); + } + + /** + * The report access filter can withhold the token from a user with the capability. + */ + public function test_report_access_filter_can_withhold_token() { + $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); + $user = new WP_User( $user_id ); + $user->add_cap( 'view_woocommerce_reports' ); + wp_set_current_user( $user_id ); + add_filter( 'visualizer_can_fetch_woocommerce_reports', '__return_false' ); + + $headers = $this->capture_woocommerce_request_headers(); + + remove_filter( 'visualizer_can_fetch_woocommerce_reports', '__return_false' ); + $this->assertArrayNotHasKey( 'X-Visualizer-Token', $headers ); + } + + /** + * A failed WooCommerce report fetch is reported as a failure. + */ + public function test_failed_woocommerce_fetch_returns_false() { + $filter = function () { + return $this->response( 401, array(), '{"code":"woocommerce_rest_cannot_view"}' ); + }; + add_filter( 'pre_http_request', $filter ); + + $source = new Visualizer_Source_Json( + array( + 'url' => home_url( '/wp-json/wc/v3/reports/sales' ), + 'root' => 'root', + ) + ); + $result = $source->fetch(); + + remove_filter( 'pre_http_request', $filter ); + $this->assertFalse( $result ); + $this->assertNotEmpty( $source->get_error() ); + } + + /** + * A visitor's live refresh of a WooCommerce report chart keeps the stored data when the fetch fails. + */ + public function test_visitor_refresh_keeps_stored_woocommerce_data() { + $admin_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); + wp_set_current_user( $admin_id ); + $content = serialize( array( array( '10.00' ) ) ); + $chart_id = self::factory()->post->create( + array( + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, + 'post_status' => 'publish', + 'post_content' => wp_slash( $content ), + ) + ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, 'Visualizer_Source_Json' ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_URL, home_url( '/wp-json/wc/v3/reports/sales' ) ); + update_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_ROOT, 'root' ); + update_post_meta( + $chart_id, + Visualizer_Plugin::CF_SERIES, + array( + array( + 'label' => 'total_sales', + 'type' => 'number', + ), + ) + ); + wp_set_current_user( 0 ); + $filter = function () { + return $this->response( 401, array(), '{"code":"woocommerce_rest_cannot_view"}' ); + }; + add_filter( 'pre_http_request', $filter ); + + apply_filters( 'visualizer_schedule_refresh_chart', get_post( $chart_id ), $chart_id, false ); + + remove_filter( 'pre_http_request', $filter ); + $this->assertSame( $content, get_post_field( 'post_content', $chart_id, 'raw' ) ); + $this->assertNotEmpty( get_post_meta( $chart_id, Visualizer_Plugin::CF_ERROR, true ) ); + } + /** * Captures the headers generated for a same-site WooCommerce reports request. * From 765ab3b2a93a5b3bdc4e6f8315632983d0ad8257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Bulkevi=C4=8Dius?= Date: Sat, 14 Nov 2026 03:46:30 +0200 Subject: [PATCH 20/20] fix: keep stored values in editing paths and escape editor output Return stored rows to the AI builder and the chart ability, escape the text editor and preview headers, check refresh errors after the last read, and record the report user only when a user saves a different endpoint. Copies of a chart do not carry the original report user. --- classes/Visualizer/Module.php | 17 +++ classes/Visualizer/Module/AIBuilder.php | 4 +- classes/Visualizer/Module/Abilities.php | 4 +- classes/Visualizer/Module/Chart.php | 28 +--- classes/Visualizer/Module/Setup.php | 4 +- classes/Visualizer/Render/Layout.php | 8 +- tests/test-ajax.php | 165 ++++++++++++++++++++++++ tests/test-chart-data-sanitization.php | 26 ++++ tests/test-remote-fetch.php | 44 +++++++ 9 files changed, 268 insertions(+), 32 deletions(-) diff --git a/classes/Visualizer/Module.php b/classes/Visualizer/Module.php index 8fbb8977..d00b2517 100644 --- a/classes/Visualizer/Module.php +++ b/classes/Visualizer/Module.php @@ -924,6 +924,23 @@ function ( $matches ) { return $sanitize ? self::sanitize_chart_data( $altered ) : $altered; } + /** + * Saves a chart's JSON endpoint, recording the user who changes it as the WooCommerce report user. + * + * A scheduled refresh of the endpoint then uses this user's report access, + * not the access of whoever authorized an earlier endpoint. + * + * @param int $chart_id The chart ID. + * @param string $url The JSON endpoint. + * @return void + */ + public static function update_json_url( $chart_id, $url ) { + if ( get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_URL, true ) !== $url ) { + update_post_meta( $chart_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, get_current_user_id() ); + } + update_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_URL, $url ); + } + /** * Sanitize chart data before passing it to HTML-capable renderers. * diff --git a/classes/Visualizer/Module/AIBuilder.php b/classes/Visualizer/Module/AIBuilder.php index c97be184..931e7814 100644 --- a/classes/Visualizer/Module/AIBuilder.php +++ b/classes/Visualizer/Module/AIBuilder.php @@ -195,7 +195,7 @@ public function fetchChart(): void { $this->_verify_chart_access( $chart_id ); $series = get_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, true ); - $data = Visualizer_Module::get_chart_data( $chart, '', false ); + $data = Visualizer_Module::get_chart_data( $chart, '', false, false ); $code = get_post_meta( $chart_id, self::CF_D3_CODE, true ); $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true ); $title = ( is_array( $settings ) && ! empty( $settings['backend-title'] ) ) @@ -360,7 +360,7 @@ public function uploadData(): void { $source = new Visualizer_Source_Json( $params ); // Store config for sync - update_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_URL, $params['url'] ); + Visualizer_Module::update_json_url( $chart_id, $params['url'] ); update_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_ROOT, $params['root'] ); if ( ! empty( $_POST['json_schedule'] ) ) { update_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, intval( $_POST['json_schedule'] ) ); diff --git a/classes/Visualizer/Module/Abilities.php b/classes/Visualizer/Module/Abilities.php index 95c2cb43..87aefe17 100644 --- a/classes/Visualizer/Module/Abilities.php +++ b/classes/Visualizer/Module/Abilities.php @@ -598,7 +598,7 @@ public function executeGetChart( $input = array() ) { $type = (string) get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true ); $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type ); - $data = self::get_chart_data( $chart, $type ); + $data = self::get_chart_data( $chart, $type, true, false ); $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); $settings = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $settings, $chart->ID, $type ); if ( ! is_array( $settings ) ) { @@ -1048,7 +1048,7 @@ private function setJsonSource( $chart, $input, $hours, $dry_run ) { $this->clearSourceMeta( $chart->ID, true ); update_post_meta( $chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true ); $this->persistSource( $chart->ID, $source ); - update_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_URL, $params['url'] ); + self::update_json_url( $chart->ID, $params['url'] ); update_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_ROOT, $params['root'] ); $headers = array( 'method' => $params['method'] ); diff --git a/classes/Visualizer/Module/Chart.php b/classes/Visualizer/Module/Chart.php index c8f951e7..34d615ab 100644 --- a/classes/Visualizer/Module/Chart.php +++ b/classes/Visualizer/Module/Chart.php @@ -70,26 +70,6 @@ public function __construct( Visualizer_Plugin $plugin ) { $this->_addAjaxAction( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY, 'saveFilter' ); $this->_addFilter( 'visualizer_get_sidebar', 'getSidebar', 10, 2 ); - - $this->_addAction( 'added_post_meta', 'recordJsonSourceUser', null, 10, 3 ); - $this->_addAction( 'updated_post_meta', 'recordJsonSourceUser', null, 10, 3 ); - } - - /** - * Records the user who set a chart's JSON endpoint as its WooCommerce report user. - * - * A scheduled refresh of that endpoint then uses this user's report access, - * not the access of whoever authorized an earlier endpoint. - * - * @param int $meta_id The meta ID. - * @param int $object_id The post ID. - * @param string $meta_key The meta key. - * @return void - */ - public function recordJsonSourceUser( $meta_id, $object_id, $meta_key ) { - if ( Visualizer_Plugin::CF_JSON_URL === $meta_key ) { - update_post_meta( $object_id, Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER, get_current_user_id() ); - } } /** @@ -273,7 +253,7 @@ public function setJsonData() { update_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, $source->getSeries() ); update_post_meta( $chart->ID, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() ); update_post_meta( $chart->ID, Visualizer_Plugin::CF_DEFAULT_DATA, 0 ); - update_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_URL, $params['url'] ); + self::update_json_url( $chart->ID, $params['url'] ); update_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_ROOT, $params['root'] ); delete_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_HEADERS ); @@ -651,7 +631,8 @@ public function renderChartPages() { $post_meta = get_post_meta( $parent_chart_id ); $chart_id = $new_chart_id; foreach ( $post_meta as $key => $value ) { - if ( strpos( $key, 'visualizer-' ) !== false ) { + // A copy refreshes reports with its own author's access. + if ( strpos( $key, 'visualizer-' ) !== false && Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER !== $key ) { add_post_meta( $new_chart_id, $key, self::maybe_decode_content( $value[0] ) ); } } @@ -1495,7 +1476,8 @@ public function cloneChart() { } else { $post_meta = get_post_meta( $chart_id ); foreach ( $post_meta as $key => $value ) { - if ( strpos( $key, 'visualizer-' ) !== false ) { + // A copy refreshes reports with its own author's access. + if ( strpos( $key, 'visualizer-' ) !== false && Visualizer_Plugin::CF_WOOCOMMERCE_REPORT_USER !== $key ) { add_post_meta( $new_chart_id, $key, self::maybe_decode_content( $value[0] ) ); } } diff --git a/classes/Visualizer/Module/Setup.php b/classes/Visualizer/Module/Setup.php index 00a3fbca..3f530b35 100644 --- a/classes/Visualizer/Module/Setup.php +++ b/classes/Visualizer/Module/Setup.php @@ -384,6 +384,8 @@ public function refresh_db_for_chart( $chart, $chart_id, $force = false ) { return $chart; } + // Editable-table charts fetch again here, so check the error after this read. + $content = $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ); $error = $source->get_error(); if ( empty( $error ) ) { $this->disableRevisionsTemporarily(); @@ -406,7 +408,7 @@ public function refresh_db_for_chart( $chart, $chart_id, $force = false ) { wp_update_post( array( 'ID' => $chart_id, - 'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ), + 'post_content' => $content, ) ); diff --git a/classes/Visualizer/Render/Layout.php b/classes/Visualizer/Render/Layout.php index 33a27edb..ed9b5b21 100644 --- a/classes/Visualizer/Render/Layout.php +++ b/classes/Visualizer/Render/Layout.php @@ -411,7 +411,7 @@ public static function _renderTextEditor( $args ) { } ?>
- +
'; } else { - echo '' . $header . ''; + echo '' . esc_html( $header ) . ''; } } ?> @@ -479,8 +479,8 @@ public static function _renderEditorTable( $args ) { if ( $editable_data ) { echo ''; - echo ''; + echo '