-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A0 widget #16
A0 widget #16
Changes from all commits
2f616bc
e5867b5
21d10b6
b5a36ec
dd2c202
9c5ff93
e49b940
8af498e
b823c8d
49a7b54
68e09ae
479c34c
9973cbc
cc89ecb
345cc9d
58d1bf6
2bae772
8349e67
d088c60
a2a362d
0d0c582
84f5d09
30facef
f9c6784
3a39a9f
2c62c15
347dc53
b2b5275
7529736
f975bfc
a3b8157
594a97d
1544fc8
106a829
607c4ae
41434d5
f53f4b5
7b683e5
7cdd8e5
2a77e29
362f6a9
a48ce05
e35b5b3
d4ea519
bfa0c97
3147493
d10006c
2e57d26
ac6159f
75ebd3d
36640dd
d6f6be9
fcc4a42
fa7c512
8d4e4cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* Plugin Name: Wordpress Auth0 Integration | ||
* Description: Implements the Auth0 Single Sign On solution into Wordpress | ||
* Version: 1.0.8 | ||
* Version: 1.1.0 | ||
* Author: Auth0 | ||
* Author URI: https://auth0.com | ||
*/ | ||
|
@@ -52,18 +52,27 @@ public static function init(){ | |
|
||
add_action( 'widgets_init', array(__CLASS__, 'wp_register_widget')); | ||
|
||
$plugin = plugin_basename(__FILE__); | ||
add_filter("plugin_action_links_$plugin", array(__CLASS__, 'wp_add_plugin_settings_link')); | ||
|
||
WP_Auth0_Admin::init(); | ||
} | ||
|
||
// Add settings link on plugin page | ||
public static function wp_add_plugin_settings_link($links) { | ||
$settings_link = '<a href="options-general.php?page=wpa0">Settings</a>'; | ||
array_unshift($links, $settings_link); | ||
return $links; | ||
} | ||
|
||
public static function wp_register_widget() { | ||
register_widget( 'wp_auth0_widget' ); | ||
register_widget( 'WP_Auth0_Widget' ); | ||
} | ||
|
||
public static function wp_enqueue(){ | ||
$activated = absint(WP_Auth0_Options::get( 'active' )); | ||
if(!$activated) { | ||
return; | ||
} | ||
$client_id = WP_Auth0_Options::get('client_id'); | ||
|
||
if (trim($client_id) == "") return; | ||
|
||
wp_enqueue_style( 'auth0-widget', WPA0_PLUGIN_URL . 'assets/css/main.css' ); | ||
} | ||
|
@@ -116,15 +125,69 @@ public static function render_back_to_auth0() { | |
|
||
} | ||
|
||
public static function render_auth0_login_css() { ?> | ||
protected static function GetBoolean($value) | ||
{ | ||
return ($value == 1 || strtolower($value) == 'true'); | ||
} | ||
protected static function IsValid($array, $key) | ||
{ | ||
return (isset($array[$key]) && trim($array[$key]) != ''); | ||
} | ||
public static function buildSettings($settings) | ||
{ | ||
$options_obj = array(); | ||
if (isset($settings['form_title']) && | ||
(!isset($settings['dict']) || (isset($settings['dict']) && trim($settings['dict']) == '')) && | ||
trim($settings['form_title']) != '') { | ||
$options_obj['dict'] = array( | ||
"signin" => array( | ||
"title" => $settings['form_title'] | ||
) | ||
); | ||
} | ||
elseif (isset($settings['dict']) && trim($settings['dict']) != '') { | ||
if ($oDict = json_decode($settings['dict'], true)) { | ||
$options_obj['dict'] = $oDict; | ||
} | ||
else{ | ||
$options_obj['dict'] = $settings['dict']; | ||
} | ||
} | ||
if (self::IsValid($settings,'social_big_buttons')) { | ||
$options_obj['socialBigButtons'] = self::GetBoolean($settings['social_big_buttons']); | ||
} | ||
if (self::IsValid($settings,'gravatar')) { | ||
$options_obj['gravatar'] = self::GetBoolean($settings['gravatar']); | ||
} | ||
if (self::IsValid($settings,'username_style')) { | ||
$options_obj['usernameStyle'] = $settings['username_style']; | ||
} | ||
if (self::IsValid($settings,'remember_last_login')) { | ||
$options_obj['rememberLastLogin'] = self::GetBoolean($settings['remember_last_login']); | ||
} | ||
if (self::IsValid($settings,'icon_url')) { | ||
$options_obj['icon'] = $settings['icon_url']; | ||
} | ||
if (isset($settings['extra_conf']) && trim($settings['extra_conf']) != '') { | ||
$extra_conf_arr = json_decode($settings['extra_conf'], true); | ||
$options_obj = array_merge( $extra_conf_arr, $options_obj ); | ||
} | ||
return $options_obj; | ||
} | ||
|
||
public static function render_auth0_login_css() { | ||
$client_id = WP_Auth0_Options::get('client_id'); | ||
|
||
if (trim($client_id) == "") return; | ||
?> | ||
<link rel='stylesheet' href='<?php echo plugins_url( 'assets/css/login.css', __FILE__ ); ?>' type='text/css' /> | ||
<?php } | ||
<?php | ||
} | ||
|
||
public static function render_form( $html ){ | ||
$activated = absint(WP_Auth0_Options::get( 'active' )); | ||
$client_id = WP_Auth0_Options::get('client_id'); | ||
|
||
if(!$activated) | ||
return $html; | ||
if (trim($client_id) == "") return; | ||
|
||
ob_start(); | ||
|
||
|
@@ -357,11 +420,10 @@ public static function wp_init(){ | |
self::setup_rewrites(); | ||
|
||
$cdn_url = WP_Auth0_Options::get('cdn_url'); | ||
|
||
if (strpos($cdn_url, 'w2/auth0-widget') !== false) | ||
if (strpos($cdn_url, 'auth0-widget-5') !== false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How will we be able to update Lock version as well in every future WP update if we want? Something like this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is to upgrade from auth0-widget-5 to lock. Right now, it is tied to lock-6.min.js and will be updated until the next major release. If we want to force the update, I added an internal version counter (other than the AUTH0_DB_VERSION) to manage the settings updates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! Martin Gontovnikas Twitter: @mgonto (https://twitter.com/mgonto) On Monday, 6 de October de 2014 at 11:49, Germán Lena wrote:
|
||
{ | ||
WP_Auth0_Options::set( 'cdn_url', '//cdn.auth0.com/js/lock-6.min.js' ); | ||
WP_Auth0_Options::set( 'version', 1 ); | ||
//WP_Auth0_Options::set( 'version', 1 ); | ||
} | ||
|
||
// Initialize session | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a picture of how to active Auth0 Widget and where you see the configs?