Skip to content

Commit 23550be

Browse files
Merge branch 'development' of https://github.com/codeinwp/visualizer into issue-217
2 parents 839b201 + 4dd54f3 commit 23550be

File tree

17 files changed

+201
-45
lines changed

17 files changed

+201
-45
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,5 @@ deploy:
7272
after_deploy:
7373
- chmod +x bin/deploy.sh
7474
- ". ./bin/deploy.sh"
75+
after_failure:
76+
- cat "logs/phpcs.log"

CHANGELOG.md

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

2+
### v3.0.11 - 2018-08-15
3+
**Changes:**
4+
* Fixed issue with the Series Settings options for the Table Chart
5+
* Fixed issue with chart showing "Table has no columns" with remote sources
6+
7+
### v3.0.10 - 2018-07-20
8+
**Changes:**
9+
* Fixed problem with chart reverting to the default values
10+
* Fixed problem with Boolean column type
11+
* Fixed problem with the Geo chart type not saving colors options
12+
213
### v3.0.9 - 2018-07-12
314
**Changes:**
415
* New chart title option for the back-end of the charts that don't allow a title on the front-end

classes/Visualizer/Module.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,54 @@ protected function get_language() {
395395
return reset( $array );
396396
}
397397

398+
/**
399+
* Gets/creates the JS where user-specific customizations can be/have been added.
400+
*/
401+
protected function get_user_customization_js() {
402+
// use this as the JS file in case we are not able to create the file in uploads.
403+
$default = VISUALIZER_ABSURL . 'js/customization.js';
404+
405+
$uploads = wp_get_upload_dir();
406+
$specific = $uploads['baseurl'] . '/visualizer/customization.js';
407+
408+
// for testing on user sites (before we send them the correctly customized file).
409+
if ( VISUALIZER_TEST_JS_CUSTOMIZATION ) {
410+
return $default;
411+
}
412+
413+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
414+
WP_Filesystem();
415+
global $wp_filesystem;
416+
417+
$dir = $wp_filesystem->wp_content_dir() . 'uploads/visualizer';
418+
$file = $wp_filesystem->wp_content_dir() . 'uploads/visualizer/customization.js';
419+
420+
if ( $wp_filesystem->is_readable( $file ) ) {
421+
return $specific;
422+
}
423+
424+
if ( $wp_filesystem->exists( $file ) && ! $wp_filesystem->is_readable( $file ) ) {
425+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Unable to read file %s', $file ), 'error', __FILE__, __LINE__ );
426+
return $default;
427+
}
428+
429+
if ( ! $wp_filesystem->exists( $dir ) ) {
430+
if ( ( $done = $wp_filesystem->mkdir( $dir ) ) === false ) {
431+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Unable to create directory %s', $dir ), 'error', __FILE__, __LINE__ );
432+
return $default;
433+
}
434+
}
435+
436+
// if file does not exist, copy.
437+
if ( ! $wp_filesystem->exists( $file ) ) {
438+
$src = str_replace( ABSPATH, $wp_filesystem->abspath(), VISUALIZER_ABSPATH . '/js/customization.js' );
439+
if ( ( $done = $wp_filesystem->copy( $src, $file ) ) === false ) {
440+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Unable to copy file %s to %s', $src, $file ), 'error', __FILE__, __LINE__ );
441+
return $default;
442+
}
443+
}
444+
445+
return $specific;
446+
}
447+
398448
}

