Skip to content
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

Merged
merged 55 commits into from
Oct 8, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2f616bc
Fix for legacy php versions
glena Sep 27, 2014
e5867b5
A0 widget
glena Sep 26, 2014
21d10b6
Fix to allow to show multiple times the auth0 login form in the same …
glena Sep 26, 2014
b5a36ec
fix
glena Sep 26, 2014
dd2c202
plugin version updated
glena Sep 26, 2014
9c5ff93
upgraded to lock :)
glena Sep 26, 2014
e49b940
upgrade cdn settings to use the lock widget
glena Sep 26, 2014
8af498e
Merge remote-tracking branch 'origin/a0-widget' into a0-widget
glena Sep 27, 2014
b823c8d
Fix for legacy php versions
glena Sep 29, 2014
49a7b54
New settings management
glena Sep 30, 2014
68e09ae
agregado de configuracion
glena Sep 30, 2014
479c34c
change the way it generates the json configuration
glena Sep 30, 2014
9973cbc
added dict + extra settings
glena Oct 1, 2014
cc89ecb
added widget configurations
glena Oct 1, 2014
345cc9d
update version
glena Sep 30, 2014
58d1bf6
fix hidden WP login form when the plugin is disabled
glena Oct 1, 2014
2bae772
upgrade the plugin revision
glena Oct 1, 2014
8349e67
fix
glena Sep 26, 2014
d088c60
A0 widget
glena Sep 26, 2014
a2a362d
fix
glena Sep 26, 2014
0d0c582
upgraded to lock :)
glena Sep 26, 2014
84f5d09
agregado de configuracion
glena Sep 30, 2014
30facef
fix hidden WP login form when the plugin is disabled
glena Oct 1, 2014
f9c6784
the widget now has its own settings! :)
glena Oct 1, 2014
3a39a9f
now the widget can be shown as a modal! :D
glena Oct 2, 2014
2c62c15
shortCode with settings & modal
glena Oct 2, 2014
347dc53
fix the way that the modal is shown (by error it was setted as popup)
glena Oct 2, 2014
b2b5275
updated settings and readme
glena Oct 4, 2014
7529736
fix js changes
glena Oct 4, 2014
f975bfc
change the widget settings form to allow the user to select which opt…
glena Oct 4, 2014
a3b8157
fixes for the shortcode
glena Oct 4, 2014
594a97d
fixes :)
glena Oct 4, 2014
1544fc8
update version
glena Sep 30, 2014
106a829
fix hidden WP login form when the plugin is disabled
glena Oct 1, 2014
607c4ae
upgrade the plugin revision
glena Oct 1, 2014
41434d5
A0 widget
glena Sep 26, 2014
f53f4b5
Fix to allow to show multiple times the auth0 login form in the same …
glena Sep 26, 2014
7b683e5
fix
glena Sep 26, 2014
7cdd8e5
upgraded to lock :)
glena Sep 26, 2014
2a77e29
A0 widget
glena Sep 26, 2014
362f6a9
Fix to allow to show multiple times the auth0 login form in the same …
glena Sep 26, 2014
a48ce05
fix
glena Sep 26, 2014
e35b5b3
New settings management
glena Sep 30, 2014
d4ea519
agregado de configuracion
glena Sep 30, 2014
bfa0c97
added dict + extra settings
glena Oct 1, 2014
3147493
fix hidden WP login form when the plugin is disabled
glena Oct 1, 2014
d10006c
fix
glena Sep 26, 2014
2e57d26
agregado de configuracion
glena Sep 30, 2014
ac6159f
fix hidden WP login form when the plugin is disabled
glena Oct 1, 2014
75ebd3d
the widget now has its own settings! :)
glena Oct 1, 2014
36640dd
now the widget can be shown as a modal! :D
glena Oct 2, 2014
d6f6be9
removed fields, added fields, added descriptions and links
glena Oct 7, 2014
fcc4a42
changes to the plugin and screenshots added
glena Oct 7, 2014
fa7c512
fix widget as modal
glena Oct 7, 2014
8d4e4cb
screenshots added
glena Oct 7, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added widget configurations
  • Loading branch information
