function wpfbbtn_append_button()
{
    if (isset($_GET['redirect_to'])) {
        $redirectTo = $_GET['redirect_to'];
    } else {
        $redirectTo = htmlspecialchars($_SERVER['REQUEST_URI']);
    }
    if (strpos($redirectTo, 'login')) {
        $redirectTo = '/';
    }
    jfb_output_facebook_btn();
    jfb_output_facebook_init();
    jfb_output_facebook_callback($redirectTo);
}
Beispiel #2
0
//and popup a Facebook Connect dialog.  When they click OK it'll redirect them through
//process_login.php just as if they clicked "Login with Facebook" manually.
//NOTE: The following is a sample template, but you'll almost certainly have to customize it to work
//with your theme and show what you want.  The only important thing is to call jfb_output_facebook_init(),
//jfb_output_facebook_callback(get_permalink($post->ID)), and jfb_output_facebook_instapopup().
//Those three functions will be sufficient to show the Facebook popup and setup the login redirect.
j_mail("Facebook Autologin", "Post " . $_REQUEST['p'] . " requires login: Showing Facebook prompt (Referrer: " . $_SERVER['HTTP_REFERER'] . ")");
/******************Template for "AutoLogin" Page******************/
get_header();
//get_sidebar();
echo '<div id="main-col"><div id="content" class="post">';
//Output Facebook Javascript to immediately show a login prompt to the user
//Note: The FB api is already initialized via wp_footer, so I don't need to
//call jfb_output_facebook_init() again - I just create another login callback, this time which
//redirects to the destination post instead of back to the current page.
jfb_output_facebook_callback(get_permalink($post->ID), "autologin_callback");
jfb_output_facebook_instapopup("autologin_callback");
//Show the user a message.  Since the post is private and the user isn't yet logged in, you can
//use your discretion as to what information you reveal about the destination post.
if (function_exists('gallery_pg_id') && $post->post_parent == gallery_pg_id()) {
    echo "<h2>{$post->post_title}</h2><br />This photo album is private and requires login.  A Facebook Connect window should popup in a moment.<br /><br />";
} else {
    echo "<h2>Login Required</h2><br />This post is private and requires login.  A Facebook Connect window should popup in a moment.<br /><br />";
}
//If the destination post has a thumbnail, show it (sizing it down if it's too wide)
if (has_post_thumbnail($post->ID)) {
    $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
    $maxWd = 590;
    if ($thumb[1] > $maxWd) {
        $thumb[2] = $maxWd * ($thumb[2] / $thumb[1]);
        $thumb[1] = $maxWd;