| 1 |
<?php |
| 2 |
/* |
| 3 |
+=====================================================================+ |
| 4 |
| ____ _ ____ __ _ _ | |
| 5 |
| / ___|___ __| | ___ | _ \ _ __ ___ / _(_) | ___ _ __ | |
| 6 |
| | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| | |
| 7 |
| | |__| (_) | (_| | __/ | __/| | | (_) | _| | | __/ | | |
| 8 |
| \____\___/ \__,_|\___| |_| |_| \___/|_| |_|_|\___|_| | |
| 9 |
| | |
| 10 |
| (c) Jerome Bruandet ~ https://code-profiler.com/ | |
| 11 |
+=====================================================================+ |
| 12 |
*/ |
| 13 |
|
| 14 |
if (! defined( 'ABSPATH' ) ) { die( 'Forbidden' ); } |
| 15 |
|
| 16 |
// ===================================================================== |
| 17 |
// Display File I/O stats. |
| 18 |
|
| 19 |
$buffer = code_profiler_get_profile_data( $profile_path, 'iostats' ); |
| 20 |
if ( isset( $buffer['error'] ) ) { |
| 21 |
return; |
| 22 |
} |
| 23 |
// Fetch options |
| 24 |
$cp_options = get_option( 'code-profiler' ); |
| 25 |
// Horizontal vs vertical chart |
| 26 |
if ( empty( $cp_options['chart_type'] ) || ! in_array( $cp_options['chart_type'], ['x', 'y' ] ) ) { |
| 27 |
$axis = 'x'; |
| 28 |
} else { |
| 29 |
$axis = $cp_options['chart_type']; |
| 30 |
} |
| 31 |
|
| 32 |
$label = []; |
| 33 |
$data = ''; |
| 34 |
$color = ''; |
| 35 |
$colorh = ''; |
| 36 |
$colorb = ''; |
| 37 |
$hidden = 0; |
| 38 |
$total_calls = 0; |
| 39 |
foreach( $buffer as $k => $slugs ) { |
| 40 |
if ( empty( $slugs[1] ) && ! empty( $cp_options['hide_empty_value'] ) ) { |
| 41 |
$hidden++; |
| 42 |
continue; |
| 43 |
} |
| 44 |
$label[] = $slugs[0]; |
| 45 |
$data .= "{$slugs[1]},"; |
| 46 |
$total_calls += $slugs[1]; |
| 47 |
} |
| 48 |
$count = count( $label ) - 1; |
| 49 |
$data = rtrim( $data, ',' ); |
| 50 |
|
| 51 |
?> |
| 52 |
<div style="width:80vw;margin:auto"> |
| 53 |
<canvas id="myChart"></canvas> |
| 54 |
</div> |
| 55 |
<script> |
| 56 |
jQuery(document).ready(function() { |
| 57 |
'use strict'; |
| 58 |
cpjs_iostats_chart('<?php echo esc_js( $axis ) ?>', [<?php |
| 59 |
for( $i = 0; $i < $count; $i++ ) { |
| 60 |
echo "'". esc_js( $label[ $i ] ) ."',"; |
| 61 |
} |
| 62 |
echo "'". esc_js( $label[ $i ] ) ."'"; |
| 63 |
?>], |
| 64 |
[<?php echo esc_js( $data ) ?>], <?php echo esc_js( $total_calls ) ?> |
| 65 |
); |
| 66 |
}); |
| 67 |
</script> |
| 68 |
<?php |
| 69 |
// Actions below stats |
| 70 |
$save_png = 1; |
| 71 |
$rotate_img = 1; |
| 72 |
$type = 'iostats'; |
| 73 |
// ===================================================================== |
| 74 |
// EOF |
| 75 |
|