Version Description
Download this release
Release Info
Developer | jfarthing84 |
Plugin | Theme My Login |
Version | 2.0.3 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.0.3
- includes/profile-actions.php +1 -1
- includes/wp-login-actions.php +7 -6
- readme.txt +5 -2
- theme-my-login.php +72 -435
includes/profile-actions.php
CHANGED
@@ -29,7 +29,7 @@ case 'update':
|
|
29 |
$this->errors = edit_user($user_id);
|
30 |
|
31 |
if ( !is_wp_error( $this->errors ) ) {
|
32 |
-
$redirect = ('
|
33 |
wp_redirect($redirect);
|
34 |
exit;
|
35 |
}
|
29 |
$this->errors = edit_user($user_id);
|
30 |
|
31 |
if ( !is_wp_error( $this->errors ) ) {
|
32 |
+
$redirect = (admin_url('profile.php') . '?updated=true');
|
33 |
wp_redirect($redirect);
|
34 |
exit;
|
35 |
}
|
includes/wp-login-actions.php
CHANGED
@@ -48,7 +48,8 @@ case 'logout' :
|
|
48 |
check_admin_referer('log-out');
|
49 |
wp_logout();
|
50 |
|
51 |
-
|
|
|
52 |
if ( isset( $_REQUEST['redirect_to'] ) )
|
53 |
$redirect_to = $_REQUEST['redirect_to'];
|
54 |
|
@@ -60,7 +61,7 @@ case 'retrievepassword' :
|
|
60 |
if ( $http_post ) {
|
61 |
$this->errors = retrieve_password();
|
62 |
if ( !is_wp_error($this->errors) ) {
|
63 |
-
wp_redirect('wp-login.php?checkemail=confirm');
|
64 |
exit();
|
65 |
}
|
66 |
}
|
@@ -73,16 +74,16 @@ case 'rp' :
|
|
73 |
$this->errors = reset_password($_GET['key']);
|
74 |
|
75 |
if ( ! is_wp_error($this->errors) ) {
|
76 |
-
wp_redirect('wp-login.php?checkemail=newpass');
|
77 |
exit();
|
78 |
}
|
79 |
|
80 |
-
wp_redirect('wp-login.php?action=lostpassword&error=invalidkey');
|
81 |
exit();
|
82 |
break;
|
83 |
case 'register' :
|
84 |
if ( !get_option('users_can_register') ) {
|
85 |
-
wp_redirect('wp-login.php?registration=disabled');
|
86 |
exit();
|
87 |
}
|
88 |
|
@@ -94,7 +95,7 @@ case 'register' :
|
|
94 |
$this->errors = register_new_user($user_login, $user_email);
|
95 |
|
96 |
if ( !is_wp_error($this->errors) ) {
|
97 |
-
wp_redirect('wp-login.php?checkemail=registered');
|
98 |
exit();
|
99 |
}
|
100 |
}
|
48 |
check_admin_referer('log-out');
|
49 |
wp_logout();
|
50 |
|
51 |
+
|
52 |
+
$redirect_to = get_option('siteurl') . '/wp-login.php?loggedout=true';
|
53 |
if ( isset( $_REQUEST['redirect_to'] ) )
|
54 |
$redirect_to = $_REQUEST['redirect_to'];
|
55 |
|
61 |
if ( $http_post ) {
|
62 |
$this->errors = retrieve_password();
|
63 |
if ( !is_wp_error($this->errors) ) {
|
64 |
+
wp_redirect(get_option('siteurl') . '/wp-login.php?checkemail=confirm');
|
65 |
exit();
|
66 |
}
|
67 |
}
|
74 |
$this->errors = reset_password($_GET['key']);
|
75 |
|
76 |
if ( ! is_wp_error($this->errors) ) {
|
77 |
+
wp_redirect(get_option('siteurl') . '/wp-login.php?checkemail=newpass');
|
78 |
exit();
|
79 |
}
|
80 |
|
81 |
+
wp_redirect(get_option('siteurl') . '/wp-login.php?action=lostpassword&error=invalidkey');
|
82 |
exit();
|
83 |
break;
|
84 |
case 'register' :
|
85 |
if ( !get_option('users_can_register') ) {
|
86 |
+
wp_redirect(get_option('siteurl') . '/wp-login.php?registration=disabled');
|
87 |
exit();
|
88 |
}
|
89 |
|
95 |
$this->errors = register_new_user($user_login, $user_email);
|
96 |
|
97 |
if ( !is_wp_error($this->errors) ) {
|
98 |
+
wp_redirect(get_option('siteurl') . '/wp-login.php?checkemail=registered');
|
99 |
exit();
|
100 |
}
|
101 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://webdesign.jaedub.com
|
|
4 |
Tags: wordpress, login, register, theme, form, james kelly
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.7.1
|
7 |
-
Stable tag: 2.0.
|
8 |
|
9 |
This plugin themes the WordPress login, register, forgot password and profile pages to look like the rest of your website.
|
10 |
|
@@ -13,6 +13,8 @@ This plugin themes the WordPress login, register, forgot password and profile pa
|
|
13 |
|
14 |
This plugin themes the WordPress login, register, forgot password and profile pages to look like the rest of your website. It replaces the wp-login.php and profile.php by using a page template from your theme.
|
15 |
|
|
|
|
|
16 |
|
17 |
== Installation ==
|
18 |
|
@@ -53,4 +55,5 @@ Now you can save your changes and go test out your new themed login and registra
|
|
53 |
* 1.2.0 - 2009-03-26 - Added capability to customize page titles for all pages affected by plugin
|
54 |
* 2.0.0 - 2009-03-27 - Completely rewrote plugin to use page template, no more specifying template files & HTML
|
55 |
* 2.0.1 - 2009-03-30 - Fixed a bug that redirected users who were not yet logged in to profile page
|
56 |
-
* 2.0.2 - 2009-03-31 - Fixed a bug that broke new user registration and a bug that broke other plugins that use 'the_content' filter
|
|
4 |
Tags: wordpress, login, register, theme, form, james kelly
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.7.1
|
7 |
+
Stable tag: 2.0.3
|
8 |
|
9 |
This plugin themes the WordPress login, register, forgot password and profile pages to look like the rest of your website.
|
10 |
|
13 |
|
14 |
This plugin themes the WordPress login, register, forgot password and profile pages to look like the rest of your website. It replaces the wp-login.php and profile.php by using a page template from your theme.
|
15 |
|
16 |
+
To everybody who has been bearing with this plugin since the begining, thank you. I believe everything should be in well working order now. If you have any questions, comments or concerns, please contact me through my website listed here.
|
17 |
+
|
18 |
|
19 |
== Installation ==
|
20 |
|
55 |
* 1.2.0 - 2009-03-26 - Added capability to customize page titles for all pages affected by plugin
|
56 |
* 2.0.0 - 2009-03-27 - Completely rewrote plugin to use page template, no more specifying template files & HTML
|
57 |
* 2.0.1 - 2009-03-30 - Fixed a bug that redirected users who were not yet logged in to profile page
|
58 |
+
* 2.0.2 - 2009-03-31 - Fixed a bug that broke new user registration and a bug that broke other plugins that use 'the_content' filter
|
59 |
+
* 2.0.3 - 2009-04-02 - Fixed various reported bugs and cleaned up code
|
theme-my-login.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Theme My Login
|
4 |
Plugin URI: http://webdesign.jaedub.com/wordpress-plugins/theme-my-login-plugin
|
5 |
Description: Themes the WordPress login, register, forgot password and profile pages to look like the rest of your website.
|
6 |
-
Version: 2.0.
|
7 |
Author: Jae Dub
|
8 |
Author URI: http://webdesign.jaedub.com
|
9 |
|
@@ -27,13 +27,14 @@ Version History
|
|
27 |
Fixed a bug that redirected users who were not yet logged in to profile page
|
28 |
2.0.2 - 2009-03-31
|
29 |
Fixed a bug that broke new user registration and a bug that broke other plugins that use 'the_content' filter
|
|
|
|
|
30 |
*/
|
31 |
|
32 |
if (!class_exists('ThemeMyLogin')) {
|
33 |
class ThemeMyLogin {
|
34 |
|
35 |
var $options = array();
|
36 |
-
var $is_login = false;
|
37 |
var $errors = '';
|
38 |
|
39 |
function ThemeMyLogin() {
|
@@ -43,22 +44,15 @@ if (!class_exists('ThemeMyLogin')) {
|
|
43 |
function __construct() {
|
44 |
register_activation_hook ( __FILE__, array( &$this, 'Activate' ) );
|
45 |
register_deactivation_hook ( __FILE__, array( &$this, 'Deactivate' ) );
|
46 |
-
|
47 |
-
add_action('init', array(&$this, 'Init'));
|
48 |
add_action('admin_menu', array(&$this, 'AddAdminPage'));
|
|
|
|
|
49 |
|
50 |
-
add_action('wp_print_scripts', array(&$this, 'DoLogin'));
|
51 |
-
|
52 |
add_filter('wp_title', array(&$this, 'WPTitle'));
|
53 |
add_filter('the_title', array(&$this, 'TheTitle'));
|
54 |
-
|
55 |
add_filter('wp_list_pages_excludes', array(&$this, 'ListPagesExcludes'));
|
56 |
-
|
57 |
-
if ($_GET['show'] == 'profile') {
|
58 |
-
add_action('wp_head', array(&$this, 'ProfileJS'));
|
59 |
-
add_action('wp_head', array(&$this, 'ProfileCSS'));
|
60 |
-
wp_enqueue_script('jquery');
|
61 |
-
}
|
62 |
}
|
63 |
|
64 |
function Activate() {
|
@@ -66,8 +60,8 @@ if (!class_exists('ThemeMyLogin')) {
|
|
66 |
delete_option('tml_options');
|
67 |
|
68 |
$theme_my_login = get_page_by_title('Login');
|
69 |
-
|
70 |
-
|
71 |
'post_title' => 'Login',
|
72 |
'post_status' => 'publish',
|
73 |
'post_type' => 'page',
|
@@ -76,21 +70,17 @@ if (!class_exists('ThemeMyLogin')) {
|
|
76 |
'comment_status' => 'closed',
|
77 |
'ping_status' => 'closed'
|
78 |
);
|
79 |
-
|
|
|
80 |
$theme_my_login = wp_insert_post($insert);
|
|
|
81 |
} else {
|
82 |
-
$
|
83 |
-
$
|
84 |
-
|
85 |
-
'post_content' => '[theme-my-login]',
|
86 |
-
'comment_status' => 'closed',
|
87 |
-
'ping_status' => 'closed'
|
88 |
-
);
|
89 |
-
|
90 |
-
wp_update_post($update);
|
91 |
}
|
92 |
|
93 |
-
$this->SetOption(
|
94 |
$this->SaveOptions();
|
95 |
}
|
96 |
|
@@ -103,7 +93,6 @@ if (!class_exists('ThemeMyLogin')) {
|
|
103 |
|
104 |
# Sets up default options
|
105 |
function InitOptions() {
|
106 |
-
$this->options['version'] = '2.0';
|
107 |
$this->options['chk_uninstall'] = 0;
|
108 |
$this->options['page_id'] = '0';
|
109 |
$this->options['login_redirect'] = 'wp-admin/';
|
@@ -163,245 +152,87 @@ if (!class_exists('ThemeMyLogin')) {
|
|
163 |
function QueryURL() {
|
164 |
global $wp_rewrite;
|
165 |
|
166 |
-
$
|
167 |
|
168 |
if ($wp_rewrite->using_permalinks())
|
169 |
-
return $
|
170 |
else
|
171 |
-
return $
|
172 |
}
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
function Init() {
|
175 |
global $pagenow;
|
176 |
-
|
177 |
$this->LoadOptions();
|
178 |
-
$
|
179 |
|
180 |
if ( is_user_logged_in() && is_admin() && current_user_can('edit_posts') === false && !isset($_POST['from']) && $_POST['from'] != 'profile' ) {
|
181 |
-
$
|
182 |
-
|
183 |
-
|
184 |
-
wp_safe_redirect($url);
|
185 |
exit;
|
186 |
}
|
187 |
|
188 |
switch ($pagenow) {
|
189 |
case 'wp-register.php':
|
190 |
case 'wp-login.php':
|
191 |
-
|
192 |
-
|
193 |
-
foreach($_GET as $key => $value) :
|
194 |
-
if (strpos($url, '?') !== false) :
|
195 |
-
if ($count == 1)
|
196 |
-
$url .= $key . '=' . $value;
|
197 |
-
else
|
198 |
-
$url .= '&' . $key . '=' . $value;
|
199 |
-
else :
|
200 |
-
$url .= '?' . $key . '=' . $value;
|
201 |
-
endif;
|
202 |
-
$count++;
|
203 |
-
endforeach;
|
204 |
-
else :
|
205 |
-
$url = get_permalink( $this->GetOption('page_id') );
|
206 |
-
endif;
|
207 |
-
wp_safe_redirect($url);
|
208 |
exit;
|
209 |
break;
|
210 |
}
|
211 |
-
|
212 |
-
$this->errors = new WP_Error();
|
213 |
-
|
214 |
-
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
|
215 |
-
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
216 |
-
|
217 |
-
if ( isset($_GET['key']) )
|
218 |
-
$action = 'resetpass';
|
219 |
-
|
220 |
-
nocache_headers();
|
221 |
-
|
222 |
-
if ( defined('RELOCATE') ) { // Move flag is set
|
223 |
-
if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
|
224 |
-
$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
|
225 |
-
|
226 |
-
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
227 |
-
if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('siteurl') )
|
228 |
-
update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
|
229 |
-
}
|
230 |
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
245 |
}
|
246 |
-
|
247 |
-
switch ($action) :
|
248 |
-
case 'logout':
|
249 |
-
$this->Logout();
|
250 |
-
break;
|
251 |
-
case 'lostpassword':
|
252 |
-
case 'retrievepassword':
|
253 |
-
require('includes/compat.php');
|
254 |
-
if ( $http_post ) {
|
255 |
-
$this->errors = retrieve_password();
|
256 |
-
if ( !is_wp_error($this->errors) ) {
|
257 |
-
wp_redirect('wp-login.php?checkemail=confirm');
|
258 |
-
exit();
|
259 |
-
}
|
260 |
-
}
|
261 |
-
break;
|
262 |
-
case 'register':
|
263 |
-
require_once('includes/compat.php');
|
264 |
-
if ( !get_option('users_can_register') ) {
|
265 |
-
wp_redirect('wp-login.php?registration=disabled');
|
266 |
-
exit();
|
267 |
-
}
|
268 |
-
|
269 |
-
$user_login = '';
|
270 |
-
$user_email = '';
|
271 |
-
if ( $http_post ) {
|
272 |
-
require_once( ABSPATH . WPINC . '/registration.php');
|
273 |
-
|
274 |
-
$user_login = $_POST['user_login'];
|
275 |
-
$user_email = $_POST['user_email'];
|
276 |
-
$this->errors = register_new_user($user_login, $user_email);
|
277 |
-
if ( !is_wp_error($this->errors) ) {
|
278 |
-
wp_redirect('wp-login.php?checkemail=registered');
|
279 |
-
exit();
|
280 |
-
}
|
281 |
-
}
|
282 |
-
break;
|
283 |
-
case 'login':
|
284 |
-
$secure_cookie = '';
|
285 |
-
|
286 |
-
// If the user wants ssl but the session is not ssl, force a secure cookie.
|
287 |
-
if ( !empty($_POST['log']) && !force_ssl_admin() ) {
|
288 |
-
$user_name = sanitize_user($_POST['log']);
|
289 |
-
if ( $user = get_userdatabylogin($user_name) ) {
|
290 |
-
if ( get_user_option('use_ssl', $user->ID) ) {
|
291 |
-
$secure_cookie = true;
|
292 |
-
force_ssl_admin(true);
|
293 |
-
}
|
294 |
-
}
|
295 |
-
}
|
296 |
-
|
297 |
-
if ( isset( $_REQUEST['redirect_to'] ) ) {
|
298 |
-
$redirect_to = $_REQUEST['redirect_to'];
|
299 |
-
// Redirect to https if user wants ssl
|
300 |
-
if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') )
|
301 |
-
$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
|
302 |
-
} else {
|
303 |
-
$redirect_to = $this->GetOption('login_redirect');
|
304 |
-
}
|
305 |
-
|
306 |
-
if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
|
307 |
-
$secure_cookie = false;
|
308 |
-
|
309 |
-
$user = wp_signon('', $secure_cookie);
|
310 |
-
|
311 |
-
$redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
|
312 |
-
|
313 |
-
if ( !is_wp_error($user) ) {
|
314 |
-
// If the user can't edit posts, send them to their profile.
|
315 |
-
if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
|
316 |
-
$redirect_to = admin_url('profile.php');
|
317 |
-
wp_safe_redirect($redirect_to);
|
318 |
-
exit();
|
319 |
-
}
|
320 |
-
|
321 |
-
$this->errors = $user;
|
322 |
-
|
323 |
-
break;
|
324 |
-
|
325 |
-
case 'update':
|
326 |
-
if (isset($_POST['from']) && $_POST['from'] == 'profile') {
|
327 |
-
|
328 |
-
if ( !$user_id ) {
|
329 |
-
$current_user = wp_get_current_user();
|
330 |
-
$user_id = $current_user->ID;
|
331 |
-
if (!$user_id) {
|
332 |
-
wp_redirect('wp-login.php');
|
333 |
-
exit;
|
334 |
-
}
|
335 |
-
}
|
336 |
-
|
337 |
-
//include ABSPATH . '/wp-admin/includes/misc.php';
|
338 |
-
include ABSPATH . '/wp-admin/includes/user.php';
|
339 |
-
include ABSPATH . 'wp-includes/registration-functions.php';
|
340 |
-
|
341 |
-
check_admin_referer('update-user_' . $user_id);
|
342 |
-
|
343 |
-
if ( !current_user_can('edit_user', $user_id) )
|
344 |
-
wp_die(__('You do not have permission to edit this user.'));
|
345 |
-
|
346 |
-
do_action('personal_options_update');
|
347 |
-
|
348 |
-
$this->errors = edit_user($user_id);
|
349 |
-
|
350 |
-
if ( !is_wp_error( $this->errors ) ) {
|
351 |
-
$redirect = 'wp-admin/profile.php?updated=true';
|
352 |
-
$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
|
353 |
-
wp_redirect($redirect);
|
354 |
-
exit;
|
355 |
-
}
|
356 |
-
}
|
357 |
-
break;
|
358 |
-
endswitch;
|
359 |
}
|
360 |
|
361 |
-
function
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
368 |
-
|
369 |
-
if ( isset($_GET['key']) )
|
370 |
-
$action = 'resetpass';
|
371 |
-
|
372 |
-
if ($_GET['show'] == 'profile') {
|
373 |
-
if (is_user_logged_in()) {
|
374 |
-
add_filter('the_content', array(&$this, 'Profile'));
|
375 |
-
} else {
|
376 |
-
wp_redirect('wp-login.php');
|
377 |
-
exit;
|
378 |
-
}
|
379 |
-
} else {
|
380 |
-
|
381 |
-
switch ($action) {
|
382 |
-
case 'lostpassword' :
|
383 |
-
case 'retrievepassword' :
|
384 |
-
add_filter('the_content', array(&$this, 'LostPassword'));
|
385 |
-
break;
|
386 |
-
case 'resetpass' :
|
387 |
-
case 'rp' :
|
388 |
-
$this->ResetPass();
|
389 |
-
break;
|
390 |
-
case 'register' :
|
391 |
-
add_filter('the_content', array(&$this, 'Register'));
|
392 |
-
break;
|
393 |
-
case 'login' :
|
394 |
-
default:
|
395 |
-
add_filter('the_content', array(&$this, 'Login'));
|
396 |
-
break;
|
397 |
-
}
|
398 |
-
}
|
399 |
-
endif;
|
400 |
}
|
401 |
|
402 |
function WPTitle($title) {
|
403 |
if (is_page($this->GetOption('page_id'))) {
|
404 |
-
if ($_GET['
|
405 |
return str_replace('%blogname%', get_option('blogname'), $this->GetOption('profile_title'));
|
406 |
|
407 |
switch ($_GET['action']) {
|
@@ -423,7 +254,7 @@ if (!class_exists('ThemeMyLogin')) {
|
|
423 |
|
424 |
function TheTitle($title) {
|
425 |
if ($title == 'Login') {
|
426 |
-
if ($_GET['
|
427 |
return $this->GetOption('profile_text');
|
428 |
|
429 |
switch ($_GET['action']) {
|
@@ -448,200 +279,6 @@ if (!class_exists('ThemeMyLogin')) {
|
|
448 |
|
449 |
return $excludes;
|
450 |
}
|
451 |
-
|
452 |
-
function DoHeader($message = '', $wp_error = '') {
|
453 |
-
global $error;
|
454 |
-
|
455 |
-
if ( empty($wp_error) )
|
456 |
-
$wp_error = new WP_Error();
|
457 |
-
?>
|
458 |
-
|
459 |
-
<div id="login">
|
460 |
-
|
461 |
-
<?php
|
462 |
-
|
463 |
-
if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n";
|
464 |
-
|
465 |
-
// Incase a plugin uses $error rather than the $errors object
|
466 |
-
if ( !empty( $error ) ) {
|
467 |
-
$wp_error->add('error', $error);
|
468 |
-
unset($error);
|
469 |
-
}
|
470 |
-
|
471 |
-
if ( $wp_error->get_error_code() ) {
|
472 |
-
$errors = '';
|
473 |
-
$messages = '';
|
474 |
-
foreach ( $wp_error->get_error_codes() as $code ) {
|
475 |
-
$severity = $wp_error->get_error_data($code);
|
476 |
-
foreach ( $wp_error->get_error_messages($code) as $error ) {
|
477 |
-
if ( 'message' == $severity )
|
478 |
-
$messages .= ' ' . $error . "<br />\n";
|
479 |
-
else
|
480 |
-
$errors .= ' ' . $error . "<br />\n";
|
481 |
-
}
|
482 |
-
}
|
483 |
-
if ( !empty($errors) )
|
484 |
-
echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
|
485 |
-
if ( !empty($messages) )
|
486 |
-
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
|
487 |
-
|
488 |
-
}
|
489 |
-
}
|
490 |
-
|
491 |
-
function Logout() {
|
492 |
-
if ($wp_version > '2.6')
|
493 |
-
check_admin_referer('log-out');
|
494 |
-
wp_logout();
|
495 |
-
|
496 |
-
if ($this->GetOption('logout_redirect')) {
|
497 |
-
$redirect_to = $this->GetOption('logout_redirect');
|
498 |
-
} else {
|
499 |
-
if ( isset( $_REQUEST['redirect_to'] ) )
|
500 |
-
$redirect_to = $_REQUEST['redirect_to'];
|
501 |
-
else
|
502 |
-
$redirect_to = 'wp-login.php';
|
503 |
-
}
|
504 |
-
|
505 |
-
wp_safe_redirect($redirect_to);
|
506 |
-
exit();
|
507 |
-
}
|
508 |
-
|
509 |
-
function LostPassword($content) {
|
510 |
-
if (strpos($content, '[theme-my-login]') !== false)
|
511 |
-
include 'includes/lost-password.php';
|
512 |
-
else
|
513 |
-
return $content;
|
514 |
-
}
|
515 |
-
|
516 |
-
function ResetPass() {
|
517 |
-
if (!function_exists('reset_password')) :
|
518 |
-
function reset_password($key) {
|
519 |
-
global $wpdb;
|
520 |
-
|
521 |
-
require('includes/compat.php');
|
522 |
-
|
523 |
-
$key = preg_replace('/[^a-z0-9]/i', '', $key);
|
524 |
-
|
525 |
-
if ( empty( $key ) )
|
526 |
-
return new WP_Error('invalid_key', __('Invalid key'));
|
527 |
-
|
528 |
-
$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s", $key));
|
529 |
-
if ( empty( $user ) )
|
530 |
-
return new WP_Error('invalid_key', __('Invalid key'));
|
531 |
-
|
532 |
-
do_action('password_reset', $user);
|
533 |
-
|
534 |
-
// Generate something random for a password...
|
535 |
-
$new_pass = wp_generate_password();
|
536 |
-
wp_set_password($new_pass, $user->ID);
|
537 |
-
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
538 |
-
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
|
539 |
-
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
540 |
-
|
541 |
-
if ( !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
|
542 |
-
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
543 |
-
|
544 |
-
if ( !function_exists('wp_password_change_notification') ) :
|
545 |
-
function wp_password_change_notification(&$user) {
|
546 |
-
if ( $user->user_email != get_option('admin_email') ) {
|
547 |
-
$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
|
548 |
-
wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), get_option('blogname')), $message);
|
549 |
-
}
|
550 |
-
}
|
551 |
-
endif;
|
552 |
-
|
553 |
-
wp_password_change_notification($user);
|
554 |
-
|
555 |
-
return true;
|
556 |
-
}
|
557 |
-
endif;
|
558 |
-
|
559 |
-
$errors = reset_password($_GET['key']);
|
560 |
-
|
561 |
-
if ( ! is_wp_error($errors) ) {
|
562 |
-
wp_redirect('wp-login.php?checkemail=newpass');
|
563 |
-
exit();
|
564 |
-
}
|
565 |
-
|
566 |
-
wp_redirect('wp-login.php?action=lostpassword&error=invalidkey');
|
567 |
-
exit();
|
568 |
-
}
|
569 |
-
|
570 |
-
function Register($content) {
|
571 |
-
if (strpos($content, '[theme-my-login]') !== false)
|
572 |
-
include 'includes/register.php';
|
573 |
-
else
|
574 |
-
return $content;
|
575 |
-
}
|
576 |
-
|
577 |
-
function Login($content) {
|
578 |
-
if (strpos($content, '[theme-my-login]') !== false)
|
579 |
-
include 'includes/login.php';
|
580 |
-
else
|
581 |
-
return $content;
|
582 |
-
}
|
583 |
-
|
584 |
-
function Profile($content) {
|
585 |
-
if (strpos($content, '[theme-my-login]') !== false)
|
586 |
-
include 'includes/profile.php';
|
587 |
-
else
|
588 |
-
return $content;
|
589 |
-
}
|
590 |
-
|
591 |
-
function ProfileJS ( ) {
|
592 |
-
?>
|
593 |
-
<script type="text/javascript">
|
594 |
-
function update_nickname ( ) {
|
595 |
-
|
596 |
-
var nickname = jQuery('#nickname').val();
|
597 |
-
var display_nickname = jQuery('#display_nickname').val();
|
598 |
-
|
599 |
-
if ( nickname == '' ) {
|
600 |
-
jQuery('#display_nickname').remove();
|
601 |
-
}
|
602 |
-
jQuery('#display_nickname').val(nickname).html(nickname);
|
603 |
-
|
604 |
-
}
|
605 |
-
|
606 |
-
jQuery(function($) {
|
607 |
-
$('#pass1').keyup( check_pass_strength )
|
608 |
-
$('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
|
609 |
-
} );
|
610 |
-
|
611 |
-
jQuery(document).ready( function() {
|
612 |
-
jQuery('#pass1,#pass2').attr('autocomplete','off');
|
613 |
-
jQuery('#nickname').blur(update_nickname);
|
614 |
-
});
|
615 |
-
</script>
|
616 |
-
<?php
|
617 |
-
}
|
618 |
-
|
619 |
-
function ProfileCSS ( ) {
|
620 |
-
?>
|
621 |
-
<style type="text/css">
|
622 |
-
table.form-table th, table.form-table td {
|
623 |
-
padding: 0;
|
624 |
-
}
|
625 |
-
table.form-table th {
|
626 |
-
width: 150px;
|
627 |
-
vertical-align: text-top;
|
628 |
-
text-align: left;
|
629 |
-
}
|
630 |
-
p.message {
|
631 |
-
padding: 3px 5px;
|
632 |
-
background-color: lightyellow;
|
633 |
-
border: 1px solid yellow;
|
634 |
-
}
|
635 |
-
#display_name {
|
636 |
-
width: 250px;
|
637 |
-
}
|
638 |
-
.field-hint {
|
639 |
-
display: block;
|
640 |
-
clear: both;
|
641 |
-
}
|
642 |
-
</style>
|
643 |
-
<?php
|
644 |
-
}
|
645 |
}
|
646 |
}
|
647 |
|
3 |
Plugin Name: Theme My Login
|
4 |
Plugin URI: http://webdesign.jaedub.com/wordpress-plugins/theme-my-login-plugin
|
5 |
Description: Themes the WordPress login, register, forgot password and profile pages to look like the rest of your website.
|
6 |
+
Version: 2.0.3
|
7 |
Author: Jae Dub
|
8 |
Author URI: http://webdesign.jaedub.com
|
9 |
|
27 |
Fixed a bug that redirected users who were not yet logged in to profile page
|
28 |
2.0.2 - 2009-03-31
|
29 |
Fixed a bug that broke new user registration and a bug that broke other plugins that use 'the_content' filter
|
30 |
+
2.0.3 - 2009-04-02
|
31 |
+
Fixed various reported bugs and cleaned up code
|
32 |
*/
|
33 |
|
34 |
if (!class_exists('ThemeMyLogin')) {
|
35 |
class ThemeMyLogin {
|
36 |
|
37 |
var $options = array();
|
|
|
38 |
var $errors = '';
|
39 |
|
40 |
function ThemeMyLogin() {
|
44 |
function __construct() {
|
45 |
register_activation_hook ( __FILE__, array( &$this, 'Activate' ) );
|
46 |
register_deactivation_hook ( __FILE__, array( &$this, 'Deactivate' ) );
|
47 |
+
|
|
|
48 |
add_action('admin_menu', array(&$this, 'AddAdminPage'));
|
49 |
+
add_action('init', array(&$this, 'Init'));
|
50 |
+
add_action('init', array(&$this, 'ReInit'));
|
51 |
|
|
|
|
|
52 |
add_filter('wp_title', array(&$this, 'WPTitle'));
|
53 |
add_filter('the_title', array(&$this, 'TheTitle'));
|
|
|
54 |
add_filter('wp_list_pages_excludes', array(&$this, 'ListPagesExcludes'));
|
55 |
+
add_filter('the_content', array(&$this, 'TheContent'));
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
|
58 |
function Activate() {
|
60 |
delete_option('tml_options');
|
61 |
|
62 |
$theme_my_login = get_page_by_title('Login');
|
63 |
+
|
64 |
+
$insert = array(
|
65 |
'post_title' => 'Login',
|
66 |
'post_status' => 'publish',
|
67 |
'post_type' => 'page',
|
70 |
'comment_status' => 'closed',
|
71 |
'ping_status' => 'closed'
|
72 |
);
|
73 |
+
|
74 |
+
if (!$theme_my_login) {
|
75 |
$theme_my_login = wp_insert_post($insert);
|
76 |
+
$page_id = $theme_my_login;
|
77 |
} else {
|
78 |
+
$insert['ID'] = $theme_my_login->ID;
|
79 |
+
wp_update_post($insert);
|
80 |
+
$page_id = $theme_my_login->ID;
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
|
83 |
+
$this->SetOption('page_id', $page_id);
|
84 |
$this->SaveOptions();
|
85 |
}
|
86 |
|
93 |
|
94 |
# Sets up default options
|
95 |
function InitOptions() {
|
|
|
96 |
$this->options['chk_uninstall'] = 0;
|
97 |
$this->options['page_id'] = '0';
|
98 |
$this->options['login_redirect'] = 'wp-admin/';
|
152 |
function QueryURL() {
|
153 |
global $wp_rewrite;
|
154 |
|
155 |
+
$permalink = get_permalink( $this->GetOption('page_id') );
|
156 |
|
157 |
if ($wp_rewrite->using_permalinks())
|
158 |
+
return $permalink . '?';
|
159 |
else
|
160 |
+
return $permalink . '&';
|
161 |
}
|
162 |
+
|
163 |
+
function ArgURL($permalink = '', $arg = array()) {
|
164 |
+
if (isset($arg)) :
|
165 |
+
$count = 1;
|
166 |
+
foreach($arg as $key => $value) :
|
167 |
+
if (strpos($permalink, '?') !== false) :
|
168 |
+
if ($count == 1)
|
169 |
+
$permalink .= $key . '=' . $value;
|
170 |
+
else
|
171 |
+
$permalink .= '&' . $key . '=' . $value;
|
172 |
+
else :
|
173 |
+
$permalink .= '?' . $key . '=' . $value;
|
174 |
+
endif;
|
175 |
+
$count++;
|
176 |
+
endforeach;
|
177 |
+
else :
|
178 |
+
$permalink = get_permalink( $this->GetOption('page_id') );
|
179 |
+
endif;
|
180 |
+
|
181 |
+
return $permalink;
|
182 |
+
}
|
183 |
+
|
184 |
function Init() {
|
185 |
global $pagenow;
|
186 |
+
|
187 |
$this->LoadOptions();
|
188 |
+
$permalink = $this->QueryURL();
|
189 |
|
190 |
if ( is_user_logged_in() && is_admin() && current_user_can('edit_posts') === false && !isset($_POST['from']) && $_POST['from'] != 'profile' ) {
|
191 |
+
$_GET['profile'] = true;
|
192 |
+
$redirect_to = $this->ArgURL($permalink, $_GET);
|
193 |
+
wp_safe_redirect($redirect_to);
|
|
|
194 |
exit;
|
195 |
}
|
196 |
|
197 |
switch ($pagenow) {
|
198 |
case 'wp-register.php':
|
199 |
case 'wp-login.php':
|
200 |
+
$redirect_to = $this->ArgURL($permalink, $_GET);
|
201 |
+
wp_safe_redirect($redirect_to);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
exit;
|
203 |
break;
|
204 |
}
|
205 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
+
function ReInit() {
|
208 |
+
if ($_GET['profile'] && $_REQUEST['action'] == 'update' && is_user_logged_in())
|
209 |
+
include 'includes/profile-actions.php';
|
210 |
+
else
|
211 |
+
include 'includes/wp-login-actions.php';
|
212 |
+
}
|
213 |
+
|
214 |
+
function TheContent($content) {
|
215 |
+
if (strpos($content, '[theme-my-login]') !== false) {
|
216 |
+
if ($_GET['profile'] && is_user_logged_in())
|
217 |
+
return $this->DisplayProfile();
|
218 |
+
else
|
219 |
+
return $this->DisplayLogin();
|
220 |
+
} else {
|
221 |
+
return $content;
|
222 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
224 |
|
225 |
+
function DisplayProfile() {
|
226 |
+
include 'includes/profile-form.php';
|
227 |
+
}
|
228 |
+
|
229 |
+
function DisplayLogin() {
|
230 |
+
include 'includes/wp-login-forms.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
|
233 |
function WPTitle($title) {
|
234 |
if (is_page($this->GetOption('page_id'))) {
|
235 |
+
if ($_GET['profile'] && is_user_logged_in())
|
236 |
return str_replace('%blogname%', get_option('blogname'), $this->GetOption('profile_title'));
|
237 |
|
238 |
switch ($_GET['action']) {
|
254 |
|
255 |
function TheTitle($title) {
|
256 |
if ($title == 'Login') {
|
257 |
+
if ($_GET['profile'] && is_user_logged_in())
|
258 |
return $this->GetOption('profile_text');
|
259 |
|
260 |
switch ($_GET['action']) {
|
279 |
|
280 |
return $excludes;
|
281 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
}
|
283 |
}
|
284 |
|