Skip to content

Commit 264cba5

Browse files
Merge pull request #9 from Codeinwp/3.3.1
3.3.1
2 parents 12a122e + a12148c commit 264cba5

File tree

17 files changed

+164
-48
lines changed

17 files changed

+164
-48
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:

CHANGELOG.md

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

2+
### v3.3.0 - 2019-08-14
3+
**Changes:**
4+
* Add support for ChartJS
5+
* Add alpha color picker for supported charts
6+
* Fix issue with some options of DataTable
7+
* Include DataTable charts in block editor
8+
* Fix issue with import from JSON not working with some sources
9+
* Add menu and onboarding page
10+
* Fix issue with frontend action checkboxes
11+
* Improve UX in advanced settings
12+
213
### v3.2.1 - 2019-05-05
314
**Changes:**
415
* Fix issue with async loading of scripts

classes/Visualizer/Module.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,13 @@ protected function get_user_customization_js() {
451451
WP_Filesystem();
452452
global $wp_filesystem;
453453

454-
$dir = $wp_filesystem->wp_content_dir() . 'uploads/visualizer';
455-
$file = $wp_filesystem->wp_content_dir() . 'uploads/visualizer/customization.js';
454+
$multisite_arg = '/';
455+
if ( is_multisite() && ! is_main_site() ) {
456+
$multisite_arg = '/sites/' . get_current_blog_id() . '/';
457+
}
458+
459+
$dir = $wp_filesystem->wp_content_dir() . 'uploads' . $multisite_arg . 'visualizer';
460+
$file = $wp_filesystem->wp_content_dir() . 'uploads' . $multisite_arg . 'visualizer/customization.js';
456461

457462
if ( $wp_filesystem->is_readable( $file ) ) {
458463
return $specific;

classes/Visualizer/Module/Chart.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ public function renderChartPages() {
443443
add_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 );
444444
add_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() );
445445
add_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() );
446+
add_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' );
446447
add_post_meta(
447448
$chart_id,
448449
Visualizer_Plugin::CF_SETTINGS,
@@ -1022,19 +1023,10 @@ public function uploadData() {
10221023
*/
10231024
public function cloneChart() {
10241025
$chart_id = $success = false;
1025-
$nonce = wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ), Visualizer_Plugin::ACTION_CLONE_CHART );
1026+
$nonce = isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], Visualizer_Plugin::ACTION_CLONE_CHART );
10261027
$capable = current_user_can( 'edit_posts' );
10271028
if ( $nonce && $capable ) {
1028-
$chart_id = filter_input(
1029-
INPUT_GET,
1030-
'chart',
1031-
FILTER_VALIDATE_INT,
1032-
array(
1033-
'options' => array(
1034-
'min_range' => 1,
1035-
),
1036-
)
1037-
);
1029+
$chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : '';
10381030
if ( $chart_id ) {
10391031
$chart = get_post( $chart_id );
10401032
$success = $chart && $chart->post_type === Visualizer_Plugin::CPT_VISUALIZER;
@@ -1051,12 +1043,15 @@ public function cloneChart() {
10511043
'post_content' => $chart->post_content,
10521044
)
10531045
);
1054-
if ( $new_chart_id && ! is_wp_error( $new_chart_id ) ) {
1055-
add_post_meta( $new_chart_id, Visualizer_Plugin::CF_CHART_TYPE, get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true ) );
1056-
add_post_meta( $new_chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, get_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, true ) );
1057-
add_post_meta( $new_chart_id, Visualizer_Plugin::CF_SOURCE, get_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, true ) );
1058-
add_post_meta( $new_chart_id, Visualizer_Plugin::CF_SERIES, get_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, true ) );
1059-
add_post_meta( $new_chart_id, Visualizer_Plugin::CF_SETTINGS, get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true ) );
1046+
if ( is_wp_error( $new_chart_id ) ) {
1047+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Error while cloning chart %d = %s', $chart_id, print_r( $new_chart_id, true ) ), 'error', __FILE__, __LINE__ );
1048+
} else {
1049+
$post_meta = get_post_meta( $chart_id );
1050+
foreach ( $post_meta as $key => $value ) {
1051+
if ( strpos( $key, 'visualizer-' ) !== false ) {
1052+
add_post_meta( $new_chart_id, $key, maybe_unserialize( $value[0] ) );
1053+
}
1054+
}
10601055
$redirect = add_query_arg(
10611056
array(
10621057
'page' => 'visualizer',
@@ -1067,6 +1062,11 @@ public function cloneChart() {
10671062
);
10681063
}
10691064
}
1065+
1066+
if ( defined( 'WP_TESTS_DOMAIN' ) ) {
1067+
wp_die();
1068+
}
1069+
10701070
wp_redirect( $redirect );
10711071
exit;
10721072
}

