| 1 |
<?php |
| 2 |
/* |
| 3 |
+=====================================================================+ |
| 4 |
| ____ _ ____ __ _ _ | |
| 5 |
| / ___|___ __| | ___ | _ \ _ __ ___ / _(_) | ___ _ __ | |
| 6 |
| | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| | |
| 7 |
| | |__| (_) | (_| | __/ | __/| | | (_) | _| | | __/ | | |
| 8 |
| \____\___/ \__,_|\___| |_| |_| \___/|_| |_|_|\___|_| | |
| 9 |
| | |
| 10 |
| (c) Jerome Bruandet ~ https://nintechnet.com/codeprofiler/ | |
| 11 |
+=====================================================================+ |
| 12 |
*/ |
| 13 |
|
| 14 |
if (! defined( 'ABSPATH' ) ) { die('Forbidden'); } |
| 15 |
|
| 16 |
// ===================================================================== |
| 17 |
// Display selected profile. |
| 18 |
|
| 19 |
// Display the profile name |
| 20 |
if ( preg_match('`/\d{10}\.\d+?\.(.+)$`', $profile_path, $match ) ) { |
| 21 |
$profile_name = sanitize_file_name( $match[1] ); |
| 22 |
} else { |
| 23 |
$profile_name = 'profile'; |
| 24 |
} |
| 25 |
// Fetch summary to display in tooltip (CP >1.2) |
| 26 |
$summary_stats = code_profiler_getsummarystats( $profile_path ); |
| 27 |
|
| 28 |
?><br /> |
| 29 |
<div class="alignleft actions bulkactions"> |
| 30 |
<select style="max-width: none;" onchange='window.location="?page=code-profiler&cptab=profiles_list&action=view_profile§ion=" + this.value;'> |
| 31 |
<?php |
| 32 |
foreach( $section_list as $num => $section_name ) { |
| 33 |
$orderby = ''; |
| 34 |
$order = ''; |
| 35 |
// Set the sorting order for the select box URI |
| 36 |
if ( $num == 2 || $num == 3 ) { |
| 37 |
$orderby = 'time'; $order = 'desc'; |
| 38 |
} elseif ( $num == 4 ) { |
| 39 |
$orderby = 'order'; $order = 'asc'; |
| 40 |
} |
| 41 |
echo '<option value="'. (int) $num . |
| 42 |
sprintf( |
| 43 |
'&id=%s&orderby=%s&order=%s', |
| 44 |
esc_attr( $id ), |
| 45 |
esc_attr( $orderby ), |
| 46 |
esc_attr( $order ) |
| 47 |
) .'"'. |
| 48 |
selected( $num, $section, false ) .'>'. |
| 49 |
sprintf( |
| 50 |
esc_html__('Page %s: %s', 'code-profiler'), |
| 51 |
(int) $num, |
| 52 |
esc_html( $section_name ) |
| 53 |
) . |
| 54 |
'</option>'; |
| 55 |
} |
| 56 |
?> |
| 57 |
</select> |
| 58 |
<?php |
| 59 |
if ( $section > 1 ) { |
| 60 |
if ( $section == 3 || $section == 4 ) { |
| 61 |
$orderby = 'time'; |
| 62 |
$order = 'desc'; |
| 63 |
} elseif ( $section == 5 ) { |
| 64 |
$orderby = 'order'; |
| 65 |
$order = 'asc'; |
| 66 |
} |
| 67 |
?> |
| 68 |
<a class="prev-page button" href="?page=code-profiler&cptab=profiles_list&action=view_profile&id=<?php echo esc_attr( $id ) ?>§ion=<?php echo esc_attr( $section - 1 ) ?><?php |
| 69 |
sprintf( |
| 70 |
'&orderby=%s&order=%s', |
| 71 |
esc_attr( $orderby ), |
| 72 |
esc_attr( $order ) |
| 73 |
) |
| 74 |
?>">‹</a> |
| 75 |
|
| 76 |
<?php |
| 77 |
} else { |
| 78 |
?> |
| 79 |
<input type="button" class="prev-page button" value="‹" disabled /> |
| 80 |
<?php |
| 81 |
} |
| 82 |
if ( $section < count( $section_list ) ) { |
| 83 |
if ( $section == 1 || $section == 2 ) { |
| 84 |
$orderby = 'time'; |
| 85 |
$order = 'desc'; |
| 86 |
} elseif ( $section == 3 ) { |
| 87 |
$orderby = 'order'; |
| 88 |
$order = 'asc'; |
| 89 |
} |
| 90 |
?> |
| 91 |
<a class="next-page button" href="?page=code-profiler&cptab=profiles_list&action=view_profile&id=<?php echo esc_attr( $id ) ?>§ion=<?php echo esc_attr( $section + 1 ) ?><?php |
| 92 |
sprintf( |
| 93 |
'&orderby=%s&order=%s', |
| 94 |
esc_attr( $orderby ), |
| 95 |
esc_attr( $order ) |
| 96 |
) |
| 97 |
?>">›</a> |
| 98 |
<?php |
| 99 |
|
| 100 |
} else { |
| 101 |
?> |
| 102 |
<input class="next-page button" type="button" value="›" disabled /> |
| 103 |
<?php |
| 104 |
} |
| 105 |
if ( $section != 4 ) { |
| 106 |
echo '<p><span class="description">'; |
| 107 |
printf( esc_html__( 'Viewing: %s', 'code-profiler' ), esc_html( $match[1] ) ); |
| 108 |
echo '</span>'; |
| 109 |
if ( $summary_stats ) { |
| 110 |
echo '<span class="code-profiler-tip" data-tip="'. esc_attr( $summary_stats ) .'"></span>'; |
| 111 |
} |
| 112 |
echo '</p>'; |
| 113 |
} |
| 114 |
?> |
| 115 |
</div> |
| 116 |
<?php |
| 117 |
$suffix = ''; |
| 118 |
if ( $section == 1 ) { |
| 119 |
require 'menu_view_plugins.php'; |
| 120 |
$suffix = 'plugins'; |
| 121 |
|
| 122 |
} elseif ( $section == 2 ) { |
| 123 |
require 'menu_view_iostats.php'; |
| 124 |
$suffix = 'iostats'; |
| 125 |
|
| 126 |
} elseif ( $section == 3 ) { |
| 127 |
require 'menu_view_diskio.php'; |
| 128 |
$suffix = 'diskio'; |
| 129 |
|
| 130 |
} elseif ( $section == 4 ) { |
| 131 |
require 'menu_pro.php'; |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
if ( isset( $buffer['error'] ) ) { |
| 136 |
echo $buffer['error']; |
| 137 |
return; |
| 138 |
} |
| 139 |
|
| 140 |
if ( $section == 4 ) { return; } |
| 141 |
|
| 142 |
// Display footer with help, menu and buttons. |
| 143 |
|
| 144 |
// Hide it while the graphs are loading |
| 145 |
if ( $section == 1 || $section == 2 || $section == 3 ) { |
| 146 |
echo '<div id="cp-footer-buttons" style="display:none" class="tablenav bottom">'; |
| 147 |
} else { |
| 148 |
echo '<div class="tablenav bottom">'; |
| 149 |
} |
| 150 |
|
| 151 |
?> |
| 152 |
<div id="cp-footer-help" style="display:none"> |
| 153 |
<?php include 'help.php'; ?> |
| 154 |
<br /> |
| 155 |
</div> |
| 156 |
|
| 157 |
<div style="text-align:center;"> |
| 158 |
<?php |
| 159 |
if (! empty( $hidden ) ) { |
| 160 |
echo '<p class="description">'; |
| 161 |
printf( esc_html__('Hidden items: %s', 'code-profiler'), $hidden ); |
| 162 |
|
| 163 |
if ( $type == 'slugs' && isset( $hidden_max_plugins ) ) { |
| 164 |
?> |
| 165 |
<span class="code-profiler-tip" data-tip="<?php printf( esc_attr__('Only the first %s plugins will be shown on the graph. You can modify that value in the "Settings" page.', 'code-profiler' ), (int) $chart_max_plugins ) ?>"></span> |
| 166 |
</p> |
| 167 |
<?php |
| 168 |
} else { |
| 169 |
?> |
| 170 |
<span class="code-profiler-tip" data-tip="<?php esc_attr_e('Items that have an empty value are not shown. If you want to display them anyway, you can enable that option in the "Settings" page.', 'code-profiler' ) ?>"></span> |
| 171 |
</p> |
| 172 |
<?php |
| 173 |
} |
| 174 |
} |
| 175 |
?> |
| 176 |
</div> |
| 177 |
|
| 178 |
<div class="alignleft actions bulkactions"> |
| 179 |
<input type="button" class="button button-primary" style="min-width:100px" value="<?php esc_attr_e('Help', 'code-profiler' )?>" onclick="jQuery('#cp-footer-help').slideToggle(500);"/> |
| 180 |
</div> |
| 181 |
|
| 182 |
<div class="tablenav-pages"> |
| 183 |
|
| 184 |
<?php |
| 185 |
if ( isset( $rotate_img ) ) { |
| 186 |
?> |
| 187 |
<button type="button" class="button button-secondary" id="htov" title="<?php esc_attr_e('Click to rotate graph', 'code-profiler' )?>"><span class="dashicons dashicons-image-rotate" style="vertical-align: sub;"></span></button> |
| 188 |
<?php |
| 189 |
} |
| 190 |
if ( isset( $save_png ) ) { |
| 191 |
?> |
| 192 |
<a type="button" class="button button-secondary" id="download-png-img" download="<?php echo esc_attr("{$profile_name}_{$suffix}") ?>.png" title="<?php esc_attr_e('Click to download as an image', 'code-profiler' )?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-download" style="vertical-align: sub;"></span><?php esc_attr_e('Download as a PNG image', 'code-profiler' )?></a> |
| 193 |
<?php |
| 194 |
} |
| 195 |
?> |
| 196 |
</div> |
| 197 |
</div> |
| 198 |
|
| 199 |
<?php |
| 200 |
|
| 201 |
// ===================================================================== |
| 202 |
// EOF |
| 203 |
|