Social Login - Version 1.3.5

Version Description

  • Administration area redirection fixed
  • Automatic email creation added
  • Email verification added
Download this release

Release Info

Developer ClaudeSchlesser
Plugin Icon 128x128 Social Login
Version 1.3.5
Comparing to
See all releases

Code changes from version 1.3.4 to 1.3.5

includes/admin.php CHANGED
@@ -33,7 +33,7 @@ function oa_social_login_check_api_settings()
33
  {
34
  check_ajax_referer('oa_social_login_ajax_nonce');
35
 
36
- $api_domain = $_POST['api_subdomain'].'.api.oneall.com';
37
  $api_key = $_POST['api_key'];
38
  $api_secret = $_POST['api_secret'];
39
 
@@ -153,6 +153,13 @@ function oa_social_login_settings_validate ($settings)
153
  }
154
  }
155
 
 
 
 
 
 
 
 
156
  //Enabled providers
157
  if (isset ($settings ['providers']) AND is_array ($settings ['providers']))
158
  {
@@ -197,6 +204,10 @@ function oa_display_social_login_settings ()
197
  To be able to use this plugin you first of all need to create a free account at <a href="https://app.oneall.com/signup/" target="_blank">http://www.oneall.com</a>
198
  and create a new Site. After having created your account and setup your Site, please enter the Site Settings in the form below.
199
  </p>
 
 
 
 
200
  <h3>The basic account creation is free and the setup is easy!</h3>
201
  <p>
202
  <a class="button-secondary" href="https://app.oneall.com/signup/" target="_blank"><strong>Setup my account now</strong></a>
@@ -215,7 +226,11 @@ function oa_display_social_login_settings ()
215
  <div class="oa_container_body">
216
  <p>
217
  Login to your account to manage your providers and access your <a href="http://www.oneall.com/services/social-insights/" target="_blank">Social Insights</a>.
218
- Determine which social networks are popular amongst your users and tailor your registration experience increase user engagement
 
 
 
 
219
  </p>
220
  <p>
221
  <a class="button-secondary" href="https://app.oneall.com/signin/" target="_blank"><strong>Signin to my account</strong></a>
33
  {
34
  check_ajax_referer('oa_social_login_ajax_nonce');
35
 
36
+ $api_domain = strtolower($_POST['api_subdomain']).'.api.oneall.com';
37
  $api_key = $_POST['api_key'];
38
  $api_secret = $_POST['api_secret'];
39
 
153
  }
154
  }
155
 
156
+ //Subdomain is always lowercase
157
+ if (isset ($sanitzed_settings['api_subdomain']))
158
+ {
159
+ $sanitzed_settings['api_subdomain'] = strtolower ($sanitzed_settings['api_subdomain']);
160
+ }
161
+
162
+
163
  //Enabled providers
164
  if (isset ($settings ['providers']) AND is_array ($settings ['providers']))
165
  {
204
  To be able to use this plugin you first of all need to create a free account at <a href="https://app.oneall.com/signup/" target="_blank">http://www.oneall.com</a>
205
  and create a new Site. After having created your account and setup your Site, please enter the Site Settings in the form below.
206
  </p>
207
+ <p>
208
+ Feel free to <a href="http://www.oneall.com/company/contact-us/" target="_blank">contact us</a> if you need any help with the integration of this plugin!
209
+ We are devoted to creating a positive experience for our users. If anything is unclear, please get in touch!
210
+ </p>
211
  <h3>The basic account creation is free and the setup is easy!</h3>
212
  <p>
213
  <a class="button-secondary" href="https://app.oneall.com/signup/" target="_blank"><strong>Setup my account now</strong></a>
226
  <div class="oa_container_body">
227
  <p>
228
  Login to your account to manage your providers and access your <a href="http://www.oneall.com/services/social-insights/" target="_blank">Social Insights</a>.
229
+ Determine which social networks are popular amongst your users and tailor your registration experience to increase your users' engagement
230
+ </p>
231
+ <p>
232
+ Feel free to <a href="http://www.oneall.com/company/contact-us/" target="_blank">contact us</a> if you need any help with the integration of this plugin!
233
+ We are devoted to creating a positive experience for our users. If anything is unclear, please get in touch!
234
  </p>
235
  <p>
236
  <a class="button-secondary" href="https://app.oneall.com/signin/" target="_blank"><strong>Signin to my account</strong></a>
includes/toolbox.php CHANGED
@@ -12,6 +12,18 @@ function oa_social_login_get_user_by_token ($user_token)
12
  return $wpdb->get_var ($wpdb->prepare ($sql, $user_token));
13
  }
