[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/classes/ -> class-bp-core-login-widget.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Core Login Widget.
   4   *
   5   * @package BuddyPress
   6   * @subpackage Core
   7   * @since 1.9.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * BuddyPress Login Widget.
  15   *
  16   * @since 1.9.0
  17   */
  18  class BP_Core_Login_Widget extends WP_Widget {
  19  
  20      /**
  21       * Constructor method.
  22       *
  23       * @since 1.9.0
  24       */
  25  	public function __construct() {
  26          parent::__construct(
  27              false,
  28              _x( '(BuddyPress) Log In', 'Title of the login widget', 'buddypress' ),
  29              array(
  30                  'description'                 => __( 'Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in.', 'buddypress' ),
  31                  'classname'                   => 'widget_bp_core_login_widget buddypress widget',
  32                  'customize_selective_refresh' => true,
  33              )
  34          );
  35      }
  36  
  37      /**
  38       * Display the login widget.
  39       *
  40       * @since 1.9.0
  41       *
  42       * @see WP_Widget::widget() for description of parameters.
  43       *
  44       * @param array $args     Widget arguments.
  45       * @param array $instance Widget settings, as saved by the user.
  46       */
  47  	public function widget( $args, $instance ) {
  48          $title = isset( $instance['title'] ) ? $instance['title'] : '';
  49  
  50          /**
  51           * Filters the title of the Login widget.
  52           *
  53           * @since 1.9.0
  54           * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
  55           *
  56           * @param string $title    The widget title.
  57           * @param array  $instance The settings for the particular instance of the widget.
  58           * @param string $id_base  Root ID for all widgets of this type.
  59           */
  60          $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
  61  
  62          echo $args['before_widget'];
  63  
  64          echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?>
  65  
  66          <?php if ( is_user_logged_in() ) : ?>
  67  
  68              <?php
  69              /**
  70               * Fires before the display of widget content if logged in.
  71               *
  72               * @since 1.9.0
  73               */
  74              do_action( 'bp_before_login_widget_loggedin' ); ?>
  75  
  76              <div class="bp-login-widget-user-avatar">
  77                  <a href="<?php echo bp_loggedin_user_domain(); ?>">
  78                      <?php bp_loggedin_user_avatar( 'type=thumb&width=50&height=50' ); ?>
  79                  </a>
  80              </div>
  81  
  82              <div class="bp-login-widget-user-links">
  83                  <div class="bp-login-widget-user-link"><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></div>
  84                  <div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
  85              </div>
  86  
  87              <?php
  88  
  89              /**
  90               * Fires after the display of widget content if logged in.
  91               *
  92               * @since 1.9.0
  93               */
  94              do_action( 'bp_after_login_widget_loggedin' ); ?>
  95  
  96          <?php else : ?>
  97  
  98              <?php
  99  
 100              /**
 101               * Fires before the display of widget content if logged out.
 102               *
 103               * @since 1.9.0
 104               */
 105              do_action( 'bp_before_login_widget_loggedout' ); ?>
 106  
 107              <form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
 108                  <label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
 109                  <input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
 110  
 111                  <label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
 112                  <input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" <?php bp_form_field_attributes( 'password' ) ?> />
 113  
 114                  <div class="forgetmenot"><label for="bp-login-widget-rememberme"><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
 115  
 116                  <input type="submit" name="wp-submit" id="bp-login-widget-submit" value="<?php esc_attr_e( 'Log In', 'buddypress' ); ?>" />
 117  
 118                  <?php if ( bp_get_signup_allowed() ) : ?>
 119  
 120                      <span class="bp-login-widget-register-link"><a href="<?php echo esc_url( bp_get_signup_page() ); ?>"><?php _e( 'Register', 'buddypress' ); ?></a></span>
 121  
 122                  <?php endif; ?>
 123  
 124                  <?php
 125  
 126                  /**
 127                   * Fires inside the display of the login widget form.
 128                   *
 129                   * @since 2.4.0
 130                   */
 131                  do_action( 'bp_login_widget_form' ); ?>
 132  
 133              </form>
 134  
 135              <?php
 136  
 137              /**
 138               * Fires after the display of widget content if logged out.
 139               *
 140               * @since 1.9.0
 141               */
 142              do_action( 'bp_after_login_widget_loggedout' ); ?>
 143  
 144          <?php endif;
 145  
 146          echo $args['after_widget'];
 147      }
 148  
 149      /**
 150       * Update the login widget options.
 151       *
 152       * @since 1.9.0
 153       *
 154       * @param array $new_instance The new instance options.
 155       * @param array $old_instance The old instance options.
 156       * @return array $instance The parsed options to be saved.
 157       */
 158  	public function update( $new_instance, $old_instance ) {
 159          $instance             = $old_instance;
 160          $instance['title']    = isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
 161  
 162          return $instance;
 163      }
 164  
 165      /**
 166       * Output the login widget options form.
 167       *
 168       * @since 1.9.0
 169       *
 170       * @param array $instance Settings for this widget.
 171       * @return void
 172       */
 173  	public function form( $instance = array() ) {
 174  
 175          $settings = wp_parse_args( $instance, array(
 176              'title' => '',
 177          ) ); ?>
 178  
 179          <p>
 180              <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?>
 181              <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>" /></label>
 182          </p>
 183  
 184          <?php
 185      }
 186  }


Generated: Mon Dec 9 01:01:38 2019 Cross-referenced by PHPXref 0.7.1