Social Login WordPress Plugin – AccessPress Social Login Lite - Version 3.4.1

Version Description

  • Issue resolved for google+ login being shutdown and migrate to google OAuth.
Download this release

Release Info

Developer Access Keys
Plugin Icon 128x128 Social Login WordPress Plugin – AccessPress Social Login Lite
Version 3.4.1
Comparing to
See all releases

Code changes from version 3.4.0 to 3.4.1

accesspress-social-login-lite.php CHANGED
@@ -1,46 +1,48 @@
1
- <?php defined( 'ABSPATH' ) or die( "No script kiddies please!" );
 
 
2
  /*
3
  Plugin name: Social Login WordPress Plugin - AccessPress Social Login Lite
4
  Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/
5
  Description: A plugin to add various social logins to a site.
6
- version: 3.4.0
7
  Author: AccessPress Themes
8
  Author URI: https://accesspressthemes.com/
9
  Text Domain: accesspress-social-login-lite
10
  Domain Path: /languages/
11
  License: GPLv2 or later
12
- */
13
  //Declearation of the necessary constants for plugin
14
- if( !defined( 'APSL_VERSION' ) ) {
15
- define( 'APSL_VERSION', '3.4.0' );
16
  }
17
 
18
- if( !defined( 'APSL_IMAGE_DIR' ) ) {
19
- define( 'APSL_IMAGE_DIR', plugin_dir_url( __FILE__ ) . 'images' );
20
  }
21
 
22
- if( !defined( 'APSL_JS_DIR' ) ) {
23
- define( 'APSL_JS_DIR', plugin_dir_url( __FILE__ ) . 'js' );
24
  }
25
 
26
- if( !defined( 'APSL_CSS_DIR' ) ) {
27
- define( 'APSL_CSS_DIR', plugin_dir_url( __FILE__ ) . 'css' );
28
  }
29
 
30
- if( !defined( 'APSL_LANG_DIR' ) ) {
31
- define( 'APSL_LANG_DIR', basename( dirname( __FILE__ ) ) . '/languages/' );
32
  }
33
 
34
- if( !defined( 'APSL_TEXT_DOMAIN' ) ) {
35
- define( 'APSL_TEXT_DOMAIN', 'accesspress-social-login-lite' );
36
  }
37
 
38
- if( !defined( 'APSL_SETTINGS' ) ) {
39
- define( 'APSL_SETTINGS', 'apsl-lite-settings' );
40
  }
41
 