14
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  /**
17
  * Handle the callback
@@ -52,7 +64,6 @@ function oa_social_login_callback ()
52
  //User Data
53
  if (is_object ($social_data) AND $social_data->response->result->status->code == 200)
54
  {
55
-
56
  $identity = $social_data->response->result->data->user->identity;
57
  $user_token = $social_data->response->result->data->user->user_token;
58
 
@@ -67,6 +78,7 @@ function oa_social_login_callback ()
67
  $user_last_name = $identity->name->familyName;
68
 
69
  //Fullname
 
70
  if ( ! empty ($identity->name->formatted))
71
  {
72
  $user_full_name = $identity->name->formatted;
@@ -89,7 +101,9 @@ function oa_social_login_callback ()
89
  $user_email = $email->value;
90
  }
91
  }
 
92
  //User Website
 
93
  if ( ! empty ($identity->profileUrl))
94
  {
95
  $user_website = $identity->profileUrl;
@@ -98,12 +112,9 @@ function oa_social_login_callback ()
98
  {
99
  $user_website = $identity->urls [0]->value;
100
  }
101
- else
102
- {
103
- $user_website = '';
104
- }
105
 
106
  //Preferred Username
 
107
  if ( ! empty ($identity->preferredUsername))
108
  {
109
  $user_login = $identity->preferredUsername;
@@ -116,31 +127,38 @@ function oa_social_login_callback ()
116
  {
117
  $user_login = $identity->name->formatted;
118
  }
119
- else
120
- {
121
- $user_login = 'user_' . rand (99999, 999999);
122
- }
123
 
124
  // Get user by token
125
  $user_id = oa_social_login_get_user_by_token ($user_token);
126
 
127
- //User found
128
- if ($user_id)
129
- {
130
- $user_data = get_userdata ($user_id);
131
- $user_login = $user_data->user_login;
132
- }
133
- else
134
  {
135
- // Create new user and associate token
136
- $user_login_raw = $user_login;
137
- $i = 1;
138
- while (username_exists ($user_login))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  {
140
- $user_login = $user_login_raw . '-'.($i++);
141
  }
142
 
143
- $userdata = array (
144
  'user_login' => $user_login,
145
  'user_email' => $user_email,
146
  'first_name' => $user_first_name,
@@ -150,8 +168,8 @@ function oa_social_login_callback ()
150
  );
151
 
152
  // Create a new user
153
- $user_id = wp_insert_user ($userdata);
154
- if ( ! empty ($user_id))
155
  {
156
  delete_metadata('user', null, 'oa_social_login_user_token', $user_token, true);
157
  update_user_meta ($user_id, 'oa_social_login_user_token', $user_token);
@@ -160,8 +178,24 @@ function oa_social_login_callback ()
160
  }
161
  }
162
 
163
- wp_set_auth_cookie ($user_id);
164
- wp_set_current_user($user_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
  }
167
  }
12
  return $wpdb->get_var ($wpdb->prepare ($sql, $user_token));
13
  }
14
 
15
+ /**
16
+ * Create a random email
17
+ */
18
+ function oa_social_login_create_rand_email()
19
+ {
20
+ do
21
+ {
22
+ $email = md5(uniqid(wp_rand(10000,99000)))."@example.com";
23
+ } while(email_exists($email));
24
+
25
+ return $email;
26
+ }
27
 
