· 8 years ago · Jun 09, 2018, 02:30 PM
1<?php
2
3/*
4
5Plugin Name: WP Steam Auth
6
7Plugin URI: http://hwk.fr
8
9Description: Register, Login & Synchronize WP Users via Steam Authentification
10
11Author: hwk
12
13Version: 0.6.4
14
15Author URI: http://hwk.fr
16
17Licence: GPLv2
18
19*/
20
21
22
23if(!defined('ABSPATH')) {
24
25 die('You are not allowed to call this page directly.');
26
27}
28
29
30
31///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
32
33
34
35defined( 'WP_STEAM_AUTH_PLUGIN_ABS_PATH' ) || define( 'WP_STEAM_AUTH_PLUGIN_ABS_PATH', plugin_dir_path( __FILE__ ) );
36
37
38
39///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40
41
42
43// wpSAP: Config
44
45$wpsapConfig['domainName'] = get_site_url();
46
47$wpsapConfig['apiKey'] = get_option('wpsapSettings_apiKey');
48
49$wpsapConfig['logoutRedirect'] = get_option('wpsapSettings_logoutRedirect');
50
51$wpsapConfig['loginRedirect'] = get_option('wpsapSettings_loginRedirect');
52
53$wpsapConfig['logoutRedirectReferer'] = (get_option('wpsapSettings_logoutRedirectReferer') == 'checked') ? true : false;
54
55$wpsapConfig['loginRedirectReferer'] = (get_option('wpsapSettings_loginRedirectReferer') == 'checked') ? true : false;
56
57
58
59$wpsapOptions['avatarUpload'] = (get_option('wpsapOption_avatarUpload') == 'checked') ? true : false;
60
61$wpsapOptions['avatarEnabled'] = (get_option('wpsapOption_avatarEnabled') == 'checked') ? true : false;
62
63$wpsapOptions['enablePopup'] = (get_option('wpsapOption_popupEnabled') == 'checked') ? true : false;
64
65
66
67$wpsapConfig['slugSteamApp'] = get_option('wpsapSettings_steamAppUrl');
68
69$wpsapConfig['slugLogin'] = get_option('wpsapSettings_steamAppLoginUrl');
70
71$wpsapConfig['slugLogged'] = 'logged';
72
73$wpsapConfig['slugSync'] = get_option('wpsapSettings_steamAppSyncUrl');
74
75$wpsapConfig['slugLogout'] = get_option('wpsapSettings_steamAppLogoutUrl');
76
77
78
79$wpsapOptions['metaFields'] = array('steamid','communityvisibilitystate','profilestate','personaname','lastlogoff','profileurl','avatar','avatarmedium','avatarfull','personastate','primaryclanid','timecreated','realname','uptodate');
80
81
82
83///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
84
85
86
87require( WP_STEAM_AUTH_PLUGIN_ABS_PATH . 'inc/filters.php');
88
89require( WP_STEAM_AUTH_PLUGIN_ABS_PATH . 'inc/shortcodes.php');
90
91
92
93///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
94
95
96
97// wpSAP: init
98
99add_action( 'wp', 'wpsap_init' );
100
101function wpsap_init(){
102
103
104
105 global $wpsapConfig, $wpsapOptions;
106
107
108
109 require( WP_STEAM_AUTH_PLUGIN_ABS_PATH . 'inc/modifiers.php');
110
111 require( WP_STEAM_AUTH_PLUGIN_ABS_PATH . 'inc/functions.php');
112
113
114
115 if( !empty($wpsapConfig['apiKey']) ){
116
117
118
119 // WpSAP: Register JS
120
121 if($wpsapOptions['enablePopup'] == 'checked'){
122
123 wp_register_script('wpsap-js', plugin_dir_url(__FILE__) . '/js/wp-steam-auth.min.js', '', '', true);
124
125 wp_enqueue_script('wpsap-js');
126
127 }
128
129
130
131
132
133 // wpSAP: Action Login / Sync
134
135 if( get_query_var('wpsap_action') == 'login' || get_query_var('wpsap_action') == 'sync' ){
136
137
138
139 // OpenID
140
141 if( !class_exists('LightOpenID') ){
142
143 require( WP_STEAM_AUTH_PLUGIN_ABS_PATH . 'library/openid.php');
144
145 }
146
147
148
149 try{
150
151 $openid = new LightOpenID($wpsapConfig['domainName']);
152
153
154
155 // Auth
156
157 if(!$openid->mode){
158
159 $openid->identity = 'http://steamcommunity.com/openid';
160
161 wp_redirect( $openid->authUrl() );
162
163 exit;
164
165
166
167 // Cancel
168
169 }elseif($openid->mode == 'cancel'){
170
171 echo 'User has canceled authentication!';
172
173
174
175 }else{
176
177
178
179 // Success!
180
181 if($openid->validate()){
182
183 $identity = $openid->identity;
184
185
186 $pattern = "/^https:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
187
188 preg_match($pattern, $identity, $matches);
189
190 $currentSteamId = $matches[1];
191
192
193
194 // Wordpress Operations
195
196 // --------------------
197
198
199
200 // wpUser: steamId Exists?
201
202 $args = array(
203
204 'meta_key' => 'steam_steamid',
205
206 'meta_value' => $currentSteamId,
207
208 'meta_compare' => '='
209
210 );
211
212 $findUser = get_users($args);
213
214 $findUser = $findUser[0];
215
216
217
218 // wpUser: Create user
219
220 if( empty($findUser) ){
221
222
223
224 $wpsapProfile = wpsap_sync_steam_profile($currentSteamId);
225
226
227
228 if(!$wpsapProfile)
229
230 return;
231
232
233
234 if(get_query_var('wpsap_action') == 'sync' && is_user_logged_in()){
235
236 $wpUserId = get_current_user_id();
237
238
239
240 }elseif(get_query_var('wpsap_action') == 'login'){
241
242 $wpUserName = $wpsapProfile['steam_personaname'];
243
244 $wpUserMail = $wpsapProfile['steam_steamid'].'@steam.com';
245
246 $wpUserPassword = wp_generate_password(12, true);
247
248 $wpUserId = wp_create_user( $wpUserName, $wpUserPassword, $wpUserMail );
249
250
251
252 }
253
254
255
256 if(!empty($wpUserId)){
257
258 foreach($wpsapProfile as $name => $value){
259
260 update_user_meta( $wpUserId, $name, $value );
261
262 }
263
264 }
265
266
267
268 if($wpsapOptions['avatarUpload']){
269
270 $wpsapUserAvatarUrl = wpsap_upload_avatar( $wpsapProfile['steam_avatarfull'], $wpUserId, sanitize_title($wpsapProfile['steam_personaname']) );
271
272 update_user_meta( $wpUserId, 'steam_wp_avatar', $wpsapUserAvatarUrl );
273
274 }
275
276
277
278 // wpUser: Found user
279
280 }else{
281
282 $wpUserId = $findUser->ID;
283
284
285
286 $wpsapGetForceResync = get_user_meta($wpUserId, 'steam_force_resync', true);
287
288 if($wpsapGetForceResync == 1){
289
290
291
292 $wpsapProfile = wpsap_sync_steam_profile($currentSteamId);
293
294
295
296 if(!$wpsapProfile)
297
298 return;
299
300
301
302 foreach($wpsapProfile as $name => $value){
303
304 update_user_meta( $wpUserId, $name, $value );
305
306 }
307
308
309
310 if($wpsapOptions['avatarUpload']){
311
312 $wpsapUserAvatarUrl = wpsap_upload_avatar( $wpsapProfile['steam_avatarfull'], $wpUserId, sanitize_title($wpsapProfile['steam_personaname']) );
313
314 update_user_meta( $wpUserId, 'steam_wp_avatar', $wpsapUserAvatarUrl );
315
316 }
317
318
319
320 delete_user_meta($wpUserId, 'steam_force_resync');
321
322
323
324 }
325
326
327
328 }
329
330
331
332 // wpUser: Login Auth
333
334 wp_set_auth_cookie( $wpUserId, true );
335
336
337
338 // Redirect
339
340 if (!headers_sent()) {
341
342 wp_redirect( $wpsapConfig['loginRedirect'] );
343
344 exit;
345
346
347
348 }else{ ?>
349
350 <script type="text/javascript">
351
352 window.location.href = "<?php echo $wpsapConfig['loginRedirect']; ?>";
353
354 </script>
355
356 <noscript>
357
358 <meta http-equiv="refresh" content="0;url=<?php echo $wpsapConfig['loginRedirect']; ?>" />
359
360 </noscript>
361
362 <?php
363
364 exit;
365
366 }
367
368
369
370 // Error!
371
372 }else{
373
374 echo 'User is not logged in.'."\n";
375
376
377
378 }
379
380 }
381
382
383
384 // Error
385
386 }catch(ErrorException $e){
387
388 echo $e->getMessage();
389
390
391
392 }
393
394
395
396
397
398 // wpSAP: Logged + Popup
399
400 }elseif( get_query_var('wpsap_action') == 'logged' && $wpsapOptions['enablePopup'] ){
401
402 echo '<script type="text/javascript">';
403
404 echo 'window.close();';
405
406 echo '</script>';
407
408 echo '<meta http-equiv="refresh" content="1;url=' . $wpsapConfig['domainName'] . '" />';
409
410 exit;
411
412
413
414
415
416
417
418 // wpSAP: Logout
419
420 }elseif( get_query_var('wpsap_action') == 'logout' ){
421
422 wp_logout();
423
424 wp_redirect( $wpsapConfig['logoutRedirect'] );
425
426 exit;
427
428
429
430 }
431
432
433
434 }
435
436
437
438}
439
440
441
442///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
443
444
445
446add_action('admin_menu', 'wpsap_admin_menu');
447
448function wpsap_admin_menu(){
449
450 $menu = add_submenu_page('options-general.php', 'WP Steam Auth', 'WP Steam Auth', 'manage_options', 'wp-steam-auth', 'wpsap_admin_page');
451
452 add_action( 'admin_print_styles-' . $menu, 'wpsap_admin_css' );
453
454 add_action( 'admin_print_scripts-' . $menu, 'wpsap_admin_js' );
455
456}
457
458
459
460function wpsap_admin_css(){
461
462 wp_enqueue_style( 'stylesheet_admin', plugins_url('/css/admin.css', __FILE__) );
463
464}
465
466
467
468function wpsap_admin_js(){
469
470 wp_enqueue_script( 'jquery-functions', plugins_url('/js/admin.js', __FILE__), array( 'jquery' ) );
471
472}
473
474
475
476add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'wpsap_admin_plugins_link' );
477
478function wpsap_admin_plugins_link($links){
479
480 $mylinks = array(
481
482 '<a href="' . admin_url( 'options-general.php?page=wp-steam-auth' ) . '">Settings</a>',
483
484 );
485
486 return array_merge($links, $mylinks);
487
488}
489
490
491
492add_action( 'admin_init', 'wpsap_admin_settings' );
493
494function wpsap_admin_settings(){
495
496 register_setting( 'wpsap-settings-group', 'wpsapSettings_apiKey' );
497
498 register_setting( 'wpsap-settings-group', 'wpsapSettings_loginRedirect' );
499
500 register_setting( 'wpsap-settings-group', 'wpsapSettings_loginRedirectReferer' );
501
502 register_setting( 'wpsap-settings-group', 'wpsapSettings_logoutRedirect' );
503
504 register_setting( 'wpsap-settings-group', 'wpsapSettings_logoutRedirectReferer' );
505
506
507
508 register_setting( 'wpsap-settings-group', 'wpsapSettings_steamAppFlush' );
509
510 register_setting( 'wpsap-settings-group', 'wpsapSettings_steamAppUrl' );
511
512 register_setting( 'wpsap-settings-group', 'wpsapSettings_steamAppLoginUrl' );
513
514 register_setting( 'wpsap-settings-group', 'wpsapSettings_steamAppSyncUrl' );
515
516 register_setting( 'wpsap-settings-group', 'wpsapSettings_steamAppLogoutUrl' );
517
518
519
520 register_setting( 'wpsap-settings-group', 'wpsapOption_avatarUpload' );
521
522 register_setting( 'wpsap-settings-group', 'wpsapOption_avatarEnabled' );
523
524 register_setting( 'wpsap-settings-group', 'wpsapOption_popupEnabled' );
525
526
527
528 $wpsapSettings_steamAppUrl = get_option('wpsapSettings_steamAppUrl');
529
530 $wpsapSettings_steamAppLoginUrl = get_option('wpsapSettings_steamAppLoginUrl');
531
532 $wpsapSettings_steamAppSyncUrl = get_option('wpsapSettings_steamAppSyncUrl');
533
534 $wpsapSettings_steamAppLogoutUrl = get_option('wpsapSettings_steamAppLogoutUrl');
535
536
537
538 if(get_option('wpsapSettings_steamAppLoginUrl') == false){
539
540 update_option('wpsapSettings_steamAppLoginUrl', 'login');
541
542 }
543
544
545
546 if(get_option('wpsapSettings_steamAppSyncUrl') == false){
547
548 update_option('wpsapSettings_steamAppSyncUrl', 'sync');
549
550 }
551
552
553
554 if(get_option('wpsapSettings_steamAppLogoutUrl') == false){
555
556 update_option('wpsapSettings_steamAppLogoutUrl', 'logout');
557
558 }
559
560
561
562 $wpsapSettings_steamAppUrl = get_option('wpsapSettings_steamAppUrl');
563
564 $wpsapSettings_steamAppLoginUrl = get_option('wpsapSettings_steamAppLoginUrl');
565
566 $wpsapSettings_steamAppSyncUrl = get_option('wpsapSettings_steamAppSyncUrl');
567
568 $wpsapSettings_steamAppLogoutUrl = get_option('wpsapSettings_steamAppLogoutUrl');
569
570
571
572}
573
574
575
576///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
577
578
579
580function wpsap_admin_page() {
581
582$wpsapSettings_steamAppUrl = get_option('wpsapSettings_steamAppUrl');
583
584$wpsapSettings_steamAppLoginUrl = get_option('wpsapSettings_steamAppLoginUrl');
585
586$wpsapSettings_steamAppSyncUrl = get_option('wpsapSettings_steamAppSyncUrl');
587
588$wpsapSettings_steamAppLogoutUrl = get_option('wpsapSettings_steamAppLogoutUrl');
589
590?>
591
592
593
594<div class="wrap">
595
596
597
598 <h1>WP Steam Auth Plugin</h1>
599
600
601
602 <div id="poststuff">
603
604 <div id="post-body" class="metabox-holder">
605
606 <div id="post-body-content">
607
608
609
610 <form method="post" action="options.php" style="max-width:1530px;">
611
612 <?php settings_fields( 'wpsap-settings-group' ); ?>
613
614 <?php do_settings_sections( 'wpsap-settings-group' ); ?>
615
616 <input type="hidden" name="wpsap_admin_form_hidden" value="settings" />
617
618
619
620 <div class="row">
621
622 <div class="col-lg-7">
623
624
625
626 <div class="row">
627
628 <div class="col-lg-12">
629
630
631
632 <div class="postbox">
633
634 <h2 class="hndle"><span>Settings</span></h2>
635
636 <div class="inside">
637
638 <table class="form-table">
639
640 <tr valign="top">
641
642 <th scope="row" class="settinglabel"><label>Steam API Key <span class="text-danger">*</span></label></th>
643
644 <td class="settingfield">
645
646 <input type="text" name="wpsapSettings_apiKey" class="regular-text" value="<?php echo esc_attr( get_option('wpsapSettings_apiKey') ); ?>" placeholder="XXXXXXXXXXXXXXXXXXXXXXX" required />
647
648 <p>Login to <a href="https://steamcommunity.com/" target="_blank">Steam</a>, go to: <a href="http://steamcommunity.com/dev/apikey" target="_blank">http://steamcommunity.com/dev/apikey</a> & enter your Domain URL</p>
649
650 </td>
651
652 </tr>
653
654
655
656 <th scope="row" class="settinglabel"><label>Domain URL</label></th>
657
658 <td class="settingfield">
659
660 <?php echo get_site_url(); ?>
661
662 <p>Full Domain URL. Should be the same as the one provided in your Steam API</p>
663
664 </td>
665
666 </tr>
667
668
669
670 <th scope="row" class="settinglabel"><label>Post-Login Redirect <span class="text-danger">*</span></label></th>
671
672 <td class="settingfield">
673
674 <div class="wpsapSettings_loginRedirect">
675
676 <input type="text" name="wpsapSettings_loginRedirect" class="regular-text" value="<?php echo esc_attr( get_option('wpsapSettings_loginRedirect') ); ?>" placeholder="http://" />
677
678 <label><input type="checkbox" name="wpsapSettings_loginRedirectReferer" value="checked" <?php echo esc_attr( get_option('wpsapSettings_loginRedirectReferer') ); ?> /> Use referer instead</label>
679
680 <p>Use Absolute URL</p>
681
682 </div>
683
684 <div class="wpsapSettings_loginRedirect_alt">
685
686 <small><em class="text-muted">Popup Option enabled, no redirection needed</em></small>
687
688 </div>
689
690 </td>
691
692 </tr>
693
694
695
696 <th scope="row" class="settinglabel"><label>Post-Logout Redirect <span class="text-danger">*</span></label></th>
697
698 <td class="settingfield">
699
700 <input type="text" name="wpsapSettings_logoutRedirect" class="regular-text" value="<?php echo esc_attr( get_option('wpsapSettings_logoutRedirect') ); ?>" placeholder="http://" />
701
702 <label><input type="checkbox" name="wpsapSettings_logoutRedirectReferer" value="checked" <?php echo esc_attr( get_option('wpsapSettings_logoutRedirectReferer') ); ?> /> Use referer instead</label>
703
704 <p>Use Absolute URL</p>
705
706 </td>
707
708 </tr>
709
710
711
712 </table>
713
714 </div>
715
716 </div>
717
718
719
720
721
722 </div>
723
724
725
726 <div class="col-lg-12">
727
728
729
730 <div class="postbox">
731
732 <h2 class="hndle"><span>Permalinks & Rewriting</span></h2>
733
734 <div class="inside">
735
736 <input type="hidden" name="wpsapSettings_steamAppFlush" value="1" />
737
738 <table class="form-table">
739
740 <th scope="row" class="settinglabel"><label>Base URL Slug</label></th>
741
742 <td class="settingfield">
743
744 <input type="text" name="wpsapSettings_steamAppUrl" class="regular-text" value="<?php echo esc_attr( get_option('wpsapSettings_steamAppUrl') ); ?>" placeholder="" />
745
746 <p>Base slug for authentification. Can be blank.</p>
747
748 </td>
749
750 </tr>
751
752
753
754 <th scope="row" class="settinglabel"><label>Login slug <span class="text-danger">*</span></label></th>
755
756 <td class="settingfield">
757
758 <input type="text" name="wpsapSettings_steamAppLoginUrl" class="regular-text" value="<?php echo esc_attr( get_option('wpsapSettings_steamAppLoginUrl') ); ?>" placeholder="login" required />
759
760 <p>Login URL:
761
762 <code>
763
764 <?php
765
766 echo get_site_url();
767
768 echo '<span class="wpsapSettings_steamAppUrl_mirror">';
769
770 echo (!empty($wpsapSettings_steamAppUrl)) ? '/'.$wpsapSettings_steamAppUrl : '';
771
772 echo '</span>';
773
774 echo '/';
775
776 echo '<span class="wpsapSettings_steamAppLoginUrl_mirror">';
777
778 echo $wpsapSettings_steamAppLoginUrl;
779
780 echo '</span>';
781
782 echo user_trailingslashit('');
783
784 ?>
785
786 </code>
787
788 </p>
789
790 </td>
791
792 </tr>
793
794
795
796 <th scope="row" class="settinglabel"><label>Synchronize slug <span class="text-danger">*</span></label></th>
797
798 <td class="settingfield">
799
800 <input type="text" name="wpsapSettings_steamAppSyncUrl" class="regular-text" value="<?php echo esc_attr( get_option('wpsapSettings_steamAppSyncUrl') ); ?>" placeholder="sync" required />
801
802 <p>Synchronize URL:
803
804 <code>
805
806 <?php
807
808 echo get_site_url();
809
810 echo '<span class="wpsapSettings_steamAppUrl_mirror">';
811
812 echo (!empty($wpsapSettings_steamAppUrl)) ? '/'.$wpsapSettings_steamAppUrl : '';
813
814 echo '</span>';
815
816 echo '/';
817
818 echo '<span class="wpsapSettings_steamAppSyncUrl_mirror">';
819
820 echo $wpsapSettings_steamAppSyncUrl;
821
822 echo '</span>';
823
824 echo user_trailingslashit('');
825
826
827
828 ?>
829
830 </code>
831
832 </p>
833
834 </td>
835
836 </tr>
837
838
839
840 <th scope="row" class="settinglabel"><label>Logout slug <span class="text-danger">*</span></label></th>
841
842 <td class="settingfield">
843
844 <input type="text" name="wpsapSettings_steamAppLogoutUrl" class="regular-text" value="<?php echo esc_attr( get_option('wpsapSettings_steamAppLogoutUrl') ); ?>" placeholder="logout" required />
845
846 <p>Logout URL:
847
848 <code>
849
850 <?php
851
852 echo get_site_url();
853
854 echo '<span class="wpsapSettings_steamAppUrl_mirror">';
855
856 echo (!empty($wpsapSettings_steamAppUrl)) ? '/'.$wpsapSettings_steamAppUrl : '';
857
858 echo '</span>';
859
860 echo '/';
861
862 echo '<span class="wpsapSettings_steamAppLogoutUrl_mirror">';
863
864 echo $wpsapSettings_steamAppLogoutUrl;
865
866 echo '</span>';
867
868 echo user_trailingslashit('');
869
870 ?>
871
872 </code>
873
874 </p>
875
876 </td>
877
878 </tr>
879
880
881
882 </table>
883
884 </div>
885
886 </div>
887
888
889
890
891
892 </div>
893
894
895
896 <div class="col-lg-12">
897
898 <div class="postbox">
899
900 <h2 class="hndle"><span>Options</span></h2>
901
902 <div class="inside">
903
904 <table class="form-table">
905
906 <tr valign="top">
907
908 <th scope="row" class="settinglabel"><label>Upload Steam Avatar</label></th>
909
910 <td class="settingfield">
911
912 <label>
913
914 <input type="checkbox" name="wpsapOption_avatarUpload" value="checked" <?php echo esc_attr( get_option('wpsapOption_avatarUpload') ); ?> /> Enable
915
916 </label>
917
918 <p>Automatically upload Steam avatar on registration. Adding the local url to the User Meta: <code>steam_wp_avatar</code>.</p>
919
920 </td>
921
922 </tr>
923
924
925
926 <tr valign="top">
927
928 <th scope="row" class="settinglabel"><label>Enable Steam Avatar</label></th>
929
930 <td class="settingfield">
931
932 <label>
933
934 <input type="checkbox" name="wpsapOption_avatarEnabled" value="checked" <?php echo esc_attr( get_option('wpsapOption_avatarEnabled') ); ?> /> Enable
935
936 </label>
937
938 <p>Filter WP/BP functions <code>get_avatar()</code>, <code>get_avatar_url()</code> & <code>bp_avatar_filter()</code> to display locally uploaded Steam avatar.</p>
939
940 </td>
941
942 </tr>
943
944
945
946 <tr valign="top">
947
948 <th scope="row" class="settinglabel"><label>Popup Option</label></th>
949
950 <td class="settingfield">
951
952 <label>
953
954 <input type="checkbox" name="wpsapOption_popupEnabled" value="checked" <?php echo esc_attr( get_option('wpsapOption_popupEnabled') ); ?> /> Enable
955
956 </label>
957
958 <p>Activate the Steam Popup module instead of full page redirect (Login / Sync.)</p>
959
960 <p><u>Notice:</u> Remember to add the ID <code>wpsapButtonPopup</code> to your login button/link.</p>
961
962 </td>
963
964 </tr>
965
966
967
968 </table>
969
970 </div>
971
972 </div>
973
974 </div>
975
976
977
978 <div class="col-lg-12">
979
980 <div class="postbox">
981
982 <h2 class="hndle"><span>Steam API Data Example</span></h2>
983
984 <div class="inside">
985
986 <table class="form-table">
987
988 <tr valign="top">
989
990 <th scope="row" class="settinglabel"><label>WP User Meta</label></th>
991
992 <td class="settingfield">
993
994
995
996 <?php
997
998 $upload_dir = wp_upload_dir();
999
1000 $upload_dir = $upload_dir['url'] . '/...';
1001
1002
1003
1004 $wpsapAdminUserMeta = array(
1005
1006 'steamid' => '010101010101010101',
1007
1008 'communityvisibilitystate' => '3',
1009
1010 'profilestate' => '1',
1011
1012 'personaname' => 'Player',
1013
1014 'lastlogoff' => '1475386810',
1015
1016 'profileurl' => 'http://steamcommunity.com/id/PlayerURL/',
1017
1018 'avatar' => 'https://steamcdn-a.akamaihd.net/...',
1019
1020 'avatarmedium' => 'https://steamcdn-a.akamaihd.net/...',
1021
1022 'avatarfull' => 'https://steamcdn-a.akamaihd.net/...',
1023
1024 'personastate' => '1',
1025
1026 'primaryclanid' => '103582792235138353',
1027
1028 'timecreated' => '1391105541',
1029
1030 'realname' => 'John Doe',
1031
1032 'uptodate' => '1475548634',
1033
1034 'wp_avatar' => $upload_dir
1035
1036 ); ?>
1037
1038 <?php foreach($wpsapAdminUserMeta as $meta => $value){ ?>
1039
1040 <div class="form-group"><kbd>steam_<?php echo $meta; ?></kbd><small>: <?php echo $value; ?></small></div>
1041
1042 <?php } ?>
1043
1044 <p>Can be retrieved using <code>get_user_meta($user_id, 'steam_steamid', true);</code></p>
1045
1046 </td>
1047
1048 </tr>
1049
1050
1051
1052 </table>
1053
1054 </div>
1055
1056 </div>
1057
1058 </div>
1059
1060 </div>
1061
1062
1063
1064
1065
1066 </div>
1067
1068
1069
1070 <div class="col-lg-5">
1071
1072 <div class="postbox">
1073
1074 <h2 class="hndle"><span>Wordpress Shortcode</span> <span><a href="https://codex.wordpress.org/Shortcode" target="_blank">What is this?</a></span></h2>
1075
1076 <div class="inside">
1077
1078
1079
1080 <table class="form-table">
1081
1082
1083
1084 <tr valign="top">
1085
1086 <th scope="row" class="settinglabel"><label>Shortcode</label></th>
1087
1088 <td class="settingfield">
1089
1090 <pre>[wp_steam_auth]</pre>
1091
1092 </td>
1093
1094 </tr>
1095
1096 <tr valign="top">
1097
1098 <th scope="row" class="settinglabel"><label>Login Options</label></th>
1099
1100 <td class="settingfield">
1101
1102 <pre>[wp_steam_auth login_text="Login via Steam"]</pre>
1103
1104 <pre>[wp_steam_auth login_class="my_class1 my_class2"]</pre>
1105
1106 <pre>[wp_steam_auth login_image="http://..."]</pre>
1107
1108 </td>
1109
1110 </tr>
1111
1112
1113
1114 <tr valign="top">
1115
1116 <th scope="row" class="settinglabel"><label>Logout Options</label></th>
1117
1118 <td class="settingfield">
1119
1120 <pre>[wp_steam_auth logout_text="Logout"]</pre>
1121
1122 <pre>[wp_steam_auth logout_class="my_class1 my_class2"]</pre>
1123
1124 <pre>[wp_steam_auth logout_image="http://..."]</pre>
1125
1126 </td>
1127
1128 </tr>
1129
1130
1131
1132 <tr valign="top">
1133
1134 <th scope="row" class="settinglabel"><label>Sync. Options</label></th>
1135
1136 <td class="settingfield">
1137
1138 <pre>[wp_steam_auth show_sync="1"]</pre>
1139
1140 <pre>[wp_steam_auth sync_text="Synchronize"]</pre>
1141
1142 <pre>[wp_steam_auth sync_class="my_class1 my_class2"]</pre>
1143
1144 <pre>[wp_steam_auth sync_image="http://..."]</pre>
1145
1146 <p>All options can be combined together. ie: <code>[wp_steam_auth login_text="Login via Steam" login_class="my_class1 my_class2" logout_text="Logout"]</code></p>
1147
1148 </td>
1149
1150 </tr>
1151
1152
1153
1154 </table>
1155
1156 </div>
1157
1158 </div>
1159
1160
1161
1162 <div class="postbox">
1163
1164 <h2 class="hndle"><span>PHP Functions: Buttons & Conditions</span></h2>
1165
1166 <div class="inside">
1167
1168
1169
1170 <table class="form-table">
1171
1172
1173
1174 <tr valign="top">
1175
1176 <th scope="row" class="settinglabel"><label>Login button</label></th>
1177
1178 <td class="settingfield">
1179
1180 <pre>wpsap_button_login();</pre>
1181
1182 <p>URL Only: <code>wpsap_button_login_url();</code></p>
1183
1184 </td>
1185
1186 </tr>
1187
1188 <tr valign="top">
1189
1190 <th scope="row" class="settinglabel"><label>Sync. button</label></th>
1191
1192 <td class="settingfield">
1193
1194 <pre>wpsap_button_sync();</pre>
1195
1196 <p>URL Only: <code>wpsap_button_sync_url();</code></p>
1197
1198 </td>
1199
1200 </tr>
1201
1202 <tr valign="top">
1203
1204 <th scope="row" class="settinglabel"><label>Logout button</label></th>
1205
1206 <td class="settingfield">
1207
1208 <pre>wpsap_button_logout();</pre>
1209
1210 <p>URL Only: <code>wpsap_button_logout_url();</code></p>
1211
1212 </td>
1213
1214 </tr>
1215
1216
1217
1218 <tr valign="top">
1219
1220 <th scope="row" class="settinglabel"><label>Logged in?</label></th>
1221
1222 <td class="settingfield">
1223
1224 <pre>if ( is_user_logged_in() ) {
1225
1226echo '<a href="'.wpsap_button_logout_url().'">Logout</a>';
1227
1228}</pre>
1229
1230 <p>May use in combination with <code>wpsap_button_logout();</code></p>
1231
1232 </td>
1233
1234 </tr>
1235
1236
1237
1238 <tr valign="top">
1239
1240 <th scope="row" class="settinglabel"><label>Need Sync.?</label></th>
1241
1242 <td class="settingfield">
1243
1244 <pre>if ( is_user_logged_in() && !wpsap_is_user_synced() ) {
1245
1246echo '<a href="'.wpsap_button_sync_url().'">Synchronize</a>';
1247
1248}</pre>
1249
1250 <p>May use in combination with <code>wpsap_button_sync();</code></p>
1251
1252 </td>
1253
1254 </tr>
1255
1256
1257
1258 <tr valign="top">
1259
1260 <th scope="row" class="settinglabel"><label>Logged out?</label></th>
1261
1262 <td class="settingfield">
1263
1264 <pre>if ( !is_user_logged_in() ) {
1265
1266echo '<a href="'.wpsap_button_login_url().'">Login</a>';
1267
1268}</pre>
1269
1270 <p>May use in combination with <code>wpsap_button_login();</code></p>
1271
1272 </td>
1273
1274 </tr>
1275
1276
1277
1278 </table>
1279
1280 </div>
1281
1282 </div>
1283
1284
1285
1286 <div class="postbox">
1287
1288 <h2 class="hndle"><span>Resources</span> <small>Click to get Image URL</small></h2>
1289
1290 <div class="inside">
1291
1292
1293
1294 <table class="form-table">
1295
1296
1297
1298 <tr valign="top">
1299
1300 <th scope="row" class="settinglabel"><label>Small Button 1</label></th>
1301
1302 <td class="settingfield">
1303
1304 <a href="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png" target="_blank">
1305
1306 <img src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png" />
1307
1308 </a>
1309
1310 </td>
1311
1312 </tr>
1313
1314
1315
1316 <tr valign="top">
1317
1318 <th scope="row" class="settinglabel"><label>Small Button 2</label></th>
1319
1320 <td class="settingfield">
1321
1322 <a href="https://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_01.png" target="_blank">
1323
1324 <img src="https://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_01.png" />
1325
1326 </a>
1327
1328 </td>
1329
1330 </tr>
1331
1332
1333
1334 <tr valign="top">
1335
1336 <th scope="row" class="settinglabel"><label>Large Button 1</label></th>
1337
1338 <td class="settingfield">
1339
1340 <a href="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_border.png" target="_blank">
1341
1342 <img src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_border.png" />
1343
1344 </a>
1345
1346 </td>
1347
1348 </tr>
1349
1350
1351
1352 <tr valign="top">
1353
1354 <th scope="row" class="settinglabel"><label>Large Button 2</label></th>
1355
1356 <td class="settingfield">
1357
1358 <a href="https://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_02.png" target="_blank">
1359
1360 <img src="https://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_02.png" />
1361
1362 </a>
1363
1364 </td>
1365
1366 </tr>
1367
1368
1369
1370 </table>
1371
1372 </div>
1373
1374 </div>
1375
1376 </div>
1377
1378
1379
1380 </div>
1381
1382
1383
1384 <div class="postbox">
1385
1386 <div class="inside">
1387
1388 <?php submit_button(); ?>
1389
1390 </div>
1391
1392 </div>
1393
1394
1395
1396 </form>
1397
1398
1399
1400 </div>
1401
1402
1403
1404 </div>
1405
1406 </div>
1407
1408
1409
1410</div><!-- /end #wrap -->
1411
1412
1413
1414<?php } ?>