42
- if( !defined( 'APSL_PLUGIN_DIR' ) ) {
43
- define( 'APSL_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
44
  }
45
  /**
46
  * Register a widget
@@ -48,163 +50,163 @@ if( !defined( 'APSL_PLUGIN_DIR' ) ) {
48
  */
49
  include_once( 'inc/backend/widget.php' );
50
 
51
- if (version_compare(get_bloginfo('version'), '4.3.1', '>=')){
52
- // Redefine user notification function
53
- if ( !function_exists('wp_new_user_notification') ) {
54
-
55
- function wp_new_user_notification( $user_id, $deprecated = null, $notify = 'both' ) {
56
- if ( $deprecated !== null ) {
57
- _deprecated_argument( __FUNCTION__, '4.3.1' );
58
- }
59
-
60
- global $wpdb, $wp_hasher;
61
- $user = get_userdata( $user_id );
62
- if ( empty ( $user ) )
63
- return;
64
-
65
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
66
- // we want to reverse this for the plain text arena of emails.
67
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
68
-
69
- $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
70
- $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
71
- $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
72
-
73
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
74
-
75
- if ( 'admin' === $notify || empty( $notify ) ) {
76
- return;
77
- }
78
-
79
- // Generate something random for a password reset key.
80
- $key = wp_generate_password( 20, false );
81
-
82
- /** This action is documented in wp-login.php */
83
- do_action( 'retrieve_password_key', $user->user_login, $key );
84
-
85
- // Now insert the key, hashed, into the DB.
86
- if ( empty( $wp_hasher ) ) {
87
- require_once ABSPATH . WPINC . '/class-phpass.php';
88
- $wp_hasher = new PasswordHash( 8, true );
89
- }
90
- $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
91
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
92
-
93
- $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
94
- $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
95
- $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
96
-
97
- $message .= wp_login_url() . "\r\n\r\n";
98
- $message .= sprintf( __('If you have any problems, please contact us at %s.'), get_option('admin_email') ) . "\r\n\r\n";
99
- $message .= __('Adios!') . "\r\n\r\n";
100
-
101
- wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
102
- }
103
- }
104
- }else{
105
- // for wordpress version less than 4.3.1
106
  // Redefine user notification function
107
- if(!function_exists( 'wp_new_user_notification' )){
108
- function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
109
- $user = new WP_User($user_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
- $user_login = stripslashes($user->user_login);
112
- $user_email = stripslashes($user->user_email);
113
 
114
- $message = sprintf(__('New user registration on your site %s:'), get_option('blogname')) . "\r\n\r\n";
115
- $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
116
- $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
117
- $message .= __('Thanks!');
 
 
118
 
119
- $headers = 'From:'.get_option('blogname').' <'.get_option('admin_email').'>' . "\r\n";
120
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message, $headers);
 
 
 
 
 
 
 
 
121
 
122
- if ( empty($plaintext_pass) )
123
- return;
 
124
 
125
- $message = __('Hi there,') . "\r\n\r\n";
126
- $message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
127
- $message .= wp_login_url() . "\r\n";
128
- $message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
129
- $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
130
- $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\r\n\r\n";
131
- $message .= __('Thanks!');
132
 
133
- $headers = 'From:'.get_option('blogname').' <'.get_option('admin_email').'>' . "\r\n";
 
 
 
 
 
 
 
134
 
135
- wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message, $headers);
 
136
 
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
 
142
  // Declaration of the class
143
- if( !class_exists( 'APSL_Lite_Class' ) ) {
144
-
145
  class APSL_Lite_Class {
146
-
147
  var $apsl_settings;
148
-
149
  function __construct() {
150
- $this->apsl_settings = get_option( APSL_SETTINGS );
151
- add_action( 'init', array($this, 'session_init') ); //start the session if not started yet.
152
- register_activation_hook( __FILE__, array($this, 'plugin_activation') ); //load the default setting for the plugin while activating
153
- add_action( 'init', array($this, 'plugin_text_domain') ); //load the plugin text domain
154
- add_action( 'admin_menu', array($this, 'add_apsl_menu') ); //register the plugin menu in backend
155
- add_action( 'admin_enqueue_scripts', array($this, 'register_admin_assets') ); //registers all the assets required for wp-admin
156
- add_action( 'wp_enqueue_scripts', array($this, 'register_frontend_assets') ); // registers all the assets required for the frontend
157
- add_action( 'admin_post_apsl_save_options', array($this, 'save_settings') ); //save settings of a plugin
158
-
159
- $options = get_option( APSL_SETTINGS );
160
- if( $options['apsl_enable_disable_plugin'] == 'yes' ) {
161
- if( in_array( "login_form", $options['apsl_display_options'] ) ) {
162
- add_action( 'login_form', array($this, 'add_social_login') ); // add the social logins to the login form
163
- add_action( 'woocommerce_login_form', array($this, 'add_social_login_form_to_comment') );
164
-
165
  }
166
-
167
- if( in_array( "register_form", $options['apsl_display_options'] ) ) {
168
- add_action( 'register_form', array($this, 'add_social_login') ); //add the social logins to the registration form
169
- add_action( 'after_signup_form', array($this, 'add_social_login') );
170
  }
171
-
172
- if( in_array( "comment_form", $options['apsl_display_options'] ) ) {
173
- add_action( 'comment_form_top', array($this, 'add_social_login_form_to_comment') ); //add the social logins to the comment form
174
- add_action( 'comment_form_must_log_in_after', array($this, 'add_social_login_form_to_comment') ); // add the social login buttons if “Users must be registered and logged in to comment�? checked in the discussions settings.
175
-
176
  }
177
  }
178
-
179
- add_shortcode( 'apsl-login-lite', array($this, 'apsl_shortcode') ); //adds a shortcode
180
- add_action( 'init', array($this, 'login_check') ); //check for the social logins
181
- add_action( 'widgets_init', array($this, 'register_apsl_widget') ); //register the widget of a plugin
182
- add_action( 'login_enqueue_scripts', array($this, 'apsl_login_form_enqueue_style'), 10 );
183
- add_action( 'login_enqueue_scripts', array($this, 'apsl_login_form__enqueue_script'), 1 );
184
- add_action( 'admin_post_apsl_restore_default_settings', array($this, 'apsl_restore_default_settings') ); //restores default settings.
185
-
186
-
187
  /**
188
  * Hook to display custom avatars
189
  */
190
- add_filter( 'get_avatar', array($this, 'apsl_social_login_custom_avatar'), 10, 5 );
191
 
192
  //add delete action when user is deleted from wordpress backend.
193
- add_action( 'delete_user', array ($this, 'apsl_delete_user') );
194
  }
195
-
196
- function apsl_social_login_custom_avatar( $avatar, $mixed, $size, $default, $alt = '' ) {
197
- $options = get_option( APSL_SETTINGS );
198
  //Check if we have an user identifier
199
- if( is_numeric( $mixed ) AND $mixed > 0 ) {
200
  $user_id = $mixed;
201
  }
202
  //Check if we have an user email
203
- elseif( is_string( $mixed ) AND( $user = get_user_by( 'email', $mixed ) ) ) {
204
  $user_id = $user->ID;
205
  }
206
  //Check if we have an user object
207
- elseif( is_object( $mixed ) AND property_exists( $mixed, 'user_id' ) AND is_numeric( $mixed->user_id ) ) {
208
  $user_id = $mixed->user_id;
209
  }
210
  //None found
@@ -212,33 +214,35 @@ if( !class_exists( 'APSL_Lite_Class' ) ) {
212
  $user_id = null;
213
  }
214
  //User found?
215
- if( !empty( $user_id ) ) {
216
  //Override current avatar ?
217
  $override_avatar = true;
218
  //Read the avatar
219
- $user_meta_thumbnail = get_user_meta( $user_id, 'deuimage', true );
220
  //read user details
221
- $user_meta_name = get_user_meta( $user_id, 'first_name', true );
222
-
223
- if( $options['apsl_user_avatar_options'] == 'social' ) {
224
- $user_picture =( !empty( $user_meta_thumbnail ) ? $user_meta_thumbnail : '' );
225
  //Avatar found?
226
- if( $user_picture !== false AND strlen( trim( $user_picture ) ) > 0 ) {
227
  return '<img alt="' . $user_meta_name . '" src="' . $user_picture . '" class="avatar apsl-avatar-social-login avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
228
  }
229
  }
230
  }
231
  return $avatar;
232
  }
 
233
  //starts the session with the call of init hook
234
  function session_init() {
235
- if( !session_id() && !headers_sent() ) {
236
  session_start();
237
  }
238
  }
 
239
  //load the default settings of the plugin
240
  function plugin_activation() {
241
- if( !get_option( APSL_SETTINGS ) ) {
242
  include( 'inc/backend/activation.php' );
243
  }
244
  self:: apsl_database_install();
@@ -283,115 +287,124 @@ if( !class_exists( 'APSL_Lite_Class' ) ) {
283
  KEY user_id (user_id),
284
  KEY provider_name (provider_name)
285
  )";
286
- dbDelta( $sql );
287
  }
288
 
289
  //loads the text domain for translation
290
  function plugin_text_domain() {
291
- load_plugin_textdomain( 'accesspress-social-login-lite', false, APSL_LANG_DIR );
292
  }
 
293
  //register the plugin menu for backend.
294
  function add_apsl_menu() {
295
- add_menu_page( 'AccessPress Social Login Lite', 'AccessPress Social Login Lite', 'manage_options', 'accesspress-social-login-lite', array($this, 'main_page'), APSL_IMAGE_DIR . '/icon.png' );
296
  }
 
297
  //menu page
298
  function main_page() {
299
  include( 'inc/backend/main-page.php' );
300
  }
 
301
  //registration of the backend assets
302
  function register_admin_assets() {
303
- wp_enqueue_style( 'fontawsome-css', APSL_CSS_DIR .'/font-awesome/font-awesome.min.css', '', APSL_VERSION );
304
- if( isset( $_GET['page'] ) && $_GET['page'] == 'accesspress-social-login-lite' ) {
305
  //backend scripts
306
- wp_enqueue_script( 'jquery-ui-sortable' );
307
- wp_enqueue_script( 'apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION ); //registering plugin's admin js
308
  //register backend css
309
- wp_enqueue_style( 'apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION );
310
  }
311
  }
 
312
  //registration of the plugins frontend assets
313
  function register_frontend_assets() {
314
  //register frontend scripts
315
- wp_enqueue_script( 'apsl-frontend-js', APSL_JS_DIR . '/frontend.js', array('jquery'), APSL_VERSION );
316
-
317
  //register frontend css
318
  // wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
319
- wp_enqueue_style( 'fontawsome-css', APSL_CSS_DIR .'/font-awesome/font-awesome.min.css', '', APSL_VERSION );
320
 
321
- wp_enqueue_style( 'apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION );
322
  }
 
323
  //save the settings of a plugin
324
  function save_settings() {
325
- if( isset( $_POST['apsl_save_settings'] ) && $_POST['apsl_settings_action'] && wp_verify_nonce( $_POST['apsl_settings_action'], 'apsl_nonce_save_settings' ) ) {
326
  include( 'inc/backend/save-settings.php' );
327
- }
328
- else {
329
- die( 'No script kiddies please!' );
330
  }
331
  }
 
332
  //function to add the social login in the login and registration form.
333
  function add_social_login() {
334
- if( !is_user_logged_in() ) {
335
  include( 'inc/frontend/login_integration.php' );
336
  }
337
  }
 
338
  //function to add the social login in the comment form.
339
  function add_social_login_form_to_comment() {
340
- $options = get_option( APSL_SETTINGS );
341
  $login_text = $options['apsl_title_text_field'];
342
- if( !is_user_logged_in() ) {
343
- echo do_shortcode( "[apsl-login-lite login_text='{$login_text}']" );
344
  }
345
  }
 
346
  //function for adding shortcode of a plugin
347
- function apsl_shortcode( $attr ) {
348
  ob_start();
349
  include( 'inc/frontend/shortcode.php' );
350
  $html = ob_get_contents();
351
  ob_get_clean();
352
  return $html;
353
  }
 
354
  //checking of the login
355
  function login_check() {
356
  include( 'inc/frontend/login_check.php' );
357
  }
 
358
  //registration of the social login widget
359
  function register_apsl_widget() {
360
- register_widget( 'APSL_Lite_Widget' );
361
  }
362
-
363
  function apsl_login_form_enqueue_style() {
364
- wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
365
- wp_enqueue_style( 'apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION );
366
- wp_enqueue_style( 'apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION );
367
  }
368
-
369
  function apsl_login_form__enqueue_script() {
370
- wp_enqueue_script( 'apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION ); //registering plugin's admin js
371
-
372
  }
373
-
374
  function apsl_restore_default_settings() {
375
  $nonce = $_REQUEST['_wpnonce'];
376
- if( !empty( $_GET ) && wp_verify_nonce( $nonce, 'apsl-restore-default-settings-nonce' ) ) {
377
  //restore the default plugin activation settings from the activation page.
378
  include( 'inc/backend/activation.php' );
379
- $_SESSION['apsl_message'] = __( 'Settings restored Successfully.', 'accesspress-social-login-lite' );
380
- wp_redirect( admin_url() . 'admin.php?page=' . 'accesspress-social-login-lite' );
381
  exit;
382
- }
383
- else {
384
- die( 'No script kiddies please!' );
385
  }
386
  }
387
 
388
- function apsl_delete_user( $user_id ) {
389
  global $wpdb;
390
  $table_name = $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
391
- $user_obj = get_userdata( $user_id );
392
- $result = $wpdb->delete( $table_name, array( 'user_id' => $user_id ) );
393
  }
394
- } //class termination
395
 
 
 
 
396
  }
397
  $apsl_object = new APSL_Lite_Class();
1
+ <?php
2
+
3
+ defined('ABSPATH') or die("No script kiddies please!");
4
  /*
5
  Plugin name: Social Login WordPress Plugin - AccessPress Social Login Lite
6
  Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/
7
  Description: A plugin to add various social logins to a site.
8
+ version: 3.4.1
9
  Author: AccessPress Themes
10
  Author URI: https://accesspressthemes.com/
11
  Text Domain: accesspress-social-login-lite
12
  Domain Path: /languages/
13
  License: GPLv2 or later
14
+ */
15
  //Declearation of the necessary constants for plugin
16
+ if (!defined('APSL_VERSION')) {
17
+ define('APSL_VERSION', '3.4.1');
18
  }
19
 
20
+ if (!defined('APSL_IMAGE_DIR')) {
21
+ define('APSL_IMAGE_DIR', plugin_dir_url(__FILE__) . 'images');
22
  }
23
 
24
+ if (!defined('APSL_JS_DIR')) {
25
+ define('APSL_JS_DIR', plugin_dir_url(__FILE__) . 'js');
26
  }
27
 
28
+ if (!defined('APSL_CSS_DIR')) {
29
+ define('APSL_CSS_DIR', plugin_dir_url(__FILE__) . 'css');
30
  }
31
 
32
+ if (!defined('APSL_LANG_DIR')) {
33
+ define('APSL_LANG_DIR', basename(dirname(__FILE__)) . '/languages/');
34
  }
35
 
36
+ if (!defined('APSL_TEXT_DOMAIN')) {
37
+ define('APSL_TEXT_DOMAIN', 'accesspress-social-login-lite');
38
  }
39
 
40
+ if (!defined('APSL_SETTINGS')) {
41
+ define('APSL_SETTINGS', 'apsl-lite-settings');
42
  }
43
 
44
+ if (!defined('APSL_PLUGIN_DIR')) {
45
+ define('APSL_PLUGIN_DIR', plugin_dir_path(__FILE__));
46
  }
47
  /**
48
  * Register a widget
50
  */
51
  include_once( 'inc/backend/widget.php' );
52
 
53
+ if (version_compare(get_bloginfo('version'), '4.3.1', '>=')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  // Redefine user notification function
55
+ if (!function_exists('wp_new_user_notification')) {
56
+
57
+ function wp_new_user_notification($user_id, $deprecated = null, $notify = 'both') {
58
+ if ($deprecated !== null) {
59
+ _deprecated_argument(__FUNCTION__, '4.3.1');
60
+ }
61
+
62
+ global $wpdb, $wp_hasher;
63
+ $user = get_userdata($user_id);
64
+ if (empty($user))
65
+ return;
66
+
67
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
68
+ // we want to reverse this for the plain text arena of emails.
69
+ $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
70
+
71
+ $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
72
+ $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
73
+ $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
74
 
75
+ @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
 
76
 
77
+ if ('admin' === $notify || empty($notify)) {
78
+ return;
79
+ }
80
+
81
+ // Generate something random for a password reset key.
82
+ $key = wp_generate_password(20, false);
83
 
84
+ /** This action is documented in wp-login.php */
85
+ do_action('retrieve_password_key', $user->user_login, $key);
86
+
87
+ // Now insert the key, hashed, into the DB.
88
+ if (empty($wp_hasher)) {
89
+ require_once ABSPATH . WPINC . '/class-phpass.php';
90
+ $wp_hasher = new PasswordHash(8, true);
91
+ }
92
+ $hashed = time() . ':' . $wp_hasher->HashPassword($key);
93
+ $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login));
94
 
95
+ $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
96
+ $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
97
+ $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
98
 
99
+ $message .= wp_login_url() . "\r\n\r\n";
100
+ $message .= sprintf(__('If you have any problems, please contact us at %s.'), get_option('admin_email')) . "\r\n\r\n";
101
+ $message .= __('Adios!') . "\r\n\r\n";
 
 
 
 
102
 
103
+ wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
104
+ }
105
+
106
+ }
107
+ } else {
108
+ // for wordpress version less than 4.3.1
109
+ // Redefine user notification function
110
+ if (!function_exists('wp_new_user_notification')) {
111
 
112
+ function wp_new_user_notification($user_id, $plaintext_pass = '') {
113
+ $user = new WP_User($user_id);
114
 
115
+ $user_login = stripslashes($user->user_login);
116
+ $user_email = stripslashes($user->user_email);
117
+
118
+ $message = sprintf(__('New user registration on your site %s:'), get_option('blogname')) . "\r\n\r\n";
119
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
120
+ $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
121
+ $message .= __('Thanks!');
122
+
123
+ $headers = 'From:' . get_option('blogname') . ' <' . get_option('admin_email') . '>' . "\r\n";
124
+ @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message, $headers);
125
+
126
+ if (empty($plaintext_pass))
127
+ return;
128
+
129
+ $message = __('Hi there,') . "\r\n\r\n";
130
+ $message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
131
+ $message .= wp_login_url() . "\r\n";
132
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
133
+ $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
134
+ $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\r\n\r\n";
135
+ $message .= __('Thanks!');
136
+
137
+ $headers = 'From:' . get_option('blogname') . ' <' . get_option('admin_email') . '>' . "\r\n";
138
+
139
+ wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message, $headers);
140
+ }
141
+
142
+ }
143
  }
144
 
145
 
146
  // Declaration of the class
147
+ if (!class_exists('APSL_Lite_Class')) {
148
+
149
  class APSL_Lite_Class {
150
+
151
  var $apsl_settings;
152
+
153
  function __construct() {
154
+ $this->apsl_settings = get_option(APSL_SETTINGS);
155
+ add_action('init', array($this, 'session_init')); //start the session if not started yet.
156
+ register_activation_hook(__FILE__, array($this, 'plugin_activation')); //load the default setting for the plugin while activating
157
+ add_action('init', array($this, 'plugin_text_domain')); //load the plugin text domain
158
+ add_action('admin_menu', array($this, 'add_apsl_menu')); //register the plugin menu in backend
159
+ add_action('admin_enqueue_scripts', array($this, 'register_admin_assets')); //registers all the assets required for wp-admin
160
+ add_action('wp_enqueue_scripts', array($this, 'register_frontend_assets')); // registers all the assets required for the frontend
161
+ add_action('admin_post_apsl_save_options', array($this, 'save_settings')); //save settings of a plugin
162
+
163
+ $options = get_option(APSL_SETTINGS);
164
+ if ($options['apsl_enable_disable_plugin'] == 'yes') {
165
+ if (in_array("login_form", $options['apsl_display_options'])) {
166
+ add_action('login_form', array($this, 'add_social_login')); // add the social logins to the login form
167
+ add_action('woocommerce_login_form', array($this, 'add_social_login_form_to_comment'));
 
168
  }
169
+
170
+ if (in_array("register_form", $options['apsl_display_options'])) {
171
+ add_action('register_form', array($this, 'add_social_login')); //add the social logins to the registration form
172
+ add_action('after_signup_form', array($this, 'add_social_login'));
173
  }
174
+
175
+ if (in_array("comment_form", $options['apsl_display_options'])) {
176
+ add_action('comment_form_top', array($this, 'add_social_login_form_to_comment')); //add the social logins to the comment form
177
+ add_action('comment_form_must_log_in_after', array($this, 'add_social_login_form_to_comment')); // add the social login buttons if “Users must be registered and logged in to comment�? checked in the discussions settings.
 
178
  }
179
  }
180
+
181
+ add_shortcode('apsl-login-lite', array($this, 'apsl_shortcode')); //adds a shortcode
182
+ add_action('init', array($this, 'login_check')); //check for the social logins
183
+ add_action('widgets_init', array($this, 'register_apsl_widget')); //register the widget of a plugin
184
+ add_action('login_enqueue_scripts', array($this, 'apsl_login_form_enqueue_style'), 10);
185
+ add_action('login_enqueue_scripts', array($this, 'apsl_login_form__enqueue_script'), 1);
186
+ add_action('admin_post_apsl_restore_default_settings', array($this, 'apsl_restore_default_settings')); //restores default settings.
187
+
188
+
189
  /**
190
  * Hook to display custom avatars
191
  */
192
+ add_filter('get_avatar', array($this, 'apsl_social_login_custom_avatar'), 10, 5);
193
 
194
  //add delete action when user is deleted from wordpress backend.
195
+ add_action('delete_user', array($this, 'apsl_delete_user'));
196
  }
197
+
198
+ function apsl_social_login_custom_avatar($avatar, $mixed, $size, $default, $alt = '') {
199
+ $options = get_option(APSL_SETTINGS);
200
  //Check if we have an user identifier
201
+ if (is_numeric($mixed) AND $mixed > 0) {
202
  $user_id = $mixed;
203
  }
204
  //Check if we have an user email
205
+ elseif (is_string($mixed) AND ( $user = get_user_by('email', $mixed) )) {
206
  $user_id = $user->ID;
207
  }
208
  //Check if we have an user object
209
+ elseif (is_object($mixed) AND property_exists($mixed, 'user_id') AND is_numeric($mixed->user_id)) {
210
  $user_id = $mixed->user_id;
211
  }
212
  //None found
214
  $user_id = null;
215
  }
216
  //User found?
217
+ if (!empty($user_id)) {
218
  //Override current avatar ?
219
  $override_avatar = true;
220
  //Read the avatar
221
+ $user_meta_thumbnail = get_user_meta($user_id, 'deuimage', true);
222
  //read user details
223
+ $user_meta_name = get_user_meta($user_id, 'first_name', true);
224
+
225
+ if ($options['apsl_user_avatar_options'] == 'social') {
226
+ $user_picture = (!empty($user_meta_thumbnail) ? $user_meta_thumbnail : '' );
227
  //Avatar found?
228
+ if ($user_picture !== false AND strlen(trim($user_picture)) > 0) {
229
  return '<img alt="' . $user_meta_name . '" src="' . $user_picture . '" class="avatar apsl-avatar-social-login avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
230
  }
231
  }
232
  }
233
  return $avatar;
234
  }
235
+
236
  //starts the session with the call of init hook
237
  function session_init() {
238
+ if (!session_id() && !headers_sent()) {
239
  session_start();
240
  }
241
  }
242
+
243
  //load the default settings of the plugin
244
  function plugin_activation() {
245
+ if (!get_option(APSL_SETTINGS)) {
246
  include( 'inc/backend/activation.php' );
247
  }
248
  self:: apsl_database_install();
287
  KEY user_id (user_id),
288
  KEY provider_name (provider_name)
289
  )";
290
+ dbDelta($sql);
291
  }
292
 
293
  //loads the text domain for translation
294
  function plugin_text_domain() {
295
+ load_plugin_textdomain('accesspress-social-login-lite', false, APSL_LANG_DIR);
296
  }
297
+
298
  //register the plugin menu for backend.
299
  function add_apsl_menu() {
300
+ add_menu_page('AccessPress Social Login Lite', 'AccessPress Social Login Lite', 'manage_options', 'accesspress-social-login-lite', array($this, 'main_page'), APSL_IMAGE_DIR . '/icon.png');
301
  }
302
+
303
  //menu page
304
  function main_page() {
305
  include( 'inc/backend/main-page.php' );
306
  }
307
+
308
  //registration of the backend assets
309
  function register_admin_assets() {
310
+ wp_enqueue_style('fontawsome-css', APSL_CSS_DIR . '/font-awesome/font-awesome.min.css', '', APSL_VERSION);
311
+ if (isset($_GET['page']) && $_GET['page'] == 'accesspress-social-login-lite') {
312
  //backend scripts
313
+ wp_enqueue_script('jquery-ui-sortable');
314
+ wp_enqueue_script('apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION); //registering plugin's admin js
315
  //register backend css
316
+ wp_enqueue_style('apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION);
317
  }
318
  }
319
+
320
  //registration of the plugins frontend assets
321
  function register_frontend_assets() {
322
  //register frontend scripts
323
+ wp_enqueue_script('apsl-frontend-js', APSL_JS_DIR . '/frontend.js', array('jquery'), APSL_VERSION);
324
+
325
  //register frontend css
326
  // wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
327
+ wp_enqueue_style('fontawsome-css', APSL_CSS_DIR . '/font-awesome/font-awesome.min.css', '', APSL_VERSION);
328
 
329
+ wp_enqueue_style('apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION);
330
  }
331
+
332
  //save the settings of a plugin
333
  function save_settings() {
334
+ if (isset($_POST['apsl_save_settings']) && $_POST['apsl_settings_action'] && wp_verify_nonce($_POST['apsl_settings_action'], 'apsl_nonce_save_settings')) {
335
  include( 'inc/backend/save-settings.php' );
336
+ } else {
337
+ die('No script kiddies please!');
 
338
  }
339
  }
340
+
341
  //function to add the social login in the login and registration form.
342
  function add_social_login() {
343
+ if (!is_user_logged_in()) {
344
  include( 'inc/frontend/login_integration.php' );
345
  }
346
  }
347
+
348
  //function to add the social login in the comment form.
349
  function add_social_login_form_to_comment() {
350
+ $options = get_option(APSL_SETTINGS);
351
  $login_text = $options['apsl_title_text_field'];
352
+ if (!is_user_logged_in()) {
353
+ echo do_shortcode("[apsl-login-lite login_text='{$login_text}']");
354
  }
355
  }
356
+
357
  //function for adding shortcode of a plugin
358
+ function apsl_shortcode($attr) {
359
  ob_start();
360
  include( 'inc/frontend/shortcode.php' );
361
  $html = ob_get_contents();
362
  ob_get_clean();
363
  return $html;
364
  }
365
+
366
  //checking of the login
367
  function login_check() {
368
  include( 'inc/frontend/login_check.php' );
369
  }
370
+
371
  //registration of the social login widget
372
  function register_apsl_widget() {
373
+ register_widget('APSL_Lite_Widget');
374
  }
375
+
376
  function apsl_login_form_enqueue_style() {
377
+ wp_enqueue_style('fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION);
378
+ wp_enqueue_style('apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION);
379
+ wp_enqueue_style('apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION);
380
  }
381
+
382
  function apsl_login_form__enqueue_script() {
383
+ wp_enqueue_script('apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION); //registering plugin's admin js
 
384
  }
385
+
386
  function apsl_restore_default_settings() {
387
  $nonce = $_REQUEST['_wpnonce'];
388
+ if (!empty($_GET) && wp_verify_nonce($nonce, 'apsl-restore-default-settings-nonce')) {
389
  //restore the default plugin activation settings from the activation page.
390
  include( 'inc/backend/activation.php' );
391
+ $_SESSION['apsl_message'] = __('Settings restored Successfully.', 'accesspress-social-login-lite');
392
+ wp_redirect(admin_url() . 'admin.php?page=' . 'accesspress-social-login-lite');
393
  exit;
394
+ } else {
395
+ die('No script kiddies please!');
 
396
  }
397
  }
398
 
399
+ function apsl_delete_user($user_id) {
400
  global $wpdb;
401
  $table_name = $apsl_userdetails = "{$wpdb->prefix}apsl_users_social_profile_details";
402
+ $user_obj = get_userdata($user_id);
403
+ $result = $wpdb->delete($table_name, array('user_id' => $user_id));
404
  }
 
405
 
406
+ }
407
+
408
+ //class termination
409
  }
410
  $apsl_object = new APSL_Lite_Class();
inc/backend/main-page.php CHANGED
@@ -208,6 +208,9 @@
208
  <input type='hidden' name='network_ordering[]' value='google' />
209
  <div class='apsl-info'>
210
  <span class='apsl-info-note'><?php _e('Note:', 'accesspress-social-login-lite'); ?></span> <br />
 
 
 
211
  <span class='apsl-info-content'>You need to create new google API application to setup the google login. Please follow the instructions to create new application.</span>
212
  <ul class='apsl-info-lists'>
213
  <li>Go to <a href='https://console.developers.google.com/project' target='_blank'>https://console.developers.google.com/project.</a> </li>
208
  <input type='hidden' name='network_ordering[]' value='google' />
209
  <div class='apsl-info'>
210
  <span class='apsl-info-note'><?php _e('Note:', 'accesspress-social-login-lite'); ?></span> <br />
211
+ <br/>
212
+ <span class='apsl-info-content' style="color:red"><strong>Important Notice: </strong> In prior to google+ being shutdown from March 7, 2019, the code for Google+ login to google oauth login has been updated. You might need to revalidate and create the client key & client secret again. </span>
213
+ <br/><br/>
214
  <span class='apsl-info-content'>You need to create new google API application to setup the google login. Please follow the instructions to create new application.</span>
215
  <ul class='apsl-info-lists'>
216
  <li>Go to <a href='https://console.developers.google.com/project' target='_blank'>https://console.developers.google.com/project.</a> </li>
inc/frontend/login_check.php CHANGED
@@ -37,7 +37,8 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
37
  include( APSL_PLUGIN_DIR . 'google/Client.php' );
38
  }
39
  if(!class_exists('Google_Service_Plus')){
40
- include( APSL_PLUGIN_DIR . 'google/Service/Plus.php' );
 
41
  }
42
  $this->onGoogleLogin();
43
  break;
@@ -463,13 +464,19 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
463
  $client->setClientId( $client_id );
464
  $client->setClientSecret( $client_secret );
465
  $client->setRedirectUri( $redirect_uri );
466
- $client->addScope( "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.profile.emails.read" );
 
 
 
 
 
 
467
  if( isset( $encoded_url ) && $encoded_url != '' ) {
468
  $client->setState( base64_encode( "redirect_to=$encoded_url" ) );
469
  }
470
 
471
- $service = new Google_Service_Plus( $client );
472
-
473
  if( $action == 'login' ) { // Get identity from user and redirect browser to OpenID Server
474
  unset($_SESSION['access_token']);
475
  if( !( isset( $_SESSION['access_token'] ) && $_SESSION['access_token'] ) ) {
@@ -492,7 +499,8 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
492
  $client->setAccessToken( $_SESSION['access_token'] );
493
 
494
  try {
495
- $user = $service->people->get( "me", array() );
 
496
  }
497
  catch( Exception $fault ) {
498
  unset( $_SESSION['access_token'] );
@@ -502,14 +510,17 @@ if( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
502
  }
503
 
504
  if( !empty( $user ) ) {
505
- if( !empty( $user->emails ) ) {
506
 
507
- $response->email = $user->emails[0]->value;
508
- $response->username = ($user->name->givenName) ? strtolower($user->name->givenName) : $user_email;
509
- $response->first_name = $user->name->givenName;
510
- $response->last_name = $user->name->familyName;
 
511
  $response->deuid = $user->emails[0]->value;
512
- $response->deuimage = $user->image->url;
 
 
513
  $response->gender = isset($user->gender) ? $user->gender : 'N/A';
514
  $response->id = $user->id;
515
  $response->about = $user->aboutMe;
37
  include( APSL_PLUGIN_DIR . 'google/Client.php' );
38
  }
39
  if(!class_exists('Google_Service_Plus')){
40
+ include( APSL_PLUGIN_DIR . 'google/Service/Oauth2.php' );
41
+ //include( APSL_PLUGIN_DIR . 'google/Service/Plus.php' );
42
  }
43
  $this->onGoogleLogin();
44
  break;
464
  $client->setClientId( $client_id );
465
  $client->setClientSecret( $client_secret );
466
  $client->setRedirectUri( $redirect_uri );
467
+ //$client->addScope( "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.profile.emails.read" );
468
+
469
+ $client->setScopes([
470
+ "profile", // can give: all we need, but no email
471
+ "email", // can give: all we need, but no language (do we need that?)
472
+ ]);
473
+
474
  if( isset( $encoded_url ) && $encoded_url != '' ) {
475
  $client->setState( base64_encode( "redirect_to=$encoded_url" ) );
476
  }
477
 
478
+ //$service = new Google_Service_Plus( $client );
479
+ $service = new Google_Service_Oauth2($client);
480
  if( $action == 'login' ) { // Get identity from user and redirect browser to OpenID Server
481
  unset($_SESSION['access_token']);
482
  if( !( isset( $_SESSION['access_token'] ) && $_SESSION['access_token'] ) ) {
499
  $client->setAccessToken( $_SESSION['access_token'] );
500
 
501
  try {
502
+ //$user = $service->people->get( "me", array() );
503
+ $user = $service->userinfo->get();
504
  }
505
  catch( Exception $fault ) {
506
  unset( $_SESSION['access_token'] );
510
  }
511
 
512
  if( !empty( $user ) ) {
513
+ if( !empty( $user->email ) ) {
514
 
515
+ $response->email = $user->email;
516
+ //$response->username = ($user->name->givenName) ? strtolower($user->name->givenName) : $user_email;
517
+ $response->username = ($user->givenName != '') ? strtolower($user->givenName) : $user->email;
518
+ $response->first_name = $user->givenName;
519
+ $response->last_name = $user->familyName;
520
  $response->deuid = $user->emails[0]->value;
521
+ //$response->deuimage = $user->image->url;
522
+ $imageUrl = substr($user->picture, 0, strpos($user->picture . "?sz=", "?sz=")) . '?sz=450';
523
+ $response->deuimage = $imageUrl;
524
  $response->gender = isset($user->gender) ? $user->gender : 'N/A';
525
  $response->id = $user->id;
526
  $response->about = $user->aboutMe;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: social, login, social login, facebook, twitter, google, social connect, s
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
  Tested up to: 5.0
7
- Stable tag: 3.4.0
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -139,6 +139,10 @@ Yes. You can use the AccessPress social login lite anywhere by using the shortco
139
 
140
  == Changelog ==
141
 
 
 
 
 
142
  = 3.4.0 =
143
  * Issue resolved for Twitter Social Login.
144
 
4
  Donate link: http://accesspressthemes.com/donation/
5
  Requires at least: 3.8
6
  Tested up to: 5.0
7
+ Stable tag: 3.4.1
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
139
 
140
  == Changelog ==
141
 
142
+
143
+ = 3.4.1 =
144
+ * Issue resolved for google+ login being shutdown and migrate to google OAuth.
145
+
146
  = 3.4.0 =
147
  * Issue resolved for Twitter Social Login.
148