Facebook.php
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* This needs to go in the <html tag
* xmlns:fb="http://www.facebook.com/2008/fbml"
*
* http://wpdev.tenzinghost.com
* API Key: 83f54e078b9aa0e303bba959dc0a566f
* App Secret: e542aca35ab698121fa5917211013a41
* App ID: 105917066126941
*
* http://wp.cb
* API Key: 3bcccfd8c28c52197141266d9e417649
* App Secret: 9bfcd828bc6ccef12336dea57df93ecb
* App ID: 138943536118944
*/
namespace Tz\WordPress\Tools\Auth\Facebook;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\ShortCodes as SC;
use InvalidArgumentException;
const OPTION_NAME = 'tz_auth_fb';
call_user_func(function() {
SC\add_shortcodes(__NAMESPACE__ . '\ShortCodes');
Vars::$options = new Tools\WP_Option(OPTION_NAME);
if (is_admin()) {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'Settings.php');
}
});
function loadJSSDK() {
return '
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: \'' . Vars::$options['application_id'] . '\', status: true, cookie: true, xfbml: true});
FB.Event.subscribe(\'auth.login\', function(response) { window.location.reload(); });
};
(function() {
var e = document.createElement(\'script\'); e.async = true;
e.src = document.location.protocol + \'//connect.facebook.net/en_US/all.js\';
document.getElementById(\'fb-root\').appendChild(e);
}());
</script>
';
}
function drawLoginButton($value = 'Login') {
echo '<fb:login-button></fb:login-button>';
// echo '<a class="fb_button fb_button_medium"><span class="fb_button_text">' . $value . '</span></a>';
}
class Vars {
public static $options = false;
}
class ShortCodes {
public static function fb_login_button() {
ob_start();
drawLoginButton();
$btn = ob_get_contents();
ob_end_clean();
return $btn;
}
}
?>