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;
 }
/**
 * Dashboard permissions widget function.
 */
function wdfb_dashboard_permissions_widget()
{
    echo '<div class="wdfb_perms_root" style="display:none">' . '<p class="wdfb_perms_granted">' . '<span class="wdfb_message">' . __('You already granted extended permissions', 'wdfb') . '</span> ' . '</p>' . '<p class="wdfb_perms_not_granted">' . '<a href="#" class="wdfb_grant_perms" data-wdfb_locale="' . wdfb_get_locale() . '" data-wdfb_perms="' . Wdfb_Permissions::get_permissions() . '">' . __('Grant extended permissions', 'wdfb') . '</a>' . '</p>' . '</div>';
    echo '<script type="text/javascript" src="' . WDFB_PLUGIN_URL . '/js/check_permissions.js"></script>';
}
 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;
        }
    }
 function facebook_publishing_metabox()
 {
     global $post;
     $opt = $this->_get_option('wdfb_autopost');
     $is_published = get_post_meta($post->ID, 'wdfb_published_on_fb', true);
     if ($is_published) {
         echo '<div style="margin: 5px 0 15px; background-color: #FFFFE0; border-color: #E6DB55; border-radius: 3px 3px 3px 3px; border-style: solid; border-width: 1px; padding: 0 0.6em;">' . '<p>' . __("This post has already been published on Facebook", 'wdfb') . '</p>' . '</div>';
     }
     $stored = get_post_meta($post->ID, 'wdfb_scheduled_publish', true);
     $stored = is_array($stored) ? $stored : array();
     $title = !empty($stored['wdfb_metabox_publishing_title']) ? $stored['wdfb_metabox_publishing_title'] : '';
     $stored_publish = !empty($stored['wdfb_metabox_publishing_publish']);
     $stored_publishing_user = !empty($stored['wdfb_metabox_publishing_account']) ? $stored['wdfb_metabox_publishing_account'] : '';
     echo '<div>';
     echo '<label for="">' . __('Publish on Facebook with different title:', 'wdfb') . '</label>';
     echo '<input type="text" class="widefat" name="wdfb_metabox_publishing_title" id="wdfb_metabox_publishing_title" value="' . esc_attr($title) . '" />';
     echo __('<p><small>Leave this value blank to use the post title.</small></p>', 'wdfb');
     echo '</div>';
     if (!@$opt['allow_autopost']) {
         echo '<div>';
         echo '	<input type="checkbox" name="wdfb_metabox_publishing_publish" id="wdfb_metabox_publishing_publish" value="1" ' . checked($stored_publish, true, false) . ' />';
         echo '	<label for="wdfb_metabox_publishing_publish">' . __('I want to publish this post to Facebook', 'wdfb') . '</label>';
         echo __('<p><small>If checked, the post will be unconditionally published on Facebook</small></p>', 'wdfb');
         echo '</div>';
         echo '<div class="wdfb_perms_not_granted" style="display:none">' . '<div class="error below-h2">' . '<p>' . __("Your app doesn't have enough permissions to publish on Facebook", 'wdfb') . '<br />' . '<a class="wdfb_grant_perms" href="#" data-wdfb_perms="' . Wdfb_Permissions::get_publisher_permissions() . '" data-wdfb_locale="' . wdfb_get_locale() . '" >' . __('Grant needed permissions now', 'wdfb') . '</a>' . '</p>' . '</div>' . '</div>';
         $user = wp_get_current_user();
         $fb_accounts = $this->_get_api_accounts($user->ID);
         /*
         $fb_accounts = get_user_meta($user->ID, 'wdfb_api_accounts', true);
         $fb_accounts = isset($fb_accounts['auth_accounts']) ? $fb_accounts['auth_accounts'] : array();
         */
         if ($fb_accounts) {
             echo '<div>';
             echo '	<label for="wdfb_metabox_publishing_account">' . __('Publish to wall of this Facebook account:', 'wdfb') . '</label>';
             echo '	<select name="wdfb_metabox_publishing_account" id="wdfb_metabox_publishing_account">';
             foreach ($fb_accounts as $aid => $aval) {
                 $selected = selected($stored_publishing_user, $aid, false);
                 echo "<option value='{$aid}' {$selected}>{$aval}</option>";
             }
             echo '	</select>';
             echo '<br />';
             echo '<label for="post_as_page">' . __("If posting to a page, post <b>AS</b> page", "wdfb") . '</label> ' . '<input type="checkbox" name="wdfb_post_as_page" id="post_as_page" value="1" />';
             echo '</div>';
             echo '<p class="wdfb_perms_not_granted"><small>' . __('Please make sure that you granted extended permissions to your Facebook App', 'wdfb') . '</small></p>';
         }
     }
     echo '<script type="text/javascript" src="' . WDFB_PLUGIN_URL . '/js/check_permissions.js"></script>';
 }