| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package Freemius |
| 4 | 4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 5 | + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 | |
| 6 | 6 | * @since 1.1.7.3 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -9,10 +9,10 @@ | ||
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - if ( class_exists( 'Freemius_Api' ) ) { | |
| 14 | - $logger = Freemius_Api::GetLogger(); | |
| 13 | + if ( class_exists( 'Freemius_Api_WordPress' ) ) { | |
| 14 | + $logger = Freemius_Api_WordPress::GetLogger(); | |
| 15 | 15 | } else { |
| 16 | 16 | $logger = array(); |
| 17 | 17 | } |
| 18 | 18 | |
| @@ -33,11 +33,28 @@ | ||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $pretty_print = $show_body && defined( 'JSON_PRETTY_PRINT' ) && version_compare( phpversion(), '5.3', '>=' ); |
| 36 | 36 | |
| 37 | + /** | |
| 38 | + * This template is used for debugging, therefore, when possible | |
| 39 | + * we'd like to prettify the output of a JSON encoded variable. | |
| 40 | + * This will only be executed when $pretty_print is `true`, and | |
| 41 | + * the var is `true` only for PHP 5.3 and higher. Due to the | |
| 42 | + * limitations of the current Theme Check, it throws an error | |
| 43 | + * that using the "options" parameter (the 2nd param) is not | |
| 44 | + * supported in PHP 5.2 and lower. Thus, we added this alias | |
| 45 | + * variable to work around that false-positive. | |
| 46 | + * | |
| 47 | + * @author Vova Feldman (@svovaf) | |
| 48 | + * @since 1.2.2.7 | |
| 49 | + */ | |
| 50 | + $encode = 'json_encode'; | |
| 51 | + | |
| 37 | 52 | $root_path_len = strlen( ABSPATH ); |
| 53 | + | |
| 54 | + $ms_text = fs_text_x_inline( 'ms', 'milliseconds' ); | |
| 38 | 55 | ?> |
| 39 | -<h1><?php fs_echo( 'API' ) ?></h1> | |
| 56 | +<h1><?php fs_echo_inline( 'API' ) ?></h1> | |
| 40 | 57 | |
| 41 | 58 | <h2><span>Total Time:</span><?php echo Freemius_Debug_Bar_Panel::total_time() ?></h2> |
| 42 | 59 | |
| 43 | 60 | <h2><span>Total Requests:</span><?php echo Freemius_Debug_Bar_Panel::requests_count() ?></h2> |
| @@ -47,18 +64,18 @@ | ||
| 47 | 64 | <table class="widefat"> |
| 48 | 65 | <thead> |
| 49 | 66 | <tr> |
| 50 | 67 | <th>#</th> |
| 51 | - <th><?php fs_echo( 'Method' ) ?></th> | |
| 52 | - <th><?php fs_echo( 'Code' ) ?></th> | |
| 53 | - <th><?php fs_echo( 'Length' ) ?></th> | |
| 54 | - <th><?php fs_echo( 'Path' ) ?></th> | |
| 68 | + <th><?php fs_esc_html_echo_inline( 'Method' ) ?></th> | |
| 69 | + <th><?php fs_esc_html_echo_inline( 'Code' ) ?></th> | |
| 70 | + <th><?php fs_esc_html_echo_inline( 'Length' ) ?></th> | |
| 71 | + <th><?php fs_esc_html_echo_x_inline( 'Path', 'as file/folder path' ) ?></th> | |
| 55 | 72 | <?php if ( $show_body ) : ?> |
| 56 | - <th><?php fs_echo( 'Body' ) ?></th> | |
| 73 | + <th><?php fs_esc_html_echo_inline( 'Body' ) ?></th> | |
| 57 | 74 | <?php endif ?> |
| 58 | - <th><?php fs_echo( 'Result' ) ?></th> | |
| 59 | - <th><?php fs_echo( 'Start' ) ?></th> | |
| 60 | - <th><?php fs_echo( 'End' ) ?></th> | |
| 75 | + <th><?php fs_esc_html_echo_inline( 'Result' ) ?></th> | |
| 76 | + <th><?php fs_esc_html_echo_inline( 'Start' ) ?></th> | |
| 77 | + <th><?php fs_esc_html_echo_inline( 'End' ) ?></th> | |
| 61 | 78 | </tr> |
| 62 | 79 | </thead> |
| 63 | 80 | <tbody> |
| 64 | 81 | <?php foreach ( $logger as $log ) : ?> |
| @@ -65,9 +82,9 @@ | ||
| 65 | 82 | <tr> |
| 66 | 83 | <td><?php echo $log['id'] ?>.</td> |
| 67 | 84 | <td><?php echo $log['method'] ?></td> |
| 68 | 85 | <td><?php echo $log['code'] ?></td> |
| 69 | - <td><?php echo number_format( 100 * $log['total'], 2 ) . ' ' . fs_text( 'ms' ) ?></td> | |
| 86 | + <td><?php echo number_format( 100 * $log['total'], 2 ) . ' ' . $ms_text ?></td> | |
| 70 | 87 | <td> |
| 71 | 88 | <?php |
| 72 | 89 | printf( '<a href="#" onclick="jQuery(this).parent().find(\'table\').toggle(); return false;">%s</a>', |
| 73 | 90 | $log['path'] |
| @@ -98,9 +115,9 @@ | ||
| 98 | 115 | '<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>', |
| 99 | 116 | substr( $body, 0, 32 ) . ( 32 < strlen( $body ) ? '...' : '' ) |
| 100 | 117 | ); |
| 101 | 118 | if ( $pretty_print ) { |
| 102 | - $body = json_encode( json_decode( $log['body'] ), JSON_PRETTY_PRINT ); | |
| 119 | + $body = $encode( json_decode( $log['body'] ), JSON_PRETTY_PRINT ); | |
| 103 | 120 | } |
| 104 | 121 | ?> |
| 105 | 122 | <pre style="display: none"><code><?php echo esc_html( $body ) ?></code></pre> |
| 106 | 123 | <?php endif ?> |
| @@ -121,9 +138,9 @@ | ||
| 121 | 138 | |
| 122 | 139 | if ( $is_not_empty_result && $pretty_print ) { |
| 123 | 140 | $decoded = json_decode( $result ); |
| 124 | 141 | if ( ! is_null( $decoded ) ) { |
| 125 | - $result = json_encode( $decoded, JSON_PRETTY_PRINT ); | |
| 142 | + $result = $encode( $decoded, JSON_PRETTY_PRINT ); | |
| 126 | 143 | } |
| 127 | 144 | } else { |
| 128 | 145 | $result = is_string( $result ) ? $result : json_encode( $result ); |
| 129 | 146 | } |
| @@ -129,10 +146,10 @@ | ||
| 129 | 146 | } |
| 130 | 147 | ?> |
| 131 | 148 | <pre<?php if ( $is_not_empty_result ) : ?> style="display: none"<?php endif ?>><code><?php echo esc_html( $result ) ?></code></pre> |
| 132 | 149 | </td> |
| 133 | - <td><?php echo number_format( 100 * ( $log['start'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . fs_text( 'ms' ) ?></td> | |
| 134 | - <td><?php echo number_format( 100 * ( $log['end'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . fs_text( 'ms' ) ?></td> | |
| 150 | + <td><?php echo number_format( 100 * ( $log['start'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . $ms_text ?></td> | |
| 151 | + <td><?php echo number_format( 100 * ( $log['end'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . $ms_text ?></td> | |
| 135 | 152 | </tr> |
| 136 | 153 | <?php endforeach ?> |
| 137 | 154 | </tbody> |
| 138 | 155 | </table> |