Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$10
Custom Footer Function Producing Error
I have the following code in my functions.php file. It takes the javascript and adds it into the footer. Seemed to be working fine, but a user is claiming it's producing an error on their end. Just looking for someone to find what could be the issue!
Here is part of the code I believe is causing the error.
//Include Scripts
add_action('init', 'ok_theme_js');
function ok_theme_js() {
if (is_admin()) return;
//jQuery Via Google
wp_deregister_script( 'jquery' );
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"), false, '1.3.2', true);
wp_enqueue_script( 'jquery' );
//Pretty Photo
wp_enqueue_script('pretty_photo_js', get_stylesheet_directory_uri() . '/includes/js/jquery.prettyPhoto.js', false, false , true);
}
//Add Javascript To Footer
add_action('wp_footer', 'print_my_script');
function ok_footer_scripts() { ?>
<script type="text/javascript">
/* <![CDATA[ */
var J = jQuery.noConflict();
J(document).ready(function(){
//Lightbox
J("a[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square'});
//Portfolio hover
J(".ad img, .portfolio-large img").hover(
function() {
J(this).animate({"opacity": ".8"}, "fast");
},
function() {
J(this).animate({"opacity": "1"}, "fast");
});
//Portfolio hover
J(".fade img, .portfolio-items4 li a, .portfolio-items li a, .single-large img, .portfolio-item-third img, .portfolio-items2 a, .portfolio-item-third a, .blog-content h3 a").hover(
function() {
J(this).animate({"opacity": ".8"}, "fast");
},
function() {
J(this).animate({"opacity": "1"}, "fast");
});
//Removes the margin of the portfolio items on the furthest right side of the page. Let's you achieve a full-width portfolio.
J(".portfolio-items > li:nth-child(5n)").addClass('removemargin');
J(".portfolio-items2 > li:nth-child(2n)").addClass('removemargin');
J(".portfolio-items4 > li:nth-child(3n)").addClass('removemargin');
J(".portfolio-item-half .portfolio-items > li:nth-child(2n)").addClass('removemargin');
J(".portfolio-row > li:nth-child(5n)").addClass('removemargin');
J("div.columns > div:nth-child(4n)").addClass('remove-border');
J('<div style="clear:both;"> </div>').insertAfter('.content-full ul li:nth-child(3n)');
J('<div style="clear:both;"> </div>').insertAfter('.portfolio-items4 li:nth-child(3n)');
J('<div style="clear:both;"> </div>').insertAfter('.portfolio-items > li:nth-child(5n)');
});
/* ]]> */
</script>
And this is the error it is producing:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'print_my_script' was given in /home/badreef/public_html/wp-includes/plugin.php on line 405
This question has been answered.
Mike McAlister | 07/19/11 at 3:18pm
Edit
Previous versions of this question:
07/19/11 at 3:22pm
(2) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
07/19/11
3:20pmUtkarsh Kukreti says:That part isn't causing the error. Please search for "print_my_script" in your files, and paste the code around that.
- 07/19/11 3:22pm
Mike McAlister says:Whoops! I meant to post the whole snippet actually. There it is.
Mike - 07/19/11 3:22pm
Utkarsh Kukreti says:add_action('wp_footer', 'print_my_script');
should be
add_action('wp_footer', 'ok_footer_scripts'); - 07/19/11 3:28pm
Mike McAlister says:Perfect, that'll do it! Thanks Utkarsh!
Mike
- 07/19/11 3:22pm
-

Last edited:
07/19/11
3:24pmEddie Moya says:You dont seem (at least in this snippet) to have a function called 'print_my_script'. That string is sometimes used as an example for enqueueing javascript. It this is not being used here, remove it, otherwise check if there is typo or something. There should be a function called print_my_script()
This question has expired.
Mike McAlister voted on this question.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
