Skip to content

Commit 12299a8

Browse files
make sure import from chart is working fine #47
1 parent 2236d8e commit 12299a8

File tree

3 files changed

+47
-30
lines changed

3 files changed

+47
-30
lines changed

classes/Visualizer/Module/Chart.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ public function __construct( Visualizer_Plugin $plugin ) {
6161

6262
// Added by Ash/Upwork
6363
$this->_addAjaxAction( Visualizer_Plugin::ACTION_EXPORT_DATA, 'exportData' );
64-
if ( defined( 'Visualizer_Pro' ) ) {
65-
global $Visualizer_Pro;
66-
list($action, $name, $class) = $Visualizer_Pro->_getAjaxAction( $this );
67-
$this->_addAjaxAction( $action, $name, $class );
68-
}
6964
// Added by Ash/Upwork
7065
}
7166

@@ -77,12 +72,12 @@ public function __construct( Visualizer_Plugin $plugin ) {
7772
* @access private
7873
* @param array $results The response array.
7974
*/
80-
public function _sendResponse( $results ) {
75+
public static function _sendResponse( $results ) {
8176
header( 'Content-type: application/json' );
8277
nocache_headers();
8378

8479
echo json_encode( $results );
85-
exit;
80+
wp_die();
8681
}
8782

8883
/**
@@ -153,7 +148,7 @@ public function getCharts() {
153148
$charts[] = $chart_data;
154149
}
155150

156-
$this->_sendResponse( array(
151+
self::_sendResponse( array(
157152
'success' => true,
158153
'data' => $charts,
159154
'total' => $query->max_num_pages,
@@ -188,7 +183,7 @@ public function deleteChart() {
188183
}
189184

190185
if ( $is_post ) {
191-
$this->_sendResponse( array( 'success' => $success ) );
186+
self::_sendResponse( array( 'success' => $success ) );
192187
}
193188

194189
wp_redirect( wp_get_referer() );

classes/Visualizer/Render/Page/Data.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,33 @@ class="dashicons dashicons-lock"></span></h2>
150150
<div>
151151
<p class="group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
152152
<form>
153-
<select name="vz-import-from-chart" id="vz-import-from-chart"
154-
class="visualizer-select">
155-
<option value="#"><?php _e( 'Chart #123', 'visualizer' ); ?></option>
153+
<select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
154+
<?php
155+
$fetch_link = add_query_arg( array(
156+
'action' => Visualizer_Pro::ACTION_FETCH_DATA,
157+
'nonce' => wp_create_nonce(),
158+
), admin_url( 'admin-ajax.php' ) );
159+
160+
$query_args_charts = array(
161+
'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
162+
'posts_per_page' => -1,
163+
'no_found_rows' => true,
164+
);
165+
$charts = array();
166+
$query = new WP_Query( $query_args_charts );
167+
while ( $query->have_posts() ) {
168+
$chart = $query->next_post();
169+
$settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
170+
?>
171+
<option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option>
172+
<?php
173+
}
174+
?>
175+
156176
</select>
157177
</form>
178+
<input type="button" id="existing-chart" class="button button-primary"
179+
value="<?php _e( 'Import Chart', 'visualizer' ); ?>" data-viz-link="<?php echo $fetch_link;?>">
158180
<?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
159181
</div>
160182
</div>

languages/visualizer.pot

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ msgid ""
44
msgstr ""
55
"Project-Id-Version: Visualizer: Charts and Graphs Lite 2.0.0\n"
66
"Report-Msgid-Bugs-To: https://github.com/Codeinwp/visualizer/issues\n"
7-
"POT-Creation-Date: 2017-03-16 09:39:48+00:00\n"
7+
"POT-Creation-Date: 2017-03-16 15:47:05+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
@@ -101,28 +101,28 @@ msgstr ""
101101
msgid "Pro Addon"
102102
msgstr ""
103103

104-
#: classes/Visualizer/Module/Chart.php:332
105-
#: classes/Visualizer/Module/Chart.php:395
104+
#: classes/Visualizer/Module/Chart.php:327
105+
#: classes/Visualizer/Module/Chart.php:390
106106
msgid "You have entered invalid URL. Please, insert proper URL."
107107
msgstr ""
108108

109-
#: classes/Visualizer/Module/Chart.php:409
109+
#: classes/Visualizer/Module/Chart.php:404
110110
msgid "Save Chart"
111111
msgstr ""
112112

113-
#: classes/Visualizer/Module/Chart.php:410
113+
#: classes/Visualizer/Module/Chart.php:405
114114
msgid "Create Chart"
115115
msgstr ""
116116

117-
#: classes/Visualizer/Module/Chart.php:412
117+
#: classes/Visualizer/Module/Chart.php:407
118118
msgid "Insert Chart"
119119
msgstr ""
120120

121-
#: classes/Visualizer/Module/Chart.php:470
121+
#: classes/Visualizer/Module/Chart.php:465
122122
msgid "CSV file with chart data was not uploaded. Please, try again."
123123
msgstr ""
124124

125-
#: classes/Visualizer/Module/Chart.php:485
125+
#: classes/Visualizer/Module/Chart.php:480
126126
msgid "CSV file is broken or invalid. Please, try again."
127127
msgstr ""
128128

@@ -282,39 +282,39 @@ msgstr ""
282282
msgid "You can import here data from your previously created charts"
283283
msgstr ""
284284

285-
#: classes/Visualizer/Render/Page/Data.php:155
286-
msgid "Chart #123"
285+
#: classes/Visualizer/Render/Page/Data.php:179
286+
msgid "Import Chart"
287287
msgstr ""
288288

289-
#: classes/Visualizer/Render/Page/Data.php:164
289+
#: classes/Visualizer/Render/Page/Data.php:186
290290
msgid "Edit current data"
291291
msgstr ""
292292

293-
#: classes/Visualizer/Render/Page/Data.php:172
293+
#: classes/Visualizer/Render/Page/Data.php:194
294294
msgid "You can manually edit the chart data using the spreadsheet like editor."
295295
msgstr ""
296296

297-
#: classes/Visualizer/Render/Page/Data.php:174
297+
#: classes/Visualizer/Render/Page/Data.php:196
298298
msgid "View Editor"
299299
msgstr ""
300300

301-
#: classes/Visualizer/Render/Page/Data.php:174
301+
#: classes/Visualizer/Render/Page/Data.php:196
302302
msgid "Show Chart"
303303
msgstr ""
304304

305-
#: classes/Visualizer/Render/Page/Data.php:184
305+
#: classes/Visualizer/Render/Page/Data.php:206
306306
msgid "Advanced Settings"
307307
msgstr ""
308308

309-
#: classes/Visualizer/Render/Page/Data.php:187
309+
#: classes/Visualizer/Render/Page/Data.php:209
310310
msgid "Chart Settings"
311311
msgstr ""
312312

313-
#: classes/Visualizer/Render/Page/Data.php:198
313+
#: classes/Visualizer/Render/Page/Data.php:220
314314
msgid "Rate our plugin"
315315
msgstr ""
316316

317-
#: classes/Visualizer/Render/Page/Data.php:217
317+
#: classes/Visualizer/Render/Page/Data.php:239
318318
#: classes/Visualizer/Render/Page/Settings.php:55
319319
msgid "Back"
320320
msgstr ""

0 commit comments

Comments
 (0)