Skip to content

Commit 9f5737f

Browse files
Merge pull request #4 from Codeinwp/3.3.0
3.3.0
2 parents 1bfea09 + a8cacce commit 9f5737f

Some content is hidden

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

52 files changed

+2181
-82
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
### v3.2.1 - 2019-05-05
3+
**Changes:**
4+
* Fix issue with async loading of scripts
5+
26
### v3.2.0 - 2019-05-03
37
**Changes:**
48
* Add support for charts in AMP requests

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: 7 additions & 7 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.

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;
@@ -350,6 +351,13 @@ class Editor extends Component {
350351
{ 'home' === this.state.route && (
351352
<div className="visualizer-settings__content">
352353

354+
<Notice
355+
status="warning"
356+
isDismissible={ false }
357+
>
358+
{ __( '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.' ) }
359+
</Notice>
360+
353361
<div className="visualizer-settings__content-description">
354362
{ __( 'Make a new chart or display an existing one?' ) }
355363
</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)