first
This commit is contained in:
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Freemius
|
||||
* @copyright Copyright (c) 2015, Freemius, Inc.
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
||||
* @since 1.1.7.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends Debug Bar plugin by adding a panel to show all Freemius API requests.
|
||||
*
|
||||
* @author Vova Feldman (@svovaf)
|
||||
* @since 1.1.7.3
|
||||
*
|
||||
* Class Freemius_Debug_Bar_Panel
|
||||
*/
|
||||
class Freemius_Debug_Bar_Panel extends Debug_Bar_Panel {
|
||||
function init() {
|
||||
$this->title( 'Freemius' );
|
||||
}
|
||||
|
||||
static function requests_count() {
|
||||
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
|
||||
$logger = Freemius_Api_WordPress::GetLogger();
|
||||
} else {
|
||||
$logger = array();
|
||||
}
|
||||
|
||||
return number_format( count( $logger ) );
|
||||
}
|
||||
|
||||
static function total_time() {
|
||||
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
|
||||
$logger = Freemius_Api_WordPress::GetLogger();
|
||||
} else {
|
||||
$logger = array();
|
||||
}
|
||||
|
||||
$total_time = .0;
|
||||
foreach ( $logger as $l ) {
|
||||
$total_time += $l['total'];
|
||||
}
|
||||
|
||||
return number_format( 100 * $total_time, 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' );
|
||||
}
|
||||
|
||||
function render() {
|
||||
?>
|
||||
<div id='debug-bar-php'>
|
||||
<?php fs_require_template( '/debug/api-calls.php' ) ?>
|
||||
<br>
|
||||
<?php fs_require_template( '/debug/scheduled-crons.php' ) ?>
|
||||
<br>
|
||||
<?php fs_require_template( '/debug/plugins-themes-sync.php' ) ?>
|
||||
<br>
|
||||
<?php fs_require_template( '/debug/logger.php' ) ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Freemius
|
||||
* @copyright Copyright (c) 2015, Freemius, Inc.
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
||||
* @since 1.1.7.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! WP_FS__DEBUG_SDK ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Freemius custom debug panels.
|
||||
*
|
||||
* @param array $panels Debug bar panels objects
|
||||
*
|
||||
* @return array Debug bar panels with your custom panels
|
||||
*/
|
||||
function fs_custom_panels_init( $panels ) {
|
||||
if ( class_exists( 'Debug_Bar_Panel' ) ) {
|
||||
if ( FS_API__LOGGER_ON ) {
|
||||
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
|
||||
$panels[] = new Freemius_Debug_Bar_Panel();
|
||||
}
|
||||
}
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function fs_custom_status_init( $statuses ) {
|
||||
if ( class_exists( 'Debug_Bar_Panel' ) ) {
|
||||
if ( FS_API__LOGGER_ON ) {
|
||||
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
|
||||
$statuses[] = array(
|
||||
'fs_api_requests',
|
||||
fs_text_inline( 'Freemius API' ),
|
||||
Freemius_Debug_Bar_Panel::requests_count() . ' ' . fs_text_inline( 'Requests' ) .
|
||||
' (' . Freemius_Debug_Bar_Panel::total_time() . ')'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $statuses;
|
||||
}
|
||||
|
||||
add_filter( 'debug_bar_panels', 'fs_custom_panels_init' );
|
||||
add_filter( 'debug_bar_statuses', 'fs_custom_status_init' );
|
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
// Hide file structure from users on unprotected servers.
|
Reference in New Issue
Block a user