/**
  * Expand user macros after the user has been logged in
  * and returns from Facebook.
  */
 function post_login_url_expansion()
 {
     if (empty($_GET['wdfb_expand'])) {
         return false;
     }
     if (preg_match('/\\b(USER_ID|USER_LOGIN)\\b/', $_SERVER['REQUEST_URI'])) {
         wp_safe_redirect(wdfb_get_login_redirect());
         die;
     }
 }
 function process_connect_code($atts, $content = '')
 {
     if (!$this->data->get_option('wdfb_connect', 'allow_facebook_registration')) {
         return $content;
     }
     $atts = shortcode_atts(array('avatar_size' => 32, 'redirect_to' => false), $atts);
     $content = $content ? $content : __('Log in with Facebook', 'wdfb');
     $redirect_to = false;
     if ($atts['redirect_to']) {
         $redirection_keywords = array('current', 'home');
         // Proper link recognition
         if (!in_array($atts['redirect_to'], $redirection_keywords)) {
             $redirect_to = esc_url($atts['redirect_to']);
         }
         if (!$redirect_to && 'home' == $atts['redirect_to']) {
             $redirect_to = home_url();
         }
         if (!$redirect_to && 'current' == $atts['redirect_to']) {
             global $wp;
             $redirect_to = site_url($wp->request);
         }
     }
     if (!class_exists('Wdfb_WidgetConnect')) {
         echo '<script type="text/javascript" src="' . WDFB_PLUGIN_URL . '/js/wdfb_facebook_login.js"></script>';
     }
     $user = wp_get_current_user();
     $html = '';
     if (!$user->ID) {
         $html = '<p class="wdfb_login_button">' . wdfb_get_fb_plugin_markup('login-button', array('scope' => Wdfb_Permissions::get_permissions(), 'redirect-url' => $redirect_to ? apply_filters('wdfb-login-redirect_url', $redirect_to) : wdfb_get_login_redirect(), 'content' => $content)) . '</p>';
     } else {
         $redirect_to = $redirect_to ? apply_filters('wdfb-login-redirect_url', $redirect_to) : home_url();
         $logout = wp_logout_url($redirect_to);
         // Props jmoore2026
         $html .= get_avatar($user->ID, $atts['avatar_size']);
         $html .= "<br /><a href='{$logout}'>" . __('Log out', 'wdfb') . "</a>";
     }
     return $html;
 }
 function inject_fb_login_for_bp()
 {
     if (!apply_filters('wdfb-login-show_buddypress_login_button', apply_filters('wdfb-login-show_login_button', true))) {
         return false;
     }
     echo '<p class="wdfb_login_button">' . wdfb_get_fb_plugin_markup('login-button', array('scope' => Wdfb_Permissions::get_permissions(), 'redirect-url' => wdfb_get_login_redirect(), 'content' => __("Login with Facebook", 'wdfb'))) . '</p>';
 }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $register = (int) @$instance['register'];
        $width = $instance['width'];
        $width = $width ? $width : 250;
        $avatar_size = $instance['avatar_size'];
        $avatar_size = $avatar_size ? $avatar_size : 32;
        $opts = Wdfb_OptionsRegistry::get_instance();
        $register = $register && get_option('users_can_register') ? $register : false;
        if ($opts->get_option('wdfb_connect', 'allow_facebook_registration')) {
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            $user = wp_get_current_user();
            if (!$user->ID) {
                if (!$register) {
                    // Do the simple thing first
                    echo '<p class="wdfb_login_button">' . wdfb_get_fb_plugin_markup('login-button', array('scope' => Wdfb_Permissions::get_permissions(), 'redirect-url' => wdfb_get_login_redirect(), 'content' => __("Login with Facebook", 'wdfb'))) . '</p>';
                } else {
                    $fields = wdfb_get_registration_fields();
                    $force = $opts->get_option('wdfb_connect', 'force_facebook_registration') && $opts->get_option('wdfb_connect', 'require_facebook_account') ? 'fb_only=true&' : '';
                    echo '<div class="wdfb_connect_widget_container">';
                    echo '	<div class="wdfb_connect_widget_tabs"><ul class="wdfb_connect_widget_action_links">';
                    echo '		<li><a href="#wdfb_connect_widget_login"><span>' . __("Login", 'wdfb') . '</span></a></li>';
                    echo '		<li><a href="#wdfb_connect_widget_register"><span>' . __("Register", 'wdfb') . '</span></a></li>';
                    echo '	</ul></div>';
                    echo '	<div style="clear:both"></div>';
                    echo '	<div class="wdfb_connect_target" id="wdfb_connect_widget_login">';
                    echo '		<p class="wdfb_login_button">' . wdfb_get_fb_plugin_markup('login-button', array('scope' => Wdfb_Permissions::get_permissions(), 'redirect-url' => wdfb_get_login_redirect(), 'content' => __("Login with Facebook", 'wdfb'))) . '</p>';
                    echo '	</div>';
                    echo '	<div class="wdfb_connect_target" id="wdfb_connect_widget_register">';
                    echo '	<iframe src="' . WDFB_PROTOCOL . 'www.facebook.com/plugins/registration.php?' . $force . 'client_id=' . trim($opts->get_option('wdfb_api', 'app_key')) . '&' . 'redirect_uri=' . urlencode(site_url('/wp-signup.php?action=register&fb_register=1')) . '&' . 'fields=' . $fields . '&width=' . $width . '&locale=' . wdfb_get_locale() . '"
						        scrolling="auto"
						        frameborder="no"
						        style="border:none; overflow:hidden; width:' . $width . 'px;"
						        allowTransparency="true"
						        width="' . $width . '"
						        height="650">
							</iframe>';
                    echo '	</div>';
                    echo '</div>';
                }
            } else {
                //$logout = site_url('wp-login.php?action=logout&redirect_to=' . rawurlencode(home_url()));
                $logout = wp_logout_url(home_url());
                // Props jmoore2026
                echo get_avatar($user->ID, $avatar_size);
                echo "<p><a href='{$logout}'>" . __('Log out', 'wdfb') . "</a></p>";
            }
            echo $after_widget;
        }
    }