Skip to content

Commit

Permalink
starting to add google plus support
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoprimo committed Jun 18, 2014
1 parent 7c59069 commit 05178dd
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
32 changes: 31 additions & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function sc_register_social_connect_settings() {
register_setting( 'social-connect-settings-group', 'social_connect_twitter_consumer_key' );
register_setting( 'social-connect-settings-group', 'social_connect_twitter_consumer_secret' );

register_setting( 'social-connect-settings-group', 'social_connect_google_plus_enabled' );
register_setting( 'social-connect-settings-group', 'social_connect_google_plus_client_id' );
register_setting( 'social-connect-settings-group', 'social_connect_google_plus_client_secret' );

register_setting( 'social-connect-settings-group', 'social_connect_google_enabled' );
register_setting( 'social-connect-settings-group', 'social_connect_yahoo_enabled' );
register_setting( 'social-connect-settings-group', 'social_connect_wordpress_enabled' );
Expand Down Expand Up @@ -81,11 +85,37 @@ function sc_render_social_connect_settings() {
</tr>
</table>

<h3><?php _e('Google+ Settings', 'social_connect'); ?></h3>
<p><?php _e('To offer login via Google+, you need to register your site as a project on Google Developers Console and get a <strong>Client ID</strong> and a <strong>Client Secret</strong>.', 'social_connect'); ?></p>
<p><?php printf(__('Already registered? Find your keys in your <a target="_blank" href="%1$s">Google+ Project List</a>', 'social_connect'), 'https://console.developers.google.com/project'); ?></p>
<p><?php printf(__('Need to register? <a href="%1$s">Create a project</a>, enable Google+ API and create a new Client ID with the details below:', 'social_connect'), 'https://console.developers.google.com/project'); ?></p>
<ol>
<li><?php _e('Application Type: <strong>Web Application</strong>', 'social_connect'); ?></li>
<li><?php _e('Authorized JavaScript origins: <strong>&lt;YOUR SITE DOMAIN&gt;</strong>', 'social_connect'); ?></li>
<li><?php printf(__('Authorized redirect URI: <strong>%1$s</strong>', 'social_connect'), SOCIAL_CONNECT_GOOGLE_PLUS_REDIRECT_URL); ?></li>
</ol>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Enable?', 'social_connect'); ?></th>
<td>
<input type="checkbox" name="social_connect_google_plus_enabled" value="1" <?php checked(get_option('social_connect_google_plus_enabled' ), 1 ); ?> /><br/>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Client ID', 'social_connect'); ?></th>
<td><input type="text" name="social_connect_google_plus_client_id" value="<?php echo get_option('social_connect_google_plus_client_id' ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Client Secret', 'social_connect'); ?></th>
<td><input type="text" name="social_connect_google_plus_client_secret" value="<?php echo get_option('social_connect_google_plus_client_secret' ); ?>" /></td>
</tr>
</table>

<h3><?php _e('OpenID Providers', 'social_connect'); ?></h3>
<p><?php _e('Choose the OpenID providers your visitors can use to register, comment and login.', 'social_connect'); ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row">Google</th>
<th scope="row"><?php printf(__('Google (<a href="%1$s">deprecated</a>)', 'social_connect'), 'https://developers.google.com/+/api/auth-migration'); ?></th>
<td>
<input type="checkbox" name="social_connect_google_enabled" value="1" <?php checked(get_option('social_connect_google_enabled', 1 ), 1 ); ?> />
</td>
Expand Down
1 change: 1 addition & 0 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
define( 'SOCIAL_CONNECT_PLUGIN_URL', plugins_url() . '/' . basename( dirname( __FILE__ )));
}

define( 'SOCIAL_CONNECT_GOOGLE_PLUS_REDIRECT_URL', SOCIAL_CONNECT_PLUGIN_URL . '/google-plus/callback.php' );
11 changes: 11 additions & 0 deletions media/js/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
window.open(redirect_uri,'','scrollbars=no,menubar=no,height=400,width=800,resizable=yes,toolbar=no,status=no');
};

var _do_google_plus_connect = function() {
var google_plus_auth = $('#social_connect_google_plus_auth');
var redirect_uri = google_plus_auth.find('input[type=hidden][name=redirect_uri]').val();

window.open(redirect_uri,'','scrollbars=no,menubar=no,height=400,width=800,resizable=yes,toolbar=no,status=no');
};

var _do_yahoo_connect = function() {
var yahoo_auth = $('#social_connect_yahoo_auth');
var redirect_uri = yahoo_auth.find('input[type=hidden][name=redirect_uri]').val();
Expand Down Expand Up @@ -79,6 +86,10 @@
_do_google_connect();
});

