PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.5.0
Spider Elements – Premium Elementor Widgets & Addons Library v1.5.0
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / includes / freemius / templates / debug / api-calls.php
spider-elements / includes / freemius / templates / debug Last commit date
api-calls.php 1 year ago index.php 1 year ago logger.php 1 year ago plugins-themes-sync.php 1 year ago scheduled-crons.php 1 year ago
api-calls.php
155 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.1.7.3
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 if ( class_exists( 'Freemius_Api_WordPress' ) ) {
14 $logger = Freemius_Api_WordPress::GetLogger();
15 } else {
16 $logger = array();
17 }
18
19 $counters = array(
20 'GET' => 0,
21 'POST' => 0,
22 'PUT' => 0,
23 'DELETE' => 0
24 );
25
26 $show_body = false;
27 foreach ( $logger as $log ) {
28 $counters[ $log['method'] ] ++;
29
30 if ( ! is_null( $log['body'] ) ) {
31 $show_body = true;
32 }
33 }
34
35 $pretty_print = $show_body && defined( 'JSON_PRETTY_PRINT' ) && version_compare( phpversion(), '5.3', '>=' );
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
52 $root_path_len = strlen( ABSPATH );
53
54 $ms_text = fs_text_x_inline( 'ms', 'milliseconds' );
55 ?>
56 <h1><?php fs_echo_inline( 'API' ) ?></h1>
57
58 <h2><span>Total Time:</span><?php echo Freemius_Debug_Bar_Panel::total_time() ?></h2>
59
60 <h2><span>Total Requests:</span><?php echo Freemius_Debug_Bar_Panel::requests_count() ?></h2>
61 <?php foreach ( $counters as $method => $count ) : ?>
62 <h2><span><?php echo $method ?>:</span><?php echo number_format( $count ) ?></h2>
63 <?php endforeach ?>
64 <table class="widefat">
65 <thead>
66 <tr>
67 <th>#</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>
72 <?php if ( $show_body ) : ?>
73 <th><?php fs_esc_html_echo_inline( 'Body' ) ?></th>
74 <?php endif ?>
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>
78 </tr>
79 </thead>
80 <tbody>
81 <?php foreach ( $logger as $log ) : ?>
82 <tr>
83 <td><?php echo $log['id'] ?>.</td>
84 <td><?php echo $log['method'] ?></td>
85 <td><?php echo $log['code'] ?></td>
86 <td><?php echo number_format( 100 * $log['total'], 2 ) . ' ' . $ms_text ?></td>
87 <td>
88 <?php
89 printf( '<a href="#" onclick="jQuery(this).parent().find(\'table\').toggle(); return false;">%s</a>',
90 $log['path']
91 );
92 ?>
93 <table class="widefat" style="display: none">
94 <tbody>
95 <?php for ( $i = 0, $bt = $log['backtrace'], $len = count( $bt ); $i < $len; $i ++ ) : ?>
96 <tr>
97 <td><?php echo( $len - $i ) ?></td>
98 <td><?php if ( isset( $bt[ $i ]['function'] ) ) {
99 echo ( isset( $bt[ $i ]['class'] ) ? $bt[ $i ]['class'] . $bt[ $i ]['type'] : '' ) . $bt[ $i ]['function'];
100 } ?></td>
101 <td><?php if ( isset( $bt[ $i ]['file'] ) ) {
102 echo substr( $bt[ $i ]['file'], $root_path_len ) . ':' . $bt[ $i ]['line'];
103 } ?></td>
104 </tr>
105 <?php endfor ?>
106 </tbody>
107 </table>
108 </td>
109 <?php if ( $show_body ) : ?>
110 <td>
111 <?php if ( 'GET' !== $log['method'] ) : ?>
112 <?php
113 $body = $log['body'];
114 printf(
115 '<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
116 substr( $body, 0, 32 ) . ( 32 < strlen( $body ) ? '...' : '' )
117 );
118 if ( $pretty_print ) {
119 $body = $encode( json_decode( $log['body'] ), JSON_PRETTY_PRINT );
120 }
121 ?>
122 <pre style="display: none"><code><?php echo esc_html( $body ) ?></code></pre>
123 <?php endif ?>
124 </td>
125 <?php endif ?>
126 <td>
127 <?php
128 $result = $log['result'];
129
130 $is_not_empty_result = ( is_string( $result ) && ! empty( $result ) );
131
132 if ( $is_not_empty_result ) {
133 printf(
134 '<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
135 substr( $result, 0, 32 ) . ( 32 < strlen( $result ) ? '...' : '' )
136 );
137 }
138
139 if ( $is_not_empty_result && $pretty_print ) {
140 $decoded = json_decode( $result );
141 if ( ! is_null( $decoded ) ) {
142 $result = $encode( $decoded, JSON_PRETTY_PRINT );
143 }
144 } else {
145 $result = is_string( $result ) ? $result : json_encode( $result );
146 }
147 ?>
148 <pre<?php if ( $is_not_empty_result ) : ?> style="display: none"<?php endif ?>><code><?php echo esc_html( $result ) ?></code></pre>
149 </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>
152 </tr>
153 <?php endforeach ?>
154 </tbody>
155 </table>