woocommerce_print_r_alternatives

Prints human-readable information about a variable.

Description

(string|bool) apply_filters( 'woocommerce_print_r_alternatives', (mixed) $alternatives, (bool) $expression ); 

Some server environments blacklist some debugging functions. This function provides a safe way to turn an expression into a printable, readable form without calling blacklisted functions.

Returns (string|bool)

False if expression could not be printed. True if the expression was printed. If $return is true, a string representation will be returned.

Parameters (2)

0. $alternatives (mixed)
The expression to be printed.
1. $expression — Optional. (bool)
Default false. Set to true to return the human-readable string.

Usage

To run the hook, copy the example below.
  1. $alternatives = apply_filters( 'woocommerce_print_r_alternatives', $alternatives, $expression ); 
  2.  
  3. if ( !empty( $alternatives ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_print_r_alternatives callback 
  2. function filter_woocommerce_print_r_alternatives( $alternatives, $expression ) { 
  3. // make filter magic happen here... 
  4. return $alternatives
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_print_r_alternatives', 'filter_woocommerce_print_r_alternatives', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_print_r_alternatives', 'filter_woocommerce_print_r_alternatives', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/wc-core-functions.php  
  1. $alternatives = apply_filters( 'woocommerce_print_r_alternatives', $alternatives, $expression );