Skip to content

Commit

Permalink
Label for wfx_debug()
Browse files Browse the repository at this point in the history
Add optional label at top of debug output - so if using multiple on page you can identify them easier.
  • Loading branch information
Jonnyauk committed Feb 17, 2015
1 parent 2a96937 commit e9e9f07
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions functions.php
Expand Up @@ -231,10 +231,10 @@

/**
* @since 1.1
* @updated 1.1
* @updated 2.0
* Displays input in a nicer way for debugging
*/
if ( !function_exists( 'wfx_debug' ) ) : function wfx_debug($input='',$admin_only=true,$role=false,$id=false) { global $wfx_helper; $wfx_helper->debug($input,$admin_only,$role,$id); } endif;
if ( !function_exists( 'wfx_debug' ) ) : function wfx_debug($input='',$label='',$admin_only=true,$role=false,$id=false) { global $wfx_helper; $wfx_helper->debug($input,$label,$admin_only,$role,$id); } endif;

/**
* @since 1.1
Expand Down
4 changes: 2 additions & 2 deletions wf-includes/wf-engine.php
Expand Up @@ -108,7 +108,7 @@ function wflux_capacitor_helper() {

/**
* @since 0.913
* @updated 1.2
* @updated 2.0
* Creates all Wonderflux helper functions
*/
class wflux_helper_all {
Expand All @@ -128,7 +128,7 @@ function page_depth($args){ return $this->wflux_helper_do->wf_page_depth($args);
function custom_field($args){ return $this->wflux_helper_do->wf_custom_field($args); }
function __Y(){ return $this->wflux_helper_do->wf__Y(); }
function __N(){ return $this->wflux_helper_do->wf__N(); }
function debug($input,$admin_only,$role,$id) { $this->wflux_helper_do->wf_debug($input,$admin_only,$role,$id); }
function debug($input,$label,$admin_only,$role,$id) { $this->wflux_helper_do->wf_debug($input,$label,$admin_only,$role,$id); }
function debug_report($function, $message, $version) { $this->wflux_helper_do->wf_debug_report($function, $message, $version); }
function show_hooks() { $this->wflux_helper_do->wf_show_hooks(); }

Expand Down
15 changes: 8 additions & 7 deletions wf-includes/wf-helper-functions.php
Expand Up @@ -730,11 +730,12 @@ function wf__N() { return 'N'; }
* @lastupdate 2.0
*
* @param string $input The content you wish to debug - a variable or function.
* @param string $admin_only Only display to top level site admin not other users. Default=true
* @param bool $role Only display to supplied WordPress role. Default = ''
* @param integer $id Only display to supplied user ID. Default = ''
* @param string $label Added to top of output to help identify if required.
* @param string $admin_only Only display to top level site admin not other users.
* @param bool $role Only display to supplied WordPress role.
* @param integer $id Only display to supplied user ID.
*/
function wf_debug( $input='', $admin_only=true, $role=false, $id=false ) {
function wf_debug( $input='', $label='', $admin_only=true, $role=false, $id=false ) {

// Check against top level admin
if ( $admin_only && !is_super_admin() )
Expand All @@ -747,9 +748,9 @@ function wf_debug( $input='', $admin_only=true, $role=false, $id=false ) {
return;

$o = '<div style="color:#000; padding:5px; overflow:auto; border: 4px solid #ff0a0a; background-color: #fec9c9;" class="wfx_debug_output">';

$o .= ( !empty($label) ) ? '<pre style="color:#ff0a0a;"><strong>' . esc_html($label) . '</strong></pre>' : '';
if ( empty($input) ) {
$o .= '<pre>' . esc_attr__('No data returned or false/empty/null', 'wonderflux') . '</pre>';
$o .= '<pre>' . esc_html__('No data returned or false/empty/null', 'wonderflux') . '</pre>';
} else {

switch ( $input ) {
Expand Down Expand Up @@ -787,7 +788,7 @@ function wf_debug( $input='', $admin_only=true, $role=false, $id=false ) {
$input = $wp_taxonomies;
}

$o .= '<pre><strong>' . esc_attr__('Debug output for data type:', 'wonderflux') . '</strong> ' . $input_type . '</pre>';
$o .= '<pre><strong>' . esc_html__('Debug output for data type:', 'wonderflux') . '</strong> ' . $input_type . '</pre>';
if (is_array($input) || is_object($input)) {
$o .= '<pre>' . print_r($input,true) . '</pre>';
} else {
Expand Down

0 comments on commit e9e9f07

Please sign in to comment.