classes/Visualizer/Module/Utility.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,17 @@ private static function set_defaults_google( $chart, $post_status ) {
187187
}
188188

189189
/**
190-
* Sets some defaults in the chart for ChartJS charts.
190+
* Sets some defaults in the chart for ChartJS charts. Only during first creation.
191191
*
192192
* @since 3.3.0
193193
*
194194
* @access private
195195
*/
196196
private static function set_defaults_chartjs( $chart, $post_status ) {
197+
if ( $post_status !== 'auto-draft' ) {
198+
return;
199+
}
200+
197201
$type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
198202
$series = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true );
199203
$settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );

classes/Visualizer/Plugin.php

Lines changed: 2 additions & 2 deletions
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.3.0';
31+
const VERSION = '3.3.1';
3232

3333
// custom post types
3434
const CPT_VISUALIZER = 'visualizer';
@@ -90,7 +90,7 @@ class Visualizer_Plugin {
9090
const CF_CHART_URL = 'visualizer-chart-url';
9191
const CF_CHART_SCHEDULE = 'visualizer-chart-schedule';
9292
// Added by Ash/Upwork
93-
const PRO_TEASER_URL = 'http://themeisle.com/plugins/visualizer-charts-and-graphs-pro-addon/#pricing';
93+
const PRO_TEASER_URL = 'https://themeisle.com/plugins/visualizer-charts-and-graphs/upgrade/#pricing';
9494
const PRO_TEASER_TITLE = 'Check PRO version ';
9595
// Added by Ash/Upwork
9696
/**

classes/Visualizer/Render/Layout.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ public static function _renderEditorTable( $args ) {
372372
?>
373373
</tr>
374374
<?php
375+
// for remote sources, the data exists inside 'data'.
376+
if ( array_key_exists( 'data', $data ) ) {
377+
$data = $data['data'];
378+
}
375379
foreach ( $data as $row ) {
376380
echo '<tr>';
377381
echo '<th>' . __( 'Value', 'visualizer' ) . '</th>';

classes/Visualizer/Render/Page/Data.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class="visualizer-select">
238238
</li>
239239
</ul>
240240
</li>
241-
<li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
241+
<li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
242242
<h2 class="viz-group-title viz-sub-group"
243243
data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
244244
class="dashicons dashicons-lock"></span></h2>
@@ -504,7 +504,7 @@ private function permissionsSidebar() {
504504
esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
505505
class="dashicons dashicons-lock"></span>',
506506
'',
507-
apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
507+
'viz-chart-perm-view ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
508508
);
509509
Visualizer_Render_Sidebar::_renderSectionStart();
510510
Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
@@ -548,7 +548,7 @@ class="dashicons dashicons-lock"></span>',
548548
esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
549549
class="dashicons dashicons-lock"></span>',
550550
'',
551-
apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
551+
'viz-chart-perm-edit ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
552552
);
553553
Visualizer_Render_Sidebar::_renderSectionStart();
554554
Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );

classes/Visualizer/Render/Sidebar.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,12 @@ private static function is_excel_enabled() {
270270
include_once( $vendor_file );
271271
}
272272

273-
return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' ) && version_compare( PHP_VERSION, '5.6.0', '>' );
273+
if ( version_compare( phpversion(), '5.6.0', '<' ) ) {
274+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'PHP version %s not supported', phpversion() ), 'error', __FILE__, __LINE__ );
275+
return false;
276+
}
277+
278+
return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' );
274279
}
275280

276281
/**

classes/Visualizer/Source.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ public static final function get_date_formats_if_exists( $series, $data ) {
329329
*/
330330
private static final function determine_date_format( $value, $type ) {
331331
if ( version_compare( phpversion(), '5.3.0', '<' ) ) {
332+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'PHP version %s not supported', phpversion() ), 'error', __FILE__, __LINE__ );
332333
return null;
333334
}
334335

0 commit comments

Comments
 (0)