| @@ -109,10 +109,11 @@ | ||
| 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 | - $sql = "SELECT COUNT(id) FROM " . $this->db_table . " WHERE `status`='published' " . $where; | |
| 114 | - return intval( $wpdb->get_var( $sql ) ); | |
| 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 | |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | 118 | /** |
| 118 | 119 | * Gets the allowed types |
| @@ -201,9 +202,9 @@ | ||
| 201 | 202 | return $tables; |
| 202 | 203 | } |
| 203 | 204 | $tables = array(); |
| 204 | 205 | |
| 205 | - $sql = $wpdb->get_col( 'SHOW TABLES', 0 ); | |
| 206 | + $sql = $wpdb->get_col( 'SHOW TABLES', 0 );// phpcs:ignore | |
| 206 | 207 | foreach ( $sql as $table ) { |
| 207 | 208 | if ( empty( $prefix ) || 0 === strpos( $table, $wpdb->prefix ) ) { |
| 208 | 209 | $tables[] = $table; |
| 209 | 210 | } |
| @@ -309,9 +310,9 @@ | ||
| 309 | 310 | */ |
| 310 | 311 | public function get_table_html( $headers, $rows, $table_id = 'results' ) { |
| 311 | 312 | ob_start(); |
| 312 | 313 | ?> |
| 313 | - <table cellspacing="0" width="100%" id="<?= $table_id ?>"> | |
| 314 | + <table cellspacing="0" width="100%" id="<?php echo esc_attr($table_id) ?>"> | |
| 314 | 315 | <thead> |
| 315 | 316 | <tr> |
| 316 | 317 | <?php |
| 317 | 318 | foreach ( $headers as $header ) { |
| @@ -317,9 +318,9 @@ | ||
| 317 | 318 | foreach ( $headers as $header ) { |
| 318 | 319 | if( empty( $header ) ){ |
| 319 | 320 | continue; |
| 320 | 321 | } |
| 321 | - echo '<th>' . $header . '</th>'; | |
| 322 | + echo '<th>' . esc_html($header) . '</th>'; | |
| 322 | 323 | } |
| 323 | 324 | ?> |
| 324 | 325 | </tr> |
| 325 | 326 | </thead> |
| @@ -332,9 +333,9 @@ | ||
| 332 | 333 | continue; |
| 333 | 334 | } |
| 334 | 335 | echo '<tr>'; |
| 335 | 336 | foreach ( $row as $r ) { |
| 336 | - echo '<td>' . $r . '</td>'; | |
| 337 | + echo '<td>' . esc_html($r) . '</td>'; | |
| 337 | 338 | } |
| 338 | 339 | echo '</tr>'; |
| 339 | 340 | } |
| 340 | 341 | ?> |
| @@ -356,30 +357,36 @@ | ||
| 356 | 357 | $quizes_table = $wpdb->prefix . 'aysquiz_quizes'; |
| 357 | 358 | |
| 358 | 359 | switch ($query) { |
| 359 | 360 | case 'q1': |
| 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)"; | |
| 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 | |
| 361 | 363 | break; |
| 362 | 364 | case 'q2': |
| 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)"; | |
| 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 | |
| 364 | 367 | break; |
| 365 | 368 | case 'q3': |
| 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)"; | |
| 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 | |
| 367 | 371 | break; |
| 368 | 372 | case 'q4': |
| 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"; | |
| 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 | |
| 370 | 375 | break; |
| 371 | 376 | case 'q5': |
| 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"; | |
| 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 | |
| 373 | 379 | break; |
| 374 | 380 | case 'q6': |
| 375 | - $sql = "SELECT score AS `Score` FROM ".$reports_table." WHERE user_id = ".$user_id." AND quiz_id = ".$quiz_id.""; | |
| 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 | |
| 376 | 383 | break; |
| 377 | 384 | default: |
| 378 | 385 | break; |
| 379 | 386 | } |
| 380 | 387 | |
| 381 | - $result = $wpdb->get_results($sql, "ARRAY_A"); | |
| 388 | + | |
| 382 | 389 | $message = empty($result) ? __( "There is no data for your query.", "chart-builder" ) : ""; |
| 383 | 390 | return array( |
| 384 | 391 | 'message' => $message, |
| 385 | 392 | 'result' => $result, |
| @@ -392,9 +399,9 @@ | ||
| 392 | 399 | * |
| 393 | 400 | * @access public |
| 394 | 401 | * @return array |
| 395 | 402 | */ |
| 396 | - public function get_chart_settings_google_admin ($settings, $action, $source) { | |
| 403 | + public function get_chart_settings_google_admin($settings, $action, $source) { | |
| 397 | 404 | $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'); |
| 398 | 405 | |
| 399 | 406 | $tooltip_trigger_options = array( |
| 400 | 407 | "hover" => __("While hovering", "chart-builder"), |
| @@ -459,8 +466,19 @@ | ||
| 459 | 466 | "right" => __("Right", "chart-builder"), |
| 460 | 467 | "center" => __("Center", "chart-builder") |
| 461 | 468 | ); |
| 462 | 469 | |
| 470 | + $border_styles = array( | |
| 471 | + "solid" => __("Solid", "chart-builder"), | |
| 472 | + "dashed" => __("Dashed", "chart-builder"), | |
| 473 | + "dotted" => __("Dotted", "chart-builder"), | |
| 474 | + "double" => __("Double", "chart-builder"), | |
| 475 | + "groove" => __("Groove", "chart-builder"), | |
| 476 | + "inset" => __("Inset", "chart-builder"), | |
| 477 | + "outset" => __("Outset", "chart-builder"), | |
| 478 | + "ridge" => __("Ridge", "chart-builder") | |
| 479 | + ); | |
| 480 | + | |
| 463 | 481 | $animation_easing_options = array( |
| 464 | 482 | "linear" => __("Linear", "chart-builder"), |
| 465 | 483 | "in" => __("Ease in", "chart-builder"), |
| 466 | 484 | "out" => __("Ease out", "chart-builder"), |
| @@ -576,8 +594,11 @@ | ||
| 576 | 594 | |
| 577 | 595 | // Border color |
| 578 | 596 | $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#666666'; |
| 579 | 597 | |
| 598 | + // Border style | |
| 599 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 600 | + | |
| 580 | 601 | // Border width with title |
| 581 | 602 | $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; |
| 582 | 603 | |
| 583 | 604 | // Border radius with title |
| @@ -585,8 +606,12 @@ | ||
| 585 | 606 | |
| 586 | 607 | // Border color with title |
| 587 | 608 | $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; |
| 588 | 609 | |
| 610 | + // Border style with title | |
| 611 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 612 | + $settings['border_styles'] = $border_styles; | |
| 613 | + | |
| 589 | 614 | // Padding outer |
| 590 | 615 | $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; |
| 591 | 616 | |
| 592 | 617 | // Box shadow color |
| @@ -890,8 +915,10 @@ | ||
| 890 | 915 | $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic'; |
| 891 | 916 | $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'; |
| 892 | 917 | $settings['haxis_show_text_every'] = isset( $settings['haxis_show_text_every'] ) && $settings['haxis_show_text_every'] != '' ? esc_attr( $settings['haxis_show_text_every'] ) : '0'; |
| 893 | 918 | $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' : ''; | |
| 894 | 921 | $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null; |
| 895 | 922 | $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null; |
| 896 | 923 | $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'; |
| 897 | 924 | $settings['haxis_italic'] = isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] == 'on' ? 'checked' : ''; |
| @@ -914,8 +941,10 @@ | ||
| 914 | 941 | $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000'; |
| 915 | 942 | $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000'; |
| 916 | 943 | $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']; |
| 917 | 944 | $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' : ''; | |
| 918 | 947 | $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null; |
| 919 | 948 | $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null; |
| 920 | 949 | $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1; |
| 921 | 950 | $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off'; |
| @@ -940,9 +969,9 @@ | ||
| 940 | 969 | |
| 941 | 970 | $settings['enable_img'] = ( isset( $settings['enable_img'] ) && $settings['enable_img'] != '' ) ? $settings['enable_img'] : 'off'; |
| 942 | 971 | $settings['enable_img'] = isset( $settings['enable_img'] ) && $settings['enable_img'] == 'on' ? 'checked' : ''; |
| 943 | 972 | |
| 944 | - $counting_source = $source; | |
| 973 | + $counting_source = !empty($source) ? $source : array(); | |
| 945 | 974 | |
| 946 | 975 | $count_slices = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count($counting_source) - 1 : 0; |
| 947 | 976 | $count_series = (isset($counting_source[0]) && !is_null($counting_source[0]) && count($counting_source[0]) > 0) ? count($counting_source[0]) - 1 : 0; |
| 948 | 977 | $count_rows = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count(array_column($counting_source, 0)) - 1 : 0; |
| @@ -959,9 +988,10 @@ | ||
| 959 | 988 | $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'); |
| 960 | 989 | $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']); |
| 961 | 990 | $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']); |
| 962 | 991 | $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']); |
| 963 | - | |
| 992 | + $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, ''); | |
| 993 | + | |
| 964 | 994 | // Rows settings |
| 965 | 995 | $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on'; |
| 966 | 996 | $settings['enable_row_settings'] = isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] == 'on' ? 'checked' : ''; |
| 967 | 997 | |
| @@ -1023,8 +1053,11 @@ | ||
| 1023 | 1053 | |
| 1024 | 1054 | // Border color |
| 1025 | 1055 | $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#666666'; |
| 1026 | 1056 | |
| 1057 | + // Border style | |
| 1058 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1059 | + | |
| 1027 | 1060 | // Border width with title |
| 1028 | 1061 | $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; |
| 1029 | 1062 | |
| 1030 | 1063 | // Border radius with title |
| @@ -1032,8 +1065,11 @@ | ||
| 1032 | 1065 | |
| 1033 | 1066 | // Border color with title |
| 1034 | 1067 | $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; |
| 1035 | 1068 | |
| 1069 | + // Border style with title | |
| 1070 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 1071 | + | |
| 1036 | 1072 | // Padding outer |
| 1037 | 1073 | $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; |
| 1038 | 1074 | |
| 1039 | 1075 | // Box shadow color |
| @@ -1287,8 +1323,9 @@ | ||
| 1287 | 1323 | $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic'; |
| 1288 | 1324 | $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'; |
| 1289 | 1325 | $settings['haxis_show_text_every'] = isset( $settings['haxis_show_text_every'] ) && $settings['haxis_show_text_every'] != '' ? esc_attr( $settings['haxis_show_text_every'] ) : '0'; |
| 1290 | 1326 | $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'; | |
| 1291 | 1328 | $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null; |
| 1292 | 1329 | $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null; |
| 1293 | 1330 | $settings['haxis_gridlines_count'] = isset( $settings['haxis_gridlines_count'] ) && $settings['haxis_gridlines_count'] != '' ? esc_attr( $settings['haxis_gridlines_count'] ) : -1; |
| 1294 | 1331 | $settings['haxis_italic'] = ( isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] != '' ) ? $settings['haxis_italic'] : 'off'; |
| @@ -1307,8 +1344,9 @@ | ||
| 1307 | 1344 | $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000'; |
| 1308 | 1345 | $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000'; |
| 1309 | 1346 | $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']; |
| 1310 | 1347 | $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'; | |
| 1311 | 1349 | $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null; |
| 1312 | 1350 | $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null; |
| 1313 | 1351 | $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1; |
| 1314 | 1352 | $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off'; |
| @@ -1342,9 +1380,9 @@ | ||
| 1342 | 1380 | $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'); |
| 1343 | 1381 | $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']); |
| 1344 | 1382 | $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']); |
| 1345 | 1383 | $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']); |
| 1346 | - | |
| 1384 | + $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, ''); | |
| 1347 | 1385 | // Rows settings |
| 1348 | 1386 | $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on'; |
| 1349 | 1387 | |
| 1350 | 1388 | $settings['rows_color'] = isset( $settings['rows_color'] ) && $settings['rows_color'] != '' ? json_decode($settings['rows_color'], true) : array_fill(0, $count_rows, ''); |
| @@ -1359,29 +1397,69 @@ | ||
| 1359 | 1397 | * |
| 1360 | 1398 | * @access public |
| 1361 | 1399 | * @return array |
| 1362 | 1400 | */ |
| 1363 | - public function get_chart_settings_chartjs_admin ($settings) { | |
| 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 | + | |
| 1364 | 1404 | $title_positions = array( |
| 1365 | - "left" => __("Left", "chart-builder"), | |
| 1366 | - "right" => __("Right", "chart-builder"), | |
| 1367 | - "center" => __("Center", "chart-builder") | |
| 1405 | + "left" => __("Left", "chart-builder"), | |
| 1406 | + "right" => __("Right", "chart-builder"), | |
| 1407 | + "center" => __("Center", "chart-builder") | |
| 1368 | 1408 | ); |
| 1369 | 1409 | |
| 1370 | 1410 | $text_transforms = array( |
| 1371 | - "uppercase" => __("Uppercase", "chart-builder"), | |
| 1372 | - "lowercase" => __("Lowercase", "chart-builder"), | |
| 1373 | - "capitalize" => __("Capitalize", "chart-builder"), | |
| 1374 | - "none" => __("None", "chart-builder"), | |
| 1411 | + "uppercase" => __("Uppercase", "chart-builder"), | |
| 1412 | + "lowercase" => __("Lowercase", "chart-builder"), | |
| 1413 | + "capitalize" => __("Capitalize", "chart-builder"), | |
| 1414 | + "none" => __("None", "chart-builder"), | |
| 1375 | 1415 | ); |
| 1376 | 1416 | |
| 1377 | 1417 | $text_decorations = array( |
| 1378 | - "overline" => __("Overline", "chart-builder"), | |
| 1379 | - "underline" => __("Underline", "chart-builder"), | |
| 1380 | - "line-through" => __("Line through", "chart-builder"), | |
| 1381 | - "none" => __("None", "chart-builder"), | |
| 1418 | + "overline" => __("Overline", "chart-builder"), | |
| 1419 | + "underline" => __("Underline", "chart-builder"), | |
| 1420 | + "line-through" => __("Line through", "chart-builder"), | |
| 1421 | + "none" => __("None", "chart-builder"), | |
| 1382 | 1422 | ); |
| 1423 | + | |
| 1424 | + $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") | |
| 1433 | + ); | |
| 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 | + ); | |
| 1383 | 1441 | |
| 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 | + | |
| 1384 | 1462 | // Title color |
| 1385 | 1463 | $settings['title_color'] = isset( $settings['title_color'] ) && $settings['title_color'] != '' ? esc_attr( $settings['title_color'] ) : '#000000'; |
| 1386 | 1464 | |
| 1387 | 1465 | // Title color |
| @@ -1455,13 +1533,52 @@ | ||
| 1455 | 1533 | |
| 1456 | 1534 | // description text decoration |
| 1457 | 1535 | $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; |
| 1458 | 1536 | |
| 1537 | + // Box shadow | |
| 1538 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 1539 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 1540 | + | |
| 1541 | + // Border width | |
| 1542 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 1543 | + | |
| 1544 | + // Border radius | |
| 1545 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 1546 | + | |
| 1547 | + // Border color | |
| 1548 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000'; | |
| 1549 | + | |
| 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 | + // Border style | |
| 1570 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1571 | + $settings['border_styles'] = $border_styles; | |
| 1572 | + | |
| 1573 | + // slice_spacing | |
| 1574 | + $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1; | |
| 1575 | + | |
| 1459 | 1576 | // outer_radius |
| 1460 | 1577 | $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100; |
| 1461 | 1578 | |
| 1462 | - // slice_spacing | |
| 1463 | - $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1; | |
| 1579 | + // Padding outer | |
| 1580 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1464 | 1581 | |
| 1465 | 1582 | // circumference |
| 1466 | 1583 | $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360; |
| 1467 | 1584 | |
| @@ -1483,8 +1600,53 @@ | ||
| 1483 | 1600 | $settings['show_title'] = ( $settings['show_title'] != '' ) ? $settings['show_title'] : 'off'; |
| 1484 | 1601 | $settings['show_title'] = isset( $settings['show_title'] ) && $settings['show_title'] == 'on' ? 'checked' : ''; |
| 1485 | 1602 | } |
| 1486 | 1603 | |
| 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 | + // Legend font color | |
| 1624 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 1625 | + | |
| 1626 | + // Legend font size | |
| 1627 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12; | |
| 1628 | + | |
| 1629 | + // Legend position | |
| 1630 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top'; | |
| 1631 | + $settings['legend_positions'] = $legend_positions; | |
| 1632 | + | |
| 1633 | + // Legend alignment | |
| 1634 | + $settings['legend_alignment'] = isset( $settings['legend_alignment'] ) && $settings['legend_alignment'] != '' ? esc_attr( $settings['legend_alignment'] ) : 'start'; | |
| 1635 | + $settings['legend_alignments'] = $legend_alignments; | |
| 1636 | + | |
| 1637 | + // Legend Italic text | |
| 1638 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 1639 | + $settings['legend_italic'] = isset( $settings['legend_italic'] ) && $settings['legend_italic'] == 'on' ? 'checked' : ''; | |
| 1640 | + | |
| 1641 | + // Legend Bold text | |
| 1642 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 1643 | + $settings['legend_bold'] = isset( $settings['legend_bold'] ) && $settings['legend_bold'] == 'on' ? 'checked' : ''; | |
| 1644 | + | |
| 1645 | + // Legend reverse | |
| 1646 | + $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off'; | |
| 1647 | + $settings['legend_reverse'] = isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] == 'on' ? 'checked' : ''; | |
| 1648 | + | |
| 1487 | 1649 | return $settings; |
| 1488 | 1650 | |
| 1489 | 1651 | } |
| 1490 | 1652 | |
| @@ -1493,9 +1655,21 @@ | ||
| 1493 | 1655 | * |
| 1494 | 1656 | * @access public |
| 1495 | 1657 | * @return array |
| 1496 | 1658 | */ |
| 1497 | - public function get_chart_settings_chartjs_public ($settings) { | |
| 1659 | + public function get_chart_settings_chartjs_public($settings, $chartData) { | |
| 1660 | + $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'); | |
| 1661 | + // echo "<pre>"; var_dump($settings); echo "</pre>"; | |
| 1662 | + // Width | |
| 1663 | + $settings['width'] = isset( $settings['width'] ) && $settings['width'] != '' ? esc_attr( $settings['width'] ) : '100'; | |
| 1664 | + $settings['width_format'] = isset( $settings['width_format'] ) && $settings['width_format'] != '' ? esc_attr( $settings['width_format'] ) : '%'; | |
| 1665 | + $settings['chart_width'] = $settings['width'].$settings['width_format']; | |
| 1666 | + | |
| 1667 | + // height | |
| 1668 | + $settings['height'] = isset( $settings['height'] ) && $settings['height'] != '' ? esc_attr( $settings['height'] ) : '100'; | |
| 1669 | + $settings['height_format'] = isset( $settings['height_format'] ) && $settings['height_format'] != '' ? esc_attr( $settings['height_format'] ) : '%'; | |
| 1670 | + $settings['chart_height'] = $settings['height'].$settings['height_format']; | |
| 1671 | + | |
| 1498 | 1672 | // Show chart description |
| 1499 | 1673 | $settings['show_description'] = isset( $settings['show_description'] ) && $settings['show_description'] != '' ? esc_attr( $settings['show_description'] ) : 'on'; |
| 1500 | 1674 | |
| 1501 | 1675 | // Show chart title |
| @@ -1572,8 +1746,45 @@ | ||
| 1572 | 1746 | |
| 1573 | 1747 | // description text decoration |
| 1574 | 1748 | $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; |
| 1575 | 1749 | |
| 1750 | + // Box shadow | |
| 1751 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 1752 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 1753 | + | |
| 1754 | + // Border width | |
| 1755 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 1756 | + | |
| 1757 | + // Border radius | |
| 1758 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 1759 | + | |
| 1760 | + // Border color | |
| 1761 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000'; | |
| 1762 | + | |
| 1763 | + //Box shadow color | |
| 1764 | + $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; | |
| 1765 | + | |
| 1766 | + // Border style | |
| 1767 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1768 | + | |
| 1769 | + // Background color | |
| 1770 | + $settings['background_color_chart'] = isset( $settings['background_color_chart'] ) && $settings['background_color_chart'] != '' ? esc_attr( $settings['background_color_chart'] ) : '#ffffff'; | |
| 1771 | + | |
| 1772 | + // Border width with title | |
| 1773 | + $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; | |
| 1774 | + | |
| 1775 | + // Border radius with title | |
| 1776 | + $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0'; | |
| 1777 | + | |
| 1778 | + // Border color with title | |
| 1779 | + $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; | |
| 1780 | + | |
| 1781 | + // Border style with title | |
| 1782 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 1783 | + | |
| 1784 | + // Padding outer | |
| 1785 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1786 | + | |
| 1576 | 1787 | // outer_radius |
| 1577 | 1788 | $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100; |
| 1578 | 1789 | |
| 1579 | 1790 | // slice_spacing |
| @@ -1583,9 +1794,44 @@ | ||
| 1583 | 1794 | $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360; |
| 1584 | 1795 | |
| 1585 | 1796 | // start_angle |
| 1586 | 1797 | $settings['start_angle'] = isset( $settings['start_angle'] ) && $settings['start_angle'] != '' ? esc_attr( absint($settings['start_angle']) ) : 0; |
| 1798 | + | |
| 1799 | + $count_slices = (isset($chartData['source']) && !is_null($chartData['source']) && count($chartData['source']) > 0) ? count($chartData['source']) - 1 : 0; | |
| 1800 | + // Slices settings | |
| 1801 | + $settings['slice_colors_default'] = $chart_default_colors; | |
| 1802 | + $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : $chart_default_colors; | |
| 1587 | 1803 | |
| 1804 | + // Slice border color | |
| 1805 | + $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff'; | |
| 1806 | + | |
| 1807 | + // Slice border color | |
| 1808 | + $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']); | |
| 1809 | + | |
| 1810 | + // Slices border width | |
| 1811 | + $settings['slice_border_width'] = isset( $settings['slice_border_width'] ) && $settings['slice_border_width'] != '' ? esc_attr( $settings['slice_border_width'] ) : '1'; | |
| 1812 | + | |
| 1813 | + // Tooltip text color | |
| 1814 | + $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#fff'; | |
| 1815 | + | |
| 1816 | + // Legend font color | |
| 1817 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 1818 | + | |
| 1819 | + // Legend font size | |
| 1820 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12; | |
| 1821 | + | |
| 1822 | + // Legend position | |
| 1823 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top'; | |
| 1824 | + | |
| 1825 | + // Legend Italic text | |
| 1826 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 1827 | + | |
| 1828 | + // Legend Bold text | |
| 1829 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 1830 | + | |
| 1831 | + // Legend reverse | |
| 1832 | + $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off'; | |
| 1833 | + | |
| 1588 | 1834 | return $settings; |
| 1589 | 1835 | |
| 1590 | 1836 | } |
| 1591 | 1837 | } |