jfb_output_facebook_btn

Output a Login with Facebook Button.

Description

jfb_output_facebook_btn( (int) $callbackName = 0 ); 

Parameters (1)

0. $callbackname (int)
The callbackname.

Usage

  1. if ( !function_exists( 'jfb_output_facebook_btn' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'wp-fb-autoconnect/Main.php'; 
  3.  
  4. // The callbackname. 
  5. $callbackname = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jfb_output_facebook_btn($callbackname); 
  9.  

Defined (1)

The function is defined in the following location(s).

/Main.php  
  1. function jfb_output_facebook_btn($callbackName=0) 
  2. //Make sure the plugin has been setup 
  3. global $jfb_name, $jfb_version, $jfb_js_callbackfunc, $opt_jfb_valid; 
  4. global $opt_jfb_ask_perms, $opt_jfb_ask_stream, $opt_jfbp_requirerealmail; 
  5. echo "<!-- $jfb_name Button v$jfb_version -->\n"; 
  6. if( !get_option($opt_jfb_valid) ) 
  7. echo "<!--WARNING: Invalid or Unset Facebook API Key-->"; 
  8. return; 
  9.  
  10. //If a callback name is explicitly specified, use that. Otherwise, use the global (main) callback. 
  11. if( !$callbackName ) $callbackName = $jfb_js_callbackfunc; 
  12.  
  13. //Figure out our scope (aka extended permissions) 
  14. $email_perms = get_option($opt_jfb_ask_perms) || get_option($opt_jfbp_requirerealmail); 
  15. $stream_perms = get_option($opt_jfb_ask_stream); 
  16. if( $email_perms && $stream_perms ) $scope = 'email, publish_actions'; 
  17. else if( $email_perms ) $scope = 'email'; 
  18. else if( $stream_perms ) $scope = 'publish_actions'; 
  19. else $scope = ''; 
  20. $scope = apply_filters('wpfb_extended_permissions', $scope); 
  21.  
  22. //Output the button for the Premium version. NOTE: This will not work with pre-v30 Premium addons. 
  23. if(defined('JFB_PREMIUM_VER') && function_exists('jfb_output_facebook_btn_premium_30')) 
  24. //The $callbackName param was introduced to this fxn in v3.1.4. In order to avoid having to simultaneously 
  25. //update both the premium addon and the core plugin, I'm gonna use this kinda "hacky" way to tell the addon 
  26. //about the $callbackName. If no $callbackName param was specified, it'll be the same as $jfb_js_callbackfunc 
  27. //(aka the global option), so this save-and-restore approach will have no effect. 
  28. $savedGlobalCallback = $jfb_js_callbackfunc; 
  29. $jfb_js_callbackfunc = $callbackName; 
  30. jfb_output_facebook_btn_premium_30($scope); 
  31. $jfb_js_callbackfunc = $savedGlobalCallback; 
  32.  
  33. //Output the button for the free version. NOTE that I explicitly check that this is the free version, vs an older  
  34. //Premium version; it's not safe to allow logins with old Premium versions, as those depend on the PHP API which is no longer present. 
  35. //(Allowing out-of-date premium addons to login will crash in some circumstances - i.e. with autoregistration restrictions, etc.) 
  36. else if(!defined('JFB_PREMIUM_VER')) 
  37. ?><span class="fbLoginButton"><script type="text/javascript">//<!-- 
  38. document.write('<fb:login-button scope="<?php echo $scope ?>" v="2" size="small" onlogin="<?php echo $callbackName ?>();"><?php echo apply_filters('wpfb_button_text', 'Login with Facebook') ?></fb:login-button>'); 
  39. //--></script></span><?php 
  40.  
  41. //Run action 
  42. do_action('wpfb_after_button');