first commit

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-08 12:19:53 -04:00
commit 7c8c8b1c76
4586 changed files with 2050693 additions and 0 deletions
@@ -0,0 +1,139 @@
<?php
// Alot of this code is massaged from Andrew Nacin's log-deprecated-notices plugin
class Debug_Bar_Deprecated extends Debug_Bar_Panel {
private $deprecated_functions = array();
private $deprecated_files = array();
private $deprecated_arguments = array();
function init() {
$this->title( __( 'Deprecated', 'debug-bar' ) );
add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ), 10, 3 );
add_action( 'deprecated_file_included', array( $this, 'deprecated_file_included' ), 10, 4 );
add_action( 'deprecated_argument_run', array( $this, 'deprecated_argument_run' ), 10, 3 );
// Silence E_NOTICE for deprecated usage.
foreach ( array( 'function', 'file', 'argument' ) as $item ) {
add_filter( "deprecated_{$item}_trigger_error", '__return_false' );
}
}
function prerender() {
$this->set_visible(
count( $this->deprecated_functions )
|| count( $this->deprecated_files )
|| count( $this->deprecated_arguments )
);
}
function render() {
echo "<div id='debug-bar-deprecated'>";
echo '<h2><span>', __( 'Total Functions:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->deprecated_functions ) ), "</h2>\n";
echo '<h2><span>', __( 'Total Arguments:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->deprecated_arguments ) ), "</h2>\n";
echo '<h2><span>', __( 'Total Files:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->deprecated_files ) ), "</h2>\n";
if ( count( $this->deprecated_functions ) ) {
echo '<ol class="debug-bar-deprecated-list">';
foreach ( $this->deprecated_functions as $location => $message_stack ) {
list( $message, $stack ) = $message_stack;
echo "<li class='debug-bar-deprecated-function'>";
echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
echo "<br/>";
echo $stack;
echo "</li>";
}
echo '</ol>';
}
if ( count( $this->deprecated_files ) ) {
echo '<ol class="debug-bar-deprecated-list">';
foreach ( $this->deprecated_files as $location => $message_stack ) {
list( $message, $stack ) = $message_stack;
echo "<li class='debug-bar-deprecated-file'>";
echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
echo "<br/>";
echo $stack;
echo "</li>";
}
echo '</ol>';
}
if ( count( $this->deprecated_arguments ) ) {
echo '<ol class="debug-bar-deprecated-list">';
foreach ( $this->deprecated_arguments as $location => $message_stack ) {
list( $message, $stack ) = $message_stack;
echo "<li class='debug-bar-deprecated-argument'>";
echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
echo "<br/>";
echo $stack;
echo "</li>";
}
echo '</ol>';
}
echo "</div>";
}
function deprecated_function_run( $function, $replacement, $version ) {
$backtrace = debug_backtrace( false );
$bt = 4;
// Check if we're a hook callback.
if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
$bt = 6;
}
$location = $backtrace[ $bt ]['file'] . ':' . $backtrace[ $bt ]['line'];
if ( ! is_null( $replacement ) ) {
/* translators: %1$s is a function or file name, %2$s a version number, %3$s an alternative function or file to use. */
$message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 'debug-bar' ), $function, $version, $replacement );
} else {
/* translators: %1$s is a function or file name, %2$s a version number. */
$message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 'debug-bar' ), $function, $version );
}
$this->deprecated_functions[ $location ] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
}
function deprecated_file_included( $old_file, $replacement, $version, $message ) {
$backtrace = debug_backtrace( false );
$file = $backtrace[4]['file'];
$file_abs = str_replace( ABSPATH, '', $file );
$location = $file . ':' . $backtrace[4]['line'];
$message = empty( $message ) ? '' : ' ' . $message;
if ( ! is_null( $replacement ) ) {
/* translators: %1$s is a function or file name, %2$s a version number, %3$s an alternative function or file to use. */
$message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 'debug-bar' ), $file_abs, $version, $replacement ) . $message;
} else {
/* translators: %1$s is a function or file name, %2$s a version number. */
$message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 'debug-bar' ), $file_abs, $version ) . $message;
}
$this->deprecated_files[ $location ] = array( $message, wp_debug_backtrace_summary( null, 4 ) );
}
function deprecated_argument_run( $function, $message, $version ) {
$backtrace = debug_backtrace( false );
if ( 'define()' === $function ) {
$this->deprecated_arguments[] = array( $message, '' );
return;
}
$bt = 4;
if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
$bt = 6;
}
$location = $backtrace[ $bt ]['file'] . ':' . $backtrace[ $bt ]['line'];
if ( ! is_null( $message ) ) {
$message = sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s' ), $function, $version, $message );
} else {
$message = sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function, $version );
}
$this->deprecated_arguments[ $location ] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
}
}
@@ -0,0 +1,23 @@
<?php
class Debug_Bar_JS extends Debug_Bar_Panel {
public $real_error_handler = array();
function init() {
$this->title( __( 'JavaScript', 'debug-bar' ) );
/*
* attach here instead of debug_bar_enqueue_scripts
* because we want to be as early as possible!
*/
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
wp_enqueue_script( 'debug-bar-js', plugins_url( "js/debug-bar-js$suffix.js", dirname( __FILE__ ) ), array( 'jquery' ), '20111216' );
}
function render() {
echo '<div id="debug-bar-js">';
echo '<h2><span>' . __( 'Total Errors:', 'debug-bar' ) . "</span><span id='debug-bar-js-error-count'>0</span></h2>\n";
echo '<ol class="debug-bar-js-list" id="debug-bar-js-errors"></ol>' . "\n";
echo '</div>';
}
}
@@ -0,0 +1,25 @@
<?php
class Debug_Bar_Object_Cache extends Debug_Bar_Panel {
function init() {
$this->title( __( 'Object Cache', 'debug-bar' ) );
}
function prerender() {
global $wp_object_cache;
$this->set_visible( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, 'stats' ) );
}
function render() {
global $wp_object_cache;
ob_start();
echo "<div id='object-cache-stats'>";
$wp_object_cache->stats();
echo "</div>";
$out = ob_get_contents();
ob_end_clean();
echo $out;
}
}
@@ -0,0 +1,61 @@
<?php
class Debug_Bar_Panel {
public $_title = '';
public $_visible = true;
function __construct( $title = '' ) {
$this->title( $title );
if ( $this->init() === false ) {
$this->set_visible( false );
return;
}
add_filter( 'debug_bar_classes', array( $this, 'debug_bar_classes' ) );
}
function Debug_Bar_Panel( $title = '' ) {
_deprecated_constructor( __METHOD__, '0.8.3', __CLASS__ );
self::__construct( $title );
}
/**
* Initializes the panel.
*/
function init() {}
function prerender() {}
/**
* Renders the panel.
*/
function render() {}
function is_visible() {
return $this->_visible;
}
function set_visible( $visible ) {
$this->_visible = $visible;
}
/**
* Get/set title.
*
* @param null $title
* @return string|void
*/
function title( $title = null ) {
if ( ! isset( $title ) ) {
return $this->_title;
}
$this->_title = $title;
}
function debug_bar_classes( $classes ) {
return $classes;
}
}
@@ -0,0 +1,111 @@
<?php
class Debug_Bar_PHP extends Debug_Bar_Panel {
public $warnings = array();
public $notices = array();
public $real_error_handler = array();
function init() {
if ( ! WP_DEBUG ) {
return false;
}
$this->title( __( 'Notices / Warnings', 'debug-bar' ) );
$this->real_error_handler = set_error_handler( array( &$this, 'error_handler' ) );
}
function is_visible() {
return count( $this->notices ) || count( $this->warnings );
}
function debug_bar_classes( $classes ) {
if ( count( $this->warnings ) ) {
$classes[] = 'debug-bar-php-warning-summary';
} elseif ( count( $this->notices ) ) {
$classes[] = 'debug-bar-php-notice-summary';
}
return $classes;
}
function error_handler( $type, $message, $file, $line ) {
$_key = md5( $file . ':' . $line . ':' . $message );
if ( ! defined( 'E_DEPRECATED' ) ) {
define( 'E_DEPRECATED', 8192 );
}
if ( ! defined( 'E_USER_DEPRECATED' ) ) {
define( 'E_USER_DEPRECATED', 16384 );
}
switch ( $type ) {
case E_WARNING:
case E_USER_WARNING:
$this->warnings[ $_key ] = array(
$file . ':' . $line,
$message,
wp_debug_backtrace_summary( __CLASS__ ),
);
break;
case E_NOTICE:
case E_USER_NOTICE:
$this->notices[ $_key ] = array(
$file . ':' . $line,
$message,
wp_debug_backtrace_summary( __CLASS__ ),
);
break;
case E_STRICT:
// TODO
break;
case E_DEPRECATED:
case E_USER_DEPRECATED:
// TODO
break;
case 0:
// TODO
break;
}
if ( null != $this->real_error_handler ) {
return call_user_func( $this->real_error_handler, $type, $message, $file, $line );
} else {
return false;
}
}
function render() {
echo "<div id='debug-bar-php'>";
echo '<h2><span>', __( 'Total Warnings:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->warnings ) ), "</h2>\n";
echo '<h2><span>', __( 'Total Notices:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->notices ) ), "</h2>\n";
if ( count( $this->warnings ) ) {
echo '<ol class="debug-bar-php-list">';
foreach ( $this->warnings as $location_message_stack ) {
list( $location, $message, $stack ) = $location_message_stack;
echo '<li class="debug-bar-php-warning">', __( 'WARNING:', 'debug-bar' ), ' ';
echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
echo '<br/>';
echo $stack;
echo '</li>';
}
echo '</ol>';
}
if ( count( $this->notices ) ) {
echo '<ol class="debug-bar-php-list">';
foreach ( $this->notices as $location_message_stack ) {
list( $location, $message, $stack ) = $location_message_stack;
echo '<li class="debug-bar-php-notice">', __( 'NOTICE:', 'debug-bar' ), ' ';
echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
echo '<br/>';
echo $stack;
echo '</li>';
}
echo '</ol>';
}
echo "</div>";
}
}
@@ -0,0 +1,92 @@
<?php
class Debug_Bar_Queries extends Debug_Bar_Panel {
function init() {
$this->title( __( 'Queries', 'debug-bar' ) );
}
function prerender() {
$this->set_visible( defined( 'SAVEQUERIES' ) && SAVEQUERIES || ! empty( $GLOBALS['EZSQL_ERROR'] ) );
}
function debug_bar_classes( $classes ) {
if ( ! empty( $GLOBALS['EZSQL_ERROR'] ) ) {
$classes[] = 'debug-bar-php-warning-summary';
}
return $classes;
}
function render() {
global $wpdb, $EZSQL_ERROR;
$out = '';
$total_time = 0;
if ( ! empty( $wpdb->queries ) ) {
$show_many = isset( $_GET['debug_queries'] );
if ( $wpdb->num_queries > 500 && ! $show_many ) {
/* translators: %s = a url. */
$out .= "<p>" . sprintf( __( 'There are too many queries to show easily! <a href="%s">Show them anyway</a>', 'debug-bar' ), esc_url( add_query_arg( 'debug_queries', 'true' ) ) ) . "</p>";
}
$out .= '<ol class="wpd-queries">';
$counter = 0;
foreach ( $wpdb->queries as $q ) {
list( $query, $elapsed, $debug ) = $q;
$total_time += $elapsed;
if ( ++$counter > 500 && ! $show_many ) {
continue;
}
$debug = explode( ', ', $debug );
$debug = array_diff( $debug, array( 'require_once', 'require', 'include_once', 'include' ) );
$debug = implode( ', ', $debug );
$debug = str_replace( array( 'do_action, call_user_func_array' ), array( 'do_action' ), $debug );
$debug = esc_html( $debug );
$query = nl2br( esc_html( $query ) );
/* translators: %s = duration in milliseconds. */
$time = esc_html( sprintf( __( '%s ms', 'debug-bar' ), number_format_i18n( ( $elapsed * 1000 ), 1 ) ) );
$out .= "<li>$query<br/><div class='qdebug'>$debug <span>#$counter ($time)</span></div></li>\n";
}
$out .= '</ol>';
} else if ( 0 === $wpdb->num_queries ) {
$out .= "<p><strong>" . __( 'There are no queries on this page.', 'debug-bar' ) . "</strong></p>";
} else {
$out .= "<p><strong>" . __( 'SAVEQUERIES must be defined to show the query log.', 'debug-bar' ) . "</strong></p>";
}
if ( ! empty( $EZSQL_ERROR ) ) {
$out .= '<h3>' . __( 'Database Errors', 'debug-bar' ) . '</h3>';
$out .= '<ol class="wpd-queries">';
foreach ( $EZSQL_ERROR as $error ) {
$query = nl2br( esc_html( $error['query'] ) );
$message = esc_html( $error['error_str'] );
$out .= "<li>$query<br/><div class='qdebug'>$message</div></li>\n";
}
$out .= '</ol>';
}
$heading = '';
if ( $wpdb->num_queries ) {
$heading .= '<h2><span>' . __( 'Total Queries:', 'debug-bar' ) . '</span>' . number_format_i18n( $wpdb->num_queries ) . "</h2>\n";
}
if ( $total_time ) {
$heading .= '<h2><span>' . __( 'Total query time:', 'debug-bar' ) . '</span>';
/* translators: %s = duration in milliseconds. */
$heading .= sprintf( __( '%s ms', 'debug-bar' ), number_format_i18n( ( $total_time * 1000 ), 1 ) ) . "</h2>\n";
}
if ( ! empty( $EZSQL_ERROR ) ) {
$heading .= '<h2><span>' . __( 'Total DB Errors:', 'debug-bar' ) . '</span>' . number_format_i18n( count( $EZSQL_ERROR ) ) . "</h2>\n";
}
echo $heading . $out;
}
}
@@ -0,0 +1,55 @@
<?php
class Debug_Bar_Request extends Debug_Bar_Panel {
function init() {
$this->title( __('Request', 'debug-bar') );
}
function prerender() {
$this->set_visible( ! is_admin() );
}
function render() {
global $wp;
echo "<div id='debug-bar-request'>";
if ( empty( $wp->request ) ) {
$request = __( 'None', 'debug-bar' );
} else {
$request = $wp->request;
}
echo '<h3>', __( 'Request:', 'debug-bar' ), '</h3>';
echo '<p>' . esc_html( $request ) . '</p>';
if ( empty( $wp->query_string ) ) {
$query_string = __( 'None', 'debug-bar' );
} else {
$query_string = $wp->query_string;
}
echo '<h3>', __( 'Query String:', 'debug-bar' ), '</h3>';
echo '<p>' . esc_html( $query_string ) . '</p>';
if ( empty( $wp->matched_rule ) ) {
$matched_rule = __( 'None', 'debug-bar' );
} else {
$matched_rule = $wp->matched_rule;
}
echo '<h3>', __( 'Matched Rewrite Rule:', 'debug-bar' ), '</h3>';
echo '<p>' . esc_html( $matched_rule ) . '</p>';
if ( empty( $wp->matched_query ) ) {
$matched_query = __( 'None', 'debug-bar' );
} else {
$matched_query = $wp->matched_query;
}
echo '<h3>', __( 'Matched Rewrite Query:', 'debug-bar' ), '</h3>';
echo '<p>' . esc_html( $matched_query ) . '</p>';
echo '</div>';
}
}
@@ -0,0 +1,113 @@
<?php
class Debug_Bar_WP_Query extends Debug_Bar_Panel {
function init() {
$this->title( __( 'WP Query', 'debug-bar' ) );
}
function prerender() {
$this->set_visible( defined( 'SAVEQUERIES' ) && SAVEQUERIES );
}
function render() {
global $template, $wp_query;
$queried_object = get_queried_object();
if ( $queried_object && isset( $queried_object->post_type ) ) {
$post_type_object = get_post_type_object( $queried_object->post_type );
}
echo "<div id='debug-bar-wp-query'>";
echo '<h2><span>', __( 'Queried Object ID:', 'debug-bar' ), '</span>', get_queried_object_id(), "</h2>\n";
// Determine the query type. Follows the template loader order.
$type = '';
if ( is_404() ) {
$type = __( '404', 'debug-bar' );
} elseif ( is_search() ) {
$type = __( 'Search', 'debug-bar' );
} elseif ( is_tax() ) {
$type = __( 'Taxonomy', 'debug-bar' );
} elseif ( is_front_page() ) {
$type = __( 'Front Page', 'debug-bar' );
} elseif ( is_home() ) {
$type = __( 'Home', 'debug-bar' );
} elseif ( is_attachment() ) {
$type = __( 'Attachment', 'debug-bar' );
} elseif ( is_single() ) {
$type = __( 'Single', 'debug-bar' );
} elseif ( is_page() ) {
$type = __( 'Page', 'debug-bar' );
} elseif ( is_category() ) {
$type = __( 'Category', 'debug-bar' );
} elseif ( is_tag() ) {
$type = __( 'Tag', 'debug-bar' );
} elseif ( is_author() ) {
$type = __( 'Author', 'debug-bar' );
} elseif ( is_date() ) {
$type = __( 'Date', 'debug-bar' );
} elseif ( is_archive() ) {
$type = __( 'Archive', 'debug-bar' );
} elseif ( is_paged() ) {
$type = __( 'Paged', 'debug-bar' );
}
if ( ! empty( $type ) ) {
echo '<h2><span>', __( 'Query Type:', 'debug-bar' ), '</span>', $type, "</h2>\n";
}
if ( ! empty( $template ) ) {
echo '<h2><span>', __( 'Query Template:', 'debug-bar' ), '</span>', basename( $template ), "</h2>\n";
}
$show_on_front = get_option( 'show_on_front' );
$page_on_front = get_option( 'page_on_front' );
$page_for_posts = get_option( 'page_for_posts' );
echo '<h2><span>', __( 'Show on Front:', 'debug-bar' ), '</span>', $show_on_front, "</h2>\n";
if ( 'page' == $show_on_front ) {
echo '<h2><span>', __( 'Page for Posts:', 'debug-bar' ), '</span>', $page_for_posts, "</h2>\n";
echo '<h2><span>', __( 'Page on Front:', 'debug-bar' ), '</span>', $page_on_front, "</h2>\n";
}
if ( isset( $post_type_object ) ) {
echo '<h2><span>', __( 'Post Type:', 'debug-bar' ), '</span>', $post_type_object->labels->singular_name, "</h2>\n";
}
echo '<div class="clear"></div>';
if ( empty( $wp_query->query ) ) {
$query = __( 'None', 'debug-bar' );
} else {
$query = http_build_query( $wp_query->query );
}
echo '<h3>', __( 'Query Arguments:', 'debug-bar' ), '</h3>';
echo '<p>' . esc_html( $query ) . '</p>';
if ( ! empty( $wp_query->request ) ) {
echo '<h3>', __( 'Query SQL:', 'debug-bar' ), '</h3>';
echo '<p>' . esc_html( $wp_query->request ) . '</p>';
}
if ( ! is_null( $queried_object ) ) {
echo '<h3>', __( 'Queried Object:', 'debug-bar' ), '</h3>';
echo '<table class="debug-bar-wp-query-list"><tbody>';
$this->_recursive_print_kv( $queried_object );
echo '</tbody></table>';
}
echo '</div>';
}
protected function _recursive_print_kv( $kv_array ) {
foreach ( $kv_array as $key => $value ) {
if ( is_object( $value ) || is_array( $value ) ) {
echo '<tr><th>', $key, '</th> <td>&rArr;</td> <td>';
$this->_recursive_print_kv( $value );
echo '</td></tr>';
} else {
echo '<tr><th>', $key, '</th> <td>&rArr;</td> <td>', $value, '</td></tr>';
}
}
}
}