28
  /**
29
  * Handle the callback
64
  //User Data
65
  if (is_object ($social_data) AND $social_data->response->result->status->code == 200)
66
  {
 
67
  $identity = $social_data->response->result->data->user->identity;
68
  $user_token = $social_data->response->result->data->user->user_token;
69
 
78
  $user_last_name = $identity->name->familyName;
79
 
80
  //Fullname
81
+ $user_full_name = '';
82
  if ( ! empty ($identity->name->formatted))
83
  {
84
  $user_full_name = $identity->name->formatted;
101
  $user_email = $email->value;
102
  }
103
  }
104
+
105
  //User Website
106
+ $user_website = '';
107
  if ( ! empty ($identity->profileUrl))
108
  {
109
  $user_website = $identity->profileUrl;
112
  {
113
  $user_website = $identity->urls [0]->value;
114
  }
 
 
 
 
115
 
116
  //Preferred Username
117
+ $user_login = '';
118
  if ( ! empty ($identity->preferredUsername))
119
  {
120
  $user_login = $identity->preferredUsername;
127
  {
128
  $user_login = $identity->name->formatted;
129
  }
 
 
 
 
130
 
131
  // Get user by token
132
  $user_id = oa_social_login_get_user_by_token ($user_token);
133
 
134
+ //New User
135
+ if ( ! is_numeric ($user_id))
 
 
 
 
 
136
  {
137
+ //Username is mandatory
138
+ if ( ! isset ($user_login) OR strlen(trim($user_login)) == 0)
139
+ {
140
+ $user_login = $user_identity_provider.'User';
141
+ }
142
+
143
+ //Username must be unique
144
+ if (username_exists ($user_login))
145
+ {
146
+ $i = 1;
147
+ $user_login_tmp = $user_login;
148
+ do
149
+ {
150
+ $user_login_tmp = $user_login.($i++);
151
+ } while (username_exists ($user_login_tmp));
152
+ $user_login = $user_login_tmp;
153
+ }
154
+
155
+ //Email must be unique
156
+ if ( ! isset ($user_email) OR ! is_email($user_email) OR email_exists ($user_email))
157
  {
158
+ $user_email = oa_social_login_create_rand_email();
159
  }
160
 
161
+ $user_data = array (
162
  'user_login' => $user_login,
163
  'user_email' => $user_email,
164
  'first_name' => $user_first_name,
168
  );
169
 
170
  // Create a new user
171
+ $user_id = wp_insert_user ($user_data);
172
+ if (is_numeric($user_id))
173
  {
174
  delete_metadata('user', null, 'oa_social_login_user_token', $user_token, true);
175
  update_user_meta ($user_id, 'oa_social_login_user_token', $user_token);
178
  }
179
  }
180
 
181
+ //Sucess
182
+ if (is_object(get_userdata($user_id)))
183
+ {
184
+ //Setup Cookie
185
+ wp_set_auth_cookie($user_id);
186
+
187
+ //Redirect to administration area
188
+ if (! empty ($_REQUEST['oa_social_login_source']) AND in_array ($_REQUEST['oa_social_login_source'], array ('login', 'registration')))
189
+ {
190
+ wp_safe_redirect(admin_url());
191
+ exit();
192
+ }
193
+ //Set current user
194
+ else
195
+ {
196
+ wp_set_current_user($user_id);
197
+ }
198
+ }
199
  }
200
  }
201
  }
includes/user_interface.php CHANGED
@@ -29,7 +29,7 @@ function oa_social_login_shortcode_handler ($args)
29
  {
30
  if (!is_user_logged_in ())
31
  {
32
- oa_social_login_render_login_form ();
33
  }
34
  }
35
  add_shortcode ('oa_social_login', 'oa_social_login_shortcode_handler');
@@ -43,7 +43,7 @@ function oa_social_login_render_login_form_comments ()
43
  {
44
  if (comments_open () && !is_user_logged_in ())
45
  {
46
- oa_social_login_render_login_form ();
47
  }
48
  }
49
  add_action ('comment_form_top', 'oa_social_login_render_login_form_comments');
@@ -57,7 +57,7 @@ function oa_social_login_render_login_form_registration ()
57
  {
58
  if (get_option('users_can_register') === '1')
59
  {
60
- oa_social_login_render_login_form ();
61
  }
62
  }
63
  add_action ('register_form', 'oa_social_login_render_login_form_registration');
@@ -69,7 +69,10 @@ add_action ('register_form', 'oa_social_login_render_login_form_registration');
69
  */
