-
Notifications
You must be signed in to change notification settings - Fork 5
/
ui.php
executable file
·223 lines (165 loc) · 9.67 KB
/
ui.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
function sc_render_login_form_social_connect()
{
$images_url = plugins_url() . '/wp_social_connect/media/img/';
$facebook_enabled = get_option('social_connect_facebook_enabled') && get_option('social_connect_facebook_api_key') && get_option('social_connect_facebook_secret_key');
$twitter_enabled = get_option('social_connect_twitter_enabled') && get_option('social_connect_twitter_enabled') && get_option('social_connect_twitter_consumer_key') && get_option('social_connect_twitter_consumer_secret');
$liveid_enabled = get_option('social_connect_liveid_enabled') && get_option('social_connect_liveid_appid_key') && get_option('social_connect_liveid_secret_key') && get_option('social_connect_liveid_security_algorithm') && get_option('social_connect_liveid_return_url') && get_option('social_connect_liveid_policy_url');
$google_enabled = get_option('social_connect_google_enabled');
$yahoo_enabled = get_option('social_connect_yahoo_enabled');
$openid_enabled = get_option('social_connect_openid_enabled');
$wordpress_enabled = get_option('social_connect_wordpress_enabled');
?>
<div id="social_connect_ui">
<span><?php _e( 'Connect with:' ); ?></span><br/>
<div id="social_connect_form" class="social_connect_form" title="Social Connect">
<?php if($facebook_enabled) { ?>
<a href="javascript://" title="Facebook" class="social_connect_login_facebook"><img src="<?php echo $images_url . 'facebook_32.png' ?>" /></a>
<?php } ?>
<?php if($twitter_enabled) { ?>
<a href="javascript://" title="Twitter" class="social_connect_login_twitter"><img src="<?php echo $images_url . 'twitter_32.png' ?>" /></a>
<?php } ?>
<?php if($liveid_enabled) { ?>
<a href="javascript://" title="LiveID" class="social_connect_login_liveid"><img src="<?php echo $images_url . 'windows_32.png' ?>" /></a>
<?php } ?>
<?php if($google_enabled) { ?>
<a href="javascript://" title="Google" class="social_connect_login_google"><img src="<?php echo $images_url . 'google_32.png' ?>" /></a>
<?php } ?>
<?php if($yahoo_enabled) { ?>
<a href="javascript://" title="Yahoo" class="social_connect_login_yahoo"><img src="<?php echo $images_url . 'yahoo_32.png' ?>" /></a>
<?php } ?>
<?php if($openid_enabled) { ?>
<a href="javascript://" title="OpenID" class="social_connect_login_openid"><img src="<?php echo $images_url . 'openid_32.png' ?>" /></a>
<?php } ?>
<?php if($wordpress_enabled) { ?>
<a href="javascript://" title="WordPress" class="social_connect_login_wordpress"><img src="<?php echo $images_url . 'wordpress_32.png' ?>" /></a>
<?php } ?>
</div>
<br />
<?php
$social_connect_provider = isset($_COOKIE['social_connect_current_provider']) ? $_COOKIE['social_connect_current_provider'] : '';
$social_connect_user_name = isset($_COOKIE['social_connect_current_name']) ? $_COOKIE['social_connect_current_name'] : '';
$social_connect_wordpress_blog_url = isset($_COOKIE['social_connect_wordpress_blog_url']) ? $_COOKIE['social_connect_wordpress_blog_url'] : '';
$social_connect_openid_url = isset($_COOKIE['social_connect_openid_url']) ? $_COOKIE['social_connect_openid_url'] : '';
if($social_connect_wordpress_blog_url == '') {
$social_connect_wordpress_blog_name = '';
} else {
preg_match("/^(http:\/\/)?([^\/]+)/i", $social_connect_wordpress_blog_url, $matches);
$host = $matches[2];
$subdomains = explode('.', $host);
$social_connect_wordpress_blog_name = $subdomains[0];
}
if($social_connect_provider) {
$social_connect_login_continue = 'social_connect_login_continue_' . $social_connect_provider;
if($social_connect_provider == 'wordpress') {
// trigger the wordpress URL form instead
$social_connect_login_continue = 'social_connect_wordpress_proceed';
}
?>
<div class="social_connect_already_connected_form" title="Social Connect" provider="<?php echo $social_connect_provider ?>">
<img id="social_connect_already_connected_logo" src="<?php echo $images_url . $social_connect_provider . '_32.png' ?>" />
<?php printf( __( 'Welcome back %s, %scontinue?%s', 'social_connect' ), $social_connect_user_name, '<a href="javascript://" class="'.$social_connect_login_continue.'">', '</a>', 'social_connect' ); ?>
<div style="clear:both;"></div>
<br/>
<a href="javascript://" class="social_connect_already_connected_form_not_you"><?php _e( 'Not you?', 'social_connect' ); ?></a> <br/>
<a href="javascript://" class="social_connect_already_connected_user_another"><?php _e( 'Use another account', 'social_connect' ); ?></a> <br/>
</div>
<?php
}
?>
<div class="social_connect_facebook_auth" client_id="<?php echo get_option('social_connect_facebook_api_key'); ?>" redirect_uri="<?php
echo urlencode(plugins_url() . '/wp_social_connect/facebook/callback.php'); ?>">
</div>
<div class="social_connect_twitter_auth" redirect_uri="<?php echo(plugins_url() . '/wp_social_connect/twitter/connect.php'); ?>">
</div>
<div class="social_connect_liveid_auth" appid="<?php echo get_option('social_connect_liveid_appid_key'); ?>" sec_algo="<?php echo get_option('social_connect_liveid_security_algorithm'); ?>" redirect_uri="<?php echo(plugins_url() . '/wp_social_connect/liveid/connect.php'); ?>">
</div>
<div class="social_connect_google_auth" redirect_uri="<?php echo(plugins_url() . '/wp_social_connect/google/connect.php'); ?>">
</div>
<div class="social_connect_yahoo_auth" redirect_uri="<?php echo(plugins_url() . '/wp_social_connect/yahoo/connect.php'); ?>">
</div>
<div class="social_connect_openid_auth" redirect_uri="<?php echo(plugins_url() . '/wp_social_connect/openid/connect.php'); ?>">
</div>
<div class="social_connect_wordpress_auth" redirect_uri="<?php echo(plugins_url() . '/wp_social_connect/wordpress/connect.php'); ?>">
</div>
<div class="social_connect_openid_form" title="OpenID">
<p><?php _e( 'Enter your OpenID URL', 'social_connect' ); ?></p><br/>
<p>
<span>http://</span><input class="openid_url" size="15" value="<?php echo $social_connect_openid_url ?>"/> <br/><br/>
<a href="javascript://" class="social_connect_openid_proceed"><?php _e( 'Proceed', 'social_connect' ); ?></a>
</p>
</div>
<div class="social_connect_wordpress_form" title="WordPress">
<p><?php _e( 'Enter your WordPress.com blog URL', 'social_connect' ); ?></p><br/>
<p>
<span>http://</span><input class="wordpress_blog_url" size="15" value="<?php echo $social_connect_wordpress_blog_name ?>"/><span>.wordpress.com</span> <br/><br/>
<a href="javascript://" class="social_connect_wordpress_proceed"><?php _e( 'Proceed', 'social_connect' ); ?></a>
</p>
</div>
</div> <!-- End of social_connect_ui div -->
<?php
}
add_action('login_form', 'sc_render_login_form_social_connect');
add_action('register_form', 'sc_render_login_form_social_connect');
add_action('after_signup_form', 'sc_render_login_form_social_connect');
function sc_social_connect_add_meta_to_comment_form()
{
$social_connect_provider = isset($_COOKIE['social_connect_current_provider']) ? $_COOKIE['social_connect_current_provider'] : '';
if($social_connect_provider != '') {
echo "<input type='hidden' name='social_connect_comment_via_provider' value='$social_connect_provider' />";
}
}
add_action('comment_form', 'sc_social_connect_add_meta_to_comment_form');
function sc_social_connect_add_comment_meta($comment_id) {
$social_connect_comment_via_provider = isset($_POST['social_connect_comment_via_provider']) ? $_POST['social_connect_comment_via_provider'] : '';
if($social_connect_comment_via_provider != '') {
update_comment_meta($comment_id, 'social_connect_comment_via_provider', $social_connect_comment_via_provider);
}
}
add_action('comment_post', 'sc_social_connect_add_comment_meta');
function sc_social_connect_render_comment_meta($link) {
global $comment;
$images_url = plugins_url() . '/wp_social_connect/media/img/';
$social_connect_comment_via_provider = get_comment_meta($comment->comment_ID, 'social_connect_comment_via_provider', true);
if($social_connect_comment_via_provider) {
return $link . " " . "<img id='social_connect_comment_via_provider' src='" . $images_url . $social_connect_comment_via_provider . "_16.png" . "' />";
} else {
return $link;
}
}
add_action ('get_comment_author_link', 'sc_social_connect_render_comment_meta');
function sc_render_comment_form_social_connect()
{
if(comments_open() && !is_user_logged_in()) {
sc_render_login_form_social_connect();
}
}
add_action('comment_form', 'sc_render_comment_form_social_connect');
function sc_render_login_page_uri()
{
?>
<div id="social_connect_login_form_uri" href="<?php echo site_url('wp-login.php', 'login_post'); ?>"></div>
<?php
}
add_action('wp_footer', 'sc_render_login_page_uri');
function sc_render_social_connect_widget($args)
{
extract($args); // extracts before_widget,before_title,after_title,after_widget
echo $before_widget . $before_title . $after_title;
sc_render_login_form_social_connect();
echo $after_widget;
}
function social_connect_plugin_loaded()
{
$widget_ops = array('classname' => 'social_connect_widget', 'description' => "Allows users to register and login using their existing Twitter, Facebook, Windows Live ID, Google, Yahoo, OpenID and wordpress.com accounts" );
wp_register_sidebar_widget('social_connect_widget', 'Social Connect', 'sc_render_social_connect_widget', $widget_ops);
}
add_action('plugins_loaded','social_connect_plugin_loaded');
function sc_social_connect_shortcode_handler($args)
{
if(!is_user_logged_in()) {
sc_render_login_form_social_connect();
}
}
add_shortcode('social_connect', 'sc_social_connect_shortcode_handler');
?>