Changeset 2396264
- Timestamp:
- 10/08/2020 07:33:33 PM (4 years ago)
- Location:
- sidebar-login
- Files:
-
- 49 added
- 14 deleted
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sidebar-login/assets/banner-772x250.png
-
Property
svn:mime-type
changed from
application/octet-stream
toimage/png
-
Property
svn:mime-type
changed from
-
sidebar-login/assets/screenshot-1.png
-
Property
svn:mime-type
changed from
application/octet-stream
toimage/png
-
Property
svn:mime-type
changed from
-
sidebar-login/assets/screenshot-2.png
-
Property
svn:mime-type
changed from
application/octet-stream
toimage/png
-
Property
svn:mime-type
changed from
-
sidebar-login/assets/screenshot-3.png
-
Property
svn:mime-type
changed from
application/octet-stream
toimage/png
-
Property
svn:mime-type
changed from
-
sidebar-login/tags/3.0.0.beta/readme.txt
r1384463 r2396264 2 2 Contributors: mikejolley 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mike.jolley@me.com¤cy_code=&amount=&return=&item_name=Donation+for+Sidebar+Login 4 Tags: login, sidebar, widget, sidebar login, meta, form, register 5 Requires at least: 3.5 6 Tested up to: 4.5 4 Tags: login, sidebar, widget, sidebar login, login widget, login form 5 Requires at least: 5.0 6 Tested up to: 5.5 7 Requires PHP: 5.6 7 8 Stable tag: 2.7.3 8 9 License: GPLv3 … … 13 14 == Description == 14 15 15 Sidebar-Loginadds a useful login widget which you can use to login from in the sidebar of your WordPress powered blog.16 17 Once a user logs in it then redirects them back to the page they logged in fromrather than the admin panel (this is configurable).16 adds a useful login widget which you can use to login from in the sidebar of your WordPress powered blog. 17 18 Once a user logs in rather than the admin panel (this is configurable). 18 19 19 20 If you'd like to contribute code to the plugin you can do so via [GitHub](https://github.com/mikejolley/sidebar-login). … … 36 37 * `%lastname%` - logged in users lastname 37 38 * `%name%` - logged in users firstname + lastname 39 38 40 * `%admin_url%` - url to WP admin 39 41 * `%logout_url%` - logout url … … 44 46 = Filter Reference = 45 47 46 * `sidebar_login_js_in_footer` - return true to show JS file in the footer instead of the header47 48 * `sidebar_login_include_css` - return false to not include the CSS stylesheet 48 49 * `sidebar_login_widget_logged_in_links` - An array of links shown when logged in. … … 80 81 == Changelog == 81 82 83 84 85 86 87 88 89 90 91 92 82 93 = 2.7.3 = 83 94 * Tweak - %avatar% placeholder. -
sidebar-login/tags/3.0.0.beta/sidebar-login.php
r1384463 r2396264 1 1 <?php 2 /* 3 Plugin Name: Sidebar Login 4 Plugin URI: http://wordpress.org/extend/plugins/sidebar-login/ 5 Description: Allows you to easily add an ajax-enhanced login widget to the sidebar on your WordPress site. 6 Version: 2.7.3 7 Author: Mike Jolley 8 Author URI: http://mikejolley.com 9 Requires at least: 3.5 10 Tested up to: 4.5 11 Text Domain: sidebar-login 12 Domain Path: /languages/ 2 /** 3 * Sidebar Login 4 * 5 * @package SidebarLogin 6 * @author Mike Jolley 7 * @copyright 2020 Mike Jolley 8 * @license GPL-3.0-or-later 9 * 10 * @wordpress-plugin 11 * Plugin Name: Sidebar Login 12 * Plugin URI: http://wordpress.org/extend/plugins/sidebar-login/ 13 * Description: Easily add an ajax-enhanced login widget to the sidebar of your WordPress site. 14 * Version: 3.0.0.beta 15 * Author: Mike Jolley 16 * Author URI: http://mikejolley.com 17 * Requires at least: 5.0 18 * Tested up to: 5.5 19 * Requires PHP: 5.6 20 * Text Domain: sidebar-login 21 * Domain Path: /languages/ 22 */ 13 23 14 Copyright: 2015 Mike Jolley. 15 License: GNU General Public License v3.0 16 License URI: http://www.gnu.org/licenses/gpl-3.0.html 17 */ 24 defined( 'ABSPATH' ) || exit; 18 25 19 26 /** 20 * Sidebar_Login class.27 * . 21 28 */ 22 class Sidebar_Login { 29 if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { 30 return; 31 } 23 32 24 private $version = '2.7.3'; 33 /** 34 * Require Autoloader, and ensure build is complete. Otherwise abort. 35 */ 36 $autoloader = __DIR__ . '/vendor/autoload.php'; 37 $build = __DIR__ . '/build/frontend.js'; 38 if ( is_readable( $autoloader ) && is_readable( $build ) ) { 39 require $autoloader; 40 } else { 41 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 42 error_log( // phpcs:ignore 43 sprintf( 44 /* translators: 1: composer command. 2: plugin directory */ 45 esc_html__( 'Your installation of Sidebar Login is incomplete. Please run %1$s within the %2$s directory, or download the built plugin files from wordpress.org.', 'sidebar-login' ), 46 '`composer install && && npm install && npm run build`', 47 '`' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '`' 48 ) 49 ); 50 } 51 /** 52 * Outputs an admin notice if composer install has not been ran. 53 */ 54 add_action( 55 'admin_notices', 56 function() { 57 ?> 58 <div class="notice notice-error"> 59 <p> 60 <?php 61 printf( 62 /* translators: 1: composer command. 2: plugin directory */ 63 esc_html__( 'Your installation of Sidebar Login is incomplete. Please run %1$s within the %2$s directory, or download the built plugin files from wordpress.org.', 'sidebar-login' ), 64 '<code>composer install && && npm install && npm run build</code>', 65 '<code>' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '</code>' 66 ); 67 ?> 68 </p> 69 </div> 70 <?php 71 } 72 ); 73 return; 74 } 25 75 26 /** 27 * __construct function. 28 * 29 * @access public 30 * @return void 31 */ 32 public function __construct() { 33 // Hook-in 34 add_action( 'plugins_loaded', array( $this, 'i18n' ) ); 35 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) ); 36 add_action( 'widgets_init', array( $this, 'register_widget' ) ); 37 add_action( 'wp_authenticate', array( $this, 'convert_email_to_username' ), 10, 2 ); 76 /** 77 * Fetch instance of plugin. 78 * 79 * @return \MJ\SidebarLogin\Plugin 80 */ 81 function sidebar_login_init() { 82 static $instance; 38 83 39 // Ajax events 40 add_action( 'wp_ajax_sidebar_login_process', array( $this, 'ajax_handler' ) ); 41 add_action( 'wp_ajax_nopriv_sidebar_login_process', array( $this, 'ajax_handler' ) ); 84 if ( is_null( $instance ) ) { 85 $instance = new \MJ\SidebarLogin\Plugin( __FILE__ ); 42 86 } 43 87 44 /** 45 * i18n function. 46 * 47 * @access public 48 * @return void 49 */ 50 public function i18n() { 51 load_plugin_textdomain( 'sidebar-login', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 52 } 53 54 /** 55 * enqueue function. 56 * 57 * @access public 58 * @return void 59 */ 60 public function enqueue() { 61 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 62 $js_in_footer = apply_filters( 'sidebar_login_js_in_footer', false ); 63 64 // Register BLOCK UI 65 wp_register_script( 'jquery-blockui', plugins_url( 'assets/js/jquery.blockUI.min.js', __FILE__ ), array( 'jquery' ), '2.70', $js_in_footer ); 66 67 // Enqueue Sidebar Login JS 68 wp_enqueue_script( 'sidebar-login', plugins_url( 'assets/js/sidebar-login' . $suffix . '.js', __FILE__ ), array( 'jquery', 'jquery-blockui' ), $this->version, $js_in_footer ); 69 70 // Enqueue Styles 71 if ( apply_filters( 'sidebar_login_include_css', true ) ) { 72 wp_enqueue_style( 'sidebar-login', plugins_url( 'assets/css/sidebar-login.css', __FILE__ ), '', $this->version ); 73 } 74 75 // Pass variables 76 $sidebar_login_params = array( 77 'ajax_url' => $this->ajax_url(), 78 'force_ssl_admin' => force_ssl_admin() ? 1 : 0, 79 'is_ssl' => is_ssl() ? 1 : 0, 80 'i18n_username_required' => __( 'Please enter your username', 'sidebar-login' ), 81 'i18n_password_required' => __( 'Please enter your password', 'sidebar-login' ), 82 'error_class' => apply_filters( 'sidebar_login_widget_error_class', 'sidebar_login_error' ) 83 ); 84 85 wp_localize_script( 'sidebar-login', 'sidebar_login_params', $sidebar_login_params ); 86 } 87 88 /** 89 * Include and register the widget class. 90 * 91 * @access public 92 * @return void 93 */ 94 public function register_widget() { 95 include_once( 'includes/class-sidebar-login-widget.php' ); 96 } 97 98 /** 99 * ajax_url function. 100 * 101 * @access public 102 * @return void 103 */ 104 private function ajax_url() { 105 if ( is_ssl() ) { 106 return str_replace( 'http:', 'https:', admin_url( 'admin-ajax.php' ) ); 107 } else { 108 return str_replace( 'https:', 'http:', admin_url( 'admin-ajax.php' ) ); 109 } 110 } 111 112 /** 113 * When posting an email, convert to a username 114 */ 115 public function convert_email_to_username( &$username, &$password ) { 116 // If the user inputs an email address instead of a username, try to convert it 117 if ( is_email( $username ) ) { 118 if ( $user = get_user_by( 'email', $username ) ) { 119 $username = $user->user_login; 120 } 121 } 122 } 123 124 /** 125 * ajax_handler function. 126 * 127 * @access public 128 * @return void 129 */ 130 public function ajax_handler() { 131 // Get post data 132 $creds = array(); 133 $creds['user_login'] = stripslashes( trim( $_POST['user_login'] ) ); 134 $creds['user_password'] = stripslashes( trim( $_POST['user_password'] ) ); 135 $creds['remember'] = isset( $_POST['remember'] ) ? sanitize_text_field( $_POST['remember'] ) : ''; 136 $redirect_to = esc_url_raw( $_POST['redirect_to'] ); 137 $secure_cookie = null; 138 139 // If the user wants ssl but the session is not ssl, force a secure cookie. 140 if ( ! force_ssl_admin() ) { 141 $user = is_email( $creds['user_login'] ) ? get_user_by( 'email', $creds['user_login'] ) : get_user_by( 'login', sanitize_user( $creds['user_login'] ) ); 142 143 if ( $user && get_user_option( 'use_ssl', $user->ID ) ) { 144 $secure_cookie = true; 145 force_ssl_admin( true ); 146 } 147 } 148 149 if ( force_ssl_admin() ) { 150 $secure_cookie = true; 151 } 152 153 if ( is_null( $secure_cookie ) && force_ssl_admin() ) { 154 $secure_cookie = false; 155 } 156 157 // Login 158 $user = wp_signon( $creds, $secure_cookie ); 159 160 // Redirect filter 161 if ( $secure_cookie && strstr( $redirect_to, 'wp-admin' ) ) { 162 $redirect_to = str_replace( 'http:', 'https:', $redirect_to ); 163 } 164 165 // Result 166 $result = array(); 167 168 if ( ! is_wp_error( $user ) ) { 169 $result['success'] = 1; 170 $result['redirect'] = $redirect_to; 171 } else { 172 $result['success'] = 0; 173 if ( $user->errors ) { 174 foreach ( $user->errors as $error ) { 175 $result['error'] = $error[0]; 176 break; 177 } 178 } else { 179 $result['error'] = __( 'Please enter your username and password to login.', 'sidebar-login' ); 180 } 181 } 182 183 echo '<!--SBL-->'; 184 echo json_encode( $result ); 185 echo '<!--SBL_END-->'; 186 187 die(); 188 } 189 88 return $instance; 190 89 } 191 90 192 new Sidebar_Login();91 ); -
sidebar-login/trunk/readme.txt
r1384463 r2396264 2 2 Contributors: mikejolley 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mike.jolley@me.com¤cy_code=&amount=&return=&item_name=Donation+for+Sidebar+Login 4 Tags: login, sidebar, widget, sidebar login, meta, form, register 5 Requires at least: 3.5 6 Tested up to: 4.5 4 Tags: login, sidebar, widget, sidebar login, login widget, login form 5 Requires at least: 5.0 6 Tested up to: 5.5 7 Requires PHP: 5.6 7 8 Stable tag: 2.7.3 8 9 License: GPLv3 … … 13 14 == Description == 14 15 15 Sidebar-Loginadds a useful login widget which you can use to login from in the sidebar of your WordPress powered blog.16 17 Once a user logs in it then redirects them back to the page they logged in fromrather than the admin panel (this is configurable).16 adds a useful login widget which you can use to login from in the sidebar of your WordPress powered blog. 17 18 Once a user logs in rather than the admin panel (this is configurable). 18 19 19 20 If you'd like to contribute code to the plugin you can do so via [GitHub](https://github.com/mikejolley/sidebar-login). … … 36 37 * `%lastname%` - logged in users lastname 37 38 * `%name%` - logged in users firstname + lastname 39 38 40 * `%admin_url%` - url to WP admin 39 41 * `%logout_url%` - logout url … … 44 46 = Filter Reference = 45 47 46 * `sidebar_login_js_in_footer` - return true to show JS file in the footer instead of the header47 48 * `sidebar_login_include_css` - return false to not include the CSS stylesheet 48 49 * `sidebar_login_widget_logged_in_links` - An array of links shown when logged in. … … 80 81 == Changelog == 81 82 83 84 85 86 87 88 89 90 91 92 82 93 = 2.7.3 = 83 94 * Tweak - %avatar% placeholder. -
sidebar-login/trunk/sidebar-login.php
r1384463 r2396264 1 1 <?php 2 /* 3 Plugin Name: Sidebar Login 4 Plugin URI: http://wordpress.org/extend/plugins/sidebar-login/ 5 Description: Allows you to easily add an ajax-enhanced login widget to the sidebar on your WordPress site. 6 Version: 2.7.3 7 Author: Mike Jolley 8 Author URI: http://mikejolley.com 9 Requires at least: 3.5 10 Tested up to: 4.5 11 Text Domain: sidebar-login 12 Domain Path: /languages/ 2 /** 3 * Sidebar Login 4 * 5 * @package SidebarLogin 6 * @author Mike Jolley 7 * @copyright 2020 Mike Jolley 8 * @license GPL-3.0-or-later 9 * 10 * @wordpress-plugin 11 * Plugin Name: Sidebar Login 12 * Plugin URI: http://wordpress.org/extend/plugins/sidebar-login/ 13 * Description: Easily add an ajax-enhanced login widget to the sidebar of your WordPress site. 14 * Version: 3.0.0.beta 15 * Author: Mike Jolley 16 * Author URI: http://mikejolley.com 17 * Requires at least: 5.0 18 * Tested up to: 5.5 19 * Requires PHP: 5.6 20 * Text Domain: sidebar-login 21 * Domain Path: /languages/ 22 */ 13 23 14 Copyright: 2015 Mike Jolley. 15 License: GNU General Public License v3.0 16 License URI: http://www.gnu.org/licenses/gpl-3.0.html 17 */ 24 defined( 'ABSPATH' ) || exit; 18 25 19 26 /** 20 * Sidebar_Login class.27 * . 21 28 */ 22 class Sidebar_Login { 29 if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { 30 return; 31 } 23 32 24 private $version = '2.7.3'; 33 /** 34 * Require Autoloader, and ensure build is complete. Otherwise abort. 35 */ 36 $autoloader = __DIR__ . '/vendor/autoload.php'; 37 $build = __DIR__ . '/build/frontend.js'; 38 if ( is_readable( $autoloader ) && is_readable( $build ) ) { 39 require $autoloader; 40 } else { 41 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 42 error_log( // phpcs:ignore 43 sprintf( 44 /* translators: 1: composer command. 2: plugin directory */ 45 esc_html__( 'Your installation of Sidebar Login is incomplete. Please run %1$s within the %2$s directory, or download the built plugin files from wordpress.org.', 'sidebar-login' ), 46 '`composer install && && npm install && npm run build`', 47 '`' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '`' 48 ) 49 ); 50 } 51 /** 52 * Outputs an admin notice if composer install has not been ran. 53 */ 54 add_action( 55 'admin_notices', 56 function() { 57 ?> 58 <div class="notice notice-error"> 59 <p> 60 <?php 61 printf( 62 /* translators: 1: composer command. 2: plugin directory */ 63 esc_html__( 'Your installation of Sidebar Login is incomplete. Please run %1$s within the %2$s directory, or download the built plugin files from wordpress.org.', 'sidebar-login' ), 64 '<code>composer install && && npm install && npm run build</code>', 65 '<code>' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '</code>' 66 ); 67 ?> 68 </p> 69 </div> 70 <?php 71 } 72 ); 73 return; 74 } 25 75 26 /** 27 * __construct function. 28 * 29 * @access public 30 * @return void 31 */ 32 public function __construct() { 33 // Hook-in 34 add_action( 'plugins_loaded', array( $this, 'i18n' ) ); 35 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) ); 36 add_action( 'widgets_init', array( $this, 'register_widget' ) ); 37 add_action( 'wp_authenticate', array( $this, 'convert_email_to_username' ), 10, 2 ); 76 /** 77 * Fetch instance of plugin. 78 * 79 * @return \MJ\SidebarLogin\Plugin 80 */ 81 function sidebar_login_init() { 82 static $instance; 38 83 39 // Ajax events 40 add_action( 'wp_ajax_sidebar_login_process', array( $this, 'ajax_handler' ) ); 41 add_action( 'wp_ajax_nopriv_sidebar_login_process', array( $this, 'ajax_handler' ) ); 84 if ( is_null( $instance ) ) { 85 $instance = new \MJ\SidebarLogin\Plugin( __FILE__ ); 42 86 } 43 87 44 /** 45 * i18n function. 46 * 47 * @access public 48 * @return void 49 */ 50 public function i18n() { 51 load_plugin_textdomain( 'sidebar-login', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 52 } 53 54 /** 55 * enqueue function. 56 * 57 * @access public 58 * @return void 59 */ 60 public function enqueue() { 61 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 62 $js_in_footer = apply_filters( 'sidebar_login_js_in_footer', false ); 63 64 // Register BLOCK UI 65 wp_register_script( 'jquery-blockui', plugins_url( 'assets/js/jquery.blockUI.min.js', __FILE__ ), array( 'jquery' ), '2.70', $js_in_footer ); 66 67 // Enqueue Sidebar Login JS 68 wp_enqueue_script( 'sidebar-login', plugins_url( 'assets/js/sidebar-login' . $suffix . '.js', __FILE__ ), array( 'jquery', 'jquery-blockui' ), $this->version, $js_in_footer ); 69 70 // Enqueue Styles 71 if ( apply_filters( 'sidebar_login_include_css', true ) ) { 72 wp_enqueue_style( 'sidebar-login', plugins_url( 'assets/css/sidebar-login.css', __FILE__ ), '', $this->version ); 73 } 74 75 // Pass variables 76 $sidebar_login_params = array( 77 'ajax_url' => $this->ajax_url(), 78 'force_ssl_admin' => force_ssl_admin() ? 1 : 0, 79 'is_ssl' => is_ssl() ? 1 : 0, 80 'i18n_username_required' => __( 'Please enter your username', 'sidebar-login' ), 81 'i18n_password_required' => __( 'Please enter your password', 'sidebar-login' ), 82 'error_class' => apply_filters( 'sidebar_login_widget_error_class', 'sidebar_login_error' ) 83 ); 84 85 wp_localize_script( 'sidebar-login', 'sidebar_login_params', $sidebar_login_params ); 86 } 87 88 /** 89 * Include and register the widget class. 90 * 91 * @access public 92 * @return void 93 */ 94 public function register_widget() { 95 include_once( 'includes/class-sidebar-login-widget.php' ); 96 } 97 98 /** 99 * ajax_url function. 100 * 101 * @access public 102 * @return void 103 */ 104 private function ajax_url() { 105 if ( is_ssl() ) { 106 return str_replace( 'http:', 'https:', admin_url( 'admin-ajax.php' ) ); 107 } else { 108 return str_replace( 'https:', 'http:', admin_url( 'admin-ajax.php' ) ); 109 } 110 } 111 112 /** 113 * When posting an email, convert to a username 114 */ 115 public function convert_email_to_username( &$username, &$password ) { 116 // If the user inputs an email address instead of a username, try to convert it 117 if ( is_email( $username ) ) { 118 if ( $user = get_user_by( 'email', $username ) ) { 119 $username = $user->user_login; 120 } 121 } 122 } 123 124 /** 125 * ajax_handler function. 126 * 127 * @access public 128 * @return void 129 */ 130 public function ajax_handler() { 131 // Get post data 132 $creds = array(); 133 $creds['user_login'] = stripslashes( trim( $_POST['user_login'] ) ); 134 $creds['user_password'] = stripslashes( trim( $_POST['user_password'] ) ); 135 $creds['remember'] = isset( $_POST['remember'] ) ? sanitize_text_field( $_POST['remember'] ) : ''; 136 $redirect_to = esc_url_raw( $_POST['redirect_to'] ); 137 $secure_cookie = null; 138 139 // If the user wants ssl but the session is not ssl, force a secure cookie. 140 if ( ! force_ssl_admin() ) { 141 $user = is_email( $creds['user_login'] ) ? get_user_by( 'email', $creds['user_login'] ) : get_user_by( 'login', sanitize_user( $creds['user_login'] ) ); 142 143 if ( $user && get_user_option( 'use_ssl', $user->ID ) ) { 144 $secure_cookie = true; 145 force_ssl_admin( true ); 146 } 147 } 148 149 if ( force_ssl_admin() ) { 150 $secure_cookie = true; 151 } 152 153 if ( is_null( $secure_cookie ) && force_ssl_admin() ) { 154 $secure_cookie = false; 155 } 156 157 // Login 158 $user = wp_signon( $creds, $secure_cookie ); 159 160 // Redirect filter 161 if ( $secure_cookie && strstr( $redirect_to, 'wp-admin' ) ) { 162 $redirect_to = str_replace( 'http:', 'https:', $redirect_to ); 163 } 164 165 // Result 166 $result = array(); 167 168 if ( ! is_wp_error( $user ) ) { 169 $result['success'] = 1; 170 $result['redirect'] = $redirect_to; 171 } else { 172 $result['success'] = 0; 173 if ( $user->errors ) { 174 foreach ( $user->errors as $error ) { 175 $result['error'] = $error[0]; 176 break; 177 } 178 } else { 179 $result['error'] = __( 'Please enter your username and password to login.', 'sidebar-login' ); 180 } 181 } 182 183 echo '<!--SBL-->'; 184 echo json_encode( $result ); 185 echo '<!--SBL_END-->'; 186 187 die(); 188 } 189 88 return $instance; 190 89 } 191 90 192 new Sidebar_Login();91 );
Note: See TracChangeset
for help on using the changeset viewer.