70
  function oa_social_login_render_login_form_login ()
71
  {
72
- oa_social_login_render_login_form ();
 
 
 
73
  }
74
  add_action ('login_form', 'oa_social_login_render_login_form_login');
75
 
@@ -79,7 +82,10 @@ add_action ('login_form', 'oa_social_login_render_login_form_login');
79
  */
80
  function oa_social_login_render_custom_form_login ()
81
  {
82
- oa_social_login_render_login_form ();
 
 
 
83
  }
84
  add_action ('oa_social_login', 'oa_social_login_render_custom_form_login');
85
 
@@ -87,24 +93,11 @@ add_action ('oa_social_login', 'oa_social_login_render_custom_form_login');
87
  /**
88
  * Display the provider grid
89
  */
90
- function oa_social_login_render_login_form ($args = null)
91
  {
92
  //Import providers
93
  GLOBAL $oa_social_login_providers;
94
 
95
- //Arguments
96
- $target = 'inline';
97
- if (is_array ($args))
98
- {
99
- if (isset ($args['target']))
100
- {
101
- if ($args['target'] == 'widget')
102
- {
103
- $target = 'widget';
104
- }
105
- }
106
- }
107
-
108
  //Read settings
109
  $settings = get_option ('oa_social_login_settings');
110
 
@@ -130,8 +123,12 @@ function oa_social_login_render_login_form ($args = null)
130
  }
131
  }
132
 
 
 
 
 
133
  //Widget
134
- if ($target == 'widget')
135
  {
136
  $css_theme_uri = 'http://oneallcdn.com/css/api/socialize/themes/wp_widget.css';
137
  $show_title = false;
@@ -139,20 +136,23 @@ function oa_social_login_render_login_form ($args = null)
139
  //Inline
140
  else
141
  {
 
142
  $css_theme_uri = 'http://oneallcdn.com/css/api/socialize/themes/wp_inline.css';
143
  $show_title = (empty($plugin_caption ) ? false : true);
144
- }
145
 
146
- //Build Redirection URL
147
- if (in_the_loop())
148
- {
149
- $redirect_url = "'".get_permalink()."'";
150
- }
151
- else
152
- {
153
- $redirect_url = "window.location.href";
 
 
154
  }
155
 
 
156
  if (count ($providers) > 0)
157
  {
158
  //Random integer
@@ -167,12 +167,14 @@ function oa_social_login_render_login_form ($args = null)
167
  <?php
168
  }
169
  ?>
170
- <div class="oneall_social_login_providers" id="oneall_social_login_providers_<?php echo $rand; ?>"></div>
171
  <script type="text/javascript">
172
  oneall.api.plugins.social_login.build("oneall_social_login_providers_<?php echo $rand; ?>", {
173
- 'providers' : ['<?php echo implode ("','", $providers); ?>'],
174
- 'callback_uri': <?php echo $redirect_url; ?>,
175
- 'css_theme_uri' : '<?php echo $css_theme_uri; ?>'
 
 
176
  });
177
  </script>
178
  </div>
29
  {
30
  if (!is_user_logged_in ())
31
  {
32
+ oa_social_login_render_login_form ('shortcode');
33
  }
34
  }
35
  add_shortcode ('oa_social_login', 'oa_social_login_shortcode_handler');
43
  {
44
  if (comments_open () && !is_user_logged_in ())
45
  {
46
+ oa_social_login_render_login_form ('comments');
47
  }
48
  }
49
  add_action ('comment_form_top', 'oa_social_login_render_login_form_comments');
57
  {
58
  if (get_option('users_can_register') === '1')
59
  {
60
+ oa_social_login_render_login_form ('registration');
61
  }
62
  }
63
  add_action ('register_form', 'oa_social_login_render_login_form_registration');
69
  */
70
  function oa_social_login_render_login_form_login ()
71
  {
72
+ if (!is_user_logged_in ())
73
+ {
74
+ oa_social_login_render_login_form ('login');
75
+ }
76
  }
77
  add_action ('login_form', 'oa_social_login_render_login_form_login');
78
 
82
  */
83
  function oa_social_login_render_custom_form_login ()
84
  {
85
+ if (!is_user_logged_in ())
86
+ {
87
+ oa_social_login_render_login_form ('custom');
88
+ }
89
  }
90
  add_action ('oa_social_login', 'oa_social_login_render_custom_form_login');
91
 
93
  /**
94
  * Display the provider grid
95
  */
96
+ function oa_social_login_render_login_form ($source)
97
  {
98
  //Import providers
99
  GLOBAL $oa_social_login_providers;
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  //Read settings
102
  $settings = get_option ('oa_social_login_settings');
103
 
123
  }
124
  }
