* @link https://github.com/jrfnl/Debug-Bar-Constants * * @copyright 2013-2018 Juliette Reinders Folmer * @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher */ // Avoid direct calls to this file. if ( ! function_exists( 'add_action' ) ) { header( 'Status: 403 Forbidden' ); header( 'HTTP/1.1 403 Forbidden' ); exit(); } if ( ! class_exists( 'Debug_Bar_WP_Class_Constants' ) && class_exists( 'Debug_Bar_Constants_Panel' ) ) { /** * Debug Bar WP Class Constants. */ class Debug_Bar_WP_Class_Constants extends Debug_Bar_Constants_Panel { /** * Constructor. */ public function init() { $this->title( __( 'WP Class Constants', 'debug-bar-constants' ) ); } /** * Render the output. */ public function render() { $classes = get_declared_classes(); if ( class_exists( 'Debug_Bar_List_PHP_Classes' ) && property_exists( 'Debug_Bar_List_PHP_Classes', 'PHP_classes' ) ) { $classes = array_udiff( $classes, Debug_Bar_List_PHP_Classes::$PHP_classes, 'strcasecmp' ); } $constants = array(); if ( ! empty( $classes ) && is_array( $classes ) ) { // Get the constants info first. foreach ( $classes as $class ) { $reflector = new ReflectionClass( $class ); $class_constants = $reflector->getConstants(); if ( ! empty( $class_constants ) && is_array( $class_constants ) ) { $constants[ $class ] = $class_constants; } unset( $class_constants, $reflector ); } unset( $class ); // Generate the output. if ( ! empty( $constants ) && is_array( $constants ) ) { uksort( $constants, 'strnatcasecmp' ); foreach ( $constants as $class => $set ) { $count = count( $set ); echo '
';
printf(
/* TRANSLATORS: 1: open tag; 2: close tag. */
esc_html__( '%1$sPlease note%2$s: these may be both native WordPress classes as well as classes which may be declared by plugins or themes.', 'debug-bar-constants' ),
'',
''
);
echo '
';
printf(
/* TRANSLATORS: 1: interpolates to "class_name::constant_name". */
esc_html__( 'You can use these constants in your code using %1$s.', 'debug-bar-constants' ),
'class_name::constant_name'
);
echo ' ';
printf(
/* TRANSLATORS: 1: link open tag; 2: link close tag. */
esc_html__( 'See the %1$sFAQ%2$s for more information.', 'debug-bar-constants' ),
'',
''
);
echo '
', esc_html__( 'No classes nor class constants found... this is kinda strange...', 'debug-bar-constants' ), '
'; } } } // End of class Debug_Bar_WP_Class_Constants. } // End of if class_exists wrapper.