Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
49933487
authored
2010-07-02 03:39:42 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Mostly bug fixes
1 parent
63da00b4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
29 deletions
com/Analytics/Analytics.php
com/Analytics/Settings.php
com/Auth/Facebook/Facebook.php
tz-tools.php
com/Analytics/Analytics.php
View file @
4993348
<?php
namespace
Tz\WordPress\Tools\Analytics
;
use
Tz
;
use
Tz\WordPress\Tools
;
const
OPTION_NAME
=
'tz_analytics'
;
...
...
@@ -21,17 +22,18 @@ class Actions {
return
;
}
?>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '
<?php
echo
Vars
::
$options
[
'api_key'
];
?>
']);
_gaq.push(['
_trackPageview
']);
(function() {
var ga = document.createElement('
script
'); ga.type = '
text
/
javascript
'; ga.async = true;
var ga = document.createElement('
script
'); ga.type = '
text
/
javascript
';
ga.async = true;
ga.src = ('
https
:
' == document.location.protocol ? '
https
:
//ssl' : 'http://www') + '.google-analytics.com/ga.js';
var
s
=
document
.
getElementsByTagName
(
'script'
)[
0
];
s
.
parentNode
.
insertBefore
(
ga
,
s
);
})();
</script>
</script>
<?php
}
}
...
...
com/Analytics/Settings.php
View file @
4993348
...
...
@@ -40,7 +40,7 @@ class Actions {
class
Fields
{
public
static
function
api_key
()
{
echo
'<input tpe="text" name="'
.
Analytics\OPTION_NAME
.
'['
.
__FUNCTION__
.
']" id="'
.
__FUNCTION__
.
'" value="'
.
Analytics\Vars
::
$options
[
__FUNCTION__
]
.
'" />'
;
echo
'<input t
y
pe="text" name="'
.
Analytics\OPTION_NAME
.
'['
.
__FUNCTION__
.
']" id="'
.
__FUNCTION__
.
'" value="'
.
Analytics\Vars
::
$options
[
__FUNCTION__
]
.
'" />'
;
}
}
?>
\ No newline at end of file
...
...
com/Auth/Facebook/Facebook.php
View file @
4993348
...
...
@@ -28,6 +28,8 @@ namespace Tz\WordPress\Tools\Auth\Facebook;
use
Tz\WordPress\Tools
;
use
Tz\WordPress\Tools\Auth
;
use
FB
;
use
InvalidArgumentException
;
const
OPTION_NAME
=
'tz_auth_fb'
;
...
...
@@ -49,7 +51,8 @@ const OPTION_NAME = 'tz_auth_fb';
* @returns NULL|String
*/
function
drawLoginButton
(
$echo
=
true
)
{
$btn
=
'<a id="TzFB" class="fb_button fb_button_medium"><span class="fb_button_text">'
.
Vars
::
$options
[
'button_title'
]
?:
'Login'
.
'</span></a>'
;
$title
=
Vars
::
$options
[
'button_title'
]
?:
'Login'
;
$btn
=
'<a id="TzFB" class="fb_button fb_button_medium"><span class="fb_button_text">'
.
$title
.
'</span></a>'
;
if
(
!
$echo
)
{
return
$btn
;
...
...
@@ -58,21 +61,28 @@ function drawLoginButton($echo = true) {
echo
$btn
;
}
function
loadSDK
()
{
static
$loaded
=
false
;
if
(
$loaded
)
{
return
;
}
$loaded
=
true
;
// This might need some work...what happens if the object fails?
function
getSDK
()
{
static
$instance
=
false
;
if
(
false
===
$instance
)
{
require_once
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'facebook-sdk.php'
);
Vars
::
$sdk
=
new
\
FB\Facebook
(
Array
(
$instance
=
new
FB\Facebook
(
Array
(
'appId'
=>
Vars
::
$options
[
'application_id'
]
,
'secret'
=>
Vars
::
$options
[
'application_secret'
]
,
'cookie'
=>
true
));
}
return
$instance
;
}
/*
* Logic for all these methods needs to be re-thought out
* Should only load FB stuff when something happens (decide)
* 1) drawLoginButton() has been called
* 2) User is on the login_page
* 3) Some other clever way of deciding if FB stuff should load
*/
class
Actions
{
/**
* Logs the user in to WP if they logged into FB
...
...
@@ -82,10 +92,10 @@ class Actions {
global
$post
;
// I want a better way to do this
if
(
$post
->
ID
==
Auth\Vars
::
$options
[
'login_page'
]
&&
!
is_user_logged_in
())
{
load
SDK
();
$sdk
=
get
SDK
();
if
(
Vars
::
$sdk
->
getSession
())
{
$info
=
Vars
::
$sdk
->
api
(
'/me'
);
if
(
$sdk
->
getSession
())
{
$info
=
$sdk
->
api
(
'/me'
);
// get email, verify vs database
// register and/or login
}
...
...
@@ -117,16 +127,21 @@ class Actions {
* Destroy Facebook session data on site if the log out of WordPress
*/
public
static
function
wp_logout
()
{
load
SDK
();
Vars
::
$sdk
->
setSession
();
// I think this is how you log them out of Facebook
$sdk
=
get
SDK
();
$sdk
->
setSession
();
// I think this is how you log them out of Facebook
}
}
class
ShortCodes
{
public
static
function
fb_login_button
()
{
if
(
Vars
::
$sdk
->
getSession
())
{
if
(
is_user_logged_in
())
{
return
''
;
}
$sdk
=
getSDK
();
if
(
$sdk
->
getSession
())
{
ob_start
();
print_r
(
Vars
::
$sdk
->
api
(
'/me'
));
print_r
(
$sdk
->
api
(
'/me'
));
$data
=
'<pre>'
.
ob_get_contents
()
.
'</pre>'
;
ob_end_clean
();
...
...
@@ -143,11 +158,5 @@ class Vars {
* @type WP_Option
*/
public
static
$options
;
/**
* An instance of Facebook's PHP SDK
* @type Facebook
*/
public
static
$sdk
;
}
?>
\ No newline at end of file
...
...
tz-tools.php
View file @
4993348
...
...
@@ -10,8 +10,8 @@ namespace Tz\WordPress\Tools;
use
Tz\WordPress\Tools\ShortCodes
;
use
\ReflectionClass
,
\
ReflectionMethod
;
use
\
Exception
;
use
ReflectionClass
,
ReflectionMethod
;
use
Exception
;
spl_autoload_register
(
__NAMESPACE__
.
'\autoloader'
);
...
...
@@ -36,7 +36,6 @@ function import($com) {
}
function
autoloader
(
$class
)
{
$a
=
explode
(
'\\'
,
$class
);
$class
=
array_pop
(
$a
);
...
...
Please
register
or
sign in
to post a comment