125
 
126
+ //Grid Size
127
+ $grid_size_x = 99;
128
+ $grid_size_y = 99;
129
+
130
  //Widget
131
+ if ($source == 'widget')
132
  {
133
  $css_theme_uri = 'http://oneallcdn.com/css/api/socialize/themes/wp_widget.css';
134
  $show_title = false;
136
  //Inline
137
  else
138
  {
139
+ //For all page, except the Widget
140
  $css_theme_uri = 'http://oneallcdn.com/css/api/socialize/themes/wp_inline.css';
141
  $show_title = (empty($plugin_caption ) ? false : true);
 
142
 
143
+ //Comments
144
+ if ($source == 'comments')
145
+ {
146
+ $source .= '#comments';
147
+ }
148
+ elseif (in_array($source, array ('login', 'registration')))
149
+ {
150
+ $grid_size_x = 5;
151
+ $grid_size_y = 1;
152
+ }
153
  }
154
 
155
+ //Providers selected?
156
  if (count ($providers) > 0)
157
  {
158
  //Random integer
167
  <?php
168
  }
169
  ?>
170
+ <div class="oneall_social_login_providers" id="oneall_social_login_providers_<?php echo $rand; ?>" style="margin-top:5px;margin-botom:5px"></div>
171
  <script type="text/javascript">
172
  oneall.api.plugins.social_login.build("oneall_social_login_providers_<?php echo $rand; ?>", {
173
+ 'providers': ['<?php echo implode ("','", $providers); ?>'],
174
+ 'callback_uri': (window.location.href + ((window.location.href.split('?')[1] ? '&':'?') + 'oa_social_login_source=<?php echo $source; ?>')),
175
+ 'css_theme_uri': '<?php echo $css_theme_uri; ?>',
176
+ 'grid_size_x': '<?php echo $grid_size_x; ?>',
177
+ 'grid_size_y': '<?php echo $grid_size_y; ?>'
178
  });
179
  </script>
180
  </div>
includes/widget.php CHANGED
@@ -39,9 +39,7 @@ class oa_social_login_widget extends WP_Widget
39
  }
40
 
41
  //Content
42
- oa_social_login_render_login_form (array (
43
- 'target' => 'widget'
44
- ));
45
 
46
  //After Content
47
  if ( !empty ($instance ['widget_content_after']))
39
  }
40
 
41
  //Content
42
+ oa_social_login_render_login_form ('widget');
 
 
43
 
44
  //After Content
45
  if ( !empty ($instance ['widget_content_after']))
oa-social-login.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Social Login
4
  Plugin URI: http://www.oneall.com/
5
  Description: Allow your visitors to <strong>comment, login and register with 20+ social networks</strong> like Twitter, Facebook, LinkedIn, Hyves, Вконтакте, Google or Yahoo.
6
- Version: 1.3.4
7
  Author: Claude Schlesser
8
  Author URI: http://www.oneall.com/
9
  License: GPL2
3
  Plugin Name: Social Login
4
  Plugin URI: http://www.oneall.com/
