first
This commit is contained in:
@ -0,0 +1,155 @@
|
||||
<?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 ( class_exists( 'Freemius_Api_WordPress' ) ) {
|
||||
$logger = Freemius_Api_WordPress::GetLogger();
|
||||
} else {
|
||||
$logger = array();
|
||||
}
|
||||
|
||||
$counters = array(
|
||||
'GET' => 0,
|
||||
'POST' => 0,
|
||||
'PUT' => 0,
|
||||
'DELETE' => 0
|
||||
);
|
||||
|
||||
$show_body = false;
|
||||
foreach ( $logger as $log ) {
|
||||
$counters[ $log['method'] ] ++;
|
||||
|
||||
if ( ! is_null( $log['body'] ) ) {
|
||||
$show_body = true;
|
||||
}
|
||||
}
|
||||
|
||||
$pretty_print = $show_body && defined( 'JSON_PRETTY_PRINT' ) && version_compare( phpversion(), '5.3', '>=' );
|
||||
|
||||
/**
|
||||
* This template is used for debugging, therefore, when possible
|
||||
* we'd like to prettify the output of a JSON encoded variable.
|
||||
* This will only be executed when $pretty_print is `true`, and
|
||||
* the var is `true` only for PHP 5.3 and higher. Due to the
|
||||
* limitations of the current Theme Check, it throws an error
|
||||
* that using the "options" parameter (the 2nd param) is not
|
||||
* supported in PHP 5.2 and lower. Thus, we added this alias
|
||||
* variable to work around that false-positive.
|
||||
*
|
||||
* @author Vova Feldman (@svovaf)
|
||||
* @since 1.2.2.7
|
||||
*/
|
||||
$encode = 'json_encode';
|
||||
|
||||
$root_path_len = strlen( ABSPATH );
|
||||
|
||||
$ms_text = fs_text_x_inline( 'ms', 'milliseconds' );
|
||||
?>
|
||||
<h1><?php fs_echo_inline( 'API' ) ?></h1>
|
||||
|
||||
<h2><span>Total Time:</span><?php echo Freemius_Debug_Bar_Panel::total_time() ?></h2>
|
||||
|
||||
<h2><span>Total Requests:</span><?php echo Freemius_Debug_Bar_Panel::requests_count() ?></h2>
|
||||
<?php foreach ( $counters as $method => $count ) : ?>
|
||||
<h2><span><?php echo $method ?>:</span><?php echo number_format( $count ) ?></h2>
|
||||
<?php endforeach ?>
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Method' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Code' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Length' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_x_inline( 'Path', 'as file/folder path' ) ?></th>
|
||||
<?php if ( $show_body ) : ?>
|
||||
<th><?php fs_esc_html_echo_inline( 'Body' ) ?></th>
|
||||
<?php endif ?>
|
||||
<th><?php fs_esc_html_echo_inline( 'Result' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Start' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'End' ) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ( $logger as $log ) : ?>
|
||||
<tr>
|
||||
<td><?php echo $log['id'] ?>.</td>
|
||||
<td><?php echo $log['method'] ?></td>
|
||||
<td><?php echo $log['code'] ?></td>
|
||||
<td><?php echo number_format( 100 * $log['total'], 2 ) . ' ' . $ms_text ?></td>
|
||||
<td>
|
||||
<?php
|
||||
printf( '<a href="#" onclick="jQuery(this).parent().find(\'table\').toggle(); return false;">%s</a>',
|
||||
$log['path']
|
||||
);
|
||||
?>
|
||||
<table class="widefat" style="display: none">
|
||||
<tbody>
|
||||
<?php for ( $i = 0, $bt = $log['backtrace'], $len = count( $bt ); $i < $len; $i ++ ) : ?>
|
||||
<tr>
|
||||
<td><?php echo( $len - $i ) ?></td>
|
||||
<td><?php if ( isset( $bt[ $i ]['function'] ) ) {
|
||||
echo ( isset( $bt[ $i ]['class'] ) ? $bt[ $i ]['class'] . $bt[ $i ]['type'] : '' ) . $bt[ $i ]['function'];
|
||||
} ?></td>
|
||||
<td><?php if ( isset( $bt[ $i ]['file'] ) ) {
|
||||
echo substr( $bt[ $i ]['file'], $root_path_len ) . ':' . $bt[ $i ]['line'];
|
||||
} ?></td>
|
||||
</tr>
|
||||
<?php endfor ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
<?php if ( $show_body ) : ?>
|
||||
<td>
|
||||
<?php if ( 'GET' !== $log['method'] ) : ?>
|
||||
<?php
|
||||
$body = $log['body'];
|
||||
printf(
|
||||
'<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
|
||||
substr( $body, 0, 32 ) . ( 32 < strlen( $body ) ? '...' : '' )
|
||||
);
|
||||
if ( $pretty_print ) {
|
||||
$body = $encode( json_decode( $log['body'] ), JSON_PRETTY_PRINT );
|
||||
}
|
||||
?>
|
||||
<pre style="display: none"><code><?php echo esc_html( $body ) ?></code></pre>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
<td>
|
||||
<?php
|
||||
$result = $log['result'];
|
||||
|
||||
$is_not_empty_result = ( is_string( $result ) && ! empty( $result ) );
|
||||
|
||||
if ( $is_not_empty_result ) {
|
||||
printf(
|
||||
'<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
|
||||
substr( $result, 0, 32 ) . ( 32 < strlen( $result ) ? '...' : '' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $is_not_empty_result && $pretty_print ) {
|
||||
$decoded = json_decode( $result );
|
||||
if ( ! is_null( $decoded ) ) {
|
||||
$result = $encode( $decoded, JSON_PRETTY_PRINT );
|
||||
}
|
||||
} else {
|
||||
$result = is_string( $result ) ? $result : json_encode( $result );
|
||||
}
|
||||
?>
|
||||
<pre<?php if ( $is_not_empty_result ) : ?> style="display: none"<?php endif ?>><code><?php echo esc_html( $result ) ?></code></pre>
|
||||
</td>
|
||||
<td><?php echo number_format( 100 * ( $log['start'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . $ms_text ?></td>
|
||||
<td><?php echo number_format( 100 * ( $log['end'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . $ms_text ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
// Hide file structure from users on unprotected servers.
|
@ -0,0 +1,66 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$log_book = FS_Logger::get_log();
|
||||
?>
|
||||
<h1><?php fs_echo_inline( 'Log' ) ?></h1>
|
||||
|
||||
<table class="widefat" style="font-size: 11px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Type' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Function' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Message' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'File' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Timestamp' ) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php $i = 0;
|
||||
foreach ( $log_book as $log ) : ?>
|
||||
<?php
|
||||
/**
|
||||
* @var FS_Logger $logger
|
||||
*/
|
||||
$logger = $log['logger'];
|
||||
?>
|
||||
<tr<?php if ( $i % 2 ) {
|
||||
echo ' class="alternate"';
|
||||
} ?>>
|
||||
<td><?php echo $log['cnt'] ?>.</td>
|
||||
<td><?php echo $logger->get_id() ?></td>
|
||||
<td><?php echo $log['log_type'] ?></td>
|
||||
<td><b><code style="color: blue;"><?php echo ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] ?></code></b></td>
|
||||
<td>
|
||||
<?php
|
||||
printf(
|
||||
'<a href="#" style="color: darkorange !important;" onclick="jQuery(this).parent().find(\'div\').toggle(); return false;"><nobr>%s</nobr></a>',
|
||||
esc_html( substr( $log['msg'], 0, 32 ) ) . ( 32 < strlen( $log['msg'] ) ? '...' : '' )
|
||||
);
|
||||
?>
|
||||
<div style="display: none;">
|
||||
<b style="color: darkorange;"><?php echo esc_html( $log['msg'] ) ?></b>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php
|
||||
if ( isset( $log['file'] ) ) {
|
||||
echo substr( $log['file'], $logger->get_file() ) . ':' . $log['line'];
|
||||
}
|
||||
?></td>
|
||||
<td><?php echo number_format( 100 * ( $log['timestamp'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' ) ?></td>
|
||||
</tr>
|
||||
<?php $i ++; endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
@ -0,0 +1,76 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$fs_options = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
|
||||
$all_plugins = $fs_options->get_option( 'all_plugins' );
|
||||
$all_themes = $fs_options->get_option( 'all_themes' );
|
||||
|
||||
/* translators: %s: time period (e.g. In "2 hours") */
|
||||
$in_x_text = fs_text_inline( 'In %s', 'in-x' );
|
||||
/* translators: %s: time period (e.g. "2 hours" ago) */
|
||||
$x_ago_text = fs_text_inline( '%s ago', 'x-ago' );
|
||||
$sec_text = fs_text_x_inline( 'sec', 'seconds' );
|
||||
?>
|
||||
<h1><?php fs_esc_html_echo_inline( 'Plugins & Themes Sync', 'plugins-themes-sync' ) ?></h1>
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Total', 'total' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Last', 'last' ) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ( is_object( $all_plugins ) ) : ?>
|
||||
<tr>
|
||||
<td><?php fs_esc_html_echo_inline( 'Plugins', 'plugins' ) ?></td>
|
||||
<td><?php echo count( $all_plugins->plugins ) ?></td>
|
||||
<td><?php
|
||||
if ( isset( $all_plugins->timestamp ) && is_numeric( $all_plugins->timestamp ) ) {
|
||||
$diff = abs( WP_FS__SCRIPT_START_TIME - $all_plugins->timestamp );
|
||||
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
|
||||
$diff . ' ' . $sec_text :
|
||||
human_time_diff( WP_FS__SCRIPT_START_TIME, $all_plugins->timestamp );
|
||||
|
||||
echo esc_html( sprintf(
|
||||
( ( WP_FS__SCRIPT_START_TIME < $all_plugins->timestamp ) ?
|
||||
$in_x_text :
|
||||
$x_ago_text ),
|
||||
$human_diff
|
||||
) );
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
<?php if ( is_object( $all_themes ) ) : ?>
|
||||
<tr>
|
||||
<td><?php fs_esc_html_echo_inline( 'Themes', 'themes' ) ?></td>
|
||||
<td><?php echo count( $all_themes->themes ) ?></td>
|
||||
<td><?php
|
||||
if ( isset( $all_themes->timestamp ) && is_numeric( $all_themes->timestamp ) ) {
|
||||
$diff = abs( WP_FS__SCRIPT_START_TIME - $all_themes->timestamp );
|
||||
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
|
||||
$diff . ' ' . $sec_text :
|
||||
human_time_diff( WP_FS__SCRIPT_START_TIME, $all_themes->timestamp );
|
||||
|
||||
echo esc_html( sprintf(
|
||||
( ( WP_FS__SCRIPT_START_TIME < $all_themes->timestamp ) ?
|
||||
$in_x_text :
|
||||
$x_ago_text ),
|
||||
$human_diff
|
||||
) );
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
</tbody>
|
||||
</table>
|
@ -0,0 +1,136 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$fs_options = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
|
||||
$scheduled_crons = array();
|
||||
|
||||
$module_types = array(
|
||||
WP_FS__MODULE_TYPE_PLUGIN,
|
||||
WP_FS__MODULE_TYPE_THEME
|
||||
);
|
||||
|
||||
foreach ( $module_types as $module_type ) {
|
||||
$modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() );
|
||||
if ( is_array( $modules ) && count( $modules ) > 0 ) {
|
||||
foreach ( $modules as $slug => $data ) {
|
||||
if ( WP_FS__MODULE_TYPE_THEME === $module_type ) {
|
||||
$current_theme = wp_get_theme();
|
||||
$is_active = ( $current_theme->stylesheet === $data->file );
|
||||
} else {
|
||||
$is_active = is_plugin_active( $data->file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Vova Feldman
|
||||
*
|
||||
* @since 1.2.1 Don't load data from inactive modules.
|
||||
*/
|
||||
if ( $is_active ) {
|
||||
$fs = freemius( $data->id );
|
||||
|
||||
$next_execution = $fs->next_sync_cron();
|
||||
$last_execution = $fs->last_sync_cron();
|
||||
|
||||
if ( false !== $next_execution ) {
|
||||
$scheduled_crons[ $slug ][] = array(
|
||||
'name' => $fs->get_plugin_name(),
|
||||
'slug' => $slug,
|
||||
'module_type' => $fs->get_module_type(),
|
||||
'type' => 'sync_cron',
|
||||
'last' => $last_execution,
|
||||
'next' => $next_execution,
|
||||
);
|
||||
}
|
||||
|
||||
$next_install_execution = $fs->next_install_sync();
|
||||
$last_install_execution = $fs->last_install_sync();
|
||||
|
||||
if (false !== $next_install_execution ||
|
||||
false !== $last_install_execution
|
||||
) {
|
||||
$scheduled_crons[ $slug ][] = array(
|
||||
'name' => $fs->get_plugin_name(),
|
||||
'slug' => $slug,
|
||||
'module_type' => $fs->get_module_type(),
|
||||
'type' => 'install_sync',
|
||||
'last' => $last_install_execution,
|
||||
'next' => $next_install_execution,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sec_text = fs_text_x_inline( 'sec', 'seconds' );
|
||||
?>
|
||||
<h1><?php fs_esc_html_echo_inline( 'Scheduled Crons' ) ?></h1>
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Module' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Module Type' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Cron Type' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Last' ) ?></th>
|
||||
<th><?php fs_esc_html_echo_inline( 'Next' ) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
/* translators: %s: time period (e.g. In "2 hours") */
|
||||
$in_x_text = fs_text_inline( 'In %s', 'in-x' );
|
||||
/* translators: %s: time period (e.g. "2 hours" ago) */
|
||||
$x_ago_text = fs_text_inline( '%s ago', 'x-ago' );
|
||||
?>
|
||||
<?php foreach ( $scheduled_crons as $slug => $crons ) : ?>
|
||||
<?php foreach ( $crons as $cron ) : ?>
|
||||
<tr>
|
||||
<td><?php echo $slug ?></td>
|
||||
<td><?php echo $cron['name'] ?></td>
|
||||
<td><?php echo $cron['module_type'] ?></td>
|
||||
<td><?php echo $cron['type'] ?></td>
|
||||
<td><?php
|
||||
if ( is_numeric( $cron['last'] ) ) {
|
||||
$diff = abs( WP_FS__SCRIPT_START_TIME - $cron['last'] );
|
||||
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
|
||||
$diff . ' ' . $sec_text :
|
||||
human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['last'] );
|
||||
|
||||
echo esc_html( sprintf(
|
||||
( ( WP_FS__SCRIPT_START_TIME < $cron['last'] ) ?
|
||||
$in_x_text :
|
||||
$x_ago_text ),
|
||||
$human_diff
|
||||
) );
|
||||
}
|
||||
?></td>
|
||||
<td><?php
|
||||
if ( is_numeric( $cron['next'] ) ) {
|
||||
$diff = abs( WP_FS__SCRIPT_START_TIME - $cron['next'] );
|
||||
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
|
||||
$diff . ' ' . $sec_text :
|
||||
human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['next'] );
|
||||
|
||||
echo esc_html( sprintf(
|
||||
( ( WP_FS__SCRIPT_START_TIME < $cron['next'] ) ?
|
||||
$in_x_text :
|
||||
$x_ago_text ),
|
||||
$human_diff
|
||||
) );
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
Reference in New Issue
Block a user