WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

wc_print_r() WC 3.0

Prints human-readable information about a variable.

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

Хуки из функции
Возвращает

Строку/true/false. False if expression could not be printed. True if the expression was printed.

    If `$return` is true, a string representation will be returned.

Использование

wc_print_r( $expression, $return );
$expression(смешанный) (обязательный)
The expression to be printed.
$return(true/false)
Set to true to return the human-readable string.
По умолчанию: false

Список изменений

С версии 3.0 Введена.

Код wc_print_r() WC 4.6.0

<?php
function wc_print_r( $expression, $return = false ) {
	$alternatives = array(
		array(
			'func' => 'print_r',
			'args' => array( $expression, true ),
		),
		array(
			'func' => 'var_export',
			'args' => array( $expression, true ),
		),
		array(
			'func' => 'json_encode',
			'args' => array( $expression ),
		),
		array(
			'func' => 'serialize',
			'args' => array( $expression ),
		),
	);

	$alternatives = apply_filters( 'woocommerce_print_r_alternatives', $alternatives, $expression );

	foreach ( $alternatives as $alternative ) {
		if ( function_exists( $alternative['func'] ) ) {
			$res = $alternative['func']( ...$alternative['args'] );
			if ( $return ) {
				return $res; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
			}

			echo $res; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
			return true;
		}
	}

	return false;
}