Skip to content

Commit 15241b7

Browse files
Merge pull request #657 from contactashish13/issue-655
UX Changes to chart settings
2 parents 3f28e5c + e1faa78 commit 15241b7

File tree

16 files changed

+665
-616
lines changed

16 files changed

+665
-616
lines changed

classes/Visualizer/Module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ public static function get_chart_data( $chart, $type, $run_filter = true ) {
706706
$data = unserialize( html_entity_decode( $chart->post_content ) );
707707
$altered = array();
708708
foreach ( $data as $index => $array ) {
709-
if ( ! is_array( $index ) ) {
709+
if ( ! is_array( $index ) && is_array( $array ) ) {
710710
foreach ( $array as &$datum ) {
711711
if ( is_string( $datum ) ) {
712712
$datum = stripslashes( $datum );

classes/Visualizer/Module/Chart.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public function renderChartPages() {
534534
wp_register_style( 'visualizer-chosen', VISUALIZER_ABSURL . 'css/lib/chosen.min.css', array(), Visualizer_Plugin::VERSION );
535535

536536
wp_register_style( 'visualizer-frame', VISUALIZER_ABSURL . 'css/frame.css', array( 'visualizer-chosen' ), Visualizer_Plugin::VERSION );
537-
wp_register_script( 'visualizer-frame', VISUALIZER_ABSURL . 'js/frame.js', array( 'visualizer-chosen', 'jquery-ui-accordion' ), Visualizer_Plugin::VERSION, true );
537+
wp_register_script( 'visualizer-frame', VISUALIZER_ABSURL . 'js/frame.js', array( 'visualizer-chosen', 'jquery-ui-accordion', 'jquery-ui-tabs' ), Visualizer_Plugin::VERSION, true );
538538
wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
539539
wp_register_script(
540540
'visualizer-render',
@@ -575,6 +575,7 @@ public function renderChartPages() {
575575
// if the cancel button is clicked.
576576
$this->undoRevisions( $chart_id, true );
577577
} elseif ( isset( $_POST['save'] ) && 1 === intval( $_POST['save'] ) ) {
578+
$this->handlePermissions();
578579
// if the save button is clicked.
579580
$this->undoRevisions( $chart_id, false );
580581
} else {
@@ -591,7 +592,7 @@ public function renderChartPages() {
591592
$this->_handleTypesPage();
592593
break;
593594
default:
594-
do_action( 'visualizer_pro_handle_tab', $tab, $this->_chart );
595+
// this should never happen.
595596
break;
596597
}
597598
defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit();
@@ -652,13 +653,31 @@ private function loadCodeEditorAssets( $chart_id ) {
652653
return $table_col_mapping;
653654
}
654655

656+
/**
657+
* Handle permissions from the new conslidated settings sidebar.
658+
*/
659+
private function handlePermissions() {
660+
if ( ! Visualizer_Module::is_pro() ) {
661+
return;
662+
}
663+
664+
// we will not support old free and new pro.
665+
// handling new free and old pro.
666+
if ( has_action( 'visualizer_pro_handle_tab' ) ) {
667+
do_action( 'visualizer_pro_handle_tab', 'permissions', $this->_chart );
668+
} else {
669+
do_action( 'visualizer_handle_permissions', $this->_chart );
670+
}
671+
}
672+
655673
/**
656674
* Handle data and settings page
657675
*/
658676
private function _handleDataAndSettingsPage() {
659677
if ( isset( $_POST['map_api_key'] ) ) {
660678
update_option( 'visualizer-map-api-key', $_POST['map_api_key'] );
661679
}
680+
662681
if ( $_SERVER['REQUEST_METHOD'] === 'POST' && isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'] ) ) {
663682
if ( $this->_chart->post_status === 'auto-draft' ) {
664683
$this->_chart->post_status = 'publish';
@@ -691,7 +710,6 @@ private function _handleDataAndSettingsPage() {
691710
$render = new Visualizer_Render_Page_Send();
692711
$render->text = sprintf( '[visualizer id="%d"]', $this->_chart->ID );
693712
wp_iframe( array( $render, 'render' ) );
694-
695713
return;
696714
}
697715
$data = $this->_getChartArray();
@@ -743,6 +761,7 @@ private function _handleDataAndSettingsPage() {
743761
'loading' => esc_html__( 'Loading...', 'visualizer' ),
744762
'json_error' => esc_html__( 'An error occured in fetching data.', 'visualizer' ),
745763
'select_columns' => esc_html__( 'Please select a few columns to include in the chart.', 'visualizer' ),
764+
'save_settings' => esc_html__( 'The settings seem to have changed. If you want to update your data, please save the chart first to save your settings. If you continue, you may lose your changes.', 'visualizer' ),
746765
),
747766
'charts' => array(
748767
'canvas' => $data,

0 commit comments

Comments
 (0)