PluginProbe
Chartify – WordPress Chart Plugin / 3.2.7
Chartify – WordPress Chart Plugin v3.2.7
3.8.0 3.7.9 3.7.8 3.7.7 3.7.6 3.7.5 trunk 1.0.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 All 83 releases
← All changes | includes/class-chart-builder-functions.php +37 -246 3.7.63.2.7 View file →
@@ -109,11 +109,10 @@
109 109
110 110 public function get_all_charts_count() {
111 111 global $wpdb;
112 112 $where = str_replace("WHERE", "AND", Chart_Builder_DB_Actions::get_where_condition());
113 -
114 - $sql = "SELECT COUNT(id) FROM {$this->db_table} WHERE `status` = %s {$where}";
115 - return intval( $wpdb->get_var( $wpdb->prepare($sql, 'published') ));// phpcs:ignore
113 + $sql = "SELECT COUNT(id) FROM " . $this->db_table . " WHERE `status`='published' " . $where;
114 + return intval( $wpdb->get_var( $sql ) );
116 115 }
117 116
118 117 /**
119 118 * Gets the allowed types
@@ -202,9 +201,9 @@
202 201 return $tables;
203 202 }
204 203 $tables = array();
205 204
206 - $sql = $wpdb->get_col( 'SHOW TABLES', 0 );// phpcs:ignore
205 + $sql = $wpdb->get_col( 'SHOW TABLES', 0 );
207 206 foreach ( $sql as $table ) {
208 207 if ( empty( $prefix ) || 0 === strpos( $table, $wpdb->prefix ) ) {
209 208 $tables[] = $table;
210 209 }
@@ -357,36 +356,30 @@
357 356 $quizes_table = $wpdb->prefix . 'aysquiz_quizes';
358 357
359 358 switch ($query) {
360 359 case 'q1':
361 - $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM {$reports_table} WHERE quiz_id = %d GROUP BY CAST(end_date AS date)";
362 - $result = $wpdb->get_results($wpdb->prepare($sql, $quiz_id), "ARRAY_A");// phpcs:ignore
360 + $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM ".$reports_table." WHERE quiz_id = ".$quiz_id." GROUP BY CAST(end_date AS date)";
363 361 break;
364 362 case 'q2':
365 - $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM {$reports_table} WHERE user_id = %d GROUP BY CAST(end_date AS date)";
366 - $result = $wpdb->get_results($wpdb->prepare($sql, $user_id), "ARRAY_A");// phpcs:ignore
363 + $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM ".$reports_table." WHERE user_id = ".$user_id." GROUP BY CAST(end_date AS date)";
367 364 break;
368 365 case 'q3':
369 - $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM {$reports_table} WHERE user_id = %d AND quiz_id = %d GROUP BY CAST(end_date AS date)";
370 - $result = $wpdb->get_results($wpdb->prepare($sql, $user_id, $quiz_id), "ARRAY_A");// phpcs:ignore
366 + $sql = "SELECT CAST(end_date AS date) AS `Date`, COUNT(id) AS `Count` FROM ".$reports_table." WHERE user_id = ".$user_id." AND quiz_id = ".$quiz_id." GROUP BY CAST(end_date AS date)";
371 367 break;
372 368 case 'q4':
373 - $sql = "SELECT {$quizes_table}.title AS `Quiz`, AVG({$reports_table}.score) AS `Average` FROM {$reports_table} LEFT JOIN {$quizes_table} ON {$reports_table}.quiz_id = {$quizes_table}.id WHERE {$reports_table}.user_id = %d GROUP BY {$quizes_table}.title";
374 - $result = $wpdb->get_results($wpdb->prepare($sql, $user_id), "ARRAY_A");// phpcs:ignore
369 + $sql = "SELECT ".$quizes_table.".title AS `Quiz`, AVG(".$reports_table.".score) AS `Average` FROM ".$reports_table." LEFT JOIN ".$quizes_table." ON ".$reports_table.".quiz_id = ".$quizes_table.".id WHERE ".$reports_table.".user_id = ".$user_id." GROUP BY ".$quizes_table.".title";
375 370 break;
376 371 case 'q5':
377 - $sql = "SELECT {$quizes_table}.title AS `Quiz`, COUNT({$reports_table}.score) AS `Count` FROM {$reports_table} LEFT JOIN {$quizes_table} ON {$reports_table}.quiz_id = {$quizes_table}.id WHERE {$reports_table}.user_id = %d GROUP BY {$quizes_table}.title";
378 - $result = $wpdb->get_results($wpdb->prepare($sql, $user_id), "ARRAY_A");// phpcs:ignore
372 + $sql = "SELECT ".$quizes_table.".title AS `Quiz`, COUNT(".$reports_table.".score) AS `Count` FROM ".$reports_table." LEFT JOIN ".$quizes_table." ON ".$reports_table.".quiz_id = ".$quizes_table.".id WHERE ".$reports_table.".user_id = ".$user_id." GROUP BY ".$quizes_table.".title";
379 373 break;
380 374 case 'q6':
381 - $sql = "SELECT score AS `Score` FROM {$reports_table} WHERE user_id = %d AND quiz_id = %d";
382 - $result = $wpdb->get_results($wpdb->prepare($sql, $user_id, $quiz_id), "ARRAY_A");// phpcs:ignore
375 + $sql = "SELECT score AS `Score` FROM ".$reports_table." WHERE user_id = ".$user_id." AND quiz_id = ".$quiz_id."";
383 376 break;
384 377 default:
385 378 break;
386 379 }
387 380
388 -
381 + $result = $wpdb->get_results($sql, "ARRAY_A");
389 382 $message = empty($result) ? __( "There is no data for your query.", "chart-builder" ) : "";
390 383 return array(
391 384 'message' => $message,
392 385 'result' => $result,
@@ -399,9 +392,9 @@
399 392 *
400 393 * @access public
401 394 * @return array
402 395 */
403 - public function get_chart_settings_google_admin($settings, $action, $source) {
396 + public function get_chart_settings_google_admin ($settings, $action, $source) {
404 397 $chart_default_colors = array('#3366cc','#dc3912','#ff9900','#109618', '#990099','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411');
405 398
406 399 $tooltip_trigger_options = array(
407 400 "hover" => __("While hovering", "chart-builder"),
@@ -915,10 +908,8 @@
915 908 $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic';
916 909 $settings['haxis_slanted_text_angle'] = isset( $settings['haxis_slanted_text_angle'] ) && $settings['haxis_slanted_text_angle'] != '' && $settings['haxis_slanted_text_angle'] != '0' ? esc_attr( $settings['haxis_slanted_text_angle'] ) : '30';
917 910 $settings['haxis_show_text_every'] = isset( $settings['haxis_show_text_every'] ) && $settings['haxis_show_text_every'] != '' ? esc_attr( $settings['haxis_show_text_every'] ) : '0';
918 911 $settings['haxis_format'] = isset( $settings['haxis_format'] ) && $settings['haxis_format'] != '' ? esc_attr( $settings['haxis_format'] ) : '';
919 - $settings['haxis_enable_divide_percent'] = ( isset( $settings['haxis_enable_divide_percent'] ) && $settings['haxis_enable_divide_percent'] != '' ) ? $settings['haxis_enable_divide_percent'] : 'off';
920 - $settings['haxis_enable_divide_percent'] = isset( $settings['haxis_enable_divide_percent'] ) && $settings['haxis_enable_divide_percent'] == 'on' ? 'checked' : '';
921 912 $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null;
922 913 $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null;
923 914 $settings['haxis_gridlines_count'] = isset( $settings['haxis_gridlines_count'] ) && $settings['haxis_gridlines_count'] != '' ? esc_attr( $settings['haxis_gridlines_count'] ) : -1;$settings['haxis_italic'] = ( isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] != '' ) ? $settings['haxis_italic'] : 'off';
924 915 $settings['haxis_italic'] = isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] == 'on' ? 'checked' : '';
@@ -941,10 +932,8 @@
941 932 $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000';
942 933 $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000';
943 934 $settings['vaxis_text_font_size'] = isset( $settings['vaxis_text_font_size'] ) && $settings['vaxis_text_font_size'] != '' ? absint(esc_attr( $settings['vaxis_text_font_size'] )) : $settings['font_size'];
944 935 $settings['vaxis_format'] = isset( $settings['vaxis_format'] ) && $settings['vaxis_format'] != '' ? esc_attr( $settings['vaxis_format'] ) : '';
945 - $settings['vaxis_enable_divide_percent'] = ( isset( $settings['vaxis_enable_divide_percent'] ) && $settings['vaxis_enable_divide_percent'] != '' ) ? $settings['vaxis_enable_divide_percent'] : 'off';
946 - $settings['vaxis_enable_divide_percent'] = isset( $settings['vaxis_enable_divide_percent'] ) && $settings['vaxis_enable_divide_percent'] == 'on' ? 'checked' : '';
947 936 $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null;
948 937 $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null;
949 938 $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1;
950 939 $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off';
@@ -969,9 +958,9 @@
969 958
970 959 $settings['enable_img'] = ( isset( $settings['enable_img'] ) && $settings['enable_img'] != '' ) ? $settings['enable_img'] : 'off';
971 960 $settings['enable_img'] = isset( $settings['enable_img'] ) && $settings['enable_img'] == 'on' ? 'checked' : '';
972 961
973 - $counting_source = !empty($source) ? $source : array();
962 + $counting_source = $source;
974 963
975 964 $count_slices = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count($counting_source) - 1 : 0;
976 965 $count_series = (isset($counting_source[0]) && !is_null($counting_source[0]) && count($counting_source[0]) > 0) ? count($counting_source[0]) - 1 : 0;
977 966 $count_rows = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count(array_column($counting_source, 0)) - 1 : 0;
@@ -988,10 +977,9 @@
988 977 $settings['series_visible_in_legend'] = isset( $settings['series_visible_in_legend'] ) && $settings['series_visible_in_legend'] != '' ? json_decode($settings['series_visible_in_legend'], true) : array_fill(0, $count_series, 'on');
989 978 $settings['series_line_width'] = isset( $settings['series_line_width'] ) && $settings['series_line_width'] != '' ? json_decode($settings['series_line_width'], true) : array_fill(0, $count_series, $settings['line_width']);
990 979 $settings['series_point_size'] = isset( $settings['series_point_size'] ) && $settings['series_point_size'] != '' ? json_decode($settings['series_point_size'], true) : array_fill(0, $count_series, $settings['point_size']);
991 980 $settings['series_point_shape'] = isset( $settings['series_point_shape'] ) && $settings['series_point_shape'] != '' ? json_decode($settings['series_point_shape'], true) : array_fill(0, $count_series, $settings['point_shape']);
992 - $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, '');
993 -
981 +
994 982 // Rows settings
995 983 $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on';
996 984 $settings['enable_row_settings'] = isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] == 'on' ? 'checked' : '';
997 985
@@ -1323,9 +1311,8 @@
1323 1311 $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic';
1324 1312 $settings['haxis_slanted_text_angle'] = isset( $settings['haxis_slanted_text_angle'] ) && $settings['haxis_slanted_text_angle'] != '' && $settings['haxis_slanted_text_angle'] != '0' ? esc_attr( $settings['haxis_slanted_text_angle'] ) : '30';
1325 1313 $settings['haxis_show_text_every'] = isset( $settings['haxis_show_text_every'] ) && $settings['haxis_show_text_every'] != '' ? esc_attr( $settings['haxis_show_text_every'] ) : '0';
1326 1314 $settings['haxis_format'] = isset( $settings['haxis_format'] ) && $settings['haxis_format'] != '' ? esc_attr( $settings['haxis_format'] ) : '';
1327 - $settings['haxis_enable_divide_percent'] = ( isset( $settings['haxis_enable_divide_percent'] ) && $settings['haxis_enable_divide_percent'] != '' ) ? $settings['haxis_enable_divide_percent'] : 'off';
1328 1315 $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null;
1329 1316 $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null;
1330 1317 $settings['haxis_gridlines_count'] = isset( $settings['haxis_gridlines_count'] ) && $settings['haxis_gridlines_count'] != '' ? esc_attr( $settings['haxis_gridlines_count'] ) : -1;
1331 1318 $settings['haxis_italic'] = ( isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] != '' ) ? $settings['haxis_italic'] : 'off';
@@ -1344,9 +1331,8 @@
1344 1331 $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000';
1345 1332 $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000';
1346 1333 $settings['vaxis_text_font_size'] = isset( $settings['vaxis_text_font_size'] ) && $settings['vaxis_text_font_size'] != '' ? absint(esc_attr( $settings['vaxis_text_font_size'] )) : $settings['font_size'];
1347 1334 $settings['vaxis_format'] = isset( $settings['vaxis_format'] ) && $settings['vaxis_format'] != '' ? esc_attr( $settings['vaxis_format'] ) : '';
1348 - $settings['vaxis_enable_divide_percent'] = ( isset( $settings['vaxis_enable_divide_percent'] ) && $settings['vaxis_enable_divide_percent'] != '' ) ? $settings['vaxis_enable_divide_percent'] : 'off';
1349 1335 $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null;
1350 1336 $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null;
1351 1337 $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1;
1352 1338 $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off';
@@ -1380,9 +1366,9 @@
1380 1366 $settings['series_visible_in_legend'] = isset( $settings['series_visible_in_legend'] ) && $settings['series_visible_in_legend'] != '' ? json_decode($settings['series_visible_in_legend'], true) : array_fill(0, $count_series, 'on');
1381 1367 $settings['series_line_width'] = isset( $settings['series_line_width'] ) && $settings['series_line_width'] != '' ? json_decode($settings['series_line_width'], true) : array_fill(0, $count_series, $settings['line_width']);
1382 1368 $settings['series_point_size'] = isset( $settings['series_point_size'] ) && $settings['series_point_size'] != '' ? json_decode($settings['series_point_size'], true) : array_fill(0, $count_series, $settings['point_size']);
1383 1369 $settings['series_point_shape'] = isset( $settings['series_point_shape'] ) && $settings['series_point_shape'] != '' ? json_decode($settings['series_point_shape'], true) : array_fill(0, $count_series, $settings['point_shape']);
1384 - $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, '');
1370 +
1385 1371 // Rows settings
1386 1372 $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on';
1387 1373
1388 1374 $settings['rows_color'] = isset( $settings['rows_color'] ) && $settings['rows_color'] != '' ? json_decode($settings['rows_color'], true) : array_fill(0, $count_rows, '');
@@ -1397,69 +1383,40 @@
1397 1383 *
1398 1384 * @access public
1399 1385 * @return array
1400 1386 */
1401 - public function get_chart_settings_chartjs_admin($settings, $source) {
1402 - $chart_default_colors = array('#36A2EB','#FF6384','#FF9F40','#FFCD56', '#4BC0C0','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411');
1403 -
1387 + public function get_chart_settings_chartjs_admin ($settings) {
1404 1388 $title_positions = array(
1405 - "left" => __("Left", "chart-builder"),
1406 - "right" => __("Right", "chart-builder"),
1407 - "center" => __("Center", "chart-builder")
1389 + "left" => __("Left", "chart-builder"),
1390 + "right" => __("Right", "chart-builder"),
1391 + "center" => __("Center", "chart-builder")
1408 1392 );
1409 1393
1410 1394 $text_transforms = array(
1411 - "uppercase" => __("Uppercase", "chart-builder"),
1412 - "lowercase" => __("Lowercase", "chart-builder"),
1413 - "capitalize" => __("Capitalize", "chart-builder"),
1414 - "none" => __("None", "chart-builder"),
1395 + "uppercase" => __("Uppercase", "chart-builder"),
1396 + "lowercase" => __("Lowercase", "chart-builder"),
1397 + "capitalize" => __("Capitalize", "chart-builder"),
1398 + "none" => __("None", "chart-builder"),
1415 1399 );
1416 1400
1417 1401 $text_decorations = array(
1418 - "overline" => __("Overline", "chart-builder"),
1419 - "underline" => __("Underline", "chart-builder"),
1420 - "line-through" => __("Line through", "chart-builder"),
1421 - "none" => __("None", "chart-builder"),
1402 + "overline" => __("Overline", "chart-builder"),
1403 + "underline" => __("Underline", "chart-builder"),
1404 + "line-through" => __("Line through", "chart-builder"),
1405 + "none" => __("None", "chart-builder"),
1422 1406 );
1423 1407
1424 1408 $border_styles = array(
1425 - "solid" => __("Solid", "chart-builder"),
1426 - "dashed" => __("Dashed", "chart-builder"),
1427 - "dotted" => __("Dotted", "chart-builder"),
1428 - "double" => __("Double", "chart-builder"),
1429 - "groove" => __("Groove", "chart-builder"),
1430 - "inset" => __("Inset", "chart-builder"),
1431 - "outset" => __("Outset", "chart-builder"),
1432 - "ridge" => __("Ridge", "chart-builder")
1409 + "solid" => __("Solid", "chart-builder"),
1410 + "dashed" => __("Dashed", "chart-builder"),
1411 + "dotted" => __("Dotted", "chart-builder"),
1412 + "double" => __("Double", "chart-builder"),
1413 + "groove" => __("Groove", "chart-builder"),
1414 + "inset" => __("Inset", "chart-builder"),
1415 + "outset" => __("Outset", "chart-builder"),
1416 + "ridge" => __("Ridge", "chart-builder")
1433 1417 );
1434 -
1435 - $legend_positions = array(
1436 - "top" => __("Above the chart", "chart-builder"),
1437 - "bottom" => __("Below the chart", "chart-builder"),
1438 - "left" => __("Left of the chart", "chart-builder"),
1439 - "right" => __("Right of the chart", "chart-builder"),
1440 - );
1441 1418
1442 - $legend_alignments = array(
1443 - "start" => __("Start", "chart-builder"),
1444 - "center" => __("Center", "chart-builder"),
1445 - "end" => __("End", "chart-builder"),
1446 - );
1447 -
1448 - $group_width_format_options = array(
1449 - "%" => __("%", "chart-builder"),
1450 - "px" => __("px", "chart-builder"),
1451 - );
1452 -
1453 - // Width
1454 - $settings['width'] = isset( $settings['width'] ) && $settings['width'] != '' ? esc_attr( $settings['width'] ) : '100';
1455 - $settings['width_format'] = isset( $settings['width_format'] ) && $settings['width_format'] != '' ? esc_attr( $settings['width_format'] ) : '%';
1456 - $settings['width_format_options'] = $group_width_format_options;
1457 -
1458 - // Height
1459 - $settings['height'] = isset( $settings['height'] ) && $settings['height'] != '' ? esc_attr( $settings['height'] ) : '100';
1460 - $settings['height_format'] = isset( $settings['height_format'] ) && $settings['height_format'] != '' ? esc_attr( $settings['height_format'] ) : '%';
1461 -
1462 1419 // Title color
1463 1420 $settings['title_color'] = isset( $settings['title_color'] ) && $settings['title_color'] != '' ? esc_attr( $settings['title_color'] ) : '#000000';
1464 1421
1465 1422 // Title color
@@ -1546,39 +1503,17 @@
1546 1503
1547 1504 // Border color
1548 1505 $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000';
1549 1506
1550 - // Background color
1551 - $settings['background_color_chart'] = isset( $settings['background_color_chart'] ) && $settings['background_color_chart'] != '' ? esc_attr( $settings['background_color_chart'] ) : '#ffffff';
1552 -
1553 - // Border width with title
1554 - $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0';
1555 -
1556 - // Border radius with title
1557 - $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0';
1558 -
1559 - // Border color with title
1560 - $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000';
1561 -
1562 - // Border style with title
1563 - $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid';
1564 - $settings['border_styles'] = $border_styles;
1565 -
1566 - //Box shadow color
1567 - $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color'];
1568 -
1569 1507 // Border style
1570 1508 $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid';
1571 1509 $settings['border_styles'] = $border_styles;
1572 1510
1573 - // slice_spacing
1574 - $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1;
1575 -
1576 1511 // outer_radius
1577 1512 $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100;
1578 1513
1579 - // Padding outer
1580 - $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0';
1514 + // slice_spacing
1515 + $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1;
1581 1516
1582 1517 // circumference
1583 1518 $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360;
1584 1519
@@ -1600,73 +1535,8 @@
1600 1535 $settings['show_title'] = ( $settings['show_title'] != '' ) ? $settings['show_title'] : 'off';
1601 1536 $settings['show_title'] = isset( $settings['show_title'] ) && $settings['show_title'] == 'on' ? 'checked' : '';
1602 1537 }
1603 1538
1604 - $counting_source = !empty($source) ? $source : array();
1605 - $count_slices = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count($counting_source) - 1 : 0;
1606 -
1607 - // Slices settings
1608 - $settings['slice_colors_default'] = $chart_default_colors;
1609 - $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : array_slice($chart_default_colors, 0, $count_slices);
1610 -
1611 - // Slice border color
1612 - $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff';
1613 -
1614 - // Slice border color
1615 - $settings['slices_border_color'] = isset( $settings['slices_border_color'] ) && $settings['slices_border_color'] != '' ? json_decode($settings['slices_border_color'], true) : array_fill(0, $count_slices, $settings['slice_border_color']);
1616 -
1617 - // Slices border width
1618 - $settings['slice_border_width'] = isset( $settings['slice_border_width'] ) && $settings['slice_border_width'] != '' ? esc_attr( $settings['slice_border_width'] ) : '1';
1619 -
1620 - // Tooltip text color
1621 - $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#fff';
1622 -
1623 - $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] != '' ? esc_attr( $settings['show_color_code'] ) : 'off';
1624 - $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] == 'on' ? 'checked' : '';
1625 -
1626 - $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] != '' ) ? $settings['tooltip_italic'] : 'off';
1627 - $settings['tooltip_italic'] = isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] == 'on' ? 'checked' : '';
1628 -
1629 - // Tooltip font size
1630 - $settings['tooltip_font_size'] = isset( $settings['tooltip_font_size'] ) && intval($settings['tooltip_font_size']) > 0 ? esc_attr( $settings['tooltip_font_size'] ) : '12';
1631 -
1632 - // Tooltip bold options
1633 - $tooltip_bold_options = array(
1634 - "default" => __("Default", "chart-builder"),
1635 - "true" => __("Enable", "chart-builder"),
1636 - "false" => __("Disable", "chart-builder")
1637 - );
1638 -
1639 - // Tooltip bold text
1640 - $settings['tooltip_bold'] = isset( $settings['tooltip_bold'] ) && $settings['tooltip_bold'] != '' ? esc_attr( $settings['tooltip_bold'] ) : 'default';
1641 - $settings['tooltip_bold_options'] = $tooltip_bold_options;
1642 -
1643 - // Legend font color
1644 - $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000';
1645 -
1646 - // Legend font size
1647 - $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12;
1648 -
1649 - // Legend position
1650 - $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top';
1651 - $settings['legend_positions'] = $legend_positions;
1652 -
1653 - // Legend alignment
1654 - $settings['legend_alignment'] = isset( $settings['legend_alignment'] ) && $settings['legend_alignment'] != '' ? esc_attr( $settings['legend_alignment'] ) : 'start';
1655 - $settings['legend_alignments'] = $legend_alignments;
1656 -
1657 - // Legend Italic text
1658 - $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off';
1659 - $settings['legend_italic'] = isset( $settings['legend_italic'] ) && $settings['legend_italic'] == 'on' ? 'checked' : '';
1660 -
1661 - // Legend Bold text
1662 - $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off';
1663 - $settings['legend_bold'] = isset( $settings['legend_bold'] ) && $settings['legend_bold'] == 'on' ? 'checked' : '';
1664 -
1665 - // Legend reverse
1666 - $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off';
1667 - $settings['legend_reverse'] = isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] == 'on' ? 'checked' : '';
1668 -
1669 1539 return $settings;
1670 1540
1671 1541 }
1672 1542
@@ -1675,21 +1545,9 @@
1675 1545 *
1676 1546 * @access public
1677 1547 * @return array
1678 1548 */
1679 - public function get_chart_settings_chartjs_public($settings, $chartData) {
1680 - $chart_default_colors = array('#36A2EB','#FF6384','#FF9F40','#FFCD56', '#4BC0C0','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411');
1681 - // echo "<pre>"; var_dump($settings); echo "</pre>";
1682 - // Width
1683 - $settings['width'] = isset( $settings['width'] ) && $settings['width'] != '' ? esc_attr( $settings['width'] ) : '100';
1684 - $settings['width_format'] = isset( $settings['width_format'] ) && $settings['width_format'] != '' ? esc_attr( $settings['width_format'] ) : '%';
1685 - $settings['chart_width'] = $settings['width'].$settings['width_format'];
1686 -
1687 - // height
1688 - $settings['height'] = isset( $settings['height'] ) && $settings['height'] != '' ? esc_attr( $settings['height'] ) : '100';
1689 - $settings['height_format'] = isset( $settings['height_format'] ) && $settings['height_format'] != '' ? esc_attr( $settings['height_format'] ) : '%';
1690 - $settings['chart_height'] = $settings['height'].$settings['height_format'];
1691 -
1549 + public function get_chart_settings_chartjs_public ($settings) {
1692 1550 // Show chart description
1693 1551 $settings['show_description'] = isset( $settings['show_description'] ) && $settings['show_description'] != '' ? esc_attr( $settings['show_description'] ) : 'on';
1694 1552
1695 1553 // Show chart title
@@ -1779,32 +1637,11 @@
1779 1637
1780 1638 // Border color
1781 1639 $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000';
1782 1640
1783 - //Box shadow color
1784 - $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color'];
1785 -
1786 1641 // Border style
1787 1642 $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid';
1788 1643
1789 - // Background color
1790 - $settings['background_color_chart'] = isset( $settings['background_color_chart'] ) && $settings['background_color_chart'] != '' ? esc_attr( $settings['background_color_chart'] ) : '#ffffff';
1791 -
1792 - // Border width with title
1793 - $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0';
1794 -
1795 - // Border radius with title
1796 - $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0';
1797 -
1798 - // Border color with title
1799 - $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000';
1800 -
1801 - // Border style with title
1802 - $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid';
1803 -
1804 - // Padding outer
1805 - $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0';
1806 -
1807 1644 // outer_radius
1808 1645 $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100;
1809 1646
1810 1647 // slice_spacing
@@ -1814,55 +1651,9 @@
1814 1651 $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360;
1815 1652
1816 1653 // start_angle
1817 1654 $settings['start_angle'] = isset( $settings['start_angle'] ) && $settings['start_angle'] != '' ? esc_attr( absint($settings['start_angle']) ) : 0;
1818 -
1819 - $count_slices = (isset($chartData['source']) && !is_null($chartData['source']) && count($chartData['source']) > 0) ? count($chartData['source']) - 1 : 0;
1820 - // Slices settings
1821 - $settings['slice_colors_default'] = $chart_default_colors;
1822 - $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : $chart_default_colors;
1823 1655
1824 - // Slice border color
1825 - $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff';
1826 -
1827 - // Slice border color
1828 - $settings['slices_border_color'] = isset( $settings['slices_border_color'] ) && $settings['slices_border_color'] != '' ? json_decode($settings['slices_border_color'], true) : array_fill(0, $count_slices, $settings['slice_border_color']);
1829 -
1830 - // Slices border width
1831 - $settings['slice_border_width'] = isset( $settings['slice_border_width'] ) && $settings['slice_border_width'] != '' ? esc_attr( $settings['slice_border_width'] ) : '1';
1832 -
1833 - // Tooltip text color
1834 - $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#fff';
1835 -
1836 - // Tooltip font size
1837 - $settings['tooltip_font_size'] = isset( $settings['tooltip_font_size'] ) && intval($settings['tooltip_font_size']) > 0 ? esc_attr( $settings['tooltip_font_size'] ) : 12;
1838 -
1839 - // Show color code
1840 - $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] != '' ? esc_attr( $settings['show_color_code'] ) : 'off';
1841 - $settings['show_color_code'] = isset( $settings['show_color_code'] ) && $settings['show_color_code'] == 'on' ? 'checked' : '';
1842 -
1843 - // Tooltip Italic text
1844 - $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] != '' ) ? $settings['tooltip_italic'] : 'off';
1845 - //$settings['tooltip_italic'] = isset( $settings['tooltip_italic'] ) && $settings['tooltip_italic'] == 'checked' ? 'italic' : 'normal';
1846 - $settings['tooltip_italic'] = ( isset( $settings['tooltip_italic'] ) && ($settings['tooltip_italic'] == 'checked' || $settings['tooltip_italic'] == 'on') ) ? 'italic' : 'normal';
1847 - // Legend font color
1848 - $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000';
1849 -
1850 - // Legend font size
1851 - $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12;
1852 -
1853 - // Legend position
1854 - $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top';
1855 -
1856 - // Legend Italic text
1857 - $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off';
1858 -
1859 - // Legend Bold text
1860 - $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off';
1861 -
1862 - // Legend reverse
1863 - $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off';
1864 -
1865 1656 return $settings;
1866 1657
1867 1658 }
1868 1659 }