@@ -73,12 +73,14 @@ public function getCharts() {
73
73
$ query_args = array (
74
74
'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
75
75
'posts_per_page ' => 9 ,
76
- 'paged ' => filter_input ( INPUT_GET , 'page ' , FILTER_VALIDATE_INT , array (
77
- 'options ' => array (
78
- 'min_range ' => 1 ,
79
- 'default ' => 1 ,
80
- ),
81
- ) ),
76
+ 'paged ' => filter_input (
77
+ INPUT_GET , 'page ' , FILTER_VALIDATE_INT , array (
78
+ 'options ' => array (
79
+ 'min_range ' => 1 ,
80
+ 'default ' => 1 ,
81
+ ),
82
+ )
83
+ ),
82
84
);
83
85
$ filter = filter_input ( INPUT_GET , 's ' , FILTER_SANITIZE_STRING );
84
86
if ( $ filter && in_array ( $ filter , Visualizer_Plugin::getChartTypes () ) ) {
@@ -98,11 +100,13 @@ public function getCharts() {
98
100
$ chart_data ['id ' ] = $ chart ->ID ;
99
101
$ charts [] = $ chart_data ;
100
102
}
101
- self ::_sendResponse ( array (
102
- 'success ' => true ,
103
- 'data ' => $ charts ,
104
- 'total ' => $ query ->max_num_pages ,
105
- ) );
103
+ self ::_sendResponse (
104
+ array (
105
+ 'success ' => true ,
106
+ 'data ' => $ charts ,
107
+ 'total ' => $ query ->max_num_pages ,
108
+ )
109
+ );
106
110
}
107
111
108
112
/**
@@ -163,11 +167,13 @@ public function deleteChart() {
163
167
$ nonce = wp_verify_nonce ( filter_input ( $ input_method , 'nonce ' ) );
164
168
$ capable = current_user_can ( 'delete_posts ' );
165
169
if ( $ nonce && $ capable ) {
166
- $ chart_id = filter_input ( $ input_method , 'chart ' , FILTER_VALIDATE_INT , array (
167
- 'options ' => array (
168
- 'min_range ' => 1 ,
169
- ),
170
- ) );
170
+ $ chart_id = filter_input (
171
+ $ input_method , 'chart ' , FILTER_VALIDATE_INT , array (
172
+ 'options ' => array (
173
+ 'min_range ' => 1 ,
174
+ ),
175
+ )
176
+ );
171
177
if ( $ chart_id ) {
172
178
$ chart = get_post ( $ chart_id );
173
179
$ success = $ chart && $ chart ->post_type == Visualizer_Plugin::CPT_VISUALIZER ;
@@ -177,9 +183,11 @@ public function deleteChart() {
177
183
wp_delete_post ( $ chart_id , true );
178
184
}
179
185
if ( $ is_post ) {
180
- self ::_sendResponse ( array (
181
- 'success ' => $ success ,
182
- ) );
186
+ self ::_sendResponse (
187
+ array (
188
+ 'success ' => $ success ,
189
+ )
190
+ );
183
191
}
184
192
wp_redirect ( wp_get_referer () );
185
193
exit ;
@@ -201,21 +209,25 @@ public function renderChartPages() {
201
209
$ default_type = 'line ' ;
202
210
$ source = new Visualizer_Source_Csv ( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples ' . DIRECTORY_SEPARATOR . $ default_type . '.csv ' );
203
211
$ source ->fetch ();
204
- $ chart_id = wp_insert_post ( array (
205
- 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
206
- 'post_title ' => 'Visualization ' ,
207
- 'post_author ' => get_current_user_id (),
208
- 'post_status ' => 'auto-draft ' ,
209
- 'post_content ' => $ source ->getData (),
210
- ) );
212
+ $ chart_id = wp_insert_post (
213
+ array (
214
+ 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
215
+ 'post_title ' => 'Visualization ' ,
216
+ 'post_author ' => get_current_user_id (),
217
+ 'post_status ' => 'auto-draft ' ,
218
+ 'post_content ' => $ source ->getData (),
219
+ )
220
+ );
211
221
if ( $ chart_id && ! is_wp_error ( $ chart_id ) ) {
212
222
add_post_meta ( $ chart_id , Visualizer_Plugin::CF_CHART_TYPE , $ default_type );
213
223
add_post_meta ( $ chart_id , Visualizer_Plugin::CF_DEFAULT_DATA , 1 );
214
224
add_post_meta ( $ chart_id , Visualizer_Plugin::CF_SOURCE , $ source ->getSourceName () );
215
225
add_post_meta ( $ chart_id , Visualizer_Plugin::CF_SERIES , $ source ->getSeries () );
216
- add_post_meta ( $ chart_id , Visualizer_Plugin::CF_SETTINGS , array (
217
- 'focusTarget ' => 'datum ' ,
218
- ) );
226
+ add_post_meta (
227
+ $ chart_id , Visualizer_Plugin::CF_SETTINGS , array (
228
+ 'focusTarget ' => 'datum ' ,
229
+ )
230
+ );
219
231
}
220
232
wp_redirect ( add_query_arg ( 'chart ' , (int ) $ chart_id ) );
221
233
defined ( 'WP_TESTS_DOMAIN ' ) ? wp_die () : exit ();
@@ -225,15 +237,19 @@ public function renderChartPages() {
225
237
wp_register_script ( 'visualizer-frame ' , VISUALIZER_ABSURL . 'js/frame.js ' , array ( 'jquery ' ), Visualizer_Plugin::VERSION , true );
226
238
wp_register_script ( 'google-jsapi-new ' , '//www.gstatic.com/charts/loader.js ' , array (), null , true );
227
239
wp_register_script ( 'google-jsapi-old ' , '//www.google.com/jsapi ' , array ( 'google-jsapi-new ' ), null , true );
228
- wp_register_script ( 'visualizer-render ' , VISUALIZER_ABSURL . 'js/render.js ' , array (
229
- 'google-jsapi-old ' ,
230
- 'google-jsapi-new ' ,
231
- 'visualizer-frame ' ,
232
- ), Visualizer_Plugin::VERSION , true );
233
- wp_register_script ( 'visualizer-preview ' , VISUALIZER_ABSURL . 'js/preview.js ' , array (
234
- 'wp-color-picker ' ,
235
- 'visualizer-render ' ,
236
- ), Visualizer_Plugin::VERSION , true );
240
+ wp_register_script (
241
+ 'visualizer-render ' , VISUALIZER_ABSURL . 'js/render.js ' , array (
242
+ 'google-jsapi-old ' ,
243
+ 'google-jsapi-new ' ,
244
+ 'visualizer-frame ' ,
245
+ ), Visualizer_Plugin::VERSION , true
246
+ );
247
+ wp_register_script (
248
+ 'visualizer-preview ' , VISUALIZER_ABSURL . 'js/preview.js ' , array (
249
+ 'wp-color-picker ' ,
250
+ 'visualizer-render ' ,
251
+ ), Visualizer_Plugin::VERSION , true
252
+ );
237
253
// added by Ash/Upwork
238
254
if ( VISUALIZER_PRO ) {
239
255
global $ Visualizer_Pro ;
@@ -293,15 +309,17 @@ private function _handleDataAndSettingsPage() {
293
309
wp_enqueue_style ( 'visualizer-frame ' );
294
310
wp_enqueue_script ( 'visualizer-preview ' );
295
311
wp_enqueue_script ( 'visualizer-render ' );
296
- wp_localize_script ( 'visualizer-render ' , 'visualizer ' , array (
297
- 'l10n ' => array (
298
- 'invalid_source ' => esc_html__ ( 'You have entered invalid URL. Please, insert proper URL. ' , 'visualizer ' ),
299
- ),
300
- 'charts ' => array (
301
- 'canvas ' => $ data ,
302
- ),
303
- 'map_api_key ' => get_option ( 'visualizer-map-api-key ' ),
304
- ) );
312
+ wp_localize_script (
313
+ 'visualizer-render ' , 'visualizer ' , array (
314
+ 'l10n ' => array (
315
+ 'invalid_source ' => esc_html__ ( 'You have entered invalid URL. Please, insert proper URL. ' , 'visualizer ' ),
316
+ ),
317
+ 'charts ' => array (
318
+ 'canvas ' => $ data ,
319
+ ),
320
+ 'map_api_key ' => get_option ( 'visualizer-map-api-key ' ),
321
+ )
322
+ );
305
323
$ render = new Visualizer_Render_Page_Data ();
306
324
$ render ->chart = $ this ->_chart ;
307
325
$ render ->type = $ data ['type ' ];
@@ -441,35 +459,41 @@ public function cloneChart() {
441
459
$ nonce = wp_verify_nonce ( filter_input ( INPUT_GET , 'nonce ' ), Visualizer_Plugin::ACTION_CLONE_CHART );
442
460
$ capable = current_user_can ( 'edit_posts ' );
443
461
if ( $ nonce && $ capable ) {
444
- $ chart_id = filter_input ( INPUT_GET , 'chart ' , FILTER_VALIDATE_INT , array (
445
- 'options ' => array (
446
- 'min_range ' => 1 ,
447
- ),
448
- ) );
462
+ $ chart_id = filter_input (
463
+ INPUT_GET , 'chart ' , FILTER_VALIDATE_INT , array (
464
+ 'options ' => array (
465
+ 'min_range ' => 1 ,
466
+ ),
467
+ )
468
+ );
449
469
if ( $ chart_id ) {
450
470
$ chart = get_post ( $ chart_id );
451
471
$ success = $ chart && $ chart ->post_type == Visualizer_Plugin::CPT_VISUALIZER ;
452
472
}
453
473
}
454
474
$ redirect = wp_get_referer ();
455
475
if ( $ success ) {
456
- $ new_chart_id = wp_insert_post ( array (
457
- 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
458
- 'post_title ' => 'Visualization ' ,
459
- 'post_author ' => get_current_user_id (),
460
- 'post_status ' => $ chart ->post_status ,
461
- 'post_content ' => $ chart ->post_content ,
462
- ) );
476
+ $ new_chart_id = wp_insert_post (
477
+ array (
478
+ 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
479
+ 'post_title ' => 'Visualization ' ,
480
+ 'post_author ' => get_current_user_id (),
481
+ 'post_status ' => $ chart ->post_status ,
482
+ 'post_content ' => $ chart ->post_content ,
483
+ )
484
+ );
463
485
if ( $ new_chart_id && ! is_wp_error ( $ new_chart_id ) ) {
464
486
add_post_meta ( $ new_chart_id , Visualizer_Plugin::CF_CHART_TYPE , get_post_meta ( $ chart_id , Visualizer_Plugin::CF_CHART_TYPE , true ) );
465
487
add_post_meta ( $ new_chart_id , Visualizer_Plugin::CF_DEFAULT_DATA , get_post_meta ( $ chart_id , Visualizer_Plugin::CF_DEFAULT_DATA , true ) );
466
488
add_post_meta ( $ new_chart_id , Visualizer_Plugin::CF_SOURCE , get_post_meta ( $ chart_id , Visualizer_Plugin::CF_SOURCE , true ) );
467
489
add_post_meta ( $ new_chart_id , Visualizer_Plugin::CF_SERIES , get_post_meta ( $ chart_id , Visualizer_Plugin::CF_SERIES , true ) );
468
490
add_post_meta ( $ new_chart_id , Visualizer_Plugin::CF_SETTINGS , get_post_meta ( $ chart_id , Visualizer_Plugin::CF_SETTINGS , true ) );
469
- $ redirect = add_query_arg ( array (
470
- 'page ' => 'visualizer ' ,
471
- 'type ' => filter_input ( INPUT_GET , 'type ' ),
472
- ), admin_url ( 'upload.php ' ) );
491
+ $ redirect = add_query_arg (
492
+ array (
493
+ 'page ' => 'visualizer ' ,
494
+ 'type ' => filter_input ( INPUT_GET , 'type ' ),
495
+ ), admin_url ( 'upload.php ' )
496
+ );
473
497
}
474
498
}
475
499
wp_redirect ( $ redirect );
@@ -488,11 +512,13 @@ public function exportData() {
488
512
$ chart_id = $ success = false ;
489
513
$ capable = current_user_can ( 'edit_posts ' );
490
514
if ( $ capable ) {
491
- $ chart_id = isset ( $ _GET ['chart ' ] ) ? filter_var ( $ _GET ['chart ' ], FILTER_VALIDATE_INT , array (
492
- 'options ' => array (
493
- 'min_range ' => 1 ,
494
- ),
495
- ) ) : '' ;
515
+ $ chart_id = isset ( $ _GET ['chart ' ] ) ? filter_var (
516
+ $ _GET ['chart ' ], FILTER_VALIDATE_INT , array (
517
+ 'options ' => array (
518
+ 'min_range ' => 1 ,
519
+ ),
520
+ )
521
+ ) : '' ;
496
522
if ( $ chart_id ) {
497
523
$ chart = get_post ( $ chart_id );
498
524
$ success = $ chart && $ chart ->post_type == Visualizer_Plugin::CPT_VISUALIZER ;
@@ -553,10 +579,12 @@ public function exportData() {
553
579
$ csv .= implode ( ', ' , $ array );
554
580
}
555
581
fclose ( $ fp );
556
- echo wp_send_json_success ( array (
557
- 'csv ' => $ csv ,
558
- 'name ' => $ filename ,
559
- ) );
582
+ echo wp_send_json_success (
583
+ array (
584
+ 'csv ' => $ csv ,
585
+ 'name ' => $ filename ,
586
+ )
587
+ );
560
588
}// End if().
561
589
defined ( 'WP_TESTS_DOMAIN ' ) ? wp_die () : exit ();
562
590
}
@@ -576,14 +604,16 @@ private function _handleDataPage() {
576
604
unset( $ data ['settings ' ]['width ' ], $ data ['settings ' ]['height ' ] );
577
605
wp_enqueue_style ( 'visualizer-frame ' );
578
606
wp_enqueue_script ( 'visualizer-render ' );
579
- wp_localize_script ( 'visualizer-render ' , 'visualizer ' , array (
580
- 'l10n ' => array (
581
- 'invalid_source ' => esc_html__ ( 'You have entered invalid URL. Please, insert proper URL. ' , 'visualizer ' ),
582
- ),
583
- 'charts ' => array (
584
- 'canvas ' => $ data ,
585
- ),
586
- ) );
607
+ wp_localize_script (
608
+ 'visualizer-render ' , 'visualizer ' , array (
609
+ 'l10n ' => array (
610
+ 'invalid_source ' => esc_html__ ( 'You have entered invalid URL. Please, insert proper URL. ' , 'visualizer ' ),
611
+ ),
612
+ 'charts ' => array (
613
+ 'canvas ' => $ data ,
614
+ ),
615
+ )
616
+ );
587
617
// Added by Ash/Upwork
588
618
if ( VISUALIZER_PRO ) {
589
619
global $ Visualizer_Pro ;
0 commit comments