/**
  * Main entry point.
  *
  * @static
  */
 public static function serve()
 {
     $me = new Wdfb_AdminPages();
     $me->data = Wdfb_OptionsRegistry::get_instance();
     $me->model = new Wdfb_Model();
     $me->add_hooks();
 }
 public static function get_instance()
 {
     if (self::$_instance) {
         return self::$_instance;
     }
     self::$_instance = new Wdfb_OptionsRegistry();
     return self::$_instance;
 }
    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 form($instance)
 {
     $title = esc_attr(@$instance['title']);
     $limit = esc_attr(@$instance['limit']);
     $avatar_size = esc_attr(@$instance['avatar_size']);
     $hide_text = esc_attr(@$instance['hide_text']);
     // Set defaults
     // ...
     $html = '';
     $limit = $limit ? $limit : 5;
     // Sanity check
     $data =& Wdfb_OptionsRegistry::get_instance();
     if (!$data->get_option('wdfb_comments', 'import_fb_comments')) {
         $html .= '<div class="error below-h2"><p>' . __('Your comments are currently not being imported from Facebook. This will make the widget show stale data, if any.', 'wdfb') . '</p></div>';
     }
     $html .= '<p>';
     $html .= '<label for="' . $this->get_field_id('title') . '">' . __('Title:', 'wdfb') . '</label>';
     $html .= '<input type="text" name="' . $this->get_field_name('title') . '" id="' . $this->get_field_id('title') . '" class="widefat" value="' . $title . '"/>';
     $html .= '</p>';
     $html .= '<p>';
     $html .= '<label for="' . $this->get_field_id('limit') . '">' . __('Display only this many comments:', 'wdfb') . '</label>';
     $html .= '<select name="' . $this->get_field_name('limit') . '" id="' . $this->get_field_id('limit') . '">';
     for ($i = 1; $i < 21; $i++) {
         $html .= '<option value="' . $i . '" ' . ($limit == $i ? 'selected="selected"' : '') . '>' . $i . '</option>';
     }
     $html .= '</select>';
     $html .= '</p>';
     $html .= '<p>';
     $html .= '<label for="' . $this->get_field_id('avatar_size') . '">' . __('Avatar size:', 'wdfb') . '</label>';
     $html .= '<select name="' . $this->get_field_name('avatar_size') . '" id="' . $this->get_field_id('avatar_size') . '">';
     for ($i = 15; $i < 125; $i += 5) {
         $html .= '<option value="' . $i . '" ' . ($avatar_size == $i ? 'selected="selected"' : '') . '>' . $i . '</option>';
     }
     $html .= '</select>px';
     $html .= '<br />';
     $checked = !$avatar_size ? 'checked="checked"' : '';
     $html .= '<input type="checkbox" ' . $checked . ' name="' . $this->get_field_name('avatar_size') . '" id="' . $this->get_field_id('avatar_show') . '" value="0" /> ';
     $html .= '<label for="' . $this->get_field_id('avatar_show') . '">' . __('Do not show avatars', 'wdfb') . '</label>';
     $html .= '</p>';
     $html .= '<p>';
     $checked = $hide_text ? 'checked="checked"' : '';
     $html .= '<input type="checkbox" ' . $checked . ' name="' . $this->get_field_name('hide_text') . '" id="' . $this->get_field_id('hide_text') . '" value="1" />';
     $html .= '&nbsp;<label for="' . $this->get_field_id('hide_text') . '">' . __("Do not show comment text", 'wdfb') . '</label>';
     $html .= '</p>';
     echo $html;
 }
 function __construct()
 {
     global $wpdb;
     $this->data = Wdfb_OptionsRegistry::get_instance();
     $this->db = $wpdb;
     if (isset(Facebook::$CURL_OPTS)) {
         Facebook::$CURL_OPTS = apply_filters('wdfb-fb_core-facebook_curl_options', Facebook::$CURL_OPTS);
         if (!(defined('WDFB_FACEBOOK_SSL_CERTIFICATE') && WDFB_FACEBOOK_SSL_CERTIFICATE)) {
             Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 0;
             Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = 0;
         }
     }
     $this->fb = new Facebook(array('appId' => trim($this->data->get_option('wdfb_api', 'app_key')), 'secret' => trim($this->data->get_option('wdfb_api', 'secret_key')), 'cookie' => true));
     $this->fb->getLoginUrl();
     // Generate the CSRF sig stuff yay
     $this->log = new Wdfb_ErrorLog();
     $this->_batch_page_size = apply_filters('wdfb-fb_core-batch_request-page_size', defined('WDFB_BATCH_REQUEST_PAGE_SIZE') && WDFB_BATCH_REQUEST_PAGE_SIZE ? WDFB_BATCH_REQUEST_PAGE_SIZE : 25);
 }
 public static function get_new_user_permissions()
 {
     $data = Wdfb_OptionsRegistry::get_instance();
     $extra_fields = array('gender', 'hometown', 'relationship_status', 'significant_other', 'political', 'religion', 'favorite_teams', 'quotes');
     $import = false;
     if (!defined('BP_VERSION') && $data->get_option('wdfb_connect', 'wordpress_registration_fields')) {
         $wp_fields = $data->get_option('wdfb_connect', 'wordpress_registration_fields');
         if (is_array($wp_fields)) {
             foreach ($wp_fields as $map) {
                 if (!isset($map['fb'])) {
                     continue;
                 }
                 if (!in_array($map['fb'], $extra_fields)) {
                     continue;
                 }
                 $import = true;
                 break;
             }
         }
     } else {
         if (defined('BP_VERSION')) {
             $model = new Wdfb_Model();
             $fields = $model->get_bp_xprofile_fields();
             if (is_array($fields)) {
                 foreach ($fields as $field) {
                     $fb_value = $data->get_option('wdfb_connect', 'buddypress_registration_fields_' . $field['id']);
                     if (!in_array($fb_value, $extra_fields)) {
                         continue;
                     }
                     $import = true;
                     break;
                 }
             }
         }
     }
     $perms = $import ? rtrim(join(',', array(self::EXTRAS, self::NEW_USER)), ',') : rtrim(self::NEW_USER, ',');
     return apply_filters('wdfb-permissions-new_user', $perms);
 }
