storefront theme child and wp_enqueue_scripts

I registered a storefront child theme. From function.php I add class with require if is_admin ().
I am looking to load a js script with wp_enqueue_scripts. in the constructor of my class

add_action ('wp_enqueue_scripts', array ($ this, 'add_books_author_js'));

my function

public function add_books_author_js () {
wp_deregister_script ('books-author-js');
wp_register_script (
get_stylesheet_directory_uri (). '/assets/js/books-author.js',
array ('jquery', 'jquery-ui-autocomplete'),
wp_enqueue_script ('books-author-js');

it doesn’t work and if I copy the code into the class class-storefront-admin.php it works fine

  • This topic was modified 6 days, 7 hours ago by vincentavct.

Source link