Widget_LoginLogout

Sidebar LoginLogout widget with Facebook Connect button.

Defined (1)

The class is defined in the following location(s).

/Widget.php  
  1. class Widget_LoginLogout extends WP_Widget 
  2. ////////////////////////////////////////////////////// 
  3. //Init the Widget 
  4. public function __construct() 
  5. {  
  6. parent::__construct( false, "WP-FB AutoConnect Basic", array( 'description' => __('A Login/Logout widget with Facebook Connect button', 'wp-fb-autoconnect') ) ); 
  7.  
  8. ////////////////////////////////////////////////////// 
  9. //Output the widget's content. 
  10. function widget( $args, $instance ) 
  11. //Get args and output the title 
  12. extract( $args ); 
  13. echo $before_widget; 
  14. $title = apply_filters('widget_title', $instance['title']); 
  15. if( $title ) echo $before_title . $title . $after_title; 
  16.  
  17. //If logged in, show "Welcome, User!" 
  18. if( is_user_logged_in() ): 
  19. ?> 
  20. <div style='text-align:center'> 
  21. <?php  
  22. $userdata = wp_get_current_user(); 
  23. _e('Welcome', 'wp-fb-autoconnect') . ', ' . $userdata->display_name; 
  24. ?>!<br /> 
  25. <small> 
  26. <a href="<?php echo get_option('siteurl')?>/wp-admin/profile.php"><?php _e("Edit Profile", 'wp-fb-autoconnect')?></a> | <a href=" <?php echo wp_logout_url( $_SERVER['REQUEST_URI'] )?>"><?php _e("Logout", 'wp-fb-autoconnect')?></a> 
  27. </small> 
  28. </div> 
  29. <?php 
  30. //Otherwise, show the login form (with Facebook Connect button) 
  31. else: 
  32. ?> 
  33. <form name='loginform' id='loginform' action='<?php echo wp_login_url(); ?>' method='post'> 
  34. <label><?php _e("User", 'wp-fb-autoconnect')?>:</label><br /> 
  35. <input type='text' name='log' id='user_login' class='input' tabindex='20' /><input type='submit' name='wp-submit' id='wp-submit' value='<?php _e("Login", 'wp-fb-autoconnect')?>' tabindex='23' /><br /> 
  36. <label><?php _e("Pass", 'wp-fb-autoconnect')?>:</label><br /> 
  37. <input type='password' name='pwd' id='user_pass' class='input' tabindex='21' /> 
  38. <span id="forgotText"><a href="<?php echo wp_lostpassword_url()?>" rel="nofollow" ><?php _e('Forgot', 'wp-fb-autoconnect')?>?</a></span><br /> 
  39. <?php //echo "<input name='rememberme' type='hidden' id='rememberme' value='forever' />";?> 
  40. <?php echo wp_register('', ''); ?> 
  41. <input type='hidden' name='redirect_to' value='<?php echo htmlspecialchars($_SERVER['REQUEST_URI'])?>' /> 
  42. </form> 
  43. <?php 
  44. global $opt_jfb_hide_button; 
  45. if( !get_option($opt_jfb_hide_button) ) 
  46. jfb_output_facebook_btn(); 
  47. //jfb_output_facebook_init(); This is output in wp_footer as of 1.5.4 
  48. //jfb_output_facebook_callback(); This is output in wp_footer as of 1.9.0 
  49. endif; 
  50. echo $after_widget; 
  51.  
  52.  
  53. ////////////////////////////////////////////////////// 
  54. //Update the widget settings 
  55. function update( $new_instance, $old_instance ) 
  56. $instance = $old_instance; 
  57. $instance['title'] = $new_instance['title']; 
  58. return $instance; 
  59.  
  60. //////////////////////////////////////////////////// 
  61. //Display the widget settings on the widgets admin panel 
  62. function form( $instance ) 
  63. ?> 
  64. <p> 
  65. <b><?php _e('Title', 'wp-fb-autoconnect')?>:</b> 
  66. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo isset($instance['title'])?$instance['title']:""; ?>" /> 
  67. </p> 
  68.  
  69. <?php 
  70. //If the Premium addon isn't installed, show a teaser of the premium widget options. 
  71. if(!defined('JFB_PREMIUM')): 
  72.  
  73. global $jfb_homepage; 
  74. echo "<hr/><i><small>". 
  75. __("The following options are available to Premium users only.", "wp-fb-autoconnect") . 
  76. " ". 
  77. __("For information about the WP-FB-AutoConnect Premium Add-On, including purchasing instructions, please visit the plugin homepage:", "wp-fb-autoconnect") .  
  78. " <a target='preminfo' href=\"$jfb_homepage#premium\">here</a>." . 
  79. "</small></i><br/><br/>"; 
  80. ?> 
  81. <p> 
  82. <b><?php _e('Labels', 'wp-fb-autoconnect'); ?>:</b><br /> 
  83. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelUserName'); ?>" name="<?php echo $this->get_field_name('labelUserName'); ?>" type="text" <?php $this->eValue($instance, 'labelUserName'); ?> /> <small><?php _e('User', 'wp-fb-autoconnect')?>:</small><br /> 
  84. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelPass'); ?>" name="<?php echo $this->get_field_name('labelPass'); ?>" type="text" <?php $this->eValue($instance, 'labelPass'); ?> /> <small><?php _e('Pass', 'wp-fb-autoconnect')?>:</small><br /> 
  85. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelBtn'); ?>" name="<?php echo $this->get_field_name('labelBtn'); ?>" type="text" <?php $this->eValue($instance, 'labelBtn'); ?> /> <small><?php _e('Login', 'wp-fb-autoconnect')?></small> 
  86. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelRemember'); ?>" name="<?php echo $this->get_field_name('labelRemember'); ?>" type="text" <?php $this->eValue($instance, 'labelRemember'); ?> /> <small><?php _e('Remember', 'wp-fb-autoconnect')?></small> 
  87. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelForgot'); ?>" name="<?php echo $this->get_field_name('labelForgot'); ?>" type="text" <?php $this->eValue($instance, 'labelForgot'); ?> /> <small><?php _e('Forgot', 'wp-fb-autoconnect')?>?</small> 
  88. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelLogout'); ?>" name="<?php echo $this->get_field_name('labelLogout'); ?>" type="text" <?php $this->eValue($instance, 'labelLogout'); ?> /> <small><?php _e('Logout', 'wp-fb-autoconnect')?></small> 
  89. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelProfile'); ?>" name="<?php echo $this->get_field_name('labelProfile'); ?>" type="text" <?php $this->eValue($instance, 'labelProfile'); ?> /> <small><?php _e('Edit Profile', 'wp-fb-autoconnect')?></small> 
  90. <input <?php $this->disableatt() ?> style="width:50%;" id="<?php echo $this->get_field_id('labelWelcome'); ?>" name="<?php echo $this->get_field_name('labelWelcome'); ?>" type="text" <?php $this->eValue($instance, 'labelWelcome'); ?> /> <small><?php _e('Welcome', 'wp-fb-autoconnect')?>, </small> 
  91. </p> 
  92. <p> 
  93. <b><?php _e('Other', 'wp-fb-autoconnect')?>:</b><br /> 
  94. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'showwplogin'); ?> id="<?php echo $this->get_field_id( 'showwplogin' ); ?>" name="<?php echo $this->get_field_name( 'showwplogin' ); ?>" /> 
  95. <label for="<?php echo $this->get_field_id( 'showwplogin' ); ?>"><?php _e('Show WP User/Pass Login', 'wp-fb-autoconnect')?></label><br /> 
  96. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'showrememberme' ); ?> id="<?php echo $this->get_field_id( 'showrememberme' ); ?>" name="<?php echo $this->get_field_name( 'showrememberme' ); ?>" /> 
  97. <label for="<?php echo $this->get_field_id( 'showrememberme' ); ?>"><?php _e("Show 'Remember'", 'wp-fb-autoconnect')?></label><br /> 
  98. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'showregister'); ?> id="<?php echo $this->get_field_id( 'showregister' ); ?>" name="<?php echo $this->get_field_name( 'showregister' ); ?>" /> 
  99. <label for="<?php echo $this->get_field_id( 'showregister' ); ?>"><?php _e("Show 'Register'", 'wp-fb-autoconnect')?></label><br /> 
  100. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'showforgot' ); ?> id="<?php echo $this->get_field_id( 'showforgot' ); ?>" name="<?php echo $this->get_field_name( 'showforgot' ); ?>" /> 
  101. <label for="<?php echo $this->get_field_id( 'showforgot' ); ?>"><?php _e("Show 'Forgot?'", 'wp-fb-autoconnect')?></label><br /> 
  102. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'showEditProfile' ); ?> id="<?php echo $this->get_field_id( 'showEditProfile' ); ?>" name="<?php echo $this->get_field_name( 'showEditProfile' ); ?>" /> 
  103. <label for="<?php echo $this->get_field_id( 'showEditProfile' ); ?>"><?php _e("Show 'Edit Profile'", 'wp-fb-autoconnect')?></label><br /> 
  104. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'logoutofFB' ); ?> id="<?php echo $this->get_field_id( 'logoutofFB' ); ?>" name="<?php echo $this->get_field_name( 'logoutofFB' ); ?>" /> 
  105. <label for="<?php echo $this->get_field_id( 'logoutofFB' ); ?>"><?php echo __('Prompt') . ' \'' . __('Logout of Facebook too?', 'wp-fb-autoconnect') . "'";?></label><br /> 
  106. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'bpProfileLink' ); ?> id="<?php echo $this->get_field_id( 'bpProfileLink' ); ?>" name="<?php echo $this->get_field_name( 'bpProfileLink' ); ?>" /> 
  107. <label for="<?php echo $this->get_field_id( 'bpProfileLink' ); ?>"><?php _e("Edit profile links to BP (if available)", 'wp-fb-autoconnect')?></label><br /> 
  108. <input <?php $this->disableatt() ?> class="checkbox" type="checkbox" <?php $this->eChecked( $instance, 'showavatar' ); ?> id="<?php echo $this->get_field_id( 'showavatar' ); ?>" name="<?php echo $this->get_field_name( 'showavatar' ); ?>" /> 
  109. <label for="<?php echo $this->get_field_id( 'showavatar' ); ?>"><?php _e("Show Avatar (when logged in)", 'wp-fb-autoconnect')?></label><br /> 
  110. <?php _e('Avatar Size', 'wp-fb-autoconnect')?>: <input <?php $this->disableatt() ?> style="width:35px" id="<?php echo $this->get_field_id('avatarsize'); ?>" name="<?php echo $this->get_field_name('avatarsize'); ?>" type="text" <?php $this->eValue($instance, 'avatarsize'); ?> />px<br/> 
  111. <?php _e('Forgot Pass URL', 'wp-fb-autoconnect')?>:<br/> 
  112. <input <?php $this->disableatt() ?> style="width:100%" id="<?php echo $this->get_field_id('forgotURL'); ?>" name="<?php echo $this->get_field_name('forgotURL'); ?>" type="text" <?php $this->eValue($instance, 'forgotURL'); ?> /> 
  113. </p> 
  114. <?php 
  115. endif; //Premium teaser 
  116.  
  117. /** 
  118. * Helpers for outputting a 'teaser' premium widget in the free plugin. 
  119. */ 
  120. function eValue($instance, $index) { echo "value=\"" . (isset($instance[$index])?$instance[$index]:'') . "\" "; } 
  121. function eChecked($instance, $index) { isset($instance[$index])?checked( $instance[$index], true ):checked(false, true);} 
  122. function disableatt() { echo (get_class($this) == "Widget_AutoConnect_Premium"?"":"disabled='disabled'"); }