| @@ -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, |
| @@ -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,15 @@ | ||
| 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 | + | |
| 614 | + // Padding outer | |
| 615 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 616 | + | |
| 589 | 617 | // Box shadow color |
| 590 | 618 | $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; |
| 591 | 619 | |
| 592 | 620 | // Chart Area background color |
| @@ -887,8 +915,10 @@ | ||
| 887 | 915 | $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic'; |
| 888 | 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'; |
| 889 | 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'; |
| 890 | 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' : ''; | |
| 891 | 921 | $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null; |
| 892 | 922 | $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null; |
| 893 | 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'; |
| 894 | 924 | $settings['haxis_italic'] = isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] == 'on' ? 'checked' : ''; |
| @@ -911,8 +941,10 @@ | ||
| 911 | 941 | $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000'; |
| 912 | 942 | $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000'; |
| 913 | 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']; |
| 914 | 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' : ''; | |
| 915 | 947 | $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null; |
| 916 | 948 | $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null; |
| 917 | 949 | $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1; |
| 918 | 950 | $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off'; |
| @@ -956,9 +988,10 @@ | ||
| 956 | 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'); |
| 957 | 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']); |
| 958 | 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']); |
| 959 | 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']); |
| 960 | - | |
| 992 | + $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, ''); | |
| 993 | + | |
| 961 | 994 | // Rows settings |
| 962 | 995 | $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on'; |
| 963 | 996 | $settings['enable_row_settings'] = isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] == 'on' ? 'checked' : ''; |
| 964 | 997 | |
| @@ -1020,8 +1053,11 @@ | ||
| 1020 | 1053 | |
| 1021 | 1054 | // Border color |
| 1022 | 1055 | $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#666666'; |
| 1023 | 1056 | |
| 1057 | + // Border style | |
| 1058 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1059 | + | |
| 1024 | 1060 | // Border width with title |
| 1025 | 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'; |
| 1026 | 1062 | |
| 1027 | 1063 | // Border radius with title |
| @@ -1029,8 +1065,14 @@ | ||
| 1029 | 1065 | |
| 1030 | 1066 | // Border color with title |
| 1031 | 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'; |
| 1032 | 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 | + | |
| 1072 | + // Padding outer | |
| 1073 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1074 | + | |
| 1033 | 1075 | // Box shadow color |
| 1034 | 1076 | $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; |
| 1035 | 1077 | |
| 1036 | 1078 | // Chart Area background color |
| @@ -1281,8 +1323,9 @@ | ||
| 1281 | 1323 | $settings['haxis_slanted'] = isset( $settings['haxis_slanted'] ) && $settings['haxis_slanted'] != '' ? esc_attr( $settings['haxis_slanted'] ) : 'automatic'; |
| 1282 | 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'; |
| 1283 | 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'; |
| 1284 | 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'; | |
| 1285 | 1328 | $settings['haxis_max_value'] = isset( $settings['haxis_max_value'] ) && $settings['haxis_max_value'] != '' ? esc_attr( $settings['haxis_max_value'] ) : null; |
| 1286 | 1329 | $settings['haxis_min_value'] = isset( $settings['haxis_min_value'] ) && $settings['haxis_min_value'] != '' ? esc_attr( $settings['haxis_min_value'] ) : null; |
| 1287 | 1330 | $settings['haxis_gridlines_count'] = isset( $settings['haxis_gridlines_count'] ) && $settings['haxis_gridlines_count'] != '' ? esc_attr( $settings['haxis_gridlines_count'] ) : -1; |
| 1288 | 1331 | $settings['haxis_italic'] = ( isset( $settings['haxis_italic'] ) && $settings['haxis_italic'] != '' ) ? $settings['haxis_italic'] : 'off'; |
| @@ -1301,8 +1344,9 @@ | ||
| 1301 | 1344 | $settings['vaxis_text_color'] = isset( $settings['vaxis_text_color'] ) && $settings['vaxis_text_color'] != '' ? esc_attr( $settings['vaxis_text_color'] ) : '#000000'; |
| 1302 | 1345 | $settings['vaxis_baseline_color'] = isset( $settings['vaxis_baseline_color'] ) && $settings['vaxis_baseline_color'] != '' ? esc_attr( $settings['vaxis_baseline_color'] ) : '#000000'; |
| 1303 | 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']; |
| 1304 | 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'; | |
| 1305 | 1349 | $settings['vaxis_max_value'] = isset( $settings['vaxis_max_value'] ) && $settings['vaxis_max_value'] != '' ? esc_attr( $settings['vaxis_max_value'] ) : null; |
| 1306 | 1350 | $settings['vaxis_min_value'] = isset( $settings['vaxis_min_value'] ) && $settings['vaxis_min_value'] != '' ? esc_attr( $settings['vaxis_min_value'] ) : null; |
| 1307 | 1351 | $settings['vaxis_gridlines_count'] = isset( $settings['vaxis_gridlines_count'] ) && $settings['vaxis_gridlines_count'] != '' ? esc_attr( $settings['vaxis_gridlines_count'] ) : -1; |
| 1308 | 1352 | $settings['vaxis_italic'] = ( isset( $settings['vaxis_italic'] ) && $settings['vaxis_italic'] != '' ) ? $settings['vaxis_italic'] : 'off'; |
| @@ -1336,9 +1380,9 @@ | ||
| 1336 | 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'); |
| 1337 | 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']); |
| 1338 | 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']); |
| 1339 | 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']); |
| 1340 | - | |
| 1384 | + $settings['series_format'] = isset( $settings['series_format'] ) && $settings['series_format'] != '' ? json_decode($settings['series_format'], true) : array_fill(0, $count_series, ''); | |
| 1341 | 1385 | // Rows settings |
| 1342 | 1386 | $settings['enable_row_settings'] = ( isset( $settings['enable_row_settings'] ) && $settings['enable_row_settings'] != '' ) ? $settings['enable_row_settings'] : 'on'; |
| 1343 | 1387 | |
| 1344 | 1388 | $settings['rows_color'] = isset( $settings['rows_color'] ) && $settings['rows_color'] != '' ? json_decode($settings['rows_color'], true) : array_fill(0, $count_rows, ''); |
| @@ -1354,8 +1398,10 @@ | ||
| 1354 | 1398 | * @access public |
| 1355 | 1399 | * @return array |
| 1356 | 1400 | */ |
| 1357 | 1401 | public function get_chart_settings_chartjs_admin ($settings) { |
| 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 | + | |
| 1358 | 1404 | $title_positions = array( |
| 1359 | 1405 | "left" => __("Left", "chart-builder"), |
| 1360 | 1406 | "right" => __("Right", "chart-builder"), |
| 1361 | 1407 | "center" => __("Center", "chart-builder") |
| @@ -1373,9 +1419,33 @@ | ||
| 1373 | 1419 | "underline" => __("Underline", "chart-builder"), |
| 1374 | 1420 | "line-through" => __("Line through", "chart-builder"), |
| 1375 | 1421 | "none" => __("None", "chart-builder"), |
| 1376 | 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 | + ); | |
| 1377 | 1441 | |
| 1442 | + $legend_alignments = array( | |
| 1443 | + "start" => __("Start", "chart-builder"), | |
| 1444 | + "center" => __("Center", "chart-builder"), | |
| 1445 | + "end" => __("End", "chart-builder"), | |
| 1446 | + ); | |
| 1447 | + | |
| 1378 | 1448 | // Title color |
| 1379 | 1449 | $settings['title_color'] = isset( $settings['title_color'] ) && $settings['title_color'] != '' ? esc_attr( $settings['title_color'] ) : '#000000'; |
| 1380 | 1450 | |
| 1381 | 1451 | // Title color |
| @@ -1449,13 +1519,52 @@ | ||
| 1449 | 1519 | |
| 1450 | 1520 | // description text decoration |
| 1451 | 1521 | $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; |
| 1452 | 1522 | |
| 1523 | + // Box shadow | |
| 1524 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 1525 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 1526 | + | |
| 1527 | + // Border width | |
| 1528 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 1529 | + | |
| 1530 | + // Border radius | |
| 1531 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 1532 | + | |
| 1533 | + // Border color | |
| 1534 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000'; | |
| 1535 | + | |
| 1536 | + // Background color | |
| 1537 | + $settings['background_color_chart'] = isset( $settings['background_color_chart'] ) && $settings['background_color_chart'] != '' ? esc_attr( $settings['background_color_chart'] ) : '#ffffff'; | |
| 1538 | + | |
| 1539 | + // Border width with title | |
| 1540 | + $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; | |
| 1541 | + | |
| 1542 | + // Border radius with title | |
| 1543 | + $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0'; | |
| 1544 | + | |
| 1545 | + // Border color with title | |
| 1546 | + $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; | |
| 1547 | + | |
| 1548 | + // Border style with title | |
| 1549 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 1550 | + $settings['border_styles'] = $border_styles; | |
| 1551 | + | |
| 1552 | + //Box shadow color | |
| 1553 | + $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; | |
| 1554 | + | |
| 1555 | + // Border style | |
| 1556 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1557 | + $settings['border_styles'] = $border_styles; | |
| 1558 | + | |
| 1559 | + // slice_spacing | |
| 1560 | + $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1; | |
| 1561 | + | |
| 1453 | 1562 | // outer_radius |
| 1454 | 1563 | $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100; |
| 1455 | 1564 | |
| 1456 | - // slice_spacing | |
| 1457 | - $settings['slice_spacing'] = isset( $settings['slice_spacing'] ) && $settings['slice_spacing'] != '' ? esc_attr( absint($settings['slice_spacing']) ) : 1; | |
| 1565 | + // Padding outer | |
| 1566 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1458 | 1567 | |
| 1459 | 1568 | // circumference |
| 1460 | 1569 | $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360; |
| 1461 | 1570 | |
| @@ -1477,8 +1586,49 @@ | ||
| 1477 | 1586 | $settings['show_title'] = ( $settings['show_title'] != '' ) ? $settings['show_title'] : 'off'; |
| 1478 | 1587 | $settings['show_title'] = isset( $settings['show_title'] ) && $settings['show_title'] == 'on' ? 'checked' : ''; |
| 1479 | 1588 | } |
| 1480 | 1589 | |
| 1590 | + $count_slices = (isset($counting_source) && !is_null($counting_source) && count($counting_source) > 0) ? count($counting_source) - 1 : 0; | |
| 1591 | + | |
| 1592 | + // Slices settings | |
| 1593 | + $settings['slice_colors_default'] = $chart_default_colors; | |
| 1594 | + $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : array_slice($chart_default_colors, 0, $count_slices);; | |
| 1595 | + | |
| 1596 | + // Slice border color | |
| 1597 | + $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff'; | |
| 1598 | + | |
| 1599 | + // Slices border width | |
| 1600 | + $settings['slice_border_width'] = isset( $settings['slice_border_width'] ) && $settings['slice_border_width'] != '' ? esc_attr( $settings['slice_border_width'] ) : '1'; | |
| 1601 | + | |
| 1602 | + // Tooltip text color | |
| 1603 | + $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#fff'; | |
| 1604 | + | |
| 1605 | + // Legend font color | |
| 1606 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 1607 | + | |
| 1608 | + // Legend font size | |
| 1609 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12; | |
| 1610 | + | |
| 1611 | + // Legend position | |
| 1612 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top'; | |
| 1613 | + $settings['legend_positions'] = $legend_positions; | |
| 1614 | + | |
| 1615 | + // Legend alignment | |
| 1616 | + $settings['legend_alignment'] = isset( $settings['legend_alignment'] ) && $settings['legend_alignment'] != '' ? esc_attr( $settings['legend_alignment'] ) : 'start'; | |
| 1617 | + $settings['legend_alignments'] = $legend_alignments; | |
| 1618 | + | |
| 1619 | + // Legend Italic text | |
| 1620 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 1621 | + $settings['legend_italic'] = isset( $settings['legend_italic'] ) && $settings['legend_italic'] == 'on' ? 'checked' : ''; | |
| 1622 | + | |
| 1623 | + // Legend Bold text | |
| 1624 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 1625 | + $settings['legend_bold'] = isset( $settings['legend_bold'] ) && $settings['legend_bold'] == 'on' ? 'checked' : ''; | |
| 1626 | + | |
| 1627 | + // Legend reverse | |
| 1628 | + $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off'; | |
| 1629 | + $settings['legend_reverse'] = isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] == 'on' ? 'checked' : ''; | |
| 1630 | + | |
| 1481 | 1631 | return $settings; |
| 1482 | 1632 | |
| 1483 | 1633 | } |
| 1484 | 1634 | |
| @@ -1488,8 +1638,9 @@ | ||
| 1488 | 1638 | * @access public |
| 1489 | 1639 | * @return array |
| 1490 | 1640 | */ |
| 1491 | 1641 | public function get_chart_settings_chartjs_public ($settings) { |
| 1642 | + $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'); | |
| 1492 | 1643 | // Show chart description |
| 1493 | 1644 | $settings['show_description'] = isset( $settings['show_description'] ) && $settings['show_description'] != '' ? esc_attr( $settings['show_description'] ) : 'on'; |
| 1494 | 1645 | |
| 1495 | 1646 | // Show chart title |
| @@ -1566,8 +1717,45 @@ | ||
| 1566 | 1717 | |
| 1567 | 1718 | // description text decoration |
| 1568 | 1719 | $settings['description_text_decoration'] = isset( $settings['description_text_decoration'] ) && $settings['description_text_decoration'] != '' ? esc_attr( $settings['description_text_decoration'] ) : 'none'; |
| 1569 | 1720 | |
| 1721 | + // Box shadow | |
| 1722 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] != '' ? esc_attr( $settings['box_shadow'] ) : 'off'; | |
| 1723 | + $settings['box_shadow'] = isset( $settings['box_shadow'] ) && $settings['box_shadow'] == 'on' ? 'checked' : ''; | |
| 1724 | + | |
| 1725 | + // Border width | |
| 1726 | + $settings['border_width'] = isset( $settings['border_width'] ) && $settings['border_width'] != '' ? esc_attr( $settings['border_width'] ) : '0'; | |
| 1727 | + | |
| 1728 | + // Border radius | |
| 1729 | + $settings['border_radius'] = isset( $settings['border_radius'] ) && $settings['border_radius'] != '' ? esc_attr( $settings['border_radius'] ) : '0'; | |
| 1730 | + | |
| 1731 | + // Border color | |
| 1732 | + $settings['border_color'] = isset( $settings['border_color'] ) && $settings['border_color'] != '' ? esc_attr( $settings['border_color'] ) : '#000000'; | |
| 1733 | + | |
| 1734 | + //Box shadow color | |
| 1735 | + $settings['box_shadow_color'] = isset( $settings['box_shadow_color'] ) && $settings['box_shadow_color'] != '' ? esc_attr( $settings['box_shadow_color'] ) : $settings['border_color']; | |
| 1736 | + | |
| 1737 | + // Border style | |
| 1738 | + $settings['border_style'] = isset( $settings['border_style'] ) && $settings['border_style'] != '' ? esc_attr( $settings['border_style'] ) : 'solid'; | |
| 1739 | + | |
| 1740 | + // Background color | |
| 1741 | + $settings['background_color_chart'] = isset( $settings['background_color_chart'] ) && $settings['background_color_chart'] != '' ? esc_attr( $settings['background_color_chart'] ) : '#ffffff'; | |
| 1742 | + | |
| 1743 | + // Border width with title | |
| 1744 | + $settings['border_width_with_title'] = isset( $settings['border_width_with_title'] ) && $settings['border_width_with_title'] != '' ? esc_attr( $settings['border_width_with_title'] ) : '0'; | |
| 1745 | + | |
| 1746 | + // Border radius with title | |
| 1747 | + $settings['border_radius_with_title'] = isset( $settings['border_radius_with_title'] ) && $settings['border_radius_with_title'] != '' ? esc_attr( $settings['border_radius_with_title'] ) : '0'; | |
| 1748 | + | |
| 1749 | + // Border color with title | |
| 1750 | + $settings['border_color_with_title'] = isset( $settings['border_color_with_title'] ) && $settings['border_color_with_title'] != '' ? esc_attr( $settings['border_color_with_title'] ) : '#000000'; | |
| 1751 | + | |
| 1752 | + // Border style with title | |
| 1753 | + $settings['border_style_with_title'] = isset( $settings['border_style_with_title'] ) && $settings['border_style_with_title'] != '' ? esc_attr( $settings['border_style_with_title'] ) : 'solid'; | |
| 1754 | + | |
| 1755 | + // Padding outer | |
| 1756 | + $settings['padding_outer'] = isset( $settings['padding_outer'] ) && $settings['padding_outer'] != '' ? esc_attr( $settings['padding_outer'] ) : '0'; | |
| 1757 | + | |
| 1570 | 1758 | // outer_radius |
| 1571 | 1759 | $settings['outer_radius'] = isset( $settings['outer_radius'] ) && $settings['outer_radius'] != '' ? esc_attr( absint($settings['outer_radius']) ) : 100; |
| 1572 | 1760 | |
| 1573 | 1761 | // slice_spacing |
| @@ -1577,9 +1765,41 @@ | ||
| 1577 | 1765 | $settings['circumference'] = isset( $settings['circumference'] ) && $settings['circumference'] != '' ? esc_attr( absint($settings['circumference']) ) : 360; |
| 1578 | 1766 | |
| 1579 | 1767 | // start_angle |
| 1580 | 1768 | $settings['start_angle'] = isset( $settings['start_angle'] ) && $settings['start_angle'] != '' ? esc_attr( absint($settings['start_angle']) ) : 0; |
| 1769 | + | |
| 1770 | + $count_slices = (isset($chartData['source']) && !is_null($chartData['source']) && count($chartData['source']) > 0) ? count($chartData['source']) - 1 : 0; | |
| 1771 | + // Slices settings | |
| 1772 | + $settings['slice_colors_default'] = $chart_default_colors; | |
| 1773 | + $settings['slice_color'] = isset( $settings['slice_color'] ) && $settings['slice_color'] != '' ? json_decode($settings['slice_color'], true) : $chart_default_colors; | |
| 1581 | 1774 | |
| 1775 | + // Slice border color | |
| 1776 | + $settings['slice_border_color'] = isset( $settings['slice_border_color'] ) && $settings['slice_border_color'] != '' ? esc_attr( $settings['slice_border_color'] ) : '#ffffff'; | |
| 1777 | + | |
| 1778 | + // Slices border width | |
| 1779 | + $settings['slice_border_width'] = isset( $settings['slice_border_width'] ) && $settings['slice_border_width'] != '' ? esc_attr( $settings['slice_border_width'] ) : '1'; | |
| 1780 | + | |
| 1781 | + // Tooltip text color | |
| 1782 | + $settings['tooltip_text_color'] = isset( $settings['tooltip_text_color'] ) && $settings['tooltip_text_color'] != '' ? esc_attr( $settings['tooltip_text_color'] ) : '#fff'; | |
| 1783 | + | |
| 1784 | + // Legend font color | |
| 1785 | + $settings['legend_color'] = isset( $settings['legend_color'] ) && $settings['legend_color'] != '' ? esc_attr( $settings['legend_color'] ) : '#000000'; | |
| 1786 | + | |
| 1787 | + // Legend font size | |
| 1788 | + $settings['legend_font_size'] = isset( $settings['legend_font_size'] ) && intval($settings['legend_font_size']) > 0 ? esc_attr( $settings['legend_font_size'] ) : 12; | |
| 1789 | + | |
| 1790 | + // Legend position | |
| 1791 | + $settings['legend_position'] = isset( $settings['legend_position'] ) && $settings['legend_position'] != '' ? esc_attr( $settings['legend_position'] ) : 'top'; | |
| 1792 | + | |
| 1793 | + // Legend Italic text | |
| 1794 | + $settings['legend_italic'] = ( isset( $settings['legend_italic'] ) && $settings['legend_italic'] != '' ) ? $settings['legend_italic'] : 'off'; | |
| 1795 | + | |
| 1796 | + // Legend Bold text | |
| 1797 | + $settings['legend_bold'] = ( isset( $settings['legend_bold'] ) && $settings['legend_bold'] != '' ) ? $settings['legend_bold'] : 'off'; | |
| 1798 | + | |
| 1799 | + // Legend reverse | |
| 1800 | + $settings['legend_reverse'] = ( isset( $settings['legend_reverse'] ) && $settings['legend_reverse'] != '' ) ? $settings['legend_reverse'] : 'off'; | |
| 1801 | + | |
| 1582 | 1802 | return $settings; |
| 1583 | 1803 | |
| 1584 | 1804 | } |
| 1585 | 1805 | } |