Skip to content

Commit 295f1ef

Browse files
release
- [Fix] Import from JSON: Reordering columns only reorders the label, not the associated data - [Fix] numberFormat option doesn't apply in Bar charts when using annotations - [Fix] Google GEO chart is not rendering if 3rd data column is added
2 parents 63874fb + 965ece8 commit 295f1ef

File tree

16 files changed

+87
-44
lines changed

16 files changed

+87
-44
lines changed

bin/wp-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ docker exec $args visualizer_wordpress wp --allow-root core install --url="http:
2323
# update core
2424
docker exec $args visualizer_wordpress chown -R www-data:www-data /var/www/html/
2525
docker exec $args visualizer_wordpress chmod 0777 -R /var/www/html/wp-content
26-
docker exec $args visualizer_wordpress wp --allow-root core update
26+
docker exec $args visualizer_wordpress wp --allow-root core update --version=5.5
2727
docker exec $args visualizer_wordpress wp --allow-root core update-db
2828

2929
# install required external plugins

classes/Visualizer/Gutenberg/build/block.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/Visualizer/Gutenberg/src/Components/ChartSelect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class ChartSelect extends Component {
147147
</InspectorControls>
148148
}
149149

150-
<div className="visualizer-settings__chart">
150+
<div className="visualizer-settings__chart" data-chart-type={ chart }>
151151