<?php

get_header();
?>

<?php 
$redirect_url = is_multisite() ? site_url('/wp-signup.php?action=register&fb_register=1') : site_url('/wp-login.php?action=register&fb_register=1');
$redirect_url = apply_filters('wdfb_registration_redirect_url', $redirect_url);
$opts = Wdfb_OptionsRegistry::get_instance();
$force = $opts->get_option('wdfb_connect', 'force_facebook_registration') && $opts->get_option('wdfb_connect', 'require_facebook_account') ? 'fb_only=true&' : '';
?>

	<h2><?php 
_e('Register with Facebook', 'wdfb');
?>
</h2>

<?php 
foreach ($errors as $error) {
    ?>
	<?php 
    $error = is_array($error) ? array_reduce($error, create_function('$val,$el', 'return "$val <br />$el";')) : $error;
    ?>
	<div class="error fade"><p><?php 
    echo $error;
    ?>
</p></div>
<?php 
}
?>
/**
 * Schedule cron jobs for comments import.
 */
function wdfb_comment_import()
{
    $data =& Wdfb_OptionsRegistry::get_instance();
    if (!$data->get_option('wdfb_comments', 'import_fb_comments')) {
        return;
    }
    // Don't import comments
    Wdfb_CommentsImporter::serve();
}
 function __construct()
 {
     $this->data = Wdfb_OptionsRegistry::get_instance();
     $this->model = new Wdfb_Model();
     $this->replacer = new Wdfb_MarkerReplacer();
 }
 function __construct()
 {
     $this->data = Wdfb_OptionsRegistry::get_instance();
 }
 function create_import_fb_comments_skip_box()
 {
     $opt = $this->_get_option('wdfb_comments');
     $skips = @$opt['skip_import'];
     $skips = is_array($skips) ? $skips : array();
     $reverse = @$opt['reverse_skip_logic'];
     $data = Wdfb_OptionsRegistry::get_instance();
     $accounts = $data->get_option('wdfb_api', 'auth_tokens');
     if (is_array($accounts)) {
         echo '<div id="wdfb-comments-skip_accounts">';
         foreach ($accounts as $fb_uid => $token) {
             if (!$fb_uid) {
                 continue;
             }
             $checked = in_array($fb_uid, $skips) ? true : false;
             echo $this->_create_subcheckbox('comments', 'skip_import', $fb_uid, $checked) . " <label for='skip_import-{$fb_uid}'><span class='wdfb_uid_to_name_mapper'>{$fb_uid}</span></label><br />";
         }
         echo '<div><small>' . ($reverse ? __('Comments on your posts on Facebook will <b>ONLY</b> be imported for the checked IDs.', 'wdfb') : __('Comments on your posts on Facebook will <b>NOT</b> be imported for any of the checked IDs.', 'wdfb')) . '</small></div>';
         echo '<br />' . '<label for="reverse_skip_logic">' . __('Reverse checking logic:', 'wdfb') . '</label>' . '&nbsp;' . $this->_create_checkbox('comments', 'reverse_skip_logic', $reverse) . '';
         echo '<div><small>' . __('Togglig this option will reverse import skipping options.', 'wdfb') . '</small></div>';
         echo '</div>';
     }
 }
 function wdfb_wp_core__trump_discussion_settings()
 {
     $data = Wdfb_OptionsRegistry::get_instance();
     if ($data->get_option('wdfb_comments', 'override_wp_comments_settings')) {
         add_filter('comments_open', '__return_false');
     }
 }
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $width = (int) $instance['width'];
     $width = $width ? $width : 300;
     $height = (int) $instance['height'];
     $height = $height ? $height : 300;
     $url = $instance['url'];
     $url = $url ? $url : parse_url(site_url(), PHP_URL_HOST);
     $show_header = (int) @$instance['show_header'];
     $show_header = $show_header ? 'true' : 'false';
     $recommendations = (int) @$instance['recommendations'];
     $recommendations = $recommendations ? 'true' : 'false';
     $filter = @$instance['filter'];
     $color_scheme = $instance['color_scheme'];
     $color_scheme = $color_scheme ? $color_scheme : 'light';
     $links = $instance['links'];
     $links = $links ? $links : '_blank';
     $iframe = (int) $instance['iframe'];
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if (!$iframe) {
         echo wdfb_get_fb_plugin_markup('activity', compact(array('url', 'width', 'height', 'recommendations', 'links', 'color_scheme')));
     } else {
         $data = Wdfb_OptionsRegistry::get_instance();
         $key = $data->get_option('wdfb_api', 'app_key');
         $locale = wdfb_get_locale();
         echo "<iframe src='//www.facebook.com/plugins/activity.php?api_key={$key}&amp;app_id={$key}&amp;site={$url}&amp;width={$width}&amp;height={$height}&amp;header={$show_header}&amp;colorscheme={$color_scheme}&amp;linktarget={$links}&amp;locale={$locale}&amp;border_color&amp;font&amp;recommendations={$recommendations}&amp;appId={$key}' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:{$width}px; height:{$height}px;' allowTransparency='true'></iframe>";
     }
     echo $after_widget;
 }