Adding action in global.js ?
I have a javasrcipt to do some charactor converting job before post by adding an extra button next to bp Post button.
So far, I’ve managed to load my js through function.php. The next step is to edit the global.js.
Since my button is a small part of each bp post submitting area, it’s more convinient to mix my js with bp’s js,
Is it the correct thing to do like this–
#1. Copy global.js file into child theme folder;
#2. Copy this line from default theme function.php:
`wp_enqueue_script( ‘dtheme-ajax-js’, get_template_directory_uri() . ‘/_inc/global.js’, array( ‘jquery’ ) );`
#3. Paste this line in child them function.php, and edite the js url:
`wp_enqueue_script( ‘myjs’, ‘http://mydomain.com/wp-contents/theme/childthem/global.js’, array( ‘jquery’ ) );`
#4. Edit the copy of global.js file in child them folder to add my js directly into it.
I’m deeply in doubting here– childthem function.php can overwrite default them funtion if they are the same, but, “wp_enqueue_script() ” can be used more than once in a function php file. So, maybe the edited global.js will get loaded due to the “wp_enqueue_script() ” in child theme’s function.php, and the original global.js will get loaded too — due to the “wp_enqueue_script() ” in default theme’s function.php.
Would anybody shade some light on this?
- The topic ‘Adding action in global.js ?’ is closed to new replies.