Version Description
- Code formatting to optimize the plugin size.
- Text changes in the how to use section.
Download this release
Release Info
Developer | Access Keys |
Plugin | Social Login WordPress Plugin – AccessPress Social Login Lite |
Version | 2.0.3 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.0.3
- accesspress-social-login-lite.php +105 -114
- inc/backend/activation.php +20 -21
- inc/backend/how-to-use.php +3 -3
- inc/backend/main-page.php +180 -128
- inc/backend/save-settings.php +13 -13
- inc/backend/widget.php +28 -30
- inc/frontend/login_check.php +207 -207
- inc/frontend/login_integration.php +17 -16
- inc/frontend/shortcode.php +33 -31
- js/backend.js +1 -1
- readme.txt +5 -1
accesspress-social-login-lite.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php defined('ABSPATH') or die("No script kiddies please!");
|
2 |
/*
|
3 |
Plugin name: AccessPress Social Login Lite
|
4 |
Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/
|
5 |
Description: A plugin to add various social logins to a site.
|
6 |
-
version: 2.0.
|
7 |
Author: AccessPress Themes
|
8 |
Author URI: https://accesspressthemes.com/
|
9 |
Text Domain: apsl-lite
|
@@ -12,36 +12,36 @@
|
|
12 |
*/
|
13 |
|
14 |
//Declearation of the necessary constants for plugin
|
15 |
-
if (!defined('APSL_VERSION')) {
|
16 |
-
define('APSL_VERSION', '2.0.
|
17 |
}
|
18 |
|
19 |
-
if (!defined('APSL_IMAGE_DIR')) {
|
20 |
-
define('APSL_IMAGE_DIR', plugin_dir_url(__FILE__) . 'images');
|
21 |
}
|
22 |
|
23 |
-
if (!defined('APSL_JS_DIR')) {
|
24 |
-
define('APSL_JS_DIR', plugin_dir_url(__FILE__) . 'js');
|
25 |
}
|
26 |
|
27 |
-
if (!defined('APSL_CSS_DIR')) {
|
28 |
-
define('APSL_CSS_DIR', plugin_dir_url(__FILE__) . 'css');
|
29 |
}
|
30 |
|
31 |
-
if (!defined('APSL_LANG_DIR')) {
|
32 |
-
define('APSL_LANG_DIR', basename(dirname(__FILE__)) . '/languages/');
|
33 |
}
|
34 |
|
35 |
-
if (!defined('APSL_TEXT_DOMAIN')) {
|
36 |
-
define('APSL_TEXT_DOMAIN', 'apsl-lite');
|
37 |
}
|
38 |
|
39 |
-
if (!defined('APSL_SETTINGS')) {
|
40 |
-
define('APSL_SETTINGS', 'apsl-lite-settings');
|
41 |
}
|
42 |
|
43 |
-
if (!defined('APSL_PLUGIN_DIR')) {
|
44 |
-
define('APSL_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
45 |
}
|
46 |
|
47 |
|
@@ -51,100 +51,100 @@ if (!defined('APSL_PLUGIN_DIR')) {
|
|
51 |
include_once( 'inc/backend/widget.php' );
|
52 |
|
53 |
// Redefine user notification function
|
54 |
-
if (!function_exists('wp_new_user_notification')) {
|
55 |
|
56 |
-
function wp_new_user_notification($user_id, $plaintext_pass = '') {
|
57 |
-
$user = new WP_User($user_id);
|
58 |
|
59 |
-
$user_login = stripslashes($user->user_login);
|
60 |
-
$user_email = stripslashes($user->user_email);
|
61 |
|
62 |
-
$message = sprintf(__('New user registration on your site %s:'), get_option('blogname')) . "\r\n\r\n";
|
63 |
-
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
64 |
-
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
|
65 |
-
$message .= __('Thanks!');
|
66 |
|
67 |
-
$headers = 'From:' . get_option('blogname') . ' <' . get_option('admin_email') . '>' . "\r\n";
|
68 |
-
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message, $headers);
|
69 |
|
70 |
-
if (empty($plaintext_pass))
|
71 |
return;
|
72 |
|
73 |
-
$message = __('Hi there,') . "\r\n\r\n";
|
74 |
-
$message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
|
75 |
$message .= wp_login_url() . "\r\n";
|
76 |
-
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
|
77 |
-
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
|
78 |
-
$message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\r\n\r\n";
|
79 |
-
$message .= __('Thanks!');
|
80 |
|
81 |
-
$headers = 'From:' . get_option('blogname') . ' <' . get_option('admin_email') . '>' . "\r\n";
|
82 |
|
83 |
-
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message, $headers);
|
84 |
}
|
85 |
|
86 |
}
|
87 |
|
88 |
// Declaration of the class
|
89 |
-
if (!class_exists('APSL_Lite_Class')) {
|
90 |
|
91 |
class APSL_Lite_Class {
|
92 |
|
93 |
var $apsl_settings;
|
94 |
|
95 |
function __construct() {
|
96 |
-
$this->apsl_settings = get_option(APSL_SETTINGS);
|
97 |
-
add_action('init', array($this, 'session_init')); //start the session if not started yet.
|
98 |
-
register_activation_hook(__FILE__, array($this, 'plugin_activation')); //load the default setting for the plugin while activating
|
99 |
-
add_action('init', array($this, 'plugin_text_domain')); //load the plugin text domain
|
100 |
-
add_action('admin_menu', array($this, 'add_apsl_menu')); //register the plugin menu in backend
|
101 |
-
add_action('admin_enqueue_scripts', array($this, 'register_admin_assets')); //registers all the assets required for wp-admin
|
102 |
-
add_action('wp_enqueue_scripts', array($this, 'register_frontend_assets')); // registers all the assets required for the frontend
|
103 |
-
add_action('admin_post_apsl_save_options', array($this, 'save_settings')); //save settings of a plugin
|
104 |
-
|
105 |
-
$options = get_option(APSL_SETTINGS);
|
106 |
-
if ($options['apsl_enable_disable_plugin'] == 'yes') {
|
107 |
-
if (in_array("login_form", $options['apsl_display_options'])) {
|
108 |
-
add_action('login_form', array($this, 'add_social_login')); // add the social logins to the login form
|
109 |
}
|
110 |
|
111 |
-
if (in_array("register_form", $options['apsl_display_options'])) {
|
112 |
-
add_action('register_form', array($this, 'add_social_login')); //add the social logins to the registration form
|
113 |
-
add_action('after_signup_form', array($this, 'add_social_login'));
|
114 |
}
|
115 |
|
116 |
-
if (in_array("comment_form", $options['apsl_display_options'])) {
|
117 |
-
add_action('comment_form_top', array($this, 'add_social_login_form_to_comment')); //add the social logins to the comment form
|
118 |
}
|
119 |
}
|
120 |
|
121 |
-
add_shortcode('apsl-login-lite', array($this, 'apsl_shortcode')); //adds a shortcode
|
122 |
-
add_action('init', array($this, 'login_check')); //check for the social logins
|
123 |
-
add_action('widgets_init', array($this, 'register_apsl_widget')); //register the widget of a plugin
|
124 |
-
add_action('login_enqueue_scripts', array($this, 'apsl_login_form_enqueue_style'), 10);
|
125 |
-
add_action('login_enqueue_scripts', array($this, 'apsl_login_form__enqueue_script'), 1);
|
126 |
-
add_action('admin_post_apsl_restore_default_settings', array($this, 'apsl_restore_default_settings')); //restores default settings.
|
127 |
|
128 |
/**
|
129 |
* Hook to display custom avatars
|
130 |
*/
|
131 |
-
add_filter('get_avatar', array($this, 'apsl_social_login_custom_avatar'), 10, 5);
|
132 |
}
|
133 |
|
134 |
-
function apsl_social_login_custom_avatar($avatar, $mixed, $size, $default, $alt = '') {
|
135 |
-
$options = get_option(APSL_SETTINGS);
|
136 |
|
137 |
//Check if we have an user identifier
|
138 |
-
if (is_numeric($mixed) AND $mixed > 0) {
|
139 |
$user_id = $mixed;
|
140 |
}
|
141 |
|
142 |
//Check if we have an user email
|
143 |
-
elseif (is_string($mixed) AND ( $user = get_user_by('email', $mixed))) {
|
144 |
$user_id = $user->ID;
|
145 |
}
|
146 |
//Check if we have an user object
|
147 |
-
elseif (is_object($mixed) AND property_exists($mixed, 'user_id') AND is_numeric($mixed->user_id)) {
|
148 |
$user_id = $mixed->user_id;
|
149 |
}
|
150 |
//None found
|
@@ -153,22 +153,22 @@ if (!class_exists('APSL_Lite_Class')) {
|
|
153 |
}
|
154 |
|
155 |
//User found?
|
156 |
-
if (!empty($user_id)) {
|
157 |
|
158 |
//Override current avatar ?
|
159 |
$override_avatar = true;
|
160 |
|
161 |
//Read the avatar
|
162 |
-
$user_meta_thumbnail = get_user_meta($user_id, 'deuimage', true);
|
163 |
|
164 |
//read user details
|
165 |
-
$user_meta_name = get_user_meta($user_id, 'first_name', true);
|
166 |
|
167 |
-
if ($options['apsl_user_avatar_options'] == 'social') {
|
168 |
-
$user_picture = (!empty($user_meta_thumbnail) ? $user_meta_thumbnail : '');
|
169 |
|
170 |
//Avatar found?
|
171 |
-
if ($user_picture !== false AND strlen(trim($user_picture)) > 0) {
|
172 |
return '<img alt="' . $user_meta_name . '" src="' . $user_picture . '" class="avatar apsl-avatar-social-login avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
|
173 |
}
|
174 |
}
|
@@ -178,27 +178,26 @@ if (!class_exists('APSL_Lite_Class')) {
|
|
178 |
|
179 |
//starts the session with the call of init hook
|
180 |
function session_init() {
|
181 |
-
if (!session_id()) {
|
182 |
session_start();
|
183 |
}
|
184 |
}
|
185 |
|
186 |
//load the default settings of the plugin
|
187 |
function plugin_activation() {
|
188 |
-
if (!get_option(APSL_SETTINGS)) {
|
189 |
include('inc/backend/activation.php');
|
190 |
}
|
191 |
}
|
192 |
|
193 |
//loads the text domain for translation
|
194 |
function plugin_text_domain() {
|
195 |
-
load_plugin_textdomain(APSL_TEXT_DOMAIN, false, APSL_LANG_DIR);
|
196 |
}
|
197 |
|
198 |
//register the plugin menu for backend.
|
199 |
function add_apsl_menu() {
|
200 |
-
|
201 |
-
add_menu_page('AccessPress Social Login Lite', 'AccessPress Social Login Lite', 'manage_options', APSL_TEXT_DOMAIN, array($this, 'main_page'), APSL_IMAGE_DIR . '/icon.png');
|
202 |
}
|
203 |
|
204 |
//menu page
|
@@ -208,61 +207,56 @@ if (!class_exists('APSL_Lite_Class')) {
|
|
208 |
|
209 |
//registration of the backend assets
|
210 |
function register_admin_assets() {
|
211 |
-
wp_enqueue_style('fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION);
|
212 |
-
|
213 |
-
if (isset($_GET['page']) && $_GET['page'] == APSL_TEXT_DOMAIN) {
|
214 |
-
|
215 |
//backend scripts
|
216 |
-
wp_enqueue_script('jquery-ui-sortable');
|
217 |
-
wp_enqueue_script('apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION); //registering plugin's admin js
|
218 |
//register backend css
|
219 |
-
wp_enqueue_style('apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION);
|
220 |
}
|
221 |
}
|
222 |
|
223 |
//registration of the plugins frontend assets
|
224 |
function register_frontend_assets() {
|
225 |
//register frontend scripts
|
226 |
-
wp_enqueue_script('apsl-frontend-js', APSL_JS_DIR . '/frontend.js', array('jquery'), APSL_VERSION);
|
227 |
|
228 |
//register frontend css
|
229 |
-
wp_enqueue_style('fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION);
|
230 |
-
wp_enqueue_style('apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION);
|
231 |
}
|
232 |
|
233 |
//save the settings of a plugin
|
234 |
function save_settings() {
|
235 |
-
if (isset($_POST['apsl_save_settings']) && $_POST['apsl_settings_action'] && wp_verify_nonce($_POST['apsl_settings_action'], 'apsl_nonce_save_settings')) {
|
236 |
include('inc/backend/save-settings.php');
|
237 |
} else {
|
238 |
-
die('No script kiddies please!');
|
239 |
}
|
240 |
}
|
241 |
|
242 |
//function to add the social login in the login and registration form.
|
243 |
function add_social_login() {
|
244 |
-
if (!is_user_logged_in()) {
|
245 |
include('inc/frontend/login_integration.php');
|
246 |
}
|
247 |
}
|
248 |
|
249 |
//function to add the social login in the comment form.
|
250 |
function add_social_login_form_to_comment() {
|
251 |
-
|
252 |
-
<?php
|
253 |
-
|
254 |
-
$options = get_option(APSL_SETTINGS);
|
255 |
$login_text = $options['apsl_title_text_field'];
|
256 |
-
if (!is_user_logged_in()) {
|
257 |
?>
|
258 |
<?php
|
259 |
|
260 |
-
echo do_shortcode("[apsl-login-lite login_text='{$login_text}']");
|
261 |
}
|
262 |
}
|
263 |
|
264 |
//function for adding shortcode of a plugin
|
265 |
-
function apsl_shortcode($attr) {
|
266 |
ob_start();
|
267 |
include('inc/frontend/shortcode.php');
|
268 |
$html = ob_get_contents();
|
@@ -277,35 +271,32 @@ if (!class_exists('APSL_Lite_Class')) {
|
|
277 |
|
278 |
//registration of the social login widget
|
279 |
function register_apsl_widget() {
|
280 |
-
register_widget('APSL_Lite_Widget');
|
281 |
}
|
282 |
|
283 |
function apsl_login_form_enqueue_style() {
|
284 |
-
wp_enqueue_style('fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION);
|
285 |
-
wp_enqueue_style('apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION);
|
286 |
-
wp_enqueue_style('apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION);
|
287 |
}
|
288 |
|
289 |
function apsl_login_form__enqueue_script() {
|
290 |
-
wp_enqueue_script('apsl-admin-js', APSL_JS_DIR . '/backend.js', array('jquery', 'jquery-ui-sortable'), APSL_VERSION); //registering plugin's admin js
|
291 |
}
|
292 |
|
293 |
function apsl_restore_default_settings() {
|
294 |
$nonce = $_REQUEST['_wpnonce'];
|
295 |
-
if (!empty($_GET) && wp_verify_nonce($nonce, 'apsl-restore-default-settings-nonce')) {
|
296 |
//restore the default plugin activation settings from the activation page.
|
297 |
include( 'inc/backend/activation.php' );
|
298 |
-
$_SESSION['apsl_message'] = __('Settings restored Successfully.', APSL_TEXT_DOMAIN);
|
299 |
-
wp_redirect(admin_url() . 'admin.php?page=' . APSL_TEXT_DOMAIN);
|
300 |
exit;
|
301 |
} else {
|
302 |
-
die('No script kiddies please!');
|
303 |
}
|
304 |
}
|
305 |
|
306 |
-
}
|
307 |
-
|
308 |
-
//class termination
|
309 |
}
|
310 |
-
|
311 |
-
$apsl_object = new APSL_Lite_Class();
|
1 |
+
<?php defined( 'ABSPATH' ) or die( "No script kiddies please!" );
|
2 |
/*
|
3 |
Plugin name: AccessPress Social Login Lite
|
4 |
Plugin URI: https://accesspressthemes.com/wordpress-plugins/accesspress-social-login-lite/
|
5 |
Description: A plugin to add various social logins to a site.
|
6 |
+
version: 2.0.3
|
7 |
Author: AccessPress Themes
|
8 |
Author URI: https://accesspressthemes.com/
|
9 |
Text Domain: apsl-lite
|
12 |
*/
|
13 |
|
14 |
//Declearation of the necessary constants for plugin
|
15 |
+
if ( !defined( 'APSL_VERSION' ) ) {
|
16 |
+
define( 'APSL_VERSION', '2.0.3' );
|
17 |
}
|
18 |
|
19 |
+
if ( !defined( 'APSL_IMAGE_DIR' ) ) {
|
20 |
+
define( 'APSL_IMAGE_DIR', plugin_dir_url( __FILE__ ) . 'images' );
|
21 |
}
|
22 |
|
23 |
+
if ( !defined( 'APSL_JS_DIR' ) ) {
|
24 |
+
define( 'APSL_JS_DIR', plugin_dir_url( __FILE__ ) . 'js' );
|
25 |
}
|
26 |
|
27 |
+
if ( !defined( 'APSL_CSS_DIR' ) ) {
|
28 |
+
define( 'APSL_CSS_DIR', plugin_dir_url( __FILE__ ) . 'css' );
|
29 |
}
|
30 |
|
31 |
+
if ( !defined( 'APSL_LANG_DIR' ) ) {
|
32 |
+
define( 'APSL_LANG_DIR', basename( dirname( __FILE__ ) ) . '/languages/' );
|
33 |
}
|
34 |
|
35 |
+
if ( !defined( 'APSL_TEXT_DOMAIN' ) ) {
|
36 |
+
define( 'APSL_TEXT_DOMAIN', 'apsl-lite' );
|
37 |
}
|
38 |
|
39 |
+
if ( !defined( 'APSL_SETTINGS' ) ) {
|
40 |
+
define( 'APSL_SETTINGS', 'apsl-lite-settings' );
|
41 |
}
|
42 |
|
43 |
+
if ( !defined( 'APSL_PLUGIN_DIR' ) ) {
|
44 |
+
define( 'APSL_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
45 |
}
|
46 |
|
47 |
|
51 |
include_once( 'inc/backend/widget.php' );
|
52 |
|
53 |
// Redefine user notification function
|
54 |
+
if ( !function_exists( 'wp_new_user_notification' ) ) {
|
55 |
|
56 |
+
function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
|
57 |
+
$user = new WP_User( $user_id );
|
58 |
|
59 |
+
$user_login = stripslashes( $user->user_login );
|
60 |
+
$user_email = stripslashes( $user->user_email );
|
61 |
|
62 |
+
$message = sprintf( __( 'New user registration on your site %s:' ), get_option( 'blogname' ) ) . "\r\n\r\n";
|
63 |
+
$message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n";
|
64 |
+
$message .= sprintf( __( 'E-mail: %s' ), $user_email ) . "\r\n";
|
65 |
+
$message .= __( 'Thanks!' );
|
66 |
|
67 |
+
$headers = 'From:' . get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) . '>' . "\r\n";
|
68 |
+
@wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), get_option( 'blogname' ) ), $message, $headers );
|
69 |
|
70 |
+
if ( empty( $plaintext_pass ) )
|
71 |
return;
|
72 |
|
73 |
+
$message = __( 'Hi there,' ) . "\r\n\r\n";
|
74 |
+
$message .= sprintf( __( "Welcome to %s! Here's how to log in:" ), get_option( 'blogname' ) ) . "\r\n\r\n";
|
75 |
$message .= wp_login_url() . "\r\n";
|
76 |
+
$message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n";
|
77 |
+
$message .= sprintf( __( 'Password: %s' ), $plaintext_pass ) . "\r\n\r\n";
|
78 |
+
$message .= sprintf( __( 'If you have any problems, please contact me at %s.' ), get_option( 'admin_email' ) ) . "\r\n\r\n";
|
79 |
+
$message .= __( 'Thanks!' );
|
80 |
|
81 |
+
$headers = 'From:' . get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) . '>' . "\r\n";
|
82 |
|
83 |
+
wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), get_option( 'blogname' ) ), $message, $headers );
|
84 |
}
|
85 |
|
86 |
}
|
87 |
|
88 |
// Declaration of the class
|
89 |
+
if ( !class_exists( 'APSL_Lite_Class' ) ) {
|
90 |
|
91 |
class APSL_Lite_Class {
|
92 |
|
93 |
var $apsl_settings;
|
94 |
|
95 |
function __construct() {
|
96 |
+
$this->apsl_settings = get_option( APSL_SETTINGS );
|
97 |
+
add_action( 'init', array( $this, 'session_init' ) ); //start the session if not started yet.
|
98 |
+
register_activation_hook( __FILE__, array( $this, 'plugin_activation' ) ); //load the default setting for the plugin while activating
|
99 |
+
add_action( 'init', array( $this, 'plugin_text_domain' ) ); //load the plugin text domain
|
100 |
+
add_action( 'admin_menu', array( $this, 'add_apsl_menu' ) ); //register the plugin menu in backend
|
101 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_assets' ) ); //registers all the assets required for wp-admin
|
102 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_assets' ) ); // registers all the assets required for the frontend
|
103 |
+
add_action( 'admin_post_apsl_save_options', array( $this, 'save_settings' ) ); //save settings of a plugin
|
104 |
+
|
105 |
+
$options = get_option( APSL_SETTINGS );
|
106 |
+
if ( $options['apsl_enable_disable_plugin'] == 'yes' ) {
|
107 |
+
if ( in_array( "login_form", $options['apsl_display_options'] ) ) {
|
108 |
+
add_action( 'login_form', array( $this, 'add_social_login' ) ); // add the social logins to the login form
|
109 |
}
|
110 |
|
111 |
+
if ( in_array( "register_form", $options['apsl_display_options'] ) ) {
|
112 |
+
add_action( 'register_form', array( $this, 'add_social_login' ) ); //add the social logins to the registration form
|
113 |
+
add_action( 'after_signup_form', array( $this, 'add_social_login' ) );
|
114 |
}
|
115 |
|
116 |
+
if ( in_array( "comment_form", $options['apsl_display_options'] ) ) {
|
117 |
+
add_action( 'comment_form_top', array( $this, 'add_social_login_form_to_comment' ) ); //add the social logins to the comment form
|
118 |
}
|
119 |
}
|
120 |
|
121 |
+
add_shortcode( 'apsl-login-lite', array( $this, 'apsl_shortcode' ) ); //adds a shortcode
|
122 |
+
add_action( 'init', array( $this, 'login_check' ) ); //check for the social logins
|
123 |
+
add_action( 'widgets_init', array( $this, 'register_apsl_widget' ) ); //register the widget of a plugin
|
124 |
+
add_action( 'login_enqueue_scripts', array( $this, 'apsl_login_form_enqueue_style' ), 10 );
|
125 |
+
add_action( 'login_enqueue_scripts', array( $this, 'apsl_login_form__enqueue_script' ), 1 );
|
126 |
+
add_action( 'admin_post_apsl_restore_default_settings', array( $this, 'apsl_restore_default_settings' ) ); //restores default settings.
|
127 |
|
128 |
/**
|
129 |
* Hook to display custom avatars
|
130 |
*/
|
131 |
+
add_filter( 'get_avatar', array( $this, 'apsl_social_login_custom_avatar' ), 10, 5 );
|
132 |
}
|
133 |
|
134 |
+
function apsl_social_login_custom_avatar( $avatar, $mixed, $size, $default, $alt = '' ) {
|
135 |
+
$options = get_option( APSL_SETTINGS );
|
136 |
|
137 |
//Check if we have an user identifier
|
138 |
+
if ( is_numeric( $mixed ) AND $mixed > 0 ) {
|
139 |
$user_id = $mixed;
|
140 |
}
|
141 |
|
142 |
//Check if we have an user email
|
143 |
+
elseif ( is_string( $mixed ) AND ( $user = get_user_by( 'email', $mixed )) ) {
|
144 |
$user_id = $user->ID;
|
145 |
}
|
146 |
//Check if we have an user object
|
147 |
+
elseif ( is_object( $mixed ) AND property_exists( $mixed, 'user_id' ) AND is_numeric( $mixed->user_id ) ) {
|
148 |
$user_id = $mixed->user_id;
|
149 |
}
|
150 |
//None found
|
153 |
}
|
154 |
|
155 |
//User found?
|
156 |
+
if ( !empty( $user_id ) ) {
|
157 |
|
158 |
//Override current avatar ?
|
159 |
$override_avatar = true;
|
160 |
|
161 |
//Read the avatar
|
162 |
+
$user_meta_thumbnail = get_user_meta( $user_id, 'deuimage', true );
|
163 |
|
164 |
//read user details
|
165 |
+
$user_meta_name = get_user_meta( $user_id, 'first_name', true );
|
166 |
|
167 |
+
if ( $options['apsl_user_avatar_options'] == 'social' ) {
|
168 |
+
$user_picture = (!empty( $user_meta_thumbnail ) ? $user_meta_thumbnail : '');
|
169 |
|
170 |
//Avatar found?
|
171 |
+
if ( $user_picture !== false AND strlen( trim( $user_picture ) ) > 0 ) {
|
172 |
return '<img alt="' . $user_meta_name . '" src="' . $user_picture . '" class="avatar apsl-avatar-social-login avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
|
173 |
}
|
174 |
}
|
178 |
|
179 |
//starts the session with the call of init hook
|
180 |
function session_init() {
|
181 |
+
if ( !session_id() ) {
|
182 |
session_start();
|
183 |
}
|
184 |
}
|
185 |
|
186 |
//load the default settings of the plugin
|
187 |
function plugin_activation() {
|
188 |
+
if ( !get_option( APSL_SETTINGS ) ) {
|
189 |
include('inc/backend/activation.php');
|
190 |
}
|
191 |
}
|
192 |
|
193 |
//loads the text domain for translation
|
194 |
function plugin_text_domain() {
|
195 |
+
load_plugin_textdomain( APSL_TEXT_DOMAIN, false, APSL_LANG_DIR );
|
196 |
}
|
197 |
|
198 |
//register the plugin menu for backend.
|
199 |
function add_apsl_menu() {
|
200 |
+
add_menu_page( 'AccessPress Social Login Lite', 'AccessPress Social Login Lite', 'manage_options', APSL_TEXT_DOMAIN, array( $this, 'main_page' ), APSL_IMAGE_DIR . '/icon.png' );
|
|
|
201 |
}
|
202 |
|
203 |
//menu page
|
207 |
|
208 |
//registration of the backend assets
|
209 |
function register_admin_assets() {
|
210 |
+
wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
|
211 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == APSL_TEXT_DOMAIN ) {
|
|
|
|
|
212 |
//backend scripts
|
213 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
214 |
+
wp_enqueue_script( 'apsl-admin-js', APSL_JS_DIR . '/backend.js', array( 'jquery', 'jquery-ui-sortable' ), APSL_VERSION ); //registering plugin's admin js
|
215 |
//register backend css
|
216 |
+
wp_enqueue_style( 'apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION );
|
217 |
}
|
218 |
}
|
219 |
|
220 |
//registration of the plugins frontend assets
|
221 |
function register_frontend_assets() {
|
222 |
//register frontend scripts
|
223 |
+
wp_enqueue_script( 'apsl-frontend-js', APSL_JS_DIR . '/frontend.js', array( 'jquery' ), APSL_VERSION );
|
224 |
|
225 |
//register frontend css
|
226 |
+
wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
|
227 |
+
wp_enqueue_style( 'apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION );
|
228 |
}
|
229 |
|
230 |
//save the settings of a plugin
|
231 |
function save_settings() {
|
232 |
+
if ( isset( $_POST['apsl_save_settings'] ) && $_POST['apsl_settings_action'] && wp_verify_nonce( $_POST['apsl_settings_action'], 'apsl_nonce_save_settings' ) ) {
|
233 |
include('inc/backend/save-settings.php');
|
234 |
} else {
|
235 |
+
die( 'No script kiddies please!' );
|
236 |
}
|
237 |
}
|
238 |
|
239 |
//function to add the social login in the login and registration form.
|
240 |
function add_social_login() {
|
241 |
+
if ( !is_user_logged_in() ) {
|
242 |
include('inc/frontend/login_integration.php');
|
243 |
}
|
244 |
}
|
245 |
|
246 |
//function to add the social login in the comment form.
|
247 |
function add_social_login_form_to_comment() {
|
248 |
+
$options = get_option( APSL_SETTINGS );
|
|
|
|
|
|
|
249 |
$login_text = $options['apsl_title_text_field'];
|
250 |
+
if ( !is_user_logged_in() ) {
|
251 |
?>
|
252 |
<?php
|
253 |
|
254 |
+
echo do_shortcode( "[apsl-login-lite login_text='{$login_text}']" );
|
255 |
}
|
256 |
}
|
257 |
|
258 |
//function for adding shortcode of a plugin
|
259 |
+
function apsl_shortcode( $attr ) {
|
260 |
ob_start();
|
261 |
include('inc/frontend/shortcode.php');
|
262 |
$html = ob_get_contents();
|
271 |
|
272 |
//registration of the social login widget
|
273 |
function register_apsl_widget() {
|
274 |
+
register_widget( 'APSL_Lite_Widget' );
|
275 |
}
|
276 |
|
277 |
function apsl_login_form_enqueue_style() {
|
278 |
+
wp_enqueue_style( 'fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', '', APSL_VERSION );
|
279 |
+
wp_enqueue_style( 'apsl-backend-css', APSL_CSS_DIR . '/backend.css', '', APSL_VERSION );
|
280 |
+
wp_enqueue_style( 'apsl-frontend-css', APSL_CSS_DIR . '/frontend.css', '', APSL_VERSION );
|
281 |
}
|
282 |
|
283 |
function apsl_login_form__enqueue_script() {
|
284 |
+
wp_enqueue_script( 'apsl-admin-js', APSL_JS_DIR . '/backend.js', array( 'jquery', 'jquery-ui-sortable' ), APSL_VERSION ); //registering plugin's admin js
|
285 |
}
|
286 |
|
287 |
function apsl_restore_default_settings() {
|
288 |
$nonce = $_REQUEST['_wpnonce'];
|
289 |
+
if ( !empty( $_GET ) && wp_verify_nonce( $nonce, 'apsl-restore-default-settings-nonce' ) ) {
|
290 |
//restore the default plugin activation settings from the activation page.
|
291 |
include( 'inc/backend/activation.php' );
|
292 |
+
$_SESSION['apsl_message'] = __( 'Settings restored Successfully.', APSL_TEXT_DOMAIN );
|
293 |
+
wp_redirect( admin_url() . 'admin.php?page=' . APSL_TEXT_DOMAIN );
|
294 |
exit;
|
295 |
} else {
|
296 |
+
die( 'No script kiddies please!' );
|
297 |
}
|
298 |
}
|
299 |
|
300 |
+
}//class termination
|
|
|
|
|
301 |
}
|
302 |
+
$apsl_object = new APSL_Lite_Class();
|
|
inc/backend/activation.php
CHANGED
@@ -1,32 +1,31 @@
|
|
1 |
-
<?php defined('ABSPATH') or die('No script kiddies please!'); ?>
|
2 |
<?php
|
3 |
-
|
4 |
$apsl_settings = array();
|
5 |
|
6 |
-
$social_networks = array(0 => 'facebook', 1 => 'twitter', 2 => 'google');
|
7 |
|
8 |
$apsl_settings['network_ordering'] = $social_networks;
|
9 |
|
10 |
//facebook settings
|
11 |
$facebook_parameters = array(
|
12 |
-
'apsl_facebook_enable'
|
13 |
-
'apsl_facebook_app_id'
|
14 |
-
'apsl_facebook_app_secret'
|
15 |
);
|
16 |
$apsl_settings['apsl_facebook_settings'] = $facebook_parameters;
|
17 |
|
18 |
//twitter settings
|
19 |
$twitter_parameters = array(
|
20 |
-
'apsl_twitter_enable'
|
21 |
-
'apsl_twitter_api_key'
|
22 |
-
'apsl_twitter_api_secret'
|
23 |
);
|
24 |
$apsl_settings['apsl_twitter_settings'] = $twitter_parameters;
|
25 |
|
26 |
//google settings
|
27 |
$google_parameters = array(
|
28 |
-
'apsl_google_enable'
|
29 |
-
'apsl_google_client_id'
|
30 |
'apsl_google_client_secret' => ''
|
31 |
);
|
32 |
|
@@ -34,20 +33,20 @@ $apsl_settings['apsl_google_settings'] = $google_parameters;
|
|
34 |
|
35 |
$apsl_settings['apsl_enable_disable_plugin'] = 'yes';
|
36 |
|
37 |
-
$display_options = array('login_form', 'register_form', 'comment_form');
|
38 |
-
$apsl_settings['apsl_display_options']
|
39 |
|
40 |
-
$apsl_settings['apsl_icon_theme']
|
41 |
|
42 |
$apsl_settings['apsl_title_text_field'] = 'Social connect:';
|
43 |
-
$apsl_settings['apsl_custom_logout_redirect_options']
|
44 |
-
$apsl_settings['apsl_custom_logout_redirect_link']
|
45 |
|
46 |
-
$apsl_settings['apsl_custom_login_redirect_options']
|
47 |
-
$apsl_settings['apsl_custom_login_redirect_link']
|
48 |
|
49 |
-
$apsl_settings['apsl_user_avatar_options']
|
50 |
|
51 |
-
$apsl_settings['apsl_send_email_notification_options']
|
52 |
|
53 |
-
update_option(APSL_SETTINGS, $apsl_settings);
|
1 |
+
<?php defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); ?>
|
2 |
<?php
|
|
|
3 |
$apsl_settings = array();
|
4 |
|
5 |
+
$social_networks = array( 0 => 'facebook', 1 => 'twitter', 2 => 'google' );
|
6 |
|
7 |
$apsl_settings['network_ordering'] = $social_networks;
|
8 |
|
9 |
//facebook settings
|
10 |
$facebook_parameters = array(
|
11 |
+
'apsl_facebook_enable' => '0',
|
12 |
+
'apsl_facebook_app_id' => '',
|
13 |
+
'apsl_facebook_app_secret' => ''
|
14 |
);
|
15 |
$apsl_settings['apsl_facebook_settings'] = $facebook_parameters;
|
16 |
|
17 |
//twitter settings
|
18 |
$twitter_parameters = array(
|
19 |
+
'apsl_twitter_enable' => '0',
|
20 |
+
'apsl_twitter_api_key' => '',
|
21 |
+
'apsl_twitter_api_secret' => ''
|
22 |
);
|
23 |
$apsl_settings['apsl_twitter_settings'] = $twitter_parameters;
|
24 |
|
25 |
//google settings
|
26 |
$google_parameters = array(
|
27 |
+
'apsl_google_enable' => '0',
|
28 |
+
'apsl_google_client_id' => '',
|
29 |
'apsl_google_client_secret' => ''
|
30 |
);
|
31 |
|
33 |
|
34 |
$apsl_settings['apsl_enable_disable_plugin'] = 'yes';
|
35 |
|
36 |
+
$display_options = array( 'login_form', 'register_form', 'comment_form' );
|
37 |
+
$apsl_settings['apsl_display_options'] = $display_options;
|
38 |
|
39 |
+
$apsl_settings['apsl_icon_theme'] = '1';
|
40 |
|
41 |
$apsl_settings['apsl_title_text_field'] = 'Social connect:';
|
42 |
+
$apsl_settings['apsl_custom_logout_redirect_options'] = 'home';
|
43 |
+
$apsl_settings['apsl_custom_logout_redirect_link'] = '';
|
44 |
|
45 |
+
$apsl_settings['apsl_custom_login_redirect_options'] = 'home';
|
46 |
+
$apsl_settings['apsl_custom_login_redirect_link'] = '';
|
47 |
|
48 |
+
$apsl_settings['apsl_user_avatar_options'] = 'default';
|
49 |
|
50 |
+
$apsl_settings['apsl_send_email_notification_options'] = 'yes';
|
51 |
|
52 |
+
update_option( APSL_SETTINGS, $apsl_settings );
|
inc/backend/how-to-use.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
<li>App ID: App id of the social media.</li>
|
10 |
<li>App secret: App secret of the social media.</li>
|
11 |
</ul>
|
12 |
-
To get the App ID and App Secret please follow the instructions(notes).
|
13 |
|
14 |
<dt><strong>Other settings:</strong></dt>
|
15 |
<dd>
|
@@ -18,7 +18,7 @@
|
|
18 |
<li>Enable or disable the social login.</li>
|
19 |
<li>Options to enable the social logins for login form, registration form and in comments.</li>
|
20 |
<li>Options to choose the pre available themes, You can choose any one theme from the pre available 4 themes.</li>
|
21 |
-
<li>Login text: Here you can setup the login text as per your
|
22 |
</ul>
|
23 |
</dd>
|
24 |
|
@@ -27,7 +27,7 @@
|
|
27 |
<ul class="how-list">
|
28 |
<li>Example 1: [apsl-login-lite login_text='Social Connection']</li>
|
29 |
<li>Shortcode attributes: <br />
|
30 |
-
i. login_text:
|
31 |
</li>
|
32 |
</ul>
|
33 |
</p></dd>
|
9 |
<li>App ID: App id of the social media.</li>
|
10 |
<li>App secret: App secret of the social media.</li>
|
11 |
</ul>
|
12 |
+
To get the App ID and App Secret please follow the instructions(notes section) for each social profile.
|
13 |
|
14 |
<dt><strong>Other settings:</strong></dt>
|
15 |
<dd>
|
18 |
<li>Enable or disable the social login.</li>
|
19 |
<li>Options to enable the social logins for login form, registration form and in comments.</li>
|
20 |
<li>Options to choose the pre available themes, You can choose any one theme from the pre available 4 themes.</li>
|
21 |
+
<li>Login text: Here you can setup the login text as per your needs.</li>
|
22 |
</ul>
|
23 |
</dd>
|
24 |
|
27 |
<ul class="how-list">
|
28 |
<li>Example 1: [apsl-login-lite login_text='Social Connection']</li>
|
29 |
<li>Shortcode attributes: <br />
|
30 |
+
i. login_text: You can use the custom login text for the shortcode using this attribute.<br />
|
31 |
</li>
|
32 |
</ul>
|
33 |
</p></dd>
|
inc/backend/main-page.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php defined('ABSPATH') or die("No script kiddies please!"); ?>
|
2 |
<div class="wrap"><div class='apsl-outer-wrapper'>
|
3 |
|
4 |
<div class="apsl-setting-header clearfix">
|
5 |
|
6 |
<div class="apsl-headerlogo">
|
7 |
-
<div class="logo-wrap"> <img src="<?php echo APSL_IMAGE_DIR; ?>/logo.png" alt="<?php esc_attr_e('AccessPress Social Login Lite', APSL_TEXT_DOMAIN); ?>" /></div>
|
8 |
-
<div class="logo-content"><?php esc_attr_e('AccessPress Social Login Lite', APSL_TEXT_DOMAIN); ?><br />
|
9 |
-
<span class='plugin-version'><?php _e('version ' . APSL_VERSION, APSL_TEXT_DOMAIN); ?></span></div>
|
10 |
</div>
|
11 |
|
12 |
<div class="apsl-right-header-block">
|
@@ -37,25 +37,27 @@
|
|
37 |
<div class="clear"></div>
|
38 |
|
39 |
<?php
|
40 |
-
$options = get_option(APSL_SETTINGS);
|
41 |
//$this->print_array($options);
|
42 |
?>
|
43 |
|
44 |
-
<?php if (isset($_SESSION['apsl_message'])) { ?>
|
45 |
<div class="apsl-message">
|
46 |
-
<p> <?php echo $_SESSION['apsl_message'];
|
|
|
|
|
47 |
</div>
|
48 |
-
|
49 |
<div class='apsl-networks'>
|
50 |
<div class='apsl-network-options'>
|
51 |
<form method="post" action="<?php echo admin_url() . 'admin-post.php' ?>">
|
52 |
<input type="hidden" name="action" value="apsl_save_options"/>
|
53 |
<div class='apsl-settings-tabs-wrapper clearfix'>
|
54 |
<ul class='apsl-tab-wrapper-fix clearfix'>
|
55 |
-
<li><a href='javascript: void(0);' id='apsl-networks-settings' class='apsl-settings-tab apsl-active-tab' ><?php _e('Network settings', APSL_TEXT_DOMAIN) ?></a></li>
|
56 |
-
<li><a href='javascript: void(0);' id='apsl-theme-settings' class='apsl-settings-tab' ><?php _e('Other settings', APSL_TEXT_DOMAIN) ?></a></li>
|
57 |
-
<li><a href='javascript: void(0);' id='apsl-how-to-use' class='apsl-settings-tab' ><?php _e('How to use', APSL_TEXT_DOMAIN) ?></a></li>
|
58 |
-
<li><a href='javascript: void(0);' id='apsl-about' class='apsl-settings-tab' ><?php _e('About', APSL_TEXT_DOMAIN) ?></a></li>
|
59 |
</ul>
|
60 |
</div>
|
61 |
<div class="clear"></div>
|
@@ -63,31 +65,36 @@
|
|
63 |
<div class='apsl-tab-contents' id='tab-apsl-networks-settings'>
|
64 |
|
65 |
<div class='network-settings'>
|
66 |
-
<?php foreach ($options['network_ordering'] as $key => $value): ?>
|
67 |
-
<?php
|
|
|
68 |
case 'facebook':
|
69 |
?>
|
70 |
<div class='apsl-settings apsl-facebook-settings'>
|
71 |
<!-- Facebook Settings -->
|
72 |
-
<div class='apsl-label'><?php _e("Facebook", APSL_TEXT_DOMAIN); ?><span class='apsl_show_hide' id='apsl_show_hide_<?php echo $value; ?>'><i class="fa fa-caret-down"></i></span> </div>
|
73 |
<div class='apsl_network_settings_wrapper' id='apsl_network_settings_<?php echo $value; ?>' style='display:none'>
|
74 |
<div class='apsl-enable-disable'>
|
75 |
-
<label><?php _e('Enable?', APSL_TEXT_DOMAIN); ?></label>
|
76 |
<input type='hidden' name='network_ordering[]' value='facebook' />
|
77 |
-
<input type="checkbox" id='aspl-facbook-enable' value='enable' name='apsl_facebook_settings[apsl_facebook_enable]' <?php checked('enable', $options['apsl_facebook_settings']['apsl_facebook_enable']); ?> />
|
78 |
</div>
|
79 |
<div class='apsl-app-id-wrapper'>
|
80 |
-
<label><?php _e('App ID:', APSL_TEXT_DOMAIN); ?></label><input type='text' id='apsl-facebook-app-id' name='apsl_facebook_settings[apsl_facebook_app_id]' value='<?php
|
81 |
-
|
82 |
-
|
|
|
|
|
83 |
</div>
|
84 |
<div class='apsl-app-secret-wrapper'>
|
85 |
-
<label><?php _e('App Secret:', APSL_TEXT_DOMAIN); ?></label><input type='text' id='apsl-facebook-app-secret' name='apsl_facebook_settings[apsl_facebook_app_secret]' value='<?php
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
</div>
|
89 |
<div class='apsl-info'>
|
90 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?></span> <br />
|
91 |
<span class='apsl-info-content'>You need to create a new facebook API Applitation to setup facebook login. Please follow the instructions to create new app.</span>
|
92 |
<br />
|
93 |
<ul class='apsl-info-lists'>
|
@@ -109,28 +116,32 @@
|
|
109 |
<?php case 'twitter': ?>
|
110 |
<div class='apsl-settings apsl-twitter-settings'>
|
111 |
<!-- Twitter Settings -->
|
112 |
-
<div class='apsl-label'><?php _e("Twitter", APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide' id='apsl_show_hide_<?php echo $value; ?>'><i class="fa fa-caret-down"></i></span> </div>
|
113 |
<div class='apsl_network_settings_wrapper' id='apsl_network_settings_<?php echo $value; ?>' style='display:none'>
|
114 |
<div class='apsl-enable-disable'>
|
115 |
-
<label><?php _e('Enable?', APSL_TEXT_DOMAIN); ?></label>
|
116 |
-
<input type="checkbox" id='aspl-twitter-enable' value='enable' name='apsl_twitter_settings[apsl_twitter_enable]' <?php checked('enable', $options['apsl_twitter_settings']['apsl_twitter_enable']); ?> />
|
117 |
</div>
|
118 |
|
119 |
<div class='apsl-app-id-wrapper'>
|
120 |
-
<label><?php _e('Consumer Key (API Key):', APSL_TEXT_DOMAIN); ?></label><input type='text' id='apsl-twitter-app-id' name='apsl_twitter_settings[apsl_twitter_api_key]' value='<?php
|
121 |
-
|
122 |
-
|
|
|
|
|
123 |
</div>
|
124 |
|
125 |
<div class='apsl-app-secret-wrapper'>
|
126 |
-
<label><?php _e('Consumer Secret (API Secret):', APSL_TEXT_DOMAIN); ?></label><input type='text' id='apsl-twitter-app-secret' name='apsl_twitter_settings[apsl_twitter_api_secret]' value='<?php
|
127 |
-
|
128 |
-
|
|
|
|
|
129 |
</div>
|
130 |
|
131 |
<input type='hidden' name='network_ordering[]' value='twitter' />
|
132 |
<div class='apsl-info'>
|
133 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?> <br /> </span>
|
134 |
<span class='apsl-info-content'>You need to create new twitter API application to setup the twitter login. Please follow the instructions to create new app.</span>
|
135 |
<ul class='apsl-info-lists'>
|
136 |
<li>Go to <a href='https://apps.twitter.com/' target='_blank'>https://apps.twitter.com/</a></li>
|
@@ -144,31 +155,36 @@
|
|
144 |
</div>
|
145 |
</div>
|
146 |
</div>
|
147 |
-
<?php
|
|
|
148 |
|
149 |
case 'google':
|
150 |
?>
|
151 |
<div class='apsl-settings apsl-google-settings'>
|
152 |
<!-- Google Settings -->
|
153 |
-
<div class='apsl-label'><?php _e("Google", APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide' id='apsl_show_hide_<?php echo $value; ?>'><i class="fa fa-caret-down"></i></span> </div>
|
154 |
<div class='apsl_network_settings_wrapper' id='apsl_network_settings_<?php echo $value; ?>' style='display:none'>
|
155 |
<div class='apsl-enable-disable'>
|
156 |
-
<label><?php _e('Enable?', APSL_TEXT_DOMAIN); ?></label>
|
157 |
-
<input type="checkbox" id='aspl-google-enable' value='enable' name='apsl_google_settings[apsl_google_enable]' <?php checked('enable', $options['apsl_google_settings']['apsl_google_enable']); ?> />
|
158 |
</div>
|
159 |
<div class='apsl-app-id-wrapper'>
|
160 |
-
<label><?php _e('Client ID:', APSL_TEXT_DOMAIN); ?></label><input type='text' id='apsl-google-client-id' name='apsl_google_settings[apsl_google_client_id]' value='<?php
|
161 |
-
|
162 |
-
|
|
|
|
|
163 |
</div>
|
164 |
<div class='apsl-app-secret-wrapper'>
|
165 |
-
<label><?php _e('Client Secret:', APSL_TEXT_DOMAIN); ?></label><input type='text' id='apsl-google-client-secret' name='apsl_google_settings[apsl_google_client_secret]' value='<?php
|
166 |
-
|
167 |
-
|
|
|
|
|
168 |
</div>
|
169 |
<input type='hidden' name='network_ordering[]' value='google' />
|
170 |
<div class='apsl-info'>
|
171 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?></span> <br />
|
172 |
<span class='apsl-info-content'>You need to create new google API application to setup the google login. Please follow the instructions to create new application.</span>
|
173 |
<ul class='apsl-info-lists'>
|
174 |
<li>Go to <a href='https://console.developers.google.com/project' target='_blank'>https://console.developers.google.com/project.</a> </li>
|
@@ -207,12 +223,12 @@
|
|
207 |
|
208 |
<div class='apsl-settings'>
|
209 |
<div class='apsl-enable-disable-opt'>
|
210 |
-
<div class="apsl-label"><?php _e('Social login', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
211 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
212 |
<p class="social-login">
|
213 |
-
<span><?php _e('Enable social login?', APSL_TEXT_DOMAIN); ?></span>
|
214 |
-
<input type='radio' id='apsl_enable_plugin' name='apsl_enable_disable_plugin' value='yes' <?php checked($options['apsl_enable_disable_plugin'], 'yes', 'true'); ?> /> <label for='apsl_enable_plugin'>Yes</label>
|
215 |
-
<input type='radio' id='apsl_disable_plugin' name='apsl_enable_disable_plugin' value='no' <?php checked($options['apsl_enable_disable_plugin'], 'no', 'true'); ?> /> <label for='apsl_disable_plugin'>No</label>
|
216 |
</p>
|
217 |
</div>
|
218 |
</div>
|
@@ -220,47 +236,55 @@
|
|
220 |
|
221 |
<div class='apsl-settings'>
|
222 |
<div class='apsl-display-options'>
|
223 |
-
<div class="apsl-label"><?php _e('Display options', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span></div>
|
224 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
225 |
-
<p><?php _e('Please choose the options where you want to display the social login form.', APSL_TEXT_DOMAIN); ?></p>
|
226 |
-
<p><input type="checkbox" id="apsl_login_form" value="login_form" name="apsl_display_options[]" <?php
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
</div>
|
236 |
</div>
|
237 |
</div>
|
238 |
|
239 |
<div class='apsl-settings'>
|
240 |
<div class='apsl-themes-wrapper'>
|
241 |
-
<div class="apsl-label"><?php _e('Available icon themes', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
242 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
243 |
-
|
244 |
<div class='apsl-theme apsl-theme-<?php echo $i; ?>'>
|
245 |
-
<label><input type="radio" id="apsl-theme-<?php echo $i; ?>" value="<?php echo $i; ?>" class="apsl-theme apsl-png-theme" name="apsl_icon_theme" <?php checked($i, $options['apsl_icon_theme']); ?> >
|
246 |
-
<span><?php _e('Theme ' . $i, APSL_TEXT_DOMAIN); ?></span></label>
|
247 |
<div class="apsl-theme-previewbox">
|
248 |
<img src="<?php echo APSL_IMAGE_DIR; ?>/preview-<?php echo $i; ?>.jpg" alt="theme preview">
|
249 |
</div>
|
250 |
</div>
|
251 |
-
|
252 |
</div>
|
253 |
</div>
|
254 |
</div>
|
255 |
|
256 |
<div class='apsl-settings'>
|
257 |
<div class='apsl-text-settings'>
|
258 |
-
<div class="apsl-label"><?php _e('Text settings', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
259 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
260 |
<p class='apsl-title-text-field'>
|
261 |
-
<span><?php _e('Login text:', APSL_TEXT_DOMAIN); ?></span> <input type='text' name='apsl_title_text_field' id='apsl-title-text' value='<?php
|
262 |
-
|
263 |
-
|
|
|
|
|
264 |
</p>
|
265 |
</div>
|
266 |
</div>
|
@@ -268,30 +292,40 @@
|
|
268 |
|
269 |
<div class='apsl-settings'>
|
270 |
<div class='apsl-logout-redirect-settings'>
|
271 |
-
<div class="apsl-label"><?php _e('Logout redirect link', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
272 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
273 |
-
<input type='radio' id='apsl_custom_logout_redirect_home' class='apsl_custom_logout_redirect_options' name='apsl_custom_logout_redirect_options' value='home' <?php
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
<
|
286 |
-
|
287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
<p class='apsl-title-text-field'>
|
289 |
-
<span><?php _e('Logout redirect page:', APSL_TEXT_DOMAIN); ?></span> <input type='text' name='apsl_custom_logout_redirect_link' id='apsl-custom-logout-redirect-link' value='<?php
|
290 |
-
|
291 |
-
|
|
|
|
|
292 |
</p>
|
293 |
<div class='apsl-info'>
|
294 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?></span> <br />
|
295 |
<span class='apsl-info-content'>Please set this value if you want to redirect the user to the custom page url(full url). If this field is not set they will be redirected back to current page.</span>
|
296 |
</div>
|
297 |
</div>
|
@@ -301,34 +335,44 @@
|
|
301 |
|
302 |
<div class='apsl-settings'>
|
303 |
<div class='apsl-login-redirect-settings'>
|
304 |
-
<div class="apsl-label"><?php _e('Login redirect link', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
305 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
306 |
-
<input type='radio' id='apsl_custom_login_redirect_home' class='apsl_custom_login_redirect_options' name='apsl_custom_login_redirect_options' value='home' <?php
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
312 |
<div class='apsl-custom-login-redirect-link1' >
|
313 |
<div class='apsl-info'>
|
314 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?></span> <br />
|
315 |
<span class='apsl-info-content'> If plugin can't detect what is the redirect uri for the page it will be redirected to home page.</span>
|
316 |
</div>
|
317 |
</div>
|
318 |
-
<input type='radio' id='apsl_custom_login_redirect_custom' class='apsl_custom_login_redirect_options' name='apsl_custom_login_redirect_options' value='custom_page' <?php
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
|
|
|
|
|
|
|
|
325 |
<p class='apsl-title-text-field'>
|
326 |
-
<span><?php _e('Login redirect page:', APSL_TEXT_DOMAIN); ?></span> <input type='text' name='apsl_custom_login_redirect_link' id='apsl-custom-login-redirect-link' value='<?php
|
327 |
-
|
328 |
-
|
|
|
|
|
329 |
</p>
|
330 |
<div class='apsl-info'>
|
331 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?></span> <br />
|
332 |
<span class='apsl-info-content'>Please set this value if you want to redirect the user to the custom page url(full url). If this field is not set they will be redirected back to home page.</span>
|
333 |
</div>
|
334 |
</div>
|
@@ -338,16 +382,20 @@
|
|
338 |
|
339 |
<div class='apsl-settings'>
|
340 |
<div class='apsl-user-avatar-settings'>
|
341 |
-
<div class="apsl-label"><?php _e('User avatar', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
342 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
343 |
-
<input type='radio' id='apsl_user_avatar_default' class='apsl_user_avatar_options' name='apsl_user_avatar_options' value='default' <?php
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
|
|
|
|
|
|
|
|
349 |
<div class='apsl-info'>
|
350 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?></span> <br />
|
351 |
<span class='apsl-info-content'>Please choose the options from where you want your users avatar to be loaded from. If you choose default wordpress avatar it will use the gravatar profile image if user have gravatar profile assocated with their registered email address.</span>
|
352 |
</div>
|
353 |
</div>
|
@@ -356,16 +404,20 @@
|
|
356 |
|
357 |
<div class='apsl-settings'>
|
358 |
<div class='apsl-user-email-settings'>
|
359 |
-
<div class="apsl-label"><?php _e('Email notification settings', APSL_TEXT_DOMAIN); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
360 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
361 |
-
<input type='radio' id='apsl_send_email_notification_yes' class='apsl_send_email_notification_yes' name='apsl_send_email_notification_options' value='yes' <?php
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
|
|
|
|
|
|
|
|
367 |
<div class='apsl-info'>
|
368 |
-
<span class='apsl-info-note'><?php _e('Note:', APSL_TEXT_DOMAIN); ?></span> <br />
|
369 |
<span class='apsl-info-content'>Here you can configure an options to send email notifications about user registration to site admin and user.</span>
|
370 |
</div>
|
371 |
</div>
|
@@ -387,13 +439,13 @@
|
|
387 |
|
388 |
<!-- Save settings Button -->
|
389 |
<div class='apsl-save-settings'>
|
390 |
-
<?php wp_nonce_field('apsl_nonce_save_settings', 'apsl_settings_action'); ?>
|
391 |
-
<input type='submit' class='apsl-submit-settings primary-button' name='apsl_save_settings' value='<?php _e('Save settings', APSL_TEXT_DOMAIN); ?>' />
|
392 |
</div>
|
393 |
|
394 |
<div class='apsl-restore-settings'>
|
395 |
-
<?php $nonce = wp_create_nonce('apsl-restore-default-settings-nonce'); ?>
|
396 |
-
<a href="<?php echo admin_url() . 'admin-post.php?action=apsl_restore_default_settings&_wpnonce=' . $nonce; ?>" onclick="return confirm('<?php _e('Are you sure you want to restore default settings?', APSL_TEXT_DOMAIN); ?>')"><input type="button" value="Restore Default Settings" class="apsl-reset-button button primary-button"/></a>
|
397 |
</div>
|
398 |
|
399 |
</div>
|
1 |
+
<?php defined( 'ABSPATH' ) or die( "No script kiddies please!" ); ?>
|
2 |
<div class="wrap"><div class='apsl-outer-wrapper'>
|
3 |
|
4 |
<div class="apsl-setting-header clearfix">
|
5 |
|
6 |
<div class="apsl-headerlogo">
|
7 |
+
<div class="logo-wrap"> <img src="<?php echo APSL_IMAGE_DIR; ?>/logo.png" alt="<?php esc_attr_e( 'AccessPress Social Login Lite', APSL_TEXT_DOMAIN ); ?>" /></div>
|
8 |
+
<div class="logo-content"><?php esc_attr_e( 'AccessPress Social Login Lite', APSL_TEXT_DOMAIN ); ?><br />
|
9 |
+
<span class='plugin-version'><?php _e( 'version ' . APSL_VERSION, APSL_TEXT_DOMAIN ); ?></span></div>
|
10 |
</div>
|
11 |
|
12 |
<div class="apsl-right-header-block">
|
37 |
<div class="clear"></div>
|
38 |
|
39 |
<?php
|
40 |
+
$options = get_option( APSL_SETTINGS );
|
41 |
//$this->print_array($options);
|
42 |
?>
|
43 |
|
44 |
+
<?php if ( isset( $_SESSION['apsl_message'] ) ) { ?>
|
45 |
<div class="apsl-message">
|
46 |
+
<p> <?php echo $_SESSION['apsl_message'];
|
47 |
+
unset( $_SESSION['apsl_message'] ); ?>
|
48 |
+
</p>
|
49 |
</div>
|
50 |
+
<?php } ?>
|
51 |
<div class='apsl-networks'>
|
52 |
<div class='apsl-network-options'>
|
53 |
<form method="post" action="<?php echo admin_url() . 'admin-post.php' ?>">
|
54 |
<input type="hidden" name="action" value="apsl_save_options"/>
|
55 |
<div class='apsl-settings-tabs-wrapper clearfix'>
|
56 |
<ul class='apsl-tab-wrapper-fix clearfix'>
|
57 |
+
<li><a href='javascript: void(0);' id='apsl-networks-settings' class='apsl-settings-tab apsl-active-tab' ><?php _e( 'Network settings', APSL_TEXT_DOMAIN ) ?></a></li>
|
58 |
+
<li><a href='javascript: void(0);' id='apsl-theme-settings' class='apsl-settings-tab' ><?php _e( 'Other settings', APSL_TEXT_DOMAIN ) ?></a></li>
|
59 |
+
<li><a href='javascript: void(0);' id='apsl-how-to-use' class='apsl-settings-tab' ><?php _e( 'How to use', APSL_TEXT_DOMAIN ) ?></a></li>
|
60 |
+
<li><a href='javascript: void(0);' id='apsl-about' class='apsl-settings-tab' ><?php _e( 'About', APSL_TEXT_DOMAIN ) ?></a></li>
|
61 |
</ul>
|
62 |
</div>
|
63 |
<div class="clear"></div>
|
65 |
<div class='apsl-tab-contents' id='tab-apsl-networks-settings'>
|
66 |
|
67 |
<div class='network-settings'>
|
68 |
+
<?php foreach ( $options['network_ordering'] as $key => $value ): ?>
|
69 |
+
<?php
|
70 |
+
switch ( $value ) {
|
71 |
case 'facebook':
|
72 |
?>
|
73 |
<div class='apsl-settings apsl-facebook-settings'>
|
74 |
<!-- Facebook Settings -->
|
75 |
+
<div class='apsl-label'><?php _e( "Facebook", APSL_TEXT_DOMAIN ); ?><span class='apsl_show_hide' id='apsl_show_hide_<?php echo $value; ?>'><i class="fa fa-caret-down"></i></span> </div>
|
76 |
<div class='apsl_network_settings_wrapper' id='apsl_network_settings_<?php echo $value; ?>' style='display:none'>
|
77 |
<div class='apsl-enable-disable'>
|
78 |
+
<label><?php _e( 'Enable?', APSL_TEXT_DOMAIN ); ?></label>
|
79 |
<input type='hidden' name='network_ordering[]' value='facebook' />
|
80 |
+
<input type="checkbox" id='aspl-facbook-enable' value='enable' name='apsl_facebook_settings[apsl_facebook_enable]' <?php checked( 'enable', $options['apsl_facebook_settings']['apsl_facebook_enable'] ); ?> />
|
81 |
</div>
|
82 |
<div class='apsl-app-id-wrapper'>
|
83 |
+
<label><?php _e( 'App ID:', APSL_TEXT_DOMAIN ); ?></label><input type='text' id='apsl-facebook-app-id' name='apsl_facebook_settings[apsl_facebook_app_id]' value='<?php
|
84 |
+
if ( isset( $options['apsl_facebook_settings']['apsl_facebook_app_id'] ) ) {
|
85 |
+
echo $options['apsl_facebook_settings']['apsl_facebook_app_id'];
|
86 |
+
}
|
87 |
+
?>' />
|
88 |
</div>
|
89 |
<div class='apsl-app-secret-wrapper'>
|
90 |
+
<label><?php _e( 'App Secret:', APSL_TEXT_DOMAIN ); ?></label><input type='text' id='apsl-facebook-app-secret' name='apsl_facebook_settings[apsl_facebook_app_secret]' value='<?php
|
91 |
+
if ( isset( $options['apsl_facebook_settings']['apsl_facebook_app_secret'] ) ) {
|
92 |
+
echo $options['apsl_facebook_settings']['apsl_facebook_app_secret'];
|
93 |
+
}
|
94 |
+
?>' />
|
95 |
</div>
|
96 |
<div class='apsl-info'>
|
97 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?></span> <br />
|
98 |
<span class='apsl-info-content'>You need to create a new facebook API Applitation to setup facebook login. Please follow the instructions to create new app.</span>
|
99 |
<br />
|
100 |
<ul class='apsl-info-lists'>
|
116 |
<?php case 'twitter': ?>
|
117 |
<div class='apsl-settings apsl-twitter-settings'>
|
118 |
<!-- Twitter Settings -->
|
119 |
+
<div class='apsl-label'><?php _e( "Twitter", APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide' id='apsl_show_hide_<?php echo $value; ?>'><i class="fa fa-caret-down"></i></span> </div>
|
120 |
<div class='apsl_network_settings_wrapper' id='apsl_network_settings_<?php echo $value; ?>' style='display:none'>
|
121 |
<div class='apsl-enable-disable'>
|
122 |
+
<label><?php _e( 'Enable?', APSL_TEXT_DOMAIN ); ?></label>
|
123 |
+
<input type="checkbox" id='aspl-twitter-enable' value='enable' name='apsl_twitter_settings[apsl_twitter_enable]' <?php checked( 'enable', $options['apsl_twitter_settings']['apsl_twitter_enable'] ); ?> />
|
124 |
</div>
|
125 |
|
126 |
<div class='apsl-app-id-wrapper'>
|
127 |
+
<label><?php _e( 'Consumer Key (API Key):', APSL_TEXT_DOMAIN ); ?></label><input type='text' id='apsl-twitter-app-id' name='apsl_twitter_settings[apsl_twitter_api_key]' value='<?php
|
128 |
+
if ( isset( $options['apsl_twitter_settings']['apsl_twitter_api_key'] ) ) {
|
129 |
+
echo $options['apsl_twitter_settings']['apsl_twitter_api_key'];
|
130 |
+
}
|
131 |
+
?>' />
|
132 |
</div>
|
133 |
|
134 |
<div class='apsl-app-secret-wrapper'>
|
135 |
+
<label><?php _e( 'Consumer Secret (API Secret):', APSL_TEXT_DOMAIN ); ?></label><input type='text' id='apsl-twitter-app-secret' name='apsl_twitter_settings[apsl_twitter_api_secret]' value='<?php
|
136 |
+
if ( isset( $options['apsl_twitter_settings']['apsl_twitter_api_secret'] ) ) {
|
137 |
+
echo $options['apsl_twitter_settings']['apsl_twitter_api_secret'];
|
138 |
+
}
|
139 |
+
?>' />
|
140 |
</div>
|
141 |
|
142 |
<input type='hidden' name='network_ordering[]' value='twitter' />
|
143 |
<div class='apsl-info'>
|
144 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?> <br /> </span>
|
145 |
<span class='apsl-info-content'>You need to create new twitter API application to setup the twitter login. Please follow the instructions to create new app.</span>
|
146 |
<ul class='apsl-info-lists'>
|
147 |
<li>Go to <a href='https://apps.twitter.com/' target='_blank'>https://apps.twitter.com/</a></li>
|
155 |
</div>
|
156 |
</div>
|
157 |
</div>
|
158 |
+
<?php
|
159 |
+
break;
|
160 |
|
161 |
case 'google':
|
162 |
?>
|
163 |
<div class='apsl-settings apsl-google-settings'>
|
164 |
<!-- Google Settings -->
|
165 |
+
<div class='apsl-label'><?php _e( "Google", APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide' id='apsl_show_hide_<?php echo $value; ?>'><i class="fa fa-caret-down"></i></span> </div>
|
166 |
<div class='apsl_network_settings_wrapper' id='apsl_network_settings_<?php echo $value; ?>' style='display:none'>
|
167 |
<div class='apsl-enable-disable'>
|
168 |
+
<label><?php _e( 'Enable?', APSL_TEXT_DOMAIN ); ?></label>
|
169 |
+
<input type="checkbox" id='aspl-google-enable' value='enable' name='apsl_google_settings[apsl_google_enable]' <?php checked( 'enable', $options['apsl_google_settings']['apsl_google_enable'] ); ?> />
|
170 |
</div>
|
171 |
<div class='apsl-app-id-wrapper'>
|
172 |
+
<label><?php _e( 'Client ID:', APSL_TEXT_DOMAIN ); ?></label><input type='text' id='apsl-google-client-id' name='apsl_google_settings[apsl_google_client_id]' value='<?php
|
173 |
+
if ( isset( $options['apsl_google_settings']['apsl_google_client_id'] ) ) {
|
174 |
+
echo $options['apsl_google_settings']['apsl_google_client_id'];
|
175 |
+
}
|
176 |
+
?>' />
|
177 |
</div>
|
178 |
<div class='apsl-app-secret-wrapper'>
|
179 |
+
<label><?php _e( 'Client Secret:', APSL_TEXT_DOMAIN ); ?></label><input type='text' id='apsl-google-client-secret' name='apsl_google_settings[apsl_google_client_secret]' value='<?php
|
180 |
+
if ( isset( $options['apsl_google_settings']['apsl_google_client_secret'] ) ) {
|
181 |
+
echo $options['apsl_google_settings']['apsl_google_client_secret'];
|
182 |
+
}
|
183 |
+
?>' />
|
184 |
</div>
|
185 |
<input type='hidden' name='network_ordering[]' value='google' />
|
186 |
<div class='apsl-info'>
|
187 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?></span> <br />
|
188 |
<span class='apsl-info-content'>You need to create new google API application to setup the google login. Please follow the instructions to create new application.</span>
|
189 |
<ul class='apsl-info-lists'>
|
190 |
<li>Go to <a href='https://console.developers.google.com/project' target='_blank'>https://console.developers.google.com/project.</a> </li>
|
223 |
|
224 |
<div class='apsl-settings'>
|
225 |
<div class='apsl-enable-disable-opt'>
|
226 |
+
<div class="apsl-label"><?php _e( 'Social login', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
227 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
228 |
<p class="social-login">
|
229 |
+
<span><?php _e( 'Enable social login?', APSL_TEXT_DOMAIN ); ?></span>
|
230 |
+
<input type='radio' id='apsl_enable_plugin' name='apsl_enable_disable_plugin' value='yes' <?php checked( $options['apsl_enable_disable_plugin'], 'yes', 'true' ); ?> /> <label for='apsl_enable_plugin'>Yes</label>
|
231 |
+
<input type='radio' id='apsl_disable_plugin' name='apsl_enable_disable_plugin' value='no' <?php checked( $options['apsl_enable_disable_plugin'], 'no', 'true' ); ?> /> <label for='apsl_disable_plugin'>No</label>
|
232 |
</p>
|
233 |
</div>
|
234 |
</div>
|
236 |
|
237 |
<div class='apsl-settings'>
|
238 |
<div class='apsl-display-options'>
|
239 |
+
<div class="apsl-label"><?php _e( 'Display options', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span></div>
|
240 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
241 |
+
<p><?php _e( 'Please choose the options where you want to display the social login form.', APSL_TEXT_DOMAIN ); ?></p>
|
242 |
+
<p><input type="checkbox" id="apsl_login_form" value="login_form" name="apsl_display_options[]" <?php
|
243 |
+
if ( in_array( "login_form", $options['apsl_display_options'] ) ) {
|
244 |
+
echo "checked='checked'";
|
245 |
+
}
|
246 |
+
?> ><label for="apsl_login_form"><?php _e( 'Login Form', APSL_TEXT_DOMAIN ); ?> </label></p>
|
247 |
+
<p><input type="checkbox" id="apsl_register_form" value="register_form" name="apsl_display_options[]" <?php
|
248 |
+
if ( in_array( "register_form", $options['apsl_display_options'] ) ) {
|
249 |
+
echo "checked='checked'";
|
250 |
+
}
|
251 |
+
?> ><label for="apsl_register_form"><?php _e( 'Register Form', APSL_TEXT_DOMAIN ); ?> </label></p>
|
252 |
+
<p><input type="checkbox" id="apsl_comment_form" value="comment_form" name="apsl_display_options[]" <?php
|
253 |
+
if ( in_array( "comment_form", $options['apsl_display_options'] ) ) {
|
254 |
+
echo "checked='checked'";
|
255 |
+
}
|
256 |
+
?> ><label for="apsl_comment_form"><?php _e( 'Comments', APSL_TEXT_DOMAIN ); ?> </label></p>
|
257 |
</div>
|
258 |
</div>
|
259 |
</div>
|
260 |
|
261 |
<div class='apsl-settings'>
|
262 |
<div class='apsl-themes-wrapper'>
|
263 |
+
<div class="apsl-label"><?php _e( 'Available icon themes', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
264 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
265 |
+
<?php for ( $i = 1; $i <= 4; $i++ ): ?>
|
266 |
<div class='apsl-theme apsl-theme-<?php echo $i; ?>'>
|
267 |
+
<label><input type="radio" id="apsl-theme-<?php echo $i; ?>" value="<?php echo $i; ?>" class="apsl-theme apsl-png-theme" name="apsl_icon_theme" <?php checked( $i, $options['apsl_icon_theme'] ); ?> >
|
268 |
+
<span><?php _e( 'Theme ' . $i, APSL_TEXT_DOMAIN ); ?></span></label>
|
269 |
<div class="apsl-theme-previewbox">
|
270 |
<img src="<?php echo APSL_IMAGE_DIR; ?>/preview-<?php echo $i; ?>.jpg" alt="theme preview">
|
271 |
</div>
|
272 |
</div>
|
273 |
+
<?php endfor; ?>
|
274 |
</div>
|
275 |
</div>
|
276 |
</div>
|
277 |
|
278 |
<div class='apsl-settings'>
|
279 |
<div class='apsl-text-settings'>
|
280 |
+
<div class="apsl-label"><?php _e( 'Text settings', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
281 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
282 |
<p class='apsl-title-text-field'>
|
283 |
+
<span><?php _e( 'Login text:', APSL_TEXT_DOMAIN ); ?></span> <input type='text' name='apsl_title_text_field' id='apsl-title-text' value='<?php
|
284 |
+
if ( isset( $options['apsl_title_text_field'] ) && $options['apsl_title_text_field'] != '' ) {
|
285 |
+
echo $options['apsl_title_text_field'];
|
286 |
+
}
|
287 |
+
?>' />
|
288 |
</p>
|
289 |
</div>
|
290 |
</div>
|
292 |
|
293 |
<div class='apsl-settings'>
|
294 |
<div class='apsl-logout-redirect-settings'>
|
295 |
+
<div class="apsl-label"><?php _e( 'Logout redirect link', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
296 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
297 |
+
<input type='radio' id='apsl_custom_logout_redirect_home' class='apsl_custom_logout_redirect_options' name='apsl_custom_logout_redirect_options' value='home' <?php
|
298 |
+
if ( isset( $options['apsl_custom_logout_redirect_options'] ) ) {
|
299 |
+
checked( $options['apsl_custom_logout_redirect_options'], 'home', 'true' );
|
300 |
+
}
|
301 |
+
?> /> <label for='apsl_custom_logout_redirect_home'><?php _e( 'Home page', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
302 |
+
<input type='radio' id='apsl_custom_logout_redirect_current' class='apsl_custom_logout_redirect_options' name='apsl_custom_logout_redirect_options' value='current_page' <?php
|
303 |
+
if ( isset( $options['apsl_custom_logout_redirect_options'] ) ) {
|
304 |
+
checked( $options['apsl_custom_logout_redirect_options'], 'current_page', 'true' );
|
305 |
+
}
|
306 |
+
?> /> <label for='apsl_custom_logout_redirect_current'><?php _e( 'Current page', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
307 |
+
|
308 |
+
|
309 |
+
<input type='radio' id='apsl_custom_logout_redirect_custom' class='apsl_custom_logout_redirect_options' name='apsl_custom_logout_redirect_options' value='custom_page' <?php
|
310 |
+
if ( isset( $options['apsl_custom_logout_redirect_options'] ) ) {
|
311 |
+
checked( $options['apsl_custom_logout_redirect_options'], 'custom_page', 'true' );
|
312 |
+
}
|
313 |
+
?> /> <label for='apsl_custom_logout_redirect_custom'><?php _e( 'Custom page', APSL_TEXT_DOMAIN ); ?></label><br />
|
314 |
+
|
315 |
+
<div class='apsl-custom-logout-redirect-link' <?php if ( isset( $options['apsl_custom_logout_redirect_options'] ) ) {
|
316 |
+
if ( $options['apsl_custom_logout_redirect_options'] == 'custom_page' ) {
|
317 |
+
?> style='display: block' <?php } else { ?> style='display:none' <?php }
|
318 |
+
}
|
319 |
+
?>>
|
320 |
<p class='apsl-title-text-field'>
|
321 |
+
<span><?php _e( 'Logout redirect page:', APSL_TEXT_DOMAIN ); ?></span> <input type='text' name='apsl_custom_logout_redirect_link' id='apsl-custom-logout-redirect-link' value='<?php
|
322 |
+
if ( isset( $options['apsl_custom_logout_redirect_link'] ) && $options['apsl_custom_logout_redirect_link'] != '' ) {
|
323 |
+
echo $options['apsl_custom_logout_redirect_link'];
|
324 |
+
}
|
325 |
+
?>' />
|
326 |
</p>
|
327 |
<div class='apsl-info'>
|
328 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?></span> <br />
|
329 |
<span class='apsl-info-content'>Please set this value if you want to redirect the user to the custom page url(full url). If this field is not set they will be redirected back to current page.</span>
|
330 |
</div>
|
331 |
</div>
|
335 |
|
336 |
<div class='apsl-settings'>
|
337 |
<div class='apsl-login-redirect-settings'>
|
338 |
+
<div class="apsl-label"><?php _e( 'Login redirect link', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
339 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
340 |
+
<input type='radio' id='apsl_custom_login_redirect_home' class='apsl_custom_login_redirect_options' name='apsl_custom_login_redirect_options' value='home' <?php
|
341 |
+
if ( isset( $options['apsl_custom_login_redirect_options'] ) ) {
|
342 |
+
checked( $options['apsl_custom_login_redirect_options'], 'home', 'true' );
|
343 |
+
}
|
344 |
+
?> /> <label for='apsl_custom_login_redirect_home'><?php _e( 'Home page', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
345 |
+
<input type='radio' id='apsl_custom_login_redirect_current' class='apsl_custom_login_redirect_options' name='apsl_custom_login_redirect_options' value='current_page' <?php
|
346 |
+
if ( isset( $options['apsl_custom_login_redirect_options'] ) ) {
|
347 |
+
checked( $options['apsl_custom_login_redirect_options'], 'current_page', 'true' );
|
348 |
+
}
|
349 |
+
?> /> <label for='apsl_custom_login_redirect_current'><?php _e( 'Current page', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
350 |
<div class='apsl-custom-login-redirect-link1' >
|
351 |
<div class='apsl-info'>
|
352 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?></span> <br />
|
353 |
<span class='apsl-info-content'> If plugin can't detect what is the redirect uri for the page it will be redirected to home page.</span>
|
354 |
</div>
|
355 |
</div>
|
356 |
+
<input type='radio' id='apsl_custom_login_redirect_custom' class='apsl_custom_login_redirect_options' name='apsl_custom_login_redirect_options' value='custom_page' <?php
|
357 |
+
if ( isset( $options['apsl_custom_login_redirect_options'] ) ) {
|
358 |
+
checked( $options['apsl_custom_login_redirect_options'], 'custom_page', 'true' );
|
359 |
+
}
|
360 |
+
?> /> <label for='apsl_custom_login_redirect_custom'><?php _e( 'Custom page', APSL_TEXT_DOMAIN ); ?></label><br />
|
361 |
+
|
362 |
+
<div class='apsl-custom-login-redirect-link' <?php if ( isset( $options['apsl_custom_login_redirect_options'] ) ) {
|
363 |
+
if ( $options['apsl_custom_login_redirect_options'] == 'custom_page' ) {
|
364 |
+
?> style='display: block' <?php } else { ?> style='display:none' <?php }
|
365 |
+
}
|
366 |
+
?>>
|
367 |
<p class='apsl-title-text-field'>
|
368 |
+
<span><?php _e( 'Login redirect page:', APSL_TEXT_DOMAIN ); ?></span> <input type='text' name='apsl_custom_login_redirect_link' id='apsl-custom-login-redirect-link' value='<?php
|
369 |
+
if ( isset( $options['apsl_custom_login_redirect_link'] ) && $options['apsl_custom_login_redirect_link'] != '' ) {
|
370 |
+
echo $options['apsl_custom_login_redirect_link'];
|
371 |
+
}
|
372 |
+
?>' />
|
373 |
</p>
|
374 |
<div class='apsl-info'>
|
375 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?></span> <br />
|
376 |
<span class='apsl-info-content'>Please set this value if you want to redirect the user to the custom page url(full url). If this field is not set they will be redirected back to home page.</span>
|
377 |
</div>
|
378 |
</div>
|
382 |
|
383 |
<div class='apsl-settings'>
|
384 |
<div class='apsl-user-avatar-settings'>
|
385 |
+
<div class="apsl-label"><?php _e( 'User avatar', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
386 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
387 |
+
<input type='radio' id='apsl_user_avatar_default' class='apsl_user_avatar_options' name='apsl_user_avatar_options' value='default' <?php
|
388 |
+
if ( isset( $options['apsl_user_avatar_options'] ) ) {
|
389 |
+
checked( $options['apsl_user_avatar_options'], 'default', 'true' );
|
390 |
+
}
|
391 |
+
?> /> <label for='apsl_user_avatar_default'><?php _e( 'Use wordpress provided default avatar.', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
392 |
+
<input type='radio' id='apsl_user_avatar_social' class='apsl_user_avatar_options' name='apsl_user_avatar_options' value='social' <?php
|
393 |
+
if ( isset( $options['apsl_user_avatar_options'] ) ) {
|
394 |
+
checked( $options['apsl_user_avatar_options'], 'social', 'true' );
|
395 |
+
}
|
396 |
+
?> /> <label for='apsl_user_avatar_social'><?php _e( 'Use the profile picture from social media where available.', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
397 |
<div class='apsl-info'>
|
398 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?></span> <br />
|
399 |
<span class='apsl-info-content'>Please choose the options from where you want your users avatar to be loaded from. If you choose default wordpress avatar it will use the gravatar profile image if user have gravatar profile assocated with their registered email address.</span>
|
400 |
</div>
|
401 |
</div>
|
404 |
|
405 |
<div class='apsl-settings'>
|
406 |
<div class='apsl-user-email-settings'>
|
407 |
+
<div class="apsl-label"><?php _e( 'Email notification settings', APSL_TEXT_DOMAIN ); ?> <span class='apsl_show_hide'><i class="fa fa-caret-down"></i></span> </div>
|
408 |
<div class='apsl_network_settings_wrapper' style='display:none'>
|
409 |
+
<input type='radio' id='apsl_send_email_notification_yes' class='apsl_send_email_notification_yes' name='apsl_send_email_notification_options' value='yes' <?php
|
410 |
+
if ( isset( $options['apsl_send_email_notification_options'] ) ) {
|
411 |
+
checked( $options['apsl_send_email_notification_options'], 'yes', 'true' );
|
412 |
+
}
|
413 |
+
?> /> <label for='apsl_send_email_notification_yes'><?php _e( 'Send email notification to both user and site admin.', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
414 |
+
<input type='radio' id='apsl_send_email_notification_no' class='apsl_send_email_notification_no' name='apsl_send_email_notification_options' value='no' <?php
|
415 |
+
if ( isset( $options['apsl_send_email_notification_options'] ) ) {
|
416 |
+
checked( $options['apsl_send_email_notification_options'], 'no', 'true' );
|
417 |
+
}
|
418 |
+
?> /> <label for='apsl_send_email_notification_no'><?php _e( 'Do not send email notification to both user and site admin.', APSL_TEXT_DOMAIN ); ?></label><br /><br />
|
419 |
<div class='apsl-info'>
|
420 |
+
<span class='apsl-info-note'><?php _e( 'Note:', APSL_TEXT_DOMAIN ); ?></span> <br />
|
421 |
<span class='apsl-info-content'>Here you can configure an options to send email notifications about user registration to site admin and user.</span>
|
422 |
</div>
|
423 |
</div>
|
439 |
|
440 |
<!-- Save settings Button -->
|
441 |
<div class='apsl-save-settings'>
|
442 |
+
<?php wp_nonce_field( 'apsl_nonce_save_settings', 'apsl_settings_action' ); ?>
|
443 |
+
<input type='submit' class='apsl-submit-settings primary-button' name='apsl_save_settings' value='<?php _e( 'Save settings', APSL_TEXT_DOMAIN ); ?>' />
|
444 |
</div>
|
445 |
|
446 |
<div class='apsl-restore-settings'>
|
447 |
+
<?php $nonce = wp_create_nonce( 'apsl-restore-default-settings-nonce' ); ?>
|
448 |
+
<a href="<?php echo admin_url() . 'admin-post.php?action=apsl_restore_default_settings&_wpnonce=' . $nonce; ?>" onclick="return confirm('<?php _e( 'Are you sure you want to restore default settings?', APSL_TEXT_DOMAIN ); ?>')"><input type="button" value="Restore Default Settings" class="apsl-reset-button button primary-button"/></a>
|
449 |
</div>
|
450 |
|
451 |
</div>
|
inc/backend/save-settings.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php defined('ABSPATH') or die("No script kiddies please!"); ?>
|
2 |
<?php
|
3 |
|
4 |
$apsl_settings = array();
|
5 |
$apsl_settings['network_ordering'] = $_POST['network_ordering'];
|
6 |
|
7 |
//for facebook settings
|
8 |
-
foreach ($_POST['apsl_facebook_settings'] as $key => $value) {
|
9 |
$$key = $value;
|
10 |
}
|
11 |
-
$apsl_facebook_enable = isset($apsl_facebook_enable) ? $apsl_facebook_enable : '';
|
12 |
|
13 |
$facebook_parameters = array(
|
14 |
'apsl_facebook_enable' => $apsl_facebook_enable,
|
@@ -18,10 +18,10 @@ $facebook_parameters = array(
|
|
18 |
$apsl_settings['apsl_facebook_settings'] = $facebook_parameters;
|
19 |
|
20 |
//for twitter settings
|
21 |
-
foreach ($_POST['apsl_twitter_settings'] as $key => $value) {
|
22 |
$$key = $value;
|
23 |
}
|
24 |
-
$apsl_twitter_enable = isset($apsl_twitter_enable) ? $apsl_twitter_enable : '';
|
25 |
|
26 |
$twitter_parameters = array(
|
27 |
'apsl_twitter_enable' => $apsl_twitter_enable,
|
@@ -32,10 +32,10 @@ $twitter_parameters = array(
|
|
32 |
$apsl_settings['apsl_twitter_settings'] = $twitter_parameters;
|
33 |
|
34 |
//for google settings
|
35 |
-
foreach ($_POST['apsl_google_settings'] as $key => $value) {
|
36 |
$$key = $value;
|
37 |
}
|
38 |
-
$apsl_google_enable = isset($apsl_google_enable) ? $apsl_google_enable : '';
|
39 |
|
40 |
$google_parameters = array(
|
41 |
'apsl_google_enable' => $apsl_google_enable,
|
@@ -47,9 +47,9 @@ $apsl_settings['apsl_google_settings'] = $google_parameters;
|
|
47 |
$apsl_settings['apsl_enable_disable_plugin'] = $_POST['apsl_enable_disable_plugin'];
|
48 |
|
49 |
$display_options = array();
|
50 |
-
if (isset($_POST['apsl_display_options'])) {
|
51 |
|
52 |
-
foreach ($_POST['apsl_display_options'] as $key => $value) {
|
53 |
$display_options[] = $value;
|
54 |
}
|
55 |
}
|
@@ -70,7 +70,7 @@ $apsl_settings['apsl_user_avatar_options'] = $_POST['apsl_user_avatar_options'];
|
|
70 |
$apsl_settings['apsl_send_email_notification_options'] = $_POST['apsl_send_email_notification_options'];
|
71 |
|
72 |
//for saving the settings
|
73 |
-
update_option(APSL_SETTINGS, $apsl_settings);
|
74 |
-
$_SESSION['apsl_message'] = __('Settings Saved Successfully.', APSL_TEXT_DOMAIN);
|
75 |
-
wp_redirect(admin_url() . 'admin.php?page=' . APSL_TEXT_DOMAIN);
|
76 |
-
exit;
|
1 |
+
<?php defined( 'ABSPATH' ) or die( "No script kiddies please!" ); ?>
|
2 |
<?php
|
3 |
|
4 |
$apsl_settings = array();
|
5 |
$apsl_settings['network_ordering'] = $_POST['network_ordering'];
|
6 |
|
7 |
//for facebook settings
|
8 |
+
foreach ( $_POST['apsl_facebook_settings'] as $key => $value ) {
|
9 |
$$key = $value;
|
10 |
}
|
11 |
+
$apsl_facebook_enable = isset( $apsl_facebook_enable ) ? $apsl_facebook_enable : '';
|
12 |
|
13 |
$facebook_parameters = array(
|
14 |
'apsl_facebook_enable' => $apsl_facebook_enable,
|
18 |
$apsl_settings['apsl_facebook_settings'] = $facebook_parameters;
|
19 |
|
20 |
//for twitter settings
|
21 |
+
foreach ( $_POST['apsl_twitter_settings'] as $key => $value ) {
|
22 |
$$key = $value;
|
23 |
}
|
24 |
+
$apsl_twitter_enable = isset( $apsl_twitter_enable ) ? $apsl_twitter_enable : '';
|
25 |
|
26 |
$twitter_parameters = array(
|
27 |
'apsl_twitter_enable' => $apsl_twitter_enable,
|
32 |
$apsl_settings['apsl_twitter_settings'] = $twitter_parameters;
|
33 |
|
34 |
//for google settings
|
35 |
+
foreach ( $_POST['apsl_google_settings'] as $key => $value ) {
|
36 |
$$key = $value;
|
37 |
}
|
38 |
+
$apsl_google_enable = isset( $apsl_google_enable ) ? $apsl_google_enable : '';
|
39 |
|
40 |
$google_parameters = array(
|
41 |
'apsl_google_enable' => $apsl_google_enable,
|
47 |
$apsl_settings['apsl_enable_disable_plugin'] = $_POST['apsl_enable_disable_plugin'];
|
48 |
|
49 |
$display_options = array();
|
50 |
+
if ( isset( $_POST['apsl_display_options'] ) ) {
|
51 |
|
52 |
+
foreach ( $_POST['apsl_display_options'] as $key => $value ) {
|
53 |
$display_options[] = $value;
|
54 |
}
|
55 |
}
|
70 |
$apsl_settings['apsl_send_email_notification_options'] = $_POST['apsl_send_email_notification_options'];
|
71 |
|
72 |
//for saving the settings
|
73 |
+
update_option( APSL_SETTINGS, $apsl_settings );
|
74 |
+
$_SESSION['apsl_message'] = __( 'Settings Saved Successfully.', APSL_TEXT_DOMAIN );
|
75 |
+
wp_redirect( admin_url() . 'admin.php?page=' . APSL_TEXT_DOMAIN );
|
76 |
+
exit;
|
inc/backend/widget.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?php
|
2 |
-
defined('ABSPATH') or die("No script kiddies please!");
|
|
|
3 |
/**
|
4 |
* Adds AccessPress Social Login Widget
|
5 |
*/
|
6 |
-
|
7 |
class APSL_Lite_Widget extends WP_Widget {
|
8 |
|
9 |
-
|
10 |
* Register widget with WordPress.
|
11 |
*/
|
12 |
function __construct() {
|
13 |
parent::__construct(
|
14 |
'apsl_widget', // Base ID
|
15 |
-
__('AccessPress Social Login Lite', APSL_TEXT_DOMAIN ), // Name
|
16 |
-
array('description' => __('AccessPress Social Login Lite Widget', APSL_TEXT_DOMAIN )) // Args
|
17 |
);
|
18 |
}
|
19 |
|
@@ -24,35 +24,34 @@ class APSL_Lite_Widget extends WP_Widget {
|
|
24 |
*
|
25 |
* @param array $instance Previously saved values from database.
|
26 |
*/
|
27 |
-
public function form($instance) {
|
28 |
|
29 |
-
if (isset($instance['title'])) {
|
30 |
$title = $instance['title'];
|
31 |
} else {
|
32 |
$title = '';
|
33 |
}
|
34 |
|
35 |
-
|
36 |
$login_text = $instance['login_text'];
|
37 |
} else {
|
38 |
$login_text = '';
|
39 |
}
|
40 |
-
|
41 |
?>
|
42 |
<p>
|
43 |
-
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title: ', APSL_TEXT_DOMAIN ); ?></label>
|
44 |
-
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">
|
45 |
</p>
|
46 |
|
47 |
<p>
|
48 |
-
<label for="<?php echo $this->get_field_id('login_text'); ?>"><?php _e( 'Login Text: ', APSL_TEXT_DOMAIN ); ?></label>
|
49 |
-
<input class="widefat" id="<?php echo $this->get_field_id('login_text'); ?>" name="<?php echo $this->get_field_name('login_text'); ?>" type="text" value="<?php echo esc_attr($login_text); ?>">
|
50 |
</p>
|
51 |
|
52 |
<?php
|
53 |
}
|
54 |
|
55 |
-
|
56 |
* Front-end display of widget.
|
57 |
*
|
58 |
* @see WP_Widget::widget()
|
@@ -60,26 +59,25 @@ class APSL_Lite_Widget extends WP_Widget {
|
|
60 |
* @param array $args Widget arguments.
|
61 |
* @param array $instance Saved values from database.
|
62 |
*/
|
63 |
-
public function widget($args, $instance) {
|
64 |
echo $args['before_widget'];
|
65 |
-
if (!empty($instance['title'])) {
|
66 |
-
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
|
67 |
}
|
68 |
global $post;
|
69 |
-
if(have_posts()){
|
70 |
-
$widget_flag = get_post_meta($post->ID, 'apsl_widget_flag', true);
|
71 |
-
}else{
|
72 |
-
$widget_flag=0;
|
73 |
}
|
74 |
-
if($widget_flag !='1'){
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
}
|
79 |
echo $args['after_widget'];
|
80 |
}
|
81 |
|
82 |
-
|
83 |
/**
|
84 |
* Sanitize widget form values as they are saved.
|
85 |
*
|
@@ -90,11 +88,11 @@ class APSL_Lite_Widget extends WP_Widget {
|
|
90 |
*
|
91 |
* @return array Updated safe values to be saved.
|
92 |
*/
|
93 |
-
public function update($new_instance, $old_instance) {
|
94 |
$instance = array();
|
95 |
-
$instance['title'] = (!empty($new_instance['title']) ) ? strip_tags($new_instance['title']) : '';
|
96 |
-
$instance['login_text'] = (!empty($new_instance['login_text']) ) ? strip_tags($new_instance['login_text']) : '';
|
97 |
return $instance;
|
98 |
}
|
99 |
|
100 |
-
}
|
1 |
<?php
|
2 |
+
defined( 'ABSPATH' ) or die( "No script kiddies please!" );
|
3 |
+
|
4 |
/**
|
5 |
* Adds AccessPress Social Login Widget
|
6 |
*/
|
|
|
7 |
class APSL_Lite_Widget extends WP_Widget {
|
8 |
|
9 |
+
/**
|
10 |
* Register widget with WordPress.
|
11 |
*/
|
12 |
function __construct() {
|
13 |
parent::__construct(
|
14 |
'apsl_widget', // Base ID
|
15 |
+
__( 'AccessPress Social Login Lite', APSL_TEXT_DOMAIN ), // Name
|
16 |
+
array( 'description' => __( 'AccessPress Social Login Lite Widget', APSL_TEXT_DOMAIN ) ) // Args
|
17 |
);
|
18 |
}
|
19 |
|
24 |
*
|
25 |
* @param array $instance Previously saved values from database.
|
26 |
*/
|
27 |
+
public function form( $instance ) {
|
28 |
|
29 |
+
if ( isset( $instance['title'] ) ) {
|
30 |
$title = $instance['title'];
|
31 |
} else {
|
32 |
$title = '';
|
33 |
}
|
34 |
|
35 |
+
if ( isset( $instance['login_text'] ) ) {
|
36 |
$login_text = $instance['login_text'];
|
37 |
} else {
|
38 |
$login_text = '';
|
39 |
}
|
|
|
40 |
?>
|
41 |
<p>
|
42 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title: ', APSL_TEXT_DOMAIN ); ?></label>
|
43 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
|
44 |
</p>
|
45 |
|
46 |
<p>
|
47 |
+
<label for="<?php echo $this->get_field_id( 'login_text' ); ?>"><?php _e( 'Login Text: ', APSL_TEXT_DOMAIN ); ?></label>
|
48 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'login_text' ); ?>" name="<?php echo $this->get_field_name( 'login_text' ); ?>" type="text" value="<?php echo esc_attr( $login_text ); ?>">
|
49 |
</p>
|
50 |
|
51 |
<?php
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
* Front-end display of widget.
|
56 |
*
|
57 |
* @see WP_Widget::widget()
|
59 |
* @param array $args Widget arguments.
|
60 |
* @param array $instance Saved values from database.
|
61 |
*/
|
62 |
+
public function widget( $args, $instance ) {
|
63 |
echo $args['before_widget'];
|
64 |
+
if ( !empty( $instance['title'] ) ) {
|
65 |
+
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
|
66 |
}
|
67 |
global $post;
|
68 |
+
if ( have_posts() ) {
|
69 |
+
$widget_flag = get_post_meta( $post->ID, 'apsl_widget_flag', true );
|
70 |
+
} else {
|
71 |
+
$widget_flag = 0;
|
72 |
}
|
73 |
+
if ( $widget_flag != '1' ) {
|
74 |
+
echo "<div class='apsl-widget'>";
|
75 |
+
echo do_shortcode( "[apsl-login-lite login_text='{$instance['login_text']}']" );
|
76 |
+
echo "</div>";
|
77 |
}
|
78 |
echo $args['after_widget'];
|
79 |
}
|
80 |
|
|
|
81 |
/**
|
82 |
* Sanitize widget form values as they are saved.
|
83 |
*
|
88 |
*
|
89 |
* @return array Updated safe values to be saved.
|
90 |
*/
|
91 |
+
public function update( $new_instance, $old_instance ) {
|
92 |
$instance = array();
|
93 |
+
$instance['title'] = (!empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
|
94 |
+
$instance['login_text'] = (!empty( $new_instance['login_text'] ) ) ? strip_tags( $new_instance['login_text'] ) : '';
|
95 |
return $instance;
|
96 |
}
|
97 |
|
98 |
+
}
|
inc/frontend/login_check.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php defined('ABSPATH') or die("No script kiddies please!"); ?>
|
2 |
<?php
|
3 |
|
4 |
-
if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
5 |
|
6 |
class APSL_Lite_Login_Check_Class {
|
7 |
|
8 |
//constructor
|
9 |
function __construct() {
|
10 |
-
if (isset($_GET['apsl_login_id'])) {
|
11 |
-
if (isset($_REQUEST['state'])) {
|
12 |
-
parse_str(base64_decode($_REQUEST['state']), $state_vars);
|
13 |
|
14 |
-
if (isset($state_vars['redirect_to'])) {
|
15 |
$_GET['redirect_to'] = $_REQUEST['redirect_to'] = $state_vars['redirect_to'];
|
16 |
}
|
17 |
}
|
18 |
|
19 |
-
$exploder = explode('_', $_GET['apsl_login_id']);
|
20 |
-
switch ($exploder[0]) {
|
21 |
case 'facebook':
|
22 |
-
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
|
23 |
-
echo _e('The Facebook SDK requires PHP version 5.4 or higher. Please notify about this error to site admin.', APSL_TEXT_DOMAIN);
|
24 |
die();
|
25 |
}
|
26 |
$this->onFacebookLogin();
|
27 |
break;
|
28 |
|
29 |
case 'twitter':
|
30 |
-
if (!class_exists('TwitterOAuth')) {
|
31 |
include( APSL_PLUGIN_DIR . 'twitter/OAuth.php' );
|
32 |
include( APSL_PLUGIN_DIR . 'twitter/twitteroauth.php' );
|
33 |
}
|
@@ -46,25 +46,25 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
46 |
//for facebook login
|
47 |
function onFacebookLogin() {
|
48 |
$response = new stdClass();
|
49 |
-
$result = $this->facebookLogin($response);
|
50 |
-
if (isset($result->status) == 'SUCCESS') {
|
51 |
-
$row = $this->getUserByMail($result->email);
|
52 |
-
$options = get_option(APSL_SETTINGS);
|
53 |
-
|
54 |
-
if (!$row) {
|
55 |
-
$this->creatUser($result->username, $result->email);
|
56 |
-
$row = $this->getUserByMail($result->email);
|
57 |
-
update_user_meta($row->ID, 'email', $result->email);
|
58 |
-
update_user_meta($row->ID, 'first_name', $result->first_name);
|
59 |
-
update_user_meta($row->ID, 'last_name', $result->last_name);
|
60 |
-
update_user_meta($row->ID, 'deuid', $result->deuid);
|
61 |
-
update_user_meta($row->ID, 'deutype', $result->deutype);
|
62 |
-
update_user_meta($row->ID, 'deuimage', $result->deuimage);
|
63 |
-
update_user_meta($row->ID, 'description', $result->about);
|
64 |
-
update_user_meta($row->ID, 'sex', $result->gender);
|
65 |
-
wp_update_user(array('ID' => $row->ID, 'display_name' => $result->first_name . ' ' . $result->last_name, 'role' => $options['apsl_user_role'], 'user_url' => $result->url));
|
66 |
}
|
67 |
-
$this->loginUser($row->ID);
|
68 |
}
|
69 |
}
|
70 |
|
@@ -74,9 +74,9 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
74 |
$callBackUrl = $this->callBackUrl();
|
75 |
$response = new stdClass();
|
76 |
$return_user_details = new stdClass();
|
77 |
-
$exploder = explode('_', $_GET['apsl_login_id']);
|
78 |
$action = $exploder[1];
|
79 |
-
$options = get_option(APSL_SETTINGS);
|
80 |
$config = array(
|
81 |
'app_id' => $options['apsl_facebook_settings']['apsl_facebook_app_id'],
|
82 |
'app_secret' => $options['apsl_facebook_settings']['apsl_facebook_app_secret'],
|
@@ -84,65 +84,65 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
84 |
);
|
85 |
|
86 |
include( APSL_PLUGIN_DIR . 'facebook/autoload.php' );
|
87 |
-
$fb = new Facebook\Facebook($config);
|
88 |
|
89 |
-
$encoded_url = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : '';
|
90 |
-
if (isset($encoded_url) && $encoded_url != '') {
|
91 |
$callback = $callBackUrl . 'apsl_login_id' . '=facebook_check&redirect_to=' . $encoded_url;
|
92 |
} else {
|
93 |
$callback = $callBackUrl . 'apsl_login_id' . '=facebook_check';
|
94 |
}
|
95 |
|
96 |
-
if ($action == 'login') {
|
97 |
// Well looks like we are a fresh dude, login to Facebook!
|
98 |
$helper = $fb->getRedirectLoginHelper();
|
99 |
-
$permissions = array('email', 'public_profile'); // optional
|
100 |
-
$loginUrl = $helper->getLoginUrl($callback, $permissions);
|
101 |
-
$this->redirect($loginUrl);
|
102 |
} else {
|
103 |
-
if (isset($_REQUEST['error'])) {
|
104 |
$response->status = 'ERROR';
|
105 |
$response->error_code = 2;
|
106 |
$response->error_message = 'INVALID AUTHORIZATION';
|
107 |
return $response;
|
108 |
die();
|
109 |
}
|
110 |
-
if (isset($_REQUEST['code'])) {
|
111 |
$helper = $fb->getRedirectLoginHelper();
|
112 |
try {
|
113 |
$accessToken = $helper->getAccessToken();
|
114 |
-
} catch (Facebook\Exceptions\FacebookResponseException $e) {
|
115 |
|
116 |
// When Graph returns an error
|
117 |
echo 'Graph returned an error: ' . $e->getMessage();
|
118 |
exit;
|
119 |
-
} catch (Facebook\Exceptions\FacebookSDKException $e) {
|
120 |
|
121 |
// When validation fails or other local issues
|
122 |
echo 'Facebook SDK returned an error: ' . $e->getMessage();
|
123 |
exit;
|
124 |
}
|
125 |
|
126 |
-
if (isset($accessToken)) {
|
127 |
// Logged in!
|
128 |
$_SESSION['facebook_access_token'] = (string) $accessToken;
|
129 |
-
$fb->setDefaultAccessToken($accessToken);
|
130 |
|
131 |
try {
|
132 |
-
$response = $fb->get('/me?fields=email,name, first_name, last_name, gender, link, about, address, bio, birthday, education, hometown, is_verified, languages, location, website');
|
133 |
$userNode = $response->getGraphUser();
|
134 |
-
} catch (Facebook\Exceptions\FacebookResponseException $e) {
|
135 |
// When Graph returns an error
|
136 |
echo 'Graph returned an error: ' . $e->getMessage();
|
137 |
exit;
|
138 |
-
} catch (Facebook\Exceptions\FacebookSDKException $e) {
|
139 |
// When validation fails or other local issues
|
140 |
echo 'Facebook SDK returned an error: ' . $e->getMessage();
|
141 |
exit;
|
142 |
}
|
143 |
|
144 |
-
$user_profile = $this->accessProtected($userNode, 'items');
|
145 |
-
if ($user_profile != null) {
|
146 |
$return_user_details->status = 'SUCCESS';
|
147 |
$return_user_details->deuid = $user_profile['id'];
|
148 |
$return_user_details->deutype = 'facebook';
|
@@ -153,10 +153,10 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
153 |
$return_user_details->gender = $user_profile['gender'];
|
154 |
$return_user_details->url = $user_profile['link'];
|
155 |
$return_user_details->about = ''; //facebook doesn't return user about details.
|
156 |
-
$headers = get_headers('https://graph.facebook.com/' . $user_profile['id'] . '/picture', 1);
|
157 |
|
158 |
// just a precaution, check whether the header isset...
|
159 |
-
if (isset($headers['Location'])) {
|
160 |
$return_user_details->deuimage = $headers['Location']; // string
|
161 |
} else {
|
162 |
$return_user_details->deuimage = false; // nothing there? .. weird, but okay!
|
@@ -171,9 +171,9 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
171 |
} else {
|
172 |
// Well looks like we are a fresh dude, login to Facebook!
|
173 |
$helper = $fb->getRedirectLoginHelper();
|
174 |
-
$permissions = array('email', 'public_profile'); // optional
|
175 |
-
$loginUrl = $helper->getLoginUrl($callback, $permissions);
|
176 |
-
$this->redirect($loginUrl);
|
177 |
}
|
178 |
}
|
179 |
return $return_user_details;
|
@@ -182,22 +182,22 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
182 |
//for twitter login
|
183 |
function onTwitterLogin() {
|
184 |
$result = $this->twitterLogin();
|
185 |
-
if (isset($result->status) == 'SUCCESS') {
|
186 |
-
$row = $this->getUserByMail($result->email);
|
187 |
-
$options = get_option(APSL_SETTINGS);
|
188 |
-
if (!$row) {
|
189 |
-
$this->creatUser($result->username, $result->email);
|
190 |
-
$row = $this->getUserByMail($result->email);
|
191 |
-
update_user_meta($row->ID, 'email', $result->email);
|
192 |
-
update_user_meta($row->ID, 'first_name', $result->first_name);
|
193 |
-
update_user_meta($row->ID, 'last_name', $result->last_name);
|
194 |
-
update_user_meta($row->ID, 'deuid', $result->deuid);
|
195 |
-
update_user_meta($row->ID, 'deutype', $result->deutype);
|
196 |
-
update_user_meta($row->ID, 'deuimage', $result->deuimage);
|
197 |
-
update_user_meta($row->ID, 'description', $result->about);
|
198 |
-
wp_update_user(array('ID' => $row->ID, 'display_name' => $result->first_name . ' ' . $result->last_name, 'role' => $options['apsl_user_role'], 'user_url' => $result->url));
|
199 |
}
|
200 |
-
$this->loginUser($row->ID);
|
201 |
}
|
202 |
}
|
203 |
|
@@ -206,22 +206,22 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
206 |
$site = $this->siteUrl();
|
207 |
$callBackUrl = $this->callBackUrl();
|
208 |
$response = new stdClass();
|
209 |
-
$exploder = explode('_', $_GET['apsl_login_id']);
|
210 |
$action = $exploder[1];
|
211 |
@session_start();
|
212 |
-
$options = get_option(APSL_SETTINGS);
|
213 |
-
if ($action == 'login') {
|
214 |
// Get identity from user and redirect browser to OpenID Server
|
215 |
-
if (!isset($request['oauth_token']) || $request['oauth_token'] == '') {
|
216 |
-
$twitterObj = new TwitterOAuth($options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret']);
|
217 |
-
$encoded_url = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : '';
|
218 |
-
if (isset($encoded_url) && $encoded_url != '') {
|
219 |
$callback = $callBackUrl . 'apsl_login_id' . '=twitter_check&redirect_to=' . $encoded_url;
|
220 |
} else {
|
221 |
$callback = $callBackUrl . 'apsl_login_id' . '=twitter_check';
|
222 |
}
|
223 |
|
224 |
-
$request_token = $twitterObj->getRequestToken($callback);
|
225 |
$_SESSION['oauth_twitter'] = array();
|
226 |
|
227 |
/* Save temporary credentials to session. */
|
@@ -229,12 +229,12 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
229 |
$_SESSION['oauth_twitter']['oauth_token_secret'] = $request_token['oauth_token_secret'];
|
230 |
|
231 |
/* If last connection failed don't display authorization link. */
|
232 |
-
switch ($twitterObj->http_code) {
|
233 |
case 200:
|
234 |
try {
|
235 |
-
$url = $twitterObj->getAuthorizeUrl($token);
|
236 |
-
$this->redirect($url);
|
237 |
-
} catch (Exception $e) {
|
238 |
$response->status = 'ERROR';
|
239 |
$response->error_code = 2;
|
240 |
$response->error_message = 'Could not get AuthorizeUrl.';
|
@@ -252,26 +252,26 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
252 |
$response->error_code = 2;
|
253 |
$response->error_message = 'INVALID AUTHORIZATION';
|
254 |
}
|
255 |
-
} else if (isset($request['oauth_token']) && isset($request['oauth_verifier'])) {
|
256 |
|
257 |
/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
|
258 |
-
$twitterObj = new TwitterOAuth($options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret'], $_SESSION['oauth_twitter']['oauth_token'], $_SESSION['oauth_twitter']['oauth_token_secret']);
|
259 |
|
260 |
/* Remove no longer needed request tokens */
|
261 |
-
unset($_SESSION['oauth_twitter']);
|
262 |
try {
|
263 |
-
$access_token = $twitterObj->getAccessToken($request['oauth_verifier']);
|
264 |
/* If HTTP response is 200 continue otherwise send to connect page to retry */
|
265 |
-
if (200 == $twitterObj->http_code) {
|
266 |
-
$user_profile = $twitterObj->get('users/show', array('screen_name' => $access_token['screen_name'], 'include_entities' => true));
|
267 |
|
268 |
/* Request access twitterObj from twitter */
|
269 |
$response->status = 'SUCCESS';
|
270 |
$response->deuid = $user_profile->id;
|
271 |
$response->deutype = 'twitter';
|
272 |
-
$response->name = explode(' ', $user_profile->name, 2);
|
273 |
$response->first_name = $response->name[0];
|
274 |
-
$response->last_name = (isset($response->name[1])) ? $response->name[1] : '';
|
275 |
$response->deuimage = $user_profile->profile_image_url_https;
|
276 |
$response->email = $user_profile->screen_name . '@twitter.com';
|
277 |
$response->username = $user_profile->screen_name . '@twitter.com';
|
@@ -285,7 +285,7 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
285 |
$response->error_code = 2;
|
286 |
$response->error_message = 'Could not connect to Twitter. Refresh the page or try again later.';
|
287 |
}
|
288 |
-
} catch (Exception $e) {
|
289 |
$response->status = 'ERROR';
|
290 |
$response->error_code = 2;
|
291 |
$response->error_message = 'Could not get AccessToken.';
|
@@ -301,22 +301,22 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
301 |
//for google login
|
302 |
function onGoogleLogin() {
|
303 |
$result = $this->GoogleLogin();
|
304 |
-
if (isset($result->status) == 'SUCCESS') {
|
305 |
-
$row = $this->getUserByMail($result->email);
|
306 |
-
$options = get_option(APSL_SETTINGS);
|
307 |
-
if (!$row) {
|
308 |
-
$this->creatUser($result->username, $result->email);
|
309 |
-
$row = $this->getUserByMail($result->email);
|
310 |
-
update_user_meta($row->ID, 'email', $result->email);
|
311 |
-
update_user_meta($row->ID, 'first_name', $result->first_name);
|
312 |
-
update_user_meta($row->ID, 'last_name', $result->last_name);
|
313 |
-
update_user_meta($row->ID, 'deuid', $result->deuid);
|
314 |
-
update_user_meta($row->ID, 'deutype', $result->deutype);
|
315 |
-
update_user_meta($row->ID, 'deuimage', $result->deuimage);
|
316 |
-
update_user_meta($row->ID, 'description', $result->about);
|
317 |
-
wp_update_user(array('ID' => $row->ID, 'display_name' => $result->first_name, 'role' => $options['apsl_user_role'], 'user_url' => $result->url));
|
318 |
}
|
319 |
-
$this->loginUser($row->ID);
|
320 |
}
|
321 |
}
|
322 |
|
@@ -326,58 +326,58 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
326 |
$request = $_REQUEST;
|
327 |
$site = $this->siteUrl();
|
328 |
$callBackUrl = $this->callBackUrl();
|
329 |
-
$options = get_option(APSL_SETTINGS);
|
330 |
$response = new stdClass();
|
331 |
-
$a = explode('_', $_GET['apsl_login_id']);
|
332 |
$action = $a[1];
|
333 |
$client_id = $options['apsl_google_settings']['apsl_google_client_id'];
|
334 |
$client_secret = $options['apsl_google_settings']['apsl_google_client_secret'];
|
335 |
|
336 |
$site_url = site_url() . '/wp-admin';
|
337 |
-
$encoded_url = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : $site_url;
|
338 |
$callback = $callBackUrl . 'apsl_login_id' . '=google_check';
|
339 |
|
340 |
$redirect_uri = $callback;
|
341 |
$client = new Google_Client;
|
342 |
|
343 |
-
$client->setClientId($client_id);
|
344 |
-
$client->setClientSecret($client_secret);
|
345 |
-
$client->setRedirectUri($redirect_uri);
|
346 |
-
$client->addScope("https://www.googleapis.com/auth/plus.profile.emails.read");
|
347 |
-
if (isset($encoded_url) && $encoded_url != '') {
|
348 |
-
$client->setState(base64_encode("redirect_to=$encoded_url"));
|
349 |
} else {
|
350 |
|
351 |
}
|
352 |
-
$service = new Google_Service_Plus($client);
|
353 |
-
if ($action == 'login') {// Get identity from user and redirect browser to OpenID Server
|
354 |
-
if (!(isset($_SESSION['access_token']) && $_SESSION['access_token'])) {
|
355 |
$authUrl = $client->createAuthUrl();
|
356 |
-
$this->redirect($authUrl);
|
357 |
die();
|
358 |
} else {
|
359 |
-
$this->redirect($redirect_uri . "&redirect_to=$encoded_url");
|
360 |
die();
|
361 |
}
|
362 |
-
} elseif (isset($_GET['code'])) { // Perform HTTP Request to OpenID server to validate key
|
363 |
-
$client->authenticate($_GET['code']);
|
364 |
$_SESSION['access_token'] = $client->getAccessToken();
|
365 |
-
$this->redirect($redirect_uri . "&redirect_to=$encoded_url");
|
366 |
die();
|
367 |
-
} elseif (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
|
368 |
-
$client->setAccessToken($_SESSION['access_token']);
|
369 |
|
370 |
try {
|
371 |
-
$user = $service->people->get("me", array());
|
372 |
-
} catch (Exception $fault) {
|
373 |
-
unset($_SESSION['access_token']);
|
374 |
-
$ref_object = $this->accessProtected($fault, 'errors');
|
375 |
echo $ref_object[0]['message'] . " Please notify about this error to the Site Admin.";
|
376 |
die();
|
377 |
}
|
378 |
|
379 |
-
if (!empty($user)) {
|
380 |
-
if (!empty($user->emails)) {
|
381 |
$response->email = $user->emails[0]->value;
|
382 |
$response->username = $user->emails[0]->value;
|
383 |
$response->first_name = $user->name->givenName;
|
@@ -401,7 +401,7 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
401 |
$response->error_code = 2;
|
402 |
$response->error_message = "INVALID AUTHORIZATION";
|
403 |
}
|
404 |
-
} elseif ($get['openid_mode'] == 'cancel') { // User Canceled your Request
|
405 |
$response->status = 'ERROR';
|
406 |
$response->error_code = 1;
|
407 |
$response->error_message = "USER CANCELED REQUEST";
|
@@ -419,9 +419,9 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
419 |
}
|
420 |
|
421 |
function callBackUrl() {
|
422 |
-
$connection = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
|
423 |
$url = $connection . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
|
424 |
-
if (strpos($url, '?') === false) {
|
425 |
$url .= '?';
|
426 |
} else {
|
427 |
$url .= '&';
|
@@ -430,146 +430,146 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
430 |
}
|
431 |
|
432 |
//function to return json values from social media urls
|
433 |
-
function get_json_values($url) {
|
434 |
-
$response = wp_remote_get($url);
|
435 |
-
$json_response = wp_remote_retrieve_body($response);
|
436 |
return $json_response;
|
437 |
}
|
438 |
|
439 |
-
function redirect($redirect) {
|
440 |
-
if (headers_sent()) { // Use JavaScript to redirect if content has been previously sent (not recommended, but safe)
|
441 |
echo '<script language="JavaScript" type="text/javascript">window.location=\'';
|
442 |
echo $redirect;
|
443 |
echo '\';</script>';
|
444 |
} else { // Default Header Redirect
|
445 |
-
header('Location: ' . $redirect);
|
446 |
}
|
447 |
exit;
|
448 |
}
|
449 |
|
450 |
-
function updateUser($username, $email) {
|
451 |
-
$row = $this->getUserByUsername($username);
|
452 |
-
if ($row && $email != '' && $row->user_email != $email) {
|
453 |
$row = (array) $row;
|
454 |
$row['user_email'] = $email;
|
455 |
-
wp_update_user($row);
|
456 |
}
|
457 |
}
|
458 |
|
459 |
// Redefine user notification function
|
460 |
-
function wp_new_user_notification($user_id, $plaintext_pass = '') {
|
461 |
-
$user = new WP_User($user_id);
|
462 |
|
463 |
-
$user_login = stripslashes($user->user_login);
|
464 |
-
$user_email = stripslashes($user->user_email);
|
465 |
|
466 |
-
$message = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n";
|
467 |
-
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
468 |
-
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
|
469 |
|
470 |
-
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);
|
471 |
|
472 |
-
if (empty($plaintext_pass))
|
473 |
return;
|
474 |
|
475 |
-
$message = __('Hi there,') . "\r\n\r\n";
|
476 |
-
$message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
|
477 |
$message .= wp_login_url() . "\r\n";
|
478 |
-
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
|
479 |
-
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
|
480 |
-
$message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\r\n\r\n";
|
481 |
-
$message .= __('Adios!');
|
482 |
|
483 |
-
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);
|
484 |
}
|
485 |
|
486 |
-
function getUserByMail($email) {
|
487 |
global $wpdb;
|
488 |
-
$row = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_email = '$email'");
|
489 |
-
if ($row) {
|
490 |
return $row;
|
491 |
}
|
492 |
return false;
|
493 |
}
|
494 |
|
495 |
-
function getUserByUsername($username) {
|
496 |
global $wpdb;
|
497 |
-
$row = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$username'");
|
498 |
-
if ($row) {
|
499 |
return $row;
|
500 |
}
|
501 |
return false;
|
502 |
}
|
503 |
|
504 |
-
function creatUser($user_name, $user_email) {
|
505 |
-
$random_password = wp_generate_password(12, false);
|
506 |
-
$user_id = wp_create_user($user_name, $random_password, $user_email);
|
507 |
-
do_action('APSL_createUser', $user_id); //hookable function to perform additional work after creation of user.
|
508 |
-
$options = get_option(APSL_SETTINGS);
|
509 |
-
if ($options['apsl_send_email_notification_options'] == 'yes') {
|
510 |
-
wp_new_user_notification($user_id, $random_password);
|
511 |
}
|
512 |
return $user_id;
|
513 |
}
|
514 |
|
515 |
-
function set_cookies($user_id = 0, $remember = true) {
|
516 |
-
if (!function_exists('wp_set_auth_cookie')) {
|
517 |
return false;
|
518 |
}
|
519 |
-
if (!$user_id) {
|
520 |
return false;
|
521 |
}
|
522 |
wp_clear_auth_cookie();
|
523 |
-
wp_set_auth_cookie($user_id, $remember);
|
524 |
-
wp_set_current_user($user_id);
|
525 |
return true;
|
526 |
}
|
527 |
|
528 |
-
function loginUser($user_id) {
|
529 |
|
530 |
$current_url_an = get_permalink();
|
531 |
-
$reauth = empty($_REQUEST['reauth']) ? false : true;
|
532 |
-
if ($reauth)
|
533 |
wp_clear_auth_cookie();
|
534 |
|
535 |
-
if (isset($_REQUEST['redirect_to'])) {
|
536 |
$redirect_to = $_REQUEST['redirect_to'];
|
537 |
// Redirect to https if user wants ssl
|
538 |
-
if (isset($secure_cookie) && false !== strpos($redirect_to, 'wp-admin'))
|
539 |
-
$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
|
540 |
} else {
|
541 |
$redirect_to = admin_url();
|
542 |
}
|
543 |
-
if (!isset($secure_cookie) && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ))
|
544 |
$secure_cookie = false;
|
545 |
|
546 |
// If cookies are disabled we can't log in even with a valid user+pass
|
547 |
-
if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]))
|
548 |
-
$user = new WP_Error('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
|
549 |
else
|
550 |
-
$user = wp_signon('', isset($secure_cookie));
|
551 |
|
552 |
-
if (!$this->set_cookies($user_id)) {
|
553 |
return false;
|
554 |
}
|
555 |
-
$requested_redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();
|
556 |
-
$user_login_url = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
|
557 |
|
558 |
-
$options = get_option(APSL_SETTINGS);
|
559 |
-
if (isset($options['apsl_custom_login_redirect_options']) && $options['apsl_custom_login_redirect_options'] != '') {
|
560 |
-
if ($options['apsl_custom_login_redirect_options'] == 'home') {
|
561 |
$user_login_url = home_url();
|
562 |
-
} else if ($options['apsl_custom_login_redirect_options'] == 'current_page') {
|
563 |
-
if (isset($_REQUEST['redirect_to'])) {
|
564 |
$redirect_to = $_REQUEST['redirect_to'];
|
565 |
// Redirect to https if user wants ssl
|
566 |
-
if (isset($secure_cookie) && false !== strpos($redirect_to, 'wp-admin'))
|
567 |
-
$user_login_url = preg_replace('|^http://|', 'https://', $redirect_to);
|
568 |
} else {
|
569 |
$user_login_url = home_url();
|
570 |
}
|
571 |
-
} else if ($options['apsl_custom_login_redirect_options'] == 'custom_page') {
|
572 |
-
if ($options['apsl_custom_login_redirect_link'] != '') {
|
573 |
$login_page = $options['apsl_custom_login_redirect_link'];
|
574 |
$user_login_url = $login_page;
|
575 |
} else {
|
@@ -580,18 +580,18 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
580 |
$user_login_url = home_url();
|
581 |
}
|
582 |
$redirect_to = $user_login_url;
|
583 |
-
wp_safe_redirect($redirect_to);
|
584 |
exit();
|
585 |
}
|
586 |
|
587 |
//returns the current page url
|
588 |
public static function curPageURL() {
|
589 |
$pageURL = 'http';
|
590 |
-
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
|
591 |
$pageURL .= "s";
|
592 |
}
|
593 |
$pageURL .= "://";
|
594 |
-
if ($_SERVER["SERVER_PORT"] != "80") {
|
595 |
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
|
596 |
} else {
|
597 |
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
@@ -600,11 +600,11 @@ if (!class_exists('APSL_Lite_Login_Check_Class')) {
|
|
600 |
}
|
601 |
|
602 |
//function to access the protected object properties
|
603 |
-
function accessProtected($obj, $prop) {
|
604 |
-
$reflection = new ReflectionClass($obj);
|
605 |
-
$property = $reflection->getProperty($prop);
|
606 |
-
$property->setAccessible(true);
|
607 |
-
return $property->getValue($obj);
|
608 |
}
|
609 |
|
610 |
}//termination of a class
|
1 |
+
<?php defined( 'ABSPATH' ) or die( "No script kiddies please!" ); ?>
|
2 |
<?php
|
3 |
|
4 |
+
if ( !class_exists( 'APSL_Lite_Login_Check_Class' ) ) {
|
5 |
|
6 |
class APSL_Lite_Login_Check_Class {
|
7 |
|
8 |
//constructor
|
9 |
function __construct() {
|
10 |
+
if ( isset( $_GET['apsl_login_id'] ) ) {
|
11 |
+
if ( isset( $_REQUEST['state'] ) ) {
|
12 |
+
parse_str( base64_decode( $_REQUEST['state'] ), $state_vars );
|
13 |
|
14 |
+
if ( isset( $state_vars['redirect_to'] ) ) {
|
15 |
$_GET['redirect_to'] = $_REQUEST['redirect_to'] = $state_vars['redirect_to'];
|
16 |
}
|
17 |
}
|
18 |
|
19 |
+
$exploder = explode( '_', $_GET['apsl_login_id'] );
|
20 |
+
switch ( $exploder[0] ) {
|
21 |
case 'facebook':
|
22 |
+
if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
|
23 |
+
echo _e( 'The Facebook SDK requires PHP version 5.4 or higher. Please notify about this error to site admin.', APSL_TEXT_DOMAIN );
|
24 |
die();
|
25 |
}
|
26 |
$this->onFacebookLogin();
|
27 |
break;
|
28 |
|
29 |
case 'twitter':
|
30 |
+
if ( !class_exists( 'TwitterOAuth' ) ) {
|
31 |
include( APSL_PLUGIN_DIR . 'twitter/OAuth.php' );
|
32 |
include( APSL_PLUGIN_DIR . 'twitter/twitteroauth.php' );
|
33 |
}
|
46 |
//for facebook login
|
47 |
function onFacebookLogin() {
|
48 |
$response = new stdClass();
|
49 |
+
$result = $this->facebookLogin( $response );
|
50 |
+
if ( isset( $result->status ) == 'SUCCESS' ) {
|
51 |
+
$row = $this->getUserByMail( $result->email );
|
52 |
+
$options = get_option( APSL_SETTINGS );
|
53 |
+
|
54 |
+
if ( !$row ) {
|
55 |
+
$this->creatUser( $result->username, $result->email );
|
56 |
+
$row = $this->getUserByMail( $result->email );
|
57 |
+
update_user_meta( $row->ID, 'email', $result->email );
|
58 |
+
update_user_meta( $row->ID, 'first_name', $result->first_name );
|
59 |
+
update_user_meta( $row->ID, 'last_name', $result->last_name );
|
60 |
+
update_user_meta( $row->ID, 'deuid', $result->deuid );
|
61 |
+
update_user_meta( $row->ID, 'deutype', $result->deutype );
|
62 |
+
update_user_meta( $row->ID, 'deuimage', $result->deuimage );
|
63 |
+
update_user_meta( $row->ID, 'description', $result->about );
|
64 |
+
update_user_meta( $row->ID, 'sex', $result->gender );
|
65 |
+
wp_update_user( array( 'ID' => $row->ID, 'display_name' => $result->first_name . ' ' . $result->last_name, 'role' => $options['apsl_user_role'], 'user_url' => $result->url ) );
|
66 |
}
|
67 |
+
$this->loginUser( $row->ID );
|
68 |
}
|
69 |
}
|
70 |
|
74 |
$callBackUrl = $this->callBackUrl();
|
75 |
$response = new stdClass();
|
76 |
$return_user_details = new stdClass();
|
77 |
+
$exploder = explode( '_', $_GET['apsl_login_id'] );
|
78 |
$action = $exploder[1];
|
79 |
+
$options = get_option( APSL_SETTINGS );
|
80 |
$config = array(
|
81 |
'app_id' => $options['apsl_facebook_settings']['apsl_facebook_app_id'],
|
82 |
'app_secret' => $options['apsl_facebook_settings']['apsl_facebook_app_secret'],
|
84 |
);
|
85 |
|
86 |
include( APSL_PLUGIN_DIR . 'facebook/autoload.php' );
|
87 |
+
$fb = new Facebook\Facebook( $config );
|
88 |
|
89 |
+
$encoded_url = isset( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : '';
|
90 |
+
if ( isset( $encoded_url ) && $encoded_url != '' ) {
|
91 |
$callback = $callBackUrl . 'apsl_login_id' . '=facebook_check&redirect_to=' . $encoded_url;
|
92 |
} else {
|
93 |
$callback = $callBackUrl . 'apsl_login_id' . '=facebook_check';
|
94 |
}
|
95 |
|
96 |
+
if ( $action == 'login' ) {
|
97 |
// Well looks like we are a fresh dude, login to Facebook!
|
98 |
$helper = $fb->getRedirectLoginHelper();
|
99 |
+
$permissions = array( 'email', 'public_profile' ); // optional
|
100 |
+
$loginUrl = $helper->getLoginUrl( $callback, $permissions );
|
101 |
+
$this->redirect( $loginUrl );
|
102 |
} else {
|
103 |
+
if ( isset( $_REQUEST['error'] ) ) {
|
104 |
$response->status = 'ERROR';
|
105 |
$response->error_code = 2;
|
106 |
$response->error_message = 'INVALID AUTHORIZATION';
|
107 |
return $response;
|
108 |
die();
|
109 |
}
|
110 |
+
if ( isset( $_REQUEST['code'] ) ) {
|
111 |
$helper = $fb->getRedirectLoginHelper();
|
112 |
try {
|
113 |
$accessToken = $helper->getAccessToken();
|
114 |
+
} catch ( Facebook\Exceptions\FacebookResponseException $e ) {
|
115 |
|
116 |
// When Graph returns an error
|
117 |
echo 'Graph returned an error: ' . $e->getMessage();
|
118 |
exit;
|
119 |
+
} catch ( Facebook\Exceptions\FacebookSDKException $e ) {
|
120 |
|
121 |
// When validation fails or other local issues
|
122 |
echo 'Facebook SDK returned an error: ' . $e->getMessage();
|
123 |
exit;
|
124 |
}
|
125 |
|
126 |
+
if ( isset( $accessToken ) ) {
|
127 |
// Logged in!
|
128 |
$_SESSION['facebook_access_token'] = (string) $accessToken;
|
129 |
+
$fb->setDefaultAccessToken( $accessToken );
|
130 |
|
131 |
try {
|
132 |
+
$response = $fb->get( '/me?fields=email,name, first_name, last_name, gender, link, about, address, bio, birthday, education, hometown, is_verified, languages, location, website' );
|
133 |
$userNode = $response->getGraphUser();
|
134 |
+
} catch ( Facebook\Exceptions\FacebookResponseException $e ) {
|
135 |
// When Graph returns an error
|
136 |
echo 'Graph returned an error: ' . $e->getMessage();
|
137 |
exit;
|
138 |
+
} catch ( Facebook\Exceptions\FacebookSDKException $e ) {
|
139 |
// When validation fails or other local issues
|
140 |
echo 'Facebook SDK returned an error: ' . $e->getMessage();
|
141 |
exit;
|
142 |
}
|
143 |
|
144 |
+
$user_profile = $this->accessProtected( $userNode, 'items' );
|
145 |
+
if ( $user_profile != null ) {
|
146 |
$return_user_details->status = 'SUCCESS';
|
147 |
$return_user_details->deuid = $user_profile['id'];
|
148 |
$return_user_details->deutype = 'facebook';
|
153 |
$return_user_details->gender = $user_profile['gender'];
|
154 |
$return_user_details->url = $user_profile['link'];
|
155 |
$return_user_details->about = ''; //facebook doesn't return user about details.
|
156 |
+
$headers = get_headers( 'https://graph.facebook.com/' . $user_profile['id'] . '/picture', 1 );
|
157 |
|
158 |
// just a precaution, check whether the header isset...
|
159 |
+
if ( isset( $headers['Location'] ) ) {
|
160 |
$return_user_details->deuimage = $headers['Location']; // string
|
161 |
} else {
|
162 |
$return_user_details->deuimage = false; // nothing there? .. weird, but okay!
|
171 |
} else {
|
172 |
// Well looks like we are a fresh dude, login to Facebook!
|
173 |
$helper = $fb->getRedirectLoginHelper();
|
174 |
+
$permissions = array( 'email', 'public_profile' ); // optional
|
175 |
+
$loginUrl = $helper->getLoginUrl( $callback, $permissions );
|
176 |
+
$this->redirect( $loginUrl );
|
177 |
}
|
178 |
}
|
179 |
return $return_user_details;
|
182 |
//for twitter login
|
183 |
function onTwitterLogin() {
|
184 |
$result = $this->twitterLogin();
|
185 |
+
if ( isset( $result->status ) == 'SUCCESS' ) {
|
186 |
+
$row = $this->getUserByMail( $result->email );
|
187 |
+
$options = get_option( APSL_SETTINGS );
|
188 |
+
if ( !$row ) {
|
189 |
+
$this->creatUser( $result->username, $result->email );
|
190 |
+
$row = $this->getUserByMail( $result->email );
|
191 |
+
update_user_meta( $row->ID, 'email', $result->email );
|
192 |
+
update_user_meta( $row->ID, 'first_name', $result->first_name );
|
193 |
+
update_user_meta( $row->ID, 'last_name', $result->last_name );
|
194 |
+
update_user_meta( $row->ID, 'deuid', $result->deuid );
|
195 |
+
update_user_meta( $row->ID, 'deutype', $result->deutype );
|
196 |
+
update_user_meta( $row->ID, 'deuimage', $result->deuimage );
|
197 |
+
update_user_meta( $row->ID, 'description', $result->about );
|
198 |
+
wp_update_user( array( 'ID' => $row->ID, 'display_name' => $result->first_name . ' ' . $result->last_name, 'role' => $options['apsl_user_role'], 'user_url' => $result->url ) );
|
199 |
}
|
200 |
+
$this->loginUser( $row->ID );
|
201 |
}
|
202 |
}
|
203 |
|
206 |
$site = $this->siteUrl();
|
207 |
$callBackUrl = $this->callBackUrl();
|
208 |
$response = new stdClass();
|
209 |
+
$exploder = explode( '_', $_GET['apsl_login_id'] );
|
210 |
$action = $exploder[1];
|
211 |
@session_start();
|
212 |
+
$options = get_option( APSL_SETTINGS );
|
213 |
+
if ( $action == 'login' ) {
|
214 |
// Get identity from user and redirect browser to OpenID Server
|
215 |
+
if ( !isset( $request['oauth_token'] ) || $request['oauth_token'] == '' ) {
|
216 |
+
$twitterObj = new TwitterOAuth( $options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret'] );
|
217 |
+
$encoded_url = isset( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : '';
|
218 |
+
if ( isset( $encoded_url ) && $encoded_url != '' ) {
|
219 |
$callback = $callBackUrl . 'apsl_login_id' . '=twitter_check&redirect_to=' . $encoded_url;
|
220 |
} else {
|
221 |
$callback = $callBackUrl . 'apsl_login_id' . '=twitter_check';
|
222 |
}
|
223 |
|
224 |
+
$request_token = $twitterObj->getRequestToken( $callback );
|
225 |
$_SESSION['oauth_twitter'] = array();
|
226 |
|
227 |
/* Save temporary credentials to session. */
|
229 |
$_SESSION['oauth_twitter']['oauth_token_secret'] = $request_token['oauth_token_secret'];
|
230 |
|
231 |
/* If last connection failed don't display authorization link. */
|
232 |
+
switch ( $twitterObj->http_code ) {
|
233 |
case 200:
|
234 |
try {
|
235 |
+
$url = $twitterObj->getAuthorizeUrl( $token );
|
236 |
+
$this->redirect( $url );
|
237 |
+
} catch ( Exception $e ) {
|
238 |
$response->status = 'ERROR';
|
239 |
$response->error_code = 2;
|
240 |
$response->error_message = 'Could not get AuthorizeUrl.';
|
252 |
$response->error_code = 2;
|
253 |
$response->error_message = 'INVALID AUTHORIZATION';
|
254 |
}
|
255 |
+
} else if ( isset( $request['oauth_token'] ) && isset( $request['oauth_verifier'] ) ) {
|
256 |
|
257 |
/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
|
258 |
+
$twitterObj = new TwitterOAuth( $options['apsl_twitter_settings']['apsl_twitter_api_key'], $options['apsl_twitter_settings']['apsl_twitter_api_secret'], $_SESSION['oauth_twitter']['oauth_token'], $_SESSION['oauth_twitter']['oauth_token_secret'] );
|
259 |
|
260 |
/* Remove no longer needed request tokens */
|
261 |
+
unset( $_SESSION['oauth_twitter'] );
|
262 |
try {
|
263 |
+
$access_token = $twitterObj->getAccessToken( $request['oauth_verifier'] );
|
264 |
/* If HTTP response is 200 continue otherwise send to connect page to retry */
|
265 |
+
if ( 200 == $twitterObj->http_code ) {
|
266 |
+
$user_profile = $twitterObj->get( 'users/show', array( 'screen_name' => $access_token['screen_name'], 'include_entities' => true ) );
|
267 |
|
268 |
/* Request access twitterObj from twitter */
|
269 |
$response->status = 'SUCCESS';
|
270 |
$response->deuid = $user_profile->id;
|
271 |
$response->deutype = 'twitter';
|
272 |
+
$response->name = explode( ' ', $user_profile->name, 2 );
|
273 |
$response->first_name = $response->name[0];
|
274 |
+
$response->last_name = (isset( $response->name[1] )) ? $response->name[1] : '';
|
275 |
$response->deuimage = $user_profile->profile_image_url_https;
|
276 |
$response->email = $user_profile->screen_name . '@twitter.com';
|
277 |
$response->username = $user_profile->screen_name . '@twitter.com';
|
285 |
$response->error_code = 2;
|
286 |
$response->error_message = 'Could not connect to Twitter. Refresh the page or try again later.';
|
287 |
}
|
288 |
+
} catch ( Exception $e ) {
|
289 |
$response->status = 'ERROR';
|
290 |
$response->error_code = 2;
|
291 |
$response->error_message = 'Could not get AccessToken.';
|
301 |
//for google login
|
302 |
function onGoogleLogin() {
|
303 |
$result = $this->GoogleLogin();
|
304 |
+
if ( isset( $result->status ) == 'SUCCESS' ) {
|
305 |
+
$row = $this->getUserByMail( $result->email );
|
306 |
+
$options = get_option( APSL_SETTINGS );
|
307 |
+
if ( !$row ) {
|
308 |
+
$this->creatUser( $result->username, $result->email );
|
309 |
+
$row = $this->getUserByMail( $result->email );
|
310 |
+
update_user_meta( $row->ID, 'email', $result->email );
|
311 |
+
update_user_meta( $row->ID, 'first_name', $result->first_name );
|
312 |
+
update_user_meta( $row->ID, 'last_name', $result->last_name );
|
313 |
+
update_user_meta( $row->ID, 'deuid', $result->deuid );
|
314 |
+
update_user_meta( $row->ID, 'deutype', $result->deutype );
|
315 |
+
update_user_meta( $row->ID, 'deuimage', $result->deuimage );
|
316 |
+
update_user_meta( $row->ID, 'description', $result->about );
|
317 |
+
wp_update_user( array( 'ID' => $row->ID, 'display_name' => $result->first_name, 'role' => $options['apsl_user_role'], 'user_url' => $result->url ) );
|
318 |
}
|
319 |
+
$this->loginUser( $row->ID );
|
320 |
}
|
321 |
}
|
322 |
|
326 |
$request = $_REQUEST;
|
327 |
$site = $this->siteUrl();
|
328 |
$callBackUrl = $this->callBackUrl();
|
329 |
+
$options = get_option( APSL_SETTINGS );
|
330 |
$response = new stdClass();
|
331 |
+
$a = explode( '_', $_GET['apsl_login_id'] );
|
332 |
$action = $a[1];
|
333 |
$client_id = $options['apsl_google_settings']['apsl_google_client_id'];
|
334 |
$client_secret = $options['apsl_google_settings']['apsl_google_client_secret'];
|
335 |
|
336 |
$site_url = site_url() . '/wp-admin';
|
337 |
+
$encoded_url = isset( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : $site_url;
|
338 |
$callback = $callBackUrl . 'apsl_login_id' . '=google_check';
|
339 |
|
340 |
$redirect_uri = $callback;
|
341 |
$client = new Google_Client;
|
342 |
|
343 |
+
$client->setClientId( $client_id );
|
344 |
+
$client->setClientSecret( $client_secret );
|
345 |
+
$client->setRedirectUri( $redirect_uri );
|
346 |
+
$client->addScope( "https://www.googleapis.com/auth/plus.profile.emails.read" );
|
347 |
+
if ( isset( $encoded_url ) && $encoded_url != '' ) {
|
348 |
+
$client->setState( base64_encode( "redirect_to=$encoded_url" ) );
|
349 |
} else {
|
350 |
|
351 |
}
|
352 |
+
$service = new Google_Service_Plus( $client );
|
353 |
+
if ( $action == 'login' ) {// Get identity from user and redirect browser to OpenID Server
|
354 |
+
if ( !(isset( $_SESSION['access_token'] ) && $_SESSION['access_token']) ) {
|
355 |
$authUrl = $client->createAuthUrl();
|
356 |
+
$this->redirect( $authUrl );
|
357 |
die();
|
358 |
} else {
|
359 |
+
$this->redirect( $redirect_uri . "&redirect_to=$encoded_url" );
|
360 |
die();
|
361 |
}
|
362 |
+
} elseif ( isset( $_GET['code'] ) ) { // Perform HTTP Request to OpenID server to validate key
|
363 |
+
$client->authenticate( $_GET['code'] );
|
364 |
$_SESSION['access_token'] = $client->getAccessToken();
|
365 |
+
$this->redirect( $redirect_uri . "&redirect_to=$encoded_url" );
|
366 |
die();
|
367 |
+
} elseif ( isset( $_SESSION['access_token'] ) && $_SESSION['access_token'] ) {
|
368 |
+
$client->setAccessToken( $_SESSION['access_token'] );
|
369 |
|
370 |
try {
|
371 |
+
$user = $service->people->get( "me", array() );
|
372 |
+
} catch ( Exception $fault ) {
|
373 |
+
unset( $_SESSION['access_token'] );
|
374 |
+
$ref_object = $this->accessProtected( $fault, 'errors' );
|
375 |
echo $ref_object[0]['message'] . " Please notify about this error to the Site Admin.";
|
376 |
die();
|
377 |
}
|
378 |
|
379 |
+
if ( !empty( $user ) ) {
|
380 |
+
if ( !empty( $user->emails ) ) {
|
381 |
$response->email = $user->emails[0]->value;
|
382 |
$response->username = $user->emails[0]->value;
|
383 |
$response->first_name = $user->name->givenName;
|
401 |
$response->error_code = 2;
|
402 |
$response->error_message = "INVALID AUTHORIZATION";
|
403 |
}
|
404 |
+
} elseif ( $get['openid_mode'] == 'cancel' ) { // User Canceled your Request
|
405 |
$response->status = 'ERROR';
|
406 |
$response->error_code = 1;
|
407 |
$response->error_message = "USER CANCELED REQUEST";
|
419 |
}
|
420 |
|
421 |
function callBackUrl() {
|
422 |
+
$connection = !empty( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
|
423 |
$url = $connection . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
|
424 |
+
if ( strpos( $url, '?' ) === false ) {
|
425 |
$url .= '?';
|
426 |
} else {
|
427 |
$url .= '&';
|
430 |
}
|
431 |
|
432 |
//function to return json values from social media urls
|
433 |
+
function get_json_values( $url ) {
|
434 |
+
$response = wp_remote_get( $url );
|
435 |
+
$json_response = wp_remote_retrieve_body( $response );
|
436 |
return $json_response;
|
437 |
}
|
438 |
|
439 |
+
function redirect( $redirect ) {
|
440 |
+
if ( headers_sent() ) { // Use JavaScript to redirect if content has been previously sent (not recommended, but safe)
|
441 |
echo '<script language="JavaScript" type="text/javascript">window.location=\'';
|
442 |
echo $redirect;
|
443 |
echo '\';</script>';
|
444 |
} else { // Default Header Redirect
|
445 |
+
header( 'Location: ' . $redirect );
|
446 |
}
|
447 |
exit;
|
448 |
}
|
449 |
|
450 |
+
function updateUser( $username, $email ) {
|
451 |
+
$row = $this->getUserByUsername( $username );
|
452 |
+
if ( $row && $email != '' && $row->user_email != $email ) {
|
453 |
$row = (array) $row;
|
454 |
$row['user_email'] = $email;
|
455 |
+
wp_update_user( $row );
|
456 |
}
|
457 |
}
|
458 |
|
459 |
// Redefine user notification function
|
460 |
+
function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
|
461 |
+
$user = new WP_User( $user_id );
|
462 |
|
463 |
+
$user_login = stripslashes( $user->user_login );
|
464 |
+
$user_email = stripslashes( $user->user_email );
|
465 |
|
466 |
+
$message = sprintf( __( 'New user registration on your blog %s:' ), get_option( 'blogname' ) ) . "\r\n\r\n";
|
467 |
+
$message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n";
|
468 |
+
$message .= sprintf( __( 'E-mail: %s' ), $user_email ) . "\r\n";
|
469 |
|
470 |
+
@wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), get_option( 'blogname' ) ), $message );
|
471 |
|
472 |
+
if ( empty( $plaintext_pass ) )
|
473 |
return;
|
474 |
|
475 |
+
$message = __( 'Hi there,' ) . "\r\n\r\n";
|
476 |
+
$message .= sprintf( __( "Welcome to %s! Here's how to log in:" ), get_option( 'blogname' ) ) . "\r\n\r\n";
|
477 |
$message .= wp_login_url() . "\r\n";
|
478 |
+
$message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n";
|
479 |
+
$message .= sprintf( __( 'Password: %s' ), $plaintext_pass ) . "\r\n\r\n";
|
480 |
+
$message .= sprintf( __( 'If you have any problems, please contact me at %s.' ), get_option( 'admin_email' ) ) . "\r\n\r\n";
|
481 |
+
$message .= __( 'Adios!' );
|
482 |
|
483 |
+
wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), get_option( 'blogname' ) ), $message );
|
484 |
}
|
485 |
|
486 |
+
function getUserByMail( $email ) {
|
487 |
global $wpdb;
|
488 |
+
$row = $wpdb->get_row( "SELECT * FROM $wpdb->users WHERE user_email = '$email'" );
|
489 |
+
if ( $row ) {
|
490 |
return $row;
|
491 |
}
|
492 |
return false;
|
493 |
}
|
494 |
|
495 |
+
function getUserByUsername( $username ) {
|
496 |
global $wpdb;
|
497 |
+
$row = $wpdb->get_row( "SELECT * FROM $wpdb->users WHERE user_login = '$username'" );
|
498 |
+
if ( $row ) {
|
499 |
return $row;
|
500 |
}
|
501 |
return false;
|
502 |
}
|
503 |
|
504 |
+
function creatUser( $user_name, $user_email ) {
|
505 |
+
$random_password = wp_generate_password( 12, false );
|
506 |
+
$user_id = wp_create_user( $user_name, $random_password, $user_email );
|
507 |
+
do_action( 'APSL_createUser', $user_id ); //hookable function to perform additional work after creation of user.
|
508 |
+
$options = get_option( APSL_SETTINGS );
|
509 |
+
if ( $options['apsl_send_email_notification_options'] == 'yes' ) {
|
510 |
+
wp_new_user_notification( $user_id, $random_password );
|
511 |
}
|
512 |
return $user_id;
|
513 |
}
|
514 |
|
515 |
+
function set_cookies( $user_id = 0, $remember = true ) {
|
516 |
+
if ( !function_exists( 'wp_set_auth_cookie' ) ) {
|
517 |
return false;
|
518 |
}
|
519 |
+
if ( !$user_id ) {
|
520 |
return false;
|
521 |
}
|
522 |
wp_clear_auth_cookie();
|
523 |
+
wp_set_auth_cookie( $user_id, $remember );
|
524 |
+
wp_set_current_user( $user_id );
|
525 |
return true;
|
526 |
}
|
527 |
|
528 |
+
function loginUser( $user_id ) {
|
529 |
|
530 |
$current_url_an = get_permalink();
|
531 |
+
$reauth = empty( $_REQUEST['reauth'] ) ? false : true;
|
532 |
+
if ( $reauth )
|
533 |
wp_clear_auth_cookie();
|
534 |
|
535 |
+
if ( isset( $_REQUEST['redirect_to'] ) ) {
|
536 |
$redirect_to = $_REQUEST['redirect_to'];
|
537 |
// Redirect to https if user wants ssl
|
538 |
+
if ( isset( $secure_cookie ) && false !== strpos( $redirect_to, 'wp-admin' ) )
|
539 |
+
$redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
|
540 |
} else {
|
541 |
$redirect_to = admin_url();
|
542 |
}
|
543 |
+
if ( !isset( $secure_cookie ) && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos( $redirect_to, 'https' ) ) && ( 0 === strpos( $redirect_to, 'http' ) ) )
|
544 |
$secure_cookie = false;
|
545 |
|
546 |
// If cookies are disabled we can't log in even with a valid user+pass
|
547 |
+
if ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[TEST_COOKIE] ) )
|
548 |
+
$user = new WP_Error( 'test_cookie', __( "<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress." ) );
|
549 |
else
|
550 |
+
$user = wp_signon( '', isset( $secure_cookie ) );
|
551 |
|
552 |
+
if ( !$this->set_cookies( $user_id ) ) {
|
553 |
return false;
|
554 |
}
|
555 |
+
$requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : site_url();
|
556 |
+
$user_login_url = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
|
557 |
|
558 |
+
$options = get_option( APSL_SETTINGS );
|
559 |
+
if ( isset( $options['apsl_custom_login_redirect_options'] ) && $options['apsl_custom_login_redirect_options'] != '' ) {
|
560 |
+
if ( $options['apsl_custom_login_redirect_options'] == 'home' ) {
|
561 |
$user_login_url = home_url();
|
562 |
+
} else if ( $options['apsl_custom_login_redirect_options'] == 'current_page' ) {
|
563 |
+
if ( isset( $_REQUEST['redirect_to'] ) ) {
|
564 |
$redirect_to = $_REQUEST['redirect_to'];
|
565 |
// Redirect to https if user wants ssl
|
566 |
+
if ( isset( $secure_cookie ) && false !== strpos( $redirect_to, 'wp-admin' ) )
|
567 |
+
$user_login_url = preg_replace( '|^http://|', 'https://', $redirect_to );
|
568 |
} else {
|
569 |
$user_login_url = home_url();
|
570 |
}
|
571 |
+
} else if ( $options['apsl_custom_login_redirect_options'] == 'custom_page' ) {
|
572 |
+
if ( $options['apsl_custom_login_redirect_link'] != '' ) {
|
573 |
$login_page = $options['apsl_custom_login_redirect_link'];
|
574 |
$user_login_url = $login_page;
|
575 |
} else {
|
580 |
$user_login_url = home_url();
|
581 |
}
|
582 |
$redirect_to = $user_login_url;
|
583 |
+
wp_safe_redirect( $redirect_to );
|
584 |
exit();
|
585 |
}
|
586 |
|
587 |
//returns the current page url
|
588 |
public static function curPageURL() {
|
589 |
$pageURL = 'http';
|
590 |
+
if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) {
|
591 |
$pageURL .= "s";
|
592 |
}
|
593 |
$pageURL .= "://";
|
594 |
+
if ( $_SERVER["SERVER_PORT"] != "80" ) {
|
595 |
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
|
596 |
} else {
|
597 |
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
600 |
}
|
601 |
|
602 |
//function to access the protected object properties
|
603 |
+
function accessProtected( $obj, $prop ) {
|
604 |
+
$reflection = new ReflectionClass( $obj );
|
605 |
+
$property = $reflection->getProperty( $prop );
|
606 |
+
$property->setAccessible( true );
|
607 |
+
return $property->getValue( $obj );
|
608 |
}
|
609 |
|
610 |
}//termination of a class
|
inc/frontend/login_integration.php
CHANGED
@@ -1,36 +1,37 @@
|
|
1 |
-
<?php defined('ABSPATH') or die("No script kiddies please!"); ?>
|
2 |
<?php
|
3 |
-
$options = get_option(APSL_SETTINGS);
|
4 |
|
5 |
-
$redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
|
6 |
|
7 |
-
$encoded_url = urlencode($redirect_to);
|
8 |
?>
|
9 |
<div class='apsl-login-networks theme-<?php echo $options['apsl_icon_theme']; ?> clearfix'>
|
10 |
<span class='apsl-login-new-text'><?php echo $options['apsl_title_text_field']; ?></span>
|
11 |
-
<?php if (isset($_REQUEST['error']) || isset($_REQUEST['denied'])) { ?>
|
12 |
<div class='apsl-error'>
|
13 |
-
<?php _e('You have Access Denied. Please authorize the app to login.', APSL_TEXT_DOMAIN); ?>
|
14 |
</div>
|
15 |
<?php } ?>
|
16 |
|
17 |
<div class='social-networks'>
|
18 |
-
<?php foreach ($options['network_ordering'] as $key => $value): ?>
|
19 |
-
<?php if ($options["apsl_{$value}_settings"]["apsl_{$value}_enable"] === 'enable') { ?>
|
20 |
<a href="<?php wp_login_url() ?>?apsl_login_id=<?php echo $value; ?>_login<?php
|
21 |
-
if ($encoded_url) {
|
22 |
-
echo "&state=" . base64_encode("redirect_to=$encoded_url");
|
23 |
}
|
24 |
-
?>" title='<?php
|
25 |
-
|
26 |
-
|
|
|
27 |
<div class="apsl-icon-block icon-<?php echo $value; ?> clearfix">
|
28 |
<i class="fa fa-<?php echo $value; ?>"></i>
|
29 |
-
<span class="apsl-login-text"><?php _e('Login', APSL_TEXT_DOMAIN); ?></span>
|
30 |
-
<span class="apsl-long-login-text"><?php _e('Login with', APSL_TEXT_DOMAIN); ?><?php echo ' ' . $value; ?></span>
|
31 |
</div>
|
32 |
</a>
|
33 |
-
|
34 |
<?php endforeach; ?>
|
35 |
</div>
|
36 |
</div>
|
1 |
+
<?php defined( 'ABSPATH' ) or die( "No script kiddies please!" ); ?>
|
2 |
<?php
|
3 |
+
$options = get_option( APSL_SETTINGS );
|
4 |
|
5 |
+
$redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
|
6 |
|
7 |
+
$encoded_url = urlencode( $redirect_to );
|
8 |
?>
|
9 |
<div class='apsl-login-networks theme-<?php echo $options['apsl_icon_theme']; ?> clearfix'>
|
10 |
<span class='apsl-login-new-text'><?php echo $options['apsl_title_text_field']; ?></span>
|
11 |
+
<?php if ( isset( $_REQUEST['error'] ) || isset( $_REQUEST['denied'] ) ) { ?>
|
12 |
<div class='apsl-error'>
|
13 |
+
<?php _e( 'You have Access Denied. Please authorize the app to login.', APSL_TEXT_DOMAIN ); ?>
|
14 |
</div>
|
15 |
<?php } ?>
|
16 |
|
17 |
<div class='social-networks'>
|
18 |
+
<?php foreach ( $options['network_ordering'] as $key => $value ): ?>
|
19 |
+
<?php if ( $options["apsl_{$value}_settings"]["apsl_{$value}_enable"] === 'enable' ) { ?>
|
20 |
<a href="<?php wp_login_url() ?>?apsl_login_id=<?php echo $value; ?>_login<?php
|
21 |
+
if ( $encoded_url ) {
|
22 |
+
echo "&state=" . base64_encode( "redirect_to=$encoded_url" );
|
23 |
}
|
24 |
+
?>" title='<?php
|
25 |
+
_e( 'Login with', APSL_TEXT_DOMAIN );
|
26 |
+
echo ' ' . $value;
|
27 |
+
?>' >
|
28 |
<div class="apsl-icon-block icon-<?php echo $value; ?> clearfix">
|
29 |
<i class="fa fa-<?php echo $value; ?>"></i>
|
30 |
+
<span class="apsl-login-text"><?php _e( 'Login', APSL_TEXT_DOMAIN ); ?></span>
|
31 |
+
<span class="apsl-long-login-text"><?php _e( 'Login with', APSL_TEXT_DOMAIN ); ?><?php echo ' ' . $value; ?></span>
|
32 |
</div>
|
33 |
</a>
|
34 |
+
<?php } ?>
|
35 |
<?php endforeach; ?>
|
36 |
</div>
|
37 |
</div>
|
inc/frontend/shortcode.php
CHANGED
@@ -1,68 +1,70 @@
|
|
1 |
-
<?php defined('ABSPATH') or die('No script kiddies please!'); ?>
|
2 |
-
<?php $options = get_option(APSL_SETTINGS); ?>
|
3 |
<?php
|
4 |
-
if (is_user_logged_in()) {
|
5 |
global $current_user;
|
6 |
$user_info = "<span class='display-name'>{$current_user->data->display_name}</span> ";
|
7 |
-
$user_info .= get_avatar($current_user->ID, 20);
|
8 |
|
9 |
-
if (!empty($_GET['redirect']))
|
10 |
$current_url = $_GET['redirect'];
|
11 |
else
|
12 |
$current_url = APSL_Lite_Login_Check_Class::curPageURL();
|
13 |
|
14 |
-
if (isset($options['apsl_custom_logout_redirect_options']) && $options['apsl_custom_logout_redirect_options'] != '') {
|
15 |
-
if ($options['apsl_custom_logout_redirect_options'] == 'home') {
|
16 |
-
$user_logout_url = wp_logout_url(home_url());
|
17 |
-
} else if ($options['apsl_custom_logout_redirect_options'] == 'current_page') {
|
18 |
-
$user_logout_url = wp_logout_url($current_url);
|
19 |
-
} else if ($options['apsl_custom_logout_redirect_options'] == 'custom_page') {
|
20 |
-
if ($options['apsl_custom_logout_redirect_link'] != '') {
|
21 |
$logout_page = $options['apsl_custom_logout_redirect_link'];
|
22 |
-
$user_logout_url = wp_logout_url($logout_page);
|
23 |
} else {
|
24 |
-
$user_logout_url = wp_logout_url($current_url);
|
25 |
}
|
26 |
}
|
27 |
} else {
|
28 |
-
$user_logout_url = wp_logout_url($current_url);
|
29 |
}
|
30 |
?><div class="user-login">Welcome <b><?php echo $user_info; ?></b> | <a href="<?php echo $user_logout_url; ?>" title="Logout">Logout</a></div>
|
31 |
<?php
|
32 |
} else {
|
33 |
?>
|
34 |
<?php
|
35 |
-
$current_url = APSL_Lite_Login_Check_Class::curPageURL();
|
36 |
-
$encoded_url = urlencode($current_url);
|
37 |
?>
|
38 |
|
39 |
<?php $theme = $options['apsl_icon_theme']; ?>
|
40 |
|
41 |
<div class='apsl-login-networks theme-<?php echo $theme; ?> clearfix'>
|
42 |
-
<?php if (isset($attr['login_text']) && $attr['login_text'] != '') { ?>
|
43 |
<span class='apsl-login-new-text'><?php echo $attr['login_text']; ?></span>
|
44 |
<?php } ?>
|
45 |
-
<?php if (isset($_REQUEST['error']) || isset($_REQUEST['denied'])) { ?>
|
46 |
-
<div class='apsl-error'><?php _e('You have Access Denied. Please authorize the app to login.', APSL_TEXT_DOMAIN); ?></div>
|
47 |
<?php } ?>
|
48 |
<div class='social-networks'>
|
49 |
-
<?php foreach ($options['network_ordering'] as $key => $value): ?>
|
50 |
-
<?php if ($options["apsl_{$value}_settings"]["apsl_{$value}_enable"] === 'enable') { ?>
|
51 |
<a href="<?php echo wp_login_url() ?>?apsl_login_id=<?php echo $value; ?>_login<?php
|
52 |
-
if ($encoded_url) {
|
53 |
-
echo "&state=" . base64_encode("redirect_to=$encoded_url");
|
54 |
}
|
55 |
-
?>" title='<?php
|
56 |
-
|
57 |
-
|
|
|
58 |
<div class="apsl-icon-block icon-<?php echo $value; ?>">
|
59 |
<i class="fa fa-<?php echo $value; ?>"></i>
|
60 |
-
<span class="apsl-login-text"><?php _e('Login', APSL_TEXT_DOMAIN); ?></span>
|
61 |
-
<span class="apsl-long-login-text"><?php _e('Login with', APSL_TEXT_DOMAIN); ?><?php echo ' ' . $value; ?></span>
|
62 |
</div>
|
63 |
</a>
|
64 |
-
|
65 |
<?php endforeach; ?>
|
66 |
</div>
|
67 |
</div>
|
68 |
-
<?php
|
|
1 |
+
<?php defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); ?>
|
2 |
+
<?php $options = get_option( APSL_SETTINGS ); ?>
|
3 |
<?php
|
4 |
+
if ( is_user_logged_in() ) {
|
5 |
global $current_user;
|
6 |
$user_info = "<span class='display-name'>{$current_user->data->display_name}</span> ";
|
7 |
+
$user_info .= get_avatar( $current_user->ID, 20 );
|
8 |
|
9 |
+
if ( !empty( $_GET['redirect'] ) )
|
10 |
$current_url = $_GET['redirect'];
|
11 |
else
|
12 |
$current_url = APSL_Lite_Login_Check_Class::curPageURL();
|
13 |
|
14 |
+
if ( isset( $options['apsl_custom_logout_redirect_options'] ) && $options['apsl_custom_logout_redirect_options'] != '' ) {
|
15 |
+
if ( $options['apsl_custom_logout_redirect_options'] == 'home' ) {
|
16 |
+
$user_logout_url = wp_logout_url( home_url() );
|
17 |
+
} else if ( $options['apsl_custom_logout_redirect_options'] == 'current_page' ) {
|
18 |
+
$user_logout_url = wp_logout_url( $current_url );
|
19 |
+
} else if ( $options['apsl_custom_logout_redirect_options'] == 'custom_page' ) {
|
20 |
+
if ( $options['apsl_custom_logout_redirect_link'] != '' ) {
|
21 |
$logout_page = $options['apsl_custom_logout_redirect_link'];
|
22 |
+
$user_logout_url = wp_logout_url( $logout_page );
|
23 |
} else {
|
24 |
+
$user_logout_url = wp_logout_url( $current_url );
|
25 |
}
|
26 |
}
|
27 |
} else {
|
28 |
+
$user_logout_url = wp_logout_url( $current_url );
|
29 |
}
|
30 |
?><div class="user-login">Welcome <b><?php echo $user_info; ?></b> | <a href="<?php echo $user_logout_url; ?>" title="Logout">Logout</a></div>
|
31 |
<?php
|
32 |
} else {
|
33 |
?>
|
34 |
<?php
|
35 |
+
$current_url = APSL_Lite_Login_Check_Class:: curPageURL();
|
36 |
+
$encoded_url = urlencode( $current_url );
|
37 |
?>
|
38 |
|
39 |
<?php $theme = $options['apsl_icon_theme']; ?>
|
40 |
|
41 |
<div class='apsl-login-networks theme-<?php echo $theme; ?> clearfix'>
|
42 |
+
<?php if ( isset( $attr['login_text'] ) && $attr['login_text'] != '' ) { ?>
|
43 |
<span class='apsl-login-new-text'><?php echo $attr['login_text']; ?></span>
|
44 |
<?php } ?>
|
45 |
+
<?php if ( isset( $_REQUEST['error'] ) || isset( $_REQUEST['denied'] ) ) { ?>
|
46 |
+
<div class='apsl-error'><?php _e( 'You have Access Denied. Please authorize the app to login.', APSL_TEXT_DOMAIN ); ?></div>
|
47 |
<?php } ?>
|
48 |
<div class='social-networks'>
|
49 |
+
<?php foreach ( $options['network_ordering'] as $key => $value ): ?>
|
50 |
+
<?php if ( $options["apsl_{$value}_settings"]["apsl_{$value}_enable"] === 'enable' ) { ?>
|
51 |
<a href="<?php echo wp_login_url() ?>?apsl_login_id=<?php echo $value; ?>_login<?php
|
52 |
+
if ( $encoded_url ) {
|
53 |
+
echo "&state=" . base64_encode( "redirect_to=$encoded_url" );
|
54 |
}
|
55 |
+
?>" title='<?php
|
56 |
+
_e( 'Login with', APSL_TEXT_DOMAIN );
|
57 |
+
echo ' ' . $value;
|
58 |
+
?>'>
|
59 |
<div class="apsl-icon-block icon-<?php echo $value; ?>">
|
60 |
<i class="fa fa-<?php echo $value; ?>"></i>
|
61 |
+
<span class="apsl-login-text"><?php _e( 'Login', APSL_TEXT_DOMAIN ); ?></span>
|
62 |
+
<span class="apsl-long-login-text"><?php _e( 'Login with', APSL_TEXT_DOMAIN ); ?><?php echo ' ' . $value; ?></span>
|
63 |
</div>
|
64 |
</a>
|
65 |
+
<?php } ?>
|
66 |
<?php endforeach; ?>
|
67 |
</div>
|
68 |
</div>
|
69 |
+
<?php
|
70 |
+
}
|
js/backend.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
jQuery(document).ready(function($){
|
2 |
//for sorting the social networks
|
3 |
$('.network-settings').sortable({
|
4 |
-
containment: "parent"
|
5 |
});
|
6 |
|
7 |
//for the tabs
|
1 |
jQuery(document).ready(function($){
|
2 |
//for sorting the social networks
|
3 |
$('.network-settings').sortable({
|
4 |
+
containment: "parent"
|
5 |
});
|
6 |
|
7 |
//for the tabs
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: social, login, social login, facebook, twitter, google, social connect, s
|
|
4 |
Donate link: http://accesspressthemes.com/donation/
|
5 |
Requires at least: 3.8
|
6 |
Tested up to: 4.3
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -131,6 +131,10 @@ Yes. You can use the AccessPress social login lite anywhere by using shortcode i
|
|
131 |
4. Backend Other settings Section.
|
132 |
|
133 |
== Changelog ==
|
|
|
|
|
|
|
|
|
134 |
= 2.0.2 =
|
135 |
* Removal of unnecessary comments from the plugin files.
|
136 |
* Code optimizations of plugin's files.
|
4 |
Donate link: http://accesspressthemes.com/donation/
|
5 |
Requires at least: 3.8
|
6 |
Tested up to: 4.3
|
7 |
+
Stable tag: 2.0.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
131 |
4. Backend Other settings Section.
|
132 |
|
133 |
== Changelog ==
|
134 |
+
= 2.0.3 =
|
135 |
+
* Code formatting to optimize the plugin size.
|
136 |
+
* Text changes in the how to use section.
|
137 |
+
|
138 |
= 2.0.2 =
|
139 |
* Removal of unnecessary comments from the plugin files.
|
140 |
* Code optimizations of plugin's files.
|