I have designed a WordPress template for my site, and in the function file, I have used the following code to introduce style files to WordPress:
class JSXStyle {
public function __construct( $name ) {
$this->MyStyle = $name;
add_action( 'wp_enqueue_scripts', array( $this, 'register_custom_style' ) );
}
public function register_custom_style() {
wp_enqueue_style( $this->MyStyle, get_stylesheet_directory_uri() . "/css/{$this->MyStyle}.css", array(), '4.0.0' );;
}
}
new JSXStyle( 'style-1' );
new JSXStyle( 'style-2' );
new JSXStyle( 'style-3' );
new JSXStyle( 'style-4' );
This code works correctly. But when I installed the query-monitor plugin, this code got an error and displayed the following message:
Creation of dynamic property JSXStyle::$MyStyle is deprecated
I don't know how to edit this code to get rid of this error. Is there a way to update this code or should I use another method?