Skip to content

Commit 0217149

Browse files
committed
Merge pull request #65 from Codeinwp/development
Development
2 parents 8fecee9 + 7478dde commit 0217149

File tree

10 files changed

+278
-56
lines changed

10 files changed

+278
-56
lines changed

classes/Visualizer/Module/Chart.php

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,9 @@ public function renderChartPages() {
252252
// dispatch pages
253253
$this->_chart = $chart;
254254
switch ( filter_input( INPUT_GET, 'tab' ) ) {
255-
case 'data':
256-
$this->_handleDataPage();
257-
break;
258255
case 'settings':
259-
$this->_handleSettingsPage();
256+
// changed by Ash/Upwork
257+
$this->_handleDataAndSettingsPage();
260258
break;
261259
case 'type':
262260
default:
@@ -294,7 +292,8 @@ private function _handleTypesPage() {
294292
}
295293

296294
// redirect to next tab
297-
wp_redirect( add_query_arg( 'tab', 'data' ) );
295+
// changed by Ash/Upwork
296+
wp_redirect( add_query_arg( 'tab', 'settings' ) );
298297
return;
299298
}
300299
}
@@ -411,6 +410,76 @@ private function _handleSettingsPage() {
411410
wp_iframe( array( $render, 'render') );
412411
}
413412

