Is there a plugin that supports calling custom functions that you've created?
Like,
page A -- I want to call function x
$(document).ready(function(){
call_function_x()
});
page B -- I want to call function y
$(document).ready(function(){
call_function_y()
});
I don't want to write the calls in the main input because of others editing and might delete them by misstake...
This is my current solution but not optimal in my eyes :)
footer.php:
<?php
/* Always have wp_footer() just before the closing </body>
* tag of your theme, or you will break many plugins, which
* generally use this hook to reference JavaScript files.
*/
wp_footer();
$js = get_post_meta($post->ID, 'javascript', true);
if ( $js != "" ) {
?>
<script type="text/javascript">
$(document).ready(function(){
<?php echo $js; ?>
});
<?php } ?>
then I added custom field "javascript" on the pages with their custom functions like this.
function_x(some_variable); function_y(some_var); function_foo(bar);