diff --git a/classes/Visualizer/Module/Chart.php b/classes/Visualizer/Module/Chart.php index 662a2a0a..8e852188 100644 --- a/classes/Visualizer/Module/Chart.php +++ b/classes/Visualizer/Module/Chart.php @@ -252,11 +252,9 @@ public function renderChartPages() { // dispatch pages $this->_chart = $chart; switch ( filter_input( INPUT_GET, 'tab' ) ) { - case 'data': - $this->_handleDataPage(); - break; case 'settings': - $this->_handleSettingsPage(); + // changed by Ash/Upwork + $this->_handleDataAndSettingsPage(); break; case 'type': default: @@ -294,7 +292,8 @@ private function _handleTypesPage() { } // redirect to next tab - wp_redirect( add_query_arg( 'tab', 'data' ) ); + // changed by Ash/Upwork + wp_redirect( add_query_arg( 'tab', 'settings' ) ); return; } } @@ -411,6 +410,76 @@ private function _handleSettingsPage() { wp_iframe( array( $render, 'render') ); } + + // changed by Ash/Upwork + private function _handleDataAndSettingsPage(){ + if ( $_SERVER['REQUEST_METHOD'] == 'POST' && wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ) ) ) { + if ( $this->_chart->post_status == 'auto-draft' ) { + $this->_chart->post_status = 'publish'; + wp_update_post( $this->_chart->to_array() ); + } + + update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_SETTINGS, $_POST ); + + $render = new Visualizer_Render_Page_Send(); + $render->text = sprintf( '[visualizer id="%d"]', $this->_chart->ID ); + + wp_iframe( array( $render, 'render') ); + return; + } + + $data = $this->_getChartArray(); + + $sidebar = ''; + $sidebar_class = 'Visualizer_Render_Sidebar_Type_' . ucfirst( $data['type'] ); + if ( class_exists( $sidebar_class, true ) ) { + $sidebar = new $sidebar_class( $data['settings'] ); + $sidebar->__series = $data['series']; + $sidebar->__data = $data['data']; + } + + unset( $data['settings']['width'], $data['settings']['height'] ); + + wp_enqueue_style( 'visualizer-frame' ); + wp_enqueue_style( 'wp-color-picker' ); + wp_enqueue_style( 'visualizer-frame' ); + + wp_enqueue_script( 'visualizer-preview' ); + wp_enqueue_script( 'visualizer-render' ); + wp_localize_script( 'visualizer-render', 'visualizer', array( + 'l10n' => array( + 'remotecsv_prompt' => esc_html__( 'Please, enter the URL of CSV file:', Visualizer_Plugin::NAME ), + 'invalid_source' => esc_html__( 'You have entered invalid URL. Please, insert proper URL.', Visualizer_Plugin::NAME ), + ), + 'charts' => array( + 'canvas' => $data, + ), + ) ); + + $render = new Visualizer_Render_Page_Data(); + $render->chart = $this->_chart; + $render->type = $data['type']; + + $render->sidebar = $sidebar; + if ( filter_input( INPUT_GET, 'library', FILTER_VALIDATE_BOOLEAN ) ) { + $render->button = filter_input( INPUT_GET, 'action' ) == Visualizer_Plugin::ACTION_EDIT_CHART + ? esc_html__( 'Save Chart', Visualizer_Plugin::NAME ) + : esc_html__( 'Create Chart', Visualizer_Plugin::NAME ); + } else { + $render->button = esc_attr__( 'Insert Chart', Visualizer_Plugin::NAME ); + } + + if( defined( 'Visualizer_Pro' ) ){ + global $Visualizer_Pro; + $Visualizer_Pro->_enqueueScriptsAndStyles($data); + } + + $this->_addAction( 'admin_head', 'renderFlattrScript' ); + + wp_iframe( array( $render, 'render') ); + } + // changed by Ash/Upwork + /** * Renders flattr script in the iframe
* diff --git a/classes/Visualizer/Plugin.php b/classes/Visualizer/Plugin.php index 262c7a8f..2ba86346 100644 --- a/classes/Visualizer/Plugin.php +++ b/classes/Visualizer/Plugin.php @@ -30,7 +30,7 @@ class Visualizer_Plugin { const NAME = 'visualizer'; - const VERSION = '1.5'; + const VERSION = '1.5.2'; // custom post types const CPT_VISUALIZER = 'visualizer'; diff --git a/classes/Visualizer/Render/Page/Data.php b/classes/Visualizer/Render/Page/Data.php index e1939aa8..af0b490a 100644 --- a/classes/Visualizer/Render/Page/Data.php +++ b/classes/Visualizer/Render/Page/Data.php @@ -65,13 +65,11 @@ protected function _renderSidebarContent() { 'chart' => $this->chart->ID, ), admin_url( 'admin-ajax.php' ) ); - echo ''; - esc_html_e( "Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).", Visualizer_Plugin::NAME ); + esc_html_e( "Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).", Visualizer_Plugin::NAME ); echo '
'; echo ''; @@ -89,7 +87,7 @@ protected function _renderSidebarContent() { esc_attr_e( 'From Computer', Visualizer_Plugin::NAME ); echo '