Skip to content

Commit 4fb9b73

Browse files
Style gets to default when we edit > Cancel a chart
1 parent 2c6f298 commit 4fb9b73

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

classes/Visualizer/Module/Chart.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,16 @@ private function _handleDataAndSettingsPage() {
307307
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'] ) ) {
308308
if ( $this->_chart->post_status == 'auto-draft' ) {
309309
$this->_chart->post_status = 'publish';
310+
311+
// ensure that a revision is not created. If a revision is created it will have the proper data and the parent of the revision will have default data.
312+
// we do not want any difference in data so disable revisions temporarily.
313+
add_filter( 'wp_revisions_to_keep', '__return_false' );
310314
wp_update_post( $this->_chart->to_array() );
311315
}
312-
update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_SETTINGS, $_POST );
316+
// save meta data only when it is NOT being canceled.
317+
if ( ! ( isset( $_POST['cancel'] ) && 1 === intval( $_POST['cancel'] ) ) ) {
318+
update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_SETTINGS, $_POST );
319+
}
313320
$render = new Visualizer_Render_Page_Send();
314321
$render->text = sprintf( '[visualizer id="%d"]', $this->_chart->ID );
315322
wp_iframe( array( $render, 'render' ) );

0 commit comments

Comments
 (0)