5
  Description: Allow your visitors to <strong>comment, login and register with 20+ social networks</strong> like Twitter, Facebook, LinkedIn, Hyves, Вконтакте, Google or Yahoo.
6
+ Version: 1.3.5
7
  Author: Claude Schlesser
8
  Author URI: http://www.oneall.com/
9
  License: GPL2
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: ClaudeSchlesser
3
  Tags: facebook, linkedin, google, yahoo, twitter, openid, wordpress.com, vkontakte, hyves, social connect, social login
4
  Requires at least: 3.0
5
  Tested up to: 3.2.1
6
- Stable tag: 1.3.4
7
 
8
  Allow your visitors to comment and login with social networks like Twitter, Facebook, LinkedIn, Hyves, OpenID, Вконтакте, Google, Yahoo
9
 
@@ -40,8 +40,9 @@ Yahoo. <br />
40
 
41
  <strong>Increase your user engagement in a few simple steps with this plugin.</strong><br />
42
 
43
- The plugin is maintained by <a href="http://www.oneall.com">OneAll</a>, a technology company offering a set of web-delivered
44
- tools and services for establishing and optimizing a site's connection with many social providers such as Facebook, Twitter, Yahoo! and LinkedIn.
 
45
 
46
 
47
  == Installation ==
@@ -57,14 +58,18 @@ tools and services for establishing and optimizing a site's connection with many
57
  You should not have to change your templates.
58
  The Social Login seamlessly integrates into your blog by using predefined hooks.
59
 
60
- If you encounter nevertheless any problems, you can add the social login or registration forms to another location in
61
- your theme by inserting the following code in that location:
62
 
63
- `<?php do_action( 'oa_social_login' ); ?>`
 
 
 
 
64
 
65
  = Do I have to change my Rewrite Settings? =
66
 
67
  The plugins does not rely on mod_rewrite and does not need any additional rules.
 
68
 
69
  = Where can I report bugs & get support? =
70
 
@@ -94,4 +99,9 @@ http://www.oneall.com/company/contact-us/
94
  * Stable Version
95
 
96
  = 1.3.4 =
97
- * Multisite issues with Widget fixed
 
 
 
 
 
3
  Tags: facebook, linkedin, google, yahoo, twitter, openid, wordpress.com, vkontakte, hyves, social connect, social login
4
  Requires at least: 3.0
5
  Tested up to: 3.2.1
6
+ Stable tag: 1.3.5
7
 
8
  Allow your visitors to comment and login with social networks like Twitter, Facebook, LinkedIn, Hyves, OpenID, Вконтакте, Google, Yahoo
9
 
40
 
41
  <strong>Increase your user engagement in a few simple steps with this plugin.</strong><br />
42
 
43
+ The Social Login Plugin is maintained by <a href="http://www.oneall.com">OneAll</a>, a technology company offering a set of web-delivered
44
+ tools and services for establishing and optimizing a site's connection with social providers such as Facebook, Twitter, Google, Yahoo!,
45
+ LinkedIn amongst others.
46
 
47
 
48
  == Installation ==
58
  You should not have to change your templates.
59
  The Social Login seamlessly integrates into your blog by using predefined hooks.
60
 
61
+ = I have a custom template and the plugin is not displayed correctly =
 
62
 
63
+ The plugin uses predefined hooks. If your theme does not support these hooks,
64
+ you can add the Social Login form manually to your theme by inserting the following code
65
+ in your template (at the location where it should be displayed, i.e. above the comments).
66
+
67
+ `<?php do_action('oa_social_login'); ?>`
68
 
69
  = Do I have to change my Rewrite Settings? =
70
 
71
  The plugins does not rely on mod_rewrite and does not need any additional rules.
72
+ It should work out of the box.
73
 
74
  = Where can I report bugs & get support? =
75
 
99
  * Stable Version
100
 
101
  = 1.3.4 =
102
+ * Multisite issues with Widget fixed
103
+
104
+ = 1.3.5 =
105
+ * Administration area redirection fixed
106
+ * Automatic email creation added
107
+ * Email verification added