Skip to content

Commit 3d35af3

Browse files
Merge pull request #5 from Codeinwp/3.3.0
3.3.0
2 parents a0c1df7 + 7dc1ace commit 3d35af3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2659
-104
lines changed

.travis.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
language: php
2-
php:
3-
- '7.1'
4-
- '7.0'
5-
- '5.6'
6-
- '5.5'
7-
- '5.4'
82
sudo: false
93
matrix:
104
fast_finish: true
115
include:
12-
- php: '5.6'
13-
install: true
14-
before_script: chmod +x bin/wraith.sh
15-
env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
16-
script: "./bin/wraith.sh"
17-
- php: '5.3'
18-
dist: precise
6+
- php: 7.2
7+
- php: 7.1
8+
- php: 7.0
9+
- php: '5.6'
10+
install: true
11+
before_script: chmod +x bin/wraith.sh
12+
env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
13+
script: "./bin/wraith.sh"
14+
- php: 5.5
15+
env: WP_VERSION=5.1
16+
- php: 5.4
17+
env: WP_VERSION=5.1
18+
- php: 5.3
19+
env: WP_VERSION=5.1
20+
dist: precise
1921
allow_failures:
2022
- env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
2123
branches:

classes/Visualizer/Gutenberg/Block.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ public function get_visualizer_data( $post ) {
194194

195195
$data['visualizer-chart-type'] = get_post_meta( $post_id, Visualizer_Plugin::CF_CHART_TYPE, true );
196196

197+
$data['visualizer-chart-library'] = get_post_meta( $post_id, Visualizer_Plugin::CF_CHART_LIBRARY, true );
198+
197199
$data['visualizer-source'] = get_post_meta( $post_id, Visualizer_Plugin::CF_SOURCE, true );
198200

199201
$data['visualizer-default-data'] = get_post_meta( $post_id, Visualizer_Plugin::CF_DEFAULT_DATA, true );

classes/Visualizer/Gutenberg/build/block.css

Lines changed: 1 addition & 2 deletions
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: 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/src/Components/Charts.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ class Charts extends Component {
102102
chart = `${ startCase( data['visualizer-chart-type']) }Chart`;
103103
}
104104

105+
if ( data['visualizer-chart-library']) {
106+
if ( 'ChartJS' === data['visualizer-chart-library']) {
107+
return;
108+
}
109+
}
110+
111+
if ( 'dataTable' === chart ) {
112+
return;
113+
}
114+
105115
return (
106116
<div className="visualizer-settings__charts-single">
107117

classes/Visualizer/Gutenberg/src/Editor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const {
2828
Button,
2929
ButtonGroup,
3030
Dashicon,
31+
Notice,
3132
Placeholder,
3233
Spinner
3334
} = wp.components;
@@ -351,6 +352,13 @@ class Editor extends Component {
351352
{ 'home' === this.state.route && (
352353
<div className="visualizer-settings__content">
353354

355+
<Notice
356+
status="warning"
357+
isDismissible={ false }
358+
>
359+
{ __( 'Right now the Visualizer block does not support display/editing of Table chart. It will be added in the next release. We recommend you to use shortcode if you want to display that particular chart type.' ) }
360+
</Notice>
361+
354362
<div className="visualizer-settings__content-description">
355363
{ __( 'Make a new chart or display an existing one?' ) }
356364
</div>

classes/Visualizer/Module.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,19 @@ public function _getDataAs( $chart_id, $type ) {
206206
}
207207
}
208208

209-
$filename = isset( $settings['title'] ) && ! empty( $settings['title'] ) ? $settings['title'] : 'visualizer#' . $chart_id;
209+
$title = 'visualizer#' . $chart_id;
210+
if ( ! empty( $settings['title'] ) ) {
211+
$title = $settings['title'];
212+
}
213+
// for ChartJS, title is an array.
214+
if ( is_array( $title ) && isset( $title['text'] ) ) {
215+
$title = $title['text'];
216+
}
217+
if ( empty( $title ) ) {
218+
$title = 'visualizer#' . $chart_id;
219+
}
220+
221+
$filename = $title;
210222

211223
switch ( $type ) {
212224
case 'csv':
@@ -476,21 +488,39 @@ protected function get_user_customization_js() {
476488
* Load the class for the given chart's chart type so that its assets can be loaded.
477489
*/
478490
protected function load_chart_type( $chart_id ) {
479-
$type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
480-
$name = 'Visualizer_Render_Sidebar_Type_' . ucwords( $type );
491+
$name = $this->load_chart_class_name( $chart_id );
481492
$class = null;
482493
if ( class_exists( $name ) || true === apply_filters( 'visualizer_load_chart', false, $name ) ) {
483494
$class = new $name;
484495
}
485496

486497
if ( is_null( $class ) && VISUALIZER_PRO ) {
487498
// lets see if this type exists in pro. New Lite(3.1.0+) & old Pro(1.8.0-).
488-
$class = apply_filters( 'visualizer_pro_chart_type_sidebar', null, array( 'type' => $type, 'settings' => get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true ) ) );
499+
$type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
500+
$class = apply_filters( 'visualizer_pro_chart_type_sidebar', null, array( 'id' => $chart_id, 'type' => $type, 'settings' => get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true ) ) );
489501
}
490502

491503
return is_null( $class ) ? null : $class->getLibrary();
492504
}
493505

506+
/**
507+
* Returns the class name for the given chart's chart type.
508+
*/
509+
protected function load_chart_class_name( $chart_id ) {
510+
$type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
511+
$lib = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, true );
512+
513+
// backward compatibility.
514+
if ( empty( $lib ) ) {
515+
$lib = 'GoogleCharts';
516+
if ( 'dataTable' === $type ) {
517+
$lib = 'DataTable';
518+
}
519+
}
520+
$name = 'Visualizer_Render_Sidebar_Type_' . $lib . '_' . ucwords( $type );
521+
return $name;
522+
}
523+
494524
/**
495525
* Generates the inline CSS to apply to the chart and adds these classes to the settings.
496526
*

classes/Visualizer/Module/AMP.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,32 @@ public static function is_amp() {
6464
}
6565

6666
/**
67-
* Loads the alterview view of the chart.
67+
* Loads the alternate view of the chart.
6868
*/
6969
public function get_chart( $chart, $data, $series, $settings ) {
70+
// let's check if there is a view parameter in the GET request.
71+
$view = isset( $_GET['view'] ) ? $_GET['view'] : null;
72+
73+
if ( ! empty( $view ) ) {
74+
// attachmend id?
75+
if ( is_numeric( $view ) ) {
76+
$view = wp_get_attachment_url( $view );
77+
}
78+
79+
$attributes = wp_check_filetype( $view );
80+
if ( $attributes && false !== strpos( $attributes['type'], 'image/' ) ) {
81+
// absolute url or relative?
82+
if ( 0 !== strpos( $view, 'http' ) ) {
83+
$view = site_url( $view );
84+
}
85+
$view = '<img src="' . $view . '">';
86+
}
87+
88+
if ( ! empty( $view ) ) {
89+
return $view;
90+
}
91+
}
92+
7093
$view = apply_filters( 'visualizer_amp_view', null, $chart, $data, $series, $settings );
7194
if ( ! is_null( $view ) ) {
7295
return $view;

0 commit comments

Comments
 (0)