wc_get_logger refactored

This commit is contained in:
Khan M Rashedun-Naby 2018-06-07 13:46:06 +06:00
parent 2bb466d53f
commit 76a9e19471
1 changed files with 23 additions and 23 deletions

View File

@ -1636,30 +1636,30 @@ function wc_get_logger() {
$class = apply_filters( 'woocommerce_logging_class', 'WC_Logger' );
if ( null === $logger || ! is_a( $logger, $class ) ) {
$implements = class_implements( $class );
if ( is_array( $implements ) && in_array( 'WC_Logger_Interface', $implements, true ) ) {
if ( is_object( $class ) ) {
$logger = $class;
} else {
$logger = new $class();
}
} else {
wc_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: 1: class name 2: woocommerce_logging_class 3: WC_Logger_Interface */
__( 'The class %1$s provided by %2$s filter must implement %3$s.', 'woocommerce' ),
'<code>' . esc_html( is_object( $class ) ? get_class( $class ) : $class ) . '</code>',
'<code>woocommerce_logging_class</code>',
'<code>WC_Logger_Interface</code>'
),
'3.0'
);
$logger = is_a( $logger, 'WC_Logger' ) ? $logger : new WC_Logger();
}
if ( null !== $logger && is_a( $logger, $class ) ) {
return $logger;
}
$implements = class_implements( $class );
if ( is_array( $implements ) && in_array( 'WC_Logger_Interface', $implements, true ) ) {
$logger = is_object( $class ) ? $class : new $class();
} else {
wc_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: 1: class name 2: woocommerce_logging_class 3: WC_Logger_Interface */
__( 'The class %1$s provided by %2$s filter must implement %3$s.', 'woocommerce' ),
'<code>' . esc_html( is_object( $class ) ? get_class( $class ) : $class ) . '</code>',
'<code>woocommerce_logging_class</code>',
'<code>WC_Logger_Interface</code>'
),
'3.0'
);
$logger = is_a( $logger, 'WC_Logger' ) ? $logger : new WC_Logger();
}
return $logger;
}