Nextend Social Login and Register (Facebook, Google, Twitter) - Version 1.4

Version Description

Download this release

Release Info

Developer nextendweb
Plugin Icon 128x128 Nextend Social Login and Register (Facebook, Google, Twitter)
Version 1.4
Comparing to
See all releases

Code changes from version 1.2 to 1.4

buttons/facebook-btn.css ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url(http://fonts.googleapis.com/css?family=Open+Sans:600);
2
+
3
+ .new-fb-btn{
4
+ margin: 5px auto;
5
+ display: inline-block;
6
+ }
7
+
8
+ .new-fb-btn,
9
+ .new-fb-btn div{
10
+ font-size:14px;
11
+ font-weight:600;
12
+ font-family:'Open Sans',sans-serif;
13
+ color:#fff;
14
+ text-shadow:0 0 1px RGBA(0,0,0,1);
15
+ white-space:nowrap;
16
+ vertical-align:middle;
17
+ }
18
+
19
+ /*
20
+ 1 --------------
21
+ */
22
+ .new-fb-1,
23
+ .new-fb-1 div{
24
+ height: 42px;
25
+ line-height: 42px;
26
+ background: url('facebook-btn.png') no-repeat 0 0;
27
+ }
28
+
29
+ div.new-fb-1{
30
+ padding: 0 0 0 20px;
31
+ }
32
+
33
+ div.new-fb-1-1{
34
+ padding: 0 43px 0 0;
35
+ background-position: right -100px;
36
+ }
37
+
38
+ div.new-fb-1-1-1{
39
+ background-repeat: repeat-x;
40
+ background-position: 0 -50px;
41
+ padding: 0 20px 0 5px;
42
+ }
43
+
44
+ /*
45
+ 2 --------------
46
+ */
47
+ .new-fb-2,
48
+ .new-fb-2 div{
49
+ height: 42px;
50
+ line-height: 42px;
51
+ background: url('facebook-btn.png') no-repeat 0 0;
52
+ }
53
+
54
+ div.new-fb-2{
55
+ padding: 0 0 0 45px;
56
+ background-position: 0 -150px;
57
+ }
58
+
59
+ div.new-fb-2-1{
60
+ padding: 0 20px 0 0;
61
+ background-position: right -250px;
62
+ }
63
+
64
+ div.new-fb-2-1-1{
65
+ background-repeat: repeat-x;
66
+ background-position: 0 -200px;
67
+ padding: 0 0 0 10px;
68
+ font-size: 12px;
69
+ }
70
+
71
+ /*
72
+ 3 --------------
73
+ */
74
+ .new-fb-3,
75
+ .new-fb-3 div{
76
+ height: 37px;
77
+ line-height: 37px;
78
+ background: url('facebook-btn.png') no-repeat 0 0;
79
+ }
80
+
81
+ div.new-fb-3{
82
+ padding: 0 0 0 35px;
83
+ background-position: 0 -300px;
84
+ }
85
+
86
+ div.new-fb-3-1{
87
+ padding: 0 18px 0 0;
88
+ background-position: right -400px;
89
+ }
90
+
91
+ div.new-fb-3-1-1{
92
+ background-repeat: repeat-x;
93
+ background-position: 0 -350px;
94
+ padding: 0 0 0 8px;
95
+ font-size: 12px;
96
+ }
97
+
98
+ /*
99
+ 4 --------------
100
+ */
101
+ .new-fb-4,
102
+ .new-fb-4 div{
103
+ height: 35px;
104
+ line-height: 32px;
105
+ background: url('facebook-btn.png') no-repeat 0 0;
106
+ }
107
+
108
+ div.new-fb-4{
109
+ padding: 0 0 0 4px;
110
+ background-position: 0 -450px;
111
+ }
112
+
113
+ div.new-fb-4-1{
114
+ padding: 0 33px 0 0;
115
+ background-position: right -550px;
116
+ }
117
+
118
+ div.new-fb-4-1-1{
119
+ background-repeat: repeat-x;
120
+ background-position: 0 -500px;
121
+ padding: 0 19px 0 18px;
122
+ font-size: 12px;
123
+ }
124
+
125
+ /*
126
+ 5 --------------
127
+ */
128
+ .new-fb-5,
129
+ .new-fb-5 div{
130
+ height: 15px;
131
+ line-height: 15px;
132
+ background: url('facebook-btn.png') no-repeat 0 0;
133
+ }
134
+
135
+ div.new-fb-5{
136
+ padding: 0 0 0 3px;
137
+ background-position: 0 -600px;
138
+ }
139
+
140
+ div.new-fb-5-1{
141
+ padding: 0 3px 0 0;
142
+ background-position: right -640px;
143
+ }
144
+
145
+ div.new-fb-5-1-1{
146
+ background-repeat: repeat-x;
147
+ background-position: 0 -620px;
148
+ padding: 0 1px;
149
+ font-size: 10px;
150
+ }
151
+
152
+ /*
153
+ 6 --------------
154
+ */
155
+ .new-fb-6,
156
+ .new-fb-6 div{
157
+ height: 29px;
158
+ line-height: 26px;
159
+ background: url('facebook-btn.png') no-repeat 0 0;
160
+ }
161
+
162
+ div.new-fb-6{
163
+ padding: 0 0 0 4px;
164
+ background-position: 0 -660px;
165
+ }
166
+
167
+ div.new-fb-6-1{
168
+ padding: 0 27px 0 0;
169
+ background-position: right -750px;
170
+ }
171
+
172
+ div.new-fb-6-1-1{
173
+ background-repeat: repeat-x;
174
+ background-position: 0 -700px;
175
+ padding: 0 10px 0 8px;
176
+ font-size: 12px;
177
+ }
178
+
179
+ /*
180
+ 7 --------------
181
+ */
182
+ .new-fb-7,
183
+ .new-fb-7 div{
184
+ height: 29px;
185
+ line-height: 26px;
186
+ background: url('facebook-btn.png') no-repeat 0 0;
187
+ }
188
+
189
+ div.new-fb-7{
190
+ padding: 0 0 0 29px;
191
+ background-position: 0 -800px;
192
+ }
193
+
194
+ div.new-fb-7-1{
195
+ padding: 0 4px 0 0;
196
+ background-position: right -900px;
197
+ }
198
+
199
+ div.new-fb-7-1-1{
200
+ background-repeat: repeat-x;
201
+ background-position: 0 -850px;
202
+ padding: 0 10px 0 10px;
203
+ font-size: 11px;
204
+ }
205
+
206
+ /*
207
+ 8 --------------
208
+ */
209
+ .new-fb-8,
210
+ .new-fb-8 div{
211
+ height: 25px;
212
+ width: 30px;
213
+ background: url('facebook-btn.png') no-repeat 0 0;
214
+ }
215
+
216
+ div.new-fb-8{
217
+ background-position: 0 -950px;
218
+ }
219
+
220
+ div.new-fb-8-1{
221
+ background-position: 0 -1050px;
222
+ transition: background-position 0.4s;
223
+ -moz-transition: background-position 0.4s; /* Firefox 4 */
224
+ -webkit-transition: background-position 0.4s; /* Safari and Chrome */
225
+ -o-transition: background-position 0.4s; /* Opera */
226
+ }
227
+
228
+ div.new-fb-8:HOVER div.new-fb-8-1{
229
+ background-position: 0 -1000px;
230
+ }
231
+
232
+ /*
233
+ 9 --------------
234
+ */
235
+ .new-fb-9,
236
+ .new-fb-9 div{
237
+ height: 26px;
238
+ width: 30px;
239
+ background: url('facebook-btn.png') no-repeat 0 0;
240
+ }
241
+
242
+ div.new-fb-9{
243
+ opacity: 0.79;
244
+ background-position: 0 -1100px;
245
+ transition: opacity 0.4s;
246
+ -moz-transition: opacity 0.4s; /* Firefox 4 */
247
+ -webkit-transition: opacity 0.4s; /* Safari and Chrome */
248
+ -o-transition: opacity 0.4s; /* Opera */
249
+ }
250
+
251
+ div.new-fb-9:HOVER{
252
+ opacity: 0.99
253
+ }
254
+
255
+ /*
256
+ 10 --------------
257
+ */
258
+ .new-fb-10,
259
+ .new-fb-10 div{
260
+ background: url('facebook-btn.png') no-repeat 0 0;
261
+ }
262
+
263
+ div.new-fb-10{
264
+ height: 36px;
265
+ width: 37px;
266
+ background-position: 0 -1150px;
267
+ }
268
+
269
+ div.new-fb-10-1{
270
+ margin: 5px 5px 6px 5px;
271
+ height: 26px;
272
+ width: 26px;
273
+ overflow: hidden;
274
+ background-position: -5px -1255px;
275
+ transition: background-position 0.4s;
276
+ -moz-transition: background-position 0.4s; /* Firefox 4 */
277
+ -webkit-transition: background-position 0.4s; /* Safari and Chrome */
278
+ -o-transition: background-position 0.4s; /* Opera */
279
+ }
280
+
281
+ div.new-fb-10:HOVER div.new-fb-10-1{
282
+ background-position: -5px -1205px;
283
+ }
284
+
285
+ /*
286
+ 11 --------------
287
+ */
288
+ .new-fb-11,
289
+ .new-fb-11 div{
290
+ height: 36px;
291
+ width: 36px;
292
+ background: url('facebook-btn.png') no-repeat 0 0;
293
+ }
294
+
295
+ div.new-fb-11{
296
+ opacity: 0.79;
297
+ background-position: 0 -1300px;
298
+ transition: opacity 0.4s;
299
+ -moz-transition: opacity 0.4s; /* Firefox 4 */
300
+ -webkit-transition: opacity 0.4s; /* Safari and Chrome */
301
+ -o-transition: opacity 0.4s; /* Opera */
302
+ }
303
+
304
+ div.new-fb-11:HOVER{
305
+ opacity: 0.99
306
+ }
307
+
308
+ /*
309
+ 12 --------------
310
+ */
311
+ .new-fb-12,
312
+ .new-fb-12 div{
313
+ height: 28px;
314
+ width: 29px;
315
+ background: url('facebook-btn.png') no-repeat 0 0;
316
+ }
317
+
318
+ div.new-fb-12{
319
+ background-position: 0 -1350px;
320
+ opacity: 0.79;
321
+ transition: opacity 0.4s;
322
+ -moz-transition: opacity 0.4s; /* Firefox 4 */
323
+ -webkit-transition: opacity 0.4s; /* Safari and Chrome */
324
+ -o-transition: opacity 0.4s; /* Opera */
325
+ }
326
+
327
+ div.new-fb-12:HOVER{
328
+ opacity: 0.99
329
+ }
330
+
331
+ /*
332
+ 13 --------------
333
+ */
334
+ .new-fb-13,
335
+ .new-fb-13 div{
336
+ height: 25px;
337
+ width: 30px;
338
+ background: url('facebook-btn.png') no-repeat 0 0;
339
+ }
340
+
341
+ div.new-fb-13{
342
+ background-position: 0 -1400px;
343
+ }
344
+
345
+ div.new-fb-13-1{
346
+ background-position: 0 -1050px;
347
+ transition: background-position 0.4s;
348
+ -moz-transition: background-position 0.4s; /* Firefox 4 */
349
+ -webkit-transition: background-position 0.4s; /* Safari and Chrome */
350
+ -o-transition: background-position 0.4s; /* Opera */
351
+ }
352
+
353
+ div.new-fb-13:HOVER div.new-fb-13-1{
354
+ background-position: 0 -1000px;
355
+ }
356
+
357
+ /*
358
+ 14 --------------
359
+ */
360
+ .new-fb-14,
361
+ .new-fb-14 div{
362
+ height: 23px;
363
+ width: 23px;
364
+ background: url('facebook-btn.png') no-repeat 0 0;
365
+ }
366
+
367
+ div.new-fb-14{
368
+ background-position: 0 -1450px;
369
+ }
370
+
371
+ div.new-fb-14-1{
372
+ background-position: 0 -1550px;
373
+ transition: background-position 0.4s;
374
+ -moz-transition: background-position 0.4s; /* Firefox 4 */
375
+ -webkit-transition: background-position 0.4s; /* Safari and Chrome */
376
+ -o-transition: background-position 0.4s; /* Opera */
377
+ }
378
+
379
+ div.new-fb-14:HOVER div.new-fb-14-1{
380
+ background-position: 0 -1500px;
381
+ }
382
+
383
+ /*
384
+ Main animations
385
+ */
386
+
387
+ .new-fb-default-anim{
388
+ opacity: 0.79;
389
+ transition: opacity 0.4s;
390
+ -moz-transition: opacity 0.4s; /* Firefox 4 */
391
+ -webkit-transition: opacity 0.4s; /* Safari and Chrome */
392
+ -o-transition: opacity 0.4s; /* Opera */
393
+ }
394
+
395
+ .new-fb-default-anim:HOVER{
396
+ opacity: 0.999;
397
+ }
buttons/facebook-btn.png ADDED
Binary file
buttons/index.html ADDED
File without changes
generatorbanner.png ADDED
Binary file
nextend-facebook-connect.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nextend Facebook Connect
4
  Plugin URI: http://nextendweb.com/
5
  Description: This plugins helps you create Facebook login and register buttons. The login and register process only takes one click.
6
- Version: 1.2
7
  Author: Roland Soos
8
  License: GPL2
9
  */
@@ -23,13 +23,49 @@ License: GPL2
23
  along with this program; if not, write to the Free Software
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
 
26
 
27
  define( 'NEW_FB_LOGIN', 1 );
28
  if ( ! defined( 'NEW_FB_LOGIN_PLUGIN_BASENAME' ) )
29
  define( 'NEW_FB_LOGIN_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
30
-
31
- register_activation_hook(__FILE__, 'nextend_fb_connect_install');
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  function nextend_fb_connect_install(){
34
  global $wpdb;
35
 
@@ -44,36 +80,35 @@ function nextend_fb_connect_install(){
44
 
45
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
46
  dbDelta($sql);
47
-
48
- }
49
-
50
- function add_author_more_query_var() {
51
- global $wp;
52
- $wp->add_query_var('author_more');
53
  }
 
54
 
55
- add_filter('init', 'new_fb_add_query_var');
56
-
 
57
  function new_fb_add_query_var(){
58
  global $wp;
59
  $wp->add_query_var('loginFacebook');
60
  $wp->add_query_var('loginFacebookdoauth');
61
  }
 
62
 
63
-
 
 
64
  add_action('parse_request', new_fb_login);
65
  function new_fb_login(){
66
- global $wp, $wpdb;
67
  if($wp->request == 'loginFacebook' || isset($wp->query_vars['loginFacebook']) ){
68
  require(dirname(__FILE__).'/sdk/init.php');
69
 
70
  $user = $facebook->getUser();
71
 
72
- if ($user && is_user_logged_in()) {
73
  header( 'Location: '.$_GET['redirect'] ) ;
74
  exit;
75
  }else{
76
- $loginUrl = $facebook->getLoginUrl(array('redirect_uri' => site_url().'?loginFacebookdoauth=1') );
77
  $_SESSION['redirect'] = isset($_GET['redirect']) ? $_GET['redirect'] : site_url();
78
  header( 'Location: '.$loginUrl ) ;
79
  exit;
@@ -89,32 +124,75 @@ function new_fb_login(){
89
  $ID = $wpdb->get_var($wpdb->prepare('
90
  SELECT ID FROM '.$wpdb->prefix.'social_users WHERE type = "fb" AND identifier = "'.$user_profile['id'].'"
91
  '));
92
- if($ID == NULL){ // Register
93
- $ID = email_exists($user_profile['email']);
94
- if($ID == false){ // Real register
95
- $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
96
- $ID = wp_create_user( 'Facebook - '.$user_profile['name'], $random_password, $user_profile['email'] );
97
- }
98
- $wpdb->insert(
99
- $wpdb->prefix.'social_users',
100
- array(
101
- 'ID' => $ID,
102
- 'type' => 'fb',
103
- 'identifier' => $user_profile['id']
104
- ),
105
- array(
106
- '%d',
107
- '%s',
108
- '%s'
109
- )
110
- );
111
  }
112
-
113
- if($ID){ // Login
114
- wp_set_auth_cookie($ID, true, false);
115
- header( 'Location: '.$_SESSION['redirect'] );
116
- unset($_SESSION['redirect']);
117
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
119
  exit;
120
  } catch (FacebookApiException $e) {
@@ -129,12 +207,100 @@ function new_fb_login(){
129
  }
130
  }
131
 
132
- function new_fb_login_url(){
133
- return site_url('loginFacebook');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- /* Options Page */
 
 
138
  require_once(trailingslashit(dirname(__FILE__)) . "nextend-facebook-settings.php");
139
 
140
  if(class_exists('NextendFBSettings')) {
@@ -145,9 +311,9 @@ if(class_exists('NextendFBSettings')) {
145
  }
146
  }
147
 
148
- add_filter( 'plugin_action_links', 'nextend_fb_plugin_action_links', 10, 2 );
149
 
150
- function nextend_fb_plugin_action_links( $links, $file ) {
151
  if ( $file != NEW_FB_LOGIN_PLUGIN_BASENAME )
152
  return $links;
153
  $settings_link = '<a href="' . menu_page_url( 'nextend-facebook-connect', false ) . '">'
@@ -156,4 +322,36 @@ function nextend_fb_plugin_action_links( $links, $file ) {
156
  array_unshift( $links, $settings_link );
157
 
158
  return $links;
159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: Nextend Facebook Connect
4
  Plugin URI: http://nextendweb.com/
5
  Description: This plugins helps you create Facebook login and register buttons. The login and register process only takes one click.
6
+ Version: 1.4
7
  Author: Roland Soos
8
  License: GPL2
9
  */
23
  along with this program; if not, write to the Free Software
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
+ global $new_fb_settings;
27
 
28
  define( 'NEW_FB_LOGIN', 1 );
29
  if ( ! defined( 'NEW_FB_LOGIN_PLUGIN_BASENAME' ) )
30
  define( 'NEW_FB_LOGIN_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
 
 
31
 
32
+ $new_fb_settings = maybe_unserialize(get_option('nextend_fb_connect'));
33
+
34
+ /*
35
+ Sessions required for the profile notices
36
+ */
37
+ function new_fb_start_session() {
38
+ if(!session_id()) {
39
+ session_start();
40
+ }
41
+ }
42
+
43
+ function new_fb_end_session() {
44
+ session_destroy ();
45
+ }
46
+
47
+ add_action('init', 'new_fb_start_session', 1);
48
+ add_action('wp_logout', 'new_fb_end_session');
49
+ add_action('wp_login', 'new_fb_end_session');
50
+
51
+ /*
52
+ Loading style for buttons
53
+ */
54
+ function nextend_fb_connect_stylesheet(){
55
+ wp_register_style( 'nextend_fb_connect_stylesheet', plugins_url('buttons/facebook-btn.css', __FILE__) );
56
+ wp_enqueue_style( 'nextend_fb_connect_stylesheet' );
57
+ }
58
+
59
+ if(!isset($new_fb_settings['fb_load_style'])) $new_fb_settings['fb_load_style'] = 1;
60
+ if($new_fb_settings['fb_load_style']){
61
+ add_action( 'wp_enqueue_scripts', 'nextend_fb_connect_stylesheet' );
62
+ add_action( 'login_enqueue_scripts', 'nextend_fb_connect_stylesheet' );
63
+ add_action( 'admin_enqueue_scripts', 'nextend_fb_connect_stylesheet' );
64
+ }
65
+
66
+ /*
67
+ Creating the required table on installation
68
+ */
69
  function nextend_fb_connect_install(){
70
  global $wpdb;
71
 
80
 
81
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
82
  dbDelta($sql);
 
 
 
 
 
 
83
  }
84
+ register_activation_hook(__FILE__, 'nextend_fb_connect_install');
85
 
86
+ /*
87
+ Adding query vars for the WP parser
88
+ */
89
  function new_fb_add_query_var(){
90
  global $wp;
91
  $wp->add_query_var('loginFacebook');
92
  $wp->add_query_var('loginFacebookdoauth');
93
  }
94
+ add_filter('init', 'new_fb_add_query_var');
95
 
96
+ /* -----------------------------------------------------------------------------
97
+ Main function to handle the Sign in/Register/Linking process
98
+ ----------------------------------------------------------------------------- */
99
  add_action('parse_request', new_fb_login);
100
  function new_fb_login(){
101
+ global $wp, $wpdb, $new_fb_settings;
102
  if($wp->request == 'loginFacebook' || isset($wp->query_vars['loginFacebook']) ){
103
  require(dirname(__FILE__).'/sdk/init.php');
104
 
105
  $user = $facebook->getUser();
106
 
107
+ if ($user && is_user_logged_in() && new_fb_is_user_connected()) {
108
  header( 'Location: '.$_GET['redirect'] ) ;
109
  exit;
110
  }else{
111
+ $loginUrl = $facebook->getLoginUrl(array('redirect_uri' => site_url('index.php').'?loginFacebookdoauth=1') );
112
  $_SESSION['redirect'] = isset($_GET['redirect']) ? $_GET['redirect'] : site_url();
113
  header( 'Location: '.$loginUrl ) ;
114
  exit;
124
  $ID = $wpdb->get_var($wpdb->prepare('
125
  SELECT ID FROM '.$wpdb->prefix.'social_users WHERE type = "fb" AND identifier = "'.$user_profile['id'].'"
126
  '));
127
+ if(!get_user_by('id',$ID)){
128
+ $wpdb->query($wpdb->prepare('
129
+ DELETE FROM '.$wpdb->prefix.'social_users WHERE ID = "'.$ID.'"
130
+ '));
131
+ $ID = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
+ if(!is_user_logged_in()){
134
+ if($ID == NULL){ // Register
135
+ $ID = email_exists($user_profile['email']);
136
+ if($ID == false){ // Real register
137
+ $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
138
+ $settings = maybe_unserialize(get_option('nextend_fb_connect'));
139
+
140
+ if(!isset($settings['fb_user_prefix'])) $settings['fb_user_prefix'] = 'facebook-';
141
+ if(!isset($user_profile['email'])) $user_profile['email'] = $user_profile['id'].'@facebook.com';
142
+ $ID = wp_create_user( $settings['fb_user_prefix'].$user_profile['name'], $random_password, $user_profile['email'] );
143
+ }
144
+ $wpdb->insert(
145
+ $wpdb->prefix.'social_users',
146
+ array(
147
+ 'ID' => $ID,
148
+ 'type' => 'fb',
149
+ 'identifier' => $user_profile['id']
150
+ ),
151
+ array(
152
+ '%d',
153
+ '%s',
154
+ '%s'
155
+ )
156
+ );
157
+ }
158
+
159
+ if($ID){ // Login
160
+ wp_set_auth_cookie($ID, true, false);
161
+ do_action('wp_login', $settings['fb_user_prefix'].$user_profile['name']);
162
+ header( 'Location: '.$_SESSION['redirect'] );
163
+ unset($_SESSION['redirect']);
164
+ exit;
165
+ }
166
+ }else{
167
+ $current_user = wp_get_current_user();
168
+ if($current_user->ID == $ID){ // It was a simple login
169
+ header( 'Location: '.$_SESSION['redirect'] );
170
+ unset($_SESSION['redirect']);
171
+ exit;
172
+ }elseif($ID === NULL){ // Let's connect the accout to the current user!
173
+ $wpdb->insert(
174
+ $wpdb->prefix.'social_users',
175
+ array(
176
+ 'ID' => $current_user->ID,
177
+ 'type' => 'fb',
178
+ 'identifier' => $user_profile['id']
179
+ ),
180
+ array(
181
+ '%d',
182
+ '%s',
183
+ '%s'
184
+ )
185
+ );
186
+ $_SESSION['new_fb_admin_notice'] = __('Your Facebook profile is successfully linked with your account. Now you can sign in with Facebook easily.', 'nextend-facebook-connect');
187
+ header( 'Location: '.$_SESSION['redirect'] );
188
+ unset($_SESSION['redirect']);
189
+ exit;
190
+ }else{
191
+ $_SESSION['new_fb_admin_notice'] = __('This Facebook profile is already linked with other account. Linking process failed!', 'nextend-facebook-connect');
192
+ header( 'Location: '.$_SESSION['redirect'] );
193
+ unset($_SESSION['redirect']);
194
+ exit;
195
+ }
196
  }
197
  exit;
198
  } catch (FacebookApiException $e) {
207
  }
208
  }
209
 
210
+ /*
211
+ Is the current user connected the Facebook profile?
212
+ */
213
+ function new_fb_is_user_connected(){
214
+ global $wpdb;
215
+ $current_user = wp_get_current_user();
216
+ $ID = $wpdb->get_var($wpdb->prepare('
217
+ SELECT ID FROM '.$wpdb->prefix.'social_users WHERE type = "fb" AND ID = "'.$current_user->ID.'"
218
+ '));
219
+ if($ID === NULL) return false;
220
+ return true;
221
+ }
222
+
223
+ /*
224
+ Connect Field in the Profile page
225
+ */
226
+ function new_add_fb_connect_field() {
227
+ global $new_is_social_header;
228
+ if($new_is_social_header === NULL){
229
+ ?>
230
+ <h3>Social connect</h3>
231
+ <?php
232
+ $new_is_social_header = true;
233
+ }
234
+ ?>
235
+ <table class="form-table">
236
+ <tbody>
237
+ <tr>
238
+ <th>
239
+ </th>
240
+ <td>
241
+ <?php if(!new_fb_is_user_connected()): ?>
242
+ <?php echo new_fb_link_button() ?>
243
+ <?php endif; ?>
244
+ </td>
245
+ </tr>
246
+ </tbody>
247
+ </table>
248
+ <?php
249
+ }
250
+ add_action('profile_personal_options', 'new_add_fb_connect_field');
251
+
252
+ function new_add_fb_login_form(){
253
+ ?>
254
+ <script>
255
+ var has_social_form = false;
256
+ var socialLogins = null;
257
+ jQuery(document).ready(function(){
258
+ (function($) {
259
+ if(!has_social_form){
260
+ has_social_form = true;
261
+ var loginForm = $('#loginform');
262
+ socialLogins = $('<div class="newsociallogins" style="text-align: center;"><div style="clear:both;"></div></div>');
263
+ loginForm.prepend("<h3 style='text-align:center;'>OR</h3>");
264
+ loginForm.prepend(socialLogins);
265
+ }
266
+ socialLogins.prepend('<?php echo addslashes(new_fb_sign_button()); ?>');
267
+ }(jQuery));
268
+ });
269
+ </script>
270
+ <?php
271
  }
272
 
273
+ add_action('login_form', 'new_add_fb_login_form');
274
+
275
+ /*if(isset($new_fb_settings['fb_import_avatar']) && $new_fb_settings['fb_import_avatar']){
276
+ add_filter( 'get_avatar', 'new_fb_insert_avatar', 100, 5 );
277
+
278
+ function new_fb_insert_avatar( $avatar, $id_or_email, $size, $default, $alt ) {
279
+
280
+ if ( strpos( $default, $this->url ) !== false ) {
281
+ $email = empty( $email ) ? 'nobody' : md5( $email );
282
+
283
+ // 'www' version for WP2.9 and older
284
+ if ( strpos( $default, 'http://0.gravatar.com/avatar/') === 0 || strpos( $default, 'http://www.gravatar.com/avatar/') === 0 )
285
+ $avatar = str_replace( $default, 'asd'."&size={$size}x{$size}", $avatar );
286
+
287
+ //otherwise, just swap the placeholder with the hash
288
+ $avatar = str_replace( 'emailhash', $email, $avatar );
289
+
290
+ //this is ugly, but has to be done
291
+ //make sure we pass the correct size params to the generated avatar
292
+ $avatar = str_replace( '%3F', "%3Fsize={$size}x{$size}%26", $avatar );
293
+
294
+ }
295
+
296
+ file_put_contents(dirname(__FILE__).'/asd.txt', $avatar."\n", FILE_APPEND);
297
+ return $avatar;
298
+ }
299
+ }*/
300
 
301
+ /*
302
+ Options Page
303
+ */
304
  require_once(trailingslashit(dirname(__FILE__)) . "nextend-facebook-settings.php");
305
 
306
  if(class_exists('NextendFBSettings')) {
311
  }
312
  }
313
 
314
+ add_filter( 'plugin_action_links', 'new_fb_plugin_action_links', 10, 2 );
315
 
316
+ function new_fb_plugin_action_links( $links, $file ) {
317
  if ( $file != NEW_FB_LOGIN_PLUGIN_BASENAME )
318
  return $links;
319
  $settings_link = '<a href="' . menu_page_url( 'nextend-facebook-connect', false ) . '">'
322
  array_unshift( $links, $settings_link );
323
 
324
  return $links;
325
+ }
326
+
327
+ /* -----------------------------------------------------------------------------
328
+ Miscellaneous functions
329
+ ----------------------------------------------------------------------------- */
330
+ function new_fb_sign_button(){
331
+ global $new_fb_settings;
332
+ return '<a href="'.new_fb_login_url().'">'.$new_fb_settings['fb_login_button'].'</a><br />';
333
+ }
334
+
335
+ function new_fb_link_button(){
336
+ global $new_fb_settings;
337
+ return '<a href="'.new_fb_login_url().'&redirect='.site_url().$_SERVER["REQUEST_URI"].'">'.$new_fb_settings['fb_link_button'].'</a><br />';
338
+ }
339
+
340
+
341
+ function new_fb_login_url(){
342
+ return site_url('index.php').'?loginFacebook=1';
343
+ }
344
+
345
+
346
+ /*
347
+ Session notices used in the profile settings
348
+ */
349
+ function new_fb_admin_notice(){
350
+ if(isset($_SESSION['new_fb_admin_notice'])){
351
+ echo '<div class="updated">
352
+ <p>'.$_SESSION['new_fb_admin_notice'].'</p>
353
+ </div>';
354
+ unset($_SESSION['new_fb_admin_notice']);
355
+ }
356
+ }
357
+ add_action('admin_notices', 'new_fb_admin_notice');
nextend-facebook-settings.php CHANGED
@@ -57,10 +57,10 @@ function NextendFB_Options_Page() {
57
  </p>
58
  <h3><?php _e('Usage', 'nextend-facebook-connect'); ?></h3>
59
  <h4><?php _e('Simple link', 'nextend-facebook-connect'); ?></h4>
60
- <p><?php _e('&lt;a href="'.get_option('siteurl').'/loginFacebook?redirect='.get_option('siteurl').'" onclick="window.location = \''.get_option('siteurl').'/loginFacebook?redirect=\'+window.location.href; return false;"&gt;Click here to login or register with Facebook&lt;/a&gt;', 'nextend-facebook-connect'); ?></p>
61
 
62
  <h4><?php _e('Image button', 'nextend-facebook-connect'); ?></h4>
63
- <p><?php _e('&lt;a href="'.get_option('siteurl').'/loginFacebook?redirect='.get_option('siteurl').'" onclick="window.location = \''.get_option('siteurl').'/loginFacebook?redirect=\'+window.location.href; return false;"&gt; &lt;img src="HereComeTheImage" /&gt; &lt;/a&gt;', 'nextend-facebook-connect'); ?></p>
64
 
65
  <h3><?php _e('Note', 'nextend-facebook-connect'); ?></h3>
66
  <p><?php _e('If the Facebook user\'s email address already used by another member of your site, the facebook profile will be automatically linked to the existing profile!', 'nextend-facebook-connect'); ?></p>
@@ -76,8 +76,12 @@ function NextendFB_Options_Page() {
76
  <div id="newfb-about" class="postbox">
77
  <h3 class="hndle"><?php _e('About this plugin', 'nextend-facebook-connect'); ?></h3>
78
  <div class="inside"><ul>
79
- <li><a href="http://wordpress.org/extend/plugins/nextend-facebook-connect/"><?php _e('Plugin URI', 'nextend-facebook-connect'); ?></a></li>
80
- <li><a href="http://profiles.wordpress.org/nextendweb" target="_blank"><?php _e('Author URI', 'nextend-facebook-connect'); ?></a></li>
 
 
 
 
81
  </ul></div>
82
  </div>
83
  <!--about end-->
@@ -107,14 +111,53 @@ function NextendFB_Options_Page() {
107
  <td>
108
  <input type="text" name="fb_appid" value="<?php echo $nextend_fb_connect['fb_appid']; ?>" />
109
  </td>
110
- </tr>
111
-
112
  <tr>
113
  <th scope="row"><?php _e('Facebook App Secret:', 'nextend-facebook-connect'); ?></th>
114
  <td>
115
  <input type="text" name="fb_secret" value="<?php echo $nextend_fb_connect['fb_secret']; ?>" />
116
  </td>
117
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  </table>
119
 
120
  <p class="submit">
57
  </p>
58
  <h3><?php _e('Usage', 'nextend-facebook-connect'); ?></h3>
59
  <h4><?php _e('Simple link', 'nextend-facebook-connect'); ?></h4>
60
+ <p><?php _e('&lt;a href="'.get_option('siteurl').'?loginFacebook=1&redirect='.get_option('siteurl').'" onclick="window.location = \''.get_option('siteurl').'?loginFacebook=1&redirect=\'+window.location.href; return false;"&gt;Click here to login or register with Facebook&lt;/a&gt;', 'nextend-facebook-connect'); ?></p>
61
 
62
  <h4><?php _e('Image button', 'nextend-facebook-connect'); ?></h4>
63
+ <p><?php _e('&lt;a href="'.get_option('siteurl').'?loginFacebook=1&redirect='.get_option('siteurl').'" onclick="window.location = \''.get_option('siteurl').'?loginFacebook=1&redirect=\'+window.location.href; return false;"&gt; &lt;img src="HereComeTheImage" /&gt; &lt;/a&gt;', 'nextend-facebook-connect'); ?></p>
64
 
65
  <h3><?php _e('Note', 'nextend-facebook-connect'); ?></h3>
66
  <p><?php _e('If the Facebook user\'s email address already used by another member of your site, the facebook profile will be automatically linked to the existing profile!', 'nextend-facebook-connect'); ?></p>
76
  <div id="newfb-about" class="postbox">
77
  <h3 class="hndle"><?php _e('About this plugin', 'nextend-facebook-connect'); ?></h3>
78
  <div class="inside"><ul>
79
+
80
+ <li><a href="http://www.nextendweb.com/social-connect-plugins-for-wordpress.html" target="_blank"><?php _e('Check the realted <b>blog post</b>!', 'nextend-facebook-connect'); ?></a></li>
81
+ <li><br></li>
82
+ <li><a href="http://wordpress.org/extend/plugins/nextend-facebook-connect/" target="_blank"><?php _e('Nextend Facebook Connect', 'nextend-facebook-connect'); ?></a></li>
83
+ <li><br></li>
84
+ <li><a href="http://profiles.wordpress.org/nextendweb" target="_blank"><?php _e('Nextend plugins at WordPress.org', 'nextend-facebook-connect'); ?></a></li>
85
  </ul></div>
86
  </div>
87
  <!--about end-->
111
  <td>
112
  <input type="text" name="fb_appid" value="<?php echo $nextend_fb_connect['fb_appid']; ?>" />
113
  </td>
114
+ </tr>
115
+
116
  <tr>
117
  <th scope="row"><?php _e('Facebook App Secret:', 'nextend-facebook-connect'); ?></th>
118
  <td>
119
  <input type="text" name="fb_secret" value="<?php echo $nextend_fb_connect['fb_secret']; ?>" />
120
  </td>
121
  </tr>
122
+
123
+ <tr>
124
+ <th scope="row"><?php _e('New user prefix:', 'nextend-facebook-connect'); ?></th>
125
+ <td>
126
+ <?php if(!isset($nextend_fb_connect['fb_user_prefix'])) $nextend_fb_connect['fb_user_prefix'] = 'Facebook - '; ?>
127
+ <input type="text" name="fb_user_prefix" value="<?php echo $nextend_fb_connect['fb_user_prefix']; ?>" />
128
+ </td>
129
+ </tr>
130
+
131
+ <tr>
132
+ <th scope="row"><?php _e('Load button stylesheet:', 'nextend-facebook-connect'); ?></th>
133
+ <td>
134
+ <?php if(!isset($nextend_fb_connect['fb_load_style'])) $nextend_fb_connect['fb_load_style'] = 1; ?>
135
+ <input name="fb_load_style" id="fb_load_style_yes" value="1" type="radio" <?php if(isset($nextend_fb_connect['fb_load_style']) && $nextend_fb_connect['fb_load_style']){?> checked <?php } ?>> Yes &nbsp;&nbsp;&nbsp;&nbsp;
136
+ <input name="fb_load_style" id="fb_load_style_no" value="0" type="radio" <?php if(isset($nextend_fb_connect['fb_load_style']) && $nextend_fb_connect['fb_load_style'] == 0){?> checked <?php } ?>> No
137
+ </td>
138
+ </tr>
139
+
140
+ <tr>
141
+ <th scope="row"><?php _e('Login button:', 'nextend-facebook-connect'); ?></th>
142
+ <td>
143
+ <?php if(!isset($nextend_fb_connect['fb_login_button'])) $nextend_fb_connect['fb_login_button'] = '<div class="new-fb-btn new-fb-1 new-fb-default-anim"><div class="new-fb-1-1"><div class="new-fb-1-1-1">CONNECT WITH</div></div></div>'; ?>
144
+ <textarea cols="83" rows="3" name="fb_login_button"><?php echo $nextend_fb_connect['fb_login_button']; ?></textarea>
145
+ </td>
146
+ </tr>
147
+
148
+ <tr>
149
+ <th scope="row"><?php _e('Link account button:', 'nextend-facebook-connect'); ?></th>
150
+ <td>
151
+ <?php if(!isset($nextend_fb_connect['fb_link_button'])) $nextend_fb_connect['fb_link_button'] = '<div class="new-fb-btn new-fb-1 new-fb-default-anim"><div class="new-fb-1-1"><div class="new-fb-1-1-1">LINK ACCOUNT TO</div></div></div>'; ?>
152
+ <textarea cols="83" rows="3" name="fb_link_button"><?php echo $nextend_fb_connect['fb_link_button']; ?></textarea>
153
+ </td>
154
+ </tr>
155
+ <tr>
156
+ <th scope="row"></th>
157
+ <td>
158
+ <a href="http://www.nextendweb.com/social-connect-button-generator" target="_blank"><img style="margin-left: -4px;" src="<?php echo plugins_url('generatorbanner.png', __FILE__); ?>" /></a>
159
+ </td>
160
+ </tr>
161
  </table>
162
 
163
  <p class="submit">
readme.txt CHANGED
@@ -3,16 +3,39 @@ Contributors: nextendweb
3
  Tags: facebook, register, login, social connect, social, facebook connect
4
  Requires at least: 3.0
5
  Tested up to: 3.4
6
- Stable tag: 1.2
 
 
7
 
8
- This plugins helps you create Facebook login and register buttons. The login and register process only takes one click.
9
 
10
  == Description ==
11
 
12
- This plugins helps you create Facebook login and register buttons. The login and register process only takes one click and you can fully customize the buttons with images and other assets.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  #### Usage
15
 
 
 
 
 
 
 
16
 
17
  **Simple link**
18
 
@@ -34,7 +57,16 @@ This plugins helps you create Facebook login and register buttons. The login and
34
  8. Click on Save changes and the top of the page contains the App Id and App secret which you have to copy and past below.
35
  9. Save changes!
36
 
 
 
 
 
 
 
37
  == Changelog ==
38
 
 
 
 
39
  = 1.2 =
40
  * Fixed a bug when the htaccess short urls not enabled.
3
  Tags: facebook, register, login, social connect, social, facebook connect
4
  Requires at least: 3.0
5
  Tested up to: 3.4
6
+ Stable tag: 1.4
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
+ One click registration & login plugin for Facebook? Easy installation? Is it totally free and comes with support? Yeah!
11
 
12
  == Description ==
13
 
14
+ Check the [DEMO](http://www.nextendweb.com/wp-login.php) on our site.
15
+
16
+ Also we created a [Social Connect button generator](http://www.nextendweb.com/social-connect-button-generator) which work with this plugin fine. This allows you to create fancy login buttons.
17
+
18
+ Personally, I hate to fill out registration forms, waiting for confirmation e-mails, so we designed this plugin for our website. Now, we want to share this very usable plugin with everyone, for free!
19
+
20
+ **Why should you choose Nextend Facebook Connect plugin from the many social plugins?**
21
+
22
+ * If your visitors have a Facebook profile, they can register your site with a single click, and later to log in too.
23
+ * The previously registered users can simply attach their existing Facebook profile to their account, so in the future, they can logging in with the one social button.
24
+ * The plugin has multiple desings, so it fits all kind of websites smoothly and elegantly. - Soon
25
+ * Very simple to use.
26
+ * Fast and helpful support.
27
+ * Totally free.
28
+
29
+ Don’t forget to follow us on Facebook and Twitter!
30
 
31
  #### Usage
32
 
33
+ After you activated the plugin, the plugin will autmatically
34
+ * add the login buttons to the WordPress login page. See screenshot #1
35
+ * add the account linking buttons to the WordPress profile page. See screenshot #2
36
+
37
+
38
+ #### Advanced usage
39
 
40
  **Simple link**
41
 
57
  8. Click on Save changes and the top of the page contains the App Id and App secret which you have to copy and past below.
58
  9. Save changes!
59
 
60
+
61
+ == Screenshots ==
62
+
63
+ 1. Our Social Connect plugins on the main WP login page
64
+ 2. Our Social Connect plugins in the profile page for account linking
65
+
66
  == Changelog ==
67
 
68
+ = 1.3 =
69
+ * Added linking option to the profile page, so an already registered user can easily link the profile with a Facebook profile.
70
+
71
  = 1.2 =
72
  * Fixed a bug when the htaccess short urls not enabled.