classes/Visualizer/Module/Admin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,14 @@ public function enqueueLibraryScripts( $suffix ) {
417417
);
418418
wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
419419
wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
420+
wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
420421
wp_enqueue_script(
421422
'visualizer-render',
422423
VISUALIZER_ABSURL . 'js/render.js',
423424
array(
424425
'google-jsapi-old',
425426
'visualizer-library',
427+
'visualizer-customization',
426428
),
427429
Visualizer_Plugin::VERSION,
428430
true

classes/Visualizer/Module/Chart.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,15 @@ public function renderChartPages() {
255255
wp_register_script( 'visualizer-frame', VISUALIZER_ABSURL . 'js/frame.js', array( 'visualizer-chosen' ), Visualizer_Plugin::VERSION, true );
256256
wp_register_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
257257
wp_register_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
258+
wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
258259
wp_register_script(
259260
'visualizer-render',
260261
VISUALIZER_ABSURL . 'js/render.js',
261262
array(
262263
'google-jsapi-old',
263264
'google-jsapi-new',
264265
'visualizer-frame',
266+
'visualizer-customization',
265267
),
266268
Visualizer_Plugin::VERSION,
267269
true
@@ -585,7 +587,20 @@ public function uploadData() {
585587
}
586588
if ( $source ) {
587589
if ( $source->fetch() ) {
588-
$chart->post_content = $source->getData();
590+
$content = $source->getData();
591+
$populate = true;
592+
if ( is_string( $content ) && is_array( unserialize( $content ) ) ) {
593+
$json = unserialize( $content );
594+
// if source exists, so should data. if source exists but data is blank, do not populate the chart.
595+
// if we populate the data even if it is empty, the chart will show "Table has no columns".
596+
if ( array_key_exists( 'source', $json ) && ! empty( $json['source'] ) && ( ! array_key_exists( 'data', $json ) || empty( $json['data'] ) ) ) {
597+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Not populating chart data as source exists (%s) but data is empty!', $json['source'] ), 'warn', __FILE__, __LINE__ );
598+
$populate = false;
599+
}
600+
}
601+
if ( $populate ) {
602+
$chart->post_content = $content;
603+
}
589604
wp_update_post( $chart->to_array() );
590605
update_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, $source->getSeries() );
591606
update_post_meta( $chart->ID, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() );

classes/Visualizer/Module/Frontend.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function __construct( Visualizer_Plugin $plugin ) {
5454
parent::__construct( $plugin );
5555

5656
$this->_addAction( 'wp_enqueue_scripts', 'enqueueScripts' );
57+
$this->_addAction( 'visualizer_enqueue_scripts', 'enqueueScripts' );
5758
$this->_addFilter( 'visualizer_get_language', 'getLanguage' );
5859
$this->_addShortcode( 'visualizer', 'renderChart' );
5960

@@ -158,7 +159,8 @@ public function perform_action( WP_REST_Request $params ) {
158159
public function enqueueScripts() {
159160
wp_register_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
160161
wp_register_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
161-
wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'visualizer-google-jsapi-old', 'jquery' ), Visualizer_Plugin::VERSION, true );
162+
wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
163+
wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'visualizer-google-jsapi-old', 'jquery', 'visualizer-customization' ), Visualizer_Plugin::VERSION, true );
162164
wp_register_script( 'visualizer-clipboardjs', VISUALIZER_ABSURL . 'js/lib/clipboardjs/clipboard.min.js', array( 'jquery' ), Visualizer_Plugin::VERSION, true );
163165
wp_register_style( 'visualizer-front', VISUALIZER_ABSURL . 'css/front.css', array(), Visualizer_Plugin::VERSION );
164166
do_action( 'visualizer_pro_frontend_load_resources' );
@@ -232,7 +234,7 @@ public function renderChart( $atts ) {
232234
}
233235

234236
// handle data filter hooks
235-
$data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type );
237+
$data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type );
236238
if ( ! empty( $atts['data'] ) ) {
237239
$data = apply_filters( $atts['data'], $data, $chart->ID, $type );
238240
}

classes/Visualizer/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class Visualizer_Plugin {
2929

3030
const NAME = 'visualizer';
31-
const VERSION = '3.0.10';
31+
const VERSION = '3.0.12';
3232

3333
// custom post types
3434
const CPT_VISUALIZER = 'visualizer';

classes/Visualizer/Render/Page/Data.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ protected function _renderSidebarContent() {
6969
'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
7070
'nonce' => wp_create_nonce(),
7171
'chart' => $this->chart->ID,
72-
), admin_url( 'admin-ajax.php' )
72+
),
73+
admin_url( 'admin-ajax.php' )
7374
);
7475

7576
// this will allow us to open the correct source tab by default.
@@ -144,7 +145,7 @@ class="visualizer-select">
144145
<?php
145146
$hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
146147
$schedules = apply_filters(
147-
'visualizer_schedules', array(
148+
'visualizer_chart_schedules', array(
148149
'1' => __( 'Each hour', 'visualizer' ),
149150
'12' => __( 'Each 12 hours', 'visualizer' ),
150151
'24' => __( 'Each day', 'visualizer' ),
@@ -183,7 +184,8 @@ class="dashicons dashicons-lock"></span></h2>
183184
array(
184185
'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
185186
'nonce' => wp_create_nonce(),
186-
), admin_url( 'admin-ajax.php' )
187+
),
188+
admin_url( 'admin-ajax.php' )
187189
);
188190
$query_args_charts = array(
189191
'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
@@ -359,7 +361,8 @@ private function getPermissionsLink( $id ) {
359361
array(
360362
'nonce' => wp_create_nonce(),
361363
'tab' => 'permissions',
362-
), remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
364+
),
365+
remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
363366
);
364367
?>
365368
" method="post">
@@ -382,7 +385,9 @@ private function permissionsSidebar() {
382385
}
383386
Visualizer_Render_Sidebar::_renderGroupStart(
384387
esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
385-
class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
388+
class="dashicons dashicons-lock"></span>',
389+
'',
390+
apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
386391
);
387392
Visualizer_Render_Sidebar::_renderSectionStart();
388393
Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
@@ -424,7 +429,9 @@ class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_up
424429

425430
Visualizer_Render_Sidebar::_renderGroupStart(
426431
esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
427-
class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
432+
class="dashicons dashicons-lock"></span>',
433+
'',
434+
apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
428435
);
429436
Visualizer_Render_Sidebar::_renderSectionStart();
430437
Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );

classes/Visualizer/Render/Sidebar.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ protected function _renderAdvancedSettings() {
183183
'manual',
184184
$this->manual,
185185
sprintf(
186-
esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ), '<br><code>' . $example . '</code>'
186+
esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ),
187+
'<br><code>' . $example . '</code>'
187188
),
188189
'',
189190
array( 'rows' => 5 )

css/media.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Version: 3.0.10
2+
Version: 3.0.12
33
*/
44
#visualizer-library-view {
55
padding: 30px 10px 10px 30px;

0 commit comments

Comments
 (0)