413+
414+
// changed by Ash/Upwork
415+
private function _handleDataAndSettingsPage(){
416+
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ) ) ) {
417+
if ( $this->_chart->post_status == 'auto-draft' ) {
418+
$this->_chart->post_status = 'publish';
419+
wp_update_post( $this->_chart->to_array() );
420+
}
421+
422+
update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_SETTINGS, $_POST );
423+
424+
$render = new Visualizer_Render_Page_Send();
425+
$render->text = sprintf( '[visualizer id="%d"]', $this->_chart->ID );
426+
427+
wp_iframe( array( $render, 'render') );
428+
return;
429+
}
430+
431+
$data = $this->_getChartArray();
432+
433+
$sidebar = '';
434+
$sidebar_class = 'Visualizer_Render_Sidebar_Type_' . ucfirst( $data['type'] );
435+
if ( class_exists( $sidebar_class, true ) ) {
436+
$sidebar = new $sidebar_class( $data['settings'] );
437+
$sidebar->__series = $data['series'];
438+
$sidebar->__data = $data['data'];
439+
}
440+
441+
unset( $data['settings']['width'], $data['settings']['height'] );
442+
443+
wp_enqueue_style( 'visualizer-frame' );
444+
wp_enqueue_style( 'wp-color-picker' );
445+
wp_enqueue_style( 'visualizer-frame' );
446+
447+
wp_enqueue_script( 'visualizer-preview' );
448+
wp_enqueue_script( 'visualizer-render' );
449+
wp_localize_script( 'visualizer-render', 'visualizer', array(
450+
'l10n' => array(
451+
'remotecsv_prompt' => esc_html__( 'Please, enter the URL of CSV file:', Visualizer_Plugin::NAME ),
452+
'invalid_source' => esc_html__( 'You have entered invalid URL. Please, insert proper URL.', Visualizer_Plugin::NAME ),
453+
),
454+
'charts' => array(
455+
'canvas' => $data,
456+
),
457+
) );
458+
459+
$render = new Visualizer_Render_Page_Data();
460+
$render->chart = $this->_chart;
461+
$render->type = $data['type'];
462+
463+
$render->sidebar = $sidebar;
464+
if ( filter_input( INPUT_GET, 'library', FILTER_VALIDATE_BOOLEAN ) ) {
465+
$render->button = filter_input( INPUT_GET, 'action' ) == Visualizer_Plugin::ACTION_EDIT_CHART
466+
? esc_html__( 'Save Chart', Visualizer_Plugin::NAME )
467+
: esc_html__( 'Create Chart', Visualizer_Plugin::NAME );
468+
} else {
469+
$render->button = esc_attr__( 'Insert Chart', Visualizer_Plugin::NAME );
470+
}
471+
472+
if( defined( 'Visualizer_Pro' ) ){
473+
global $Visualizer_Pro;
474+
$Visualizer_Pro->_enqueueScriptsAndStyles($data);
475+
}
476+
477+
$this->_addAction( 'admin_head', 'renderFlattrScript' );
478+
479+
wp_iframe( array( $render, 'render') );
480+
}
481+
// changed by Ash/Upwork
482+
414483
/**
415484
* Renders flattr script in the iframe <head>
416485
*

classes/Visualizer/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class Visualizer_Plugin {
3131

3232
const NAME = 'visualizer';
33-
const VERSION = '1.5';
33+
const VERSION = '1.5.2';
3434

3535
// custom post types
3636
const CPT_VISUALIZER = 'visualizer';

classes/Visualizer/Render/Page/Data.php

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ protected function _renderSidebarContent() {
6565
'chart' => $this->chart->ID,
6666
), admin_url( 'admin-ajax.php' ) );
6767

68-
echo '<li class="group open">';
69-
echo '<h3 class="group-title">', esc_html__( 'Upload CSV File', Visualizer_Plugin::NAME ), '</h3>';
70-
echo '<div class="group-content">';
68+
echo '<input type="button" name="back_button" class="return-settings-btn preview-btn hidden-setting" value="&laquo; Back">';
69+
echo '<div class="initial-screen">';
7170
echo '<iframe id="thehole" name="thehole"></iframe>';
72-
7371
echo '<p class="group-description">';
74-
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 );
72+
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 );
7573
echo '</p>';
7674

7775
echo '<p class="group-description">';
@@ -89,7 +87,7 @@ protected function _renderSidebarContent() {
8987
esc_attr_e( 'From Computer', Visualizer_Plugin::NAME );
9088
echo '</div>';
9189

92-
echo '<a id="" class="button from-web from-web-btn" href="javascript:;">', esc_html__( 'From Web', Visualizer_Plugin::NAME ), '</a>';
90+
echo '<a id="remote-file" class="button from-web from-web-btn" href="javascript:;">', esc_html__( 'From Web', Visualizer_Plugin::NAME ), '</a>';
9391
// Added by Ash/Upwork
9492
if( defined( 'Visualizer_Pro' ) ){
9593
global $Visualizer_Pro;
@@ -107,16 +105,27 @@ protected function _renderSidebarContent() {
107105
$Visualizer_Pro->_addEditorElements();
108106
}else{
109107
?>
110-
<a href="<?php echo Visualizer_Plugin::PRO_TEASER_URL;?>" title="<?php echo Visualizer_Plugin::PRO_TEASER_TITLE;?>" target="_new">
108+
<a href="<?php echo Visualizer_Plugin::PRO_TEASER_URL;?>" title="<?php echo Visualizer_Plugin::PRO_TEASER_TITLE;?>" class="check-pro-btn" target="_new">
111109
<input type="button" class="button preview preview-btn" id="existing-chart-free" value="<?php esc_attr_e( 'Check PRO Version ', Visualizer_Plugin::NAME );?>">
112110
</a>
111+
112+
113113
<?php
114114
}
115+
116+
echo'<input type="button" name="advanced_button" class="advanced-settings-btn preview-btn" value="'. __( 'Advanced', Visualizer_Plugin::NAME ).' &raquo;">';
115117
// Added by Ash/Upwork
116118

117119
echo '</div>';
118120
echo '</div>';
119-
echo '</li>';
121+
122+
// changed by Ash/Upwork
123+
echo '<div class= "second-screen hidden-setting">';
124+
echo '<form id="settings-form" action="', add_query_arg( 'nonce', wp_create_nonce() ), '" method="post">';
125+
echo $this->sidebar;
126+
echo '</form>';
127+
echo '</div>';
128+
// changed by Ash/Upwork
120129
}
121130

122131
/**
@@ -127,12 +136,16 @@ protected function _renderSidebarContent() {
127136
* @access protected
128137
*/
129138
protected function _renderToolbar() {
130-
echo '<a class="button button-large" href="', add_query_arg( 'tab', false ), '">';
139+
// changed by Ash/Upwork
140+
echo '<div class="toolbar-div">';
141+
echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
131142
esc_html_e( 'Back', Visualizer_Plugin::NAME );
132143
echo '</a>';
133-
echo '<a class="button button-large button-primary push-right" href="', add_query_arg( 'tab', 'settings' ), '">';
134-
esc_html_e( 'Next', Visualizer_Plugin::NAME );
135-
echo '</a>';
144+
echo '</div>';
145+
echo '</div>';
146+
147+
148+
echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
136149
}
137150

138-
}
151+
}

0 commit comments

Comments
 (0)