File tree Expand file tree Collapse file tree 6 files changed +309
-241
lines changed
classes/Visualizer/Module Expand file tree Collapse file tree 6 files changed +309
-241
lines changed Original file line number Diff line number Diff line change @@ -443,21 +443,22 @@ public function renderFlattrScript() {
443
443
*/
444
444
public function uploadData () {
445
445
// validate nonce
446
- if ( ! wp_verify_nonce ( filter_input ( INPUT_GET , 'nonce ' ) ) ) {
446
+ // do not use filter_input as it does not work for phpunit test cases, use filter_var instead
447
+ if ( ! isset ( $ _GET ['nonce ' ] ) || ! wp_verify_nonce ( $ _GET ['nonce ' ] ) ) {
447
448
status_header ( 403 );
448
449
exit ;
449
450
}
450
451
451
452
// check chart, if chart exists
452
- $ chart_id = filter_input ( INPUT_GET , 'chart ' , FILTER_VALIDATE_INT );
453
+ $ chart_id = isset ( $ _GET [ ' chart ' ] ) ? filter_var ( $ _GET [ 'chart ' ] , FILTER_VALIDATE_INT ) : '' ;
453
454
if ( ! $ chart_id || ! ( $ chart = get_post ( $ chart_id ) ) || $ chart ->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
454
455
status_header ( 400 );
455
456
exit ;
456
457
}
457
458
458
459
$ source = null ;
459
460
$ render = new Visualizer_Render_Page_Update ();
460
- if ( filter_input ( INPUT_POST , 'remote_data ' , FILTER_VALIDATE_URL ) ) {
461
+ if ( isset ( $ _POST [ ' remote_data ' ] ) && filter_var ( $ _POST [ 'remote_data ' ] , FILTER_VALIDATE_URL ) ) {
461
462
$ source = new Visualizer_Source_Csv_Remote ( $ _POST ['remote_data ' ] );
462
463
} elseif ( isset ( $ _FILES ['local_data ' ] ) && $ _FILES ['local_data ' ]['error ' ] == 0 ) {
463
464
$ source = new Visualizer_Source_Csv ( $ _FILES ['local_data ' ]['tmp_name ' ] );
@@ -488,7 +489,7 @@ public function uploadData() {
488
489
}
489
490
490
491
$ render ->render ();
491
- exit ;
492
+ wp_die () ;
492
493
}
493
494
494
495
/**
Original file line number Diff line number Diff line change @@ -90,32 +90,20 @@ function visualizer_launch() {
90
90
define ( 'VISUALIZER_CSV_ENCLOSURE ' , '" ' );
91
91
}
92
92
93
- // don't load the plugin if cron job is running or doing autosave
94
- $ doing_autosave = defined ( 'DOING_AUTOSAVE ' ) && DOING_AUTOSAVE ;
95
- $ doing_cron = defined ( 'DOING_CRON ' ) && DOING_CRON ;
96
- $ doing_ajax = defined ( 'DOING_AJAX ' ) && DOING_AJAX ;
97
- if ( $ doing_autosave || $ doing_cron ) {
98
- return ;
99
- }
100
-
101
93
// instantiate the plugin
102
94
$ plugin = Visualizer_Plugin::instance ();
103
95
104
96
// set general modules
105
97
$ plugin ->setModule ( Visualizer_Module_Setup::NAME );
106
98
$ plugin ->setModule ( Visualizer_Module_Sources::NAME );
107
99
108
- if ( $ doing_ajax ) {
109
- // set ajax modules
110
- $ plugin ->setModule ( Visualizer_Module_Chart::NAME );
100
+ $ plugin ->setModule ( Visualizer_Module_Chart::NAME );
101
+ if ( is_admin () ) {
102
+ // set admin modules
103
+ $ plugin ->setModule ( Visualizer_Module_Admin::NAME );
111
104
} else {
112
- if ( is_admin () ) {
113
- // set admin modules
114
- $ plugin ->setModule ( Visualizer_Module_Admin::NAME );
115
- } else {
116
- // set frontend modules
117
- $ plugin ->setModule ( Visualizer_Module_Frontend::NAME );
118
- }
105
+ // set frontend modules
106
+ $ plugin ->setModule ( Visualizer_Module_Frontend::NAME );
119
107
}
120
108
}
121
109
Original file line number Diff line number Diff line change 31
31
parent . addClass ( 'open' ) ;
32
32
}
33
33
} ) ;
34
- $ ( '#vz-import -file' ) . click ( function ( ) {
34
+ $ ( '#view-remote -file' ) . click ( function ( ) {
35
35
var url = $ ( this ) . parent ( ) . find ( '#remote-data' ) . val ( ) ;
36
36
37
37
if ( url !== '' ) {
You can’t perform that action at this time.
0 commit comments