glena committed Oct 1, 2014
commit cc89ecbe513783aefab274bcfce4f9ebdc22298b
9 changes: 8 additions & 1 deletion assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ jQuery(document).ready(function($) {
if (typeof(media_frame)!=="undefined")
media_frame.close();

var related_control_id = 'wpa0_icon_url';
if ($(this).attr('related') != '')
{
related_control_id = $(this).attr('related');
}

//Create WP media frame.
media_frame = wp.media.frames.customHeader = wp.media({
title: wpa0.media_title,
Expand All @@ -22,7 +28,8 @@ jQuery(document).ready(function($) {
// Set the frame callback
media_frame.on('select', function() {
var attachment = media_frame.state().get('selection').first().toJSON();
$('#wpa0_icon_url').val(attachment.url);
$('#'+related_control_id).val(attachment.url);
console.log($('#'+related_control_id));
});

//Open modal
Expand Down
33 changes: 31 additions & 2 deletions lib/WP_Auth0_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public static function init_admin(){

self::init_option_section('Advanced', array(

array('id' => 'wpa0_dict', 'name' => 'Translation', 'function' => 'render_dict'),
array('id' => 'wpa0_username_style', 'name' => 'Username style', 'function' => 'render_username_style'),
array('id' => 'wpa0_remember_last_login', 'name' => 'Remember last login', 'function' => 'render_remember_last_login'),
array('id' => 'wpa0_verified_email', 'name' => 'Requires verified email', 'function' => 'render_verified_email'),
Expand All @@ -88,6 +87,8 @@ public static function init_admin(){
array('id' => 'wpa0_ip_range_check', 'name' => 'Enable on IP Ranges', 'function' => 'render_ip_range_check'),
array('id' => 'wpa0_ip_ranges', 'name' => 'IP Ranges', 'function' => 'render_ip_ranges', 'enabled' => $use_ip_ranges),
array('id' => 'wpa0_cdn_url', 'name' => 'Widget URL', 'function' => 'render_cdn_url'),
array('id' => 'wpa0_dict', 'name' => 'Translation', 'function' => 'render_dict'),
array('id' => 'wpa0_extra_conf', 'name' => 'Extra configurations', 'function' => 'render_extra_conf'),

));

Expand Down Expand Up @@ -119,7 +120,25 @@ public static function render_form_title(){
public static function render_dict(){
$v = WP_Auth0_Options::get( 'dict' );
echo '<textarea name="' . WP_Auth0_Options::OPTIONS_NAME . '[dict]" id="wpa0_dict">' . esc_attr( $v ) . '</textarea>';
echo '<br/><span class="description">' . __('This is the widget\'s dict param.', WPA0_LANG) . '<br><a href="https://github.com/auth0/lock/wiki/Auth0Lock-customization#dict-stringobject">' . __('More info', WPA0_LANG) . '</a></span>';
echo '<br/><span class="description">';
echo __('This is the widget\'s dict param.', WPA0_LANG);
echo ' <a href="https://github.com/auth0/lock/wiki/Auth0Lock-customization#dict-stringobject">';
echo __('More info', WPA0_LANG);
echo '</a>';
echo ' <br><i><b>'.__('Note', WPA0_LANG).':</b> '.__('This will override the "Form title" setting', WPA0_LANG).'.</i>';
echo '</span>';
}

public static function render_extra_conf(){
$v = WP_Auth0_Options::get( 'extra_conf' );
echo '<textarea name="' . WP_Auth0_Options::OPTIONS_NAME . '[extra_conf]" id="wpa0_extra_conf">' . esc_attr( $v ) . '</textarea>';
echo '<br/><span class="description">';
echo __('This field allows you to set all the widget settings.', WPA0_LANG);
echo ' <a href="https://github.com/auth0/lock/wiki/Auth0Lock-customization">';
echo __('More info', WPA0_LANG);
echo '</a>';
echo ' <br><i><b>'.__('Note', WPA0_LANG).':</b> '.__('The other settings will override this configuration', WPA0_LANG).'.</i>';
echo '</span>';
}

public static function render_username_style(){
Expand Down Expand Up @@ -234,10 +253,12 @@ public static function input_validator( $input ){
'http',
'https'
));

if(empty($input['icon_url']))
$input['show_icon'] = 0;
else
$input['show_icon'] = (isset($input['show_icon']) ? 1 : 0);

$input['active'] = (isset($input['active']) ? 1 : 0);
$input['requires_verified_email'] = (isset($input['requires_verified_email']) ? 1 : 0);
$input['wordpress_login_enabled'] = (isset($input['wordpress_login_enabled']) ? 1 : 0);
Expand Down Expand Up @@ -266,6 +287,14 @@ public static function input_validator( $input ){
}
}

if (trim($input["extra_conf"]) != '')
{
if (json_decode($input["extra_conf"]) === null)
{
$error = __("The \"Extra Configuration\" parameter should be a valid json object", WPA0_LANG);
}
}

if ($error != "") {
add_settings_error(
WP_Auth0_Options::OPTIONS_NAME,
Expand Down
16 changes: 13 additions & 3 deletions lib/WP_Auth0_Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ class WP_Auth0_Widget extends WP_Widget {

function __construct() {
parent::__construct(

'wp_auth0_widget',

__('Auth0 login widget', 'wp_auth0_widget_domain'),

array( 'description' => __( 'Auth0 widget to embed the login form.', 'wpb_widget_domain' ), )
);
}

public function form( $instance ) {

wp_enqueue_media();
wp_enqueue_script( 'wpa0_admin', WPA0_PLUGIN_URL . 'assets/js/admin.js', array('jquery'));
wp_enqueue_style('media');
wp_localize_script( 'wpa0_admin', 'wpa0', array(
'media_title' => __('Choose your icon', WPA0_LANG),
'media_button' => __('Choose icon', WPA0_LANG)
));
require WPA0_PLUGIN_DIR . 'templates/a0-widget-setup-form.php';

}

public function widget( $args, $instance ) {

$activated = absint(WP_Auth0_Options::get( 'active' ));
Expand Down
104 changes: 104 additions & 0 deletions templates/a0-widget-setup-form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

$form_title = isset($instance[ 'form_title' ]) ? $instance[ 'form_title' ] : '';
$social_big_buttons = isset($instance[ 'social_big_buttons' ]) ? $instance[ 'social_big_buttons' ] : '';
$gravatar = isset($instance[ 'gravatar' ]) ? $instance[ 'gravatar' ] : '';
$show_icon = isset($instance[ 'show_icon' ]) ? $instance[ 'show_icon' ] : '';
$icon_url = isset($instance[ 'icon_url' ]) ? $instance[ 'icon_url' ] : '';
$dict = isset($instance[ 'dict' ]) ? $instance[ 'dict' ] : '';
$extra_configuration = isset($instance[ 'extra_configuration' ]) ? $instance[ 'extra_configuration' ] : '';
$username_style = isset($instance[ 'username_style' ]) ? $instance[ 'username_style' ] : '';
$remember_last_login = isset($instance[ 'remember_last_login' ]) ? $instance[ 'remember_last_login' ] : '';

?>

<p>
<label for="<?php echo $this->get_field_id( 'form_title' ); ?>"><?php _e( 'Form title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'form_title' ); ?>"
name="<?php echo $this->get_field_name( 'form_title' ); ?>"
type="text" value="<?php echo esc_attr( $form_title ); ?>" />
</p>
<p>
<label><?php _e( 'Username style:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'username_style' ); ?>_email"
name="<?php echo $this->get_field_name( 'username_style' ); ?>"
type="radio" value="email" <?php echo (esc_attr( $username_style ) == 'email' ? 'checked="true"' : ''); ?> />
<label for="<?php echo $this->get_field_id( 'username_style' ); ?>_email"><?php _e( 'Email' ); ?></label>

<input id="<?php echo $this->get_field_id( 'username_style' ); ?>_username"
name="<?php echo $this->get_field_name( 'username_style' ); ?>"
type="radio" value="username" <?php echo (esc_attr( $username_style ) == 'username' ? 'checked="true"' : ''); ?> />
<label for="<?php echo $this->get_field_id( 'username_style' ); ?>_email"><?php _e( 'Username' ); ?></label>
</p>
<p>
<input id="<?php echo $this->get_field_id( 'social_big_buttons' ); ?>"
name="<?php echo $this->get_field_name( 'social_big_buttons' ); ?>"
type="checkbox" value="1" <?php echo (esc_attr( $social_big_buttons ) == 1 ? 'checked="true"' : ''); ?> />
<label for="<?php echo $this->get_field_id( 'social_big_buttons' ); ?>"><?php _e( 'Show big social buttons' ); ?></label>
</p>
<p>
<input id="<?php echo $this->get_field_id( 'gravatar' ); ?>"
name="<?php echo $this->get_field_name( 'gravatar' ); ?>"
type="checkbox" value="1" <?php echo (esc_attr( $gravatar ) == 1 ? 'checked="true"' : ''); ?> />
<label for="<?php echo $this->get_field_id( 'gravatar' ); ?>"><?php _e( 'Enable Gravatar integration' ); ?></label>
</p>
<p>
<input id="<?php echo $this->get_field_id( 'remember_last_login' ); ?>"
name="<?php echo $this->get_field_name( 'remember_last_login' ); ?>"
type="checkbox" value="1" <?php echo (esc_attr( $remember_last_login ) == 1 ? 'checked="true"' : ''); ?> />
<label for="<?php echo $this->get_field_id( 'remember_last_login' ); ?>"><?php _e( 'Remember last login' ); ?></label>
</p>
<p>
<input id="<?php echo $this->get_field_id( 'show_icon' ); ?>"
name="<?php echo $this->get_field_name( 'show_icon' ); ?>"
type="checkbox" value="1" <?php echo (esc_attr( $show_icon ) == 1 ? 'checked="true"' : ''); ?> />
<label for="<?php echo $this->get_field_id( 'show_icon' ); ?>"><?php _e( 'Show Icon' ); ?></label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'icon_url' ); ?>"><?php _e( 'Icon Url:' ); ?></label>
<input type="text" id="<?php echo $this->get_field_id( 'icon_url' ); ?>"
name="<?php echo $this->get_field_name( 'icon_url' ); ?>"
value="<?php echo $icon_url; ?>"/>
<a href="javascript:void(0);" id="wpa0_choose_icon"
related="<?php echo $this->get_field_id( 'icon_url' ); ?>"
class="button-secondary"><?php echo _e( 'Choose Icon' ); ?></a>
<br/><span class="description"><?php echo _e('The icon should be 32x32 pixels!'); ?></span>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'dict' ); ?>"><?php _e( 'Translation:' ); ?></label>
<textarea class="widefat" id="<?php echo $this->get_field_id( 'dict' ); ?>"
name="<?php echo $this->get_field_name( 'dict' ); ?>">
<?php echo esc_attr( $dict ); ?>
</textarea>
<br/><span class="description">
<?php echo __('This is the widget\'s dict param.', WPA0_LANG); ?>
<a href="https://github.com/auth0/lock/wiki/Auth0Lock-customization#dict-stringobject"><?php echo __('More info', WPA0_LANG); ?></a>
</span><br>
<span class="description">
<i><b><?php echo __('Note', WPA0_LANG); ?>:</b>
<?php echo __('This will override the "Form title" setting', WPA0_LANG); ?>
</i>
</span>
</span>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'extra_configuration' ); ?>"><?php _e( 'Extra configuration:' ); ?></label>
<textarea class="widefat" id="<?php echo $this->get_field_id( 'extra_configuration' ); ?>"
name="<?php echo $this->get_field_name( 'extra_configuration' ); ?>">
<?php echo esc_attr( $extra_configuration ); ?>
</textarea>
<br/><span class="description">
<?php echo __('This field allows you to set all the widget settings.', WPA0_LANG); ?>
<a href="https://github.com/auth0/lock/wiki/Auth0Lock-customization"><?php echo __('More info', WPA0_LANG); ?></a>
</span><br>
<span class="description">
<i><b><?php echo __('Note', WPA0_LANG); ?>:</b>
<?php echo __('The other settings will override this configuration', WPA0_LANG); ?>
</i>
</span>
</span>
</p>