Example #1
0
<?php

ob_start();
?>
<div id="loginform">
<?php 
$_SESSION['facebook_use_last_page'] = 1;
echo ym_fbook_wp_login_form_top();
?>

<div>
<p class="center">
In order to continue you must permit the Application access to your Facebook Profile
<br /><br />
<a id="ym_fb_login_button" href="<?php 
echo ym_fbook_oauth_go();
?>
" target="_parent">Login</a>
</p>
</div>

</div>
<?php 
if ($noecho) {
    $login = ob_get_contents();
    ob_end_clean();
} else {
    ob_end_flush();
}
function ym_fbook_has_oauth_expired()
{
    if ($_SESSION['facebook_oauth_expires'] < time() && $_SESSION['facebook_oauth_expires']) {
        // ARG EXPIRED :-(
        // send to auth to go get a new token
        $_SESSION['facebook_use_last_page'] = 1;
        echo '<script type="text/javascript">top.location.href="' . ym_fbook_oauth_go() . '"</script>';
        exit;
    }
}
function ym_fbook_profile($echo = FALSE)
{
    global $facebook_settings, $facebook_client;
    $return = '';
    // messages
    $target = ym_fbook_oauth_go();
    // messages
    if ($facebook_settings->force_facebook_auth && !$_SESSION['facebook_user_id']) {
        ym_fbook_add_message(__('In order to continue you must login to the Facebook Application', 'ym_facebook'));
    }
    if ($facebook_settings->force_wordpress_auth && !$_SESSION['wordpress_user_id']) {
        ym_fbook_add_message(__('In order to continue you must login to WordPress', 'ym_facebook'));
    }
    if ($facebook_settings->require_link && !ym_fbook_is_linked()) {
        ym_fbook_add_message(__('In order to continue you must Link your accounts', 'ym_facebook'));
    }
    ym_fbook_messages();
    $return .= '
<table id="ym_fbook_status">
	<tr>
		<th>' . __('WordPress Status', 'ym_facebook') . '</th><td>';
    if (is_user_logged_in()) {
        global $current_user;
        get_currentuserinfo();
        $return .= __(sprintf('Logged in as <strong>%s</strong>', $current_user->user_login), 'ym_facebook') . ' </td><td>';
        //			if ($_SESSION['in_facebook']) {
        $return .= '<form action="" method="post" id="ym_fb_loggedoutform"><input type="hidden" name="loggedout" value="1" /><a href="#nowhere" onclick="jQuery(this).parents(\'form\').submit()">' . __('Logout') . '</a></form>';
        //			} else {
        //				$return .= '<a href="' . wp_logout_url($_SERVER['REQUEST_URI']) . '">' . __('Logout') . '</a>';
        //			}
    } else {
        $return .= __('Not Logged In', 'ym_facebook') . '</td><td><a href="';
        if ($_SESSION['in_facebook']) {
            $return .= '?login=1';
        } else {
            $return .= site_url('wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
        }
        $return .= '">' . __('Login') . '</a>';
        /*
        if ($facebook_settings->register_with_facebook) {
        	$return .= ' | ';
        	$return .= '<a href="?register=1">Register Account</a>';
        }
        */
    }
    $return .= '</td>
		</tr><tr>
		<th>' . __('Facebook Status', 'ym_facebook') . '</th><td>';
    if ($facebook_client) {
        $return .= __(sprintf('Logged in as <strong>%s</strong>', $facebook_client->user_data->name), 'ym_facebook') . '</td><td>';
        $return .= '<a href="#nowhere" class="ym_fbook_logout">' . __('Logout') . '</a>';
    } else {
        $return .= __('Not Logged In', 'ym_facebook') . '</td><td><a href="';
        $return .= $target;
        $return .= '" target="_parent">' . __('Login') . '</a>';
    }
    $return .= '</td>
		</tr><tr>
		<th>' . __('Link Status', 'ym_facebook') . '</th><td>';
    if (is_user_logged_in()) {
        $id = ym_fbook_is_linked();
        if ($id) {
            $return .= __('Linked', 'ym_facebook') . '</td><td>';
            if (!$facebook_settings->require_link) {
                $return .= '<form action="" method="post"><input type="hidden" name="dounlink" value="1" /><a href="#nowhere" onclick="jQuery(this).parents(\'form\').submit();">' . __('UnLink', 'ym_facebook') . '</a></form>';
            }
        } else {
            $return .= __('Not Linked', 'ym_facebook') . '</td><td><form action="" method="post"><input type="hidden" name="dolink" value="1" /><a href="#nowhere" onclick="jQuery(this).parents(\'form\').submit();">' . __('Link', 'ym_facebook') . '</a></form>';
        }
    } else {
        $return .= __('Login to Lnk', 'ym_facebook');
    }
    $return .= '
		</td>
	</tr>
</table>
';
    if ($echo) {
        echo $return;
    } else {
        return $return;
    }
}