Using a Child Theme, you can include a JS file and add all of your custom JS code to this single file.
Add this to the child theme functions.php file:
function my_custom_scripts() {
wp_enqueue_script('my-custom-scripts', get_stylesheet_directory_uri() . '/scripts.js', array('jquery'));
}
add_action('wp_enqueue_scripts', 'my_custom_scripts');
Create a new file called scripts.js and place it within your child theme folder.
The contents of this JS file should look like this:
jQuery(document).ready(function($){
// your scripts here
});
Hope this helps.
Hi
Thanks for the reply. Let me just clarify – here is my script. Must I add it to the JS file after the // or must I replace the whole line: // your scripts here
Sorry, not a javascript expert.
<script language=”JavaScript” type=”text/javascript”>
function click_30ef326adb4cf4078246ffe3f7e6c41c( aform_reference ) {
var aform = aform_reference;
aform[‘amount’].value = Math.round( aform[‘amount’].value*Math.pow( 10,2 ) )/Math.pow( 10,2 );
aform[‘custom_amount’].value = aform[‘custom_amount’].value.replace( /^\s+|\s+$/g,”” );
if( !aform[‘custom_amount’].value || 0 === aform[‘custom_amount’].value.length || /^\s*$/.test( aform[‘custom_amount’].value ) ) {
alert ( ‘An amount is required’ );
return false;
}
aform[‘amount’].value = Math.round( aform[‘custom_amount’].value*Math.pow( 10,2 ) )/Math.pow( 10,2 );
}
</script>
Hi there
Don’t know if you found a solution yet.
I had the same problem. WordPress wraps the code in <p> which makes it unusable.
There’s a plugin called “Don’t muck my markup”. It works like a bomb.
It disables the auto-formatting.
Hope it helps.