From 5785aeb00708f9eee0e829bfd2ab610fe8f36b15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Germ=C3=A1n=20Lena?=
Date: Thu, 16 Oct 2014 21:39:23 -0300
Subject: [PATCH] Add option to enter custom CSS #21
---
README.md | 8 ++---
WP_Auth0.php | 3 ++
lib/WP_Auth0_Admin.php | 7 ++++
lib/WP_Auth0_Options.php | 1 +
readme.txt | 8 ++---
templates/a0-widget-setup-form.php | 13 +++++++
templates/auth0-login-form.php | 55 +++++++++++++++++-------------
7 files changed, 61 insertions(+), 34 deletions(-)
diff --git a/README.md b/README.md
index 2e99b96e8..31fd765db 100644
--- a/README.md
+++ b/README.md
@@ -80,13 +80,11 @@ Under some situations, you may end up with a user with two accounts. **WordPres
### Can I customize the Login Widget?
-You can style the login form by adding a filter like this
+You can style the login form by adding your css on the "Customize the Login Widget CSS" Auth0 setting and the widget settings
- add_filter( 'auth0_login_css', function() {
- return "form a.a0-btn-small { background-color: red }";
- } );
+ form a.a0-btn-small { background-color: red !important; }
-The Login Widget is Open Source. For more information about it: https://github.com/auth0/widget
+The Login Widget is Open Source. For more information about it: https://github.com/auth0/lock
### Can I access the user profile information?
diff --git a/WP_Auth0.php b/WP_Auth0.php
index 3dfa8888d..5a7002b3b 100644
--- a/WP_Auth0.php
+++ b/WP_Auth0.php
@@ -197,6 +197,9 @@ public static function buildSettings($settings)
$options_obj['dict'] = $settings['dict'];
}
}
+ if (self::IsValid($settings,'custom_css')) {
+ $options_obj['customCSS'] = $settings['custom_css'];
+ }
if (self::IsValid($settings,'social_big_buttons')) {
$options_obj['socialBigButtons'] = self::GetBoolean($settings['social_big_buttons']);
}
diff --git a/lib/WP_Auth0_Admin.php b/lib/WP_Auth0_Admin.php
index 796eaaf98..751133df0 100755
--- a/lib/WP_Auth0_Admin.php
+++ b/lib/WP_Auth0_Admin.php
@@ -65,6 +65,7 @@ public static function init_admin(){
array('id' => 'wpa0_social_big_buttons', 'name' => 'Show big social buttons', 'function' => 'render_social_big_buttons'),
array('id' => 'wpa0_icon_url', 'name' => 'Icon URL', 'function' => 'render_icon_url'),
array('id' => 'wpa0_gravatar', 'name' => 'Enable Gravatar integration', 'function' => 'render_gravatar'),
+ array('id' => 'wpa0_custom_css', 'name' => 'Customize the Login Widget CSS', 'function' => 'render_custom_css'),
));
@@ -131,6 +132,12 @@ public static function render_dict(){
echo ' ' . __('This is the widget\'s dict param.', WPA0_LANG) . '' . __('More info', WPA0_LANG) . '';
}
+ public static function render_custom_css(){
+ $v = WP_Auth0_Options::get( 'custom_css' );
+ echo '';
+ echo ' ' . __('This should be a valid CSS to customize the Auth0 login widget. ', WPA0_LANG) . '' . __('More info', WPA0_LANG) . '';
+ }
+
public static function render_username_style(){
$v = WP_Auth0_Options::get( 'username_style' );
echo '';
diff --git a/lib/WP_Auth0_Options.php b/lib/WP_Auth0_Options.php
index da5d445be..e812642a3 100755
--- a/lib/WP_Auth0_Options.php
+++ b/lib/WP_Auth0_Options.php
@@ -58,6 +58,7 @@ private static function defaults(){
'username_style' => 'email',
'extra_conf' => '',
'remember_last_login' => true,
+ 'custom_css' => '',
'gravatar' => true,
);
}
diff --git a/readme.txt b/readme.txt
index 998a88ff4..f4dff7067 100644
--- a/readme.txt
+++ b/readme.txt
@@ -105,13 +105,11 @@ Under some situations, you may end up with a user with two accounts. Wordpress a
= Can I customize the Login Widget? =
-You can style the login form by adding a filter like this
+You can style the login form by adding your css on the "Customize the Login Widget CSS" Auth0 setting and the widget settings
- add_filter( 'auth0_login_css', function() {
- return "form a.a0-btn-small { background-color: red }";
- } );
+ form a.a0-btn-small { background-color: red !important; }
-The Login Widget is Open Source. For more information about it: https://github.com/auth0/widget
+The Login Widget is Open Source. For more information about it: https://github.com/auth0/lock
= Can I access the user profile information? =
diff --git a/templates/a0-widget-setup-form.php b/templates/a0-widget-setup-form.php
index 8f5df3c1f..81bd50547 100644
--- a/templates/a0-widget-setup-form.php
+++ b/templates/a0-widget-setup-form.php
@@ -10,6 +10,7 @@
$dict = isset($instance[ 'dict' ]) ? $instance[ 'dict' ] : '';
$extra_conf = isset($instance[ 'extra_conf' ]) ? $instance[ 'extra_conf' ] : '';
$remember_last_login = isset($instance[ 'remember_last_login' ]) ? $instance[ 'remember_last_login' ] : '';
+$custom_css = isset($instance[ 'custom_css' ]) ? $instance[ 'custom_css' ] : '';
?>
@@ -130,6 +131,18 @@ class="button-secondary">