Skip to content

Commit ec70cc1

Browse files
Merge pull request #536 from Codeinwp/development
Increase minimum requirement to PHP 5.6 Fixed issue with loading customization.js on multisites Fixed issue with manually editing a remotely loaded chart Fixed issues with cloning Fixed issues with ChartJS assigning default colors Fix security issues in block editor
2 parents bce058a + 48db17b commit ec70cc1

31 files changed

+235
-190
lines changed

.travis.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@ matrix:
88
- php: 7.1
99
- php: 7.0
1010
- php: '5.6'
11+
- name: Wraith
12+
php: '5.6'
1113
install: true
1214
before_script: chmod +x bin/wraith.sh
1315
env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
1416
script: "./bin/wraith.sh"
15-
- php: 5.5
16-
env: WP_VERSION=5.1
17-
- php: 5.4
18-
env: WP_VERSION=5.1
19-
- php: 5.3
20-
env: WP_VERSION=5.1
21-
dist: precise
2217
allow_failures:
2318
- env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
2419
branches:

classes/Visualizer/Gutenberg/Block.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ private function __construct() {
6060
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_gutenberg_scripts' ) );
6161
add_action( 'init', array( $this, 'register_block_type' ) );
6262
add_action( 'rest_api_init', array( $this, 'register_rest_endpoints' ) );
63+
add_filter( 'rest_visualizer_query', array( $this, 'add_rest_query_vars' ), 9, 2 );
6364
}
6465

6566
/**
@@ -191,6 +192,10 @@ public function register_rest_endpoints() {
191192
* Get Post Meta Fields
192193
*/
193194
public function get_visualizer_data( $post ) {
195+
if ( ! current_user_can( 'edit_posts' ) ) {
196+
return false;
197+
}
198+
194199
$data = array();
195200
$post_id = $post['id'];
196201

@@ -238,6 +243,10 @@ public function get_visualizer_data( $post ) {
238243
* Rest Callback Method
239244
*/
240245
public function update_chart_data( $data ) {
246+
if ( ! current_user_can( 'edit_posts' ) ) {
247+
return false;
248+
}
249+
241250
if ( $data['id'] && ! is_wp_error( $data['id'] ) ) {
242251

243252
update_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_TYPE, $data['visualizer-chart-type'] );
@@ -351,6 +360,10 @@ public function toUTF8( $datum ) {
351360
* Handle remote CSV data
352361
*/
353362
public function upload_csv_data( $data ) {
363+
if ( ! current_user_can( 'edit_posts' ) ) {
364+
return false;
365+
}
366+
354367
if ( $data['url'] && ! is_wp_error( $data['url'] ) && filter_var( $data['url'], FILTER_VALIDATE_URL ) ) {
355368
$source = new Visualizer_Source_Csv_Remote( $data['url'] );
356369
if ( $source->fetch() ) {
@@ -374,6 +387,10 @@ public function upload_csv_data( $data ) {
374387
* Get permission data
375388
*/
376389
public function get_permission_data( $data ) {
390+
if ( ! current_user_can( 'edit_posts' ) ) {
391+
return false;
392+
}
393+
377394
$options = array();
378395
switch ( $data['type'] ) {
379396
case 'users':
@@ -413,4 +430,15 @@ public function get_permission_data( $data ) {
413430
return $options;
414431
}
415432

433+
/**
434+
* Filter Rest Query
435+
*/
436+
public function add_rest_query_vars( $args, \WP_REST_Request $request ) {
437+
if ( isset( $request['meta_key'] ) && isset( $request['meta_value'] ) ) {
438+
$args['meta_key'] = $request->get_param( 'meta_key' );
439+
$args['meta_value'] = $request->get_param( 'meta_value' );
440+
$args['meta_compare'] = '!=';
441+
}
442+
return $args;
443+
}
416444
}

classes/Visualizer/Gutenberg/build/block.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/Visualizer/Gutenberg/build/block.js

Lines changed: 13 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/Visualizer/Gutenberg/build/handsontable.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

classes/Visualizer/Gutenberg/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"merge": "^1.2.1",
1818
"react": "16.4.1",
1919
"react-google-charts": "^3.0.8",
20-
"react-json-editor-ajrm": "^2.5.8"
20+
"react-json-editor-ajrm": "^2.5.8",
21+
"uuid": "^3.3.3"
2122
},
2223
"devDependencies": {
2324
"@babel/core": "^7.1.6",

classes/Visualizer/Gutenberg/src/Components/Charts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Charts extends Component {
4646
async componentDidMount() {
4747

4848
// Fetch review again if block loaded after saving.
49-
let result = await apiFetch({ path: 'wp/v2/visualizer/?per_page=6' });
49+
let result = await apiFetch({ path: 'wp/v2/visualizer/?per_page=6&meta_key=visualizer-chart-library&meta_value=ChartJS' });
5050
this.setState({ charts: result });
5151
}
5252

@@ -56,7 +56,7 @@ class Charts extends Component {
5656

5757
this.setState({ isBusy: true });
5858

59-
let result = await apiFetch({ path: `wp/v2/visualizer/?per_page=6&offset=${ offset }` });
59+
let result = await apiFetch({ path: `wp/v2/visualizer/?per_page=6&meta_key=visualizer-chart-library&meta_value=ChartJS&offset=${ offset }` });
6060

6161
if ( 6 > result.length ) {
6262
chartsLoaded = true;

classes/Visualizer/Gutenberg/src/Components/CreateCharts.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)