0

I have FB Auto Login plugin installed and i have wrote my own custom javascript to handle logins. Now my question is how do i override the jfb_output_facebook_init function with my own function which echos "Hello World" for example?

add_action('wp_footer', 'jfb_output_facebook_init');
function jfb_output_facebook_init()
{
global $jfb_name, $jfb_version, $opt_jfb_app_id, $opt_jfb_api_key, $opt_jfb_valid;
if( !get_option($opt_jfb_valid) ) return;

$channelURL = plugins_url(dirname(plugin_basename(__FILE__))) . "/facebook-platform/channel.html";
echo "\n<!-- $jfb_name Init v$jfb_version (NEW API) -->\n";
?>
<div id="fb-root"></div>
<script type="text/javascript">//<!--
  window.fbAsyncInit = function()
  {
    FB.init({
        appId: '<?php echo get_option($opt_jfb_app_id); ?>', status: true, cookie: true, xfbml: true, oauth:true, channelUrl: '<?php echo $channelURL; ?>' 
    });
    <?php do_action('wpfb_add_to_asyncinit'); ?>            
  };

  (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/<?php echo apply_filters('wpfb_output_facebook_locale', 'en_US'); ?>/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
//--></script>

}

1 Answer 1

0

You can simply remove the old function using remove_action() hook, and add your own using add_action() hook.

Example -

remove_action('wp_footer', 'jfb_output_facebook_init');
add_action('wp_footer', 'your_function');
1
  • You sir, are a legend. Worked like a charm :)
    – Loxzibit
    Aug 14, 2012 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.