152152
{ ( null !== this.props.chart ) &&
153153

classes/Visualizer/Gutenberg/src/Components/Charts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Charts extends Component {
132132
}
133133

134134
return (
135-
<div className="visualizer-settings__charts-single" key={ `chart-${ charts[i].id }` }>
135+
<div className="visualizer-settings__charts-single" data-chart-type={ chart } key={ `chart-${ charts[i].id }` }>
136136

137137
<div className="visualizer-settings__charts-title">
138138
{ title }

classes/Visualizer/Module/Chart.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ public function setJsonData() {
215215
$chart = get_post( $chart_id );
216216

217217
$source = new Visualizer_Source_Json( $params );
218+
update_post_meta( $chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true );
218219
$source->fetchFromEditableTable();
219220

220-
$content = $source->getData();
221+
$content = $source->getData( get_post_meta( $chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) );
221222
$chart->post_content = $content;
222223
wp_update_post( $chart->to_array() );
223224
update_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, $source->getSeries() );
@@ -266,7 +267,7 @@ public function setJsonData() {
266267

267268
$render = new Visualizer_Render_Page_Update();
268269
$render->id = $chart->ID;
269-
$render->data = json_encode( $source->getRawData() );
270+
$render->data = json_encode( $source->getRawData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) );
270271
$render->series = json_encode( $source->getSeries() );
271272
$render->render();
272273

@@ -498,7 +499,7 @@ public function renderChartPages() {
498499
'post_title' => 'Visualization',
499500
'post_author' => get_current_user_id(),
500501
'post_status' => 'auto-draft',
501-
'post_content' => $source->getData(),
502+
'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ),
502503
)
503504
);
504505
if ( $chart_id && ! is_wp_error( $chart_id ) ) {
@@ -851,7 +852,7 @@ private function _handleTypesPage() {
851852
if ( filter_var( get_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_DEFAULT_DATA, true ), FILTER_VALIDATE_BOOLEAN ) ) {
852853
$source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $type . '.csv' );
853854
$source->fetch();
854-
$this->_chart->post_content = $source->getData();
855+
$this->_chart->post_content = $source->getData( get_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) );
855856
wp_update_post( $this->_chart->to_array() );
856857
update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_SERIES, $source->getSeries() );
857858
}
@@ -1087,7 +1088,7 @@ public function uploadData() {
10871088

10881089
if ( $source ) {
10891090
if ( $source->fetch() ) {
1090-
$content = $source->getData();
1091+
$content = $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) );
10911092
$populate = true;
10921093
if ( is_string( $content ) && is_array( unserialize( $content ) ) ) {
10931094
$json = unserialize( $content );
@@ -1114,7 +1115,7 @@ public function uploadData() {
11141115
$settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
11151116

11161117
$render->id = $chart->ID;
1117-
$render->data = json_encode( $source->getRawData() );
1118+
$render->data = json_encode( $source->getRawData( get_post_meta( $chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) );
11181119
$render->series = json_encode( $source->getSeries() );
11191120
$render->settings = json_encode( $settings );
11201121
} else {
@@ -1349,10 +1350,10 @@ public function saveQuery() {
13491350
wp_update_post(
13501351
array(
13511352
'ID' => $chart_id,
1352-
'post_content' => $source->getData(),
1353+
'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ),
13531354
)
13541355
);
1355-
$render->data = json_encode( $source->getRawData() );
1356+
$render->data = json_encode( $source->getRawData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ) );
13561357
$render->series = json_encode( $source->getSeries() );
13571358
$render->id = $chart_id;
13581359
} else {

classes/Visualizer/Module/Frontend.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ function endpoint_register() {
108108
'visualizer/v' . VISUALIZER_REST_VERSION,
109109
'/action/(?P<chart>\d+)/(?P<type>.+)/',
110110
array(
111-
'methods' => 'GET',
111+
// POST is required for save/cancel, GET for all others
112+
'methods' => array( 'POST', 'GET' ),
112113
'args' => array(
113114
'chart' => array(
114115
'required' => true,
@@ -119,11 +120,17 @@ function endpoint_register() {
119120
'type' => array(
120121
'required' => true,
121122
'type' => 'string',
122-
'enum' => array_keys( $this->get_actions() ),
123+
'enum' => array_merge( array( 'save', 'cancel' ), array_keys( $this->get_actions() ) ),
123124
),
124125
),
125126
'permission_callback' => function ( WP_REST_Request $request ) {
126127
$chart_id = filter_var( sanitize_text_field( $request->get_param( 'chart' ), FILTER_VALIDATE_INT ) );
128+
if ( ! empty( $chart_id ) && in_array( $request->get_param( 'type' ), array( 'save', 'cancel' ), true ) ) {
129+
// let save and cancel go without any check as past version of pro
130+
// did not send the X-WP-Nonce
131+
// we can change this at a later date.
132+
return true;
133+
}
127134
return ! empty( $chart_id ) && apply_filters( 'visualizer_pro_show_chart', true, $chart_id );
128135
},
129136
'callback' => array( $this, 'perform_action' ),

classes/Visualizer/Module/Setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function refresh_db_for_chart( $chart, $chart_id, $force = false ) {
309309
wp_update_post(
310310
array(
311311
'ID' => $chart_id,
312-
'post_content' => $source->getData(),
312+
'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ),
313313
)
314314
);
315315

classes/Visualizer/Plugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class Visualizer_Plugin {
2929

3030
const NAME = 'visualizer';
31-
const VERSION = '3.4.6';
31+
const VERSION = '3.4.7';
3232

3333
// custom post types
3434
const CPT_VISUALIZER = 'visualizer';
@@ -45,6 +45,7 @@ class Visualizer_Plugin {
4545

4646
const CF_SOURCE_FILTER = 'visualizer-source-filter';
4747
const CF_FILTER_CONFIG = 'visualizer-filter-config';
48+
const CF_EDITABLE_TABLE = 'visualizer-editable-table';
4849

4950
// custom actions
5051
const ACTION_GET_CHARTS = 'visualizer-get-charts';

classes/Visualizer/Source.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ public function getSeries() {
141141
* @access public
142142
* @return string The serialized array of data.
143143
*/
144-
public function getData() {
144+
public function getData( $fetch_from_editable_table = false ) {
145+
if ( $fetch_from_editable_table ) {
146+
$this->_fetchDataFromEditableTable();
147+
}
145148
return serialize( $this->_data );
146149
}
147150

@@ -153,7 +156,10 @@ public function getData() {
153156
* @access public
154157
* @return array
155158
*/
156-
public function getRawData() {
159+
public function getRawData( $fetch_from_editable_table = false ) {
160+
if ( $fetch_from_editable_table ) {
161+
$this->_fetchDataFromEditableTable();
162+
}
157163
return $this->_data;
158164
}
159165

@@ -443,7 +449,6 @@ private function _fetchSeriesFromEditableTable() {
443449
* @access private
444450
*/
445451
private function _fetchDataFromEditableTable() {
446-
$params = $this->_args;
447452
$headers = wp_list_pluck( $this->_series, 'label' );
448453
$this->fetch();
449454

@@ -452,7 +457,10 @@ private function _fetchDataFromEditableTable() {
452457

453458
foreach ( $data as $line ) {
454459
$data_row = array();
455-
foreach ( $line as $header => $value ) {
460+
// we have to make sure we are fetching the data in the right order
461+
// in case the columns have been reordered
462+
foreach ( $headers as $header ) {
463+
$value = $line[ $header ];
456464
// phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
457465
if ( in_array( $header, $headers ) ) {
458466
$data_row[] = $value;

css/media.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Version: 3.4.6
2+
Version: 3.4.7
33
*/
44
#visualizer-library-view {
55
padding: 30px 10px 10px 30px;

0 commit comments

Comments
 (0)