Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
de32477
fix: persist database results before saving charts
lucadobrescu Jul 10, 2026
58130b5
fix: wait for database save before chart save
lucadobrescu Jul 10, 2026
ce677c4
test: stabilize database-source e2e spec
lucadobrescu Jul 13, 2026
c35d72f
Sync branch [skip ci]
pirate-bot Jul 22, 2026
cea4ea6
Sync branch [skip ci]
pirate-bot Jul 22, 2026
2bcb43e
fix: check per-post edit_post capability in chart_data REST field
lucadobrescu Jul 27, 2026
6b05e98
fix: use can_edit_chart so contributor authors keep access to own charts
lucadobrescu Jul 29, 2026
97071aa
Sync branch [skip ci]
pirate-bot Jul 29, 2026
8e1f634
chore(deps-dev): bump phpstan/phpstan from 2.1.54 to 2.2.6 (#1351)
dependabot[bot] Jul 29, 2026
022ed18
chore(deps-dev): bump wp-coding-standards/wpcs from 3.3.0 to 3.4.1 (#…
dependabot[bot] Jul 29, 2026
f20d399
chore(deps): bump codeinwp/themeisle-sdk from 3.3.55 to 3.3.57 (#1349)
dependabot[bot] Jul 29, 2026
8951fbc
Merge origin/development into fix/1329-database-source-save
Copilot Jul 29, 2026
481eb0a
Merge pull request #1335 from Codeinwp/fix/1329-database-source-save
selul Jul 29, 2026
4094672
Merge pull request #1348 from Codeinwp/fix/605-chart-data-cap-check
kushh23 Jul 30, 2026
c7d2255
chore(deps-dev): bump dealerdirect/phpcodesniffer-composer-installer …
dependabot[bot] Jul 30, 2026
0f3d000
fix: gate AI Builder db_query behind super-admin + Pro to match class…
Jul 30, 2026
c385ff4
Merge pull request #1357 from Codeinwp/fix/587-ai-builder-db-query-pr…
kushh23 Jul 30, 2026
827e278
fix(e2e): make the suite target the actual wp-env instance (#1358)
Soare-Robert-Daniel Jul 30, 2026
229a0a4
fix: enforce per-chart authorization in AI Builder endpoints
lucadobrescu Jul 29, 2026
09e61d0
test: log in via wp-login POST instead of dashboard navigation
lucadobrescu Jul 29, 2026
f3a4d5b
fix: gate setup wizard endpoints behind manage_options and nonces
lucadobrescu Jul 29, 2026
7b30054
test: log in via wp-login POST instead of dashboard navigation
lucadobrescu Jul 29, 2026
889afa9
fix: strip tags from chart custom CSS at render time (#1355)
lucadobrescu Jul 30, 2026
3d7e77b
test: cover the AI Builder chart-access and workflow-binding guards
Soare-Robert-Daniel Jul 30, 2026
baf67a3
Merge pull request #1353 from Codeinwp/fix/aibuilder-chart-auth
Soare-Robert-Daniel Jul 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ artifacts
classes/Visualizer/Gutenberg/build
classes/Visualizer/ChartBuilder/build
classes/Visualizer/D3Renderer/build

# Local wp-env port pinning (per-checkout).
.wp-env.override.json
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"themes": [],
"mappings": {
"wp-content/mu-plugins/visualizer-e2e-force-lazy-render.php": "./tests/e2e/config/force-lazy-render.php"
"wp-content/mu-plugins": "./tests/e2e/config/mu-plugins"
},
"config": {
"WP_DEBUG": true,
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Gutenberg/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function register_rest_endpoints() {
* Get Post Meta Fields
*/
public function get_visualizer_data( $post ) {
if ( ! current_user_can( 'edit_posts' ) ) {
if ( ! Visualizer_Module::can_edit_chart( $post['id'] ) ) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ protected function get_inline_custom_css( $id, $settings ) {
$class_name = $id . $name;
$properties = implode( ' !important; ', array_filter( $attributes ) );
if ( ! empty( $properties ) ) {
$css .= '.' . $class_name . ' {' . $properties . ' !important;}';
$css .= wp_strip_all_tags( '.' . $class_name . ' {' . $properties . ' !important;}' );
$classes[ $name ] = $class_name;
}
}
Expand Down
12 changes: 10 additions & 2 deletions classes/Visualizer/Module/AIBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function _verify_create_nonce(): void {
* @param int $chart_id Chart ID.
*/
private function _verify_chart_access( $chart_id ): void {
if ( ! current_user_can( 'edit_post', $chart_id ) ) {
if ( ! self::can_edit_chart( $chart_id ) ) {
wp_send_json_error( array( 'message' => __( 'Unauthorized.', 'visualizer' ) ), 403 );
}
}
Expand Down Expand Up @@ -369,7 +369,7 @@ public function uploadData(): void {

// ── Database query ────────────────────────────────────────────────
case 'db_query':
if ( ! current_user_can( 'manage_options' ) && ! is_super_admin() ) {
if ( ! current_user_can( 'manage_options' ) || ! is_super_admin() || ! Visualizer_Module::is_pro() ) {
wp_send_json_error( array( 'message' => __( 'Action not allowed for this user.', 'visualizer' ) ), 403 );
}
if ( empty( $_POST['db_query'] ) ) {
Expand Down Expand Up @@ -502,6 +502,10 @@ public function generateChart(): void {
}
}

if ( ! empty( $workflow_id ) ) {
set_transient( 'viz_ai_wf_' . $workflow_id, get_current_user_id(), 6 * HOUR_IN_SECONDS );
}

wp_send_json_success(
array(
'workflow_id' => $workflow_id,
Expand All @@ -524,6 +528,10 @@ public function chartStatus(): void {
wp_send_json_error( array( 'message' => __( 'Missing workflow ID.', 'visualizer' ) ) );
}

if ( (int) get_transient( 'viz_ai_wf_' . $workflow_id ) !== get_current_user_id() ) {
wp_send_json_error( array( 'message' => __( 'Unauthorized.', 'visualizer' ) ), 403 );
}

$agents_url = VISUALIZER_AGENTS_URL;
$workflow_slug = $this->_get_workflow_slug();
$headers = $this->_get_agents_headers();
Expand Down
9 changes: 9 additions & 0 deletions classes/Visualizer/Module/Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ public function visualizer_enqueue_setup_wizard_scripts() {
* @return bool|void
*/
public function dismissWizard( $redirect_to_dashboard = true ) {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have permission to perform this action.', 'visualizer' ), '', array( 'response' => 403 ) );
}
if ( false !== $redirect_to_dashboard ) {
check_admin_referer( 'visualizer_dismiss_wizard' );
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$status = isset( $_REQUEST['status'] ) ? (int) $_REQUEST['status'] : 0;
update_option( 'visualizer_fresh_install', $status );
Expand All @@ -169,6 +175,9 @@ public function dismissWizard( $redirect_to_dashboard = true ) {
*/
public function visualizer_wizard_step_process() {
check_ajax_referer( VISUALIZER_ABSPATH, 'security' );
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json( array( 'status' => 0 ), 403 );
}
$step = ! empty( $_POST['step'] ) ? sanitize_text_field( wp_unslash( $_POST['step'] ) ) : 1;
switch ( $step ) {
case 'step_2':
Expand Down
79 changes: 45 additions & 34 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions js/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,34 @@

init_db_import_component();

var settings_button = document.querySelector( '#settings-button' );
if ( settings_button ) {
settings_button.addEventListener( 'click', function( event ){
$('body').trigger('visualizer:db:query:update', {});
if( $( '#db-chart-button' ).attr( 'data-current' ) !== 'filter' || $( '.visualizer-db-query' ).val().length === 0 ){
return;
}

event.preventDefault();
event.stopImmediatePropagation();

var query_saved = false;
var resume_save = function(){
query_saved = true;
settings_button.click();
};

$('body').one( 'visualizer:render:currentchart:update', resume_save );
$( '#thehole' ).one( 'load', function(){
$('body').off( 'visualizer:render:currentchart:update', resume_save );
if ( ! query_saved ) {
$( '#db-chart-button' ).trigger( 'click' );
}
} );
$( '#db-chart-button' ).trigger( 'click' );
}, true );
}

$('#visualizer-query-fetch').on('click', function(e){

$('body').trigger('visualizer:db:query:update', {});
Expand Down
13 changes: 8 additions & 5 deletions templates/setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
* @package Templates
*/

$dashboard_url = add_query_arg(
array(
'action' => 'visualizer_dismiss_wizard',
'status' => 0,
$dashboard_url = wp_nonce_url(
add_query_arg(
array(
'action' => 'visualizer_dismiss_wizard',
'status' => 0,
),
admin_url( 'admin.php' )
),
admin_url( 'admin.php' )
'visualizer_dismiss_wizard'
);

$chart_id = ! empty( $this->wizard_data['chart_id'] ) ? (int) $this->wizard_data['chart_id'] : '';
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/config/mu-plugins/enable-database-source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Enable database-source E2E tests for requests carrying the test cookie.
*/

if ( defined( 'TI_E2E_TESTING' ) && isset( $_COOKIE['visualizer_e2e_database_source'] ) ) {
defined( 'VISUALIZER_PRO_VERSION' ) || define( 'VISUALIZER_PRO_VERSION', '2.0.1' );

if ( ! class_exists( 'Visualizer_Pro' ) ) {
class Visualizer_Pro {
const ACTION_FETCH_DATA = 'visualizer-fetch-data';
const CF_PERMISSIONS = 'visualizer-permissions';
}
}

add_filter( 'visualizer_is_pro', '__return_true', PHP_INT_MAX );

add_filter(
'visualizer_pro_upsell_class',
function ( $class, $feature = '' ) {
return 'db-query' === $feature ? '' : $class;
},
PHP_INT_MAX,
2
);
}
Loading
Loading