I have a syntax error in my php code and just cannot figure out how should I fix it. I've been trying for ages and narrowed down the faulty code to the following :
<?php
global $post;
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
if ( ! class_exists( 'Tax_Meta_Boxes' ) ) :
class Tax_Meta_Boxes {
public function __construct() {
add_action( 'save_post', array( $this, 'tax_meta_data' ) );
}
}
?>
I ran the code through the PHP checker, the error seems to be with the last line and ?>.
I tried fiddling around with it, remove it, but error still there.
The error is caused by the function :
if ( ! class_exists( 'Tax_Meta_Boxes' ) ) :
class Tax_Meta_Boxes {
public function __construct() {
add_action( 'save_post', array( $this, 'tax_meta_data' ) );
}
}
If I remove the function, my error is gone, but what is wrong in the code of this function, how can I fix it ?