You’re using the incorrect hook. The only hook is wp_enqueue_scripts
(plural). You use wp_enqueue_style()
and wp_register_script()
etc. on that hook, but the hook is always the same.
So this:
add_action('wp_enqueue_script' , array( $this, 'initBootstrap' ));
add_action('wp_enqueue_style' , array( $this, 'initBootstrap' ));
add_action('wp_register_script' , array( $this, 'initParallax' ));
add_action('wp_register_style' , array( $this, 'initParallax' ));
add_action('wp_register_script' , array( $this, 'initSwiper' ));
add_action('wp_register_style' , array( $this, 'initSwiper' ));
Needs to be:
add_action('wp_enqueue_scripts' , array( $this, 'initBootstrap' ));
add_action('wp_enqueue_scripts' , array( $this, 'initBootstrap' ));
add_action('wp_enqueue_scripts' , array( $this, 'initParallax' ));
add_action('wp_enqueue_scripts' , array( $this, 'initParallax' ));
add_action('wp_enqueue_scripts' , array( $this, 'initSwiper' ));
add_action('wp_enqueue_scripts' , array( $this, 'initSwiper' ));
That’s the reason it wasn’t working, but you’re also misusing wp_script_is()
. It won’t affect your code, since the result will always be false, but you need to pass the handle of the script, not the filename.
So this:
if( !wp_style_is( 'universal-parallax.min.css' , 'enqueued' ) ){
wp_register_style( 'parallax' , plugin_dir_url(__FILE__).'/css/universal-parallax.min.css' );
}
Should be:
if( !wp_style_is( 'parallax', 'enqueued' ) ){
wp_register_style( 'parallax' , plugin_dir_url(__FILE__).'/css/universal-parallax.min.css' );
}
However, you really don’t need that condition at all. If the script is already enqueued, then nothing’s going to happen, so there’s no reason to check for it.