$(".social_connect_login_google_plus").on("click", function() {
_do_google_plus_connect();
});

$(".social_connect_login_yahoo").on("click", function() {
_do_yahoo_connect();
});
Expand Down
6 changes: 6 additions & 0 deletions social-connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ function sc_parse_request($wp) {
case 'google':
require_once 'google/connect.php';
break;
case 'google-plus':
require_once 'google-plus/connect.php';
break;
case 'yahoo':
require_once 'yahoo/connect.php';
break;
Expand Down Expand Up @@ -152,6 +155,9 @@ function sc_social_connect_process_login( $is_ajax = false ) {
$sc_name = $sc_first_name . ' ' . $sc_last_name;
$user_login = strtolower( $sc_first_name.$sc_last_name );
break;
case 'google-plus':
die('asdf');
break;
case 'yahoo':
$sc_provider_identity = $_REQUEST[ 'social_connect_openid_identity' ];
social_connect_verify_signature( $sc_provider_identity, $sc_provided_signature, $redirect_to );
Expand Down
7 changes: 6 additions & 1 deletion ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ function sc_render_login_form_social_connect( $args = NULL ) {

$twitter_enabled = get_option( 'social_connect_twitter_enabled' ) && get_option( 'social_connect_twitter_consumer_key' ) && get_option( 'social_connect_twitter_consumer_secret' );
$facebook_enabled = get_option( 'social_connect_facebook_enabled', 1 ) && get_option( 'social_connect_facebook_api_key' ) && get_option( 'social_connect_facebook_secret_key' );
$google_plus_enabled = get_option( 'social_connect_google_plus_enabled', 1 );
$google_enabled = get_option( 'social_connect_google_enabled', 1 );
$yahoo_enabled = get_option( 'social_connect_yahoo_enabled', 1 );
$wordpress_enabled = get_option( 'social_connect_wordpress_enabled', 1 );
?>

<?php if ($twitter_enabled || $facebook_enabled || $google_enabled || $yahoo_enabled || $wordpress_enabled) : ?>
<?php if ($twitter_enabled || $facebook_enabled || $google_enabled || $google_plus_enabled|| $yahoo_enabled || $wordpress_enabled) : ?>
<div class="social_connect_ui <?php if( strpos( $_SERVER['REQUEST_URI'], 'wp-signup.php' ) ) echo 'mu_signup'; ?>">
<p class="comment-form-social-connect">
<?php if( $display_label !== false ) : ?>
Expand All @@ -34,6 +35,9 @@ function sc_render_login_form_social_connect( $args = NULL ) {
<?php if( $twitter_enabled ) :
echo apply_filters('social_connect_login_twitter','<a href="javascript:void(0);" title="Twitter" class="social_connect_login_twitter"><img alt="Twitter" src="'.$images_url.'twitter_32.png" /></a>');
endif; ?>
<?php if( $google_plus_enabled ) :
echo apply_filters('social_connect_login_google_plus','<a href="javascript:void(0);" title="Google+" class="social_connect_login_google_plus"><img alt="Google+" src="'.$images_url.'google_plus_32.png" /></a>');
endif; ?>
<?php if( $google_enabled ) :
echo apply_filters('social_connect_login_google','<a href="javascript:void(0);" title="Google" class="social_connect_login_google"><img alt="Google" src="'.$images_url.'google_32.png" /></a>');
endif; ?>
Expand All @@ -57,6 +61,7 @@ function sc_render_login_form_social_connect( $args = NULL ) {

<div id="social_connect_twitter_auth"><input type="hidden" name="redirect_uri" value="<?php echo home_url('index.php?social-connect=twitter'); ?>" /></div>
<div id="social_connect_google_auth"><input type="hidden" name="redirect_uri" value="<?php echo home_url('index.php?social-connect=google'); ?>" /></div>
<div id="social_connect_google_plus_auth"><input type="hidden" name="redirect_uri" value="<?php echo home_url('index.php?social-connect=google-plus'); ?>" /></div>
<div id="social_connect_yahoo_auth"><input type="hidden" name="redirect_uri" value="<?php echo home_url('index.php?social-connect=yahoo'); ?>" /></div>
<div id="social_connect_wordpress_auth"><input type="hidden" name="redirect_uri" value="<?php echo home_url('index.php?social-connect=wordpress'); ?>" /></div>

Expand Down

0 comments on commit 05178dd

Please sign in to comment.