Theme My Login - Version 6.0

Version Description

  • Complete code rewrite
  • Users can now log in with e-mail address as well as username
  • Remove option to disable template tag and widget in favor of always being enabled
  • Remove option to rewrite login links in favor of always being rewritten
  • Custom templates can now be defined per action (login, register, etc.)
  • User moderation activation e-mails can be resent on demand
  • Add various new hooks to help with custom integration with other plugins
  • Make custom user links sortable
  • Customize every aspect of every e-mail
  • Add a cool new random tip widget in the TML admin
  • Use WP 3.0 functions (such as 'network_site_url') if available
  • phpDoc everywhere!
Download this release

Release Info

Developer jfarthing84
Plugin Icon 128x128 Theme My Login
Version 6.0
Comparing to
See all releases

Code changes from version 5.1.6 to 6.0

Files changed (68) hide show
  1. admin/class-theme-my-login-admin.php +684 -0
  2. admin/css/colors-classic.css +1 -1
  3. admin/css/colors-fresh.css +1 -1
  4. admin/css/theme-my-login-admin.css +5 -1
  5. admin/includes/admin.php +0 -220
  6. admin/includes/module.php +0 -123
  7. admin/js/theme-my-login-admin.js +14 -0
  8. admin/options-basic.php +0 -34
  9. admin/options-modules.php +0 -14
  10. admin/options-optimization.php +0 -15
  11. admin/options.php +0 -87
  12. includes/class-theme-my-login-debug.php +199 -0
  13. includes/class-theme-my-login-module.php +65 -0
  14. includes/class-theme-my-login-template.php +569 -0
  15. includes/class-theme-my-login-widget.php +125 -0
  16. includes/class-theme-my-login.php +1078 -0
  17. includes/class.php +0 -140
  18. includes/functions.php +0 -108
  19. includes/hook-functions.php +0 -122
  20. includes/login-actions.php +0 -146
  21. includes/login-functions.php +0 -185
  22. includes/pluggable-functions.php +0 -86
  23. includes/template-functions.php +0 -284
  24. includes/widget.php +0 -77
  25. js/jquery.shake.js +18 -0
  26. language/theme-my-login.pot +745 -423
  27. modules/custom-email/admin/admin.php +0 -38
  28. modules/custom-email/admin/custom-email-admin.php +278 -0
  29. modules/custom-email/admin/options-general.php +0 -26
  30. modules/custom-email/admin/options-new-user.php +0 -18
  31. modules/custom-email/admin/options-reset-pass.php +0 -18
  32. modules/custom-email/admin/options-retrieve-pass.php +0 -16
  33. modules/custom-email/custom-email.php +676 -47
  34. modules/custom-email/includes/hook-functions.php +0 -115
  35. modules/custom-passwords/custom-passwords.php +390 -21
  36. modules/custom-passwords/includes/functions.php +0 -58
  37. modules/custom-passwords/includes/hook-functions.php +0 -113
  38. modules/custom-redirection/admin/admin.php +0 -47
  39. modules/custom-redirection/custom-redirection.php +258 -31
  40. modules/custom-redirection/includes/hook-functions.php +0 -85
  41. modules/custom-user-links/admin/admin.php +0 -277
  42. modules/custom-user-links/admin/{admin.css → css/custom-user-links-admin.css} +17 -17
  43. modules/custom-user-links/admin/custom-user-links-admin.php +334 -0
  44. modules/custom-user-links/admin/js/custom-user-links-admin.js +37 -0
  45. modules/custom-user-links/custom-user-links.php +107 -57
  46. modules/security/admin/js/security-admin.js +3 -0
  47. modules/security/admin/security-admin.php +214 -0
  48. modules/security/security.php +443 -0
  49. modules/themed-profiles/includes/template-functions.php +0 -196
  50. modules/themed-profiles/{themed-profiles.css → password-strength.css} +1 -1
  51. modules/themed-profiles/themed-profiles.php +201 -86
  52. modules/user-moderation/admin/admin.php +0 -94
  53. modules/user-moderation/admin/options-user-activation-email.php +0 -16
  54. modules/user-moderation/admin/options-user-approval-email.php +0 -16
  55. modules/user-moderation/admin/options-user-denial-email.php +0 -15
  56. modules/user-moderation/admin/user-moderation-admin.php +491 -0
  57. modules/user-moderation/includes/email-functions.php +0 -64
  58. modules/user-moderation/includes/functions.php +0 -159
  59. modules/user-moderation/includes/hook-functions.php +0 -79
  60. modules/user-moderation/user-moderation.php +778 -66
  61. readme.txt +17 -6
  62. templates/login-form.php +35 -0
  63. templates/lostpassword-form.php +26 -0
  64. templates/profile-form.php +162 -0
  65. templates/register-form.php +31 -0
  66. templates/resetpass-form.php +31 -0
  67. templates/user-panel.php +15 -0
  68. theme-my-login.php +79 -90
admin/class-theme-my-login-admin.php ADDED
@@ -0,0 +1,684 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login class
4
+ *
5
+ * @package Theme My Login
6
+ */
7
+
8
+ if ( !class_exists( 'Theme_My_Login_Admin' ) ) :
9
+ /**
10
+ * Theme My Login Admin class
11
+ *
12
+ * @since 6.0
13
+ */
14
+ class Theme_My_Login_Admin {
15
+ /**
16
+ * Holds reference to global $theme_my_login object
17
+ *
18
+ * @since 6.0
19
+ * @access public
20
+ * @var object
21
+ */
22
+ var $theme_my_login;
23
+
24
+ /**
25
+ * Holds TML menu array
26
+ *
27
+ * @since 6.0
28
+ * @access public
29
+ * @var array
30
+ */
31
+ var $menu;
32
+
33
+ /**
34
+ * Holds TML submenu array
35
+ *
36
+ * @since 6.0
37
+ * @access public
38
+ * @var array
39
+ */
40
+ var $submenu;
41
+
42
+ /**
43
+ * Adds "Theme My Login" to the WordPress "Settings" menu
44
+ *
45
+ * @since 6.0
46
+ * @access public
47
+ */
48
+ function admin_menu() {
49
+ // Create our settings link in the default WP "Settings" menu
50
+ add_options_page(
51
+ __( 'Theme My Login', $this->theme_my_login->textdomain ),
52
+ __( 'Theme My Login', $this->theme_my_login->textdomain ),
53
+ 'manage_options',
54
+ 'theme-my-login',
55
+ array( &$this, 'display_settings_page' )
56
+ );
57
+ }
58
+
59
+ /**
60
+ * Registers TML settings
61
+ *
62
+ * This is used because register_setting() isn't available until the "admin_init" hook.
63
+ *
64
+ * @since 6.0
65
+ * @access public
66
+ */
67
+ function admin_init() {
68
+ // Register our settings in the global "whitelist_settings"
69
+ register_setting( 'theme_my_login', 'theme_my_login', array( &$this, 'save_settings' ) );
70
+
71
+ // Create a hook for modules to use
72
+ do_action_ref_array( 'tml_admin_init', array( &$this ) );
73
+ }
74
+
75
+ /**
76
+ * Outputs HTML for module errors
77
+ *
78
+ * @since 6.0
79
+ * @access public
80
+ */
81
+ function module_errors() {
82
+ $module_errors = $this->theme_my_login->get_option( 'module_errors' );
83
+ // If we have errors to display
84
+ if ( $module_errors ) {
85
+ // Display them
86
+ echo '<div class="error">';
87
+ foreach ( (array) $module_errors as $module => $error ) {
88
+ echo '<p><strong>' . sprintf( __( 'ERROR: The module "%1$s" could not be activated (%2$s).', $this->theme_my_login->textdomain ), $module, $error ) . '</strong></p>';
89
+ }
90
+ echo '</div>';
91
+ // Unset the error array
92
+ $this->theme_my_login->delete_option( 'module_errors' );
93
+ // Update the options in the DB
94
+ $this->theme_my_login->save_options();
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Outputs message to admin to visit settings page after initial plugin activation
100
+ *
101
+ * @since 6.0
102
+ * @access public
103
+ */
104
+ function initial_nag() {
105
+ if ( $this->theme_my_login->get_option( 'initial_nag' ) && current_user_can( 'manage_options' ) ) {
106
+ echo '<div id="tml-initial-nag" class="updated">';
107
+ echo '<p>';
108
+ echo '<strong>' . __( 'NOTICE:', $this->theme_my_login->textdomain ) . '</strong> ';
109
+ printf( __( 'Now that you have activated Theme My Login, please <a href="%s">visit the settings page</a> and familiarize yourself with all of the available options.', $this->theme_my_login->textdomain ), admin_url( 'options-general.php?page=theme-my-login' ) );
110
+ echo '</p><p>';
111
+ printf( '<a href="%s">' . __( 'Take me to the settings page', $this->theme_my_login->textdomain ) . '</a>', admin_url( 'options-general.php?page=theme-my-login' ) );
112
+ echo '</p></div>';
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Outputs a random TML usage tip
118
+ *
119
+ * @since 6.0
120
+ * @access public
121
+ */
122
+ function did_you_know() {
123
+ $tips = apply_filters( 'tml_tips', array(
124
+ __( 'You can now login with your e-mail address or username! Try it out!', $this->theme_my_login->textdomain ),
125
+ __( 'Theme My Login now utilizes a module system. Modules are similar to WordPress plugins. Each module extends the default functionality of Theme My Login. <a rel="tml-options" href="#tml-modules">Click here</a> to get started with modules now.', $this->theme_my_login->textdomain ),
126
+ __( 'Theme My Login now allows custom forms. You can create your own form template(s) by copying the default version(s) from "theme-my-login/templates" to your current theme directory. Try it out!', $this->theme_my_login->textdomain ),
127
+ __( 'You can maintain your stylesheet changes between upgrades. Just simply copy the file "theme-my-login/theme-my-login.css" to your current theme directory and edit it as you please!', $this->theme_my_login->textdomain ),
128
+ __( 'Theme My Login provides a shortcode that you can use within your posts with multiple parameters to customize the form. Visit the <a href="http://www.jfarthing.com/docs/theme-my-login/shortcode" target="_blank">Theme My Login Documentation</a> for usage instructions.', $this->theme_my_login->textdomain ),
129
+ __( 'Theme My Login is <em>FREE</em> but Jeff sure appreciates <a href="http://www.jfarthing.com/donate" target="_blank">donations</a>!', $this->theme_my_login->textdomain ),
130
+ __( 'Jeff is <a href="http://www.jfarthing.com/hire-me" target="_blank">available for hire</a>!', $this->theme_my_login->textdomain )
131
+ ) );
132
+ $key = array_rand( $tips );
133
+ echo '<div id="tml-tips" class="updated">';
134
+ echo '<p><strong>' . __( 'Did You Know?', $this->theme_my_login->textdomain ) . '</strong></p>';
135
+ echo '<p>' . $tips[$key] . '</p>';
136
+ echo '</div>';
137
+ }
138
+
139
+ /**
140
+ * Loads admin styles and scripts
141
+ *
142
+ * @since 6.0
143
+ * @access public
144
+ */
145
+ function load_settings_page() {
146
+ global $user_ID;
147
+
148
+ if ( current_user_can( 'manage_options' ) ) {
149
+ // Remove initial nag now that the settings page has been visited
150
+ if ( $this->theme_my_login->get_option( 'initial_nag' ) )
151
+ $this->theme_my_login->set_option( 'initial_nag', 0, true );
152
+ // Show "Did You Know" box
153
+ add_action( 'admin_notices', array( &$this, 'did_you_know' ) );
154
+ }
155
+
156
+ // Enqueue neccessary scripts and styles
157
+ wp_enqueue_script( 'theme-my-login-admin', plugins_url( '/theme-my-login/admin/js/theme-my-login-admin.js' ), array( 'jquery-ui-tabs', 'jquery-shake' ) );
158
+ wp_enqueue_style( 'theme-my-login-admin', plugins_url( '/theme-my-login/admin/css/theme-my-login-admin.css' ) );
159
+
160
+ // Set the correct admin style according to user setting (Only supports default admin schemes)
161
+ $admin_color = function_exists( 'get_user_meta' ) ? get_user_meta( $user_ID, 'admin_color' ) : get_usermeta( $user_ID, 'admin_color' );
162
+ $stylesheet = ( 'classic' == $admin_color ) ? 'colors-classic.css' : 'colors-fresh.css';
163
+ wp_enqueue_style( 'theme-my-login-colors-fresh', plugins_url( '/theme-my-login/admin/css/' . $stylesheet ) );
164
+ }
165
+
166
+ /**
167
+ * Outputs the main TML admin
168
+ *
169
+ * @since 6.0
170
+ * @access public
171
+ */
172
+ function display_settings_page() {
173
+ // Default menu
174
+ $this->add_menu_page( __('General', $this->theme_my_login->textdomain ), 'tml-options' );
175
+ $this->add_submenu_page( 'tml-options', __( 'Basic', $this->theme_my_login->textdomain ), 'tml-options-basic', array( &$this, 'display_basic_settings' ) );
176
+ $this->add_submenu_page( 'tml-options', __( 'Modules', $this->theme_my_login->textdomain ), 'tml-options-modules', array( &$this, 'display_module_settings' ) );
177
+
178
+ // Allow plugins to add to menu
179
+ do_action_ref_array( 'tml_admin_menu', array( &$this ) );
180
+ ?>
181
+ <div class="wrap">
182
+ <?php screen_icon( 'options-general' ); ?>
183
+ <h2><?php esc_html_e( 'Theme My Login Settings', $this->theme_my_login->textdomain ); ?></h2>
184
+
185
+ <form action="options.php" method="post">
186
+ <?php settings_fields( 'theme_my_login' ); ?>
187
+
188
+ <div style="display:none;">
189
+ <p><input type="submit" name="submit" value="<?php esc_attr_e( 'Save Changes', $this->theme_my_login->textdomain ) ?>" /></p>
190
+ </div>
191
+
192
+ <div id="tml-container">
193
+
194
+ <ul>
195
+ <?php foreach ( $this->menu as $menu ) {
196
+ echo '<li><a href="#' . $menu[1] . '">' . $menu[0] . '</a></li>' . "\n";
197
+ } ?>
198
+ </ul>
199
+
200
+ <?php foreach ( $this->menu as $menu ) {
201
+ echo '<div id="' . $menu[1] . '" class="' . $menu[1] . '">' . "\n";
202
+ if ( isset( $this->submenu[$menu[1]] ) ) {
203
+ echo '<ul>' . "\n";
204
+ foreach ( $this->submenu[$menu[1]] as $submenu ) {
205
+ echo '<li><a href="#' . $submenu[1] . '">' . $submenu[0] . '</a></li>' . "\n";
206
+ }
207
+ echo '</ul>' . "\n";
208
+
209
+ foreach ( $this->submenu[$menu[1]] as $submenu ) {
210
+ echo '<div id="' . $submenu[1] . '" class="' . $menu[1] . '">' . "\n";
211
+ if ( has_action( $submenu[2] ) ) {
212
+ do_action( 'load-' . $submenu[2] );
213
+ call_user_func_array( 'do_action', array_merge( (array) $submenu[2], (array) $submenu[3] ) );
214
+ } else {
215
+ if ( validate_file( $submenu[1] ) )
216
+ return false;
217
+
218
+ if ( ! ( file_exists( WP_PLUGIN_DIR . '/' . $submenu[1] ) && is_file( WP_PLUGIN_DIR . '/' . $submenu[1] ) ) )
219
+ return false;
220
+
221
+ do_action( 'load-' . $submenu[1] );
222
+ include ( WP_PLUGIN_DIR . '/' . $submenu[1] );
223
+ }
224
+ echo '</div>' . "\n";
225
+ }
226
+ } else {
227
+ if ( has_action( $menu[2] ) ) {
228
+ do_action( 'load-' . $menu[2] );
229
+ call_user_func_array( 'do_action', array_merge( (array) $menu[2], (array) $menu[3] ) );
230
+ } else {
231
+ if ( validate_file( $menu[1] ) )
232
+ return false;
233
+
234
+ if ( ! ( file_exists( WP_PLUGIN_DIR . '/' . $menu[1] ) && is_file( WP_PLUGIN_DIR . '/' . $menu[1] ) ) )
235
+ return false;
236
+
237
+ do_action( 'load-' . $menu[1] );
238
+ include ( WP_PLUGIN_DIR . '/' . $menu[1] );
239
+ }
240
+ }
241
+ echo '</div>' . "\n";
242
+ } ?>
243
+
244
+ </div>
245
+
246
+ <p><input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', $this->theme_my_login->textdomain ) ?>" /></p>
247
+ </form>
248
+
249
+ </div>
250
+ <?php
251
+ }
252
+
253
+ /**
254
+ * Outputs HTML for "Basic" settings tab
255
+ *
256
+ * @since 6.0
257
+ * @access public
258
+ */
259
+ function display_basic_settings() {
260
+ // Shorthand reference
261
+ $theme_my_login =& $this->theme_my_login;
262
+ ?>
263
+ <table class="form-table">
264
+ <tr valign="top">
265
+ <th scope="row"><label for="theme_my_login_page_id"><?php _e( 'Page ID', $theme_my_login->textdomain ); ?></label></th>
266
+ <td>
267
+ <input name="theme_my_login[page_id]" type="text" id="theme_my_login_page_id" value="<?php echo (int) $theme_my_login->get_option( 'page_id' ); ?>" class="small-text" />
268
+ <p class="description"><?php _e( 'This should be the ID of the WordPress page that includes the [theme-my-login] shortcode. By default, this page is titled "Login".', $theme_my_login->textdomain ); ?></p>
269
+ </td>
270
+ </tr>
271
+ <tr valign="top">
272
+ <th scope="row"><?php _e( 'Pagelist', $theme_my_login->textdomain ); ?></th>
273
+ <td>
274
+ <input name="theme_my_login[show_page]" type="checkbox" id="theme_my_login_show_page" value="1"<?php checked( 1, $theme_my_login->get_option( 'show_page' ) ); ?> />
275
+ <label for="theme_my_login_show_page"><?php _e( 'Show Page In Pagelist', $theme_my_login->textdomain ); ?></label>
276
+ <p class="description"><?php _e( 'Enable this setting to add login/logout links to the pagelist generated by functions like wp_list_pages() and wp_page_menu().', $theme_my_login->textdomain ); ?></p>
277
+ </td>
278
+ </tr>
279
+ <tr valign="top">
280
+ <th scope="row"><?php _e( 'Stylesheet', $theme_my_login->textdomain ); ?></th>
281
+ <td>
282
+ <input name="theme_my_login[enable_css]" type="checkbox" id="theme_my_login_enable_css" value="1"<?php checked( 1, $theme_my_login->get_option( 'enable_css' ) ); ?> />
283
+ <label for="theme_my_login_enable_css"><?php _e( 'Enable "theme-my-login.css"', $theme_my_login->textdomain ); ?></label>
284
+ <p class="description"><?php _e( 'In order to keep changes between upgrades, you can store your customized "theme-my-login.css" in your current theme directory.', $theme_my_login->textdomain ); ?></p>
285
+ </td>
286
+ </tr>
287
+ <?php do_action( 'tml_settings_basic' ); ?>
288
+ </table>
289
+ <?php
290
+ }
291
+
292
+ /**
293
+ * Outputs HTML for "Module" settings tab
294
+ *
295
+ * @since 6.0
296
+ * @access public
297
+ */
298
+ function display_module_settings() {
299
+ $all_modules = get_plugins( '/' . TML_DIRNAME . '/modules' );
300
+ $active_modules = (array) $this->theme_my_login->get_option( 'active_modules' );
301
+ ?>
302
+ <table class="form-table">
303
+ <tr valign="top">
304
+ <th scope="row"><?php _e( 'Modules', $this->theme_my_login->textdomain ); ?></th>
305
+ <td>
306
+ <?php if ( !empty( $all_modules ) ) : foreach ( $all_modules as $module_file => $module_data ) : ?>
307
+ <input name="theme_my_login_modules[]" type="checkbox" id="theme_my_login_modules_<?php echo $module_file; ?>" value="<?php echo $module_file; ?>"<?php checked( 1, in_array( $module_file, (array) $active_modules ) ); ?> />
308
+ <label for="theme_my_login_modules_<?php echo $module_file; ?>"><?php printf( __( 'Enable %s', $this->theme_my_login->textdomain ), $module_data['Name'] ); ?></label><br />
309
+ <?php if ( $module_data['Description'] ) echo '<p class="description">' . $module_data['Description'] . '</p>'; ?>
310
+ <?php endforeach; else : _e( 'No modules found.', $this->theme_my_login->textdomain ); endif; ?>
311
+ </td>
312
+ </tr>
313
+ <?php do_action( 'tml_settings_modules' ); ?>
314
+ </table>
315
+ <?php
316
+ }
317
+
318
+ /**
319
+ * Sanitizes TML settings
320
+ *
321
+ * This is the callback for register_setting()
322
+ *
323
+ * @since 6.0
324
+ * @access public
325
+ *
326
+ * @param string|array $settings Settings passed in from filter
327
+ * @return string|array Sanitized settings
328
+ */
329
+ function save_settings( $settings ) {
330
+ // Shorthand reference
331
+ $options =& $this->theme_my_login->options;
332
+
333
+ // Sanitize new settings
334
+ $settings['page_id'] = absint( $settings['page_id'] );
335
+ $settings['show_page'] = ( isset( $settings['show_page'] ) && $settings['show_page'] ) ? 1 : 0;
336
+ $settings['enable_css'] = ( isset( $settings['enable_css'] ) && $settings['enable_css'] ) ? 1 : 0;
337
+
338
+ $modules = isset( $_POST['theme_my_login_modules'] ) ? $_POST['theme_my_login_modules'] : array();
339
+
340
+ // If we have modules to activate
341
+ if ( $activate = array_diff( (array) $modules, (array) $options['active_modules'] ) ) {
342
+ // Attempt to activate them
343
+ $result = $this->activate_modules( $activate );
344
+ // Check for WP_Error
345
+ if ( is_wp_error( $result ) ) {
346
+ // Loop through each module in the WP_Error object
347
+ foreach ( $result->get_error_data( 'modules_invalid' ) as $module => $wp_error ) {
348
+ // Store the module and error message to a temporary array which will be passed to 'admin_notices'
349
+ if ( is_wp_error( $wp_error ) )
350
+ $options['module_errors'][$module] = $wp_error->get_error_message();
351
+ }
352
+ }
353
+ }
354
+
355
+ // If we have modules to deactivate
356
+ if ( $deactivate = array_diff( (array) $options['active_modules'], $modules ) ) {
357
+ // Deactive them
358
+ $this->deactivate_modules( $deactivate );
359
+ }
360
+
361
+ // Merge current settings
362
+ $settings = $this->theme_my_login->array_merge_recursive( $options, $settings );
363
+
364
+ // Allow plugins/modules to add/modify settings
365
+ $settings = apply_filters( 'tml_save_settings', $settings );
366
+
367
+ return $settings;
368
+ }
369
+
370
+ /**
371
+ * Activates a TML module
372
+ *
373
+ * @since 6.0
374
+ * @access public
375
+ *
376
+ * @param string $module Module to activate
377
+ * @return null|WP_Error True on success, WP_Error on error
378
+ */
379
+ function activate_module( $module ) {
380
+ $module = plugin_basename( trim( $module ) );
381
+ $valid = $this->validate_module( $module );
382
+ if ( is_wp_error( $valid ) )
383
+ return $valid;
384
+
385
+ $current = (array) $this->theme_my_login->get_option( 'active_modules' );
386
+ if ( !$this->theme_my_login->is_module_active( $module ) ) {
387
+ //ob_start();
388
+ @include ( TML_ABSPATH . '/modules/' . $module );
389
+ $current[] = $module;
390
+ sort( $current );
391
+ do_action( 'tml_activate_module', trim( $module ) );
392
+ $this->theme_my_login->set_option( 'active_modules', $current );
393
+ do_action_ref_array( 'tml_activate_' . trim( $module ), array( &$this->theme_my_login ) );
394
+ do_action( 'tml_activated_module', trim( $module ) );
395
+ //ob_end_clean();
396
+ }
397
+ return null;
398
+ }
399
+
400
+ /**
401
+ * Activates one or more TML module(s)
402
+ *
403
+ * @since 6.0
404
+ * @access public
405
+ *
406
+ * @param string|array $modules Module(s) to activate
407
+ * @return bool|WP_Error True on succes, WP_Error on error
408
+ */
409
+ function activate_modules( $modules ) {
410
+ if ( !is_array( $modules ) )
411
+ $modules = array( $modules );
412
+
413
+ $errors = array();
414
+ foreach ( (array) $modules as $module ) {
415
+ $result = $this->activate_module( $module );
416
+ if ( is_wp_error( $result ) )
417
+ $errors[$module] = $result;
418
+ }
419
+
420
+ if ( !empty( $errors ) )
421
+ return new WP_Error( 'modules_invalid', __( 'One of the modules is invalid.', $this->theme_my_login->textdomain ), $errors );
422
+
423
+ return true;
424
+ }
425
+
426
+ /**
427
+ * Deactivates one or more TML module(s)
428
+ *
429
+ * @since 6.0
430
+ * @access public
431
+ *
432
+ * @param string|array $plugins Module(s) to deactivate
433
+ * @param bool $silent If true, prevents calling deactivate hook
434
+ */
435
+ function deactivate_modules( $modules, $silent = false ) {
436
+ $current = (array) $this->theme_my_login->get_option( 'active_modules' );
437
+
438
+ if ( !is_array( $modules ) )
439
+ $modules = array( $modules );
440
+
441
+ foreach ( $modules as $module ) {
442
+ $module = plugin_basename( $module );
443
+ if( !$this->theme_my_login->is_module_active( $module ) )
444
+ continue;
445
+
446
+ if ( !$silent )
447
+ do_action( 'tml_deactivate_module', trim( $module ) );
448
+
449
+ $key = array_search( $module, (array) $current );
450
+
451
+ if ( false !== $key )
452
+ array_splice( $current, $key, 1 );
453
+
454
+ if ( !$silent ) {
455
+ do_action_ref_array( 'tml_deactivate_' . trim( $module ), array( &$this->theme_my_login ) );
456
+ do_action( 'tml_deactivated_module', trim( $module ) );
457
+ }
458
+ }
459
+
460
+ $this->theme_my_login->set_option( 'active_modules', $current, true );
461
+ }
462
+
463
+ /**
464
+ * Validates a TML module
465
+ *
466
+ * @since 6.0
467
+ * @access public
468
+ *
469
+ * @param string $module Module path
470
+ * @return int|WP_Error 0 on success, WP_Error on failure.
471
+ */
472
+ function validate_module( $module ) {
473
+ if ( validate_file( $module ) )
474
+ return new WP_Error( 'module_invalid', __( 'Invalid module path.', $this->theme_my_login->textdomain ) );
475
+ if ( !file_exists( TML_ABSPATH. '/modules/' . $module ) )
476
+ return new WP_Error( 'module_not_found', __( 'Module file does not exist.', $this->theme_my_login->textdomain ) );
477
+
478
+ $installed_modules = get_plugins( '/' . TML_DIRNAME . '/modules' );
479
+ if ( !isset( $installed_modules[$module] ) )
480
+ return new WP_Error( 'no_module_header', __( 'The module does not have a valid header.', $this->theme_my_login->textdomain ) );
481
+ return 0;
482
+ }
483
+
484
+ /**
485
+ * Adds a tab in the TML admin menu
486
+ *
487
+ * @since 6.0
488
+ * @access public
489
+ *
490
+ * @param string $menu_title The text to be used for the menu
491
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
492
+ * @param callback $function The function to be called to output the content for this page.
493
+ * @param array $function_args Arguments to pass in to callback function
494
+ * @param int $position The position in the menu order this one should appear
495
+ */
496
+ function add_menu_page( $menu_title, $menu_slug, $function = '', $function_args = array(), $position = NULL ) {
497
+ $menu_slug = plugin_basename( $menu_slug );
498
+
499
+ $hookname = get_plugin_page_hookname( $menu_slug, '' );
500
+ $hookname = preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $hookname );
501
+ if ( !empty( $function ) && !empty( $hookname ) )
502
+ add_action( $hookname, $function );
503
+
504
+ $new_menu = array( $menu_title, $menu_slug, $hookname, $function_args );
505
+
506
+ if ( NULL === $position )
507
+ $this->menu[] = $new_menu;
508
+ else
509
+ $this->menu[$position] = $new_menu;
510
+
511
+ return $hookname;
512
+ }
513
+
514
+ /**
515
+ * Adds a subtab to a tab in the TML admin menu
516
+ *
517
+ * @since 6.0
518
+ * @access public
519
+ *
520
+ * @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
521
+ * @param string $menu_title The text to be used for the menu
522
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
523
+ * @param callback $function The function to be called to output the content for this page.
524
+ * @param array $function_args Arguments to pass in to callback function
525
+ */
526
+ function add_submenu_page( $parent_slug, $menu_title, $menu_slug, $function = '', $function_args = array() ) {
527
+ $menu_slug = plugin_basename( $menu_slug );
528
+ $parent = plugin_basename( $parent_slug );
529
+
530
+ $count = ( isset( $this->submenu[$parent_slug] ) && is_array( $this->submenu[$parent_slug] ) ) ? count( $this->submenu[$parent_slug] ) + 1 : 1;
531
+
532
+ $hookname = get_plugin_page_hookname( $parent_slug . '-' . $count, '' );
533
+ $hookname = preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $hookname );
534
+ if ( !empty( $function ) && !empty( $hookname ) )
535
+ add_action( $hookname, $function, 10, count( $function_args ) );
536
+
537
+ $this->submenu[$parent_slug][] = array( $menu_title, $menu_slug, $hookname, $function_args );
538
+
539
+ return $hookname;
540
+ }
541
+
542
+ /**
543
+ * Installs TML
544
+ *
545
+ * @since 6.0
546
+ * @access public
547
+ */
548
+ function install() {
549
+ // Shorthand reference
550
+ $theme_my_login =& $this->theme_my_login;
551
+
552
+ // Declare page_id to avoid notices
553
+ $page_id = 0;
554
+
555
+ // Current version
556
+ $version = $theme_my_login->get_option( 'version' );
557
+
558
+ // 4.4 upgrade
559
+ if ( version_compare( $version, '4.4', '<' ) ) {
560
+ remove_role( 'denied' );
561
+ }
562
+ // 6.0 upgrade
563
+ if ( version_compare( $version, '6.0', '<' ) ) {
564
+
565
+ }
566
+
567
+ // Get existing page ID
568
+ $page_id = $theme_my_login->get_option( 'page_id' );
569
+
570
+ // Maybe create login page?
571
+ if ( ( $page_id && $page = get_page( $page_id ) ) || $page = get_page_by_title( 'Login' ) ) {
572
+ $page_id = $page->ID;
573
+ // Make sure the page is not in the trash
574
+ if ( 'trash' == $page->post_status )
575
+ wp_untrash_post( $page_id );
576
+ } else {
577
+ $insert = array(
578
+ 'post_title' => 'Login',
579
+ 'post_status' => 'publish',
580
+ 'post_type' => 'page',
581
+ 'post_content' => '[theme-my-login]',
582
+ 'comment_status' => 'closed',
583
+ 'ping_status' => 'closed'
584
+ );
585
+ $page_id = wp_insert_post( $insert );
586
+ }
587
+
588
+ $plugin_data = get_plugin_data( TML_ABSPATH . '/theme-my-login.php' );
589
+ $theme_my_login->set_option( 'version', $plugin_data['Version'] );
590
+ $theme_my_login->set_option( 'page_id', (int) $page_id );
591
+ return $theme_my_login->save_options();
592
+ }
593
+
594
+ /**
595
+ * Uninstalls TML
596
+ *
597
+ * @since 6.0
598
+ * @access public
599
+ */
600
+ function uninstall() {
601
+ // Shorthand reference
602
+ $theme_my_login =& $this->theme_my_login;
603
+
604
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
605
+
606
+ // Run module uninstall hooks
607
+ $modules = get_plugins( '/' . TML_DIRNAME . '/modules' );
608
+ foreach ( array_keys( $modules ) as $module ) {
609
+ $module = plugin_basename( trim( $module ) );
610
+
611
+ $valid = $this->validate_module( $module );
612
+ if ( is_wp_error( $valid ) )
613
+ continue;
614
+
615
+ @include ( TML_ABSPATH . '/modules/' . $module );
616
+ do_action( 'uninstall_' . trim( $module ) );
617
+ }
618
+
619
+ // Delete the page
620
+ wp_delete_post( $theme_my_login->get_option( 'page_id' ) );
621
+
622
+ // Delete options
623
+ delete_option( $theme_my_login->options_key );
624
+ delete_option( 'widget_' . $theme_my_login->options_key );
625
+ }
626
+
627
+ /**
628
+ * PHP4 style constructor
629
+ *
630
+ * @since 6.0
631
+ * @access public
632
+ */
633
+ function Theme_My_Login_Admin() {
634
+ $this->__construct();
635
+ }
636
+
637
+ /**
638
+ * PHP5 style constructor
639
+ *
640
+ * @since 6.0
641
+ * @access public
642
+ */
643
+ function __construct() {
644
+ $this->theme_my_login =& $GLOBALS['theme_my_login'];
645
+
646
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
647
+ add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
648
+ add_action( 'admin_notices', array( &$this, 'module_errors' ) );
649
+ add_action( 'admin_notices', array( &$this, 'initial_nag' ) );
650
+ add_action( 'load-settings_page_theme-my-login', array( &$this, 'load_settings_page' ) );
651
+ }
652
+ }
653
+
654
+ /**
655
+ * Install method wrapper
656
+ *
657
+ * @see Theme_My_Login_Admin::install()
658
+ * @since 6.0
659
+ * @access public
660
+ */
661
+ function theme_my_login_install() {
662
+ $theme_my_login_admin =& $GLOBALS['theme_my_login_admin'];
663
+ if ( is_object( $theme_my_login_admin ) )
664
+ $theme_my_login_admin->install();
665
+ }
666
+ register_activation_hook( TML_ABSPATH . '/theme-my-login.php', 'theme_my_login_install' );
667
+
668
+ /**
669
+ * Uninstall method wrapper
670
+ *
671
+ * @see Theme_My_Login_Admin::uninstall()
672
+ * @since 6.0
673
+ * @access public
674
+ */
675
+ function theme_my_login_uninstall() {
676
+ $theme_my_login_admin =& $GLOBALS['theme_my_login_admin'];
677
+ if ( is_object( $theme_my_login_admin ) )
678
+ $theme_my_login_admin->uninstall();
679
+ }
680
+ register_uninstall_hook( TML_ABSPATH . '/theme-my-login.php', 'theme_my_login_uninstall' );
681
+
682
+ endif; // Class exists
683
+
684
+ ?>
admin/css/colors-classic.css CHANGED
@@ -15,7 +15,7 @@
15
  .ui-tabs .ui-tabs-nav li, .ui-tabs .ui-tabs-panel .ui-tabs-nav li { position: relative; float: left; margin: 0; padding: 0; }
16
  .ui-tabs .ui-tabs-nav li a, .ui-tabs .ui-tabs-panel .ui-tabs-nav li a { float: left; text-decoration: none; padding: .4em 1em; }
17
  .ui-tabs .ui-tabs-panel, .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 0 0 1em 0; display: block; border: none; }
18
- .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 0; }
19
  .ui-tabs .ui-tabs-hide, .ui-tabs .ui-tabs-panel .ui-tabs-hide { display: none !important; }
20
 
21
  .ui-widget-content {
15
  .ui-tabs .ui-tabs-nav li, .ui-tabs .ui-tabs-panel .ui-tabs-nav li { position: relative; float: left; margin: 0; padding: 0; }
16
  .ui-tabs .ui-tabs-nav li a, .ui-tabs .ui-tabs-panel .ui-tabs-nav li a { float: left; text-decoration: none; padding: .4em 1em; }
17
  .ui-tabs .ui-tabs-panel, .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 0 0 1em 0; display: block; border: none; }
18
+ .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 10px; }
19
  .ui-tabs .ui-tabs-hide, .ui-tabs .ui-tabs-panel .ui-tabs-hide { display: none !important; }
20
 
21
  .ui-widget-content {
admin/css/colors-fresh.css CHANGED
@@ -15,7 +15,7 @@
15
  .ui-tabs .ui-tabs-nav li, .ui-tabs .ui-tabs-panel .ui-tabs-nav li { position: relative; float: left; margin: 0; padding: 0; }
16
  .ui-tabs .ui-tabs-nav li a, .ui-tabs .ui-tabs-panel .ui-tabs-nav li a { float: left; text-decoration: none; padding: .4em 1em; }
17
  .ui-tabs .ui-tabs-panel, .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 0 0 1em 0; display: block; border: none; }
18
- .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 0; }
19
  .ui-tabs .ui-tabs-hide, .ui-tabs .ui-tabs-panel .ui-tabs-hide { display: none !important; }
20
 
21
  .ui-widget-content {
15
  .ui-tabs .ui-tabs-nav li, .ui-tabs .ui-tabs-panel .ui-tabs-nav li { position: relative; float: left; margin: 0; padding: 0; }
16
  .ui-tabs .ui-tabs-nav li a, .ui-tabs .ui-tabs-panel .ui-tabs-nav li a { float: left; text-decoration: none; padding: .4em 1em; }
17
  .ui-tabs .ui-tabs-panel, .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 0 0 1em 0; display: block; border: none; }
18
+ .ui-tabs .ui-tabs-panel .ui-tabs-panel { padding: 10px; }
19
  .ui-tabs .ui-tabs-hide, .ui-tabs .ui-tabs-panel .ui-tabs-hide { display: none !important; }
20
 
21
  .ui-widget-content {
admin/css/theme-my-login-admin.css CHANGED
@@ -2,9 +2,13 @@
2
 
3
  #tml-container table th { width: 125px; }
4
 
 
 
5
  #tml-container table input.regular-text { width: 25em; }
6
  #tml-container table input.extended-text { width: 40em; }
7
  #tml-container table input.full-text { width: 99%; }
8
  #tml-container table input.small-text { width: 50px; }
9
 
10
- #tml-container div div { font-size: 1em; }
 
 
2
 
3
  #tml-container table th { width: 125px; }
4
 
5
+ #tml-container table h3 { margin: 5px 0; font: italic normal normal 18px/23px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; }
6
+
7
  #tml-container table input.regular-text { width: 25em; }
8
  #tml-container table input.extended-text { width: 40em; }
9
  #tml-container table input.full-text { width: 99%; }
10
  #tml-container table input.small-text { width: 50px; }
11
 
12
+ #tml-container div div { font-size: 1em; }
13
+
14
+ #tml-tips { background:#f0f8ff; border:1px solid #addae6; }
admin/includes/admin.php DELETED
@@ -1,220 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_add_new_user_notification_override_notice() {
4
- add_action('admin_notices', 'wdbj_tml_new_user_notification_override_notice');
5
- }
6
-
7
- function wdbj_tml_add_password_change_notification_override_notice() {
8
- add_action('admin_notices', 'wdbj_tml_password_change_notification_override_notice');
9
- }
10
-
11
- function wdbj_tml_new_user_notification_override_notice() {
12
- $message = __('<strong>WARNING</strong>: The function <em>wp_new_user_notification</em> has already been overridden by another plugin. ', 'theme-my-login');
13
- $message .= __('Some features of <em>Theme My Login</em> may not function properly.', 'theme-my-login');
14
- echo '<div class="error"><p>' . $message . '</p></div>';
15
- }
16
-
17
- function wdbj_tml_password_change_notification_override_notice() {
18
- $message = __('<strong>WARNING</strong>: The function <em>wp_password_change_notification</em> has already been overridden by another plugin. ', 'theme-my-login');
19
- $message .= __('Some features of <em>Theme My Login</em> may not function properly.', 'theme-my-login');
20
- echo '<div class="error"><p>' . $message . '</p></div>';
21
- }
22
-
23
- function wdbj_tml_admin_menu() {
24
- // Create our settings link in the default WP "Settings" menu
25
- add_options_page(__('Theme My Login', 'theme-my-login'), __('Theme My Login', 'theme-my-login'), 'manage_options', 'theme-my-login/admin/options.php');
26
- }
27
-
28
- function wdbj_tml_admin_init() {
29
- // Register our settings in the global 'whitelist_settings'
30
- register_setting('theme_my_login', 'theme_my_login', 'wdbj_tml_save_settings');
31
-
32
- // Hook into the loading of our dedicated settings page
33
- add_action('load-theme-my-login/admin/options.php', 'wdbj_tml_load_settings_page');
34
-
35
- // Create a hook for modules to use
36
- do_action('tml_admin_init');
37
- }
38
-
39
- function wdbj_tml_load_settings_page() {
40
- global $theme_my_login, $user_ID;
41
-
42
- do_action('tml_settings_page');
43
-
44
- // Enqueue neccessary scripts and styles
45
- wp_enqueue_script('theme-my-login-admin', plugins_url('/theme-my-login/admin/js/theme-my-login-admin.js'));
46
- wp_enqueue_script('jquery-ui-tabs');
47
- wp_enqueue_style('theme-my-login-admin', plugins_url('/theme-my-login/admin/css/theme-my-login-admin.css'));
48
-
49
- // Set the correct admin style according to user setting (Only supports default admin schemes)
50
- if ( function_exists('get_user_meta') )
51
- $admin_color = get_user_meta($user_ID, 'admin_color');
52
- else
53
- $admin_color = get_usermeta($user_ID, 'admin_color');
54
-
55
- if ( 'classic' == $admin_color )
56
- wp_enqueue_style('theme-my-login-colors-classic', plugins_url('/theme-my-login/admin/css/colors-classic.css'));
57
- else
58
- wp_enqueue_style('theme-my-login-colors-fresh', plugins_url('/theme-my-login/admin/css/colors-fresh.css'));
59
-
60
- // Handle activation/deactivation of modules
61
- if ( isset($theme_my_login->options['activate_modules']) || isset($theme_my_login->options['deactivate_modules']) ) {
62
- // If we have modules to activate
63
- if ( isset($theme_my_login->options['activate_modules']) ) {
64
- // Attempt to activate them
65
- $result = wdbj_tml_activate_modules($theme_my_login->options['activate_modules']);
66
- // Check for WP_Error
67
- if ( is_wp_error($result) ) {
68
- // Loop through each module in the WP_Error object
69
- foreach ( $result->get_error_data('plugins_invalid') as $module => $wp_error ) {
70
- // Store the module and error message to a temporary array which will be passed to 'admin_notices'
71
- if ( is_wp_error($wp_error) )
72
- $theme_my_login->options['module_errors'][$module] = $wp_error->get_error_message();
73
- }
74
- }
75
- // Unset the 'activate_modules' array
76
- unset($theme_my_login->options['activate_modules']);
77
- }
78
-
79
- // If we have modules to deactivate
80
- if ( isset($theme_my_login->options['deactivate_modules']) ) {
81
- // Deactive them
82
- wdbj_tml_deactivate_modules($theme_my_login->options['deactivate_modules']);
83
- // Unset the 'deactivate_modules' array
84
- unset($theme_my_login->options['deactivate_modules']);
85
- }
86
-
87
- // Update the options in the DB
88
- wdbj_tml_save_options();
89
-
90
- // Redirect so that the newly activated modules can be included and newly unactivated modules can not be included
91
- $redirect = isset($theme_my_login->options['module_errors']) ? admin_url('options-general.php?page=theme-my-login/admin/options.php') : add_query_arg('updated', 'true');
92
- wp_redirect($redirect);
93
- exit();
94
- }
95
-
96
- // If we have errors to display, hook into 'admin_notices' to display them
97
- if ( isset($theme_my_login->options['module_errors']) && $theme_my_login->options['module_errors'] )
98
- add_action('admin_notices', 'wdbj_tml_module_error_notice');
99
- }
100
-
101
- function wdbj_tml_module_error_notice() {
102
- global $theme_my_login;
103
-
104
- // If we have errors to display
105
- if ( isset($theme_my_login->options['module_errors']) ) {
106
- // Display them
107
- echo '<div class="error">';
108
- foreach ( $theme_my_login->options['module_errors'] as $module => $error ) {
109
- echo '<p><strong>' . sprintf(__('ERROR: The module "$module" could not be activated (%s).', 'theme-my-login'), $error) . '</strong></p>';
110
- }
111
- echo '</div>';
112
- // Unset the error array
113
- unset($theme_my_login->options['module_errors']);
114
- // Update the options in the DB
115
- wdbj_tml_save_options();
116
- }
117
- }
118
-
119
- function wdbj_tml_save_settings($settings) {
120
- global $theme_my_login;
121
-
122
- // Assign current settings
123
- $current = $theme_my_login->options;
124
-
125
- // Sanitize new settings
126
- $settings['page_id'] = absint($settings['page_id']);
127
- $settings['show_page'] = ( isset($settings['show_page']) && $settings['show_page'] ) ? 1 : 0;
128
- $settings['rewrite_links'] = ( isset($settings['rewrite_links']) && $settings['rewrite_links'] ) ? 1 : 0;
129
- $settings['enable_css'] = ( isset($settings['enable_css']) && $settings['enable_css'] ) ? 1 : 0;
130
- $settings['enable_template_tag'] = ( isset($settings['enable_template_tag']) && $settings['enable_template_tag'] ) ? 1 : 0;
131
- $settings['enable_widget'] = ( isset($settings['enable_widget']) && $settings['enable_widget'] ) ? 1 : 0;
132
- if ( isset($_POST['tml_editing_modules']) ) {
133
- $settings['modules'] = isset($settings['modules']) ? (array) $settings['modules'] : array();
134
-
135
- // Set modules to be activated
136
- if ( $activate = array_diff($settings['modules'], (array) $current['active_modules']) )
137
- $settings['activate_modules'] = $activate;
138
-
139
- // Set modules to be deactivated
140
- if ( $deactivate = array_diff((array) $current['active_modules'], $settings['modules']) )
141
- $settings['deactivate_modules'] = $deactivate;
142
-
143
- // Unset 'modules' as it is only relevent here
144
- unset($settings['modules']);
145
- }
146
-
147
- // Merge current settings
148
- $settings = wp_parse_args($settings, $current);
149
-
150
- // Allow plugins/modules to add/modify settings
151
- $settings = apply_filters('tml_save_settings', $settings);
152
-
153
- return $settings;
154
- }
155
-
156
- function wdbj_tml_install() {
157
- global $theme_my_login;
158
-
159
- $previous_install = get_option('theme_my_login');
160
- if ( $previous_install ) {
161
- if ( version_compare($previous_install['version'], '4.4', '<') )
162
- remove_role('denied');
163
- }
164
-
165
- if ( $page = get_page_by_title('Login') ) {
166
- $page_id = $page->ID;
167
- if ( 'trash' == $page->post_status )
168
- wp_untrash_post($page_id);
169
- if ( strpos($page->post_content, '[theme-my-login-page]') === false ) {
170
- $page->post_content = preg_replace("/(\[theme-my-login .*\])/", '[theme-my-login-page]', $page->post_content);
171
- wp_update_post($page);
172
- }
173
- } else {
174
- $insert = array(
175
- 'post_title' => 'Login',
176
- 'post_status' => 'publish',
177
- 'post_type' => 'page',
178
- 'post_content' => '[theme-my-login-page]',
179
- 'comment_status' => 'closed',
180
- 'ping_status' => 'closed'
181
- );
182
- $page_id = wp_insert_post($insert);
183
- }
184
-
185
- $options = wp_parse_args($previous_install, Theme_My_Login::default_options());
186
-
187
- $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/theme-my-login/theme-my-login.php');
188
- $options['version'] = $plugin_data['Version'];
189
- $options['page_id'] = $page_id;
190
- return update_option('theme_my_login', $options);
191
- }
192
-
193
- function wdbj_tml_uninstall() {
194
- $options = get_option('theme_my_login');
195
-
196
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
197
-
198
- // Run module uninstall hooks
199
- $modules = get_plugins('/theme-my-login/modules');
200
- foreach ( array_keys($modules) as $module ) {
201
- $module = plugin_basename(trim($module));
202
-
203
- $valid = wdbj_tml_validate_module($module);
204
- if ( is_wp_error($valid) )
205
- continue;
206
-
207
- @include (TML_MODULE_DIR . '/' . $module);
208
- do_action('uninstall_' . trim($module));
209
- }
210
-
211
- // Delete the page
212
- if ( get_page($options['page_id']) )
213
- wp_delete_post($options['page_id']);
214
-
215
- // Delete options
216
- delete_option('theme_my_login');
217
- delete_option('widget_theme-my-login');
218
- }
219
-
220
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/includes/module.php DELETED
@@ -1,123 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_activate_module($module) {
4
- $module = plugin_basename(trim($module));
5
- $valid = wdbj_tml_validate_module($module);
6
- if ( is_wp_error($valid) )
7
- return $valid;
8
-
9
- $current = (array) wdbj_tml_get_option('active_modules');
10
- if ( ! wdbj_tml_is_module_active($module) ) {
11
- //ob_start();
12
- @include (TML_MODULE_DIR . '/' . $module);
13
- $current[] = $module;
14
- sort($current);
15
- do_action('tml_activate_module', trim($module));
16
- // We will not use this since our function modifies the global plugin object instead of saving to the DB
17
- //update_option('theme_my_login', $current);
18
- wdbj_tml_update_option($current, 'active_modules');
19
- do_action('activate_' . trim($module));
20
- do_action('tml_activated_module', trim($module));
21
- //ob_end_clean();
22
- }
23
-
24
- return null;
25
- }
26
-
27
- function wdbj_tml_deactivate_modules($modules, $silent= false) {
28
- $current = (array) wdbj_tml_get_option('active_modules');
29
-
30
- if ( ! is_array($modules) )
31
- $modules = array($modules);
32
-
33
- foreach ( $modules as $module ) {
34
- $module = plugin_basename($module);
35
- if( ! wdbj_tml_is_module_active($module) )
36
- continue;
37
- if ( ! $silent )
38
- do_action('tml_deactivate_module', trim($module));
39
-
40
- $key = array_search( $module, (array) $current );
41
-
42
- if ( false !== $key )
43
- array_splice( $current, $key, 1 );
44
-
45
- if ( ! $silent ) {
46
- do_action( 'deactivate_' . trim( $module ) );
47
- do_action( 'tml_deactivated_module', trim( $module ) );
48
- }
49
- }
50
-
51
- // We will not use this since the function modifies our global plugin object instead of saving to the DB
52
- //update_option('theme_my_login', $current);
53
- wdbj_tml_update_option($current, 'active_modules');
54
- }
55
-
56
- function wdbj_tml_activate_modules($modules) {
57
- if ( !is_array($modules) )
58
- $modules = array($modules);
59
-
60
- $errors = array();
61
- foreach ( (array) $modules as $module ) {
62
- $result = wdbj_tml_activate_module($module);
63
- if ( is_wp_error($result) )
64
- $errors[$module] = $result;
65
- }
66
-
67
- if ( !empty($errors) )
68
- return new WP_Error('plugins_invalid', __('One of the plugins is invalid.', 'theme-my-login'), $errors);
69
-
70
- return true;
71
- }
72
-
73
- function wdbj_tml_validate_module($module) {
74
- if ( validate_file($module) )
75
- return new WP_Error('plugin_invalid', __('Invalid plugin path.', 'theme-my-login'));
76
- if ( ! file_exists(TML_MODULE_DIR . '/' . $module) )
77
- return new WP_Error('plugin_not_found', __('Plugin file does not exist.', 'theme-my-login'));
78
-
79
- $installed_modules = get_plugins('/theme-my-login/modules');
80
- if ( ! isset($installed_modules[$module]) )
81
- return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.', 'theme-my-login'));
82
- return 0;
83
- }
84
-
85
- function wdbj_tml_add_menu_page($menu_title, $file, $function = '', $function_args = array(), $position = NULL) {
86
- global $wdbj_tml_admin_menu;
87
-
88
- $file = plugin_basename($file);
89
-
90
- $hookname = get_plugin_page_hookname($file, '');
91
- $hookname = preg_replace('|[^a-zA-Z0-9_:.]|', '-', $hookname);
92
- if ( !empty($function) && !empty($hookname) )
93
- add_action($hookname, $function);
94
-
95
- $new_menu = array($menu_title, $file, $hookname, $function_args);
96
-
97
- if ( NULL === $position )
98
- $wdbj_tml_admin_menu[] = $new_menu;
99
- else
100
- $wdbj_tml_admin_menu[$position] = $new_menu;
101
-
102
- return $hookname;
103
- }
104
-
105
- function wdbj_tml_add_submenu_page($parent, $menu_title, $file, $function = array(), $function_args = '') {
106
- global $wdbj_tml_admin_submenu;
107
-
108
- $file = plugin_basename($file);
109
- $parent = plugin_basename($parent);
110
-
111
- $count = ( isset($wdbj_tml_admin_submenu[$parent]) && is_array($wdbj_tml_admin_submenu[$parent]) ) ? count($wdbj_tml_admin_submenu[$parent]) + 1 : 1;
112
-
113
- $hookname = get_plugin_page_hookname($parent . '-' . $count, '');
114
- $hookname = preg_replace('|[^a-zA-Z0-9_:.]|', '-', $hookname);
115
- if ( !empty($function) && !empty($hookname) )
116
- add_action($hookname, $function);
117
-
118
- $wdbj_tml_admin_submenu[$parent][] = array($menu_title, $file, $hookname, $function_args);
119
-
120
- return $hookname;
121
- }
122
-
123
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/theme-my-login-admin.js CHANGED
@@ -13,4 +13,18 @@ jQuery(document).ready(function($){
13
  },
14
  selected: getUserSetting( 'tml1', 0 )
15
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  });
13
  },
14
  selected: getUserSetting( 'tml1', 0 )
15
  });
16
+
17
+ $("#tml-tips").shake( 500 );
18
+ $("#tml-tips a").click(function() {
19
+ var menu = $(this).attr( 'rel' );
20
+ var submenu = $(this).attr( 'href' );
21
+ var target = $(this).attr( 'target' );
22
+ if ( '_blank' == target )
23
+ return true;
24
+ if ( '' != menu )
25
+ $("#tml-container").tabs( 'select', '#' . menu );
26
+ if ( '' != submenu )
27
+ $("#tml-container div").tabs( 'select', submenu );
28
+ return false;
29
+ });
30
  });
admin/options-basic.php DELETED
@@ -1,34 +0,0 @@
1
- <table class="form-table">
2
- <tr valign="top">
3
- <th scope="row"><label for="theme_my_login_page_id"><?php _e('Page ID', 'theme-my-login'); ?></label></th>
4
- <td>
5
- <input name="theme_my_login[page_id]" type="text" id="theme_my_login_page_id" value="<?php echo (int) $theme_my_login->options['page_id']; ?>" class="small-text" />
6
- <p class="description"><?php _e('This should be the ID of the WordPress page that includes the [theme-my-login-page] shortcode. By default, this page is titled "Login".', 'theme-my-login'); ?></p>
7
- </td>
8
- </tr>
9
- <tr valign="top">
10
- <th scope="row"><?php _e('Pagelist', 'theme-my-login'); ?></th>
11
- <td>
12
- <input name="theme_my_login[show_page]" type="checkbox" id="theme_my_login_show_page" value="1"<?php checked(1, $theme_my_login->options['show_page']); ?> />
13
- <label for="theme_my_login_show_page"><?php _e('Show Page In Pagelist', 'theme-my-login'); ?></label>
14
- <p class="description"><?php _e('Enable this setting to add login/logout links to the pagelist generated by functions like wp_list_pages() and wp_page_menu().', 'theme-my-login'); ?></p>
15
- </td>
16
- </tr>
17
- <tr valign="top">
18
- <th scope="row"><?php _e('Links', 'theme-my-login'); ?></th>
19
- <td>
20
- <input name="theme_my_login[rewrite_links]" type="checkbox" id="theme_my_login_rewrite_links" value="1"<?php checked(1, $theme_my_login->options['rewrite_links']); ?> />
21
- <label for="theme_my_login_rewrite_links"><?php _e('Rewrite Login Links', 'theme-my-login'); ?></label>
22
- <p class="description"><?php _e('Enable this setting to rewrite links generated by functions like wp_loginout() and wp_register().', 'theme-my-login'); ?></p>
23
- </td>
24
- </tr>
25
- <tr valign="top">
26
- <th scope="row"><?php _e('Stylesheet', 'theme-my-login'); ?></th>
27
- <td>
28
- <input name="theme_my_login[enable_css]" type="checkbox" id="theme_my_login_enable_css" value="1"<?php checked(1, $theme_my_login->options['enable_css']); ?> />
29
- <label for="theme_my_login_enable_css"><?php _e('Enable "theme-my-login.css"', 'theme-my-login'); ?></label>
30
- <p class="description"><?php _e('In order to keep changes between upgrades, you can store your customized "theme-my-login.css" in your current theme directory.', 'theme-my-login'); ?></p>
31
- </td>
32
- </tr>
33
- <?php do_action('tml_settings_basic', $theme_my_login->options); ?>
34
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/options-modules.php DELETED
@@ -1,14 +0,0 @@
1
- <table class="form-table">
2
- <tr valign="top">
3
- <th scope="row"><?php _e('Modules', 'theme-my-login'); ?></th>
4
- <td>
5
- <input type="hidden" name="tml_editing_modules" value="1" />
6
- <?php $modules = get_plugins('/theme-my-login/modules'); if ( !empty($modules) ) : foreach ( $modules as $module_file => $module_data ) : ?>
7
- <input name="theme_my_login[modules][]" type="checkbox" id="theme_my_login_modules_<?php echo $module_file; ?>" value="<?php echo $module_file; ?>"<?php checked(1, in_array($module_file, (array) $theme_my_login->options['active_modules'])); ?> />
8
- <label for="theme_my_login_modules_<?php echo $module_file; ?>"><?php printf(__('Enable %s', 'theme-my-login'), $module_data['Name']); ?></label><br />
9
- <?php if ( $module_data['Description'] ) echo '<p class="description">' . $module_data['Description'] . '</p>'; ?>
10
- <?php endforeach; else : _e('No modules found.', 'theme-my-login'); endif; ?>
11
- </td>
12
- </tr>
13
- <?php do_action('tml_settings_modules', $theme_my_login->options); ?>
14
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/options-optimization.php DELETED
@@ -1,15 +0,0 @@
1
- <table class="form-table">
2
- <tr valign="top">
3
- <th scope="row"><?php _e('Optimization', 'theme-my-login'); ?></th>
4
- <td>
5
- <input name="theme_my_login[enable_template_tag]" type="checkbox" id="theme_my_login_enable_template_tag" value="1"<?php checked('1', $theme_my_login->options['enable_template_tag']); ?> />
6
- <label for="theme_my_login_enable_template_tag"><?php _e('Enable Template Tag', 'theme-my-login'); ?></label><br />
7
- <p class="description"><?php _e('Enable this setting if you wish to use the theme_my_login() template tag. Otherwise, leave it disabled for optimization purposes.', 'theme-my-login'); ?></p>
8
-
9
- <input name="theme_my_login[enable_widget]" type="checkbox" id="theme_my_login_enable_widget" value="1"<?php checked('1', $theme_my_login->options['enable_widget']); ?> />
10
- <label for="theme_my_login_enable_widget"><?php _e('Enable Widget', 'theme-my-login'); ?></label><br />
11
- <p class="description"><?php _e('Enable this setting if you wish to use the "Theme My Login" widget. Otherwise, leave it disabled for optimization purposes.', 'theme-my-login'); ?></p>
12
- </td>
13
- </tr>
14
- <?php do_action('tml_settings_optimization', $theme_my_login->options); ?>
15
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/options.php DELETED
@@ -1,87 +0,0 @@
1
- <?php
2
-
3
- // Default menu
4
- wdbj_tml_add_menu_page(__('General', 'theme-my-login'), 'theme-my-login/admin/options.php');
5
- wdbj_tml_add_submenu_page('theme-my-login/admin/options.php', __('Basic', 'theme-my-login'), 'theme-my-login/admin/options-basic.php');
6
- wdbj_tml_add_submenu_page('theme-my-login/admin/options.php', __('Modules', 'theme-my-login'), 'theme-my-login/admin/options-modules.php');
7
- wdbj_tml_add_submenu_page('theme-my-login/admin/options.php', __('Optimization', 'theme-my-login'), 'theme-my-login/admin/options-optimization.php');
8
-
9
- // Allow plugins to add to menu
10
- do_action('tml_admin_menu');
11
-
12
- ?>
13
-
14
- <div class="updated" style="background:#f0f8ff; border:1px solid #addae6">
15
- <p><?php _e('If you like this plugin, please help keep it up to date by <a href="http://www.jfarthing.com/donate">donating through PayPal</a>!', 'theme-my-login'); ?></p>
16
- </div>
17
-
18
- <div class="wrap">
19
- <?php screen_icon('options-general'); ?>
20
- <h2><?php esc_html_e('Theme My Login Settings', 'theme-my-login'); ?></h2>
21
-
22
- <form action="options.php" method="post">
23
- <?php settings_fields('theme_my_login'); ?>
24
-
25
- <div style="display:none;">
26
- <p><input type="submit" name="submit" value="<?php esc_attr_e('Save Changes', 'theme-my-login') ?>" /></p>
27
- </div>
28
-
29
- <div id="tml-container">
30
-
31
- <ul>
32
- <?php foreach ( $wdbj_tml_admin_menu as $tml_menu ) {
33
- echo '<li><a href="#' . $tml_menu[2] . '">' . $tml_menu[0] . '</a></li>' . "\n";
34
- }?>
35
- </ul>
36
-
37
-
38
- <?php foreach ( $wdbj_tml_admin_menu as $tml_menu ) {
39
- echo '<div id="' . $tml_menu[2] . '">' . "\n";
40
- if ( isset($wdbj_tml_admin_submenu[$tml_menu[1]]) ) {
41
- echo '<ul>' . "\n";
42
- foreach ( $wdbj_tml_admin_submenu[$tml_menu[1]] as $tml_submenu ) {
43
- echo '<li><a href="#' . $tml_submenu[2] . '">' . $tml_submenu[0] . '</a></li>' . "\n";
44
- }
45
- echo '</ul>' . "\n";
46
-
47
- foreach ( $wdbj_tml_admin_submenu[$tml_menu[1]] as $tml_submenu ) {
48
- echo '<div id="' . $tml_submenu[2] . '">' . "\n";
49
- if ( has_action($tml_submenu[2]) ) {
50
- do_action('load-' . $tml_submenu[2]);
51
- call_user_func_array('do_action', array_merge((array) $tml_submenu[2], (array) $tml_submenu[3]));
52
- } else {
53
- if ( validate_file($tml_submenu[1]) )
54
- return false;
55
-
56
- if ( ! ( file_exists(WP_PLUGIN_DIR . '/' . $tml_submenu[1]) && is_file(WP_PLUGIN_DIR . '/' . $tml_submenu[1]) ) )
57
- return false;
58
-
59
- do_action('load-' . $tml_submenu[1]);
60
- include (WP_PLUGIN_DIR . '/' . $tml_submenu[1]);
61
- }
62
- echo '</div>' . "\n";
63
- }
64
- } else {
65
- if ( has_action($tml_menu[2]) ) {
66
- do_action('load-' . $tml_menu[2]);
67
- call_user_func_array('do_action', array_merge((array) $tml_menu[2], (array) $tml_menu[3]));
68
- } else {
69
- if ( validate_file($tml_menu[1]) )
70
- return false;
71
-
72
- if ( ! ( file_exists(WP_PLUGIN_DIR . '/' . $tml_menu[1]) && is_file(WP_PLUGIN_DIR . '/' . $tml_menu[1]) ) )
73
- return false;
74
-
75
- do_action('load-' . $tml_menu[1]);
76
- include (WP_PLUGIN_DIR . '/' . $tml_menu[1]);
77
- }
78
- }
79
- echo '</div>' . "\n";
80
- } ?>
81
-
82
- </div>
83
-
84
- <p><input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes', 'theme-my-login') ?>" /></p>
85
- </form>
86
-
87
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-theme-my-login-debug.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login debug class
4
+ *
5
+ * @package Theme My Login
6
+ * @subpackage Debug
7
+ */
8
+
9
+ if ( !class_exists( 'Theme_My_Login_Debug' ) ) :
10
+ /**
11
+ * Theme My Login Debug class
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Debug {
16
+ /**
17
+ * Holds memory usage at construct
18
+ *
19
+ * @since 6.0
20
+ * @access public
21
+ * @var int
22
+ */
23
+ var $initial_memory = 0;
24
+
25
+ /**
26
+ * Holds memory usage at each major hook
27
+ *
28
+ * @since 6.0
29
+ * @access public
30
+ * @var array
31
+ */
32
+ var $hook_usage = array();
33
+
34
+ /**
35
+ * Holds array of which hooks to record
36
+ *
37
+ * @since 6.0
38
+ * @access public
39
+ * @var array
40
+ */
41
+ var $core_hooks = array();
42
+
43
+ /**
44
+ * Records current memory usage at specific hooks
45
+ *
46
+ * @since 6.0
47
+ * @access public
48
+ */
49
+ function record_memory_usage() {
50
+ $current_filter = current_filter();
51
+ if ( in_array( $current_filter, $this->core_hooks ) || substr( $current_filter, 0, 4 ) == 'tml_' )
52
+ $this->core_hook_usage[$current_filter] = memory_get_usage();
53
+ }
54
+
55
+ /**
56
+ * Outputs memory usage
57
+ *
58
+ * @since 6.0
59
+ * @access public
60
+ */
61
+ function dump_memory_usage() {
62
+ echo '<h2>Memory Usage Summary</h2>' . "\n";
63
+ echo '<ul>' . "\n";
64
+ echo '<li><strong>Initial Usage</strong>: ' . $this->num_bytes_to_string( $this->initial_memory ) . '</li>' . "\n";
65
+ echo '<li><strong>Peak Usage</strong>: ' . $this->num_bytes_to_string( memory_get_peak_usage() ) . '</li>' . "\n";
66
+ echo '<li><strong>End Usage</strong>: ' . $this->num_bytes_to_string( memory_get_usage() ) . '</li>' . "\n";
67
+ echo '</ul>';
68
+
69
+ echo '<h2>Memory Usage by Hook</h2>' . "\n";
70
+ echo '<ul>' . "\n";
71
+ foreach ( $this->core_hook_usage as $hook => $memory ) {
72
+ echo '<li><strong>' . $hook . '</strong>: ' . $this->num_bytes_to_string( $memory ) . '</li>' . "\n";
73
+ }
74
+ echo '</ul>' . "\n";
75
+ }
76
+
77
+ /**
78
+ * Converts a shorthand string representation (ie. 3.2M) to a numerical byte value
79
+ *
80
+ * @since 6.0
81
+ * @access public
82
+ *
83
+ * @param string $value Shorthand notation
84
+ * @return int Value in bytes
85
+ */
86
+ function string_to_num_bytes( $value ) {
87
+ if ( is_numeric( $value ) ) {
88
+ return $value;
89
+ } else {
90
+ $qty = substr( $value, 0, strlen( $value ) - 1 );
91
+ $unit = strtolower( substr( $value, -1 ) );
92
+ switch ( $unit ) {
93
+ case 'k':
94
+ $qty *= 1024;
95
+ break;
96
+ case 'm':
97
+ $qty *= pow( 1024, 2 );
98
+ break;
99
+ case 'g':
100
+ $qty *= pow( 1024, 3 );
101
+ break;
102
+ default:
103
+ $qty = intval( $qty );
104
+ }
105
+ return $qty;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Converts a numerical byte value to a shorthand string representation (ie. 3.2M)
111
+ *
112
+ * @since 6.0
113
+ * @access public
114
+ *
115
+ * @param int $value Number of bytes
116
+ * @param string $unit Can either be K for kilobytes, M for megabytes or G for gigabytes
117
+ * @return string Shorthand notation from the given value and unit
118
+ */
119
+ function num_bytes_to_string( $value, $unit = 'm' ) {
120
+ if ( !is_numeric( $value ) )
121
+ $value = $this->string_to_num_bytes( $value );
122
+ switch ( $unit ) {
123
+ case 'k':
124
+ $value /= 1024;
125
+ break;
126
+ case 'm':
127
+ $value /= pow( 1024, 2 );
128
+ break;
129
+ case 'g':
130
+ $value /= pow( 1024, 3);
131
+ break;
132
+ }
133
+ $value = number_format( $value, 2 );
134
+ $unit = strtoupper( $unit );
135
+ return $value . $unit;
136
+ }
137
+
138
+ /**
139
+ * PHP4 style constructor
140
+ *
141
+ * @since 6.0
142
+ * @access public
143
+ */
144
+ function Theme_My_Login_Debug() {
145
+ $this->__construct();
146
+ }
147
+
148
+ /**
149
+ * PHP5 style constructor
150
+ *
151
+ * @since 6.0
152
+ * @access public
153
+ */
154
+ function __construct() {
155
+ $this->initial_memory = memory_get_usage();
156
+ $this->core_hooks = array(
157
+ 'muplugins_loaded',
158
+ 'load_textdomain',
159
+ 'update_option',
160
+ 'plugins_loaded',
161
+ 'load_textdomain',
162
+ 'sanitize_comment_cookies',
163
+ 'setup_theme',
164
+ 'load_textdomain',
165
+ 'auth_cookie_malformed',
166
+ 'set_current_user',
167
+ 'init',
168
+ 'widgets_init',
169
+ 'load_textdomain',
170
+ 'parse_request',
171
+ 'send_headers',
172
+ 'pre_get_posts',
173
+ 'posts_selection',
174
+ 'wp',
175
+ 'template_redirect',
176
+ 'get_header',
177
+ 'wp_head',
178
+ 'wp_enqueue_scripts',
179
+ 'wp_print_styles',
180
+ 'wp_print_scripts',
181
+ 'loop_start',
182
+ 'the_post',
183
+ 'loop_end',
184
+ 'get_footer',
185
+ 'wp_footer',
186
+ 'wp_print_footer_scripts'
187
+ );
188
+ add_action( 'plugins_loaded', array( &$this, 'record_memory_usage' ) );
189
+ add_action( 'all', array( &$this, 'record_memory_usage' ) );
190
+ add_action( 'wp_footer', array( &$this, 'dump_memory_usage' ) );
191
+ }
192
+ }
193
+
194
+ if ( function_exists( 'memory_get_usage' ) )
195
+ $Theme_My_Login_Debug =& new Theme_My_Login_Debug();
196
+
197
+ endif; // Class exists
198
+
199
+ ?>
includes/class-theme-my-login-module.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login Module class
4
+ *
5
+ * @package Theme My Login
6
+ * @subpackage Modules
7
+ */
8
+
9
+ if ( !class_exists( 'Theme_My_Login_Module' ) ) :
10
+ /*
11
+ * Theme My Login Module class
12
+ *
13
+ * This class is the base class to be extended by a module.
14
+ *
15
+ * @since 6.0
16
+ */
17
+ class Theme_My_Login_Module {
18
+ /**
19
+ * Holds reference to global $theme_my_login object
20
+ *
21
+ * @since 6.0
22
+ * @access public
23
+ * @var object
24
+ */
25
+ var $theme_my_login;
26
+
27
+ /**
28
+ * Called when object is constructed
29
+ *
30
+ * @since 6.0
31
+ * @access public
32
+ */
33
+ function load() {
34
+ // This function should be overridden by the module extend class
35
+ }
36
+
37
+ /**
38
+ * PHP4 style constructor
39
+ *
40
+ * @since 6.0
41
+ * @access public
42
+ *
43
+ * @param object $theme_my_login Reference to global $theme_my_login object
44
+ */
45
+ function Theme_My_Login_Module() {
46
+ $this->__construct();
47
+ }
48
+
49
+ /**
50
+ * PHP5 style constructor
51
+ *
52
+ * @since 6.0
53
+ * @access public
54
+ *
55
+ * @param object $theme_my_login Reference to global $theme_my_login object
56
+ */
57
+ function __construct() {
58
+ $this->theme_my_login =& $GLOBALS['theme_my_login'];
59
+ $this->load();
60
+ }
61
+ }
62
+
63
+ endif; // Class exists
64
+
65
+ ?>
includes/class-theme-my-login-template.php ADDED
@@ -0,0 +1,569 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login template class
4
+ *
5
+ * @package Theme My Login
6
+ * @subpackage Template
7
+ */
8
+
9
+ if ( !class_exists( 'Theme_My_Login_Template' ) ) :
10
+ /*
11
+ * Theme My Login template class
12
+ *
13
+ * This class contains properties and methods common to displaying output.
14
+ *
15
+ * @since 6.0
16
+ */
17
+ class Theme_My_Login_Template {
18
+ /**
19
+ * Holds reference to global $theme_my_login object
20
+ *
21
+ * @since 6.0
22
+ * @access public
23
+ * @var object
24
+ */
25
+ var $theme_my_login;
26
+
27
+ /**
28
+ * Holds this instance
29
+ *
30
+ * @since 6.0
31
+ * @access public
32
+ * @var int
33
+ */
34
+ var $instance;
35
+
36
+ /**
37
+ * Holds this instance action
38
+ *
39
+ * @since 6.0
40
+ * @access public
41
+ * @var string
42
+ */
43
+ var $action;
44
+
45
+ /**
46
+ * Set if current instance is active
47
+ *
48
+ * @since 6.0
49
+ * @access public
50
+ * @var bool
51
+ */
52
+ var $is_active = false;
53
+
54
+ /**
55
+ * Holds instance specific template options
56
+ *
57
+ * @since 6.0
58
+ * @access public
59
+ * @var array
60
+ */
61
+ var $options = array();
62
+
63
+ /**
64
+ * Holds instance specific template errors
65
+ *
66
+ * @since 6.0
67
+ * @access public
68
+ * @var object
69
+ */
70
+ var $errors;
71
+
72
+ /**
73
+ * Displays output according to current action
74
+ *
75
+ * @since 6.0
76
+ * @access public
77
+ *
78
+ * @return string HTML output
79
+ */
80
+ function display( $action = '' ) {
81
+ if ( empty( $action ) )
82
+ $action = $this->action;
83
+
84
+ ob_start();
85
+ echo $this->options['before_widget'];
86
+ if ( $this->options['show_title'] )
87
+ echo $this->options['before_title'] . $this->get_title( $action ) . $this->options['after_title'] . "\n";
88
+ // Is there a specified template?
89
+ if ( has_action( 'tml_display_' . $action ) ) {
90
+ do_action_ref_array( 'tml_display_' . $action, array( &$this ) );
91
+ } else {
92
+ $template = array();
93
+ switch ( $action ) {
94
+ case 'lostpassword':
95
+ case 'retrievepassword':
96
+ if ( !empty( $this->options['lostpassword_template'] ) )
97
+ $template[] = $this->options['lostpassword_template'];
98
+ $template[] = 'lostpassword-form.php';
99
+ break;
100
+ case 'register':
101
+ if ( !empty( $this->options['register_template'] ) )
102
+ $template[] = $this->options['register_template'];
103
+ $template[] = 'register-form.php';
104
+ break;
105
+ case 'login':
106
+ default :
107
+ if ( is_user_logged_in() ) {
108
+ if ( !empty( $this->options['user_template'] ) )
109
+ $template[] = $this->options['user_template'];
110
+ $template[] = 'user-panel.php';
111
+ } else {
112
+ if ( !empty( $this->options['login_template'] ) )
113
+ $template[] = $this->options['login_template'];
114
+ $template[] = 'login-form.php';
115
+ }
116
+ }
117
+ $this->get_template( $template );
118
+ }
119
+ echo $this->options['after_widget'] . "\n";
120
+ $output = ob_get_contents();
121
+ ob_end_clean();
122
+ return apply_filters( 'tml_display', $output, $this->options );
123
+ }
124
+
125
+ /**
126
+ * Returns action title
127
+ *
128
+ * @since 6.0
129
+ * @access public
130
+ *
131
+ * @param string $action The action to retrieve. Defaults to current action.
132
+ * @return string Title of $action
133
+ */
134
+ function get_title( $action = '' ) {
135
+ if ( empty( $action ) )
136
+ $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login';
137
+
138
+ if ( is_user_logged_in() ) {
139
+ $user = wp_get_current_user();
140
+ $title = sprintf( __( 'Welcome, %s', 'theme-my-login' ), $user->display_name );
141
+ } else {
142
+ switch ( $action ) {
143
+ case 'register':
144
+ $title = __( 'Register', 'theme-my-login' );
145
+ break;
146
+ case 'lostpassword':
147
+ case 'retrievepassword':
148
+ case 'resetpass':
149
+ case 'rp':
150
+ $title = __( 'Lost Password', 'theme-my-login' );
151
+ break;
152
+ case 'login':
153
+ default:
154
+ $title = __( 'Log In', 'theme-my-login' );
155
+ }
156
+ }
157
+ return apply_filters( 'tml_title', $title, $action );
158
+ }
159
+
160
+ /**
161
+ * Outputs action title
162
+ *
163
+ * @since 6.0
164
+ * @access public
165
+ *
166
+ * @param string $action The action to retieve. Defaults to current action.
167
+ */
168
+ function the_title( $action = '' ) {
169
+ echo $this->get_title( $action );
170
+ }
171
+
172
+ /**
173
+ * Returns plugin errors
174
+ *
175
+ * @since 6.0
176
+ * @access public
177
+ */
178
+ function get_errors() {
179
+ global $error;
180
+
181
+ $wp_error =& $this->theme_my_login->errors;
182
+
183
+ if ( empty( $wp_error ) )
184
+ $wp_error = new WP_Error();
185
+
186
+ // Incase a plugin uses $error rather than the $errors object
187
+ if ( !empty( $error ) ) {
188
+ $wp_error->add('error', $error);
189
+ unset($error);
190
+ }
191
+
192
+ $output = '';
193
+ if ( $this->is_active ) {
194
+ if ( $wp_error->get_error_code() ) {
195
+ $errors = '';
196
+ $messages = '';
197
+ foreach ( $wp_error->get_error_codes() as $code ) {
198
+ $severity = $wp_error->get_error_data( $code );
199
+ foreach ( $wp_error->get_error_messages( $code ) as $error ) {
200
+ if ( 'message' == $severity )
201
+ $messages .= ' ' . $error . "<br />\n";
202
+ else
203
+ $errors .= ' ' . $error . "<br />\n";
204
+ }
205
+ }
206
+ if ( !empty( $errors ) )
207
+ $output .= '<p class="error">' . apply_filters( 'login_errors', $errors ) . "</p>\n";
208
+ if ( !empty( $messages ) )
209
+ $output .= '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
210
+ }
211
+ }
212
+ return $output;
213
+ }
214
+
215
+ /**
216
+ * Prints plugin errors
217
+ *
218
+ * @since 6.0
219
+ * @access public
220
+ */
221
+ function the_errors() {
222
+ echo $this->get_errors();
223
+ }
224
+
225
+ /**
226
+ * Returns requested action URL
227
+ *
228
+ * @since 6.0
229
+ * @access public
230
+ *
231
+ * @param string $action Action to retrieve
232
+ * @param int|string $instance Optionally add an instance to the URL
233
+ * @return string The requested action URL
234
+ */
235
+ function get_action_url( $action = 'login', $instance = '' ) {
236
+ if ( empty( $instance ) )
237
+ $instance = $this->instance;
238
+
239
+ if ( isset( $this->options[$action . '_widget'] ) && !$this->options[$action . '_widget'] ) {
240
+ $url = $this->theme_my_login->get_login_page_link( 'action=' . $action );
241
+ } else {
242
+ if ( empty( $instance ) )
243
+ $url = $this->theme_my_login->get_current_url( array( 'action' => $action ) );
244
+ else
245
+ $url = $this->theme_my_login->get_current_url( array( 'action' => $action, 'instance' => $instance ) );
246
+ }
247
+
248
+ // Respect FORCE_SSL_LOGIN
249
+ if ( 'login' == $action && force_ssl_login() )
250
+ $url = preg_replace( '|^http://|', 'https://', $url );
251
+
252
+ return apply_filters( 'tml_action_url', $url, $action );
253
+ }
254
+
255
+ /**
256
+ * Outputs requested action URL
257
+ *
258
+ * @since 6.0
259
+ * @access public
260
+ *
261
+ * @param string $action Action to retrieve
262
+ * @param int|string $instance Optionally add an instance to the URL
263
+ */
264
+ function the_action_url( $action = 'login', $instance = '' ) {
265
+ echo esc_url( $this->get_action_url( $action, $instance ) );
266
+ }
267
+
268
+ /**
269
+ * Returns the action links
270
+ *
271
+ * @since 6.0
272
+ * @access public
273
+ *
274
+ * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
275
+ */
276
+ function get_action_links( $args = '' ) {
277
+ $args = wp_parse_args( $args, array( 'login' => true, 'register' => true, 'lostpassword' => true ) );
278
+ $action_links = array();
279
+ if ( $args['login'] && $this->options['show_log_link'] )
280
+ $action_links[] = array( 'title' => $this->get_title( 'login' ), 'url' => $this->get_action_url( 'login' ) );
281
+ if ( $args['register'] && $this->options['show_reg_link'] && get_option( 'users_can_register' ) )
282
+ $action_links[] = array( 'title' => $this->get_title( 'register' ), 'url' => $this->get_action_url( 'register' ) );
283
+ if ( $args['lostpassword'] && $this->options['show_pass_link'] )
284
+ $action_links[] = array( 'title' => $this->get_title( 'lostpassword' ), 'url' => $this->get_action_url( 'lostpassword' ) );
285
+ return apply_filters( 'tml_action_links', $action_links );
286
+ }
287
+
288
+ /**
289
+ * Outputs the action links
290
+ *
291
+ * @since 6.0
292
+ * @access public
293
+ *
294
+ * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
295
+ */
296
+ function the_action_links( $args = '' ) {
297
+ if ( $action_links = $this->get_action_links( $args ) ) {
298
+ echo '<ul class="tml-action-links">' . "\n";
299
+ foreach ( (array) $action_links as $link ) {
300
+ echo '<li><a href="' . esc_url( $link['url'] ) . '">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
301
+ }
302
+ echo '</ul>' . "\n";
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Returns logged-in user links
308
+ *
309
+ * @since 6.0
310
+ * @access public
311
+ *
312
+ * @return array Logged-in user links
313
+ */
314
+ function get_user_links() {
315
+ $user_links = array(
316
+ array( 'title' => __( 'Dashboard', 'theme-my-login' ), 'url' => admin_url() ),
317
+ array( 'title' => __( 'Profile', 'theme-my-login' ), 'url' => admin_url( 'profile.php' ) )
318
+ );
319
+ return apply_filters( 'tml_user_links', $user_links );
320
+ }
321
+
322
+ /**
323
+ * Outputs logged-in user links
324
+ *
325
+ * @since 6.0
326
+ * @access public
327
+ */
328
+ function the_user_links() {
329
+ if ( $user_links = $this->get_user_links() ) {
330
+ echo '<ul class="tml-user-links">';
331
+ foreach ( (array) $user_links as $link ) {
332
+ echo '<li><a href="' . esc_url( $link['url'] ) . '">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
333
+ }
334
+ echo '<li><a href="' . wp_logout_url() . '">' . __( 'Log out', $this->theme_my_login->textdomain ) . '</a></li>' . "\n";
335
+ echo '</ul>';
336
+ }
337
+ }
338
+
339
+ /**
340
+ * Displays user avatar
341
+ *
342
+ * @since 6.0
343
+ * @access public
344
+ */
345
+ function the_user_avatar( $size = 50 ) {
346
+ global $current_user;
347
+ if ( empty( $size ) )
348
+ $size = $this->options['gravatar_size'];
349
+ echo get_avatar( $current_user->ID, $size );
350
+ }
351
+
352
+ /**
353
+ * Returns template message for requested action
354
+ *
355
+ * @since 6.0
356
+ * @access public
357
+ *
358
+ * @param string $action Action to retrieve
359
+ * @return string The requested template message
360
+ */
361
+ function get_action_template_message( $action = '' ) {
362
+ if ( 'register' == $action )
363
+ $message = __( 'Register For This Site', 'theme-my-login' );
364
+ elseif ( 'lostpassword' == $action )
365
+ $message = __( 'Please enter your username or e-mail address. You will receive a new password via e-mail.', 'theme-my-login' );
366
+ else
367
+ $message = '';
368
+ return apply_filters( 'tml_action_template_message', $message, $action );
369
+ }
370
+
371
+ /**
372
+ * Outputs template message for requested action
373
+ *
374
+ * @since 6.0
375
+ * @access public
376
+ *
377
+ * @param string $action Action to retrieve
378
+ * @param string $before_message Text/HTML to add before the message
379
+ * @param string $after_message Text/HTML to add after the message
380
+ */
381
+ function the_action_template_message( $action = 'login', $before_message = '<p class="message">', $after_message = '</p>' ) {
382
+ if ( $message = $this->get_action_template_message( $action ) )
383
+ echo $before_message . $message . $after_message;
384
+ }
385
+
386
+ /**
387
+ * Locates specified template
388
+ *
389
+ * @since 6.0
390
+ * @access public
391
+ *
392
+ * @param string|array $template_names The template(s) to locate
393
+ * @param bool $load If true, the template will be included if found
394
+ * @return string|bool Template path if found, false if not
395
+ */
396
+ function get_template( $template_names, $load = true ) {
397
+ // Shothand reference to this
398
+ $template =& $this;
399
+ // Shorthand reference to $theme_my_login
400
+ $theme_my_login =& $this->theme_my_login;
401
+ // Easy access to current user
402
+ $current_user = wp_get_current_user();
403
+
404
+ if ( !is_array( $template_names ) )
405
+ $template_names = array( $template_names );
406
+
407
+ if ( !$template_path = locate_template( $template_names ) ) {
408
+ foreach ( $template_names as $template_name ) {
409
+ if ( file_exists( TML_ABSPATH . '/templates/' . $template_name ) ) {
410
+ $template_path = TML_ABSPATH . '/templates/' . $template_name;
411
+ break;
412
+ }
413
+ }
414
+ }
415
+
416
+ $template_path = apply_filters( 'tml_template', $template_path );
417
+
418
+ if ( $load && $template_path ) {
419
+ include( $template_path );
420
+ }
421
+
422
+ return $template_path;
423
+ }
424
+
425
+ /**
426
+ * Returns the proper redirect URL according to action
427
+ *
428
+ * @since 6.0
429
+ * @access public
430
+ *
431
+ * @param string $action The action
432
+ * @return string The redirect URL
433
+ */
434
+ function get_redirect_url( $action = '' ) {
435
+ if ( empty( $action ) )
436
+ $action = $this->action;
437
+
438
+ $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
439
+
440
+ switch ( $action ) {
441
+ case 'lostpassword' :
442
+ case 'retrievepassword' :
443
+ $url = apply_filters( 'lostpassword_redirect', !empty( $redirect_to ) ? $redirect_to : $this->theme_my_login->get_current_url( 'checkemail=confirm' ) );
444
+ break;
445
+ case 'register' :
446
+ $url = apply_filters( 'registration_redirect', !empty( $redirect_to ) ? $redirect_to : $this->theme_my_login->get_current_url( 'checkemail=registered' ) );
447
+ break;
448
+ case 'login' :
449
+ default :
450
+ $url = apply_filters( 'login_redirect', !empty( $redirect_to ) ? $redirect_to : admin_url(), $redirect_to, null );
451
+ }
452
+ return apply_filters( 'tml_redirect_url', $url, $action );
453
+ }
454
+
455
+ /**
456
+ * Outputs redirect URL
457
+ *
458
+ * @since 6.0
459
+ * @access public
460
+ */
461
+ function the_redirect_url() {
462
+ echo esc_url( $this->get_redirect_url() );
463
+ }
464
+
465
+ /**
466
+ * Outputs current template instance ID
467
+ *
468
+ * @since 6.0
469
+ * @access public
470
+ */
471
+ function the_instance() {
472
+ echo esc_attr( $this->instance );
473
+ }
474
+
475
+ /**
476
+ * Returns requested $value
477
+ *
478
+ * @since 6.0
479
+ * @access public
480
+ *
481
+ * @param string $value The value to retrieve
482
+ * @return string|bool The value if it exists, false if not
483
+ */
484
+ function get_posted_value( $value ) {
485
+ if ( $this->is_active && isset( $_REQUEST[$value] ) )
486
+ return stripslashes( $_REQUEST[$value] );
487
+ return false;
488
+ }
489
+
490
+ /**
491
+ * Outputs requested value
492
+ *
493
+ * @since 6.0
494
+ * @access public
495
+ *
496
+ * @param string $value The value to retrieve
497
+ */
498
+ function the_posted_value( $value ) {
499
+ echo esc_attr( $this->get_posted_value( $value ) );
500
+ }
501
+
502
+ /**
503
+ * Merges default template options with instance template options
504
+ *
505
+ * @since 6.0
506
+ * @access public
507
+ *
508
+ * @param array $options Instance options
509
+ */
510
+ function load_options( $options = array() ) {
511
+ $this->options = shortcode_atts( array(
512
+ 'instance' => '',
513
+ 'default_action' => 'login',
514
+ 'login_template' => '',
515
+ 'register_template' => '',
516
+ 'lostpassword_template' => '',
517
+ 'user_template' => '',
518
+ 'show_title' => true,
519
+ 'show_log_link' => true,
520
+ 'show_reg_link' => true,
521
+ 'show_pass_link' => true,
522
+ 'register_widget' => false,
523
+ 'lostpassword_widget' => false,
524
+ 'logged_in_widget' => true,
525
+ 'show_gravatar' => true,
526
+ 'gravatar_size' => 50,
527
+ 'before_widget' => '<li>',
528
+ 'after_widget' => '</li>',
529
+ 'before_title' => '<h2>',
530
+ 'after_title' => '</h2>'
531
+ ), (array) $options );
532
+ }
533
+
534
+ /**
535
+ * PHP4 style constructor
536
+ *
537
+ * @since 6.0
538
+ * @access public
539
+ *
540
+ * @param array $options Instance options
541
+ */
542
+ function Theme_My_Login_Template( $options = '' ) {
543
+ $this->__construct( $options );
544
+ }
545
+
546
+ /**
547
+ * PHP5 style constructor
548
+ *
549
+ * @since 6.0
550
+ * @access public
551
+ *
552
+ * @param array $options Instance options
553
+ */
554
+ function __construct( $options = '' ) {
555
+ $this->theme_my_login =& $GLOBALS['theme_my_login'];
556
+ $this->load_options( $options );
557
+
558
+ $this->action = isset( $this->options['default_action'] ) ? $this->options['default_action'] : 'login';
559
+ $this->instance = $this->options['instance'];
560
+ if ( $this->theme_my_login->request_instance == $this->instance ) {
561
+ $this->is_active = true;
562
+ $this->action = $this->theme_my_login->request_action;
563
+ }
564
+ }
565
+ }
566
+
567
+ endif; // Class exists
568
+
569
+ ?>
includes/class-theme-my-login-widget.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login widget class
4
+ *
5
+ * @package Theme My Login
6
+ * @subpackage Widget
7
+ */
8
+
9
+ if ( !class_exists( 'Theme_My_Login_Widget' ) ) :
10
+ /*
11
+ * Theme My Login widget class
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Widget extends WP_Widget {
16
+ /**
17
+ * PHP4 style constructor
18
+ *
19
+ * @since 6.0
20
+ * @access public
21
+ */
22
+ function Theme_My_Login_Widget() {
23
+ $widget_options = array( 'classname' => 'widget_theme_my_login', 'description' => __( 'A login form for your blog.', 'theme-my-login' ) );
24
+ $this->WP_Widget( 'theme-my-login', __( 'Theme My Login', 'theme-my-login' ), $widget_options );
25
+ }
26
+
27
+ /**
28
+ * Displays the widget
29
+ *
30
+ * @since 6.0
31
+ * @access public
32
+ *
33
+ * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
34
+ * @param array $instance The settings for the particular instance of the widget
35
+ */
36
+ function widget( $args, $instance ) {
37
+ global $theme_my_login;
38
+ if ( is_user_logged_in() && !$instance['logged_in_widget'] )
39
+ return;
40
+ $args = array_merge( $args, $instance );
41
+ echo $theme_my_login->shortcode( $args );
42
+ }
43
+
44
+ /**
45
+ * Updates the widget
46
+ *
47
+ * @since 6.0
48
+ * @access public
49
+ */
50
+ function update( $new_instance, $old_instance ) {
51
+ $instance = $old_instance;
52
+ $instance['default_action'] = in_array( $new_instance['default_action'], array( 'login', 'register', 'lostpassword' ) ) ? $new_instance['default_action'] : 'login';
53
+ $instance['logged_in_widget'] = empty( $new_instance['logged_in_widget'] ) ? false : true;
54
+ $instance['show_title'] = empty( $new_instance['show_title'] ) ? false : true;
55
+ $instance['show_log_link'] = empty( $new_instance['show_log_link'] ) ? false: true;
56
+ $instance['show_reg_link'] = empty( $new_instance['show_reg_link'] ) ? false: true;
57
+ $instance['show_pass_link'] = empty( $new_instance['show_pass_link'] ) ? false: true;
58
+ $instance['show_gravatar'] = empty( $new_instance['show_gravatar'] ) ? false : true;
59
+ $instance['gravatar_size'] = absint( $new_instance['gravatar_size'] );
60
+ $instance['register_widget'] = empty( $new_instance['register_widget'] ) ? false : true;
61
+ $instance['lostpassword_widget'] = empty( $new_instance['lostpassword_widget'] ) ? false : true;
62
+ return $instance;
63
+ }
64
+
65
+ /**
66
+ * Displays the widget admin form
67
+ *
68
+ * @since 6.0
69
+ * @access public
70
+ */
71
+ function form( $instance ) {
72
+ $defaults = array(
73
+ 'default_action' => 'login',
74
+ 'logged_in_widget' => 1,
75
+ 'show_title' => 1,
76
+ 'show_log_link' => 1,
77
+ 'show_reg_link' => 1,
78
+ 'show_pass_link' => 1,
79
+ 'show_gravatar' => 1,
80
+ 'gravatar_size' => 50,
81
+ 'register_widget' => 1,
82
+ 'lostpassword_widget' => 1
83
+ );
84
+
85
+ $instance = wp_parse_args( $instance, $defaults );
86
+ $actions = array( 'login' => __( 'Login', 'theme-my-login' ), 'register' => __( 'Register', 'theme-my-login' ), 'lostpassword' => __( 'Lost Password', 'theme-my-login' ) );
87
+ echo '<p>' . __( 'Default Action', 'theme-my-login' ) . '<br /><select name="' . $this->get_field_name( 'default_action' ) . '" id="' . $this->get_field_id( 'default_action' ) . '">';
88
+ foreach ( $actions as $action => $title ) {
89
+ $is_selected = ( $instance['default_action'] == $action ) ? ' selected="selected"' : '';
90
+ echo '<option value="' . $action . '"' . $is_selected . '>' . $title . '</option>';
91
+ }
92
+ echo '</select></p>' . "\n";
93
+ $is_checked = ( empty( $instance['logged_in_widget'] ) ) ? '' : 'checked="checked" ';
94
+ echo '<p><input name="' . $this->get_field_name( 'logged_in_widget' ) . '" type="checkbox" id="' . $this->get_field_id( 'logged_in_widget' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'logged_in_widget' ) . '">' . __( 'Show When Logged In', 'theme-my-login' ) . '</label></p>' . "\n";
95
+ $is_checked = ( empty( $instance['show_title'] ) ) ? '' : 'checked="checked" ';
96
+ echo '<p><input name="' . $this->get_field_name( 'show_title' ) . '" type="checkbox" id="' . $this->get_field_id( 'show_title' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'show_title' ) . '">' . __( 'Show Title', 'theme-my-login' ) . '</label></p>' . "\n";
97
+ $is_checked = ( empty( $instance['show_log_link'] ) ) ? '' : 'checked="checked" ';
98
+ echo '<p><input name="' . $this->get_field_name( 'show_log_link' ) . '" type="checkbox" id="' . $this->get_field_id( 'show_log_link' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'show_log_link' ) . '">' . __( 'Show Login Link', 'theme-my-login' ) . '</label></p>' . "\n";
99
+ $is_checked = ( empty( $instance['show_reg_link'] ) ) ? '' : 'checked="checked" ';
100
+ echo '<p><input name="' . $this->get_field_name( 'show_reg_link' ) . '" type="checkbox" id="' . $this->get_field_id( 'show_reg_link' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'show_reg_link' ) . '">' . __( 'Show Register Link', 'theme-my-login' ) . '</label></p>' . "\n";
101
+ $is_checked = ( empty( $instance['show_pass_link'] ) ) ? '' : 'checked="checked" ';
102
+ echo '<p><input name="' . $this->get_field_name( 'show_pass_link' ) . '" type="checkbox" id="' . $this->get_field_id( 'show_pass_link' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'show_pass_link' ) . '">' . __( 'Show Lost Password Link', 'theme-my-login' ) . '</label></p>' . "\n";
103
+ $is_checked = ( empty( $instance['show_gravatar'] ) ) ? '' : 'checked="checked" ';
104
+ echo '<p><input name="' . $this->get_field_name( 'show_gravatar' ) . '" type="checkbox" id="' . $this->get_field_id( 'show_gravatar' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'show_gravatar' ) . '">' . __( 'Show Gravatar', 'theme-my-login' ) . '</label></p>' . "\n";
105
+ echo '<p>' . __( 'Gravatar Size', 'theme-my-login' ) . ': <input name="' . $this->get_field_name( 'gravatar_size' ) . '" type="text" id="' . $this->get_field_id( 'gravatar_size' ) . '" value="' . $instance['gravatar_size'] . '" size="3" /> <label for="' . $this->get_field_id( 'gravatar_size' ) . '"></label></p>' . "\n";
106
+ $is_checked = ( empty( $instance['register_widget'] ) ) ? '' : 'checked="checked" ';
107
+ echo '<p><input name="' . $this->get_field_name( 'register_widget' ) . '" type="checkbox" id="' . $this->get_field_id( 'register_widget' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'register_widget' ) . '">' . __( 'Allow Registration', 'theme-my-login' ) . '</label></p>' . "\n";
108
+ $is_checked = ( empty( $instance['lostpassword_widget'] ) ) ? '' : 'checked="checked" ';
109
+ echo '<p><input name="' . $this->get_field_name( 'lostpassword_widget' ) . '" type="checkbox" id="' . $this->get_field_id( 'lostpassword_widget' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'lostpassword_widget' ) . '">' . __( 'Allow Password Recovery', 'theme-my-login' ) . '</label></p>' . "\n";
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Registers the TML widget
115
+ *
116
+ * @since 6.0
117
+ */
118
+ function theme_my_login_widget_init() {
119
+ register_widget( 'Theme_My_Login_Widget' );
120
+ }
121
+ add_action( 'widgets_init', 'theme_my_login_widget_init' );
122
+
123
+ endif; // Class exists
124
+
125
+ ?>
includes/class-theme-my-login.php ADDED
@@ -0,0 +1,1078 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login class
4
+ *
5
+ * @package Theme My Login
6
+ */
7
+
8
+ if ( !class_exists( 'Theme_My_Login' ) ) :
9
+ /*
10
+ * Theme My Login class
11
+ *
12
+ * This class contains properties and methods common to the front-end.
13
+ *
14
+ * @since 6.0
15
+ */
16
+ class Theme_My_Login {
17
+ /**
18
+ * Holds plugin textdomain
19
+ *
20
+ * @since 6.0
21
+ * @access public
22
+ * @var string
23
+ */
24
+ var $textdomain = 'theme-my-login';
25
+
26
+ /**
27
+ * Holds TML options key
28
+ *
29
+ * @since 6.0
30
+ * @access public
31
+ * @var string
32
+ */
33
+ var $options_key = 'theme_my_login';
34
+
35
+ /**
36
+ * Holds TML options
37
+ *
38
+ * @since 6.0
39
+ * @access public
40
+ * @var array
41
+ */
42
+ var $options = array();
43
+
44
+ /**
45
+ * Hold WP_Error object
46
+ *
47
+ * @since 6.0
48
+ * @access public
49
+ * @var object
50
+ */
51
+ var $errors;
52
+
53
+ /**
54
+ * Total instances of TML
55
+ *
56
+ * @since 6.0
57
+ * @access public
58
+ * @var int
59
+ */
60
+ var $count = 0;
61
+
62
+ /**
63
+ * Current instance being requested via HTTP GET or POST
64
+ *
65
+ * @since 6.0
66
+ * @access public
67
+ * @var int
68
+ */
69
+ var $request_instance;
70
+
71
+ /**
72
+ * Current action being requested via HTTP GET or POST
73
+ *
74
+ * @since 6.0
75
+ * @access public
76
+ * @var string
77
+ */
78
+ var $request_action;
79
+
80
+ /**
81
+ * PHP4 style constructor
82
+ *
83
+ * @since 6.0
84
+ * @access public
85
+ */
86
+ function Theme_My_Login() {
87
+ $this->__construct();
88
+ }
89
+
90
+ /**
91
+ * PHP5 constructor
92
+ *
93
+ * @since 6.0
94
+ * @access public
95
+ */
96
+ function __construct() {
97
+ $this->request_action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login';
98
+ $this->request_instance = isset( $_REQUEST['instance'] ) ? $_REQUEST['instance'] : '';
99
+
100
+ $this->load_options();
101
+
102
+ // Re-load options after modules loaded so that modules can hook into "tml_init_options"
103
+ //add_action( 'tml_modules_loaded', array( &$this, 'load_options' ), 1 );
104
+
105
+ add_action( 'parse_request', array( &$this, 'the_request' ) );
106
+
107
+ add_action( 'init', array( &$this, 'init' ) );
108
+ add_action( 'wp_default_scripts', array( &$this, 'default_scripts' ) );
109
+ add_action( 'wp_print_footer_scripts', array( &$this, 'print_footer_scripts' ) );
110
+
111
+ add_action( 'wp_head', array( &$this, 'login_head' ) );
112
+
113
+ add_filter( 'the_title', array( &$this, 'the_title' ), 10, 2 );
114
+ add_filter( 'single_post_title', array( &$this, 'single_post_title' ) );
115
+ add_filter( 'wp_setup_nav_menu_item', array( &$this, 'wp_setup_nav_menu_item' ) );
116
+
117
+ add_filter( 'site_url', array( &$this, 'site_url' ), 10, 3 );
118
+
119
+ add_filter( 'wp_list_pages_excludes', array( &$this, 'wp_list_pages_excludes' ) );
120
+ add_filter( 'wp_list_pages', array( &$this, 'wp_list_pages' ) );
121
+
122
+ add_action( 'wp_authenticate', array( &$this, 'wp_authenticate' ) );
123
+
124
+ add_action( 'tml_new_user_registered', 'wp_new_user_notification', 10, 2 );
125
+ add_action( 'tml_user_password_changed', 'wp_password_change_notification' );
126
+
127
+ add_shortcode( 'theme-my-login', array( &$this, 'shortcode' ) );
128
+ }
129
+
130
+ function init() {
131
+ load_plugin_textdomain( $this->textdomain, '', TML_DIRNAME . '/language' );
132
+
133
+ $this->errors = new WP_Error();
134
+
135
+ if ( $this->get_option( 'enable_css' ) )
136
+ wp_enqueue_style( 'theme-my-login', $this->get_stylesheet(), false, $this->get_option( 'version' ) );
137
+ }
138
+
139
+ /**
140
+ * Determine if specified page is the logn page
141
+ *
142
+ * since 6.0
143
+ * @access public
144
+ *
145
+ * @param int $page_id Optional. The page ID (Defaults to current page)
146
+ */
147
+ function is_login_page( $page_id = '' ) {
148
+ if ( empty( $page_id ) ) {
149
+ global $wp_query;
150
+ if ( $wp_query->is_page )
151
+ $page_id = $wp_query->get_queried_object_id();
152
+ }
153
+
154
+ $is_login_page = ( $page_id == $this->get_option( 'page_id' ) );
155
+
156
+ return apply_filters( 'tml_is_login_page', $is_login_page );
157
+ }
158
+
159
+ /**
160
+ * Proccesses the request
161
+ *
162
+ * Callback for "parse_request" hook in WP::parse_request()
163
+ *
164
+ * @see WP::parse_request()
165
+ * @since 6.0
166
+ * @access public
167
+ */
168
+ function the_request() {
169
+ $errors =& $this->errors;
170
+ $action =& $this->request_action;
171
+ $instance =& $this->request_instance;
172
+
173
+ if ( is_admin() )
174
+ return;
175
+
176
+ do_action_ref_array( 'tml_request', array( &$this ) );
177
+
178
+ // Set a cookie now to see if they are supported by the browser.
179
+ setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN );
180
+ if ( SITECOOKIEPATH != COOKIEPATH )
181
+ setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN );
182
+
183
+ // allow plugins to override the default actions, and to add extra actions if they want
184
+ do_action( 'login_form_' . $action );
185
+
186
+ if ( has_action( 'tml_request_' . $action ) ) {
187
+ do_action_ref_array( 'tml_request_' . $action, array( &$this ) );
188
+ } else {
189
+ $http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
190
+ switch ( $action ) {
191
+ case 'logout' :
192
+ check_admin_referer( 'log-out' );
193
+
194
+ $user = wp_get_current_user();
195
+
196
+ $redirect_to = apply_filters( 'logout_redirect', site_url( 'wp-login.php?loggedout=true' ), isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
197
+
198
+ wp_logout();
199
+
200
+ wp_safe_redirect( $redirect_to );
201
+ exit();
202
+ break;
203
+ case 'lostpassword' :
204
+ case 'retrievepassword' :
205
+ if ( $http_post ) {
206
+ $errors = $this->retrieve_password();
207
+ if ( !is_wp_error( $errors ) ) {
208
+ $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : $this->get_current_url( 'checkemail=confirm' );
209
+ if ( !empty( $instance ) )
210
+ $redirect_to = add_query_arg( 'instance', $instance, $redirect_to );
211
+ wp_safe_redirect( $redirect_to );
212
+ exit();
213
+ }
214
+ }
215
+
216
+ if ( isset( $_REQUEST['error'] ) && 'invalidkey' == $_REQUEST['error'] )
217
+ $errors->add( 'invalidkey', __( 'Sorry, that key does not appear to be valid.', $this->textdomain ) );
218
+ break;
219
+ case 'resetpass' :
220
+ case 'rp' :
221
+ $errors = $this->reset_password( $_GET['key'], $_GET['login'] );
222
+
223
+ if ( !is_wp_error( $errors ) ) {
224
+ $redirect_to = apply_filters( 'resetpass_redirect', $this->get_current_url( 'checkemail=newpass' ) );
225
+ if ( !empty( $instance ) )
226
+ $redirect_to = add_query_arg( 'instance', $instance, $redirect_to );
227
+ wp_safe_redirect( $redirect_to );
228
+ exit();
229
+ }
230
+
231
+ $redirect_to = $this->get_current_url( 'action=lostpassword&error=invalidkey' );
232
+ if ( !empty( $instance ) )
233
+ $redirect_to = add_query_arg( 'instance', $instance, $redirect_to );
234
+ wp_redirect( $redirect_to );
235
+ exit();
236
+ break;
237
+ case 'register' :
238
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
239
+ // Multisite uses wp-signup.php
240
+ wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php' ) );
241
+ exit;
242
+ }
243
+
244
+ if ( !get_option( 'users_can_register' ) ) {
245
+ wp_redirect( $this->get_current_url( 'registration=disabled' ) );
246
+ exit();
247
+ }
248
+
249
+ $user_login = '';
250
+ $user_email = '';
251
+ if ( $http_post ) {
252
+ require_once( ABSPATH . WPINC . '/registration.php' );
253
+
254
+ $user_login = $_POST['user_login'];
255
+ $user_email = $_POST['user_email'];
256
+
257
+ $errors = $this->register_new_user( $user_login, $user_email );
258
+ if ( !is_wp_error( $errors ) ) {
259
+ $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : $this->get_current_url( 'checkemail=registered' );
260
+ if ( !empty( $instance ) )
261
+ $redirect_to = add_query_arg( 'instance', $instance, $redirect_to );
262
+ $redirect_to = apply_filters( 'register_redirect', $redirect_to );
263
+ wp_redirect( $redirect_to );
264
+ exit();
265
+ }
266
+ }
267
+ break;
268
+ case 'login' :
269
+ default:
270
+ $secure_cookie = '';
271
+ $interim_login = isset( $_REQUEST['interim-login'] );
272
+
273
+ // If the user wants ssl but the session is not ssl, force a secure cookie.
274
+ if ( !empty( $_POST['log'] ) && !force_ssl_admin() ) {
275
+ $user_name = sanitize_user( $_POST['log'] );
276
+ if ( $user = get_userdatabylogin( $user_name ) ) {
277
+ if ( get_user_option( 'use_ssl', $user->ID ) ) {
278
+ $secure_cookie = true;
279
+ force_ssl_admin( true );
280
+ }
281
+ }
282
+ }
283
+
284
+ if ( isset( $_REQUEST['redirect_to'] ) && !empty( $_REQUEST['redirect_to'] ) ) {
285
+ $redirect_to = $_REQUEST['redirect_to'];
286
+ // Redirect to https if user wants ssl
287
+ if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) )
288
+ $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
289
+ } else {
290
+ $redirect_to = admin_url();
291
+ }
292
+
293
+ $reauth = empty( $_REQUEST['reauth'] ) ? false : true;
294
+
295
+ // If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
296
+ // cookie and redirect back to the referring non-secure admin page. This allows logins to always be POSTed over SSL while allowing the user to choose visiting
297
+ // the admin via http or https.
298
+ if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos( $redirect_to, 'https' ) ) && ( 0 === strpos( $redirect_to, 'http' ) ) )
299
+ $secure_cookie = false;
300
+
301
+ if ( $http_post ) {
302
+ $user = wp_signon( '', $secure_cookie );
303
+
304
+ $redirect_to = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
305
+
306
+ if ( $http_post && !is_wp_error( $user ) && !$reauth ) {
307
+ // If the user can't edit posts, send them to their profile.
308
+ if ( !$user->has_cap( 'edit_posts' ) && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) )
309
+ $redirect_to = admin_url( 'profile.php' );
310
+ wp_safe_redirect( $redirect_to );
311
+ exit();
312
+ }
313
+
314
+ $errors = $user;
315
+ }
316
+
317
+ $this->redirect_to = $redirect_to;
318
+
319
+ // Clear errors if loggedout is set.
320
+ if ( !empty( $_GET['loggedout'] ) || $reauth )
321
+ $errors = new WP_Error();
322
+
323
+ // If cookies are disabled we can't log in even with a valid user+pass
324
+ if ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[TEST_COOKIE] ) )
325
+ $errors->add( '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.', $this->textdomain ) );
326
+
327
+ // Some parts of this script use the main login form to display a message
328
+ if ( isset( $_GET['loggedout'] ) && TRUE == $_GET['loggedout'] )
329
+ $errors->add( 'loggedout', __( 'You are now logged out.', $this->textdomain ), 'message' );
330
+ elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] )
331
+ $errors->add( 'registerdisabled', __( 'User registration is currently not allowed.', $this->textdomain ) );
332
+ elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] )
333
+ $errors->add( 'confirm', __( 'Check your e-mail for the confirmation link.', $this->textdomain ), 'message' );
334
+ elseif ( isset( $_GET['checkemail'] ) && 'newpass' == $_GET['checkemail'] )
335
+ $errors->add( 'newpass', __( 'Check your e-mail for your new password.', $this->textdomain ), 'message' );
336
+ elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] )
337
+ $errors->add( 'registered', __( 'Registration complete. Please check your e-mail.', $this->textdomain ), 'message' );
338
+ elseif ( $interim_login )
339
+ $errors->add( 'expired', __( 'Your session has expired. Please log-in again.', $this->textdomain ), 'message' );
340
+
341
+ // Clear any stale cookies.
342
+ if ( $reauth )
343
+ wp_clear_auth_cookie();
344
+ break;
345
+ } // end switch
346
+ } // endif has_filter()
347
+ }
348
+
349
+ /**
350
+ * Returns link for login page
351
+ *
352
+ * @since 6.0
353
+ * @access public
354
+ *
355
+ * @param string|array $query Optional. Query arguments to add to link
356
+ * @param bool $remove_filter True to remove "page_link" filter
357
+ * @return string Login page link with optional $query arguments appended
358
+ */
359
+ function get_login_page_link( $query = '' ) {
360
+ $link = get_page_link( $this->get_option( 'page_id' ) );
361
+ if ( !empty( $query ) ) {
362
+ $q = wp_parse_args( $query );
363
+ $link = add_query_arg( $q, $link );
364
+ }
365
+ return apply_filters( 'tml_page_link', $link, $query );
366
+ }
367
+
368
+ /**
369
+ * Changes the_title() to reflect the current action
370
+ *
371
+ * Callback for "the_title" hook in the_title()
372
+ *
373
+ * @see the_title()
374
+ * @since 6.0
375
+ * @acess public
376
+ *
377
+ * @param string $title The current post title
378
+ * @param int $post_id The current post ID
379
+ * @return string The modified post title
380
+ */
381
+ function the_title( $title, $post_id = '' ) {
382
+ if ( is_admin() && !defined( 'IS_PROFILE_PAGE' ) )
383
+ return $title;
384
+
385
+ // No post ID until WP 3.0!
386
+ if ( empty( $post_id ) ) {
387
+ global $wpdb;
388
+ $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s", $title ) );
389
+ }
390
+
391
+ if ( $this->get_option( 'page_id' ) == $post_id ) {
392
+ if ( !in_the_loop() ) {
393
+ $title = is_user_logged_in() ? __( 'Log Out', $this->textdomain ) : __( 'Log In', $this->textdomain );
394
+ } else {
395
+ $action = empty( $this->request_instance ) ? $this->request_action : 'login';
396
+ $title = Theme_My_Login_Template::get_title( $action );
397
+ }
398
+ }
399
+ return $title;
400
+ }
401
+
402
+ /**
403
+ * Changes single_post_title() to reflect the current action
404
+ *
405
+ * Callback for "single_post_title" hook in single_post_title()
406
+ *
407
+ * @see single_post_title()
408
+ * @since 6.0
409
+ * @access public
410
+ *
411
+ * @param string $title The current post title
412
+ * @return string The modified post title
413
+ */
414
+ function single_post_title( $title ) {
415
+ if ( $this->is_login_page() ) {
416
+ $action = empty( $this->request_instance ) ? $this->request_action : 'login';
417
+ $title = Theme_My_Login_Template::get_title( $action );
418
+ }
419
+ return $title;
420
+ }
421
+
422
+ /**
423
+ * Excludes TML page if set in the admin
424
+ *
425
+ * Callback for "wp_list_pages_excludes" hook in wp_list_pages()
426
+ *
427
+ * @see wp_list_pages()
428
+ * @since 6.0
429
+ * @access public
430
+ *
431
+ * @param array $exclude_array Array of excluded pages
432
+ * @return array Modified array of excluded pages
433
+ */
434
+ function wp_list_pages_excludes( $exclude_array ) {
435
+ $exclude_array = (array) $exclude_array;
436
+ if ( !$this->get_option( 'show_page' ) )
437
+ $exclude_array[] = $this->get_option( 'page_id' );
438
+ return $exclude_array;
439
+ }
440
+
441
+ /**
442
+ * Changes login link to logout if user is logged in
443
+ *
444
+ * Callback for "wp_list_pages" hook in wp_list_pages()
445
+ *
446
+ * @see wp_list_pages()
447
+ * @since 6.0
448
+ * @access public
449
+ *
450
+ * @param string $output The output
451
+ * @return string The filtered output
452
+ */
453
+ function wp_list_pages( $output ) {
454
+ if ( is_user_logged_in() )
455
+ $output = str_replace( '"' . $this->get_login_page_link() . '"', '"' . wp_logout_url() . '"', $output );
456
+ return $output;
457
+ }
458
+
459
+ /**
460
+ * Alters menu item title & link according to whether user is logged in or not
461
+ *
462
+ * Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
463
+ *
464
+ * @see wp_setup_nav_menu_item()
465
+ * @since 6.0
466
+ * @access public
467
+ *
468
+ * @param object $menu_item The menu item
469
+ * @return object The (possibly) modified menu item
470
+ */
471
+ function wp_setup_nav_menu_item( $menu_item ) {
472
+ if ( 'page' == $menu_item->object && $this->is_login_page( $menu_item->object_id ) ) {
473
+ $menu_item->title = $this->the_title( $menu_item->title, $menu_item->object_id );
474
+ $menu_item->url = $this->get_login_page_link( $menu_item->url, $menu_item->object_id );
475
+ }
476
+ return $menu_item;
477
+ }
478
+
479
+ /**
480
+ * Handler for "theme-my-login" shortcode
481
+ *
482
+ * Optional $atts contents:
483
+ *
484
+ * - instance - A unqiue instance ID for this instance.
485
+ * - default_action - The action to display. Defaults to "login".
486
+ * - login_template - The template used for the login form. Defaults to "login-form.php".
487
+ * - register_template - The template used for the register form. Defaults to "register-form.php".
488
+ * - lostpassword_template - The template used for the lost password form. Defaults to "lostpassword-form.php".
489
+ * - user_template - The templated used for when a user is logged in. Defalts to "user-panel.php".
490
+ * - show_title - True to display the current title, false to hide. Defaults to true.
491
+ * - show_log_link - True to display the login link, false to hide. Defaults to true.
492
+ * - show_reg_link - True to display the register link, false to hide. Defaults to true.
493
+ * - show_pass_link - True to display the lost password link, false to hide. Defaults to true.
494
+ * - register_widget - True to allow registration in widget, false to send to register page. Defaults to false.
495
+ * - lostpassword_widget - True to allow password recovery in widget, false to send to lost password page. Defaults to false.
496
+ * - logged_in_widget - True to display the widget when logged in, false to hide. Defaults to true.
497
+ * - show_gravatar - True to display the user's gravatar, false to hide. Defaults to true.
498
+ * - gravatar_size - The size of the user's gravatar. Defaults to "50".
499
+ * - before_widget - Content to display before widget. Defaults to "<li>".
500
+ * - after_widget - Content to display after widget. Defaults to "</li>".
501
+ * - before_title - Content to display before the title (if displayed). Defaults to "<h2>".
502
+ * - after_title - Content to display after the title (if displayed). Defaults to "</h2>".
503
+ *
504
+ * @since 6.0
505
+ * @access public
506
+ *
507
+ * @param string|array $atts Attributes passed from the shortcode
508
+ * @return string HTML output from Theme_My_Login_Template->display()
509
+ */
510
+ function shortcode( $atts = '' ) {
511
+
512
+ if ( $this->is_login_page() && in_the_loop() ) {
513
+ $atts['instance'] = '';
514
+ $atts['show_title'] = false;
515
+ $atts['before_widget'] = '';
516
+ $atts['after_widget'] = '';
517
+ } else {
518
+ $atts['instance'] = $this->get_new_instance();
519
+ }
520
+
521
+ $template =& new Theme_My_Login_Template( $atts );
522
+
523
+ return $template->display();
524
+ }
525
+
526
+ /**
527
+ * Incremenets $this->count and returns it
528
+ *
529
+ * @since 6.0
530
+ * @access public
531
+ *
532
+ * @return int New value of $this->count
533
+ */
534
+ function get_new_instance() {
535
+ $this->count++;
536
+ return $this->count;
537
+ }
538
+
539
+ /**
540
+ * Returns current URL
541
+ *
542
+ * @since 6.0
543
+ * @access public
544
+ *
545
+ * @param string $query Optionally append query to the current URL
546
+ * @return string URL with optional path appended
547
+ */
548
+ function get_current_url( $query = '' ) {
549
+ $url = remove_query_arg( array( 'instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce', 'reauth', 'login' ) );
550
+ if ( !empty( $query ) ) {
551
+ $r = wp_parse_args( $query );
552
+ foreach ( $r as $k => $v ) {
553
+ if ( strpos( $v, ' ' ) !== false )
554
+ $r[$k] = rawurlencode( $v );
555
+ }
556
+ $url = add_query_arg( $r, $url );
557
+ }
558
+ return $url;
559
+ }
560
+
561
+ /**
562
+ * Rewrites URL's containing wp-login.php created by site_url()
563
+ *
564
+ * @since 6.0
565
+ * @access public
566
+ *
567
+ * @param string $url The URL
568
+ * @param string $path The path specified
569
+ * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
570
+ * @return string The modified URL
571
+ */
572
+ function site_url( $url, $path, $orig_scheme ) {
573
+ if ( strpos( $url, 'wp-login.php' ) !== false && !isset( $_REQUEST['interim-login'] ) ) {
574
+ $parsed_url = parse_url( $url );
575
+ $url = $this->get_login_page_link();
576
+ if ( 'https' == strtolower( $orig_scheme ) )
577
+ $url = preg_replace( '|^http://|', 'https://', $url );
578
+ if ( isset( $parsed_url['query'] ) ) {
579
+ wp_parse_str( $parsed_url['query'], $r );
580
+ foreach ( $r as $k => $v ) {
581
+ if ( strpos($v, ' ') !== false )
582
+ $r[$k] = rawurlencode( $v );
583
+ }
584
+ $url = add_query_arg( $r, $url );
585
+ }
586
+ }
587
+ return $url;
588
+ }
589
+
590
+ /**
591
+ * Enqueues the specified sylesheet
592
+ *
593
+ * First looks in theme/template directories for the stylesheet, falling back to plugin directory
594
+ *
595
+ * @since 6.0
596
+ * @access public
597
+ *
598
+ * @param string $file Filename of stylesheet to load
599
+ * @return string Path to stylesheet
600
+ */
601
+ function get_stylesheet( $file = 'theme-my-login.css' ) {
602
+ if ( file_exists( get_stylesheet_directory() . '/' . $file ) )
603
+ $stylesheet = get_stylesheet_directory_uri() . '/' . $file;
604
+ elseif ( file_exists( get_template_directory() . '/' . $file ) )
605
+ $stylesheet = get_template_directory_uri() . '/' . $file;
606
+ else
607
+ $stylesheet = plugins_url( '/theme-my-login/' . $file );
608
+ return $stylesheet;
609
+ }
610
+
611
+ /**
612
+ * Adds scripts to $wp_scripts object
613
+ *
614
+ * @since 6.0
615
+ * @access public
616
+ */
617
+ function default_scripts( $wp_scripts ) {
618
+ $wp_scripts->add( 'jquery-shake', plugins_url( 'theme-my-login/js/jquery.shake.js' ), array( 'jquery' ) );
619
+ }
620
+
621
+ /**
622
+ * Prints javascript in the footer
623
+ *
624
+ * @since 6.0
625
+ * @access public
626
+ */
627
+ function print_footer_scripts() {
628
+ if ( is_admin() )
629
+ return;
630
+
631
+ $action = empty( $this->request_action ) ? 'login' : $this->request_action;
632
+ switch ( $action ) {
633
+ case 'lostpassword' :
634
+ case 'retrievepassword' :
635
+ case 'register' :
636
+ ?>
637
+ <script type="text/javascript">
638
+ try{document.getElementById('user_login<?php echo $this->request_instance; ?>').focus();}catch(e){}
639
+ if(typeof wpOnload=='function')wpOnload()
640
+ </script>
641
+ <?php
642
+ break;
643
+ case 'login' :
644
+ $user_login = '';
645
+ if ( isset($_POST['log']) )
646
+ $user_login = ( 'incorrect_password' == $this->errors->get_error_code() || 'empty_password' == $this->errors->get_error_code() ) ? esc_attr( stripslashes( $_POST['log'] ) ) : '';
647
+ ?>
648
+ <script type="text/javascript">
649
+ function wp_attempt_focus() {
650
+ setTimeout( function() {
651
+ try {
652
+ <?php if ( $user_login ) { ?>
653
+ d = document.getElementById('user_pass<?php echo $this->request_instance; ?>');
654
+ <?php } else { ?>
655
+ d = document.getElementById('user_login<?php echo $this->request_instance; ?>');
656
+ <?php } ?>
657
+ d.value = '';
658
+ d.focus();
659
+ } catch(e){}
660
+ }, 200 );
661
+ }
662
+ wp_attempt_focus();
663
+ if(typeof wpOnload=='function')wpOnload()
664
+ </script>
665
+ <?php
666
+ break;
667
+ }
668
+ }
669
+
670
+ /**
671
+ * Calls "login_head" hook on login page
672
+ *
673
+ * Callback for "wp_head" hook
674
+ *
675
+ * @since 6.0
676
+ * @access public
677
+ */
678
+ function login_head() {
679
+ if ( $this->is_login_page() )
680
+ do_action( 'login_head' );
681
+ }
682
+
683
+ /**
684
+ * Initializes TML options
685
+ *
686
+ * @since 6.0
687
+ * @access public
688
+ */
689
+ function init_options() {
690
+ $this->options = apply_filters( 'tml_init_options', array(
691
+ 'page_id' => 0,
692
+ 'show_page' => 1,
693
+ 'enable_css' => 1,
694
+ 'active_modules' => array(),
695
+ 'initial_nag' => 1
696
+ ) );
697
+ }
698
+
699
+ /**
700
+ * Loads TML options
701
+ *
702
+ * @since 6.0
703
+ * @access public
704
+ */
705
+ function load_options( $return = false ) {
706
+
707
+ $this->init_options();
708
+
709
+ $options = get_option( $this->options_key );
710
+
711
+ if ( is_array( $options ) ) {
712
+ $this->options = array_merge( $this->options, $options );
713
+ } else {
714
+ update_option( $this->options_key, $this->options );
715
+ }
716
+
717
+ if ( $return )
718
+ return $this->options;
719
+ }
720
+
721
+ /**
722
+ * Saves TML options
723
+ *
724
+ * @since 6.0
725
+ * @access public
726
+ */
727
+ function save_options() {
728
+ $options = get_option( $this->options_key );
729
+ if ( $options != $this->options )
730
+ update_option( $this->options_key, $this->options );
731
+ }
732
+
733
+ /**
734
+ * Retrieve a TML option
735
+ *
736
+ * @since 6.0
737
+ * @access public
738
+ *
739
+ * @param string|array $option Name of option to retrieve or an array of hierarchy for multidimensional options
740
+ * @param mixed $default optional. Default value to return if $option is not set
741
+ * @return mixed Value of requested option or $default if option is not set
742
+ */
743
+ function get_option( $option, $default = false ) {
744
+ $options = $this->options;
745
+ $value = false;
746
+ if ( is_array( $option ) ) {
747
+ foreach ( $option as $key ) {
748
+ if ( !isset( $options[$key] ) ) {
749
+ $value = $default;
750
+ break;
751
+ }
752
+ $options = $value = $options[$key];
753
+ }
754
+ } else {
755
+ $value = isset( $options[$option] ) ? $options[$option] : $default;
756
+ }
757
+ return apply_filters( 'tml_get_option', $value, $option, $default );
758
+ }
759
+
760
+ /**
761
+ * Set a TML option
762
+ *
763
+ * @since 6.0
764
+ * @access public
765
+ *
766
+ * @param string $option Name of option to set
767
+ * @param mixed $value Value of new option
768
+ * @param bool $save True will save to DB
769
+ */
770
+ function set_option( $option, $value = '', $save = false ) {
771
+ $this->options[$option] = apply_filters( 'tml_set_option', $value, $option );
772
+ if ( $save )
773
+ $this->save_options();
774
+ }
775
+
776
+ /**
777
+ * Deletes (unsets) a TML option
778
+ *
779
+ * @since 6.0
780
+ * @access public
781
+ *
782
+ * @param string $option Name of option to delete
783
+ */
784
+ function delete_option( $option ) {
785
+ if ( isset( $this->options[$option] ) )
786
+ unset( $this->options[$option] );
787
+ }
788
+
789
+ /**
790
+ * Merges arrays recursively, replacing duplicate string keys
791
+ *
792
+ * @since 6.0
793
+ * @access public
794
+ */
795
+ function array_merge_recursive() {
796
+ $args = func_get_args();
797
+
798
+ $result = array_shift( $args );
799
+
800
+ foreach ( $args as $arg ) {
801
+ foreach ( $arg as $key => $value ) {
802
+ // Renumber numeric keys as array_merge() does.
803
+ if ( is_numeric( $key ) ) {
804
+ if ( !in_array( $value, $result ) )
805
+ $result[] = $value;
806
+ }
807
+ // Recurse only when both values are arrays.
808
+ elseif ( array_key_exists( $key, $result ) && is_array( $result[$key] ) && is_array( $value ) ) {
809
+ $result[$key] = $this->array_merge_recursive( $result[$key], $value );
810
+ }
811
+ // Otherwise, use the latter value.
812
+ else {
813
+ $result[$key] = $value;
814
+ }
815
+ }
816
+ }
817
+ return $result;
818
+ }
819
+
820
+ /**
821
+ * Returns active and valid TML modules
822
+ *
823
+ * Returns all valid modules specified via $this->options['active_modules']
824
+ *
825
+ * @since 6.0
826
+ * @access public
827
+ */
828
+ function get_active_and_valid_modules() {
829
+ $modules = array();
830
+ $active_modules = apply_filters( 'tml_active_modules', $this->get_option( 'active_modules' ) );
831
+ foreach ( (array) $active_modules as $module ) {
832
+ // check the $plugin filename
833
+ // Validate plugin filename
834
+ if ( !validate_file( $module ) // $module must validate as file
835
+ || '.php' == substr( $module, -4 ) // $module must end with '.php'
836
+ || file_exists( TML_ABSPATH . '/modules/' . $module ) // $module must exist
837
+ )
838
+ $modules[] = TML_ABSPATH . '/modules/' . $module;
839
+ }
840
+ return $modules;
841
+ }
842
+
843
+ /**
844
+ * Determine if $module is an active TML module
845
+ *
846
+ * @since 6.0
847
+ * @access public
848
+ *
849
+ * @param string $module Filename of module to check
850
+ * @return bool True if $module is active, false if not
851
+ */
852
+ function is_module_active( $module ) {
853
+ $active_modules = apply_filters( 'tml_active_modules', $this->get_option( 'active_modules' ) );
854
+ return in_array( $module, (array) $active_modules );
855
+ }
856
+
857
+ /**
858
+ * Handles e-mail address login
859
+ *
860
+ * @since 6.0
861
+ * @access public
862
+ *
863
+ * @param string $username Username or email
864
+ * @param string $password User's password
865
+ */
866
+ function wp_authenticate( &$user_login ) {
867
+ global $wpdb;
868
+ if ( is_email( $user_login ) ) {
869
+ if ( $found = $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM $wpdb->users WHERE user_email = %s", $user_login ) ) )
870
+ $user_login = $found;
871
+ }
872
+ return;
873
+ }
874
+
875
+ /**
876
+ * Handles sending password retrieval email to user.
877
+ *
878
+ * @since 6.0
879
+ * @access public
880
+ * @uses $wpdb WordPress Database object
881
+ *
882
+ * @return bool|WP_Error True: when finish. WP_Error on error
883
+ */
884
+ function retrieve_password() {
885
+ global $wpdb;
886
+
887
+ $errors = new WP_Error();
888
+
889
+ if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
890
+ $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or e-mail address.', $this->textdomain ) );
891
+
892
+ if ( strpos( $_POST['user_login'], '@' ) ) {
893
+ $user_data = get_user_by_email( trim( $_POST['user_login'] ) );
894
+ if ( empty( $user_data ) )
895
+ $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: There is no user registered with that email address.', $this->textdomain ) );
896
+ } else {
897
+ $login = trim( $_POST['user_login'] );
898
+ $user_data = get_userdatabylogin( $login );
899
+ }
900
+
901
+ do_action( 'lostpassword_post' );
902
+
903
+ if ( $errors->get_error_code() )
904
+ return $errors;
905
+
906
+ if ( !$user_data ) {
907
+ $errors->add( 'invalidcombo', __( '<strong>ERROR</strong>: Invalid username or e-mail.', $this->textdomain ) );
908
+ return $errors;
909
+ }
910
+
911
+ // redefining user_login ensures we return the right case in the email
912
+ $user_login = $user_data->user_login;
913
+ $user_email = $user_data->user_email;
914
+
915
+ do_action( 'retreive_password', $user_login ); // Misspelled and deprecated
916
+ do_action( 'retrieve_password', $user_login );
917
+
918
+ $allow = apply_filters( 'allow_password_reset', true, $user_data->ID );
919
+
920
+ if ( !$allow )
921
+ return new WP_Error( 'no_password_reset', __( 'Password reset is not allowed for this user', $this->textdomain ) );
922
+ else if ( is_wp_error( $allow ) )
923
+ return $allow;
924
+
925
+ $key = $wpdb->get_var( $wpdb->prepare( "SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login ) );
926
+ if ( empty( $key ) ) {
927
+ // Generate something random for a key...
928
+ $key = wp_generate_password( 20, false );
929
+ do_action( 'retrieve_password_key', $user_login, $key );
930
+ // Now insert the new md5 key into the db
931
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => $key ), array( 'user_login' => $user_login ) );
932
+ }
933
+ $site_url = ( function_exists( 'network_site_url' ) ) ? 'network_site_url' : 'site_url'; // Pre 3.0 compatibility
934
+ $message = __( 'Someone has asked to reset the password for the following site and username.', $this->textdomain ) . "\r\n\r\n";
935
+ $message .= $site_url() . "\r\n\r\n";
936
+ $message .= sprintf( __( 'Username: %s', $this->textdomain ), $user_login ) . "\r\n\r\n";
937
+ $message .= __( 'To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', $this->textdomain ) . "\r\n\r\n";
938
+ $message .= $site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . "\r\n";
939
+
940
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
941
+ $blogname = $GLOBALS['current_site']->site_name;
942
+ } else {
943
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
944
+ // we want to reverse this for the plain text arena of emails.
945
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
946
+ }
947
+
948
+ $title = sprintf( __( '[%s] Password Reset', $this->textdomain ), $blogname );
949
+
950
+ $title = apply_filters( 'retrieve_password_title', $title, $user_data->ID );
951
+ $message = apply_filters( 'retrieve_password_message', $message, $key, $user_data->ID );
952
+
953
+ if ( $message && !wp_mail( $user_email, $title, $message ) )
954
+ wp_die( __( 'The e-mail could not be sent.', $this->textdomain ) . "<br />\n" . __( 'Possible reason: your host may have disabled the mail() function...', $this->textdomain ) );
955
+
956
+ return true;
957
+ }
958
+
959
+ /**
960
+ * Handles resetting the user's password.
961
+ *
962
+ * @since 6.0
963
+ * @access public
964
+ * @uses $wpdb WordPress Database object
965
+ *
966
+ * @param string $key Hash to validate sending user's password
967
+ * @return bool|WP_Error
968
+ */
969
+ function reset_password( $key, $login ) {
970
+ global $wpdb;
971
+
972
+ $key = preg_replace( '/[^a-z0-9]/i', '', $key );
973
+
974
+ if ( empty( $key ) || !is_string( $key ) )
975
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->textdomain ) );
976
+
977
+ if ( empty( $login ) || !is_string( $login ) )
978
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->textdomain ) );
979
+
980
+ $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login ) );
981
+ if ( empty( $user ) )
982
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->textdomain ) );
983
+
984
+ // Generate something random for a password...
985
+ $new_pass = wp_generate_password();
986
+
987
+ do_action( 'password_reset', $user, $new_pass );
988
+
989
+ $site_url = ( function_exists( 'network_site_url' ) ) ? 'network_site_url' : 'site_url'; // Pre 3.0 compatibility
990
+
991
+ wp_set_password( $new_pass, $user->ID );
992
+ update_user_option( $user->ID, 'default_password_nag', true, true ); //Set up the Password change nag.
993
+ $message = sprintf( __( 'Username: %s', $this->textdomain ), $user->user_login ) . "\r\n";
994
+ $message .= sprintf( __( 'Password: %s', $this->textdomain ), $new_pass ) . "\r\n";
995
+ $message .= $site_url( 'wp-login.php', 'login' ) . "\r\n";
996
+
997
+ if ( function_exists( 'is_multisite') && is_multisite() ) {
998
+ $blogname = $GLOBALS['current_site']->site_name;
999
+ } else {
1000
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
1001
+ // we want to reverse this for the plain text arena of emails.
1002
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1003
+ }
1004
+
1005
+ $title = sprintf( __( '[%s] Your new password', $this->textdomain ), $blogname );
1006
+
1007
+ $title = apply_filters( 'password_reset_title', $title, $user->ID );
1008
+ $message = apply_filters( 'password_reset_message', $message, $new_pass, $user->ID );
1009
+
1010
+ if ( $message && !wp_mail( $user->user_email, $title, $message ) )
1011
+ wp_die( __( 'The e-mail could not be sent.', $this->textdomain ) . "<br />\n" . __( 'Possible reason: your host may have disabled the mail() function...', $this->textdomain ) );
1012
+
1013
+ do_action( 'tml_user_password_changed', $user );
1014
+
1015
+ return true;
1016
+ }
1017
+
1018
+ /**
1019
+ * Handles registering a new user.
1020
+ *
1021
+ * @since 6.0
1022
+ * @access public
1023
+ *
1024
+ * @param string $user_login User's username for logging in
1025
+ * @param string $user_email User's email address to send password and add
1026
+ * @return int|WP_Error Either user's ID or error on failure.
1027
+ */
1028
+ function register_new_user( $user_login, $user_email ) {
1029
+ $errors = new WP_Error();
1030
+
1031
+ $sanitized_user_login = sanitize_user( $user_login );
1032
+ $user_email = apply_filters( 'user_registration_email', $user_email );
1033
+
1034
+ // Check the username
1035
+ if ( $sanitized_user_login == '' ) {
1036
+ $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.', $this->textdomain ) );
1037
+ } elseif ( !validate_username( $user_login ) ) {
1038
+ $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.', $this->textdomain ) );
1039
+ $sanitized_user_login = '';
1040
+ } elseif ( username_exists( $sanitized_user_login ) ) {
1041
+ $errors->add( 'username_exists', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.', $this->textdomain ) );
1042
+ }
1043
+
1044
+ // Check the e-mail address
1045
+ if ( '' == $user_email ) {
1046
+ $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your e-mail address.', $this->textdomain ) );
1047
+ } elseif ( !is_email( $user_email ) ) {
1048
+ $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.', $this->textdomain ) );
1049
+ $user_email = '';
1050
+ } elseif ( email_exists( $user_email ) ) {
1051
+ $errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.', $this->textdomain ) );
1052
+ }
1053
+
1054
+ do_action( 'register_post', $sanitized_user_login, $user_email, $errors );
1055
+
1056
+ $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
1057
+
1058
+ if ( $errors->get_error_code() )
1059
+ return $errors;
1060
+
1061
+ $user_pass = apply_filters( 'tml_user_registration_pass', wp_generate_password() );
1062
+ $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
1063
+ if ( !$user_id ) {
1064
+ $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', $this->textdomain ), get_option( 'admin_email' ) ) );
1065
+ return $errors;
1066
+ }
1067
+
1068
+ update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
1069
+
1070
+ do_action( 'tml_new_user_registered', $user_id, $user_pass );
1071
+
1072
+ return $user_id;
1073
+ }
1074
+ }
1075
+
1076
+ endif; // Class exists
1077
+
1078
+ ?>
includes/class.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
-
3
- if ( ! class_exists('Theme_My_Login') ) :
4
- class Theme_My_Login {
5
- var $options;
6
- var $errors;
7
- var $request_action;
8
- var $request_instance;
9
- var $current_instance;
10
- var $count;
11
- var $redirect_to;
12
-
13
- function get_new_instance() {
14
- ++$this->count;
15
- return 'tml-' . $this->count;
16
- }
17
-
18
- function update_option() {
19
- $args = func_get_args();
20
- if ( !is_array($args) )
21
- return false;
22
-
23
- $value = array_shift($args);
24
-
25
- $option =& $this->options;
26
- foreach ( $args as $arg ) {
27
- $option =& $option[$arg];
28
- }
29
- $option = $value;
30
- return true;
31
- }
32
-
33
- function delete_option() {
34
- $args = func_get_args();
35
- if ( !is_array($args) )
36
- return false;
37
-
38
- $option = 'options';
39
- foreach ( $args as $arg ) {
40
- $option .= "['$arg']";
41
- }
42
- eval("unset(\$this->{$option});");
43
- return true;
44
- }
45
-
46
- function get_option() {
47
- $args = func_get_args();
48
- if ( !is_array($args) )
49
- return false;
50
-
51
- $option = $this->options;
52
- foreach ( $args as $arg ) {
53
- if ( !isset($option[$arg]) )
54
- return false;
55
- $option = $option[$arg];
56
- }
57
- return $option;
58
- }
59
-
60
- function save_options() {
61
- return update_option('theme_my_login', $this->options);
62
- }
63
-
64
- function set_error($code = '', $error = '', $data = '') {
65
- if ( empty($code) )
66
- $this->errors = new WP_Error();
67
- elseif ( is_a($code, 'WP_Error') )
68
- $this->errors = $code;
69
- elseif ( is_a($this->errors, 'WP_Error') )
70
- $this->errors->add($code, $error, $data);
71
- else
72
- $this->errors = new WP_Error($code, $error, $data);
73
- }
74
-
75
- function get_error($code = '') {
76
- if ( is_a($this->errors, 'WP_Error') )
77
- return $this->errors->get_error_message($code);
78
- return false;
79
- }
80
-
81
- function set_var() {
82
- $args = func_get_args();
83
- if ( !is_array($args) || count($args) < 2 )
84
- return false;
85
-
86
- $value = array_shift($args);
87
- $key = array_shift($args);
88
-
89
- $option = $key;
90
- foreach ( $args as $arg ) {
91
- $option .= "['$arg']";
92
- }
93
- eval("\$this->{$option} = \$value;");
94
- return true;
95
- }
96
-
97
- function get_var() {
98
- $args = func_get_args();
99
- if ( !is_array($args) )
100
- return false;
101
-
102
- $key = array_shift($args);
103
- if ( !isset($this->{$key}) )
104
- return false;
105
-
106
- $option = $this->{$key};
107
- foreach ( $args as $arg ) {
108
- if ( !isset($option[$arg]) )
109
- return $option;
110
- $option = $option[$arg];
111
- }
112
- return $option;
113
- }
114
-
115
- function default_options() {
116
- $options = array(
117
- 'show_page' => 1,
118
- 'rewrite_links' => 1,
119
- 'enable_css' => 1,
120
- 'enable_template_tag' => 0,
121
- 'enable_widget' => 0,
122
- 'active_modules' => array()
123
- );
124
- return apply_filters('tml_default_option', $options);
125
- }
126
-
127
- function __construct() {
128
- $this->options = get_option('theme_my_login', $this->default_options());
129
- $this->request_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
130
- $this->request_instance = isset($_REQUEST['instance']) ? $_REQUEST['instance'] : 'tml-page';
131
- $this->count = 0;
132
- }
133
-
134
- function Theme_My_Login() {
135
- $this->__construct();
136
- }
137
- }
138
- endif;
139
-
140
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/functions.php DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_update_option() {
4
- global $theme_my_login;
5
- $args = func_get_args();
6
- return call_user_func_array(array(&$theme_my_login, 'update_option'), $args);
7
- }
8
-
9
- function wdbj_tml_delete_option() {
10
- global $theme_my_login;
11
- $args = func_get_args();
12
- return call_user_func_array(array(&$theme_my_login, 'delete_option'), $args);
13
- }
14
-
15
- function wdbj_tml_get_option() {
16
- global $theme_my_login;
17
- $args = func_get_args();
18
- return call_user_func_array(array(&$theme_my_login, 'get_option'), $args);
19
- }
20
-
21
- function wdbj_tml_save_options() {
22
- global $theme_my_login;
23
- return $theme_my_login->save_options();
24
- }
25
-
26
- function wdbj_tml_set_error($code = '', $error = '', $data = '') {
27
- global $theme_my_login;
28
- return $theme_my_login->set_error($code, $error, $data);
29
- }
30
-
31
- function wdbj_tml_get_error($code = '') {
32
- global $theme_my_login;
33
- return $theme_my_login->get_error($code);
34
- }
35
-
36
- function wdbj_tml_get_var() {
37
- global $theme_my_login;
38
- $args = func_get_args();
39
- return call_user_func_array(array(&$theme_my_login, 'get_var'), $args);
40
- }
41
-
42
- function wdbj_tml_set_var() {
43
- global $theme_my_login;
44
- $args = func_get_args();
45
- return call_user_func_array(array(&$theme_my_login, 'set_var'), $args);
46
- }
47
-
48
- function wdbj_tml_get_new_instance() {
49
- global $theme_my_login;
50
- return $theme_my_login->get_new_instance();
51
- }
52
-
53
- function wdbj_tml_get_current_url($query = '') {
54
- $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
55
- $self = $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
56
-
57
- $keys = array('instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce');
58
- $url = remove_query_arg($keys, $self);
59
-
60
- if ( !empty($query) ) {
61
- wp_parse_str($query, $r);
62
- foreach ( $r as $k => $v ) {
63
- if ( strpos($v, ' ') !== false )
64
- $r[$k] = rawurlencode($v);
65
- }
66
- $url = add_query_arg($r, $url);
67
- }
68
- return $url;
69
- }
70
-
71
- function wdbj_tml_get_css($file = 'theme-my-login.css') {
72
- if ( file_exists(get_stylesheet_directory() . "/$file") )
73
- $css_file = get_stylesheet_directory_uri() . "/$file";
74
- elseif ( file_exists(get_template_directory() . "/$file") )
75
- $css_file = get_template_directory_uri() . "/$file";
76
- else
77
- $css_file = plugins_url("/theme-my-login/$file");
78
-
79
- wp_enqueue_style('theme-my-login', $css_file);
80
- }
81
-
82
- function wdbj_tml_is_module_active($module) {
83
- $modules = apply_filters('tml_active_modules', wdbj_tml_get_option('active_modules'));
84
- return in_array($module, (array) $modules);
85
- }
86
-
87
- function wdbj_tml_load_active_modules() {
88
- $modules = apply_filters('tml_active_modules', wdbj_tml_get_option('active_modules'));
89
- if ( is_array($modules) ) {
90
- foreach ( $modules as $module ) {
91
- // check the $plugin filename
92
- // Validate plugin filename
93
- if ( validate_file($module) // $module must validate as file
94
- || '.php' != substr($module, -4) // $module must end with '.php'
95
- || !file_exists(TML_MODULE_DIR . '/' . $module) // $module must exist
96
- )
97
- continue;
98
-
99
- include_once(TML_MODULE_DIR . '/' . $module);
100
- }
101
- unset($module);
102
- }
103
- unset($modules);
104
-
105
- do_action('tml_modules_loaded');
106
- }
107
-
108
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/hook-functions.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_the_title($title, $post_id = '') {
4
- global $wdbj_tml_doing_pagelist;
5
-
6
- if ( is_admin() && !defined('IS_PROFILE_PAGE') )
7
- return $title;
8
-
9
- // No post ID until WP 3.0!
10
- if ( empty( $post_id ) ) {
11
- global $wpdb;
12
- $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_status = 'publish'", $title ) );
13
- }
14
-
15
- if ( wdbj_tml_get_option('page_id') == $post_id ) {
16
- if ( $wdbj_tml_doing_pagelist ) {
17
- $title = is_user_logged_in() ? __('Log Out', 'theme-my-login') : __('Log In', 'theme-my-login');
18
- } else {
19
- require_once (WP_PLUGIN_DIR . '/theme-my-login/includes/template-functions.php');
20
- $action = ( 'tml-page' == wdbj_tml_get_var('request_instance') ) ? wdbj_tml_get_var('request_action') : 'login';
21
- $title = wdbj_tml_get_title($action);
22
- }
23
- }
24
- return $title;
25
- }
26
-
27
- function wdbj_tml_single_post_title($title) {
28
- if ( is_page(wdbj_tml_get_option('page_id')) ) {
29
- require_once (WP_PLUGIN_DIR . '/theme-my-login/includes/template-functions.php');
30
- $action = ( 'tml-page' == wdbj_tml_get_var('request_instance') ) ? wdbj_tml_get_var('request_action') : 'login';
31
- $title = wdbj_tml_get_title($action);
32
- }
33
- return $title;
34
- }
35
-
36
- function wdbj_tml_site_url($url, $path, $orig_scheme) {
37
- if ( strpos($url, 'wp-login.php') !== false && !isset($_REQUEST['interim-login']) ) {
38
- $parsed_url = parse_url($url);
39
- $url = get_permalink(wdbj_tml_get_option('page_id'));
40
- if ( isset($parsed_url['query']) ) {
41
- wp_parse_str($parsed_url['query'], $r);
42
- foreach ( $r as $k => $v ) {
43
- if ( strpos($v, ' ') !== false )
44
- $r[$k] = rawurlencode($v);
45
- }
46
- $url = add_query_arg($r, $url);
47
- }
48
- }
49
- return $url;
50
- }
51
-
52
- function wdbj_tml_list_pages_excludes($exclude_array) {
53
- global $wdbj_tml_doing_pagelist;
54
- $wdbj_tml_doing_pagelist = true;
55
- if ( !wdbj_tml_get_option('show_page') )
56
- $exclude_array[] = wdbj_tml_get_option('page_id');
57
- return $exclude_array;
58
- }
59
-
60
- function wdbj_tml_list_pages($output) {
61
- global $wdbj_tml_doing_pagelist;
62
- $wdbj_tml_doing_pagelist = false;
63
- return $output;
64
- }
65
-
66
- function wdbj_tml_page_link($link, $id) {
67
- global $wdbj_tml_doing_pagelist;
68
- if ( !$wdbj_tml_doing_pagelist )
69
- return $link;
70
- if ( $id == wdbj_tml_get_option('page_id') ) {
71
- if ( is_user_logged_in() && ( !isset($_REQUEST['action']) || 'logout' != $_REQUEST['action'] ) )
72
- $link = wp_nonce_url(add_query_arg('action', 'logout', $link), 'log-out');
73
- }
74
- return $link;
75
- }
76
-
77
- function wdbj_tml_setup_nav_menu_item($menu_item) {
78
- if ( 'page' == $menu_item->object ) {
79
- $page_id = wdbj_tml_get_option('page_id');
80
- if ( $page_id == $menu_item->object_id ) {
81
- if ( is_user_logged_in() ) {
82
- $menu_item->title = __('Log Out', 'theme-my-login');
83
- $menu_item->url = wp_nonce_url(add_query_arg('action', 'logout', get_page_link($page_id)), 'log-out');
84
- } else {
85
- $menu_item->title = __('Log In', 'theme-my-login');
86
- }
87
- }
88
- }
89
- return $menu_item;
90
- }
91
-
92
- function wdbj_tml_shortcode($atts = '') {
93
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/template-functions.php' );
94
-
95
- if ( empty($atts['instance_id']) )
96
- $atts['instance_id'] = wdbj_tml_get_new_instance();
97
-
98
- if ( wdbj_tml_get_var('request_instance') == $atts['instance_id'] )
99
- $atts['is_active'] = 1;
100
-
101
- wdbj_tml_set_var(shortcode_atts(wdbj_tml_get_display_options(), $atts), 'current_instance');
102
- return wdbj_tml_display();
103
- }
104
-
105
- function wdbj_tml_page_shortcode($atts = '') {
106
-
107
- if ( !is_array($atts) )
108
- $atts = array();
109
-
110
- $atts['instance_id'] = 'tml-page';
111
-
112
- if ( !isset($atts['show_title']) )
113
- $atts['show_title'] = 0;
114
- if ( !isset($atts['before_widget']) )
115
- $atts['before_widget'] = '';
116
- if ( !isset($atts['after_widget']) )
117
- $atts['after_widget'] = '';
118
-
119
- return wdbj_tml_shortcode($atts);
120
- }
121
-
122
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/login-actions.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
-
3
- $instance = wdbj_tml_get_var('request_instance');
4
- $action = wdbj_tml_get_var('request_action');
5
-
6
- //Set a cookie now to see if they are supported by the browser.
7
- setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
8
- if ( SITECOOKIEPATH != COOKIEPATH )
9
- setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
10
-
11
- // allow plugins to override the default actions, and to add extra actions if they want
12
- if ( has_filter('login_action_' . $action) ) :
13
-
14
- do_action('login_action_' . $action, $instance);
15
-
16
- else :
17
-
18
- $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
19
- switch ( $action ) {
20
- case 'logout' :
21
- check_admin_referer('log-out');
22
-
23
- $user = wp_get_current_user();
24
-
25
- $redirect_to = site_url('wp-login.php?loggedout=true');
26
- $redirect_to = apply_filters('logout_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
27
-
28
- wp_logout();
29
-
30
- wp_safe_redirect($redirect_to);
31
- exit();
32
- break;
33
- case 'lostpassword' :
34
- case 'retrievepassword' :
35
- if ( $http_post ) {
36
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/login-functions.php' );
37
- $errors = retrieve_password();
38
- if ( !is_wp_error($errors) ) {
39
- $redirect_to = site_url('wp-login.php?checkemail=confirm');
40
- if ( 'tml-page' != $instance )
41
- $redirect_to = wdbj_tml_get_current_url('checkemail=confirm&instance=' . $instance);
42
- wp_redirect($redirect_to);
43
- exit();
44
- } else wdbj_tml_set_error($errors);
45
- }
46
-
47
- if ( isset($_REQUEST['error']) && 'invalidkey' == $_REQUEST['error'] )
48
- wdbj_tml_set_error('invalidkey', __('Sorry, that key does not appear to be valid.', 'theme-my-login'));
49
- break;
50
- case 'resetpass' :
51
- case 'rp' :
52
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/login-functions.php' );
53
- $errors = reset_password($_GET['key'], $_GET['login']);
54
-
55
- if ( !is_wp_error($errors) ) {
56
- $redirect_to = site_url('wp-login.php?checkemail=newpass');
57
- if ( 'tml-page' != $instance )
58
- $redirect_to = wdbj_tml_get_current_url('checkemail=newpass&instance=' . $instance);
59
- $redirect_to = apply_filters('resetpass_redirect', $redirect_to);
60
- wp_redirect($redirect_to);
61
- exit();
62
- } else wdbj_tml_set_error($errors);
63
-
64
- $redirect_to = site_url('wp-login.php?action=lostpassword&error=invalidkey');
65
- if ( 'tml-page' != $instance )
66
- $redirect_to = wdbj_tml_get_current_url('action=lostpassword&error=invalidkey&instance=' . $instance);
67
- wp_redirect($redirect_to);
68
- exit();
69
- break;
70
- case 'register' :
71
- if ( !get_option('users_can_register') ) {
72
- wp_redirect(wdbj_tml_get_current_url('registration=disabled'));
73
- exit();
74
- }
75
-
76
- $user_login = '';
77
- $user_email = '';
78
- $user_pass = '';
79
- if ( $http_post ) {
80
- require_once( ABSPATH . WPINC . '/registration.php' );
81
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/login-functions.php' );
82
-
83
- $user_login = $_POST['user_login'];
84
- $user_email = $_POST['user_email'];
85
-
86
- $errors = register_new_user($user_login, $user_email);
87
- if ( !is_wp_error($errors) ) {
88
- $redirect_to = site_url('wp-login.php?checkemail=registered');
89
- if ( 'tml-page' != $instance )
90
- $redirect_to = wdbj_tml_get_current_url('checkemail=registered&instance=' . $instance);
91
- $redirect_to = apply_filters('register_redirect', $redirect_to);
92
- wp_redirect($redirect_to);
93
- exit();
94
- } else wdbj_tml_set_error($errors);
95
- }
96
- break;
97
- case 'login' :
98
- default:
99
- $secure_cookie = '';
100
-
101
- // If the user wants ssl but the session is not ssl, force a secure cookie.
102
- if ( !empty($_POST['log']) && !force_ssl_admin() ) {
103
- $user_name = sanitize_user($_POST['log']);
104
- if ( $user = get_userdatabylogin($user_name) ) {
105
- if ( get_user_option('use_ssl', $user->ID) ) {
106
- $secure_cookie = true;
107
- force_ssl_admin(true);
108
- }
109
- }
110
- }
111
-
112
- if ( isset($_REQUEST['redirect_to']) && !empty($_REQUEST['redirect_to']) ) {
113
- $redirect_to = $_REQUEST['redirect_to'];
114
- // Redirect to https if user wants ssl
115
- if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') )
116
- $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
117
- } else {
118
- $redirect_to = admin_url();
119
- }
120
-
121
- if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
122
- $secure_cookie = false;
123
-
124
- $user = wp_signon('', $secure_cookie);
125
-
126
- $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
127
-
128
- wdbj_tml_set_var($redirect_to, 'redirect_to');
129
-
130
- if ( $http_post ) {
131
- if ( !is_wp_error($user) ) {
132
- // If the user can't edit posts, send them to their profile.
133
- if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) )
134
- $redirect_to = admin_url('profile.php');
135
- wp_safe_redirect($redirect_to);
136
- exit();
137
- }
138
-
139
- wdbj_tml_set_error($user);
140
- }
141
- break;
142
- }
143
-
144
- endif;
145
-
146
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/login-functions.php DELETED
@@ -1,185 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Handles sending password retrieval email to user.
5
- *
6
- * @uses $wpdb WordPress Database object
7
- *
8
- * @return bool|WP_Error True: when finish. WP_Error on error
9
- */
10
- function retrieve_password() {
11
- global $wpdb;
12
-
13
- $errors = new WP_Error();
14
-
15
- if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
16
- $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'theme-my-login'));
17
-
18
- if ( strpos($_POST['user_login'], '@') ) {
19
- $user_data = get_user_by_email(trim($_POST['user_login']));
20
- if ( empty($user_data) )
21
- $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'theme-my-login'));
22
- } else {
23
- $login = trim($_POST['user_login']);
24
- $user_data = get_userdatabylogin($login);
25
- }
26
-
27
- do_action('lostpassword_post');
28
-
29
- if ( $errors->get_error_code() )
30
- return $errors;
31
-
32
- if ( !$user_data ) {
33
- $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'theme-my-login'));
34
- return $errors;
35
- }
36
-
37
- // redefining user_login ensures we return the right case in the email
38
- $user_login = $user_data->user_login;
39
- $user_email = $user_data->user_email;
40
-
41
- do_action('retreive_password', $user_login); // Misspelled and deprecated
42
- do_action('retrieve_password', $user_login);
43
-
44
- $allow = apply_filters('allow_password_reset', true, $user_data->ID);
45
-
46
- if ( ! $allow )
47
- return new WP_Error('no_password_reset', __('Password reset is not allowed for this user', 'theme-my-login'));
48
- else if ( is_wp_error($allow) )
49
- return $allow;
50
-
51
- $key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
52
- if ( empty($key) ) {
53
- // Generate something random for a key...
54
- $key = wp_generate_password(20, false);
55
- do_action('retrieve_password_key', $user_login, $key);
56
- // Now insert the new md5 key into the db
57
- $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
58
- }
59
- $message = __('Someone has asked to reset the password for the following site and username.', 'theme-my-login') . "\r\n\r\n";
60
- $message .= get_option('siteurl') . "\r\n\r\n";
61
- $message .= sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n\r\n";
62
- $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', 'theme-my-login') . "\r\n\r\n";
63
- $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";
64
-
65
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
66
- // we want to reverse this for the plain text arena of emails.
67
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
68
-
69
- $title = sprintf(__('[%s] Password Reset', 'theme-my-login'), $blogname);
70
-
71
- $title = apply_filters('retrieve_password_title', $title, $user_data->ID);
72
- $message = apply_filters('retrieve_password_message', $message, $key, $user_data->ID);
73
-
74
- if ( $message && !wp_mail($user_email, $title, $message) )
75
- die('<p>' . __('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login') . '</p>');
76
-
77
- return true;
78
- }
79
-
80
- /**
81
- * Handles resetting the user's password.
82
- *
83
- * @uses $wpdb WordPress Database object
84
- *
85
- * @param string $key Hash to validate sending user's password
86
- * @return bool|WP_Error
87
- */
88
- function reset_password($key, $login) {
89
- global $wpdb;
90
-
91
- $key = preg_replace('/[^a-z0-9]/i', '', $key);
92
-
93
- if ( empty( $key ) || !is_string( $key ) )
94
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
95
-
96
- if ( empty($login) || !is_string($login) )
97
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
98
-
99
- $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
100
- if ( empty( $user ) )
101
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
102
-
103
- // Generate something random for a password...
104
- $new_pass = wp_generate_password();
105
-
106
- do_action('password_reset', $user, $new_pass);
107
-
108
- wp_set_password($new_pass, $user->ID);
109
- update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
110
- $message = sprintf(__('Username: %s', 'theme-my-login'), $user->user_login) . "\r\n";
111
- $message .= sprintf(__('Password: %s', 'theme-my-login'), $new_pass) . "\r\n";
112
- $message .= site_url('wp-login.php', 'login') . "\r\n";
113
-
114
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
115
- // we want to reverse this for the plain text arena of emails.
116
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
117
-
118
- $title = sprintf(__('[%s] Your new password', 'theme-my-login'), $blogname);
119
-
120
- $title = apply_filters('password_reset_title', $title, $user->ID);
121
- $message = apply_filters('password_reset_message', $message, $new_pass, $user->ID);
122
-
123
- if ( $message && !wp_mail($user->user_email, $title, $message) )
124
- die('<p>' . __('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login') . '</p>');
125
-
126
- wp_password_change_notification($user);
127
-
128
- return true;
129
- }
130
-
131
- /**
132
- * Handles registering a new user.
133
- *
134
- * @param string $user_login User's username for logging in
135
- * @param string $user_email User's email address to send password and add
136
- * @return int|WP_Error Either user's ID or error on failure.
137
- */
138
- function register_new_user($user_login, $user_email) {
139
- $errors = new WP_Error();
140
-
141
- $user_login = sanitize_user( $user_login );
142
- $user_email = apply_filters( 'user_registration_email', $user_email );
143
-
144
- // Check the username
145
- if ( $user_login == '' )
146
- $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.', 'theme-my-login'));
147
- elseif ( !validate_username( $user_login ) ) {
148
- $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.', 'theme-my-login'));
149
- $user_login = '';
150
- } elseif ( username_exists( $user_login ) )
151
- $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'theme-my-login'));
152
-
153
- // Check the e-mail address
154
- if ($user_email == '') {
155
- $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'theme-my-login'));
156
- } elseif ( !is_email( $user_email ) ) {
157
- $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.', 'theme-my-login'));
158
- $user_email = '';
159
- } elseif ( email_exists( $user_email ) )
160
- $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'theme-my-login'));
161
-
162
- do_action('register_post', $user_login, $user_email, $errors);
163
-
164
- $errors = apply_filters( 'registration_errors', $errors, $user_login, $user_email );
165
-
166
- if ( $errors->get_error_code() )
167
- return $errors;
168
-
169
- $user_pass = wp_generate_password();
170
-
171
- // Allow the new password to be filtered by plugins
172
- $user_pass = apply_filters('user_registration_pass', $user_pass);
173
-
174
- $user_id = wp_create_user( $user_login, $user_pass, $user_email );
175
- if ( !$user_id ) {
176
- $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'theme-my-login'), get_option('admin_email')));
177
- return $errors;
178
- }
179
-
180
- wp_new_user_notification($user_id, $user_pass);
181
-
182
- return $user_id;
183
- }
184
-
185
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/pluggable-functions.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
-
3
- if ( !function_exists('wp_password_change_notification') ) :
4
- /**
5
- * Notify the blog admin of a user changing password, normally via email.
6
- *
7
- * @since 2.7
8
- *
9
- * @param object $user User Object
10
- */
11
- function wp_password_change_notification(&$user) {
12
- do_action('wp_password_change_notification');
13
- // send a copy of password change notification to the admin
14
- // but check to see if it's the admin whose password we're changing, and skip this
15
- if ( $user->user_email != get_option('admin_email') ) {
16
- if ( apply_filters('password_change_notification', true) ) {
17
- $message = sprintf(__('Password Lost and Changed for user: %s', 'theme-my-login'), $user->user_login) . "\r\n";
18
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
19
- // we want to reverse this for the plain text arena of emails.
20
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
21
-
22
- $title = sprintf(__('[%s] Password Lost/Changed', 'theme-my-login'), $blogname);
23
-
24
- $title = apply_filters('password_change_notification_title', $title, $user->ID);
25
- $message = apply_filters('password_change_notification_message', $message, $user->ID);
26
-
27
- @wp_mail(get_option('admin_email'), $title, $message);
28
- }
29
- }
30
- }
31
- endif;
32
-
33
- if ( !function_exists('wp_new_user_notification') ) :
34
- /**
35
- * Notify the blog admin of a new user, normally via email.
36
- *
37
- * @since 2.0
38
- *
39
- * @param int $user_id User ID
40
- * @param string $plaintext_pass Optional. The user's plaintext password
41
- */
42
- function wp_new_user_notification($user_id, $plaintext_pass = '') {
43
- $user = new WP_User($user_id);
44
-
45
- do_action('wp_new_user_notification', $user_id, $plaintext_pass);
46
-
47
- $user_login = stripslashes($user->user_login);
48
- $user_email = stripslashes($user->user_email);
49
-
50
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
51
- // we want to reverse this for the plain text arena of emails.
52
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
53
-
54
- if ( apply_filters('new_user_admin_notification', true) ) {
55
- $message = sprintf(__('New user registration on your blog %s:', 'theme-my-login'), $blogname) . "\r\n\r\n";
56
- $message .= sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n\r\n";
57
- $message .= sprintf(__('E-mail: %s', 'theme-my-login'), $user_email) . "\r\n";
58
-
59
- $title = sprintf(__('[%s] New User Registration', 'theme-my-login'), $blogname);
60
-
61
- $title = apply_filters('new_user_admin_notification_title', $title, $user_id);
62
- $message = apply_filters('new_user_admin_notification_message', $message, $user_id);
63
-
64
- @wp_mail(get_option('admin_email'), $title, $message);
65
- }
66
-
67
- if ( empty($plaintext_pass) )
68
- return;
69
-
70
- if ( apply_filters('new_user_notification', true) ) {
71
- $message = sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n";
72
- $message .= sprintf(__('Password: %s', 'theme-my-login'), $plaintext_pass) . "\r\n";
73
- $message .= wp_login_url() . "\r\n";
74
-
75
- $title = sprintf(__('[%s] Your username and password', 'theme-my-login'), $blogname);
76
-
77
- $title = apply_filters('new_user_notification_title', $title, $user_id);
78
- $message = apply_filters('new_user_notification_message', $message, $plaintext_pass, $user_id);
79
-
80
- wp_mail($user_email, $title, $message);
81
- }
82
-
83
- }
84
- endif;
85
-
86
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/template-functions.php DELETED
@@ -1,284 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_display() {
4
- $current_instance = wdbj_tml_get_var('current_instance');
5
- $request_instance = wdbj_tml_get_var('request_instance');
6
-
7
- $action = isset($current_instance['default_action']) ? $current_instance['default_action'] : 'login';
8
- if ( $request_instance == $current_instance['instance_id'] )
9
- $action = wdbj_tml_get_var('request_action');
10
-
11
- ob_start();
12
- echo $current_instance['before_widget'];
13
- if ( $current_instance['show_title'] )
14
- echo $current_instance['before_title'] . wdbj_tml_get_title($action) . $current_instance['after_title'] . "\n";
15
- if ( is_user_logged_in() ) {
16
- $user = wp_get_current_user();
17
- $user_role = reset($user->roles);
18
- echo '<div class="login" id="' . $current_instance['instance_id'] . '">' . "\n";
19
- if ( $current_instance['show_gravatar'] )
20
- echo '<div class="tml-user-avatar">' . get_avatar( $user->ID, $current_instance['gravatar_size'] ) . '</div>' . "\n";
21
- echo '<ul class="tml-user-links">' . "\n";
22
- $user_links = array(
23
- array('title' => __('Dashboard', 'theme-my-login'), 'url' => admin_url()),
24
- array('title' => __('Profile', 'theme-my-login'), 'url' => admin_url('profile.php'))
25
- );
26
- $user_links = apply_filters('tml_user_links', $user_links);
27
- if ( $user_links ) {
28
- foreach ( $user_links as $link ) {
29
- echo '<li><a href="' . $link['url'] . '">' . $link['title'] . '</a></li>' . "\n";
30
- }
31
- }
32
- echo '<li><a href="' . wp_logout_url() . '">' . __('Log out', 'theme-my-login') . '</a></li>' . "\n";
33
- echo "</ul>\n</div>\n";
34
- } else {
35
- if ( has_filter('login_form_' . $action) ) {
36
- do_action('login_form_' . $action, $current_instance['instance_id']);
37
- } else {
38
- switch ( $action ) {
39
- case 'lostpassword' :
40
- case 'retrievepassword' :
41
- wdbj_tml_get_lost_password_form();
42
- break;
43
- case 'register' :
44
- wdbj_tml_get_register_form();
45
- break;
46
- case 'login' :
47
- default :
48
- wdbj_tml_get_login_form();
49
- break;
50
- }
51
- }
52
- }
53
- echo $current_instance['after_widget'] . "\n";
54
- unset($current_instance, $request_instance, $action, $user_links, $link);
55
- $contents = ob_get_contents();
56
- ob_end_clean();
57
- return apply_filters('tml_display', $contents);
58
- }
59
-
60
- function wdbj_tml_get_display_options() {
61
- $display_options = array(
62
- 'instance_id' => 'tml-page',
63
- 'is_active' => 0,
64
- 'default_action' => 'login',
65
- 'show_title' => 1,
66
- 'show_log_link' => 1,
67
- 'show_reg_link' => 1,
68
- 'show_pass_link' => 1,
69
- 'register_widget' => 0,
70
- 'lost_pass_widget' => 0,
71
- 'logged_in_widget' => 1,
72
- 'show_gravatar' => 1,
73
- 'gravatar_size' => 50,
74
- 'before_widget' => '<li>',
75
- 'after_widget' => '</li>',
76
- 'before_title' => '<h2>',
77
- 'after_title' => '</h2>'
78
- );
79
- return apply_filters('tml_display_options', $display_options);
80
- }
81
-
82
- function wdbj_tml_get_title($action = '') {
83
- if ( empty($action) )
84
- $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
85
-
86
- if ( is_user_logged_in() ) {
87
- $user = wp_get_current_user();
88
- $title = sprintf(__('Welcome, %s', 'theme-my-login'), $user->display_name);
89
- } else {
90
- switch ( $action ) {
91
- case 'register':
92
- $title = __('Register', 'theme-my-login');
93
- break;
94
- case 'lostpassword':
95
- case 'retrievepassword':
96
- case 'resetpass':
97
- case 'rp':
98
- $title = __('Lost Password', 'theme-my-login');
99
- break;
100
- case 'login':
101
- default:
102
- $title = __('Log In', 'theme-my-login');
103
- }
104
- }
105
- return apply_filters('tml_title', $title, $action);
106
- }
107
-
108
- function wdbj_tml_get_header($message = '') {
109
- global $error;
110
-
111
- $wp_error = wdbj_tml_get_var('errors');
112
- $current_instance = wdbj_tml_get_var('current_instance');
113
-
114
- if ( empty($wp_error) )
115
- $wp_error = new WP_Error();
116
-
117
- echo '<div class="login" id="' . $current_instance['instance_id'] . '">';
118
-
119
- $message = apply_filters('login_message', $message);
120
- if ( !empty($message) )
121
- echo '<p class="message">' . $message . "</p>\n";
122
-
123
- // Incase a plugin uses $error rather than the $errors object
124
- if ( !empty( $error ) ) {
125
- $wp_error->add('error', $error);
126
- unset($error);
127
- }
128
-
129
- if ( $current_instance['is_active'] ) {
130
- if ( $wp_error->get_error_code() ) {
131
- $errors = '';
132
- $messages = '';
133
- foreach ( $wp_error->get_error_codes() as $code ) {
134
- $severity = $wp_error->get_error_data($code);
135
- foreach ( $wp_error->get_error_messages($code) as $error ) {
136
- if ( 'message' == $severity )
137
- $messages .= ' ' . $error . "<br />\n";
138
- else
139
- $errors .= ' ' . $error . "<br />\n";
140
- }
141
- }
142
- if ( !empty($errors) )
143
- echo '<p class="error">' . apply_filters('login_errors', $errors) . "</p>\n";
144
- if ( !empty($messages) )
145
- echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
146
- }
147
- }
148
- }
149
-
150
- function wdbj_tml_get_footer($login_link = true, $register_link = true, $password_link = true) {
151
- $current_instance = wdbj_tml_get_var('current_instance');
152
-
153
- echo '<ul class="tml-links">' . "\n";
154
- if ( $login_link && $current_instance['show_log_link'] ) {
155
- $url = wdbj_tml_get_current_url('instance=' . $current_instance['instance_id']);
156
- echo '<li><a href="' . esc_url($url) . '">' . wdbj_tml_get_title('login') . '</a></li>' . "\n";
157
- }
158
- if ( $register_link && $current_instance['show_reg_link'] && get_option('users_can_register') ) {
159
- $url = ( $current_instance['register_widget'] ) ? wdbj_tml_get_current_url('action=register&instance=' . $current_instance['instance_id']) : site_url('wp-login.php?action=register', 'login');
160
- echo '<li><a href="' . esc_url($url) . '">' . wdbj_tml_get_title('register') . '</a></li>' . "\n";
161
- }
162
- if ( $password_link && $current_instance['show_pass_link'] ) {
163
- $url = ( $current_instance['lost_pass_widget'] ) ? wdbj_tml_get_current_url('action=lostpassword&instance=' . $current_instance['instance_id']) : site_url('wp-login.php?action=lostpassword', 'login');
164
- echo '<li><a href="' . esc_url($url) . '">' . wdbj_tml_get_title('lostpassword') . '</a></li>' . "\n";
165
- }
166
- echo '</ul>' . "\n";
167
- echo '</div>' . "\n";
168
- }
169
-
170
- function wdbj_tml_get_login_form() {
171
- $current_instance = wdbj_tml_get_var('current_instance');
172
-
173
- // Clear errors if loggedout is set.
174
- if ( !empty($_GET['loggedout']) )
175
- wdbj_tml_set_error();
176
-
177
- // If cookies are disabled we can't log in even with a valid user+pass
178
- if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
179
- wdbj_tml_set_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.", 'theme-my-login'));
180
-
181
- // Some parts of this script use the main login form to display a message
182
- if ( $current_instance['is_active'] ) {
183
- if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
184
- wdbj_tml_set_error('loggedout', __('You are now logged out.', 'theme-my-login'), 'message');
185
- elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
186
- wdbj_tml_set_error('registerdisabled', __('User registration is currently not allowed.', 'theme-my-login'));
187
- elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
188
- wdbj_tml_set_error('confirm', __('Check your e-mail for the confirmation link.', 'theme-my-login'), 'message');
189
- elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
190
- wdbj_tml_set_error('newpass', __('Check your e-mail for your new password.', 'theme-my-login'), 'message');
191
- elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )
192
- wdbj_tml_set_error('registered', __('Registration complete. Please check your e-mail.', 'theme-my-login'), 'message');
193
- }
194
-
195
- wdbj_tml_get_header();
196
-
197
- if ( isset($_POST['log']) )
198
- $user_login = ( wdbj_tml_get_error('incorrect_password') || wdbj_tml_get_error('empty_password') ) ? esc_attr(stripslashes($_POST['log'])) : '';
199
-
200
- $user_login = ( $current_instance['is_active'] && isset($user_login) ) ? $user_login : '';
201
-
202
- if ( ( ! ( isset($_GET['checkemail']) && $current_instance['is_active'] ) ) ||
203
- ( ! ( in_array($_GET['checkemail'], array('confirm', 'newpass') ) && $current_instance['is_active'] ) ) ) {
204
- ?>
205
- <form name="loginform" id="loginform-<?php echo $current_instance['instance_id']; ?>" action="<?php echo esc_url(wdbj_tml_get_current_url('action=login&instance=' . $current_instance['instance_id'])); ?>" method="post">
206
- <p>
207
- <label for="log-<?php echo $current_instance['instance_id']; ?>"><?php _e('Username', 'theme-my-login') ?></label>
208
- <input type="text" name="log" id="log-<?php echo $current_instance['instance_id']; ?>" class="input" value="<?php echo isset($user_login) ? $user_login : ''; ?>" size="20" />
209
- </p>
210
- <p>
211
- <label for="pwd-<?php echo $current_instance['instance_id']; ?>"><?php _e('Password', 'theme-my-login') ?></label>
212
- <input type="password" name="pwd" id="pwd-<?php echo $current_instance['instance_id']; ?>" class="input" value="" size="20" />
213
- </p>
214
- <?php do_action('login_form', $current_instance['instance_id']); ?>
215
- <p class="forgetmenot"><input name="rememberme" type="checkbox" id="rememberme-<?php echo $current_instance['instance_id']; ?>" value="forever" /> <label for="rememberme-<?php echo $current_instance['instance_id']; ?>"><?php _e('Remember Me', 'theme-my-login'); ?></label></p>
216
- <p class="submit">
217
- <input type="submit" name="wp-submit" id="wp-submit-<?php echo $current_instance['instance_id']; ?>" value="<?php _e('Log In', 'theme-my-login'); ?>" />
218
- <input type="hidden" name="redirect_to" value="<?php echo esc_attr(wdbj_tml_get_var('redirect_to')); ?>" />
219
- <input type="hidden" name="testcookie" value="1" />
220
- </p>
221
- </form>
222
- <?php
223
- }
224
- if ( $current_instance['is_active'] && isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) )
225
- $login_link = true;
226
- else
227
- $login_link = false;
228
- wdbj_tml_get_footer($login_link, true, true);
229
- }
230
-
231
- function wdbj_tml_get_register_form() {
232
- $current_instance = wdbj_tml_get_var('current_instance');
233
-
234
- $user_login = isset($_POST['user_login']) ? $_POST['user_login'] : '';
235
- $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
236
-
237
- $message = apply_filters('register_message', __('A password will be e-mailed to you.', 'theme-my-login'));
238
-
239
- wdbj_tml_get_header($message);
240
- ?>
241
- <form name="registerform" id="registerform-<?php echo $current_instance['instance_id']; ?>" action="<?php echo esc_url(wdbj_tml_get_current_url('action=register&instance=' . $current_instance['instance_id'])); ?>" method="post">
242
- <p>
243
- <label for="user_login-<?php echo $current_instance['instance_id']; ?>"><?php _e('Username', 'theme-my-login') ?></label>
244
- <input type="text" name="user_login" id="user_login-<?php echo $current_instance['instance_id']; ?>" class="input" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" />
245
- </p>
246
- <p>
247
- <label for="user_email-<?php echo $current_instance['instance_id']; ?>"><?php _e('E-mail', 'theme-my-login') ?></label>
248
- <input type="text" name="user_email" id="user_email-<?php echo $current_instance['instance_id']; ?>" class="input" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="20" />
249
- </p>
250
- <?php do_action('register_form', $current_instance['instance_id']); ?>
251
- <p class="submit">
252
- <input type="submit" name="wp-submit" id="wp-submit-<?php echo $current_instance['instance_id']; ?>" value="<?php _e('Register', 'theme-my-login'); ?>" />
253
- </p>
254
- </form>
255
- <?php
256
- wdbj_tml_get_footer(true, false, true);
257
- }
258
-
259
- function wdbj_tml_get_lost_password_form() {
260
- $current_instance = wdbj_tml_get_var('current_instance');
261
-
262
- do_action('lost_password', $current_instance['instance_id']);
263
-
264
- $message = apply_filters('lostpassword_message', __('Please enter your username or e-mail address. You will receive a new password via e-mail.', 'theme-my-login'));
265
-
266
- wdbj_tml_get_header($message);
267
-
268
- $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
269
- ?>
270
- <form name="lostpasswordform" id="lostpasswordform-<?php echo $current_instance['instance_id']; ?>" action="<?php echo esc_url(wdbj_tml_get_current_url('action=lostpassword&instance=' . $current_instance['instance_id'])); ?>" method="post">
271
- <p>
272
- <label for="user_login-<?php echo $current_instance['instance_id']; ?>"><?php _e('Username or E-mail:', 'theme-my-login') ?></label>
273
- <input type="text" name="user_login" id="user_login-<?php echo $current_instance['instance_id']; ?>" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" />
274
- </p>
275
- <?php do_action('lostpassword_form', $current_instance['instance_id']); ?>
276
- <p class="submit">
277
- <input type="submit" name="wp-submit" id="wp-submit-<?php echo $current_instance['instance_id']; ?>" value="<?php _e('Get New Password', 'theme-my-login'); ?>" />
278
- </p>
279
- </form>
280
- <?php
281
- wdbj_tml_get_footer(true, true, false);
282
- }
283
-
284
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/widget.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- if ( !class_exists('Theme_My_Login_Widget') ) :
4
- class Theme_My_Login_Widget extends WP_Widget {
5
-
6
- function Theme_My_Login_Widget(){
7
- $widget_ops = array('classname' => 'widget_theme_my_login', 'description' => __('A login form for your blog.', 'theme-my-login') );
8
- parent::WP_Widget('theme-my-login', __('Theme My Login', 'theme-my-login'), $widget_ops);
9
- }
10
-
11
- function widget($args, $instance){
12
- if ( is_user_logged_in() && !$instance['logged_in_widget'] )
13
- return;
14
- $args = array_merge($args, $instance);
15
- echo wdbj_tml_shortcode($args);
16
- }
17
-
18
- function update($new_instance, $old_instance){
19
- $instance = $old_instance;
20
- $instance['default_action'] = in_array($new_instance['default_action'], array('login', 'register', 'lostpassword')) ? $new_instance['default_action'] : 'login';
21
- $instance['logged_in_widget'] = empty($new_instance['logged_in_widget']) ? false : true;
22
- $instance['show_title'] = empty($new_instance['show_title']) ? false : true;
23
- $instance['show_log_link'] = empty($new_instance['show_log_link']) ? false: true;
24
- $instance['show_reg_link'] = empty($new_instance['show_reg_link']) ? false: true;
25
- $instance['show_pass_link'] = empty($new_instance['show_pass_link']) ? false: true;
26
- $instance['show_gravatar'] = empty($new_instance['show_gravatar']) ? false : true;
27
- $instance['gravatar_size'] = absint($new_instance['gravatar_size']);
28
- $instance['register_widget'] = empty($new_instance['register_widget']) ? false : true;
29
- $instance['lost_pass_widget'] = empty($new_instance['lost_pass_widget']) ? false : true;
30
- return $instance;
31
- }
32
-
33
- function form($instance){
34
- $defaults = array(
35
- 'default_action' => 'login',
36
- 'logged_in_widget' => 1,
37
- 'show_title' => 1,
38
- 'show_log_link' => 1,
39
- 'show_reg_link' => 1,
40
- 'show_pass_link' => 1,
41
- 'show_gravatar' => 1,
42
- 'gravatar_size' => 50,
43
- 'register_widget' => 1,
44
- 'lost_pass_widget' => 1
45
- );
46
-
47
- $instance = wp_parse_args($instance, $defaults);
48
- $actions = array('login' => 'Login', 'register' => 'Register', 'lostpassword' => 'Lost Password');
49
- echo '<p>Default Action<br /><select name="' . $this->get_field_name('default_action') . '" id="' . $this->get_field_id('default_action') . '">';
50
- foreach ($actions as $action => $title) {
51
- $is_selected = ($instance['default_action'] == $action) ? ' selected="selected"' : '';
52
- echo '<option value="' . $action . '"' . $is_selected . '>' . $title . '</option>';
53
- }
54
- echo '</select></p>' . "\n";
55
- $is_checked = (empty($instance['logged_in_widget'])) ? '' : 'checked="checked" ';
56
- echo '<p><input name="' . $this->get_field_name('logged_in_widget') . '" type="checkbox" id="' . $this->get_field_id('logged_in_widget') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('logged_in_widget') . '">' . __('Show When Logged In', 'theme-my-login') . '</label></p>' . "\n";
57
- $is_checked = (empty($instance['show_title'])) ? '' : 'checked="checked" ';
58
- echo '<p><input name="' . $this->get_field_name('show_title') . '" type="checkbox" id="' . $this->get_field_id('show_title') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('show_title') . '">' . __('Show Title', 'theme-my-login') . '</label></p>' . "\n";
59
- $is_checked = (empty($instance['show_log_link'])) ? '' : 'checked="checked" ';
60
- echo '<p><input name="' . $this->get_field_name('show_log_link') . '" type="checkbox" id="' . $this->get_field_id('show_log_link') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('show_log_link') . '">' . __('Show Login Link', 'theme-my-login') . '</label></p>' . "\n";
61
- $is_checked = (empty($instance['show_reg_link'])) ? '' : 'checked="checked" ';
62
- echo '<p><input name="' . $this->get_field_name('show_reg_link') . '" type="checkbox" id="' . $this->get_field_id('show_reg_link') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('show_reg_link') . '">' . __('Show Register Link', 'theme-my-login') . '</label></p>' . "\n";
63
- $is_checked = (empty($instance['show_pass_link'])) ? '' : 'checked="checked" ';
64
- echo '<p><input name="' . $this->get_field_name('show_pass_link') . '" type="checkbox" id="' . $this->get_field_id('show_pass_link') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('show_pass_link') . '">' . __('Show Lost Password Link', 'theme-my-login') . '</label></p>' . "\n";
65
- $is_checked = (empty($instance['show_gravatar'])) ? '' : 'checked="checked" ';
66
- echo '<p><input name="' . $this->get_field_name('show_gravatar') . '" type="checkbox" id="' . $this->get_field_id('show_gravatar') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('show_gravatar') . '">' . __('Show Gravatar', 'theme-my-login') . '</label></p>' . "\n";
67
- echo '<p>' . __('Gravatar Size', 'theme-my-login') . ': <input name="' . $this->get_field_name('gravatar_size') . '" type="text" id="' . $this->get_field_id('gravatar_size') . '" value="' . $instance['gravatar_size'] . '" size="3" /> <label for="' . $this->get_field_id('gravatar_size') . '"></label></p>' . "\n";
68
- $is_checked = (empty($instance['register_widget'])) ? '' : 'checked="checked" ';
69
- echo '<p><input name="' . $this->get_field_name('register_widget') . '" type="checkbox" id="' . $this->get_field_id('register_widget') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('register_widget') . '">' . __('Allow Registration', 'theme-my-login') . '</label></p>' . "\n";
70
- $is_checked = (empty($instance['lost_pass_widget'])) ? '' : 'checked="checked" ';
71
- echo '<p><input name="' . $this->get_field_name('lost_pass_widget') . '" type="checkbox" id="' . $this->get_field_id('lost_pass_widget') . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id('lost_pass_widget') . '">' . __('Allow Password Recovery', 'theme-my-login') . '</label></p>' . "\n";
72
- }
73
-
74
- }
75
- endif;
76
-
77
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/jquery.shake.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery.fn.shake = function( speed, loop ) {
2
+ if ( !speed || speed <= 0 )
3
+ speed = 1000;
4
+ if ( !loop || loop <= 0 )
5
+ loop = 5;
6
+
7
+ this.each( function() {
8
+ jQuery(this).css( { position: 'relative' } );
9
+ var origLeft = parseInt( jQuery(this).css( "left" ), 10 );
10
+ for ( var x = 1; x <= loop; x++ ) {
11
+ jQuery(this)
12
+ .animate( { left: origLeft - 10 }, ( ( ( speed / 4 ) / 4 ) ) )
13
+ .animate( { left: origLeft + 10 }, ( ( speed / 4 ) / 2 ) )
14
+ .animate( { left: origLeft }, ( ( ( speed / 4 ) / 4 ) ) );
15
+ }
16
+ } );
17
+ return this;
18
+ };
language/theme-my-login.pot CHANGED
@@ -1,4 +1,4 @@
1
- # Translation of the WordPress plugin Theme My Login 5.0 by Jeff Farthing.
2
  # Copyright (C) 2010 Jeff Farthing
3
  # This file is distributed under the same license as the Theme My Login package.
4
  # FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
@@ -6,9 +6,9 @@
6
  #, fuzzy
7
  msgid ""
8
  msgstr ""
9
- "Project-Id-Version: Theme My Login 5.0\n"
10
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/theme-my-login\n"
11
- "POT-Creation-Date: 2010-03-09 18:41+0000\n"
12
  "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,842 +16,1164 @@ msgstr ""
16
  "Content-Type: text/plain; charset=utf-8\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
 
19
- #: admin/includes/admin.php:4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  msgid ""
21
- "<strong>WARNING</strong>: The function <em>wp_new_user_notification</em> has "
22
- "already been overridden by another plugin. "
 
 
 
 
23
  msgstr ""
24
 
25
- #: admin/includes/admin.php:5 admin/includes/admin.php:11
26
- msgid "Some features of <em>Theme My Login</em> may not function properly."
27
  msgstr ""
28
 
29
- #: admin/includes/admin.php:10
30
  msgid ""
31
- "<strong>WARNING</strong>: The function <em>wp_password_change_notification</"
32
- "em> has already been overridden by another plugin. "
 
 
33
  msgstr ""
34
 
35
- #. #-#-#-#-# plugin.pot (Theme My Login 5.0) #-#-#-#-#
36
- #. Plugin Name of a plugin/theme
37
- #: admin/includes/admin.php:17 includes/widget.php:8
38
- msgid "Theme My Login"
 
39
  msgstr ""
40
 
41
- #: admin/includes/admin.php:103
42
- #, php-format
43
- msgid "ERROR: The module \"$module\" could not be activated (%s)."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  msgstr ""
45
 
46
- #: admin/includes/module.php:68
47
- msgid "One of the plugins is invalid."
 
 
48
  msgstr ""
49
 
50
- #: admin/includes/module.php:75
51
- msgid "Invalid plugin path."
52
  msgstr ""
53
 
54
- #: admin/includes/module.php:77
55
- msgid "Plugin file does not exist."
56
  msgstr ""
57
 
58
- #: admin/includes/module.php:81
59
- msgid "The plugin does not have a valid header."
60
  msgstr ""
61
 
62
- #: admin/options-basic.php:3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  msgid "Page ID"
64
  msgstr ""
65
 
66
- #: admin/options-basic.php:6
67
  msgid ""
68
  "This should be the ID of the WordPress page that includes the [theme-my-"
69
  "login] shortcode. By default, this page is titled \"Login\"."
70
  msgstr ""
71
 
72
- #: admin/options-basic.php:10
73
  msgid "Pagelist"
74
  msgstr ""
75
 
76
- #: admin/options-basic.php:13
77
  msgid "Show Page In Pagelist"
78
  msgstr ""
79
 
80
- #: admin/options-basic.php:14
81
  msgid ""
82
  "Enable this setting to add login/logout links to the pagelist generated by "
83
  "functions like wp_list_pages() and wp_page_menu()."
84
  msgstr ""
85
 
86
- #: admin/options-basic.php:18
87
- msgid "Links"
88
  msgstr ""
89
 
90
- #: admin/options-basic.php:21
91
- msgid "Rewrite Login Links"
92
  msgstr ""
93
 
94
- #: admin/options-basic.php:22
95
  msgid ""
96
- "Enable this setting to rewrite links generated by functions like wp_loginout"
97
- "() and wp_register()."
98
  msgstr ""
99
 
100
- #: admin/options-basic.php:26
101
- msgid "Stylesheet"
 
102
  msgstr ""
103
 
104
- #: admin/options-basic.php:29
105
- msgid "Enable \"theme-my-login.css\""
106
  msgstr ""
107
 
108
- #: admin/options-basic.php:30
109
- msgid ""
110
- "In order to keep changes between upgrades, you can store your customized "
111
- "\"theme-my-login.css\" in your current theme directory."
112
  msgstr ""
113
 
114
- #: admin/options-modules.php:3 admin/options.php:6
115
- msgid "Modules"
116
  msgstr ""
117
 
118
- #: admin/options-modules.php:8
 
 
 
 
 
 
 
 
119
  #, php-format
120
- msgid "Enable %s"
121
  msgstr ""
122
 
123
- #: admin/options-modules.php:10
124
- msgid "No modules found."
 
 
 
 
 
 
125
  msgstr ""
126
 
127
- #: admin/options-optimization.php:3 admin/options.php:7
128
- msgid "Optimization"
 
129
  msgstr ""
130
 
131
- #: admin/options-optimization.php:6
132
- msgid "Enable Template Tag"
 
133
  msgstr ""
134
 
135
- #: admin/options-optimization.php:7
136
- msgid ""
137
- "Enable this setting if you wish to use the theme_my_login() template tag. "
138
- "Otherwise, leave it disabled for optimization purposes."
 
 
 
 
139
  msgstr ""
140
 
141
- #: admin/options-optimization.php:10
142
- msgid "Enable Widget"
143
  msgstr ""
144
 
145
- #: admin/options-optimization.php:11
146
  msgid ""
147
- "Enable this setting if you wish to use the \"Theme My Login\" widget. "
148
- "Otherwise, leave it disabled for optimization purposes."
149
  msgstr ""
150
 
151
- #: admin/options.php:4 modules/custom-email/admin/admin.php:6
152
- msgid "General"
153
  msgstr ""
154
 
155
- #: admin/options.php:5
156
- msgid "Basic"
157
  msgstr ""
158
 
159
- #: admin/options.php:15
160
- msgid ""
161
- "If you like this plugin, please help keep it up to date by <a href=\"http://"
162
- "www.jfarthing.com/donate\">donating through PayPal</a>!"
163
  msgstr ""
164
 
165
- #: admin/options.php:20
166
- msgid "Theme My Login Settings"
167
  msgstr ""
168
 
169
- #: admin/options.php:26 admin/options.php:84
170
- msgid "Save Changes"
171
  msgstr ""
172
 
173
- #: includes/hook-functions.php:64
174
- msgid "Log Out"
175
  msgstr ""
176
 
177
- #: includes/hook-functions.php:66 includes/template-functions.php:102
178
- #: includes/template-functions.php:217
179
- msgid "Log In"
180
  msgstr ""
181
 
182
- #: includes/login-actions.php:48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  msgid "Sorry, that key does not appear to be valid."
184
  msgstr ""
185
 
186
- #: includes/login-functions.php:16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  msgid "<strong>ERROR</strong>: Enter a username or e-mail address."
188
  msgstr ""
189
 
190
- #: includes/login-functions.php:21
191
  msgid ""
192
  "<strong>ERROR</strong>: There is no user registered with that email address."
193
  msgstr ""
194
 
195
- #: includes/login-functions.php:33
196
  msgid "<strong>ERROR</strong>: Invalid username or e-mail."
197
  msgstr ""
198
 
199
- #: includes/login-functions.php:47
200
  msgid "Password reset is not allowed for this user"
201
  msgstr ""
202
 
203
- #: includes/login-functions.php:59
204
  msgid ""
205
  "Someone has asked to reset the password for the following site and username."
206
  msgstr ""
207
 
208
- #: includes/login-functions.php:61 includes/login-functions.php:110
209
- #: includes/pluggable-functions.php:56 includes/pluggable-functions.php:71
210
- #: modules/custom-passwords/includes/functions.php:37
211
- #: modules/user-moderation/includes/functions.php:87
212
- #: modules/user-moderation/includes/functions.php:150
 
213
  #, php-format
214
  msgid "Username: %s"
215
  msgstr ""
216
 
217
- #: includes/login-functions.php:62
218
  msgid ""
219
  "To reset your password visit the following address, otherwise just ignore "
220
  "this email and nothing will happen."
221
  msgstr ""
222
 
223
- #: includes/login-functions.php:69
224
  #, php-format
225
  msgid "[%s] Password Reset"
226
  msgstr ""
227
 
228
- #: includes/login-functions.php:75 includes/login-functions.php:124
229
- #: modules/custom-passwords/includes/functions.php:51
230
- #: modules/user-moderation/admin/admin.php:59
231
- #: modules/user-moderation/includes/functions.php:97
 
 
232
  msgid "The e-mail could not be sent."
233
  msgstr ""
234
 
235
- #: includes/login-functions.php:75 includes/login-functions.php:124
236
- #: modules/custom-passwords/includes/functions.php:51
237
- #: modules/user-moderation/admin/admin.php:59
238
- #: modules/user-moderation/includes/functions.php:97
 
 
239
  msgid "Possible reason: your host may have disabled the mail() function..."
240
  msgstr ""
241
 
242
- #: includes/login-functions.php:94 includes/login-functions.php:97
243
- #: includes/login-functions.php:101
244
- #: modules/custom-passwords/includes/functions.php:9
245
- #: modules/custom-passwords/includes/functions.php:12
246
- #: modules/custom-passwords/includes/functions.php:16
247
- #: modules/user-moderation/includes/functions.php:17
248
- #: modules/user-moderation/includes/functions.php:20
249
- #: modules/user-moderation/includes/functions.php:24
250
  msgid "Invalid key"
251
  msgstr ""
252
 
253
- #: includes/login-functions.php:111 includes/pluggable-functions.php:72
254
- #: modules/custom-passwords/includes/functions.php:38
255
- #: modules/user-moderation/includes/functions.php:88
 
256
  #, php-format
257
  msgid "Password: %s"
258
  msgstr ""
259
 
260
- #: includes/login-functions.php:118
261
- #: modules/custom-passwords/includes/functions.php:45
262
  #, php-format
263
  msgid "[%s] Your new password"
264
  msgstr ""
265
 
266
- #: includes/login-functions.php:146
267
  msgid "<strong>ERROR</strong>: Please enter a username."
268
  msgstr ""
269
 
270
- #: includes/login-functions.php:148
271
  msgid ""
272
- "<strong>ERROR</strong>: This username is invalid. Please enter a valid "
273
- "username."
274
  msgstr ""
275
 
276
- #: includes/login-functions.php:151
277
  msgid ""
278
  "<strong>ERROR</strong>: This username is already registered, please choose "
279
  "another one."
280
  msgstr ""
281
 
282
- #: includes/login-functions.php:155
283
  msgid "<strong>ERROR</strong>: Please type your e-mail address."
284
  msgstr ""
285
 
286
- #: includes/login-functions.php:157
287
  msgid "<strong>ERROR</strong>: The email address isn&#8217;t correct."
288
  msgstr ""
289
 
290
- #: includes/login-functions.php:160
291
  msgid ""
292
  "<strong>ERROR</strong>: This email is already registered, please choose "
293
  "another one."
294
  msgstr ""
295
 
296
- #: includes/login-functions.php:176
297
  #, php-format
298
  msgid ""
299
  "<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a "
300
  "href=\"mailto:%s\">webmaster</a> !"
301
  msgstr ""
302
 
303
- #: includes/pluggable-functions.php:17
304
- #, php-format
305
- msgid "Password Lost and Changed for user: %s"
 
306
  msgstr ""
307
 
308
- #: includes/pluggable-functions.php:22
309
- #, php-format
310
- msgid "[%s] Password Lost/Changed"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  msgstr ""
312
 
313
- #: includes/pluggable-functions.php:55
 
 
 
 
 
 
 
 
 
 
 
 
314
  #, php-format
315
- msgid "New user registration on your blog %s:"
316
  msgstr ""
317
 
318
- #: includes/pluggable-functions.php:57
319
- #: modules/user-moderation/includes/functions.php:151
320
  #, php-format
321
  msgid "E-mail: %s"
322
  msgstr ""
323
 
324
- #: includes/pluggable-functions.php:59
325
  #, php-format
326
  msgid "[%s] New User Registration"
327
  msgstr ""
328
 
329
- #: includes/pluggable-functions.php:75
330
  #, php-format
331
  msgid "[%s] Your username and password"
332
  msgstr ""
333
 
334
- #: includes/template-functions.php:23
335
- #: modules/custom-user-links/custom-user-links.php:57
336
- msgid "Dashboard"
337
  msgstr ""
338
 
339
- #: includes/template-functions.php:24
340
- #: modules/custom-user-links/custom-user-links.php:58
341
- msgid "Profile"
342
  msgstr ""
343
 
344
- #: includes/template-functions.php:32
345
- #: modules/custom-redirection/admin/admin.php:29
346
- msgid "Log out"
347
  msgstr ""
348
 
349
- #: includes/template-functions.php:88
350
- #, php-format
351
- msgid "Welcome, %s"
352
  msgstr ""
353
 
354
- #: includes/template-functions.php:92 includes/template-functions.php:252
355
- msgid "Register"
356
  msgstr ""
357
 
358
- #: includes/template-functions.php:98
359
- msgid "Lost Password"
360
  msgstr ""
361
 
362
- #: includes/template-functions.php:179
363
  msgid ""
364
- "<strong>ERROR</strong>: Cookies are blocked or not supported by your "
365
- "browser. You must <a href='http://www.google.com/cookies.html'>enable "
366
- "cookies</a> to use WordPress."
367
  msgstr ""
368
 
369
- #: includes/template-functions.php:184
370
- msgid "You are now logged out."
 
 
371
  msgstr ""
372
 
373
- #: includes/template-functions.php:186
374
- msgid "User registration is currently not allowed."
375
  msgstr ""
376
 
377
- #: includes/template-functions.php:188
378
- msgid "Check your e-mail for the confirmation link."
379
  msgstr ""
380
 
381
- #: includes/template-functions.php:190
382
- msgid "Check your e-mail for your new password."
383
  msgstr ""
384
 
385
- #: includes/template-functions.php:192
386
- msgid "Registration complete. Please check your e-mail."
387
  msgstr ""
388
 
389
- #: includes/template-functions.php:207 includes/template-functions.php:243
390
- #: modules/themed-profiles/includes/template-functions.php:33
391
- msgid "Username"
392
  msgstr ""
393
 
394
- #: includes/template-functions.php:211
395
- msgid "Password"
 
396
  msgstr ""
397
 
398
- #: includes/template-functions.php:215
399
- msgid "Remember Me"
 
400
  msgstr ""
401
 
402
- #: includes/template-functions.php:237
403
- msgid "A password will be e-mailed to you."
 
404
  msgstr ""
405
 
406
- #: includes/template-functions.php:247 modules/custom-email/admin/admin.php:5
407
- #: modules/themed-profiles/includes/template-functions.php:86
408
- msgid "E-mail"
 
409
  msgstr ""
410
 
411
- #: includes/template-functions.php:264
 
412
  msgid ""
413
- "Please enter your username or e-mail address. You will receive a new "
414
- "password via e-mail."
415
  msgstr ""
416
 
417
- #: includes/template-functions.php:272
418
- msgid "Username or E-mail:"
 
 
419
  msgstr ""
420
 
421
- #: includes/template-functions.php:277
422
- msgid "Get New Password"
 
 
 
423
  msgstr ""
424
 
425
- #: includes/widget.php:7
426
- msgid "A login form for your blog."
427
  msgstr ""
428
 
429
- #: includes/widget.php:56
430
- msgid "Show When Logged In"
 
 
431
  msgstr ""
432
 
433
- #: includes/widget.php:58
434
- msgid "Show Title"
 
 
435
  msgstr ""
436
 
437
- #: includes/widget.php:60
438
- msgid "Show Login Link"
439
  msgstr ""
440
 
441
- #: includes/widget.php:62
442
- msgid "Show Register Link"
443
  msgstr ""
444
 
445
- #: includes/widget.php:64
446
- msgid "Show Lost Password Link"
447
  msgstr ""
448
 
449
- #: includes/widget.php:66
450
- msgid "Show Gravatar"
451
  msgstr ""
452
 
453
- #: includes/widget.php:67
454
- msgid "Gravatar Size"
 
 
 
455
  msgstr ""
456
 
457
- #: includes/widget.php:69
458
- msgid "Allow Registration"
459
  msgstr ""
460
 
461
- #: includes/widget.php:71
462
- msgid "Allow Password Recovery"
463
  msgstr ""
464
 
465
- #: modules/custom-email/admin/admin.php:7
466
- msgid "New User"
467
  msgstr ""
468
 
469
- #: modules/custom-email/admin/admin.php:8
470
- msgid "Retrieve Password"
471
  msgstr ""
472
 
473
- #: modules/custom-email/admin/admin.php:9
474
- msgid "Reset Password"
475
  msgstr ""
476
 
477
- #: modules/custom-email/admin/options-general.php:4
478
- msgid "From Name"
479
  msgstr ""
480
 
481
- #: modules/custom-email/admin/options-general.php:10
482
- msgid "From E-mail"
483
  msgstr ""
484
 
485
- #: modules/custom-email/admin/options-general.php:16
486
- msgid "E-mail Format"
487
  msgstr ""
488
 
489
- #: modules/custom-email/admin/options-new-user.php:4
490
- #: modules/custom-email/admin/options-reset-pass.php:4
491
- #: modules/custom-email/admin/options-retrieve-pass.php:4
492
- #: modules/user-moderation/admin/options-user-activation-email.php:4
493
- #: modules/user-moderation/admin/options-user-approval-email.php:4
494
- #: modules/user-moderation/admin/options-user-denial-email.php:4
495
- msgid "Available Variables"
496
  msgstr ""
497
 
498
- #: modules/custom-email/admin/options-new-user.php:5
499
- #: modules/custom-email/admin/options-reset-pass.php:5
500
- #: modules/custom-email/admin/options-retrieve-pass.php:5
501
- #: modules/user-moderation/admin/options-user-activation-email.php:5
502
- #: modules/user-moderation/admin/options-user-approval-email.php:5
503
- #: modules/user-moderation/admin/options-user-denial-email.php:5
504
- msgid "Subject"
505
  msgstr ""
506
 
507
- #: modules/custom-email/admin/options-new-user.php:7
508
- #: modules/custom-email/admin/options-reset-pass.php:7
509
- #: modules/custom-email/admin/options-retrieve-pass.php:7
510
- #: modules/user-moderation/admin/options-user-activation-email.php:7
511
- #: modules/user-moderation/admin/options-user-approval-email.php:7
512
- #: modules/user-moderation/admin/options-user-denial-email.php:7
513
- msgid "Message"
514
  msgstr ""
515
 
516
- #: modules/custom-email/admin/options-reset-pass.php:10
517
- msgid "Disable Admin Notification"
518
  msgstr ""
519
 
520
- #: modules/custom-passwords/includes/hook-functions.php:5
521
- msgid "Password:"
 
522
  msgstr ""
523
 
524
- #: modules/custom-passwords/includes/hook-functions.php:7
525
- #: modules/custom-passwords/includes/hook-functions.php:66
526
- msgid "Confirm Password:"
527
  msgstr ""
528
 
529
- #: modules/custom-passwords/includes/hook-functions.php:14
530
- msgid "<strong>ERROR</strong>: Please enter a password."
531
  msgstr ""
532
 
533
- #: modules/custom-passwords/includes/hook-functions.php:16
534
- msgid "<strong>ERROR</strong>: Your passwords do not match."
 
 
535
  msgstr ""
536
 
537
- #: modules/custom-passwords/includes/hook-functions.php:18
538
- msgid ""
539
- "<strong>ERROR</strong>: Your password must be at least 6 characters in "
540
- "length."
541
  msgstr ""
542
 
543
- #: modules/custom-passwords/includes/hook-functions.php:54
544
- msgid "Please enter a new password."
545
  msgstr ""
546
 
547
- #: modules/custom-passwords/includes/hook-functions.php:62
548
- msgid "New Password:"
549
  msgstr ""
550
 
551
- #: modules/custom-passwords/includes/hook-functions.php:71
552
- msgid "Change Password"
553
  msgstr ""
554
 
555
- #: modules/custom-passwords/includes/hook-functions.php:102
556
- msgid ""
557
- "Please enter your username or e-mail address. You will receive an e-mail "
558
- "with a link to reset your password."
559
  msgstr ""
560
 
561
- #: modules/custom-passwords/includes/hook-functions.php:108
562
- msgid "Registration complete. You may now log in."
563
  msgstr ""
564
 
565
- #: modules/custom-passwords/includes/hook-functions.php:110
566
- msgid "Your password has been saved. You may now log in."
567
  msgstr ""
568
 
569
- #: modules/custom-redirection/admin/admin.php:6
570
- msgid "Redirection"
571
  msgstr ""
572
 
573
- #: modules/custom-redirection/admin/admin.php:20
574
- msgid "Log in"
 
575
  msgstr ""
576
 
577
- #: modules/custom-redirection/admin/admin.php:22
578
- #: modules/custom-redirection/admin/admin.php:31
579
- msgid "Default"
580
  msgstr ""
581
 
582
- #: modules/custom-redirection/admin/admin.php:23
583
- #: modules/custom-redirection/admin/admin.php:32
584
- msgid "Referer"
585
  msgstr ""
586
 
587
- #: modules/custom-user-links/admin/admin.php:6
588
- msgid "User Links"
 
589
  msgstr ""
590
 
591
- #: modules/custom-user-links/admin/admin.php:103
592
- #: modules/custom-user-links/admin/admin.php:119
593
- #: modules/custom-user-links/admin/admin.php:150
594
- #: modules/custom-user-links/admin/admin.php:167
595
- msgid "Title"
596
  msgstr ""
597
 
598
- #: modules/custom-user-links/admin/admin.php:104
599
- #: modules/custom-user-links/admin/admin.php:120
600
- #: modules/custom-user-links/admin/admin.php:154
601
- #: modules/custom-user-links/admin/admin.php:168
602
- msgid "URL"
603
  msgstr ""
604
 
605
- #: modules/custom-user-links/admin/admin.php:156
606
- msgid "Delete"
607
  msgstr ""
608
 
609
- #: modules/custom-user-links/admin/admin.php:157
610
- msgid "Update"
611
  msgstr ""
612
 
613
- #: modules/custom-user-links/admin/admin.php:163
614
- msgid "Add New link:"
615
  msgstr ""
616
 
617
- #: modules/custom-user-links/admin/admin.php:179
618
- msgid "Add link"
619
  msgstr ""
620
 
621
- #: modules/themed-profiles/includes/hook-functions.php:22
622
- msgid "Your Profile"
623
  msgstr ""
624
 
625
- #: modules/themed-profiles/includes/template-functions.php:21
626
- msgid "Personal Options"
627
  msgstr ""
628
 
629
- #: modules/themed-profiles/includes/template-functions.php:29
630
- msgid "Name"
631
  msgstr ""
632
 
633
- #: modules/themed-profiles/includes/template-functions.php:34
634
- msgid "Your username cannot be changed."
 
 
635
  msgstr ""
636
 
637
- #: modules/themed-profiles/includes/template-functions.php:38
638
- msgid "First name"
639
  msgstr ""
640
 
641
- #: modules/themed-profiles/includes/template-functions.php:43
642
- msgid "Last name"
 
 
643
  msgstr ""
644
 
645
- #: modules/themed-profiles/includes/template-functions.php:48
646
- msgid "Nickname"
 
 
647
  msgstr ""
648
 
649
- #: modules/themed-profiles/includes/template-functions.php:48
650
- #: modules/themed-profiles/includes/template-functions.php:86
651
- msgid "(required)"
 
652
  msgstr ""
653
 
654
- #: modules/themed-profiles/includes/template-functions.php:53
655
- msgid "Display name publicly as"
 
 
656
  msgstr ""
657
 
658
- #: modules/themed-profiles/includes/template-functions.php:82
659
- msgid "Contact Info"
 
 
 
660
  msgstr ""
661
 
662
- #: modules/themed-profiles/includes/template-functions.php:91
663
- msgid "Website"
 
 
 
664
  msgstr ""
665
 
666
- #: modules/themed-profiles/includes/template-functions.php:108
667
- msgid "About Yourself"
 
 
 
668
  msgstr ""
669
 
670
- #: modules/themed-profiles/includes/template-functions.php:112
671
- msgid "Biographical Info"
672
  msgstr ""
673
 
674
- #: modules/themed-profiles/includes/template-functions.php:114
 
 
 
 
 
 
675
  msgid ""
676
- "Share a little biographical information to fill out your profile. This may "
677
- "be shown publicly."
678
  msgstr ""
679
 
680
- #: modules/themed-profiles/includes/template-functions.php:122
681
- msgid "New Password"
 
682
  msgstr ""
683
 
684
- #: modules/themed-profiles/includes/template-functions.php:123
685
- msgid ""
686
- "If you would like to change the password type a new one. Otherwise leave "
687
- "this blank."
688
  msgstr ""
689
 
690
- #: modules/themed-profiles/includes/template-functions.php:124
691
- msgid "Type your new password again."
692
  msgstr ""
693
 
694
- #: modules/themed-profiles/includes/template-functions.php:125
695
- msgid "Strength indicator"
 
 
 
696
  msgstr ""
697
 
698
- #: modules/themed-profiles/includes/template-functions.php:126
699
  msgid ""
700
- "Hint: The password should be at least seven characters long. To make it "
701
- "stronger, use upper and lower case letters, numbers and symbols like ! \" ? "
702
- "$ % ^ &amp; )."
703
  msgstr ""
704
 
705
- #: modules/themed-profiles/includes/template-functions.php:140
706
- msgid "Additional Capabilities"
707
  msgstr ""
708
 
709
- #: modules/themed-profiles/includes/template-functions.php:160
710
- msgid "Update Profile"
 
711
  msgstr ""
712
 
713
- #: modules/themed-profiles/themed-profiles.php:45
714
- msgid "You do not have permission to edit this user."
715
  msgstr ""
716
 
717
- #: modules/user-moderation/admin/admin.php:12
718
- #: modules/user-moderation/admin/admin.php:15
719
- #: modules/user-moderation/admin/admin.php:21
720
- msgid "You can&#8217;t edit that user."
721
  msgstr ""
722
 
723
- #: modules/user-moderation/admin/admin.php:52
724
- #, php-format
725
- msgid "You have been denied access to %s"
 
726
  msgstr ""
727
 
728
- #: modules/user-moderation/admin/admin.php:53
729
- #, php-format
730
- msgid "[%s] Registration Denied"
731
  msgstr ""
732
 
733
- #: modules/user-moderation/admin/admin.php:63
734
- msgid "Moderation"
735
  msgstr ""
736
 
737
- #: modules/user-moderation/admin/admin.php:66
738
- msgid "User Activation"
739
  msgstr ""
740
 
741
- #: modules/user-moderation/admin/admin.php:67
742
- msgid "User Approval"
743
  msgstr ""
744
 
745
- #: modules/user-moderation/admin/admin.php:68
746
- msgid "User Denial"
747
  msgstr ""
748
 
749
- #: modules/user-moderation/admin/admin.php:77
750
- msgid "User Moderation"
751
  msgstr ""
752
 
753
- #: modules/user-moderation/admin/admin.php:80
754
- msgid "None"
755
  msgstr ""
756
 
757
- #: modules/user-moderation/admin/admin.php:83
758
- msgid "E-mail Confirmation"
759
  msgstr ""
760
 
761
- #: modules/user-moderation/admin/admin.php:86
762
- msgid "Admin Approval"
763
  msgstr ""
764
 
765
- #: modules/user-moderation/includes/functions.php:41
766
- #: modules/user-moderation/includes/functions.php:76
767
- msgid "Same as when you signed up."
768
  msgstr ""
769
 
770
- #: modules/user-moderation/includes/functions.php:86
771
- #, php-format
772
- msgid "You have been approved access to %s"
773
  msgstr ""
774
 
775
- #: modules/user-moderation/includes/functions.php:91
776
- #, php-format
777
- msgid "[%s] Registration Approved"
778
  msgstr ""
779
 
780
- #: modules/user-moderation/includes/functions.php:126
781
- #, php-format
782
- msgid "[%s] Activate Your Account"
783
  msgstr ""
784
 
785
- #: modules/user-moderation/includes/functions.php:127
786
- #, php-format
787
- msgid ""
788
- "Thanks for registering at %s! To complete the activation of your account "
789
- "please click the following link: "
790
  msgstr ""
791
 
792
- #: modules/user-moderation/includes/functions.php:149
793
- #, php-format
794
- msgid "New user requires approval on your blog %s:"
795
  msgstr ""
796
 
797
- #: modules/user-moderation/includes/functions.php:152
798
- msgid "To approve or deny this user:"
799
  msgstr ""
800
 
801
- #: modules/user-moderation/includes/functions.php:155
802
- #, php-format
803
- msgid "[%s] New User Awaiting Approval"
804
  msgstr ""
805
 
806
- #: modules/user-moderation/includes/hook-functions.php:30
807
- msgid "<strong>ERROR</strong>: You have not yet confirmed your e-mail address."
 
 
808
  msgstr ""
809
 
810
- #: modules/user-moderation/includes/hook-functions.php:32
811
- msgid "<strong>ERROR</strong>: Your registration has not yet been approved."
812
  msgstr ""
813
 
814
- #: modules/user-moderation/user-moderation.php:30
815
  msgid ""
816
- "Your registration was successful but you must now confirm your email address "
817
- "before you can log in. Please check your email and click on the link "
818
- "provided."
 
 
 
819
  msgstr ""
820
 
821
- #: modules/user-moderation/user-moderation.php:32
822
  msgid ""
823
- "Your registration was successful but you must now be approved by an "
824
- "administrator before you can log in. You will be notified by e-mail once "
825
- "your account has been reviewed."
826
  msgstr ""
827
 
828
- #: modules/user-moderation/user-moderation.php:35
829
- msgid "Your account has been activated. You may now log in."
830
  msgstr ""
831
 
832
- #: modules/user-moderation/user-moderation.php:37
833
- msgid ""
834
- "Your account has been activated. Please check your e-mail for your password."
835
  msgstr ""
836
 
837
- #: modules/user-moderation/user-moderation.php:41
838
- msgid "<strong>ERROR</strong>: Sorry, that key does not appear to be valid."
 
 
 
 
 
 
 
 
839
  msgstr ""
840
 
841
- #. Plugin URI of a plugin/theme
842
- msgid "http://www.jfarthing.com/wordpress-plugins/theme-my-login-plugin"
843
  msgstr ""
844
 
845
- #. Description of a plugin/theme
846
  msgid ""
847
  "Themes the WordPress login, registration and forgot password pages according "
848
  "to your theme."
849
  msgstr ""
850
 
851
- #. Author of a plugin/theme
852
  msgid "Jeff Farthing"
853
  msgstr ""
854
 
855
- #. Author URI of a plugin/theme
856
  msgid "http://www.jfarthing.com"
857
  msgstr ""
1
+ # Translation of the WordPress plugin Theme My Login 6.0 by Jeff Farthing.
2
  # Copyright (C) 2010 Jeff Farthing
3
  # This file is distributed under the same license as the Theme My Login package.
4
  # FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
6
  #, fuzzy
7
  msgid ""
8
  msgstr ""
9
+ "Project-Id-Version: Theme My Login 6.0\n"
10
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/theme-my-login\n"
11
+ "POT-Creation-Date: 2010-09-08 23:46+0000\n"
12
  "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
16
  "Content-Type: text/plain; charset=utf-8\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
 
19
+ #. #-#-#-#-# plugin.pot (Theme My Login 6.0) #-#-#-#-#
20
+ #. Plugin Name of the plugin/theme
21
+ #: admin/class-theme-my-login-admin.php:51
22
+ #: admin/class-theme-my-login-admin.php:52
23
+ #: includes/class-theme-my-login-widget.php:24
24
+ msgid "Theme My Login"
25
+ msgstr ""
26
+
27
+ #: admin/class-theme-my-login-admin.php:88
28
+ #, php-format
29
+ msgid "ERROR: The module \"%1$s\" could not be activated (%2$s)."
30
+ msgstr ""
31
+
32
+ #: admin/class-theme-my-login-admin.php:108
33
+ msgid "NOTICE:"
34
+ msgstr ""
35
+
36
+ #: admin/class-theme-my-login-admin.php:109
37
+ #, php-format
38
  msgid ""
39
+ "Now that you have activated Theme My Login, please <a href=\"%s\">visit the "
40
+ "settings page</a> and familiarize yourself with all of the available options."
41
+ msgstr ""
42
+
43
+ #: admin/class-theme-my-login-admin.php:111
44
+ msgid "Take me to the settings page"
45
  msgstr ""
46
 
47
+ #: admin/class-theme-my-login-admin.php:124
48
+ msgid "You can now login with your e-mail address or username! Try it out!"
49
  msgstr ""
50
 
51
+ #: admin/class-theme-my-login-admin.php:125
52
  msgid ""
53
+ "Theme My Login now utilizes a module system. Modules are similar to "
54
+ "WordPress plugins. Each module extends the default functionality of Theme My "
55
+ "Login. <a rel=\"tml-options\" href=\"#tml-modules\">Click here</a> to get "
56
+ "started with modules now."
57
  msgstr ""
58
 
59
+ #: admin/class-theme-my-login-admin.php:126
60
+ msgid ""
61
+ "Theme My Login now allows custom forms. You can create your own form template"
62
+ "(s) by copying the default version(s) from \"theme-my-login/templates\" to "
63
+ "your current theme directory. Try it out!"
64
  msgstr ""
65
 
66
+ #: admin/class-theme-my-login-admin.php:127
67
+ msgid ""
68
+ "You can maintain your stylesheet changes between upgrades. Just simply copy "
69
+ "the file \"theme-my-login/theme-my-login.css\" to your current theme "
70
+ "directory and edit it as you please!"
71
+ msgstr ""
72
+
73
+ #: admin/class-theme-my-login-admin.php:128
74
+ msgid ""
75
+ "Theme My Login provides a shortcode that you can use within your posts with "
76
+ "multiple parameters to customize the form. Visit the <a href=\"http://www."
77
+ "jfarthing.com/docs/theme-my-login/shortcode\" target=\"_blank\">Theme My "
78
+ "Login Documentation</a> for usage instructions."
79
+ msgstr ""
80
+
81
+ #: admin/class-theme-my-login-admin.php:129
82
+ msgid ""
83
+ "Theme My Login is <em>FREE</em> but Jeff sure appreciates <a href=\"http://"
84
+ "www.jfarthing.com/donate\" target=\"_blank\">donations</a>!"
85
  msgstr ""
86
 
87
+ #: admin/class-theme-my-login-admin.php:130
88
+ msgid ""
89
+ "Jeff is <a href=\"http://www.jfarthing.com/hire-me\" target=\"_blank"
90
+ "\">available for hire</a>!"
91
  msgstr ""
92
 
93
+ #: admin/class-theme-my-login-admin.php:134
94
+ msgid "Did You Know?"
95
  msgstr ""
96
 
97
+ #: admin/class-theme-my-login-admin.php:174
98
+ msgid "General"
99
  msgstr ""
100
 
101
+ #: admin/class-theme-my-login-admin.php:175
102
+ msgid "Basic"
103
  msgstr ""
104
 
105
+ #: admin/class-theme-my-login-admin.php:176
106
+ #: admin/class-theme-my-login-admin.php:304
107
+ msgid "Modules"
108
+ msgstr ""
109
+
110
+ #: admin/class-theme-my-login-admin.php:183
111
+ msgid "Theme My Login Settings"
112
+ msgstr ""
113
+
114
+ #: admin/class-theme-my-login-admin.php:189
115
+ #: admin/class-theme-my-login-admin.php:246
116
+ msgid "Save Changes"
117
+ msgstr ""
118
+
119
+ #: admin/class-theme-my-login-admin.php:265
120
  msgid "Page ID"
121
  msgstr ""
122
 
123
+ #: admin/class-theme-my-login-admin.php:268
124
  msgid ""
125
  "This should be the ID of the WordPress page that includes the [theme-my-"
126
  "login] shortcode. By default, this page is titled \"Login\"."
127
  msgstr ""
128
 
129
+ #: admin/class-theme-my-login-admin.php:272
130
  msgid "Pagelist"
131
  msgstr ""
132
 
133
+ #: admin/class-theme-my-login-admin.php:275
134
  msgid "Show Page In Pagelist"
135
  msgstr ""
136
 
137
+ #: admin/class-theme-my-login-admin.php:276
138
  msgid ""
139
  "Enable this setting to add login/logout links to the pagelist generated by "
140
  "functions like wp_list_pages() and wp_page_menu()."
141
  msgstr ""
142
 
143
+ #: admin/class-theme-my-login-admin.php:280
144
+ msgid "Stylesheet"
145
  msgstr ""
146
 
147
+ #: admin/class-theme-my-login-admin.php:283
148
+ msgid "Enable \"theme-my-login.css\""
149
  msgstr ""
150
 
151
+ #: admin/class-theme-my-login-admin.php:284
152
  msgid ""
153
+ "In order to keep changes between upgrades, you can store your customized "
154
+ "\"theme-my-login.css\" in your current theme directory."
155
  msgstr ""
156
 
157
+ #: admin/class-theme-my-login-admin.php:308
158
+ #, php-format
159
+ msgid "Enable %s"
160
  msgstr ""
161
 
162
+ #: admin/class-theme-my-login-admin.php:310
163
+ msgid "No modules found."
164
  msgstr ""
165
 
166
+ #: admin/class-theme-my-login-admin.php:421
167
+ msgid "One of the modules is invalid."
 
 
168
  msgstr ""
169
 
170
+ #: admin/class-theme-my-login-admin.php:474
171
+ msgid "Invalid module path."
172
  msgstr ""
173
 
174
+ #: admin/class-theme-my-login-admin.php:476
175
+ msgid "Module file does not exist."
176
+ msgstr ""
177
+
178
+ #: admin/class-theme-my-login-admin.php:480
179
+ msgid "The module does not have a valid header."
180
+ msgstr ""
181
+
182
+ #: includes/class-theme-my-login-template.php:140
183
  #, php-format
184
+ msgid "Welcome, %s"
185
  msgstr ""
186
 
187
+ #: includes/class-theme-my-login-template.php:144
188
+ #: includes/class-theme-my-login-widget.php:86 templates/register-form.php:25
189
+ msgid "Register"
190
+ msgstr ""
191
+
192
+ #: includes/class-theme-my-login-template.php:150
193
+ #: includes/class-theme-my-login-widget.php:86
194
+ msgid "Lost Password"
195
  msgstr ""
196
 
197
+ #: includes/class-theme-my-login-template.php:154
198
+ #: includes/class-theme-my-login.php:390 templates/login-form.php:28
199
+ msgid "Log In"
200
  msgstr ""
201
 
202
+ #: includes/class-theme-my-login-template.php:316
203
+ #: modules/custom-user-links/custom-user-links.php:92
204
+ msgid "Dashboard"
205
  msgstr ""
206
 
207
+ #: includes/class-theme-my-login-template.php:317
208
+ #: modules/custom-user-links/custom-user-links.php:93
209
+ msgid "Profile"
210
+ msgstr ""
211
+
212
+ #: includes/class-theme-my-login-template.php:334
213
+ #: modules/custom-redirection/custom-redirection.php:175
214
+ msgid "Log out"
215
  msgstr ""
216
 
217
+ #: includes/class-theme-my-login-template.php:363
218
+ msgid "Register For This Site"
219
  msgstr ""
220
 
221
+ #: includes/class-theme-my-login-template.php:365
222
  msgid ""
223
+ "Please enter your username or e-mail address. You will receive a new "
224
+ "password via e-mail."
225
  msgstr ""
226
 
227
+ #: includes/class-theme-my-login-widget.php:23
228
+ msgid "A login form for your blog."
229
  msgstr ""
230
 
231
+ #: includes/class-theme-my-login-widget.php:86
232
+ msgid "Login"
233
  msgstr ""
234
 
235
+ #: includes/class-theme-my-login-widget.php:87
236
+ msgid "Default Action"
 
 
237
  msgstr ""
238
 
239
+ #: includes/class-theme-my-login-widget.php:94
240
+ msgid "Show When Logged In"
241
  msgstr ""
242
 
243
+ #: includes/class-theme-my-login-widget.php:96
244
+ msgid "Show Title"
245
  msgstr ""
246
 
247
+ #: includes/class-theme-my-login-widget.php:98
248
+ msgid "Show Login Link"
249
  msgstr ""
250
 
251
+ #: includes/class-theme-my-login-widget.php:100
252
+ msgid "Show Register Link"
 
253
  msgstr ""
254
 
255
+ #: includes/class-theme-my-login-widget.php:102
256
+ msgid "Show Lost Password Link"
257
+ msgstr ""
258
+
259
+ #: includes/class-theme-my-login-widget.php:104
260
+ msgid "Show Gravatar"
261
+ msgstr ""
262
+
263
+ #: includes/class-theme-my-login-widget.php:105
264
+ msgid "Gravatar Size"
265
+ msgstr ""
266
+
267
+ #: includes/class-theme-my-login-widget.php:107
268
+ msgid "Allow Registration"
269
+ msgstr ""
270
+
271
+ #: includes/class-theme-my-login-widget.php:109
272
+ msgid "Allow Password Recovery"
273
+ msgstr ""
274
+
275
+ #: includes/class-theme-my-login.php:214
276
  msgid "Sorry, that key does not appear to be valid."
277
  msgstr ""
278
 
279
+ #: includes/class-theme-my-login.php:322
280
+ msgid ""
281
+ "<strong>ERROR</strong>: Cookies are blocked or not supported by your "
282
+ "browser. You must <a href=\"http://www.google.com/cookies.html\">enable "
283
+ "cookies</a> to use WordPress."
284
+ msgstr ""
285
+
286
+ #: includes/class-theme-my-login.php:326
287
+ msgid "You are now logged out."
288
+ msgstr ""
289
+
290
+ #: includes/class-theme-my-login.php:328
291
+ msgid "User registration is currently not allowed."
292
+ msgstr ""
293
+
294
+ #: includes/class-theme-my-login.php:330
295
+ msgid "Check your e-mail for the confirmation link."
296
+ msgstr ""
297
+
298
+ #: includes/class-theme-my-login.php:332
299
+ msgid "Check your e-mail for your new password."
300
+ msgstr ""
301
+
302
+ #: includes/class-theme-my-login.php:334
303
+ msgid "Registration complete. Please check your e-mail."
304
+ msgstr ""
305
+
306
+ #: includes/class-theme-my-login.php:336
307
+ msgid "Your session has expired. Please log-in again."
308
+ msgstr ""
309
+
310
+ #: includes/class-theme-my-login.php:390
311
+ msgid "Log Out"
312
+ msgstr ""
313
+
314
+ #: includes/class-theme-my-login.php:884
315
  msgid "<strong>ERROR</strong>: Enter a username or e-mail address."
316
  msgstr ""
317
 
318
+ #: includes/class-theme-my-login.php:889
319
  msgid ""
320
  "<strong>ERROR</strong>: There is no user registered with that email address."
321
  msgstr ""
322
 
323
+ #: includes/class-theme-my-login.php:901
324
  msgid "<strong>ERROR</strong>: Invalid username or e-mail."
325
  msgstr ""
326
 
327
+ #: includes/class-theme-my-login.php:915
328
  msgid "Password reset is not allowed for this user"
329
  msgstr ""
330
 
331
+ #: includes/class-theme-my-login.php:928
332
  msgid ""
333
  "Someone has asked to reset the password for the following site and username."
334
  msgstr ""
335
 
336
+ #: includes/class-theme-my-login.php:930 includes/class-theme-my-login.php:987
337
+ #: modules/custom-email/custom-email.php:474
338
+ #: modules/custom-email/custom-email.php:491
339
+ #: modules/custom-passwords/custom-passwords.php:321
340
+ #: modules/user-moderation/admin/user-moderation-admin.php:165
341
+ #: modules/user-moderation/user-moderation.php:370
342
  #, php-format
343
  msgid "Username: %s"
344
  msgstr ""
345
 
346
+ #: includes/class-theme-my-login.php:931
347
  msgid ""
348
  "To reset your password visit the following address, otherwise just ignore "
349
  "this email and nothing will happen."
350
  msgstr ""
351
 
352
+ #: includes/class-theme-my-login.php:942
353
  #, php-format
354
  msgid "[%s] Password Reset"
355
  msgstr ""
356
 
357
+ #: includes/class-theme-my-login.php:948
358
+ #: includes/class-theme-my-login.php:1005
359
+ #: modules/custom-passwords/custom-passwords.php:339
360
+ #: modules/user-moderation/admin/user-moderation-admin.php:61
361
+ #: modules/user-moderation/admin/user-moderation-admin.php:175
362
+ #: modules/user-moderation/admin/user-moderation-admin.php:210
363
  msgid "The e-mail could not be sent."
364
  msgstr ""
365
 
366
+ #: includes/class-theme-my-login.php:948
367
+ #: includes/class-theme-my-login.php:1005
368
+ #: modules/custom-passwords/custom-passwords.php:339
369
+ #: modules/user-moderation/admin/user-moderation-admin.php:61
370
+ #: modules/user-moderation/admin/user-moderation-admin.php:175
371
+ #: modules/user-moderation/admin/user-moderation-admin.php:210
372
  msgid "Possible reason: your host may have disabled the mail() function..."
373
  msgstr ""
374
 
375
+ #: includes/class-theme-my-login.php:969 includes/class-theme-my-login.php:972
376
+ #: includes/class-theme-my-login.php:976
377
+ #: modules/custom-passwords/custom-passwords.php:275
378
+ #: modules/custom-passwords/custom-passwords.php:279
379
+ #: modules/custom-passwords/custom-passwords.php:284
380
+ #: modules/user-moderation/user-moderation.php:248
381
+ #: modules/user-moderation/user-moderation.php:251
382
+ #: modules/user-moderation/user-moderation.php:256
383
  msgid "Invalid key"
384
  msgstr ""
385
 
386
+ #: includes/class-theme-my-login.php:988
387
+ #: modules/custom-email/custom-email.php:492
388
+ #: modules/custom-passwords/custom-passwords.php:322
389
+ #: modules/user-moderation/admin/user-moderation-admin.php:166
390
  #, php-format
391
  msgid "Password: %s"
392
  msgstr ""
393
 
394
+ #: includes/class-theme-my-login.php:999
395
+ #: modules/custom-passwords/custom-passwords.php:330
396
  #, php-format
397
  msgid "[%s] Your new password"
398
  msgstr ""
399
 
400
+ #: includes/class-theme-my-login.php:1030
401
  msgid "<strong>ERROR</strong>: Please enter a username."
402
  msgstr ""
403
 
404
+ #: includes/class-theme-my-login.php:1032
405
  msgid ""
406
+ "<strong>ERROR</strong>: This username is invalid because it uses illegal "
407
+ "characters. Please enter a valid username."
408
  msgstr ""
409
 
410
+ #: includes/class-theme-my-login.php:1035
411
  msgid ""
412
  "<strong>ERROR</strong>: This username is already registered, please choose "
413
  "another one."
414
  msgstr ""
415
 
416
+ #: includes/class-theme-my-login.php:1040
417
  msgid "<strong>ERROR</strong>: Please type your e-mail address."
418
  msgstr ""
419
 
420
+ #: includes/class-theme-my-login.php:1042
421
  msgid "<strong>ERROR</strong>: The email address isn&#8217;t correct."
422
  msgstr ""
423
 
424
+ #: includes/class-theme-my-login.php:1045
425
  msgid ""
426
  "<strong>ERROR</strong>: This email is already registered, please choose "
427
  "another one."
428
  msgstr ""
429
 
430
+ #: includes/class-theme-my-login.php:1058
431
  #, php-format
432
  msgid ""
433
  "<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a "
434
  "href=\"mailto:%s\">webmaster</a> !"
435
  msgstr ""
436
 
437
+ #: modules/custom-email/admin/custom-email-admin.php:43
438
+ #: modules/custom-email/admin/custom-email-admin.php:170
439
+ #: modules/user-moderation/admin/user-moderation-admin.php:333
440
+ msgid "User Notification"
441
  msgstr ""
442
 
443
+ #: modules/custom-email/admin/custom-email-admin.php:46
444
+ msgid "This e-mail will be sent to a new user upon registration."
445
+ msgstr ""
446
+
447
+ #: modules/custom-email/admin/custom-email-admin.php:47
448
+ #: modules/custom-email/admin/custom-email-admin.php:174
449
+ #: modules/user-moderation/admin/user-moderation-admin.php:337
450
+ msgid ""
451
+ "Please be sure to include the variable %user_pass% if using default "
452
+ "passwords or else the user will not know their password!"
453
+ msgstr ""
454
+
455
+ #: modules/custom-email/admin/custom-email-admin.php:48
456
+ #: modules/custom-email/admin/custom-email-admin.php:78
457
+ #: modules/custom-email/admin/custom-email-admin.php:128
458
+ #: modules/custom-email/admin/custom-email-admin.php:175
459
+ #: modules/custom-email/admin/custom-email-admin.php:205
460
+ #: modules/user-moderation/admin/user-moderation-admin.php:287
461
+ #: modules/user-moderation/admin/user-moderation-admin.php:338
462
+ #: modules/user-moderation/admin/user-moderation-admin.php:368
463
+ #: modules/user-moderation/admin/user-moderation-admin.php:421
464
+ msgid "If any field is left empty, the default will be used instead."
465
+ msgstr ""
466
+
467
+ #: modules/custom-email/admin/custom-email-admin.php:51
468
+ #: modules/custom-email/admin/custom-email-admin.php:84
469
+ #: modules/custom-email/admin/custom-email-admin.php:131
470
+ #: modules/custom-email/admin/custom-email-admin.php:178
471
+ #: modules/custom-email/admin/custom-email-admin.php:211
472
+ #: modules/user-moderation/admin/user-moderation-admin.php:290
473
+ #: modules/user-moderation/admin/user-moderation-admin.php:341
474
+ #: modules/user-moderation/admin/user-moderation-admin.php:374
475
+ #: modules/user-moderation/admin/user-moderation-admin.php:424
476
+ msgid "From Name"
477
+ msgstr ""
478
+
479
+ #: modules/custom-email/admin/custom-email-admin.php:54
480
+ #: modules/custom-email/admin/custom-email-admin.php:87
481
+ #: modules/custom-email/admin/custom-email-admin.php:134
482
+ #: modules/custom-email/admin/custom-email-admin.php:181
483
+ #: modules/custom-email/admin/custom-email-admin.php:214
484
+ #: modules/user-moderation/admin/user-moderation-admin.php:293
485
+ #: modules/user-moderation/admin/user-moderation-admin.php:344
486
+ #: modules/user-moderation/admin/user-moderation-admin.php:377
487
+ #: modules/user-moderation/admin/user-moderation-admin.php:427
488
+ msgid "From E-mail"
489
+ msgstr ""
490
+
491
+ #: modules/custom-email/admin/custom-email-admin.php:57
492
+ #: modules/custom-email/admin/custom-email-admin.php:90
493
+ #: modules/custom-email/admin/custom-email-admin.php:137
494
+ #: modules/custom-email/admin/custom-email-admin.php:184
495
+ #: modules/custom-email/admin/custom-email-admin.php:217
496
+ #: modules/user-moderation/admin/user-moderation-admin.php:296
497
+ #: modules/user-moderation/admin/user-moderation-admin.php:347
498
+ #: modules/user-moderation/admin/user-moderation-admin.php:380
499
+ #: modules/user-moderation/admin/user-moderation-admin.php:430
500
+ msgid "E-mail Format"
501
+ msgstr ""
502
+
503
+ #: modules/custom-email/admin/custom-email-admin.php:63
504
+ #: modules/custom-email/admin/custom-email-admin.php:96
505
+ #: modules/custom-email/admin/custom-email-admin.php:143
506
+ #: modules/custom-email/admin/custom-email-admin.php:190
507
+ #: modules/custom-email/admin/custom-email-admin.php:223
508
+ #: modules/user-moderation/admin/user-moderation-admin.php:302
509
+ #: modules/user-moderation/admin/user-moderation-admin.php:353
510
+ #: modules/user-moderation/admin/user-moderation-admin.php:386
511
+ #: modules/user-moderation/admin/user-moderation-admin.php:436
512
+ msgid "Subject"
513
+ msgstr ""
514
+
515
+ #: modules/custom-email/admin/custom-email-admin.php:66
516
+ #: modules/custom-email/admin/custom-email-admin.php:99
517
+ #: modules/custom-email/admin/custom-email-admin.php:146
518
+ #: modules/custom-email/admin/custom-email-admin.php:193
519
+ #: modules/custom-email/admin/custom-email-admin.php:226
520
+ #: modules/user-moderation/admin/user-moderation-admin.php:305
521
+ #: modules/user-moderation/admin/user-moderation-admin.php:356
522
+ #: modules/user-moderation/admin/user-moderation-admin.php:389
523
+ #: modules/user-moderation/admin/user-moderation-admin.php:439
524
+ msgid "Message"
525
+ msgstr ""
526
+
527
+ #: modules/custom-email/admin/custom-email-admin.php:69
528
+ #: modules/custom-email/admin/custom-email-admin.php:102
529
+ #: modules/custom-email/admin/custom-email-admin.php:149
530
+ #: modules/custom-email/admin/custom-email-admin.php:196
531
+ #: modules/custom-email/admin/custom-email-admin.php:229
532
+ #: modules/user-moderation/admin/user-moderation-admin.php:308
533
+ #: modules/user-moderation/admin/user-moderation-admin.php:359
534
+ #: modules/user-moderation/admin/user-moderation-admin.php:392
535
+ #: modules/user-moderation/admin/user-moderation-admin.php:442
536
+ msgid "Available Variables"
537
+ msgstr ""
538
+
539
+ #: modules/custom-email/admin/custom-email-admin.php:74
540
+ #: modules/custom-email/admin/custom-email-admin.php:201
541
+ #: modules/user-moderation/admin/user-moderation-admin.php:364
542
+ msgid "Admin Notification"
543
+ msgstr ""
544
+
545
+ #: modules/custom-email/admin/custom-email-admin.php:77
546
+ msgid ""
547
+ "This e-mail will be sent to the e-mail address or addresses (multiple "
548
+ "addresses may be separated by commas) specified below, upon new user "
549
+ "registration."
550
+ msgstr ""
551
+
552
+ #: modules/custom-email/admin/custom-email-admin.php:81
553
+ #: modules/custom-email/admin/custom-email-admin.php:208
554
+ #: modules/user-moderation/admin/user-moderation-admin.php:371
555
+ msgid "To"
556
+ msgstr ""
557
+
558
+ #: modules/custom-email/admin/custom-email-admin.php:126
559
+ msgid ""
560
+ "This e-mail will be sent to a user when they attempt to recover their "
561
+ "password."
562
+ msgstr ""
563
+
564
+ #: modules/custom-email/admin/custom-email-admin.php:127
565
+ msgid ""
566
+ "Please be sure to include the variable %reseturl% or else the user will not "
567
+ "be able to recover their password!"
568
+ msgstr ""
569
+
570
+ #: modules/custom-email/admin/custom-email-admin.php:173
571
+ msgid "This e-mail will be sent to a user upon successful password recovery."
572
+ msgstr ""
573
+
574
+ #: modules/custom-email/admin/custom-email-admin.php:204
575
+ msgid ""
576
+ "This e-mail will be sent to the e-mail address or addresses (multiple "
577
+ "addresses may be separated by commas) specified below, upon user password "
578
+ "change."
579
+ msgstr ""
580
+
581
+ #: modules/custom-email/admin/custom-email-admin.php:231
582
+ #: modules/user-moderation/admin/user-moderation-admin.php:394
583
+ msgid "Disable Admin Notification"
584
+ msgstr ""
585
+
586
+ #: modules/custom-email/admin/custom-email-admin.php:251
587
+ #: templates/profile-form.php:86 templates/register-form.php:16
588
+ msgid "E-mail"
589
  msgstr ""
590
 
591
+ #: modules/custom-email/admin/custom-email-admin.php:252
592
+ msgid "New User"
593
+ msgstr ""
594
+
595
+ #: modules/custom-email/admin/custom-email-admin.php:253
596
+ msgid "Retrieve Password"
597
+ msgstr ""
598
+
599
+ #: modules/custom-email/admin/custom-email-admin.php:254
600
+ msgid "Reset Password"
601
+ msgstr ""
602
+
603
+ #: modules/custom-email/custom-email.php:473
604
  #, php-format
605
+ msgid "New user registration on your site %s:"
606
  msgstr ""
607
 
608
+ #: modules/custom-email/custom-email.php:475
609
+ #: modules/user-moderation/user-moderation.php:371
610
  #, php-format
611
  msgid "E-mail: %s"
612
  msgstr ""
613
 
614
+ #: modules/custom-email/custom-email.php:477
615
  #, php-format
616
  msgid "[%s] New User Registration"
617
  msgstr ""
618
 
619
+ #: modules/custom-email/custom-email.php:495
620
  #, php-format
621
  msgid "[%s] Your username and password"
622
  msgstr ""
623
 
624
+ #: modules/custom-email/custom-email.php:525
625
+ #, php-format
626
+ msgid "[%s] Password Lost/Changed"
627
  msgstr ""
628
 
629
+ #: modules/custom-email/custom-email.php:526
630
+ #, php-format
631
+ msgid "Password Lost and Changed for user: %s"
632
  msgstr ""
633
 
634
+ #: modules/custom-passwords/custom-passwords.php:29
635
+ msgid "Password:"
 
636
  msgstr ""
637
 
638
+ #: modules/custom-passwords/custom-passwords.php:31
639
+ #: templates/resetpass-form.php:16
640
+ msgid "Confirm Password:"
641
  msgstr ""
642
 
643
+ #: modules/custom-passwords/custom-passwords.php:54
644
+ msgid "<strong>ERROR</strong>: Please enter a password."
645
  msgstr ""
646
 
647
+ #: modules/custom-passwords/custom-passwords.php:57
648
+ msgid "<strong>ERROR</strong>: Your passwords do not match."
649
  msgstr ""
650
 
651
+ #: modules/custom-passwords/custom-passwords.php:60
652
  msgid ""
653
+ "<strong>ERROR</strong>: Your password must be at least 6 characters in "
654
+ "length."
 
655
  msgstr ""
656
 
657
+ #: modules/custom-passwords/custom-passwords.php:173
658
+ msgid ""
659
+ "Please enter your username or e-mail address. You will receive an e-mail "
660
+ "with a link to reset your password."
661
  msgstr ""
662
 
663
+ #: modules/custom-passwords/custom-passwords.php:176
664
+ msgid "Please enter a new password."
665
  msgstr ""
666
 
667
+ #: modules/custom-passwords/custom-passwords.php:209
668
+ msgid "Registration complete. You may now log in."
669
  msgstr ""
670
 
671
+ #: modules/custom-passwords/custom-passwords.php:212
672
+ msgid "Your password has been saved. You may now log in."
673
  msgstr ""
674
 
675
+ #: modules/custom-redirection/custom-redirection.php:136
676
+ msgid "Redirection"
677
  msgstr ""
678
 
679
+ #: modules/custom-redirection/custom-redirection.php:163
680
+ msgid "Log in"
 
681
  msgstr ""
682
 
683
+ #: modules/custom-redirection/custom-redirection.php:165
684
+ #: modules/custom-redirection/custom-redirection.php:177
685
+ msgid "Default"
686
  msgstr ""
687
 
688
+ #: modules/custom-redirection/custom-redirection.php:166
689
+ msgid ""
690
+ "Check this option to send the user to their WordPress Dashboard/Profile."
691
  msgstr ""
692
 
693
+ #: modules/custom-redirection/custom-redirection.php:167
694
+ #: modules/custom-redirection/custom-redirection.php:179
695
+ msgid "Referer"
696
  msgstr ""
697
 
698
+ #: modules/custom-redirection/custom-redirection.php:168
699
+ msgid ""
700
+ "Check this option to send the user back to the page they were visiting "
701
+ "before logging in."
702
  msgstr ""
703
 
704
+ #: modules/custom-redirection/custom-redirection.php:171
705
+ #: modules/custom-redirection/custom-redirection.php:183
706
  msgid ""
707
+ "Check this option to send the user to a custom location, specified by the "
708
+ "textbox above."
709
  msgstr ""
710
 
711
+ #: modules/custom-redirection/custom-redirection.php:178
712
+ msgid ""
713
+ "Check this option to send the user to the log in page, displaying a message "
714
+ "that they have successfully logged out."
715
  msgstr ""
716
 
717
+ #: modules/custom-redirection/custom-redirection.php:180
718
+ msgid ""
719
+ "Check this option to send the user back to the page they were visiting "
720
+ "before logging out. (Note: If the previous page being visited was an admin "
721
+ "page, this can have unexpected results.)"
722
  msgstr ""
723
 
724
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:139
725
+ msgid "User Links"
726
  msgstr ""
727
 
728
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:229
729
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:252
730
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:297
731
+ msgid "Title"
732
  msgstr ""
733
 
734
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:230
735
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:253
736
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:301
737
+ msgid "URL"
738
  msgstr ""
739
 
740
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:247
741
+ msgid "Add New link:"
742
  msgstr ""
743
 
744
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:263
745
+ msgid "Add link"
746
  msgstr ""
747
 
748
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:303
749
+ msgid "Delete"
750
  msgstr ""
751
 
752
+ #: modules/custom-user-links/admin/custom-user-links-admin.php:304
753
+ msgid "Update"
754
  msgstr ""
755
 
756
+ #: modules/security/admin/security-admin.php:35
757
+ #: modules/security/admin/security-admin.php:38
758
+ #: modules/user-moderation/admin/user-moderation-admin.php:38
759
+ #: modules/user-moderation/admin/user-moderation-admin.php:50
760
+ msgid "You can&#8217;t edit that user."
761
  msgstr ""
762
 
763
+ #: modules/security/admin/security-admin.php:70
764
+ msgid "User locked."
765
  msgstr ""
766
 
767
+ #: modules/security/admin/security-admin.php:72
768
+ msgid "User unlocked."
769
  msgstr ""
770
 
771
+ #: modules/security/admin/security-admin.php:95
772
+ msgid "Unlock"
773
  msgstr ""
774
 
775
+ #: modules/security/admin/security-admin.php:97
776
+ msgid "Lock"
777
  msgstr ""
778
 
779
+ #: modules/security/admin/security-admin.php:116
780
+ msgid "Security"
781
  msgstr ""
782
 
783
+ #: modules/security/admin/security-admin.php:136
784
+ msgid "Login Attempts"
785
  msgstr ""
786
 
787
+ #: modules/security/admin/security-admin.php:141
788
+ msgid "minute(s)"
789
  msgstr ""
790
 
791
+ #: modules/security/admin/security-admin.php:142
792
+ msgid "hour(s)"
793
  msgstr ""
794
 
795
+ #: modules/security/admin/security-admin.php:143
796
+ msgid "day(s)"
 
 
 
 
 
797
  msgstr ""
798
 
799
+ #: modules/security/admin/security-admin.php:166
800
+ #, php-format
801
+ msgid ""
802
+ "After %1$s failed login attempts within %2$s %3$s, lockout the account for %4"
803
+ "$s %5$s."
 
 
804
  msgstr ""
805
 
806
+ #: modules/security/security.php:43 modules/security/security.php:69
807
+ #, php-format
808
+ msgid ""
809
+ "<strong>ERROR</strong>: This account has been locked because of too many "
810
+ "failed login attempts. You may try again in %s."
 
 
811
  msgstr ""
812
 
813
+ #: modules/security/security.php:45
814
+ msgid "<strong>ERROR</strong>: This account has been locked."
815
  msgstr ""
816
 
817
+ #: modules/themed-profiles/themed-profiles.php:77
818
+ #: templates/profile-form.php:125
819
+ msgid "Strength indicator"
820
  msgstr ""
821
 
822
+ #: modules/themed-profiles/themed-profiles.php:78
823
+ msgid "Very weak"
 
824
  msgstr ""
825
 
826
+ #: modules/themed-profiles/themed-profiles.php:79
827
+ msgid "Weak"
828
  msgstr ""
829
 
830
+ #. translators: password strength
831
+ #: modules/themed-profiles/themed-profiles.php:81
832
+ msgctxt "password strength"
833
+ msgid "Medium"
834
  msgstr ""
835
 
836
+ #: modules/themed-profiles/themed-profiles.php:82
837
+ msgid "Strong"
 
 
838
  msgstr ""
839
 
840
+ #: modules/themed-profiles/themed-profiles.php:92
841
+ msgid "You do not have permission to edit this user."
842
  msgstr ""
843
 
844
+ #: modules/themed-profiles/themed-profiles.php:108
845
+ msgid "Profile updated."
846
  msgstr ""
847
 
848
+ #: modules/themed-profiles/themed-profiles.php:178
849
+ msgid "Your Profile"
850
  msgstr ""
851
 
852
+ #: modules/user-moderation/admin/user-moderation-admin.php:83
853
+ msgid "User approved."
 
 
854
  msgstr ""
855
 
856
+ #: modules/user-moderation/admin/user-moderation-admin.php:85
857
+ msgid "Activation sent."
858
  msgstr ""
859
 
860
+ #: modules/user-moderation/admin/user-moderation-admin.php:111
861
+ msgid "Resend Activation"
862
  msgstr ""
863
 
864
+ #: modules/user-moderation/admin/user-moderation-admin.php:116
865
+ msgid "Approve"
866
  msgstr ""
867
 
868
+ #: modules/user-moderation/admin/user-moderation-admin.php:150
869
+ #: modules/user-moderation/user-moderation.php:275
870
+ msgid "Same as when you signed up."
871
  msgstr ""
872
 
873
+ #: modules/user-moderation/admin/user-moderation-admin.php:164
874
+ #, php-format
875
+ msgid "You have been approved access to %s"
876
  msgstr ""
877
 
878
+ #: modules/user-moderation/admin/user-moderation-admin.php:169
879
+ #, php-format
880
+ msgid "[%s] Registration Approved"
881
  msgstr ""
882
 
883
+ #: modules/user-moderation/admin/user-moderation-admin.php:203
884
+ #, php-format
885
+ msgid "You have been denied access to %s"
886
  msgstr ""
887
 
888
+ #: modules/user-moderation/admin/user-moderation-admin.php:204
889
+ #, php-format
890
+ msgid "[%s] Registration Denied"
 
 
891
  msgstr ""
892
 
893
+ #: modules/user-moderation/admin/user-moderation-admin.php:226
894
+ msgid "Moderation"
 
 
 
895
  msgstr ""
896
 
897
+ #: modules/user-moderation/admin/user-moderation-admin.php:228
898
+ msgid "User Activation"
899
  msgstr ""
900
 
901
+ #: modules/user-moderation/admin/user-moderation-admin.php:229
902
+ msgid "User Approval"
903
  msgstr ""
904
 
905
+ #: modules/user-moderation/admin/user-moderation-admin.php:230
906
+ msgid "User Denial"
907
  msgstr ""
908
 
909
+ #: modules/user-moderation/admin/user-moderation-admin.php:249
910
+ msgid "User Moderation"
911
  msgstr ""
912
 
913
+ #: modules/user-moderation/admin/user-moderation-admin.php:252
914
+ msgid "None"
915
  msgstr ""
916
 
917
+ #: modules/user-moderation/admin/user-moderation-admin.php:253
918
+ msgid "Check this option to require no moderation."
919
  msgstr ""
920
 
921
+ #: modules/user-moderation/admin/user-moderation-admin.php:255
922
+ msgid "E-mail Confirmation"
923
  msgstr ""
924
 
925
+ #: modules/user-moderation/admin/user-moderation-admin.php:256
926
+ msgid ""
927
+ "Check this option to require new users to confirm their e-mail address "
928
+ "before they may log in."
929
  msgstr ""
930
 
931
+ #: modules/user-moderation/admin/user-moderation-admin.php:258
932
+ msgid "Admin Approval"
933
  msgstr ""
934
 
935
+ #: modules/user-moderation/admin/user-moderation-admin.php:259
936
+ msgid ""
937
+ "Check this option to require new users to be approved by an administrator "
938
+ "before they may log in."
939
  msgstr ""
940
 
941
+ #: modules/user-moderation/admin/user-moderation-admin.php:285
942
+ msgid ""
943
+ "This e-mail will be sent to a new user upon registration when \"E-mail "
944
+ "Confirmation\" is checked for \"User Moderation\"."
945
  msgstr ""
946
 
947
+ #: modules/user-moderation/admin/user-moderation-admin.php:286
948
+ msgid ""
949
+ "Please be sure to include the variable %activateurl% or else the user will "
950
+ "not be able to activate their account!"
951
  msgstr ""
952
 
953
+ #: modules/user-moderation/admin/user-moderation-admin.php:336
954
+ msgid ""
955
+ "This e-mail will be sent to a new user upon admin approval when \"Admin "
956
+ "Approval\" is checked for \"User Moderation\"."
957
  msgstr ""
958
 
959
+ #: modules/user-moderation/admin/user-moderation-admin.php:367
960
+ msgid ""
961
+ "This e-mail will be sent to the e-mail address or addresses (multiple "
962
+ "addresses may be separated by commas) specified below upon user registration "
963
+ "when \"Admin Approval\" is checked for \"User Moderation\"."
964
  msgstr ""
965
 
966
+ #: modules/user-moderation/admin/user-moderation-admin.php:420
967
+ msgid ""
968
+ "This e-mail will be sent to a user who is deleted/denied when \"Admin "
969
+ "Approval\" is checked for \"User Moderation\" and the user's role is "
970
+ "\"Pending\"."
971
  msgstr ""
972
 
973
+ #: modules/user-moderation/user-moderation.php:171
974
+ #, php-format
975
+ msgid ""
976
+ "<strong>ERROR</strong>: You have not yet confirmed your e-mail address. <a "
977
+ "href=\"%s\">Resend activation</a>?"
978
  msgstr ""
979
 
980
+ #: modules/user-moderation/user-moderation.php:174
981
+ msgid "<strong>ERROR</strong>: Your registration has not yet been approved."
982
  msgstr ""
983
 
984
+ #: modules/user-moderation/user-moderation.php:334
985
+ #, php-format
986
+ msgid "[%s] Activate Your Account"
987
+ msgstr ""
988
+
989
+ #: modules/user-moderation/user-moderation.php:335
990
+ #, php-format
991
  msgid ""
992
+ "Thanks for registering at %s! To complete the activation of your account "
993
+ "please click the following link: "
994
  msgstr ""
995
 
996
+ #: modules/user-moderation/user-moderation.php:367
997
+ #, php-format
998
+ msgid "[%s] New User Awaiting Approval"
999
  msgstr ""
1000
 
1001
+ #: modules/user-moderation/user-moderation.php:369
1002
+ #, php-format
1003
+ msgid "New user requires approval on your blog %s:"
 
1004
  msgstr ""
1005
 
1006
+ #: modules/user-moderation/user-moderation.php:372
1007
+ msgid "To approve or deny this user:"
1008
  msgstr ""
1009
 
1010
+ #: modules/user-moderation/user-moderation.php:393
1011
+ msgid ""
1012
+ "Your registration was successful but you must now confirm your email address "
1013
+ "before you can log in. Please check your email and click on the link "
1014
+ "provided."
1015
  msgstr ""
1016
 
1017
+ #: modules/user-moderation/user-moderation.php:395
1018
  msgid ""
1019
+ "Your registration was successful but you must now be approved by an "
1020
+ "administrator before you can log in. You will be notified by e-mail once "
1021
+ "your account has been reviewed."
1022
  msgstr ""
1023
 
1024
+ #: modules/user-moderation/user-moderation.php:398
1025
+ msgid "Your account has been activated. You may now log in."
1026
  msgstr ""
1027
 
1028
+ #: modules/user-moderation/user-moderation.php:400
1029
+ msgid ""
1030
+ "Your account has been activated. Please check your e-mail for your password."
1031
  msgstr ""
1032
 
1033
+ #: modules/user-moderation/user-moderation.php:402
1034
+ msgid "<strong>ERROR</strong>: Sorry, that key does not appear to be valid."
1035
  msgstr ""
1036
 
1037
+ #: modules/user-moderation/user-moderation.php:405
1038
+ msgid "<strong>ERROR</strong>: Sorry, the activation e-mail could not be sent."
 
 
1039
  msgstr ""
1040
 
1041
+ #: modules/user-moderation/user-moderation.php:407
1042
+ msgid ""
1043
+ "The activation e-mail has been sent to the e-mail address with which you "
1044
+ "registered. Please check your email and click on the link provided."
1045
  msgstr ""
1046
 
1047
+ #: templates/login-form.php:12 templates/profile-form.php:34
1048
+ #: templates/register-form.php:12
1049
+ msgid "Username"
1050
  msgstr ""
1051
 
1052
+ #: templates/login-form.php:16
1053
+ msgid "Password"
1054
  msgstr ""
1055
 
1056
+ #: templates/login-form.php:25
1057
+ msgid "Remember Me"
1058
  msgstr ""
1059
 
1060
+ #: templates/lostpassword-form.php:12
1061
+ msgid "Username or E-mail:"
1062
  msgstr ""
1063
 
1064
+ #: templates/lostpassword-form.php:20
1065
+ msgid "Get New Password"
1066
  msgstr ""
1067
 
1068
+ #: templates/profile-form.php:22
1069
+ msgid "Personal Options"
1070
  msgstr ""
1071
 
1072
+ #: templates/profile-form.php:30
1073
+ msgid "Name"
1074
  msgstr ""
1075
 
1076
+ #: templates/profile-form.php:35
1077
+ msgid "Your username cannot be changed."
1078
  msgstr ""
1079
 
1080
+ #: templates/profile-form.php:39
1081
+ msgid "First name"
1082
  msgstr ""
1083
 
1084
+ #: templates/profile-form.php:44
1085
+ msgid "Last name"
 
1086
  msgstr ""
1087
 
1088
+ #: templates/profile-form.php:49
1089
+ msgid "Nickname"
 
1090
  msgstr ""
1091
 
1092
+ #: templates/profile-form.php:49 templates/profile-form.php:86
1093
+ msgid "(required)"
 
1094
  msgstr ""
1095
 
1096
+ #: templates/profile-form.php:54
1097
+ msgid "Display name publicly as"
 
1098
  msgstr ""
1099
 
1100
+ #: templates/profile-form.php:82
1101
+ msgid "Contact Info"
 
 
 
1102
  msgstr ""
1103
 
1104
+ #: templates/profile-form.php:91
1105
+ msgid "Website"
 
1106
  msgstr ""
1107
 
1108
+ #: templates/profile-form.php:108
1109
+ msgid "About Yourself"
1110
  msgstr ""
1111
 
1112
+ #: templates/profile-form.php:112
1113
+ msgid "Biographical Info"
 
1114
  msgstr ""
1115
 
1116
+ #: templates/profile-form.php:114
1117
+ msgid ""
1118
+ "Share a little biographical information to fill out your profile. This may "
1119
+ "be shown publicly."
1120
  msgstr ""
1121
 
1122
+ #: templates/profile-form.php:122
1123
+ msgid "New Password"
1124
  msgstr ""
1125
 
1126
+ #: templates/profile-form.php:123
1127
  msgid ""
1128
+ "If you would like to change the password type a new one. Otherwise leave "
1129
+ "this blank."
1130
+ msgstr ""
1131
+
1132
+ #: templates/profile-form.php:124
1133
+ msgid "Type your new password again."
1134
  msgstr ""
1135
 
1136
+ #: templates/profile-form.php:126
1137
  msgid ""
1138
+ "Hint: The password should be at least seven characters long. To make it "
1139
+ "stronger, use upper and lower case letters, numbers and symbols like ! \" ? "
1140
+ "$ % ^ &amp; )."
1141
  msgstr ""
1142
 
1143
+ #: templates/profile-form.php:140
1144
+ msgid "Additional Capabilities"
1145
  msgstr ""
1146
 
1147
+ #: templates/profile-form.php:159
1148
+ msgid "Update Profile"
 
1149
  msgstr ""
1150
 
1151
+ #: templates/register-form.php:23
1152
+ msgid "A password will be e-mailed to you."
1153
+ msgstr ""
1154
+
1155
+ #: templates/resetpass-form.php:12
1156
+ msgid "New Password:"
1157
+ msgstr ""
1158
+
1159
+ #: templates/resetpass-form.php:24
1160
+ msgid "Change Password"
1161
  msgstr ""
1162
 
1163
+ #. Plugin URI of the plugin/theme
1164
+ msgid "http://www.jfarthing.com/wordpress-plugins/theme-my-login/"
1165
  msgstr ""
1166
 
1167
+ #. Description of the plugin/theme
1168
  msgid ""
1169
  "Themes the WordPress login, registration and forgot password pages according "
1170
  "to your theme."
1171
  msgstr ""
1172
 
1173
+ #. Author of the plugin/theme
1174
  msgid "Jeff Farthing"
1175
  msgstr ""
1176
 
1177
+ #. Author URI of the plugin/theme
1178
  msgid "http://www.jfarthing.com"
1179
  msgstr ""
modules/custom-email/admin/admin.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_custom_email_admin_menu() {
4
- $parent = plugin_basename(TML_MODULE_DIR . '/custom-email/admin/options.php');
5
- wdbj_tml_add_menu_page(__('E-mail', 'theme-my-login'), $parent);
6
- wdbj_tml_add_submenu_page($parent, __('General', 'theme-my-login'), TML_MODULE_DIR . '/custom-email/admin/options-general.php');
7
- wdbj_tml_add_submenu_page($parent, __('New User', 'theme-my-login'), TML_MODULE_DIR . '/custom-email/admin/options-new-user.php');
8
- wdbj_tml_add_submenu_page($parent, __('Retrieve Password', 'theme-my-login'), TML_MODULE_DIR . '/custom-email/admin/options-retrieve-pass.php');
9
- wdbj_tml_add_submenu_page($parent, __('Reset Password', 'theme-my-login'), TML_MODULE_DIR . '/custom-email/admin/options-reset-pass.php');
10
- }
11
-
12
- function wdbj_tml_custom_email_sanitize_html($text) {
13
- $text = addslashes($text);
14
- $text = wp_filter_post_kses($text);
15
- $text = stripslashes($text);
16
- $text = esc_html($text);
17
- return $text;
18
- }
19
-
20
- function wdbj_tml_custom_email_sanitize_text($text) {
21
- $text = strip_tags($text);
22
- $text = addslashes($text);
23
- $text = wp_filter_post_kses($text);
24
- $text = stripslashes($text);
25
- return $text;
26
- }
27
-
28
- function wdbj_tml_custom_email_save_settings($settings) {
29
- $settings['email']['mail_from_name'] = wdbj_tml_custom_email_sanitize_text($settings['email']['mail_from_name']);
30
- $settings['email']['mail_from'] = sanitize_email($settings['email']['mail_from']);
31
- $settings['email']['mail_content_type'] = preg_replace('/[^a-zA-Z0-9_-]/', '', $settings['email']['mail_content_type']);
32
-
33
- $settings['email']['new_user']['admin_disable'] = isset($settings['email']['new_user']['admin_disable']) ? 1 : 0;
34
- $settings['email']['reset_pass']['admin_disable'] = isset($settings['email']['reset_pass']['admin_disable']) ? 1 : 0;
35
- return $settings;
36
- }
37
-
38
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-email/admin/custom-email-admin.php ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists( 'Theme_My_Login_Custom_Email_Admin' ) ) :
4
+ /**
5
+ * Theme My Login Custom Email module admin class
6
+ *
7
+ * @since 6.0
8
+ */
9
+ class Theme_My_Login_Custom_Email_Admin extends Theme_My_Login_Module {
10
+ /**
11
+ * Sanitizes settings
12
+ *
13
+ * Callback for "tml_save_settings" hook in method Theme_My_Login_Admin::save_settings()
14
+ *
15
+ * @see Theme_My_Login_Admin::save_settings()
16
+ * @since 6.0
17
+ * @access public
18
+ *
19
+ * @param string|array $settings Settings passed in from filter
20
+ * @return string|array Sanitized settings
21
+ */
22
+ function save_settings( $settings ) {
23
+ // Checkboxes
24
+ $settings['email']['new_user']['admin_disable'] = empty( $settings['email']['new_user']['admin_disable'] ) ? 0 : 1;
25
+ $settings['email']['reset_pass']['admin_disable'] = empty( $settings['email']['reset_pass']['admin_disable'] ) ? 0 : 1;
26
+ return $settings;
27
+ }
28
+
29
+ /**
30
+ * Outputs new user notification e-mail settings
31
+ *
32
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
33
+ *
34
+ * @see Theme_My_Login_Admin::add_submenu_page()
35
+ * @since 6.0
36
+ * @access public
37
+ */
38
+ function display_new_user_settings() {
39
+ ?>
40
+ <table class="form-table">
41
+ <tr>
42
+ <td>
43
+ <h3><?php _e( 'User Notification', $this->theme_my_login->textdomain ); ?></h3>
44
+
45
+ <p class="description">
46
+ <?php _e( 'This e-mail will be sent to a new user upon registration.', $this->theme_my_login->textdomain ); ?>
47
+ <?php _e( 'Please be sure to include the variable %user_pass% if using default passwords or else the user will not know their password!', $this->theme_my_login->textdomain ); ?>
48
+ <?php _e( 'If any field is left empty, the default will be used instead.', $this->theme_my_login->textdomain ); ?>
49
+ </p>
50
+
51
+ <p><label for="theme_my_login_new_user_mail_from_name"><?php _e( 'From Name', $this->theme_my_login->textdomain ); ?></label><br />
52
+ <input name="theme_my_login[email][new_user][mail_from_name]" type="text" id="theme_my_login_new_user_mail_from_name" value="<?php echo $this->theme_my_login->options['email']['new_user']['mail_from_name']; ?>" class="extended-text" /></p>
53
+
54
+ <p><label for="theme_my_login_new_user_mail_from"><?php _e( 'From E-mail', $this->theme_my_login->textdomain ); ?></label><br />
55
+ <input name="theme_my_login[email][new_user][mail_from]" type="text" id="theme_my_login_new_user_mail_from" value="<?php echo $this->theme_my_login->options['email']['new_user']['mail_from']; ?>" class="extended-text" /></p>
56
+
57
+ <p><label for="theme_my_login_new_user_mail_content_type"><?php _e( 'E-mail Format', $this->theme_my_login->textdomain ); ?></label><br />
58
+ <select name="theme_my_login[email][new_user][mail_content_type]" id="theme_my_login_new_user_mail_content_type">
59
+ <option value="plain"<?php if ( 'plain' == $this->theme_my_login->options['email']['new_user']['mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
60
+ <option value="html"<?php if ( 'html' == $this->theme_my_login->options['email']['new_user']['mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
61
+ </select></p>
62
+
63
+ <p><label for="theme_my_login_new_user_title"><?php _e( 'Subject', $this->theme_my_login->textdomain ); ?></label><br />
64
+ <input name="theme_my_login[email][new_user][title]" type="text" id="theme_my_login_new_user_title" value="<?php echo $this->theme_my_login->options['email']['new_user']['title']; ?>" class="full-text" /></p>
65
+
66
+ <p><label for="theme_my_login_new_user_message"><?php _e( 'Message', $this->theme_my_login->textdomain ); ?></label><br />
67
+ <textarea name="theme_my_login[email][new_user][message]" id="theme_my_login_new_user_message" class="large-text" rows="10"><?php echo $this->theme_my_login->options['email']['new_user']['message']; ?></textarea></p>
68
+
69
+ <p class="description"><?php _e( 'Available Variables', $this->theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_pass%, %user_ip%</p>
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <td>
74
+ <h3><?php _e( 'Admin Notification', $this->theme_my_login->textdomain ); ?></h3>
75
+
76
+ <p class="description">
77
+ <?php _e( 'This e-mail will be sent to the e-mail address or addresses (multiple addresses may be separated by commas) specified below, upon new user registration.', $this->theme_my_login->textdomain ); ?>
78
+ <?php _e( 'If any field is left empty, the default will be used instead.', $this->theme_my_login->textdomain ); ?>
79
+ </p>
80
+
81
+ <p><label for="theme_my_login_new_user_admin_mail_to"><?php _e( 'To', $this->theme_my_login->textdomain ); ?></label><br />
82
+ <input name="theme_my_login[email][new_user][admin_mail_to]" type="text" id="theme_my_login_new_user_admin_mail_to" value="<?php echo $this->theme_my_login->options['email']['new_user']['admin_mail_to']; ?>" class="extended-text" /></p>
83
+
84
+ <p><label for="theme_my_login_new_user_admin_mail_from_name"><?php _e( 'From Name', $this->theme_my_login->textdomain ); ?></label><br />
85
+ <input name="theme_my_login[email][new_user][admin_mail_from_name]" type="text" id="theme_my_login_new_user_admin_mail_from_name" value="<?php echo $this->theme_my_login->options['email']['new_user']['admin_mail_from_name']; ?>" class="extended-text" /></p>
86
+
87
+ <p><label for="theme_my_login_new_user_admin_mail_from"><?php _e( 'From E-mail', $this->theme_my_login->textdomain ); ?></label><br />
88
+ <input name="theme_my_login[email][new_user][admin_mail_from]" type="text" id="theme_my_login_new_user_admin_mail_from" value="<?php echo $this->theme_my_login->options['email']['new_user']['admin_mail_from']; ?>" class="extended-text" /></p>
89
+
90
+ <p><label for="theme_my_login_new_user_admin_mail_content_type"><?php _e( 'E-mail Format', $this->theme_my_login->textdomain ); ?></label><br />
91
+ <select name="theme_my_login[email][new_user][admin_mail_content_type]" id="theme_my_login_new_user_admin_mail_content_type">
92
+ <option value="plain"<?php if ( 'plain' == $this->theme_my_login->options['email']['new_user']['admin_mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
93
+ <option value="html"<?php if ( 'html' == $this->theme_my_login->options['email']['new_user']['admin_mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
94
+ </select></p>
95
+
96
+ <p><label for="theme_my_login_new_user_admin_title"><?php _e( 'Subject', $this->theme_my_login->textdomain ); ?></label><br />
97
+ <input name="theme_my_login[email][new_user][admin_title]" type="text" id="theme_my_login_new_user_admin_title" value="<?php echo $this->theme_my_login->options['email']['new_user']['admin_title']; ?>" class="full-text" /></p>
98
+
99
+ <p><label for="theme_my_login_new_user_admin_message"><?php _e( 'Message', $this->theme_my_login->textdomain ); ?></label><br />
100
+ <textarea name="theme_my_login[email][new_user][admin_message]" id="theme_my_login_new_user_admin_message" class="large-text" rows="10"><?php echo $this->theme_my_login->options['email']['new_user']['admin_message']; ?></textarea></p>
101
+
102
+ <p class="description"><?php _e( 'Available Variables', $this->theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_ip%</p>
103
+
104
+ <p><label for="theme_my_login_new_user_admin_disable"><input name="theme_my_login[email][new_user][admin_disable]" type="checkbox" id="theme_my_login_new_user_admin_disable" value="1"<?php checked( 1, $this->theme_my_login->options['email']['new_user']['admin_disable'] ); ?> /> Disable Admin Notification</label></p>
105
+ </td>
106
+ </tr>
107
+ </table>
108
+ <?php
109
+ }
110
+
111
+ /**
112
+ * Outputs password retrieval e-mail settings
113
+ *
114
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
115
+ *
116
+ * @see Theme_My_Login_Admin::add_submenu_page()
117
+ * @since 6.0
118
+ * @access public
119
+ */
120
+ function display_retrieve_pass_settings() {
121
+ ?>
122
+ <table class="form-table">
123
+ <tr>
124
+ <td>
125
+ <p class="description">
126
+ <?php _e( 'This e-mail will be sent to a user when they attempt to recover their password.', $this->theme_my_login->textdomain ); ?>
127
+ <?php _e( 'Please be sure to include the variable %reseturl% or else the user will not be able to recover their password!', $this->theme_my_login->textdomain ); ?>
128
+ <?php _e( 'If any field is left empty, the default will be used instead.', $this->theme_my_login->textdomain ); ?>
129
+ </p>
130
+
131
+ <p><label for="theme_my_login_retrieve_pass_mail_from_name"><?php _e( 'From Name', $this->theme_my_login->textdomain ); ?></label><br />
132
+ <input name="theme_my_login[email][retrieve_pass][mail_from_name]" type="text" id="theme_my_login_retrieve_pass_mail_from_name" value="<?php echo $this->theme_my_login->options['email']['retrieve_pass']['mail_from_name']; ?>" class="extended-text" /></p>
133
+
134
+ <p><label for="theme_my_login_retrieve_pass_mail_from"><?php _e( 'From E-mail', $this->theme_my_login->textdomain ); ?></label><br />
135
+ <input name="theme_my_login[email][retrieve_pass][mail_from]" type="text" id="theme_my_login_retrieve_pass_mail_from" value="<?php echo $this->theme_my_login->options['email']['retrieve_pass']['mail_from']; ?>" class="extended-text" /></p>
136
+
137
+ <p><label for="theme_my_login_retrieve_pass_mail_content_type"><?php _e( 'E-mail Format', $this->theme_my_login->textdomain ); ?></label><br />
138
+ <select name="theme_my_login[email][retrieve_pass][mail_content_type]" id="theme_my_login_retrieve_pass_mail_content_type">
139
+ <option value="plain"<?php if ( 'plain' == $this->theme_my_login->options['email']['retrieve_pass']['mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
140
+ <option value="html"<?php if ( 'html' == $this->theme_my_login->options['email']['retrieve_pass']['mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
141
+ </select></p>
142
+
143
+ <p><label for="theme_my_login_retrieve_pass_title"><?php _e( 'Subject', $this->theme_my_login->textdomain ); ?></label><br />
144
+ <input name="theme_my_login[email][retrieve_pass][title]" type="text" id="theme_my_login_retrieve_pass_title" value="<?php echo $this->theme_my_login->options['email']['retrieve_pass']['title']; ?>" class="full-text" /></p>
145
+
146
+ <p><label for="theme_my_login_retrieve_pass_message"><?php _e( 'Message', $this->theme_my_login->textdomain ); ?></label><br />
147
+ <textarea name="theme_my_login[email][retrieve_pass][message]" id="theme_my_login_retrieve_pass_message" class="large-text" rows="10"><?php echo $this->theme_my_login->options['email']['retrieve_pass']['message']; ?></textarea></p>
148
+
149
+ <p class="description"><?php _e( 'Available Variables', $this->theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %reseturl%, %user_login%, %user_email%, %user_ip%</p>
150
+ </td>
151
+ </tr>
152
+ </table>
153
+ <?php
154
+ }
155
+
156
+ /**
157
+ * Outputs password reset e-mail settings
158
+ *
159
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
160
+ *
161
+ * @see Theme_My_Login_Admin::add_submenu_page()
162
+ * @since 6.0
163
+ * @access public
164
+ */
165
+ function display_reset_pass_settings() {
166
+ ?>
167
+ <table class="form-table">
168
+ <tr>
169
+ <td>
170
+ <h3><?php _e( 'User Notification', $this->theme_my_login->textdomain ); ?></h3>
171
+
172
+ <p class="description">
173
+ <?php _e( 'This e-mail will be sent to a user upon successful password recovery.', $this->theme_my_login->textdomain ); ?>
174
+ <?php _e( 'Please be sure to include the variable %user_pass% if using default passwords or else the user will not know their password!', $this->theme_my_login->textdomain ); ?>
175
+ <?php _e( 'If any field is left empty, the default will be used instead.', $this->theme_my_login->textdomain ); ?>
176
+ </p>
177
+
178
+ <p><label for="theme_my_login_reset_pass_mail_from_name"><?php _e( 'From Name', $this->theme_my_login->textdomain ); ?></label><br />
179
+ <input name="theme_my_login[email][reset_pass][mail_from_name]" type="text" id="theme_my_login_reset_pass_mail_from_name" value="<?php echo $this->theme_my_login->options['email']['reset_pass']['mail_from_name']; ?>" class="extended-text" /></p>
180
+
181
+ <p><label for="theme_my_login_retrieve_pass_mail_from"><?php _e( 'From E-mail', $this->theme_my_login->textdomain ); ?></label><br />
182
+ <input name="theme_my_login[email][reset_pass][mail_from]" type="text" id="theme_my_login_reset_pass_mail_from" value="<?php echo $this->theme_my_login->options['email']['reset_pass']['mail_from']; ?>" class="extended-text" /></p>
183
+
184
+ <p><label for="theme_my_login_retrieve_pass_mail_content_type"><?php _e( 'E-mail Format', $this->theme_my_login->textdomain ); ?></label><br />
185
+ <select name="theme_my_login[email][reset_pass][mail_content_type]" id="theme_my_login_reset_pass_mail_content_type">
186
+ <option value="plain"<?php if ( 'plain' == $this->theme_my_login->options['email']['reset_pass']['mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
187
+ <option value="html"<?php if ( 'html' == $this->theme_my_login->options['email']['reset_pass']['mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
188
+ </select></p>
189
+
190
+ <p><label for="theme_my_login_reset_pass_title"><?php _e( 'Subject', $this->theme_my_login->textdomain ); ?></label><br />
191
+ <input name="theme_my_login[email][reset_pass][title]" type="text" id="theme_my_login_reset_pass_title" value="<?php echo $this->theme_my_login->options['email']['reset_pass']['title']; ?>" class="full-text" /></p>
192
+
193
+ <p><label for="theme_my_login_reset_pass_message"><?php _e( 'Message', $this->theme_my_login->textdomain ); ?></label><br />
194
+ <textarea name="theme_my_login[email][reset_pass][message]" id="theme_my_login_reset_pass_message" class="large-text" rows="10"><?php echo $this->theme_my_login->options['email']['reset_pass']['message']; ?></textarea></p>
195
+
196
+ <p class="description"><?php _e( 'Available Variables', $this->theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_pass%, %user_ip%</p>
197
+ </td>
198
+ </tr>
199
+ <tr>
200
+ <td>
201
+ <h3><?php _e( 'Admin Notification', $this->theme_my_login->textdomain ); ?></h3>
202
+
203
+ <p class="description">
204
+ <?php _e( 'This e-mail will be sent to the e-mail address or addresses (multiple addresses may be separated by commas) specified below, upon user password change.', $this->theme_my_login->textdomain ); ?>
205
+ <?php _e( 'If any field is left empty, the default will be used instead.', $this->theme_my_login->textdomain ); ?>
206
+ </p>
207
+
208
+ <p><label for="theme_my_login_reset_pass_admin_mail_to"><?php _e( 'To', $this->theme_my_login->textdomain ); ?></label><br />
209
+ <input name="theme_my_login[email][reset_pass][admin_mail_to]" type="text" id="theme_my_login_reset_pass_admin_mail_to" value="<?php echo $this->theme_my_login->options['email']['reset_pass']['admin_mail_to']; ?>" class="extended-text" /></p>
210
+
211
+ <p><label for="theme_my_login_reset_pass_admin_mail_from_name"><?php _e( 'From Name', $this->theme_my_login->textdomain ); ?></label><br />
212
+ <input name="theme_my_login[email][reset_pass][admin_mail_from_name]" type="text" id="theme_my_login_reset_pass_admin_mail_from_name" value="<?php echo $this->theme_my_login->options['email']['reset_pass']['admin_mail_from_name']; ?>" class="extended-text" /></p>
213
+
214
+ <p><label for="theme_my_login_reset_pass_admin_mail_from"><?php _e( 'From E-mail', $this->theme_my_login->textdomain ); ?></label><br />
215
+ <input name="theme_my_login[email][reset_pass][admin_mail_from]" type="text" id="theme_my_login_reset_pass_admin_mail_from" value="<?php echo $this->theme_my_login->options['email']['reset_pass']['admin_mail_from']; ?>" class="extended-text" /></p>
216
+
217
+ <p><label for="theme_my_login_reset_pass_admin_mail_content_type"><?php _e( 'E-mail Format', $this->theme_my_login->textdomain ); ?></label><br />
218
+ <select name="theme_my_login[email][reset_pass][admin_mail_content_type]" id="theme_my_login_reset_pass_admin_mail_content_type">
219
+ <option value="plain"<?php if ( 'plain' == $this->theme_my_login->options['email']['reset_pass']['admin_mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
220
+ <option value="html"<?php if ( 'html' == $this->theme_my_login->options['email']['reset_pass']['admin_mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
221
+ </select></p>
222
+
223
+ <p><label for="theme_my_login_reset_pass_admin_title"><?php _e( 'Subject', $this->theme_my_login->textdomain ); ?></label><br />
224
+ <input name="theme_my_login[email][reset_pass][admin_title]" type="text" id="theme_my_login_reset_pass_admin_title" value="<?php echo $this->theme_my_login->options['email']['reset_pass']['admin_title']; ?>" class="full-text" /></p>
225
+
226
+ <p><label for="theme_my_login_reset_pass_admin_message"><?php _e( 'Message', $this->theme_my_login->textdomain ); ?></label><br />
227
+ <textarea name="theme_my_login[email][reset_pass][admin_message]" id="theme_my_login_reset_pass_admin_message" class="large-text" rows="10"><?php echo $this->theme_my_login->options['email']['reset_pass']['admin_message']; ?></textarea></p>
228
+
229
+ <p class="description"><?php _e( 'Available Variables', $this->theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_ip%</p>
230
+
231
+ <p><label for="theme_my_login_reset_pass_admin_disable"><input name="theme_my_login[email][reset_pass][admin_disable]" type="checkbox" id="theme_my_login_reset_pass_admin_disable" value="1"<?php checked( 1, $this->theme_my_login->options['email']['reset_pass']['admin_disable'] ); ?> /> <?php _e( 'Disable Admin Notification', $this->theme_my_login->textdomain ); ?></label></p>
232
+ </td>
233
+ </tr>
234
+ </table>
235
+ <?php
236
+ }
237
+
238
+ /**
239
+ * Adds "E-mails" tab to Theme My Login menu
240
+ *
241
+ * Callback for "tml_admin_menu" hook in method Theme_My_Login_Admin::display_settings_page()
242
+ *
243
+ * @see Theme_My_Login_Admin::display_settings_page(), Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
244
+ * @uses Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
245
+ * @since 6.0
246
+ * @access public
247
+ *
248
+ * @param object $admin Reference to global $theme_my_login_admin object
249
+ */
250
+ function admin_menu( &$admin ) {
251
+ $admin->add_menu_page( __( 'E-mail', $this->theme_my_login->textdomain ), 'tml-options-email' );
252
+ $admin->add_submenu_page( 'tml-options-email', __( 'New User', $this->theme_my_login->textdomain ), 'tml-options-email-new-user', array( &$this, 'display_new_user_settings' ) );
253
+ $admin->add_submenu_page( 'tml-options-email', __( 'Retrieve Password', $this->theme_my_login->textdomain ), 'tml-options-email-retrieve-pass', array( &$this, 'display_retrieve_pass_settings' ) );
254
+ $admin->add_submenu_page( 'tml-options-email', __( 'Reset Password', $this->theme_my_login->textdomain ), 'tml-options-email-reset-pass', array( &$this, 'display_reset_pass_settings' ) );
255
+ }
256
+
257
+ /**
258
+ * Loads the module
259
+ *
260
+ * @since 6.0
261
+ * @access public
262
+ */
263
+ function load() {
264
+ add_action( 'tml_admin_menu', array( &$this, 'admin_menu' ) );
265
+ add_filter( 'tml_save_settings', array( &$this, 'save_settings' ) );
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Holds the reference to Theme_My_Login_Custom_Email_Admin object
271
+ * @global object $theme_my_login_custom_email_admin
272
+ * @since 6.0
273
+ */
274
+ $theme_my_login_custom_email_admin = new Theme_My_Login_Custom_Email_Admin();
275
+
276
+ endif; // Class exists
277
+
278
+ ?>
modules/custom-email/admin/options-general.php DELETED
@@ -1,26 +0,0 @@
1
- <table class="form-table">
2
- <tr valign="top">
3
- <td>
4
- <label for="theme_my_login_mail_from_name"><?php _e('From Name', 'theme-my-login'); ?></label><br />
5
- <input name="theme_my_login[email][mail_from_name]" type="text" id="theme_my_login_mail_from_name" value="<?php echo $theme_my_login->options['email']['mail_from_name']; ?>" class="regular-text" />
6
- <p class="description"><?php _e('Enter the name you wish for e-mails to be sent from. If left blank, the default will be used.', 'theme-my-login'); ?></p>
7
- </td>
8
- </tr>
9
- <tr valign="top">
10
- <td>
11
- <label for="theme_my_login_mail_from"><?php _e('From E-mail', 'theme-my-login'); ?></label><br />
12
- <input name="theme_my_login[email][mail_from]" type="text" id="theme_my_login_mail_from" value="<?php echo $theme_my_login->options['email']['mail_from']; ?>" class="regular-text" />
13
- <p class="description"><?php _e('Enter the e-mail address you wish for e-mails to be sent from. If left blank, the default will be used.', 'theme-my-login'); ?></p>
14
- </td>
15
- </tr>
16
- <tr valign="top">
17
- <td>
18
- <label for="theme_my_login_mail_content_type"><?php _e('E-mail Format', 'theme-my-login'); ?></label><br />
19
- <select name="theme_my_login[email][mail_content_type]" id="theme_my_login_mail_content_type">
20
- <option value="plain"<?php if ('plain' == $theme_my_login->options['email']['mail_content_type']) echo ' selected="selected"'; ?>>Plain Text</option>
21
- <option value="html"<?php if ('html' == $theme_my_login->options['email']['mail_content_type']) echo ' selected="selected"'; ?>>HTML</option>
22
- </select>
23
- <p class="description"><?php _e('If you are going to use HTML markup in your e-mail messages, select "HTML" for this setting. Otherwise, select "Plain Text".', 'theme-my-login'); ?></p>
24
- </td>
25
- </tr>
26
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-email/admin/options-new-user.php DELETED
@@ -1,18 +0,0 @@
1
- <table class="form-table">
2
- <tr>
3
- <td>
4
- <p class="description">
5
- <?php _e('This e-mail will be sent to a new user upon registration.', 'theme-my-login'); ?>
6
- <?php _e('Please be sure to include the variable %user_pass% if using default passwords or else the user will not know their password!', 'theme-my-login'); ?>
7
- <?php _e('If either field is left empty, the default will be used instead.', 'theme-my-login'); ?>
8
- </p>
9
- <p class="description"><?php _e('Available Variables', 'theme-my-login'); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_pass%, %user_ip%</p>
10
- <label for="theme_my_login_new_user_title"><?php _e('Subject', 'theme-my-login'); ?></label><br />
11
- <input name="theme_my_login[email][new_user][title]" type="text" id="theme_my_login_new_user_title" value="<?php echo $theme_my_login->options['email']['new_user']['title']; ?>" class="full-text" /><br />
12
- <label for="theme_my_login_new_user_message"><?php _e('Message', 'theme-my-login'); ?></label><br />
13
- <textarea name="theme_my_login[email][new_user][message]" id="theme_my_login_new_user_message" class="large-text" rows="10"><?php echo $theme_my_login->options['email']['new_user']['message']; ?></textarea><br />
14
- <label for="theme_my_login_new_user_admin_disable"><input name="theme_my_login[email][new_user][admin_disable]" type="checkbox" id="theme_my_login_new_user_admin_disable" value="1"<?php checked(1, $theme_my_login->options['email']['new_user']['admin_disable']); ?> /> Disable Admin Notification</label>
15
- <p class="description"><?php _e('Check this option if you do not wish to receive notification everytime someone registers for your blog.', 'theme-my-login'); ?></p>
16
- </td>
17
- </tr>
18
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-email/admin/options-reset-pass.php DELETED
@@ -1,18 +0,0 @@
1
- <table class="form-table">
2
- <tr>
3
- <td>
4
- <p class="description">
5
- <?php _e('This e-mail will be sent to a user upon successful password recovery.', 'theme-my-login'); ?>
6
- <?php _e('Please be sure to include the variable %user_pass% if using default passwords or else the user will not know their password!', 'theme-my-login'); ?>
7
- <?php _e('If either field is left empty, the default will be used instead.', 'theme-my-login'); ?>
8
- </p>
9
- <p class="description"><?php _e('Available Variables', 'theme-my-login'); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_pass%, %user_ip%</p>
10
- <label for="theme_my_login_reset_pass_title"><?php _e('Subject', 'theme-my-login'); ?></label><br />
11
- <input name="theme_my_login[email][reset_pass][title]" type="text" id="theme_my_login_reset_pass_title" value="<?php echo $theme_my_login->options['email']['reset_pass']['title']; ?>" class="full-text" /><br />
12
- <label for="theme_my_login_reset_pass_message"><?php _e('Message', 'theme-my-login'); ?></label><br />
13
- <textarea name="theme_my_login[email][reset_pass][message]" id="theme_my_login_reset_pass_message" class="large-text" rows="10"><?php echo $theme_my_login->options['email']['reset_pass']['message']; ?></textarea><br />
14
- <label for="theme_my_login_reset_pass_admin_disable"><input name="theme_my_login[email][reset_pass][admin_disable]" type="checkbox" id="theme_my_login_reset_pass_admin_disable" value="1"<?php checked(1, $theme_my_login->options['email']['reset_pass']['admin_disable']); ?> /> <?php _e('Disable Admin Notification', 'theme-my-login'); ?></label>
15
- <p class="description"><?php _e('Check this option if you do not wish to receive notification everytime someone recovers their password for your blog.', 'theme-my-login'); ?></p>
16
- </td>
17
- </tr>
18
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-email/admin/options-retrieve-pass.php DELETED
@@ -1,16 +0,0 @@
1
- <table class="form-table">
2
- <tr>
3
- <td>
4
- <p class="description">
5
- <?php _e('This e-mail will be sent to a user when they attempt to recover their password.', 'theme-my-login'); ?>
6
- <?php _e('Please be sure to include the variable %reseturl% or else the user will not be able to recover their password!', 'theme-my-login'); ?>
7
- <?php _e('If either field is left empty, the default will be used instead.', 'theme-my-login'); ?>
8
- </p>
9
- <p><em><?php _e('Available Variables', 'theme-my-login'); ?>: %blogname%, %siteurl%, %reseturl%, %user_login%, %user_email%, %user_ip%</em></p>
10
- <label for="theme_my_login_reset_pass_title"><?php _e('Subject', 'theme-my-login'); ?></label><br />
11
- <input name="theme_my_login[email][retrieve_pass][title]" type="text" id="theme_my_login_retrieve_pass_title" value="<?php echo $theme_my_login->options['email']['retrieve_pass']['title']; ?>" class="full-text" /><br />
12
- <label for="theme_my_login_reset_pass_message"><?php _e('Message', 'theme-my-login'); ?></label><br />
13
- <textarea name="theme_my_login[email][retrieve_pass][message]" id="theme_my_login_retrieve_pass_message" class="large-text" rows="10"><?php echo $theme_my_login->options['email']['retrieve_pass']['message']; ?></textarea><br />
14
- </td>
15
- </tr>
16
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-email/custom-email.php CHANGED
@@ -4,55 +4,684 @@ Plugin Name: Custom E-mail
4
  Description: Enabling this module will initialize custom e-mails. You will then have to configure the settings via the "E-mail" tab.
5
  */
6
 
7
- add_action('tml_init', 'wdbj_tml_custom_email_init');
8
- function wdbj_tml_custom_email_init() {
9
- require_once( TML_MODULE_DIR . '/custom-email/includes/hook-functions.php' );
10
- add_action('retrieve_password', 'wdbj_tml_custom_email_retrieve_pass_filters');
11
- add_action('password_reset', 'wdbj_tml_custom_email_reset_pass_filters', 10, 2);
12
- add_action('register_post', 'wdbj_tml_custom_email_new_user_filters', 10, 2);
13
- }
 
 
 
 
 
 
 
 
 
 
14
 
15
- add_action('tml_admin_init', 'wdbj_tml_custom_email_admin_init');
16
- function wdbj_tml_custom_email_admin_init() {
17
- require_once( TML_MODULE_DIR . '/custom-email/admin/admin.php' );
18
- add_action('tml_admin_menu', 'wdbj_tml_custom_email_admin_menu');
19
- add_filter('tml_save_settings', 'wdbj_tml_custom_email_save_settings');
20
- }
 
 
21
 
22
- add_action('activate_custom-email/custom-email.php', 'wdbj_tml_custom_email_activate');
23
- function wdbj_tml_custom_email_activate() {
24
- $current = wdbj_tml_get_option('email');
25
- $default = wdbj_tml_custom_email_default_settings();
26
-
27
- if ( is_array($current) )
28
- wdbj_tml_update_option(array_merge($default, $current), 'email');
29
- else
30
- wdbj_tml_update_option($default, 'email');
31
-
32
- unset($current, $default);
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- function wdbj_tml_custom_email_default_settings() {
36
- $options = array(
37
- 'mail_from' => '',
38
- 'mail_from_name' => '',
39
- 'mail_content_type' => '',
40
- 'new_user' => array(
41
- 'title' => '',
42
- 'message' => '',
43
- 'admin_disable' => 0
44
- ),
45
- 'retrieve_pass' => array(
46
- 'title' => '',
47
- 'message' => ''
48
- ),
49
- 'reset_pass' => array(
50
- 'title' => '',
51
- 'message' => '',
52
- 'admin_disable' => 0
53
- )
54
- );
55
- return $options;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
4
  Description: Enabling this module will initialize custom e-mails. You will then have to configure the settings via the "E-mail" tab.
5
  */
6
 
7
+ if ( !class_exists( 'Theme_My_Login_Custom_Email' ) ) :
8
+ /**
9
+ * Theme My Login Custom E-mail module class
10
+ *
11
+ * Customize e-mails sent from the login/registration system.
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Custom_Email extends Theme_My_Login_Module {
16
+ /**
17
+ * Holds reference to module specific options in $theme_my_login object options
18
+ *
19
+ * @since 6.0
20
+ * @access public
21
+ * @var array
22
+ */
23
+ var $options;
24
 
25
+ /**
26
+ * Mail from
27
+ *
28
+ * @since 6.0
29
+ * @access public
30
+ * @var string
31
+ */
32
+ var $mail_from;
33
 
34
+ /**
35
+ * Mail from name
36
+ *
37
+ * @since 6.0
38
+ * @access public
39
+ * @var string
40
+ */
41
+ var $mail_from_name;
42
+
43
+ /**
44
+ * Mail content type
45
+ *
46
+ * @since 6.0
47
+ * @access public
48
+ * @var string
49
+ */
50
+ var $mail_content_type;
51
+
52
+ /**
53
+ * Sets variables to be used with mail header filters
54
+ *
55
+ * @since 6.0
56
+ * @access public
57
+ *
58
+ * @param string $mail_from E-mail address to send the mail from
59
+ * @param string $mail_from_name Name to send the mail from
60
+ * @param string $mail_content_type Content type for the message
61
+ */
62
+ function set_mail_headers( $mail_from = '', $mail_from_name = '', $mail_content_type = 'text' ) {
63
+ $this->mail_from = $mail_from;
64
+ $this->mail_from_name = $mail_from_name;
65
+ $this->mail_content_type = $mail_content_type;
66
+ }
67
+
68
+ /**
69
+ * Applies all password retrieval mail filters
70
+ *
71
+ * Callback for "retrieve_password" hook in method Theme_My_Login::retrieve_password()
72
+ *
73
+ * @see Theme_My_Login::retrieve_password()
74
+ * @since 6.0
75
+ * @access public
76
+ */
77
+ function apply_retrieve_pass_filters() {
78
+ $options =& $this->options['retrieve_pass'];
79
+ $this->set_mail_headers( $options['mail_from'], $options['mail_from_name'], $options['mail_content_type'] );
80
+ add_filter( 'retrieve_password_title', array( &$this, 'retrieve_pass_title_filter' ), 10, 2 );
81
+ add_filter( 'retrieve_password_message', array( &$this, 'retrieve_pass_message_filter' ), 10, 3 );
82
+ }
83
+
84
+ /**
85
+ * Applies all password reset mail filters
86
+ *
87
+ * Callback for "password_reset" hook in method Theme_My_Login::reset_password()
88
+ *
89
+ * @see Theme_My_Login::reset_password()
90
+ * @since 6.0
91
+ * @access public
92
+ */
93
+ function apply_reset_pass_filters() {
94
+ $options =& $this->options['reset_pass'];
95
+ $this->set_mail_headers( $options['mail_from'], $options['mail_from_name'], $options['mail_content_type'] );
96
+ add_filter( 'password_reset_title', array( &$this, 'reset_pass_title_filter' ), 10, 2 );
97
+ add_filter( 'password_reset_message', array( &$this, 'reset_pass_message_filter' ), 10, 3 );
98
+ add_filter( 'password_change_notification_mail_to', array( &$this, 'password_change_notification_mail_to_filter' ) );
99
+ add_filter( 'password_change_notification_title', array( &$this, 'password_change_notification_title_filter' ), 10, 2 );
100
+ add_filter( 'password_change_notification_message', array( &$this, 'password_change_notification_message_filter' ), 10, 2 );
101
+ add_filter( 'send_password_change_notification', array( &$this, 'send_password_change_notification_filter' ) );
102
+ }
103
+
104
+ /**
105
+ * Applies all new user mail filters
106
+ *
107
+ * Callback for "register_post" hook in method Theme_My_Login::register_new_user()
108
+ *
109
+ * @see Theme_My_Login::register_new_user()
110
+ * @since 6.0
111
+ * @access public
112
+ */
113
+ function apply_new_user_filters() {
114
+ add_filter( 'new_user_notification_title', array( &$this, 'new_user_notification_title_filter' ), 10, 2 );
115
+ add_filter( 'new_user_notification_message', array( &$this, 'new_user_notification_message_filter' ), 10, 3 );
116
+ add_filter( 'send_new_user_notification', array( &$this, 'send_new_user_notification_filter' ) );
117
+ add_filter( 'new_user_admin_notification_mail_to', array( &$this, 'new_user_admin_notification_mail_to_filter' ) );
118
+ add_filter( 'new_user_admin_notification_title', array( &$this, 'new_user_admin_notification_title_filter' ), 10, 2 );
119
+ add_filter( 'new_user_admin_notification_message', array( &$this, 'new_user_admin_notification_message_filter' ), 10, 2 );
120
+ add_filter( 'send_new_user_admin_notification', array( &$this, 'send_new_user_admin_notification_filter' ) );
121
+ }
122
+
123
+ /**
124
+ * Changes the mail from address
125
+ *
126
+ * Callback for "wp_mail_from" hook in wp_mail()
127
+ *
128
+ * @see wp_mail()
129
+ * @since 6.0
130
+ * @access public
131
+ *
132
+ * @param string $from_email Default from email
133
+ * @return string New from email
134
+ */
135
+ function mail_from_filter( $from_email ) {
136
+ return empty( $this->mail_from ) ? $from_email : $this->mail_from;
137
+ }
138
+
139
+ /**
140
+ * Changes the mail from name
141
+ *
142
+ * Callback for "wp_mail_from_name" hook in wp_mail()
143
+ *
144
+ * @see wp_mail()
145
+ * @since 6.0
146
+ * @access public
147
+ *
148
+ * @param string $from_name Default from name
149
+ * @return string New from name
150
+ */
151
+ function mail_from_name_filter( $from_name ) {
152
+ return empty( $this->mail_from_name ) ? $from_name : $this->mail_from_name;
153
+ }
154
+
155
+ /**
156
+ * Changes the mail content type
157
+ *
158
+ * Callback for "wp_mail_content_type" hook in wp_mail()
159
+ *
160
+ * @see wp_mail()
161
+ * @since 6.0
162
+ * @access public
163
+ *
164
+ * @param string $content_type Default content type
165
+ * @return string New content type
166
+ */
167
+ function mail_content_type_filter( $content_type ) {
168
+ return empty( $this->mail_content_type ) ? $content_type : 'text/' . $this->mail_content_type;
169
+ }
170
+
171
+ /**
172
+ * Changes the retrieve password e-mail subject
173
+ *
174
+ * Callback for "retrieve_pass_title" hook in Theme_My_Login::retrieve_password()
175
+ *
176
+ * @see Theme_My_Login::retrieve_password()
177
+ * @since 6.0
178
+ * @access public
179
+ *
180
+ * @param string $title Default subject
181
+ * @param int $user_id User ID
182
+ * @return string New subject
183
+ */
184
+ function retrieve_pass_title_filter( $title, $user_id ) {
185
+ return empty( $this->options['retrieve_pass']['title'] ) ? $title : $this->replace_vars( $this->options['retrieve_pass']['title'], $user_id );
186
+ }
187
+
188
+ /**
189
+ * Changes the retrieve password e-mail message
190
+ *
191
+ * Callback for "retrieve_password_message" hook in Theme_My_Login::retrieve_password()
192
+ *
193
+ * @see Theme_My_Login::retrieve_password()
194
+ * @since 6.0
195
+ * @access public
196
+ *
197
+ * @param string $message Default message
198
+ * @param string $key The user's reset key
199
+ * @param int $user_id User ID
200
+ * @return string New message
201
+ */
202
+ function retrieve_pass_message_filter( $message, $key, $user_id ) {
203
+ $user = get_userdata($user_id);
204
+ $replacements = array(
205
+ '%loginurl%' => site_url( 'wp-login.php', 'login' ),
206
+ '%reseturl%' => site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' )
207
+ );
208
+ return empty( $this->options['retrieve_pass']['message'] ) ? $message : $this->replace_vars( $this->options['retrieve_pass']['message'], $user_id, $replacements );
209
+ }
210
+
211
+ /**
212
+ * Changes the password reset e-mail subject
213
+ *
214
+ * Callback for "password_reset_title" hook in Theme_My_Login::reset_password()
215
+ *
216
+ * @see Theme_My_Login::reset_password()
217
+ * @since 6.0
218
+ * @access public
219
+ *
220
+ * @param string $title Default title
221
+ * @param int $user_id User ID
222
+ * @return string New title
223
+ */
224
+ function reset_pass_title_filter( $title, $user_id ) {
225
+ return empty( $this->options['reset_pass']['title'] ) ? $title : $this->replace_vars( $this->options['reset_pass']['title'], $user_id );
226
+ }
227
+
228
+ /**
229
+ * Changes the password reset e-mail message
230
+ *
231
+ * Callback for "password_reset_message" hook in Theme_My_Login::reset_password()
232
+ *
233
+ * @see Theme_My_Login::reset_password()
234
+ * @since 6.0
235
+ * @access public
236
+ *
237
+ * @param string $message Default message
238
+ * @param string $new_pass The user's new password
239
+ * @param int $user_id User ID
240
+ * @return string New message
241
+ */
242
+ function reset_pass_message_filter( $message, $new_pass, $user_id ) {
243
+ $replacements = array(
244
+ '%loginurl%' => site_url( 'wp-login.php', 'login' ),
245
+ '%user_pass%' => $new_pass
246
+ );
247
+ return empty( $this->options['reset_pass']['message'] ) ? $message : $this->replace_vars( $this->options['reset_pass']['message'], $user_id, $replacements );
248
+ }
249
+
250
+ /**
251
+ * Changes who the password change notification e-mail is sent to
252
+ *
253
+ * Callback for "password_change_notification_mail_to" hook in Theme_My_Login_Custom_Email::password_change_notification()
254
+ *
255
+ * @see Theme_My_Login_Custom_Email::password_change_notification()
256
+ * @since 6.0
257
+ * @access public
258
+ *
259
+ * @param string $to Default admin e-mail address
260
+ * @return string New e-mail address(es)
261
+ */
262
+ function password_change_notification_mail_to_filter( $to ) {
263
+ return empty( $this->options['reset_pass']['admin_mail_to'] ) ? $to : $this->options['reset_pass']['admin_mail_to'];
264
+ }
265
+
266
+ /**
267
+ * Changes the password change notification e-mail subject
268
+ *
269
+ * Callback for "password_change_notification_title" hook in Theme_My_Login_Custom_Email::password_change_notification()
270
+ *
271
+ * @see Theme_My_Login_Custom_Email::password_change_notification()
272
+ * @since 6.0
273
+ * @access public
274
+ *
275
+ * @param string $title Default subject
276
+ * @param int $user_id User ID
277
+ * @return string New subject
278
+ */
279
+ function password_change_notification_title_filter( $title, $user_id ) {
280
+ return empty( $this->options['reset_pass']['admin_title'] ) ? $title : $this->replace_vars( $this->options['reset_pass']['admin_title'], $user_id );
281
+ }
282
+
283
+ /**
284
+ * Changes the password change notification e-mail message
285
+ *
286
+ * Callback for "password_change_notification_message" hook in Theme_My_Login_Custom_Email::password_change_notification()
287
+ *
288
+ * @see Theme_My_Login_Custom_Email::password_change_notification()
289
+ * @since 6.0
290
+ * @access public
291
+ *
292
+ * @param string $title Default message
293
+ * @param int $user_id User ID
294
+ * @return string New message
295
+ */
296
+ function password_change_notification_message_filter( $message, $user_id ) {
297
+ return empty( $this->options['reset_pass']['admin_message'] ) ? $message : $this->replace_vars( $this->options['reset_pass']['admin_message'], $user_id );
298
+ }
299
+
300
+ /**
301
+ * Determines whether or not to send the password change notification e-mail
302
+ *
303
+ * Callback for "send_password_change_notification" hook in Theme_My_Login_Custom_Email::password_change_notification()
304
+ *
305
+ * @see Theme_My_Login_Custom_Email::password_change_notification()
306
+ * @since 6.0
307
+ * @access public
308
+ *
309
+ * @param bool $enable Default setting
310
+ * @return bool New setting
311
+ */
312
+ function send_password_change_notification_filter( $enable ) {
313
+ $options =& $this->options['reset_pass'];
314
+ $this->set_mail_headers( $options['admin_mail_from'], $options['admin_mail_from_name'], $options['admin_mail_content_type'] );
315
+ if ( $this->options['reset_pass']['admin_disable'] )
316
+ return false;
317
+ return $enable;
318
+ }
319
+
320
+ /**
321
+ * Changes the new user e-mail subject
322
+ *
323
+ * Callback for "new_user_notification_title" hook in Theme_My_Login_Custom_Email::new_user_notification()
324
+ *
325
+ * @see Theme_My_Login_Custom_Email::new_user_notification()
326
+ * @since 6.0
327
+ * @access public
328
+ *
329
+ * @param string $title Default title
330
+ * @param int $user_id User ID
331
+ * @return string New title
332
+ */
333
+ function new_user_notification_title_filter( $title, $user_id ) {
334
+ return empty( $this->options['new_user']['title'] ) ? $title : $this->replace_vars( $this->options['new_user']['title'], $user_id );
335
+ }
336
+
337
+ /**
338
+ * Changes the new user e-mail message
339
+ *
340
+ * Callback for "new_user_notification_message" hook in Theme_My_Login_Custom_Email::new_user_notification()
341
+ *
342
+ * @see Theme_My_Login_Custom_Email::new_user_notification()
343
+ * @since 6.0
344
+ * @access public
345
+ *
346
+ * @param string $title Default message
347
+ * @param string $new_pass The user's password
348
+ * @param int $user_id User ID
349
+ * @return string New message
350
+ */
351
+ function new_user_notification_message_filter( $message, $new_pass, $user_id ) {
352
+ $replacements = array(
353
+ '%loginurl%' => site_url( 'wp-login.php', 'login' ),
354
+ '%user_pass%' => $new_pass
355
+ );
356
+ return empty( $this->options['new_user']['message'] ) ? $message : $this->replace_vars( $this->options['new_user']['message'], $user_id, $replacements );
357
+ }
358
+
359
+ /**
360
+ * Determines whether or not to send the new user e-mail
361
+ *
362
+ * Callback for "send_new_user_notification" hook in Theme_My_Login_Custom_Email::new_user_notification()
363
+ *
364
+ * @see Theme_My_Login_Custom_Email::new_user_notification()
365
+ * @since 6.0
366
+ * @access public
367
+ *
368
+ * @param bool $enable Default setting
369
+ * @return bool New setting
370
+ */
371
+ function send_new_user_notification_filter( $enable ) {
372
+ $options =& $this->options['new_user'];
373
+ $this->set_mail_headers( $options['mail_from'], $options['mail_from_name'], $options['mail_content_type'] );
374
+ return $enable;
375
+ }
376
+
377
+ /**
378
+ * Changes who the new user admin notification e-mail is sent to
379
+ *
380
+ * Callback for "new_user_admin_notification_mail_to" hook in Theme_My_Login_Custom_Email::new_user_notification()
381
+ *
382
+ * @see Theme_My_Login_Custom_Email::new_user_notification()
383
+ * @since 6.0
384
+ * @access public
385
+ *
386
+ * @param string $to Default admin e-mail address
387
+ * @return string New e-mail address(es)
388
+ */
389
+ function new_user_admin_notification_mail_to_filter( $to ) {
390
+ return empty( $this->options['new_user']['admin_mail_to'] ) ? $to : $this->options['new_user']['admin_mail_to'];
391
+ }
392
+
393
+ /**
394
+ * Changes the new user admin notification e-mail subject
395
+ *
396
+ * Callback for "new_user_admin_notification_title" hook in Theme_My_Login_Custom_Email::new_user_notification()
397
+ *
398
+ * @see Theme_My_Login_Custom_Email::new_user_notification()
399
+ * @since 6.0
400
+ * @access public
401
+ *
402
+ * @param string $title Default subject
403
+ * @param int $user_id User ID
404
+ * @return string New subject
405
+ */
406
+ function new_user_admin_notification_title_filter( $title, $user_id ) {
407
+ return empty( $this->options['new_user']['admin_title'] ) ? $title : $this->replace_vars( $this->options['new_user']['admin_title'], $user_id );
408
+ }
409
+
410
+ /**
411
+ * Changes the new user admin notification e-mail message
412
+ *
413
+ * Callback for "new_user_admin_notification_message" hook in Theme_My_Login_Custom_Email::new_user_notification()
414
+ *
415
+ * @see Theme_My_Login_Custom_Email::new_user_notification()
416
+ * @since 6.0
417
+ * @access public
418
+ *
419
+ * @param string $title Default message
420
+ * @param int $user_id User ID
421
+ * @return string New message
422
+ */
423
+ function new_user_admin_notification_message_filter( $message, $user_id ) {
424
+ return empty( $this->options['new_user']['admin_message'] ) ? $message : $this->replace_vars( $this->options['new_user']['admin_message'], $user_id );
425
+ }
426
+
427
+ /**
428
+ * Determines whether or not to send the new user admin notification e-mail
429
+ *
430
+ * Callback for "send_new_user_admin_notification" hook in Theme_My_Login_Custom_Email::new_user_notification()
431
+ *
432
+ * @see Theme_My_Login_Custom_Email::new_user_notification()
433
+ * @since 6.0
434
+ * @access public
435
+ *
436
+ * @param bool $enable Default setting
437
+ * @return bool New setting
438
+ */
439
+ function send_new_user_admin_notification_filter( $enable ) {
440
+ $options =& $this->options['new_user'];
441
+ $this->set_mail_headers( $options['admin_mail_from'], $options['admin_mail_from_name'], $options['admin_mail_content_type'] );
442
+ if ( $options['admin_disable'] )
443
+ return false;
444
+ return $enable;
445
+ }
446
+
447
+ /**
448
+ * Notify the blog admin of a new user
449
+ *
450
+ * @since 6.0
451
+ * @access public
452
+ *
453
+ * @param int $user_id User ID
454
+ * @param string $plaintext_pass Optional. The user's plaintext password
455
+ */
456
+ function new_user_notification( $user_id, $plaintext_pass = '' ) {
457
+ $user = new WP_User( $user_id );
458
+
459
+ do_action( 'tml_new_user_notification', $user_id, $plaintext_pass );
460
 
461
+ $user_login = stripslashes( $user->user_login );
462
+ $user_email = stripslashes( $user->user_email );
463
+
464
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
465
+ $blogname = $GLOBALS['current_site']->site_name;
466
+ } else {
467
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
468
+ // we want to reverse this for the plain text arena of emails.
469
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
470
+ }
471
+
472
+ if ( apply_filters( 'send_new_user_admin_notification', true ) ) {
473
+ $message = sprintf( __( 'New user registration on your site %s:', $this->theme_my_login->textdomain ), $blogname ) . "\r\n\r\n";
474
+ $message .= sprintf( __( 'Username: %s', $this->theme_my_login->textdomain ), $user_login ) . "\r\n\r\n";
475
+ $message .= sprintf( __( 'E-mail: %s', $this->theme_my_login->textdomain ), $user_email ) . "\r\n";
476
+
477
+ $title = sprintf( __( '[%s] New User Registration', $this->theme_my_login->textdomain ), $blogname );
478
+
479
+ $title = apply_filters( 'new_user_admin_notification_title', $title, $user_id );
480
+ $message = apply_filters( 'new_user_admin_notification_message', $message, $user_id );
481
+
482
+ $to = apply_filters( 'new_user_admin_notification_mail_to', get_option( 'admin_email' ) );
483
+
484
+ @wp_mail( $to, $title, $message );
485
+ }
486
+
487
+ if ( empty( $plaintext_pass ) )
488
+ return;
489
+
490
+ if ( apply_filters( 'send_new_user_notification', true ) ) {
491
+ $message = sprintf( __( 'Username: %s', $this->theme_my_login->textdomain ), $user_login ) . "\r\n";
492
+ $message .= sprintf( __( 'Password: %s', $this->theme_my_login->textdomain ), $plaintext_pass ) . "\r\n";
493
+ $message .= wp_login_url() . "\r\n";
494
+
495
+ $title = sprintf( __( '[%s] Your username and password', $this->theme_my_login->textdomain ), $blogname);
496
+
497
+ $title = apply_filters( 'new_user_notification_title', $title, $user_id );
498
+ $message = apply_filters( 'new_user_notification_message', $message, $plaintext_pass, $user_id );
499
+
500
+ wp_mail( $user_email, $title, $message );
501
+ }
502
+ }
503
+
504
+ /**
505
+ * Notify the blog admin of a user changing password
506
+ *
507
+ * @since 6.0
508
+ * @access public
509
+ *
510
+ * @param object $user User object
511
+ */
512
+ function password_change_notification( &$user ) {
513
+ $to = apply_filters( 'password_change_notification_mail_to', get_option( 'admin_email' ) );
514
+ // send a copy of password change notification to the admin
515
+ // but check to see if it's the admin whose password we're changing, and skip this
516
+ if ( $user->user_email != $to && apply_filters( 'send_password_change_notification', true ) ) {
517
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
518
+ $blogname = $GLOBALS['current_site']->site_name;
519
+ } else {
520
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
521
+ // we want to reverse this for the plain text arena of emails.
522
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
523
+ }
524
+
525
+ $title = sprintf( __( '[%s] Password Lost/Changed' ), $blogname );
526
+ $message = sprintf( __( 'Password Lost and Changed for user: %s' ), $user->user_login ) . "\r\n";
527
+
528
+ $title = apply_filters( 'password_change_notification_title', $title, $user->ID );
529
+ $message = apply_filters( 'password_change_notification_message', $message, $user->ID );
530
+
531
+ wp_mail( $to, $title, $message );
532
+ }
533
+ }
534
+
535
+ /**
536
+ * Replaces certain user and blog variables in $input string
537
+ *
538
+ * @since 6.0
539
+ * @access public
540
+ *
541
+ * @param string $input The input string
542
+ * @param int $user_id User ID to replace user specific variables
543
+ * @param array $replacements Misc variables => values replacements
544
+ * @return string The $input string with variables replaced
545
+ */
546
+ function replace_vars( $input, $user_id = '', $replacements = array() ) {
547
+ // Get user data
548
+ if ( $user_id )
549
+ $user = get_userdata( $user_id );
550
+
551
+ // Get all matches ($matches[0] will be '%value%'; $matches[1] will be 'value')
552
+ preg_match_all( '/%([^%]*)%/', $input, $matches );
553
+
554
+ // Allow %user_ip% variable
555
+ $replacements['%user_ip%'] = $_SERVER['REMOTE_ADDR'];
556
+
557
+ // Iterate through matches
558
+ foreach ( $matches[0] as $key => $match ) {
559
+ if ( !isset( $replacements[$match] ) ) {
560
+ if ( isset( $user ) && isset( $user->{$matches[1][$key]} ) ) // Replacement from WP_User object
561
+ $replacements[$match] = ( '%user_pass%' == $match ) ? '' : $user->{$matches[1][$key]};
562
+ else
563
+ $replacements[$match] = get_bloginfo( $matches[1][$key] ); // Replacement from get_bloginfo()
564
+ }
565
+ }
566
+ return str_replace( array_keys( $replacements ), array_values( $replacements ), $input );
567
+ }
568
+
569
+ /**
570
+ * Activates this module
571
+ *
572
+ * Callback for "tml_activate_custom-email/custom-email.php" hook in method Theme_My_Login_Admin::activate_module()
573
+ *
574
+ * @see Theme_My_Login_Admin::activate_module()
575
+ * @since 6.0
576
+ * @access public
577
+ *
578
+ * @param object $theme_my_login Reference to global $theme_my_login object
579
+ */
580
+ function activate( &$theme_my_login ) {
581
+ $options = $this->init_options();
582
+ if ( !isset( $theme_my_login->options['email'] ) ) {
583
+ $theme_my_login->options['email'] = $options['email'];
584
+ } else {
585
+ $theme_my_login->options['email'] = $theme_my_login->array_merge_recursive( $options['email'], $theme_my_login->options['email'] );
586
+ }
587
+ }
588
+
589
+ /**
590
+ * Initializes options for this module
591
+ *
592
+ * Callback for "tml_init_options" hook in method Theme_My_Login_Base::init_options()
593
+ *
594
+ * @see Theme_My_Login_Base::init_options()
595
+ * @since 6.0
596
+ * @access public
597
+ *
598
+ * @param array $options Options passed in from filter
599
+ * @return array Original $options array with module options appended
600
+ */
601
+ function init_options( $options = array() ) {
602
+ // Make sure it's an array
603
+ $options = (array) $options;
604
+ // Assign our options
605
+ $options['email'] = array(
606
+ 'new_user' => array(
607
+ 'mail_from' => '',
608
+ 'mail_from_name' => '',
609
+ 'mail_content_type' => '',
610
+ 'title' => '',
611
+ 'message' => '',
612
+ 'admin_mail_to' => '',
613
+ 'admin_mail_from' => '',
614
+ 'admin_mail_from_name' => '',
615
+ 'admin_mail_content_type' => '',
616
+ 'admin_title' => '',
617
+ 'admin_message' => '',
618
+ 'admin_disable' => 0
619
+ ),
620
+ 'retrieve_pass' => array(
621
+ 'mail_from' => '',
622
+ 'mail_from_name' => '',
623
+ 'mail_content_type' => '',
624
+ 'title' => '',
625
+ 'message' => ''
626
+ ),
627
+ 'reset_pass' => array(
628
+ 'mail_from' => '',
629
+ 'mail_from_name' => '',
630
+ 'mail_content_type' => '',
631
+ 'title' => '',
632
+ 'message' => '',
633
+ 'admin_mail_to' => '',
634
+ 'admin_mail_from' => '',
635
+ 'admin_mail_from_name' => '',
636
+ 'admin_mail_content_type' => '',
637
+ 'admin_title' => '',
638
+ 'admin_message' => '',
639
+ 'admin_disable' => 0
640
+ )
641
+ );
642
+ return $options;
643
+ }
644
+
645
+ /**
646
+ * Loads the module
647
+ *
648
+ * @since 6.0
649
+ * @access public
650
+ */
651
+ function load() {
652
+ // Create a reference to custom e-mail options
653
+ $this->options =& $this->theme_my_login->options['email'];
654
+ // Activate
655
+ add_action( 'tml_activate_custom-email/custom-email.php', array( &$this, 'activate' ) );
656
+ // Initialize
657
+ add_filter( 'tml_init_options', array( &$this, 'init_options' ) );
658
+ // E-mail filters
659
+ add_filter( 'wp_mail_from', array( &$this, 'mail_from_filter' ) );
660
+ add_filter( 'wp_mail_from_name', array( &$this, 'mail_from_name_filter') );
661
+ add_filter( 'wp_mail_content_type', array( &$this, 'mail_content_type_filter') );
662
+
663
+ add_action( 'retrieve_password', array( &$this, 'apply_retrieve_pass_filters' ) );
664
+ add_action( 'password_reset', array( &$this, 'apply_reset_pass_filters' ) );
665
+ add_action( 'tml_new_user_notification', array( &$this, 'apply_new_user_filters' ) );
666
+
667
+ remove_action( 'tml_new_user_registered', 'wp_new_user_notification', 10, 2 );
668
+ add_action( 'tml_new_user_registered', array( &$this, 'new_user_notification' ), 10, 2 );
669
+
670
+ remove_action( 'tml_user_password_changed', 'wp_password_change_notification' );
671
+ add_action( 'tml_user_password_changed', array( &$this, 'password_change_notification' ) );
672
+ }
673
  }
674
 
675
+ /**
676
+ * Holds the reference to Theme_My_Login_Custom_Email object
677
+ * @global object $theme_my_login_custom_email
678
+ * @since 6.0
679
+ */
680
+ $theme_my_login_custom_email = new Theme_My_Login_Custom_Email();
681
+
682
+ if ( is_admin() )
683
+ include_once( TML_ABSPATH . '/modules/custom-email/admin/custom-email-admin.php' );
684
+
685
+ endif; // Class exists
686
+
687
+ ?>
modules/custom-email/includes/hook-functions.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_custom_email_headers() {
4
- add_filter('wp_mail_from', 'wdbj_tml_custom_email_from');
5
- add_filter('wp_mail_from_name', 'wdbj_tml_custom_email_from_name');
6
- add_filter('wp_mail_content_type', 'wdbj_tml_custom_email_content_type');
7
- }
8
-
9
- function wdbj_tml_custom_email_retrieve_pass_filters($user_login) {
10
- wdbj_tml_custom_email_headers();
11
- add_filter('retrieve_password_title', 'wdbj_tml_custom_email_retrieve_pass_title', 10, 2);
12
- add_filter('retrieve_password_message', 'wdbj_tml_custom_email_retrieve_pass_message', 10, 3);
13
- }
14
-
15
- function wdbj_tml_custom_email_reset_pass_filters($user, $new_pass) {
16
- wdbj_tml_custom_email_headers();
17
- add_filter('password_reset_title', 'wdbj_tml_custom_email_reset_pass_title', 10, 2);
18
- add_filter('password_reset_message', 'wdbj_tml_custom_email_reset_pass_message', 10, 3);
19
- add_filter('password_change_notification', 'wdbj_tml_custom_email_reset_pass_disable');
20
- }
21
-
22
- function wdbj_tml_custom_email_new_user_filters($user_id, $user_pass) {
23
- wdbj_tml_custom_email_headers();
24
- add_filter('new_user_notification_title', 'wdbj_tml_custom_email_new_user_title', 10, 2);
25
- add_filter('new_user_notification_message', 'wdbj_tml_custom_email_new_user_message', 10, 3);
26
- add_filter('new_user_admin_notification', 'wdbj_tml_custom_email_new_user_admin_disable');
27
- }
28
-
29
- function wdbj_tml_custom_email_from($from_email) {
30
- $_from_email = wdbj_tml_get_option('email', 'mail_from');
31
- return empty($_from_email) ? $from_email : $_from_email;
32
- }
33
-
34
- function wdbj_tml_custom_email_from_name($from_name) {
35
- $_from_name = wdbj_tml_get_option('email', 'mail_from_name');
36
- return empty($_from_name) ? $from_name : $_from_name;
37
- }
38
-
39
- function wdbj_tml_custom_email_content_type($content_type) {
40
- $_content_type = wdbj_tml_get_option('email', 'mail_content_type');
41
- return empty($_content_type) ? $content_type : 'text/' . $_content_type;
42
- }
43
-
44
- function wdbj_tml_custom_email_retrieve_pass_title($title, $user_id) {
45
- $_title = wdbj_tml_get_option('email', 'retrieve_pass', 'title');
46
- return empty($_title) ? $title : wdbj_tml_custom_email_replace_vars($_title, $user_id);
47
- }
48
-
49
- function wdbj_tml_custom_email_retrieve_pass_message($message, $key, $user_id) {
50
- $_message = wdbj_tml_get_option('email', 'retrieve_pass', 'message');
51
- $user = get_userdata($user_id);
52
- $replacements = array(
53
- '%loginurl%' => site_url('wp-login.php', 'login'),
54
- '%reseturl%' => site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login')
55
- );
56
- return empty($_message) ? $message : wdbj_tml_custom_email_replace_vars($_message, $user_id, $replacements);
57
- }
58
-
59
- function wdbj_tml_custom_email_reset_pass_title($title, $user_id) {
60
- $_title = wdbj_tml_get_option('email', 'reset_pass', 'title');
61
- return empty($_title) ? $title : wdbj_tml_custom_email_replace_vars($_title, $user_id);
62
- }
63
-
64
- function wdbj_tml_custom_email_reset_pass_message($message, $new_pass, $user_id) {
65
- $_message = wdbj_tml_get_option('email', 'reset_pass', 'message');
66
- $replacements = array(
67
- '%loginurl%' => site_url('wp-login.php', 'login'),
68
- '%user_pass%' => $new_pass
69
- );
70
- return empty($_message) ? $message : wdbj_tml_custom_email_replace_vars($_message, $user_id, $replacements);
71
- }
72
-
73
- function wdbj_tml_custom_email_reset_pass_disable($enable) {
74
- return ( wdbj_tml_get_option('email', 'reset_pass', 'admin_disable') ) ? 0 : 1;
75
- }
76
-
77
- function wdbj_tml_custom_email_new_user_title($title, $user_id) {
78
- $_title = wdbj_tml_get_option('email', 'new_user', 'title');
79
- return empty($_title) ? $title : wdbj_tml_custom_email_replace_vars($_title, $user_id);
80
- }
81
-
82
- function wdbj_tml_custom_email_new_user_message($message, $new_pass, $user_id) {
83
- $_message = wdbj_tml_get_option('email', 'new_user', 'message');
84
- $replacements = array(
85
- '%loginurl%' => site_url('wp-login.php', 'login'),
86
- '%user_pass%' => $new_pass
87
- );
88
- return empty($_message) ? $message : wdbj_tml_custom_email_replace_vars($_message, $user_id, $replacements);
89
- }
90
-
91
- function wdbj_tml_custom_email_new_user_admin_disable($enable) {
92
- return ( wdbj_tml_get_option('email', 'new_user', 'admin_disable') ) ? 0 : 1;
93
- }
94
-
95
- function wdbj_tml_custom_email_replace_vars($text, $user_id = '', $replacements = array()) {
96
- // Get user data
97
- if ( $user_id )
98
- $user = get_userdata($user_id);
99
-
100
- // Get all matches ($matches[0] will be '%value%'; $matches[1] will be 'value')
101
- preg_match_all('/%([^%]*)%/', $text, $matches);
102
-
103
- // Iterate through matches
104
- foreach ( $matches[0] as $key => $match ) {
105
- if ( isset($replacements[$match]) )
106
- continue;
107
- if ( isset($user) && isset($user->{$matches[1][$key]}) )
108
- $replacements[$match] = $user->{$matches[1][$key]};
109
- else
110
- $replacements[$match] = get_bloginfo($matches[1][$key]);
111
- }
112
- return str_replace(array_keys($replacements), array_values($replacements), $text);
113
- }
114
-
115
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-passwords/custom-passwords.php CHANGED
@@ -4,26 +4,395 @@ Plugin Name: Custom Passwords
4
  Description: Enabling this module will initialize and enable custom passwords. There are no other settings for this module.
5
  */
6
 
7
- add_action('tml_init', 'wdbj_tml_custom_pass_init');
8
- function wdbj_tml_custom_pass_init() {
9
- include_once( TML_MODULE_DIR . '/custom-passwords/includes/hook-functions.php' );
10
- require_once( TML_MODULE_DIR . '/custom-passwords/includes/functions.php' );
11
- // Password registration
12
- add_action('register_form', 'wdbj_tml_custom_pass_form');
13
- add_filter('registration_errors', 'wdbj_tml_custom_pass_errors');
14
- add_filter('user_registration_pass', 'wdbj_tml_custom_pass_set_pass');
15
- // Password reset
16
- add_action('login_form_resetpass', 'wdbj_tml_custom_pass_reset_form');
17
- add_action('login_form_rp', 'wdbj_tml_custom_pass_reset_form');
18
- add_action('login_action_resetpass', 'wdbj_tml_custom_pass_reset_action');
19
- add_action('login_action_rp', 'wdbj_tml_custom_pass_reset_action');
20
- // Template messages
21
- add_filter('login_message', 'wdbj_tml_custom_pass_login_message');
22
- add_filter('lostpassword_message', 'wdbj_tml_custom_pass_lostpassword_message');
23
- add_action('template_redirect', 'wdbj_tml_custom_pass_messages', 100);
24
- // Redirection
25
- add_filter('register_redirect', 'wdbj_tml_custom_pass_register_redirect');
26
- add_filter('resetpass_redirect', 'wdbj_tml_custom_pass_resetpass_redirect');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
29
- ?>
 
 
 
 
 
 
 
 
 
4
  Description: Enabling this module will initialize and enable custom passwords. There are no other settings for this module.
5
  */
6
 
7
+ if ( !class_exists( 'Theme_My_Login_Custom_Passwords' ) ) :
8
+ /**
9
+ * Theme My Login Custom Passwords module class
10
+ *
11
+ * Adds the ability for users to set their own passwords upon registration and password reset.
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Custom_Passwords extends Theme_My_Login_Module {
16
+ /**
17
+ * Outputs password fields to registration form
18
+ *
19
+ * Callback for "tml_register_form" hook in file "register-form.php", included by Theme_My_Login_Template::display()
20
+ *
21
+ * @see Theme_My_Login::display()
22
+ * @since 6.0
23
+ * @access public
24
+ *
25
+ * @param object $template Reference to Theme_My_Login_Template object
26
+ */
27
+ function password_fields( &$template ) {
28
+ ?>
29
+ <p><label for="pass1<?php $template->the_instance(); ?>"><?php _e( 'Password:', $this->theme_my_login->textdomain );?></label>
30
+ <input autocomplete="off" name="pass1" id="pass1<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" /></p>
31
+ <p><label for="pass2<?php $template->the_instance(); ?>"><?php _e( 'Confirm Password:', $this->theme_my_login->textdomain );?></label>
32
+ <input autocomplete="off" name="pass2" id="pass2<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" /></p>
33
+ <?php
34
+ }
35
+
36
+ /**
37
+ * Handles password errors for registration form
38
+ *
39
+ * Callback for "registration_errors" hook in Theme_My_Login::register_new_user()
40
+ *
41
+ * @see Theme_My_Login::register_new_user()
42
+ * @since 6.0
43
+ * @access public
44
+ *
45
+ * @param WP_Error $errors WP_Error object
46
+ * @return WP_Error WP_Error object
47
+ */
48
+ function password_errors( $errors = '' ) {
49
+ // Make sure $errors is a WP_Error object
50
+ if ( empty( $errors ) )
51
+ $errors = new WP_Error();
52
+ // Make sure passwords aren't empty
53
+ if ( empty( $_POST['pass1'] ) || $_POST['pass1'] == '' || empty( $_POST['pass2'] ) || $_POST['pass2'] == '' ) {
54
+ $errors->add( 'empty_password', __( '<strong>ERROR</strong>: Please enter a password.', $this->theme_my_login->textdomain ) );
55
+ // Make sure passwords match
56
+ } elseif ( $_POST['pass1'] !== $_POST['pass2'] ) {
57
+ $errors->add( 'password_mismatch', __( '<strong>ERROR</strong>: Your passwords do not match.', $this->theme_my_login->textdomain ) );
58
+ // Make sure password is long enough
59
+ } elseif ( strlen( $_POST['pass1'] ) < 6 ) {
60
+ $errors->add( 'password_length', __( '<strong>ERROR</strong>: Your password must be at least 6 characters in length.', $this->theme_my_login->textdomain ) );
61
+ // All is good, assign password to a friendlier key
62
+ } else {
63
+ $_POST['user_pass'] = $_POST['pass1'];
64
+ }
65
+ return $errors;
66
+ }
67
+
68
+ /**
69
+ * Sets the user password
70
+ *
71
+ * Callback for "tml_user_registration_pass" hook in Theme_My_Login::register_new_user()
72
+ *
73
+ * @see Theme_My_Login::register_new_user()
74
+ * @since 6.0
75
+ * @access public
76
+ *
77
+ * @param string $user_pass Auto-generated password passed in from filter
78
+ * @return string Password POSTed by user
79
+ */
80
+ function set_password( $user_pass ) {
81
+ // Make sure password isn't empty
82
+ if ( isset( $_POST['user_pass'] ) && !empty( $_POST['user_pass'] ) )
83
+ $user_pass = $_POST['user_pass'];
84
+ return $user_pass;
85
+ }
86
+
87
+ /**
88
+ * Removes the default password nag
89
+ *
90
+ * Callback for "tml_new_user_registered" hook in Theme_My_Login::register_new_user()
91
+ *
92
+ * @see Theme_My_Login::register_new_user()
93
+ * @since 6.0
94
+ * @access public
95
+ *
96
+ * @param int $user_id The user's ID
97
+ */
98
+ function remove_default_password_nag( $user_id ) {
99
+ update_usermeta( $user_id, 'default_password_nag', false );
100
+ }
101
+
102
+ /**
103
+ * Resets the user's password
104
+ *
105
+ * Callback for "tml_request_resetpass" and "tml_request_rp" hooks in Theme_My_Login::the_request()
106
+ *
107
+ * @see Theme_My_Login::the_request()
108
+ * @since 6.0
109
+ * @access public
110
+ *
111
+ * @param object $theme_my_login
112
+ */
113
+ function resetpass_action( &$theme_my_login ) {
114
+ // Set local reference to $theme_my_login->errors
115
+ $errors =& $theme_my_login->errors;
116
+
117
+ // Validate the reset key
118
+ $user = $this->validate_reset_key( $_REQUEST['key'], $_REQUEST['login'] );
119
+ // Handle errors
120
+ if ( is_wp_error( $user ) ) {
121
+ // Redirect to current page with "action=lostpassword&error=invalidkey" added to the query
122
+ $redirect_to = $theme_my_login->get_current_url( 'action=lostpassword&error=invalidkey' );
123
+ // Add instance to query if specified
124
+ if ( !empty( $theme_my_login->request_instance ) )
125
+ $redirect_to = add_query_arg( 'instance', $theme_my_login->request_instance, $redirect_to );
126
+ // Redirect
127
+ wp_redirect( $redirect_to );
128
+ exit();
129
+ }
130
+
131
+ // Check if form has been posted
132
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
133
+ // Reset the password
134
+ $errors = $this->reset_password();
135
+ // Make sure there aren't any errors
136
+ if ( !is_wp_error( $errors ) ) {
137
+ // Redirect to current page with "resetpass=complete" added to the query
138
+ $redirect_to = $theme_my_login->get_current_url( 'resetpass=complete' );
139
+ // Add instance to query if specified
140
+ if ( !empty( $theme_my_login->request_instance ) )
141
+ $redirect_to = add_query_arg( 'instance', $theme_my_login->request_instance, $redirect_to );
142
+ // Redirect
143
+ wp_redirect( $redirect_to );
144
+ exit();
145
+ }
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Outputs reset password form HTML
151
+ *
152
+ * This function will first look in the current theme's directory for "resetpass-form.php" and include it if found.
153
+ * Otherwise, the HTML below will be included instead.
154
+ *
155
+ * @see Theme_My_Login_Template::display()
156
+ * @since 6.0
157
+ * @access public
158
+ *
159
+ * @param object $template Reference to $theme_my_login_template object
160
+ */
161
+ function get_resetpass_form( &$template ) {
162
+ $templates = array();
163
+ // Allow template override via shortcode or template tag args
164
+ if ( !empty( $template->options['resetpass_template'] ) )
165
+ $templates[] = $template->options['resetpass_template'];
166
+ // Default template
167
+ $templates[] = 'resetpass-form.php';
168
+ // Load the template
169
+ $template->get_template( $templates );
170
+ }
171
+
172
+ /**
173
+ * Changes template message according to a specific action
174
+ *
175
+ * Callback for "tml_action_template_message" hook in Theme_My_Login_Template::get_action_template_message()
176
+ *
177
+ * @see Theme_My_Login_Template::get_action_template_message()
178
+ * @since 6.0
179
+ * @access public
180
+ *
181
+ * @param string $message The original message
182
+ * @param string $action The requested action
183
+ * @return string The new messgage
184
+ */
185
+ function action_template_message( $message, $action ) {
186
+ switch ( $action ) {
187
+ case 'lostpassword' :
188
+ $message = __( 'Please enter your username or e-mail address. You will receive an e-mail with a link to reset your password.', $this->theme_my_login->textdomain );
189
+ break;
190
+ case 'resetpass' :
191
+ $message = __( 'Please enter a new password.', $this->theme_my_login->textdomain );
192
+ break;
193
+ case 'register' :
194
+ $message = '';
195
+ break;
196
+ }
197
+ return $message;
198
+ }
199
+
200
+ /**
201
+ * Changes the register template message
202
+ *
203
+ * Callback for "tml_register_passmail_template_message" hook
204
+ *
205
+ * @since 6.0
206
+ * @access public
207
+ *
208
+ * @return string The new register message
209
+ */
210
+ function register_passmail_template_message() {
211
+ return;
212
+ }
213
+ /**
214
+ * Handles display of various action/status messages
215
+ *
216
+ * @since 6.0
217
+ * @access public
218
+ *
219
+ * @param object $theme_my_login Reference to global $theme_my_login object
220
+ */
221
+ function action_messages( &$theme_my_login ) {
222
+ // Change "Registration complete. Please check your e-mail." to reflect the fact that they already set a password
223
+ if ( isset( $_GET['registration'] ) && 'complete' == $_GET['registration'] )
224
+ $theme_my_login->errors->add( 'registration_complete', __( 'Registration complete. You may now log in.', $this->theme_my_login->textdomain ), 'message' );
225
+ // Display the following message instead of "Check your e-mail for your new password."
226
+ elseif ( isset( $_GET['resetpass'] ) && 'complete' == $_GET['resetpass'] )
227
+ $theme_my_login->errors->add( 'password_saved', __( 'Your password has been saved. You may now log in.', $this->theme_my_login->textdomain ), 'message' );
228
+ }
229
+
230
+ /**
231
+ * Changes where the user is redirected upon successful registration
232
+ *
233
+ * Callback for "register_redirect" hook in Theme_My_Login::the_request()
234
+ *
235
+ * @see Theme_My_Login::the_request()
236
+ * @since 6.0
237
+ * @access public
238
+ *
239
+ * @return string $redirect_to Default redirect
240
+ * @return string URL to redirect to
241
+ */
242
+ function register_redirect( $redirect_to ) {
243
+ // Redirect to login page with "registration=complete" added to the query
244
+ $redirect_to = site_url( 'wp-login.php?registration=complete' );
245
+ // Add instance to the query if specified
246
+ if ( isset( $_REQUEST['instance'] ) & !empty( $_REQUEST['instance'] ) )
247
+ $redirect_to = add_query_arg( 'instance', $_REQUEST['instance'], $redirect_to );
248
+ return $redirect_to;
249
+ }
250
+
251
+ /**
252
+ * Changes where the user is redirected upon successful password reset
253
+ *
254
+ * Callback for "resetpass_redirect" hook in Theme_My_Login::the_request()
255
+ *
256
+ * @see Theme_My_Login::the_request()
257
+ * @since 6.0
258
+ * @access public
259
+ *
260
+ * @param string $redirect_to Default redirect
261
+ * @return string URL to redirect to
262
+ */
263
+ function resetpass_redirect( $redirect_to ) {
264
+ // Redirect to the login page with "resetpass=complete" added to the query
265
+ $redirect_to = site_url( 'wp-login.php?resetpass=complete' );
266
+ // Add instance to the query if specified
267
+ if ( isset( $_REQUEST['instance'] ) & !empty( $_REQUEST['instance'] ) )
268
+ $redirect_to = add_query_arg( 'instance', $_REQUEST['instance'], $redirect_to );
269
+ return $redirect_to;
270
+ }
271
+
272
+ /**
273
+ * Validates the reset key
274
+ *
275
+ * @since 6.0
276
+ * @access public
277
+ *
278
+ * @param string $key The validation key
279
+ * @param string $login The user login
280
+ * @return object|WP_Error Row from $wpdb->users table on success, WP_Error on failure
281
+ */
282
+ function validate_reset_key( $key, $login ) {
283
+ global $wpdb;
284
+
285
+ // Strip non-alphanumeric characters
286
+ $key = preg_replace( '/[^a-z0-9]/i', '', $key );
287
+
288
+ // Make sure $key isn't empty
289
+ if ( empty( $key ) || !is_string( $key ) )
290
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->theme_my_login->textdomain ) );
291
+
292
+ // Make sure $login isn't empty
293
+ if ( empty( $login ) || !is_string( $login ) )
294
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->theme_my_login->textdomain ) );
295
+
296
+ // Make sure the $key and $login pair match
297
+ $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login ) );
298
+ if ( empty( $user ) )
299
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->theme_my_login->textdomain ) );
300
+
301
+ return $user;
302
+ }
303
+
304
+ /**
305
+ * Resets the user password
306
+ *
307
+ * @since 6.0
308
+ * @access public
309
+ *
310
+ * return bool|WP_Error True on success, WP_Error on failure
311
+ */
312
+ function reset_password() {
313
+ // Validate the reset key
314
+ $user = $this->validate_reset_key( $_REQUEST['key'], $_REQUEST['login'] );
315
+ if ( is_wp_error( $user ) )
316
+ return $user;
317
+
318
+ // Validate the password
319
+ $errors = $this->password_errors( new WP_Error() );
320
+ if ( $errors->get_error_code() )
321
+ return $errors;
322
+
323
+ // Assign the password to a local variable
324
+ $new_pass = $_POST['user_pass'];
325
+
326
+ // Call "password_reset" hook
327
+ do_action( 'password_reset', $user->user_login, $new_pass );
328
+
329
+ // Set the password
330
+ wp_set_password( $new_pass, $user->ID );
331
+
332
+ // Remove the password nag
333
+ update_usermeta( $user->ID, 'default_password_nag', false );
334
+
335
+ // Notification e-mail message
336
+ $message = sprintf( __( 'Username: %s', $this->theme_my_login->textdomain ), $user->user_login ) . "\r\n";
337
+ $message .= sprintf( __( 'Password: %s', $this->theme_my_login->textdomain ), $new_pass ) . "\r\n";
338
+ $message .= site_url( 'wp-login.php', 'login' ) . "\r\n";
339
+
340
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
341
+ // we want to reverse this for the plain text arena of emails.
342
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
343
+
344
+ // Notification e-mail subject
345
+ $title = sprintf( __( '[%s] Your new password', $this->theme_my_login->textdomain ), $blogname );
346
+
347
+ // Apply filters to notification e-mail subject
348
+ $title = apply_filters( 'password_reset_title', $title, $user->ID );
349
+ // Apply filters to notification e-mail message
350
+ $message = apply_filters( 'password_reset_message', $message, $new_pass, $user->ID );
351
+
352
+ // Make sure the message sends
353
+ if ( $message && !wp_mail( $user->user_email, $title, $message ) )
354
+ die( '<p>' . __( 'The e-mail could not be sent.', $this->theme_my_login->textdomain ) . "<br />\n" . __( 'Possible reason: your host may have disabled the mail() function...', $this->theme_my_login->textdomain ) . '</p>' );
355
+
356
+ // Notify the admin of the change
357
+ wp_password_change_notification( $user );
358
+
359
+ return true;
360
+ }
361
+
362
+ /**
363
+ * Loads the module
364
+ *
365
+ * @since 6.0
366
+ * @access public
367
+ */
368
+ function load() {
369
+ // Register password
370
+ add_action( 'tml_register_form', array( &$this, 'password_fields' ) );
371
+ add_filter( 'registration_errors', array( &$this, 'password_errors' ) );
372
+ add_filter( 'tml_user_registration_pass', array( &$this, 'set_password' ) );
373
+ add_action( 'tml_new_user_registered', array( &$this, 'remove_default_password_nag' ) );
374
+ // Reset password
375
+ add_action( 'tml_display_resetpass', array( &$this, 'get_resetpass_form' ) );
376
+ add_action( 'tml_display_rp', array( &$this, 'get_resetpass_form' ) );
377
+ add_action( 'tml_request_resetpass', array( &$this, 'resetpass_action' ) );
378
+ add_action( 'tml_request_rp', array( &$this, 'resetpass_action' ) );
379
+ // Template messages
380
+ add_filter( 'tml_register_passmail_template_message', array( &$this, 'register_passmail_template_message' ) );
381
+ add_filter( 'tml_action_template_message', array( &$this, 'action_template_message' ), 10, 2 );
382
+ add_action( 'tml_request', array( &$this, 'action_messages' ) );
383
+ // Redirection
384
+ add_filter( 'register_redirect', array( &$this, 'register_redirect' ) );
385
+ add_filter( 'resetpass_redirect', array( &$this, 'resetpass_redirect' ) );
386
+ }
387
  }
388
 
389
+ /**
390
+ * Holds the reference to Theme_My_Login_Custom_Passwords object
391
+ * @global object $theme_my_login_custom_passwords
392
+ * @since 6.0
393
+ */
394
+ $theme_my_login_custom_passwords = new Theme_My_Login_Custom_Passwords();
395
+
396
+ endif; // Class exists
397
+
398
+ ?>
modules/custom-passwords/includes/functions.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_custom_pass_validate_reset_key($key, $login) {
4
- global $wpdb;
5
-
6
- $key = preg_replace('/[^a-z0-9]/i', '', $key);
7
-
8
- if ( empty( $key ) || !is_string( $key ) )
9
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
10
-
11
- if ( empty($login) || !is_string($login) )
12
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
13
-
14
- $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
15
- if ( empty( $user ) )
16
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
17
-
18
- return $user;
19
- }
20
-
21
- function wdbj_tml_custom_pass_reset_pass() {
22
-
23
- $user = wdbj_tml_custom_pass_validate_reset_key($_REQUEST['key'], $_REQUEST['login']);
24
- if ( is_wp_error($user) )
25
- return $user;
26
-
27
- $errors = wdbj_tml_custom_pass_errors(new WP_Error());
28
- if ( $errors->get_error_code() )
29
- return $errors;
30
-
31
- $new_pass = $_POST['pass1'];
32
-
33
- do_action('password_reset', $user->user_login, $new_pass);
34
-
35
- wp_set_password($new_pass, $user->ID);
36
- update_usermeta($user->ID, 'default_password_nag', false);
37
- $message = sprintf(__('Username: %s', 'theme-my-login'), $user->user_login) . "\r\n";
38
- $message .= sprintf(__('Password: %s', 'theme-my-login'), $new_pass) . "\r\n";
39
- $message .= site_url('wp-login.php', 'login') . "\r\n";
40
-
41
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
42
- // we want to reverse this for the plain text arena of emails.
43
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
44
-
45
- $title = sprintf(__('[%s] Your new password', 'theme-my-login'), $blogname);
46
-
47
- $title = apply_filters('password_reset_title', $title, $user->ID);
48
- $message = apply_filters('password_reset_message', $message, $new_pass, $user->ID);
49
-
50
- if ( $message && !wp_mail($user->user_email, $title, $message) )
51
- die('<p>' . __('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login') . '</p>');
52
-
53
- wp_password_change_notification($user);
54
-
55
- return true;
56
- }
57
-
58
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-passwords/includes/hook-functions.php DELETED
@@ -1,113 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_custom_pass_form($instance_id) {
4
- ?>
5
- <p><label for="pass1-<?php echo $instance_id; ?>"><?php _e('Password:', 'theme-my-login');?></label>
6
- <input autocomplete="off" name="pass1" id="pass1-<?php echo $instance_id; ?>" class="input" size="20" value="" type="password" /></p>
7
- <p><label for="pass2-<?php echo $instance_id; ?>"><?php _e('Confirm Password:', 'theme-my-login');?></label>
8
- <input autocomplete="off" name="pass2" id="pass2-<?php echo $instance_id; ?>" class="input" size="20" value="" type="password" /></p>
9
- <?php
10
- }
11
-
12
- function wdbj_tml_custom_pass_errors($errors = '') {
13
- if ( empty($_POST['pass1']) || $_POST['pass1'] == '' || empty($_POST['pass2']) || $_POST['pass2'] == '' ) {
14
- $errors->add('empty_password', __('<strong>ERROR</strong>: Please enter a password.', 'theme-my-login'));
15
- } elseif ( $_POST['pass1'] !== $_POST['pass2'] ) {
16
- $errors->add('password_mismatch', __('<strong>ERROR</strong>: Your passwords do not match.', 'theme-my-login'));
17
- } elseif ( strlen($_POST['pass1']) < 6 ) {
18
- $errors->add('password_length', __('<strong>ERROR</strong>: Your password must be at least 6 characters in length.', 'theme-my-login'));
19
- } else {
20
- $_POST['user_pw'] = $_POST['pass1'];
21
- }
22
- return $errors;
23
- }
24
-
25
- function wdbj_tml_custom_pass_set_pass($user_pass) {
26
- if ( isset($_POST['user_pw']) && !empty($_POST['user_pw']) )
27
- $user_pass = $_POST['user_pw'];
28
- return $user_pass;
29
- }
30
-
31
- function wdbj_tml_custom_pass_reset_action() {
32
- $user = wdbj_tml_custom_pass_validate_reset_key($_GET['key'], $_GET['login']);
33
- if ( is_wp_error($user) ) {
34
- $redirect_to = site_url('wp-login.php?action=lostpassword&error=invalidkey');
35
- if ( 'tml-page' != wdbj_tml_get_var('request_instance') )
36
- $redirect_to = wdbj_tml_get_current_url('action=lostpassword&error=invalidkey&instance=' . wdbj_tml_get_var('request_instance'));
37
- wp_redirect($redirect_to);
38
- exit();
39
- }
40
-
41
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
42
- $errors = wdbj_tml_custom_pass_reset_pass();
43
- if ( ! is_wp_error($errors) ) {
44
- $redirect_to = site_url('wp-login.php?resetpass=complete');
45
- if ( 'tml-page' != wdbj_tml_get_var('request_instance') )
46
- $redirect_to = wdbj_tml_get_current_url('resetpass=complete&instance=' . wdbj_tml_get_var('request_instance'));
47
- wp_redirect($redirect_to);
48
- exit();
49
- } else wdbj_tml_set_error($errors);
50
- }
51
- }
52
-
53
- function wdbj_tml_custom_pass_reset_form($instance_id) {
54
- $message = apply_filters('resetpass_message', __('Please enter a new password.', 'theme-my-login'));
55
-
56
- wdbj_tml_get_header($message);
57
-
58
- if ( ! wdbj_tml_get_error('invalid_key') ) {
59
- ?>
60
- <form name="resetpasswordform" id="resetpasswordform-<?php echo $instance_id; ?>" action="<?php echo esc_url(wdbj_tml_get_current_url('action=rp&key=' . $_GET['key'] . '&login=' . $_GET['login'] . '&instance=' . $instance_id)); ?>" method="post">
61
- <p>
62
- <label for="pass1-<?php echo $instance_id; ?>"><?php _e('New Password:', 'theme-my-login');?></label>
63
- <input autocomplete="off" name="pass1" id="pass1-<?php echo $instance_id; ?>" class="input" size="20" value="" type="password" />
64
- </p>
65
- <p>
66
- <label for="pass2-<?php echo $instance_id; ?>"><?php _e('Confirm Password:', 'theme-my-login');?></label>
67
- <input autocomplete="off" name="pass2" id="pass2-<?php echo $instance_id; ?>" class="input" size="20" value="" type="password" />
68
- </p>
69
- <?php do_action('resetpassword_form', $instance_id); ?>
70
- <p class="submit">
71
- <input type="submit" name="wp-submit" id="wp-submit-<?php echo $instance_id; ?>" value="<?php _e('Change Password', 'theme-my-login'); ?>" />
72
- </p>
73
- </form>
74
- <?php
75
- }
76
- wdbj_tml_get_footer(true, true, false);
77
- }
78
-
79
- function wdbj_tml_custom_pass_register_redirect($redirect_to) {
80
- $request_instance = wdbj_tml_get_var('request_instance');
81
- $redirect_to = site_url('wp-login.php?registration=complete');
82
- if ( 'tml-page' != $request_instance )
83
- $redirect_to = wdbj_tml_get_current_url('registration=complete&instance=' . $request_instance);
84
- return $redirect_to;
85
- }
86
-
87
- function wdbj_tml_custom_pass_resetpass_redirect($redirect_to) {
88
- $request_instance = wdbj_tml_get_var('request_instance');
89
- $redirect_to = site_url('wp-login.php?resetpass=complete');
90
- if ( 'tml-page' != $request_instance )
91
- $redirect_to = wdbj_tml_get_current_url('resetpass=complete&instance=' . $request_instance);
92
- return $redirect_to;
93
- }
94
-
95
- function wdbj_tml_custom_pass_login_message($message) {
96
- if ( isset($_GET['action']) && 'register' == $_GET['action'] )
97
- $message = '';
98
- return $message;
99
- }
100
-
101
- function wdbj_tml_custom_pass_lostpassword_message($message) {
102
- $message = __('Please enter your username or e-mail address. You will receive an e-mail with a link to reset your password.', 'theme-my-login');
103
- return $message;
104
- }
105
-
106
- function wdbj_tml_custom_pass_messages() {
107
- if ( isset($_GET['registration']) && 'complete' == $_GET['registration'] )
108
- wdbj_tml_set_error('registration_complete', __('Registration complete. You may now log in.', 'theme-my-login'), 'message');
109
- elseif ( isset($_GET['resetpass']) && 'complete' == $_GET['resetpass'] )
110
- wdbj_tml_set_error('password_saved', __('Your password has been saved. You may now log in.', 'theme-my-login'), 'message');
111
- }
112
-
113
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-redirection/admin/admin.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_custom_redirect_admin_menu() {
4
- global $wp_roles;
5
- $parent = plugin_basename(TML_MODULE_DIR . '/custom-redirection/admin/options.php');
6
- wdbj_tml_add_menu_page(__('Redirection', 'theme-my-login'), $parent);
7
- $user_roles = $wp_roles->get_names();
8
- foreach ( $user_roles as $role => $label ) {
9
- if ( 'pending' == $role )
10
- continue;
11
- wdbj_tml_add_submenu_page($parent, translate_user_role($label), '', 'wdbj_tml_custom_redirect_user_role_admin_page', array('role' => $role));
12
- }
13
- }
14
-
15
- function wdbj_tml_custom_redirect_user_role_admin_page($role) {
16
- $redirection = wdbj_tml_get_option('redirection', $role);
17
- ?>
18
- <table class="form-table">
19
- <tr valign="top">
20
- <th scope="row"><?php _e('Log in', 'theme-my-login'); ?></th>
21
- <td>
22
- <input name="theme_my_login[redirection][<?php echo $role; ?>][login_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_login_type_default" value="default"<?php checked('default', $redirection['login_type']); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_login_type_default"><?php _e('Default', 'theme-my-login'); ?></label>
23
- <p class="description"><?php _e('Check this option to send the user to their WordPress Dashboard/Profile.', 'theme-my-login'); ?></p>
24
- <input name="theme_my_login[redirection][<?php echo $role; ?>][login_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_login_type_referer" value="referer"<?php checked('referer', $redirection['login_type']); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_login_type_referer"><?php _e('Referer', 'theme-my-login'); ?></label>
25
- <p class="description"><?php _e('Check this option to send the user back to the page they were visiting before logging in.', 'theme-my-login'); ?></p>
26
- <input name="theme_my_login[redirection][<?php echo $role; ?>][login_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_login_type_custom" value="custom"<?php checked('custom', $redirection['login_type']); ?> />
27
- <input name="theme_my_login[redirection][<?php echo $role; ?>][login_url]" type="text" id="theme_my_login_redirection_<?php echo $role; ?>_login_url" value="<?php echo $redirection['login_url']; ?>" class="regular-text" />
28
- <p class="description"><?php _e('Check this option to send the user to a custom location, specified by the textbox above.', 'theme-my-login'); ?></p>
29
- </td>
30
- </tr>
31
- <tr valign="top">
32
- <th scope="row"><?php _e('Log out', 'theme-my-login'); ?></th>
33
- <td>
34
- <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_logout_type_default" value="default"<?php checked('default', $redirection['logout_type']); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_logout_type_default"><?php _e('Default', 'theme-my-login'); ?></label><br />
35
- <p class="description"><?php _e('Check this option to send the user to the log in page, displaying a message that they have successfully logged out.', 'theme-my-login'); ?></p>
36
- <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_logout_type_referer" value="referer"<?php checked('referer', $redirection['logout_type']); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_logout_type_referer"><?php _e('Referer', 'theme-my-login'); ?></label><br />
37
- <p class="description"><?php _e('Check this option to send the user back to the page they were visiting before logging out. (Note: If the previous page being visited was an admin page, this can have unexpected results.)', 'theme-my-login'); ?></p>
38
- <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_logout_type_custom" value="custom"<?php checked('custom', $redirection['logout_type']); ?> />
39
- <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_url]" type="text" id="theme_my_login_redirection_<?php echo $role; ?>_logout_url" value="<?php echo $redirection['logout_url']; ?>" class="regular-text" />
40
- <p class="description"><?php _e('Check this option to send the user to a custom location, specified by the textbox above.', 'theme-my-login'); ?></p>
41
- </td>
42
- </tr>
43
- </table>
44
- <?php
45
- }
46
-
47
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-redirection/custom-redirection.php CHANGED
@@ -4,39 +4,266 @@ Plugin Name: Custom Redirection
4
  Description: Enabling this module will initialize custom redirection. You will then have to configure the settings via the "Redirection" tab.
5
  */
6
 
7
- add_action('tml_init', 'wdbj_tml_custom_redirect_init');
8
- function wdbj_tml_custom_redirect_init() {
9
- include( TML_MODULE_DIR . '/custom-redirection/includes/hook-functions.php' );
10
- add_filter('login_redirect', 'wdbj_tml_custom_redirect_login', 10, 3);
11
- add_filter('logout_redirect', 'wdbj_tml_custom_redirect_logout', 10, 3);
12
- add_action('login_form', 'wdbj_tml_custom_redirect_login_form');
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- add_action('tml_admin_init', 'wdbj_tml_custom_redirect_admin_init');
16
- function wdbj_tml_custom_redirect_admin_init() {
17
- require_once (TML_MODULE_DIR . '/custom-redirection/admin/admin.php');
18
- add_action('tml_admin_menu', 'wdbj_tml_custom_redirect_admin_menu');
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- add_action('activate_custom-redirection/custom-redirection.php', 'wdbj_tml_custom_redirection_activate');
22
- function wdbj_tml_custom_redirection_activate() {
23
- $current = wdbj_tml_get_option('redirection');
24
- $default = wdbj_tml_custom_redirect_default_settings();
25
-
26
- if ( is_array($current) )
27
- wdbj_tml_update_option(array_merge($default, $current), 'redirection');
28
- else
29
- wdbj_tml_update_option($default, 'redirection');
30
-
31
- unset($current, $default);
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- function wdbj_tml_custom_redirect_default_settings() {
35
- global $wp_roles;
36
- foreach ( $wp_roles->get_names() as $role => $label ) {
37
- $options[$role] = array('login_type' => 'default', 'login_url' => '', 'logout_type' => 'default', 'logout_url' => '');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
- return $options;
40
  }
41
-
42
- ?>
 
 
 
 
 
 
 
 
 
4
  Description: Enabling this module will initialize custom redirection. You will then have to configure the settings via the "Redirection" tab.
5
  */
6
 
7
+ if ( !class_exists( 'Theme_My_Login_Custom_Redirection' ) ) :
8
+ /**
9
+ * Theme My Login Custom Redirection module class
10
+ *
11
+ * Adds the ability to redirect users when logging in/out based upon their "user role".
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Custom_Redirection extends Theme_My_Login_Module {
16
+ /**
17
+ * Adds "_wp_original_referer" field to login form
18
+ *
19
+ * Callback for "tml_login_form" hook in file "login-form.php", included by method Theme_My_Login_Template::display()
20
+ *
21
+ * @see Theme_My_Login_Template::display()
22
+ * @since 6.0
23
+ * @access public
24
+ *
25
+ * @param object $template Reference to $theme_my_login_template object
26
+ */
27
+ function login_form( &$template ) {
28
+ $jump_back_to = empty( $template->instance ) ? 'previous' : 'current';
29
+ wp_original_referer_field( true, $jump_back_to );
30
+ echo "\n";
31
+ }
32
 
33
+ /**
34
+ * Handles login redirection
35
+ *
36
+ * Callback for "login_redirect" hook in method Theme_My_Login::the_request()
37
+ *
38
+ * @see Theme_My_Login::the_request()
39
+ * @since 6.0
40
+ * @access public
41
+ *
42
+ * @param string $redirect_to Default redirect
43
+ * @param string $request Requested redirect
44
+ * @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
45
+ * @return string New redirect
46
+ */
47
+ function login_redirect( $redirect_to, $request, $user ) {
48
+ // Determine the correct referer
49
+ if ( !$http_referer = wp_get_original_referer() )
50
+ $http_referer = wp_get_referer();
51
 
52
+ // Make sure $user object exists and is a WP_User instance
53
+ if ( !is_wp_error( $user ) && is_a( $user, 'WP_User' ) ) {
54
+ $redirection = $this->theme_my_login->options['redirection'][$user->roles[0]];
55
+ if ( 'referer' == $redirection['login_type'] ) {
56
+ // Send 'em back to the referer
57
+ $redirect_to = $http_referer;
58
+ } elseif ( 'custom' == $redirection['login_type'] ) {
59
+ // Send 'em to the specified URL
60
+ $redirect_to = $redirection['login_url'];
61
+ // Allow a few user specific variables
62
+ $replace = array( '%user_id%' => $user->ID, '%user_login%' => $user->user_login );
63
+ $redirect_to = str_replace( array_keys( $replace ), array_values( $replace ), $redirect_to );
64
+ }
65
+ }
66
+
67
+ // If a redirect is requested, it takes precedence
68
+ if ( !empty( $request ) && admin_url() != $request && admin_url( 'profile.php' ) != $request )
69
+ $redirect_to = $request;
70
+
71
+ // Make sure $redirect_to isn't empty
72
+ if ( empty( $redirect_to ) )
73
+ $redirect_to = get_option( 'home' );
74
+
75
+ return $redirect_to;
76
+ }
77
+
78
+ /**
79
+ * Handles logout redirection
80
+ *
81
+ * Callback for "logout_redirect" hook in method Theme_My_Login::the_request()
82
+ *
83
+ * @see Theme_My_Login::the_request()
84
+ * @since 6.0
85
+ * @access public
86
+ *
87
+ * @param string $redirect_to Default redirect
88
+ * @param string $request Requested redirect
89
+ * @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
90
+ * @return string New redirect
91
+ */
92
+ function logout_redirect( $redirect_to, $request, $user ) {
93
+ // Determine the correct referer
94
+ if ( !$http_referer = wp_get_original_referer() )
95
+ $http_referer = wp_get_referer();
96
+ // Remove some arguments that may be present and shouldn't be
97
+ $http_referer = remove_query_arg( array( 'instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce' ), $http_referer );
98
+
99
+ // Make sure $user object exists and is a WP_User instance
100
+ if ( !is_wp_error( $user ) && is_a( $user, 'WP_User' ) ) {
101
+ $redirection = $this->theme_my_login->options['redirection'][$user->roles[0]];
102
+ if ( 'referer' == $redirection['logout_type'] ) {
103
+ // Send 'em back to the referer
104
+ $redirect_to = $http_referer;
105
+ } elseif ( 'custom' == $redirection['logout_type'] ) {
106
+ // Send 'em to the specified URL
107
+ $redirect_to = $redirection['logout_url'];
108
+ // Allow a few user specific variables
109
+ $replace = array( '%user_id%' => $user->ID, '%user_login%' => $user->user_login );
110
+ $redirect_to = str_replace( array_keys( $replace ), array_values( $replace ), $redirect_to );
111
+ }
112
+ }
113
+
114
+ // Make sure $redirect_to isn't empty or pointing to an admin URL (causing an endless loop)
115
+ if ( empty( $redirect_to ) || strpos( $redirect_to, 'wp-admin' ) !== false )
116
+ $redirect_to = $this->theme_my_login->get_login_page_link( 'loggedout=true' );
117
 
118
+ return $redirect_to;
119
+ }
120
+
121
+ /**
122
+ * Adds "Redirection" tab to Theme My Login menu
123
+ *
124
+ * Callback for "tml_admin_menu" hook in method Theme_My_Login_Admin::display_settings_page()
125
+ *
126
+ * @see Theme_My_Login_Admin::display_settings_page(), Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
127
+ * @uses Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
128
+ * @since 6.0
129
+ * @access public
130
+ *
131
+ * @param object Reference to global $theme_my_login_admin object
132
+ */
133
+ function admin_menu( &$admin ) {
134
+ global $wp_roles;
135
+ // Add menu tab
136
+ $admin->add_menu_page( __( 'Redirection', 'theme-my-login' ), 'tml-options-redirection' );
137
+ // Iterate through each user role
138
+ foreach ( $wp_roles->get_names() as $role => $label ) {
139
+ // We don't want the "pending" role created by the "User Moderation" module
140
+ if ( 'pending' == $role )
141
+ continue;
142
+ // Add submenu tab for the role
143
+ $admin->add_submenu_page( 'tml-options-redirection', translate_user_role( $label ), 'tml-options-redirection-' . $role, array( &$this, 'display_redirection_settings' ), array( $role ) );
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Outputs redirection admin menu for specified role
149
+ *
150
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
151
+ *
152
+ * @see Theme_My_Login_Admin::add_submenu_page()
153
+ * @since 6.0
154
+ * @access public
155
+ *
156
+ * @param string $role Name of user role
157
+ */
158
+ function display_redirection_settings( $role ) {
159
+ $redirection =& $this->theme_my_login->options['redirection'][$role];
160
+ ?>
161
+ <table class="form-table">
162
+ <tr valign="top">
163
+ <th scope="row"><?php _e( 'Log in', 'theme-my-login' ); ?></th>
164
+ <td>
165
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][login_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_login_type_default" value="default"<?php checked( 'default', $redirection['login_type'] ); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_login_type_default"><?php _e( 'Default', 'theme-my-login' ); ?></label>
166
+ <p class="description"><?php _e( 'Check this option to send the user to their WordPress Dashboard/Profile.', 'theme-my-login' ); ?></p>
167
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][login_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_login_type_referer" value="referer"<?php checked( 'referer', $redirection['login_type'] ); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_login_type_referer"><?php _e( 'Referer', 'theme-my-login' ); ?></label>
168
+ <p class="description"><?php _e( 'Check this option to send the user back to the page they were visiting before logging in.', 'theme-my-login' ); ?></p>
169
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][login_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_login_type_custom" value="custom"<?php checked( 'custom', $redirection['login_type'] ); ?> />
170
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][login_url]" type="text" id="theme_my_login_redirection_<?php echo $role; ?>_login_url" value="<?php echo $redirection['login_url']; ?>" class="regular-text" />
171
+ <p class="description"><?php _e( 'Check this option to send the user to a custom location, specified by the textbox above.', 'theme-my-login' ); ?></p>
172
+ </td>
173
+ </tr>
174
+ <tr valign="top">
175
+ <th scope="row"><?php _e( 'Log out', 'theme-my-login' ); ?></th>
176
+ <td>
177
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_logout_type_default" value="default"<?php checked( 'default', $redirection['logout_type'] ); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_logout_type_default"><?php _e( 'Default', 'theme-my-login' ); ?></label><br />
178
+ <p class="description"><?php _e( 'Check this option to send the user to the log in page, displaying a message that they have successfully logged out.', 'theme-my-login' ); ?></p>
179
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_logout_type_referer" value="referer"<?php checked( 'referer', $redirection['logout_type'] ); ?> /> <label for="theme_my_login_redirection_<?php echo $role; ?>_logout_type_referer"><?php _e( 'Referer', 'theme-my-login' ); ?></label><br />
180
+ <p class="description"><?php _e( 'Check this option to send the user back to the page they were visiting before logging out. (Note: If the previous page being visited was an admin page, this can have unexpected results.)', 'theme-my-login' ); ?></p>
181
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_type]" type="radio" id="theme_my_login_redirection_<?php echo $role; ?>_logout_type_custom" value="custom"<?php checked( 'custom', $redirection['logout_type'] ); ?> />
182
+ <input name="theme_my_login[redirection][<?php echo $role; ?>][logout_url]" type="text" id="theme_my_login_redirection_<?php echo $role; ?>_logout_url" value="<?php echo $redirection['logout_url']; ?>" class="regular-text" />
183
+ <p class="description"><?php _e( 'Check this option to send the user to a custom location, specified by the textbox above.', 'theme-my-login' ); ?></p>
184
+ </td>
185
+ </tr>
186
+ </table>
187
+ <?php
188
+ }
189
+
190
+ /**
191
+ * Activates this module
192
+ *
193
+ * Callback for "tml_activate_custom-redirection/custom-redirection.php" hook in method Theme_My_Login_Admin::activate_module()
194
+ *
195
+ * @see Theme_My_Login_Admin::activate_module()
196
+ * @since 6.0
197
+ * @access public
198
+ *
199
+ * @param object $theme_my_login Reference to global $theme_my_login object
200
+ */
201
+ function activate( &$theme_my_login ) {
202
+ $options = $this->init_options();
203
+ if ( !isset( $theme_my_login->options['redirection'] ) ) {
204
+ $theme_my_login->options['redirection'] = $options['redirection'];
205
+ } else {
206
+ $theme_my_login->options['redirection'] = $theme_my_login->array_merge_recursive( $options['redirection'], $theme_my_login->options['redirection'] );
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Initializes options for this module
212
+ *
213
+ * Callback for "tml_init_options" hook in method Theme_My_Login_Base::init_options()
214
+ *
215
+ * @see Theme_My_Login_Base::init_options()
216
+ * @since 6.0
217
+ * @access public
218
+ *
219
+ * @param array $options Options passed in from filter
220
+ * @return array Original $options array with module options appended
221
+ */
222
+ function init_options( $options = array() ) {
223
+ global $wp_roles;
224
+ if ( empty( $wp_roles ) )
225
+ $wp_roles =& new WP_Roles();
226
+
227
+ $options = (array) $options;
228
+
229
+ $options['redirection'] = array();
230
+ foreach ( $wp_roles->get_names() as $role => $label ) {
231
+ if ( 'pending' == $role )
232
+ continue;
233
+ $options['redirection'][$role] = array( 'login_type' => 'default', 'login_url' => '', 'logout_type' => 'default', 'logout_url' => '' );
234
+ }
235
+ return $options;
236
+ }
237
+
238
+ /**
239
+ * Loads the module
240
+ *
241
+ * @since 6.0
242
+ * @access public
243
+ */
244
+ function load() {
245
+ // Activate
246
+ add_action( 'tml_activate_custom-redirection/custom-redirection.php', array( &$this, 'activate' ) );
247
+ // Initialize
248
+ add_filter( 'tml_init_options', array( &$this, 'init_options' ) );
249
+ // Admin
250
+ add_action( 'tml_admin_menu', array( &$this, 'admin_menu' ) );
251
+ // Login form
252
+ add_action( 'tml_login_form', array( &$this, 'login_form' ) );
253
+ // Login redirect
254
+ add_filter( 'login_redirect', array( &$this, 'login_redirect' ), 10, 3 );
255
+ // Logout redirect
256
+ add_filter( 'logout_redirect', array( &$this, 'logout_redirect' ), 10, 3 );
257
  }
 
258
  }
259
+
260
+ /**
261
+ * Holds the reference to Theme_My_Login_Custom_Redirection object
262
+ * @global object $theme_my_login_custom_redirection
263
+ * @since 6.0
264
+ */
265
+ $theme_my_login_custom_redirection = new Theme_My_Login_Custom_Redirection();
266
+
267
+ endif; // Class exists
268
+
269
+ ?>
modules/custom-redirection/includes/hook-functions.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_custom_redirect_login_form($instance_id) {
4
- $jump_back_to = 'tml-page' == $instance_id ? 'previous' : 'current';
5
- wp_original_referer_field(true, $jump_back_to);
6
- echo "\n";
7
- }
8
-
9
- function wdbj_tml_custom_redirect_login($redirect_to, $request, $user) {
10
- global $pagenow;
11
-
12
- if ( 'wp-login.php' == $pagenow )
13
- return $redirect_to;
14
-
15
- // Bailout if this isn't a login
16
- if ( 'POST' != $_SERVER['REQUEST_METHOD'] )
17
- return $redirect_to;
18
-
19
- $_redirect_to = '';
20
-
21
- // User is logged in
22
- if ( is_object($user) && !is_wp_error($user) ) {
23
- $user_role = reset($user->roles);
24
- $redirection = wdbj_tml_get_option('redirection', $user_role);
25
- if ( 'default' == $redirection['login_type'] ) {
26
- // Do nothing
27
- } elseif ( 'referer' == $redirection['login_type'] ) {
28
- // Determine the correct referer
29
- if ( !$http_referer = wp_get_original_referer() )
30
- $http_referer = wp_get_referer();
31
- $_redirect_to = $http_referer;
32
- } else {
33
- $_redirect_to = $redirection['login_url'];
34
- // Allow a few user specific variables
35
- $replace = array('%user_id%' => $user->ID, '%user_login%' => $user->user_login);
36
- $_redirect_to = str_replace(array_keys($replace), array_values($replace), $_redirect_to);
37
- }
38
- // Let requested URL take precedence
39
- if ( !empty($request) && admin_url() != $request )
40
- $_redirect_to = $request;
41
- }
42
-
43
- // Make sure it's not empty!
44
- if ( !empty($_redirect_to) )
45
- $redirect_to = $_redirect_to;
46
-
47
- return $redirect_to;
48
- }
49
-
50
- function wdbj_tml_custom_redirect_logout($redirect_to, $request, $user) {
51
-
52
- $_redirect_to = '';
53
-
54
- if ( is_object($user) && !is_wp_error($user) ) {
55
- $user_role = reset($user->roles);
56
- $redirection = wdbj_tml_get_option('redirection', $user_role);
57
- if ( 'default' == $redirection['logout_type'] ) {
58
- // Do nothing
59
- } elseif ( 'referer' == $redirection['logout_type'] ) {
60
- // Determine the correct referer
61
- if ( !$http_referer = wp_get_original_referer() )
62
- $http_referer = wp_get_referer();
63
- // Clean some args
64
- $http_referer = remove_query_arg(array('instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce'), $http_referer);
65
- $_redirect_to = $http_referer;
66
- } else {
67
- $_redirect_to = $redirection['logout_url'];
68
- // Allow a few user specific variables
69
- $replace = array('%user_id%' => $user->ID, '%user_login%' => $user->user_login);
70
- $_redirect_to = str_replace(array_keys($replace), array_values($replace), $_redirect_to);
71
- }
72
- }
73
-
74
- // Make sure it's not empty!
75
- if ( !empty($_redirect_to) )
76
- $redirect_to = $_redirect_to;
77
-
78
- // Make sure it's not an admin URL
79
- if ( strpos($redirect_to, 'wp-admin') !== false )
80
- $redirect_to = add_query_arg('loggedout', 'true', get_permalink(wdbj_tml_get_option('page_id')));
81
-
82
- return $redirect_to;
83
- }
84
-
85
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-user-links/admin/admin.php DELETED
@@ -1,277 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_custom_user_links_admin_menu() {
4
- global $wp_roles;
5
- $parent = plugin_basename(TML_MODULE_DIR . '/custom-user-links/admin/options.php');
6
- wdbj_tml_add_menu_page(__('User Links', 'theme-my-login'), $parent);
7
- foreach ( $wp_roles->get_names() as $role => $label ) {
8
- if ( 'pending' == $role )
9
- continue;
10
- wdbj_tml_add_submenu_page($parent, translate_user_role($label), '', 'wdbj_tml_custom_user_links_user_role_admin_page', array('role' => $role));
11
- }
12
- }
13
-
14
- function wdbj_tml_custom_user_links_save_settings($settings) {
15
- if ( defined('DOING_AJAX') && DOING_AJAX )
16
- return $settings;
17
- if ( isset($_POST['user_links']) && is_array($_POST['user_links']) && !empty($_POST['user_links']) ) {
18
- foreach ( $_POST['user_links'] as $role => $links ) {
19
- foreach ( $links as $key => $link_data ) {
20
- $clean_title = wp_kses($link_data['title'], null);
21
- $clean_url = wp_kses($link_data['url'], null);
22
- $links[$key] = array('title' => $clean_title, 'url' => $clean_url);
23
- if ( ( empty($clean_title) && empty($clean_url) ) || ( isset($_POST['delete_user_link'][$role][$key]) && $_POST['delete_user_link'][$role][$key] ) )
24
- unset($links[$key]);
25
- }
26
- $settings['user_links'][$role] = array_values($links);
27
- }
28
- unset($role, $links, $key, $link_data, $clean_title, $clean_url);
29
- }
30
- if ( isset($_POST['new_user_link']) && is_array($_POST['new_user_link']) && !empty($_POST['new_user_link']) ) {
31
- foreach ( $_POST['new_user_link'] as $role => $link_data ) {
32
- $clean_title = wp_kses($link_data['title'], null);
33
- $clean_url = wp_kses($link_data['url'], null);
34
- if ( !empty($clean_title) && !empty($clean_url) )
35
- $settings['user_links'][$role][] = array('title' => $clean_title, 'url' => $clean_url);
36
- }
37
- unset($role, $link_data, $clean_title, $clean_url);
38
- }
39
- // Reset link keys
40
- foreach ( $settings['user_links'] as $role => $links ) {
41
- $settings['user_links'][$role] = array_values($links);
42
- }
43
- return $settings;
44
- }
45
-
46
- function wdbj_tml_custom_user_links_admin_styles() {
47
- wp_enqueue_style('theme-my-login-custom-user-links-admin', plugins_url('theme-my-login/modules/custom-user-links/admin/admin.css'));
48
- wp_enqueue_script('jquery');
49
- wp_enqueue_script('wp-lists');
50
- add_action('admin_print_footer_scripts', 'wdbj_tml_custom_user_links_admin_scripts', 20);
51
- }
52
-
53
- function wdbj_tml_custom_user_links_admin_scripts() {
54
- global $wp_roles;
55
-
56
- echo '<script type="text/javascript">' . "\n";
57
- echo 'jQuery(document).ready(function($) {' . "\n";
58
- foreach ( $wp_roles->get_names() as $role => $label ) {
59
- ?>
60
- $('#<?php echo $role; ?>-link-list').wpList( {
61
- addAfter: function( xml, s ) {
62
- $('table#<?php echo $role; ?>-link-table').show();
63
- },
64
- addBefore: function( s ) {
65
- s.data += '&user_role=<?php echo $role; ?>';
66
- return s;
67
- },
68
- delBefore: function( s ) {
69
- s.data.user_role = '<?php echo $role; ?>';
70
- return s;
71
- },
72
- delAfter: function( r, s ) {
73
- $('#' + s.element).remove();
74
- }
75
- } );
76
- <?php
77
- }
78
- echo '});' . "\n";
79
- echo '</script>' . "\n";
80
- }
81
-
82
- function wdbj_tml_custom_user_links_user_role_admin_page($role) {
83
- $links = wdbj_tml_get_option('user_links', $role);
84
- if ( empty($links) )
85
- $links = array();
86
- ?>
87
- <div id="<?php echo $role; ?>-user-links" class="user-links">
88
- <div id="ajax-response-<?php echo $role; ?>" class="ajax-response"></div>
89
- <?php
90
- wdbj_tml_custom_user_links_list_links($links, $role);
91
- wdbj_tml_custom_user_links_link_form($role); ?>
92
- </div>
93
- <?php
94
- }
95
-
96
- function wdbj_tml_custom_user_links_list_links($links, $role) {
97
- // Exit if no links
98
- if ( ! $links ) {
99
- echo '
100
- <table id="' . $role . '-link-table" style="display: none;">
101
- <thead>
102
- <tr>
103
- <th class="left">' . __( 'Title', 'theme-my-login' ) . '</th>
104
- <th>' . __( 'URL', 'theme-my-login' ) . '</th>
105
- <th></th>
106
- </tr>
107
- </thead>
108
- <tbody id="' . $role . '-link-list" class="list:' . $role . '-link">
109
- <tr><td></td></tr>
110
- </tbody>
111
- </table>'; //TBODY needed for list-manipulation JS
112
- return;
113
- }
114
- $count = 0;
115
- ?>
116
- <table id="<?php echo $role; ?>-link-table">
117
- <thead>
118
- <tr>
119
- <th class="left"><?php _e( 'Title', 'theme-my-login' ) ?></th>
120
- <th><?php _e( 'URL', 'theme-my-login' ) ?></th>
121
- <th></th>
122
- </tr>
123
- </thead>
124
- <tbody id='<?php echo $role; ?>-link-list' class='list:<?php echo $role; ?>-link'>
125
- <?php
126
- foreach ( $links as $key => $link ) {
127
- $link['id'] = $key + 1; // Artificially inflate as not to use 0 as a key
128
- echo _wdbj_tml_custom_user_links_link_row( $link, $role, $count );
129
- }
130
- ?>
131
- </tbody>
132
- </table>
133
- <?php
134
- }
135
-
136
- function _wdbj_tml_custom_user_links_link_row( $link, $role, &$count ) {
137
- $r = '';
138
- ++ $count;
139
- if ( $count % 2 )
140
- $style = 'alternate';
141
- else
142
- $style = '';
143
-
144
- $link = (object) $link;
145
-
146
- $delete_nonce = wp_create_nonce( 'delete-' . $role . '-link_' . $link->id );
147
- $update_nonce = wp_create_nonce( 'add-' . $role . '-link' );
148
-
149
- $r .= "\n\t<tr id='$role-link-$link->id' class='$style'>";
150
- $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='user_links[$role][$link->id][title]'>" . __( 'Title', 'theme-my-login' ) . "</label><input name='user_links[$role][$link->id][title]' id='user_links[$role][$link->id][title]' tabindex='6' type='text' size='20' value='$link->title' />";
151
- $r .= wp_nonce_field( 'change-' . $role . '-link', '_ajax_nonce', false, false );
152
- $r .= "</td>";
153
-
154
- $r .= "\n\t\t<td class='center'><label class='screen-reader-text' for='user_links[$role][$link->id][url]'>" . __( 'URL', 'theme-my-login' ) . "</label><input name='user_links[$role][$link->id][url]' id='user_links[$role][$link->id][url]' tabindex='6' type='text' size='20' value='$link->url' /></td>";
155
-
156
- $r .= "\n\t\t<td class='submit'><input name='delete_user_link[$role][$link->id]' type='submit' class='delete:$role-link-list:$role-link-$link->id::_ajax_nonce=$delete_nonce deletelink' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
157
- $r .= "\n\t\t<input name='updatelink' type='submit' class='add:$role-link-list:$role-link-$link->id::_ajax_nonce=$update_nonce updatelink' tabindex='6' value='". esc_attr__( 'Update' ) ."' /></td>\n\t</tr>";
158
- return $r;
159
- }
160
-
161
- function wdbj_tml_custom_user_links_link_form($role) {
162
- ?>
163
- <p><strong><?php _e( 'Add New link:' , 'theme-my-login') ?></strong></p>
164
- <table id="new-<?php echo $role; ?>-link">
165
- <thead>
166
- <tr>
167
- <th class="left"><label for="new_user_link[<?php echo $role; ?>][title]"><?php _e( 'Title', 'theme-my-login' ) ?></label></th>
168
- <th><label for="new_user_link[<?php echo $role; ?>][url]"><?php _e( 'URL', 'theme-my-login' ) ?></label></th>
169
- <th></th>
170
- </tr>
171
- </thead>
172
-
173
- <tbody>
174
- <tr>
175
- <td class="left"><input id="new_user_link[<?php echo $role; ?>][title]" name="new_user_link[<?php echo $role; ?>][title]" type="text" tabindex="8" size="20" /></td>
176
- <td class="center"><input id="new_user_link[<?php echo $role; ?>][url]" name="new_user_link[<?php echo $role; ?>][url]" type="text" tabindex="8" size="20" /></td>
177
-
178
- <td class="submit">
179
- <input type="submit" id="add_new_user_link_<?php echo $role; ?>" name="add_new_user_link[<?php echo $role; ?>]" class="add:<?php echo $role; ?>-link-list:new-<?php echo $role; ?>-link" tabindex="9" value="<?php esc_attr_e( 'Add link', 'theme-my-login' ) ?>" />
180
- <?php wp_nonce_field( 'add-' . $role . '-link', '_ajax_nonce', false ); ?>
181
- </td></tr>
182
- </tbody>
183
- </table>
184
- <?php
185
- }
186
-
187
- function wdbj_tml_custom_user_links_add_user_link_ajax() {
188
-
189
- $user_role = isset($_POST['user_role']) ? $_POST['user_role'] : '';
190
-
191
- check_ajax_referer( 'add-' . $user_role . '-link' );
192
-
193
- $c = 0;
194
- if ( isset($_POST['new_user_link'][$user_role]['title']) || isset($_POST['new_user_link'][$user_role]['url']) ) {
195
- if ( !current_user_can( 'manage_options' ) )
196
- die('-1');
197
-
198
- $clean_title = wp_kses($_POST['new_user_link'][$user_role]['title'], null);
199
- $clean_url = wp_kses($_POST['new_user_link'][$user_role]['url'], null);
200
-
201
- if ( empty($clean_title) || empty($clean_url) )
202
- die('1');
203
-
204
- // Get current links
205
- $links = wdbj_tml_get_option('user_links', $user_role);
206
- // Add new link
207
- $links[] = array('title' => $clean_title, 'url' => $clean_url);
208
- // Update links
209
- wdbj_tml_update_option($links, 'user_links', $user_role);
210
- // Save links
211
- wdbj_tml_save_options();
212
-
213
- $link_row = array_merge( array('id' => max(array_keys($links)) + 1), array_pop($links) );
214
-
215
- $x = new WP_Ajax_Response( array(
216
- 'what' => 'tml-user-link',
217
- 'id' => $link_row['id'],
218
- 'data' => _wdbj_tml_custom_user_links_link_row( $link_row, $user_role, $c ),
219
- 'position' => 1,
220
- 'supplemental' => array('user_role' => $user_role)
221
- ) );
222
- } else {
223
- $user_links = array_pop($_POST['user_links']);
224
- $id = (int) key($user_links);
225
- $clean_title = wp_kses($user_links[$id]['title'], null);
226
- $clean_url = wp_kses($user_links[$id]['url'], null);
227
- --$id; // Fix id offset
228
- if ( !$link = wdbj_tml_get_option( 'user_links', $user_role, $id ) )
229
- die('0'); // if link doesn't exist
230
- if ( !current_user_can( 'manage_options' ) )
231
- die('-1');
232
- if ( $link['title'] != $clean_title || $link['url'] != $clean_url ) {
233
- $link_row = array('title' => $clean_title, 'url' => $clean_url);
234
- if ( !$u = wdbj_tml_update_option( $link_row, 'user_links', $user_role, $id ) )
235
- die('0'); // We know link exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
236
- wdbj_tml_save_options();
237
- }
238
-
239
- ++$id;
240
- $link_row['id'] = $id;
241
-
242
- $x = new WP_Ajax_Response( array(
243
- 'what' => $user_role . '-link',
244
- 'id' => $id, 'old_id' => $id,
245
- 'data' => _wdbj_tml_custom_user_links_link_row( $link_row, $user_role, $c ),
246
- 'position' => 0,
247
- 'supplemental' => array('user_role' => $user_role)
248
- ) );
249
- }
250
- $x->send();
251
- }
252
-
253
- function wdbj_tml_custom_user_links_delete_user_link_ajax() {
254
- global $id;
255
-
256
- $user_role = isset($_POST['user_role']) ? $_POST['user_role'] : '';
257
-
258
- check_ajax_referer( "delete-$user_role-link_$id" );
259
-
260
- --$id; // Fix id offset
261
-
262
- // Get current links
263
- if ( $links = wdbj_tml_get_option('user_links', $user_role) ) {
264
- if ( isset($links[$id]) ) {
265
- // Delete link
266
- unset($links[$id]);
267
- // Update links
268
- wdbj_tml_update_option($links, 'user_links', $user_role);
269
- // Save links
270
- wdbj_tml_save_options();
271
- }
272
- die('1');
273
- }
274
- die('0');
275
- }
276
-
277
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-user-links/admin/{admin.css → css/custom-user-links-admin.css} RENAMED
@@ -1,13 +1,13 @@
1
- div.user-links {
2
  border: none;
3
  padding: 10px;
4
  }
5
 
6
- div.user-links div.ajax-response {
7
  border: none;
8
  }
9
 
10
- .user-links .submit input {
11
  text-decoration: none;
12
  font-size: 11px !important;
13
  line-height: 13px;
@@ -25,9 +25,9 @@ div.user-links div.ajax-response {
25
  box-sizing: content-box;
26
  }
27
 
28
- .user-links table,
29
- .user-links input,
30
- .user-links textarea {
31
  border-width: 1px;
32
  border-style: solid;
33
  -moz-border-radius: 3px;
@@ -36,24 +36,24 @@ div.user-links div.ajax-response {
36
  border-radius: 3px;
37
  }
38
 
39
- .user-links .updatelink,
40
- .user-links .deletelink {
41
  margin: auto;
42
  }
43
 
44
- .user-links thead th {
45
  padding: 5px 8px 8px;
46
  background-color: #f1f1f1;
47
  }
48
 
49
- .user-links .submit {
50
  border: 0 none;
51
  float: none;
52
  padding: 5px 8px;
53
  width: 25%;
54
  }
55
 
56
- .user-links table {
57
  margin: 0;
58
  width: 100%;
59
  border-width: 1px;
@@ -63,23 +63,23 @@ div.user-links div.ajax-response {
63
  background-color: #f9f9f9;
64
  }
65
 
66
- .user-links table input,
67
- .user-links table select {
68
  width: 95%;
69
  margin: 8px 0 8px 8px;
70
  border-color: #dfdfdf;
71
  background-color: #fff;
72
  }
73
 
74
- .user-links th.left,
75
- .user-links td.left {
76
  width: 35%;
77
  }
78
 
79
- .user-links td.center {
80
  text-align: center;
81
  }
82
 
83
- .user-links .submit input {
84
  width: auto;
85
  }
1
+ div.tml-options-user-links {
2
  border: none;
3
  padding: 10px;
4
  }
5
 
6
+ div.tml-options-user-links div.ajax-response {
7
  border: none;
8
  }
9
 
10
+ .tml-options-user-links .submit input {
11
  text-decoration: none;
12
  font-size: 11px !important;
13
  line-height: 13px;
25
  box-sizing: content-box;
26
  }
27
 
28
+ .tml-options-user-links table,
29
+ .tml-options-user-links input,
30
+ .tml-options-user-links textarea {
31
  border-width: 1px;
32
  border-style: solid;
33
  -moz-border-radius: 3px;
36
  border-radius: 3px;
37
  }
38
 
39
+ .tml-options-user-links .updatelink,
40
+ .tml-options-user-links .deletelink {
41
  margin: auto;
42
  }
43
 
44
+ .tml-options-user-links thead th {
45
  padding: 5px 8px 8px;
46
  background-color: #f1f1f1;
47
  }
48
 
49
+ .tml-options-user-links .submit {
50
  border: 0 none;
51
  float: none;
52
  padding: 5px 8px;
53
  width: 25%;
54
  }
55
 
56
+ .tml-options-user-links table {
57
  margin: 0;
58
  width: 100%;
59
  border-width: 1px;
63
  background-color: #f9f9f9;
64
  }
65
 
66
+ .tml-options-user-links table input,
67
+ .tml-options-user-links table select {
68
  width: 95%;
69
  margin: 8px 0 8px 8px;
70
  border-color: #dfdfdf;
71
  background-color: #fff;
72
  }
73
 
74
+ .tml-options-user-links th.left,
75
+ .tml-options-user-links td.left {
76
  width: 35%;
77
  }
78
 
79
+ .tml-options-user-links td.center {
80
  text-align: center;
81
  }
82
 
83
+ .tml-options-user-links .submit input {
84
  width: auto;
85
  }
modules/custom-user-links/admin/custom-user-links-admin.php ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists( 'Theme_My_Login_Custom_User_Links_Admin' ) ) :
4
+ /**
5
+ * Theme My Login Custom User Links module admin class
6
+ *
7
+ * @since 6.0
8
+ */
9
+ class Theme_My_Login_Custom_User_Links_Admin extends Theme_My_Login_Module {
10
+ /**
11
+ * AJAX handler for adding/updating a link
12
+ *
13
+ * Callback for "wp_ajax_add-user-link" hook in file "wp-admin/admin-ajax.php"
14
+ *
15
+ * @since 6.0
16
+ * @access public
17
+ */
18
+ function add_user_link_ajax() {
19
+
20
+ if ( !current_user_can( 'manage_options' ) )
21
+ die( '-1' );
22
+
23
+ check_ajax_referer( 'add-user-link' );
24
+
25
+ // Create a reference to current links
26
+ $links =& $this->theme_my_login->options['user_links'];
27
+
28
+ $c = 0;
29
+ if ( isset( $_POST['new_user_link'] ) ) {
30
+ // Add a new link
31
+ foreach ( $_POST['new_user_link'] as $role => $link ) {
32
+ // Make sure input isn't empty
33
+ if ( is_array( $link ) && !empty( $link ) ) {
34
+ // Clean the input
35
+ $clean_title = wp_kses( $link['title'], null );
36
+ $clean_url = wp_kses( $link['url'], null );
37
+
38
+ // Make sure input isn't empty after cleaning
39
+ if ( empty( $clean_title ) || empty( $clean_url ) )
40
+ die( '1' );
41
+
42
+ // Add new link
43
+ $links[$role][] = array( 'title' => $clean_title, 'url' => $clean_url );
44
+ // Save links
45
+ $this->theme_my_login->save_options();
46
+
47
+ $link_row = array_merge( array( 'id' => max( array_keys( $links[$role] ) ) ), end( $links[$role] ) );
48
+
49
+ $x = new WP_Ajax_Response( array(
50
+ 'what' => $role . '-link',
51
+ 'id' => $link_row['id'],
52
+ 'data' => $this->get_link_row( $link_row, $role, $c ),
53
+ 'position' => 1,
54
+ 'supplemental' => array( 'user_role' => $role )
55
+ ) );
56
+ }
57
+ }
58
+ } else {
59
+ // Update a link
60
+ foreach ( $_POST['user_links'] as $role => $link ) {
61
+ // Set the link ID
62
+ $id = key( $link );
63
+
64
+ // Clean the input
65
+ $clean_title = wp_kses( $link[$id]['title'], null );
66
+ $clean_url = wp_kses( $link[$id]['url'], null );
67
+
68
+ // Make sure the requested link ID exists
69
+ if ( !isset( $links[$role][$id] ) )
70
+ die( '0' );
71
+
72
+ // Create a reference to the link being edited
73
+ $current_link =& $links[$role][$id];
74
+
75
+ // Update the link if it has changed
76
+ if ( $current_link['title'] != $clean_title || $current_link['url'] != $clean_url ) {
77
+ $current_link = array( 'title' => $clean_title, 'url' => $clean_url );
78
+ $this->theme_my_login->save_options();
79
+ }
80
+
81
+ $link_row = array_merge( array( 'id' => $id ), $current_link );
82
+
83
+ $x = new WP_Ajax_Response( array(
84
+ 'what' => $role . '-link',
85
+ 'id' => $id,
86
+ 'old_id' => $id,
87
+ 'data' => $this->get_link_row( $link_row, $role, $c ),
88
+ 'position' => 0,
89
+ 'supplemental' => array( 'user_role' => $role )
90
+ ) );
91
+ }
92
+ }
93
+ $x->send();
94
+ }
95
+
96
+ /**
97
+ * AJAX handler for deleting a link
98
+ *
99
+ * Callback for "wp_ajax_delete-user-link" hook in file "wp-admin/admin-ajax.php"
100
+ *
101
+ * @since 6.0
102
+ * @access public
103
+ */
104
+ function delete_user_link_ajax() {
105
+ global $id;
106
+
107
+ $user_role = isset( $_POST['user_role'] ) ? $_POST['user_role'] : '';
108
+ if ( empty( $user_role ) )
109
+ die( '0' );
110
+
111
+ check_ajax_referer( "delete-user-link_$id" );
112
+
113
+ $links =& $this->theme_my_login->options['user_links'][$user_role];
114
+ if ( isset( $links[$id] ) ) {
115
+ // Delete link
116
+ unset( $links[$id] );
117
+ // Save links
118
+ $this->theme_my_login->save_options();
119
+ die( '1' );
120
+ }
121
+ die( '0' );
122
+ }
123
+
124
+ /**
125
+ * Adds "User Links" tab to Theme My Login menu
126
+ *
127
+ * Callback for "tml_admin_menu" hook in method Theme_My_Login_Admin::display_settings_page()
128
+ *
129
+ * @see Theme_My_Login_Admin::display_settings_page(), Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
130
+ * @uses Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
131
+ * @since 6.0
132
+ * @access public
133
+ *
134
+ * @param object $admin Reference to global $theme_my_login_admin object
135
+ */
136
+ function admin_menu( &$admin ) {
137
+ global $wp_roles;
138
+ // Add menu tab
139
+ $admin->add_menu_page( __( 'User Links', $this->theme_my_login->textdomain ), 'tml-options-user-links' );
140
+ // Iterate through each user role
141
+ foreach ( $wp_roles->get_names() as $role => $label ) {
142
+ // We don't want the 'pending' role created by the "User Moderation" module
143
+ if ( 'pending' == $role )
144
+ continue;
145
+ // Add submenu tab for the role
146
+ $admin->add_submenu_page( 'tml-options-user-links', translate_user_role( $label ), 'tml-options-user-links-' . $role, array( &$this, 'display_settings' ), array( $role ) );
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Sanitizes settings
152
+ *
153
+ * Callback for "tml_save_settings" hook in method Theme_My_Login_Admin::save_settings()
154
+ *
155
+ * @see Theme_My_Login_Admin::save_settings()
156
+ * @since 6.0
157
+ * @access public
158
+ *
159
+ * @param string|array $settings Settings passed in from filter
160
+ * @return string|array Sanitized settings
161
+ */
162
+ function save_settings( $settings ) {
163
+ // Bail-out if doing AJAX because it has it's own saving routine
164
+ if ( defined('DOING_AJAX') && DOING_AJAX )
165
+ return $settings;
166
+ // Handle updating/deleting of links
167
+ if ( isset( $_POST['user_links'] ) && is_array( $_POST['user_links'] ) && !empty( $_POST['user_links'] ) ) {
168
+ foreach ( $_POST['user_links'] as $role => $links ) {
169
+ foreach ( $links as $key => $link ) {
170
+ $clean_title = wp_kses( $link['title'], null );
171
+ $clean_url = wp_kses( $link['url'], null );
172
+ $links[$key] = array( 'title' => $clean_title, 'url' => $clean_url );
173
+ if ( ( empty( $clean_title ) && empty( $clean_url ) ) || ( isset( $_POST['delete_user_link'][$role][$key] ) ) )
174
+ unset( $links[$key] );
175
+ }
176
+ $settings['user_links'][$role] = array_values( $links );
177
+ }
178
+ }
179
+ // Handle new links
180
+ if ( isset( $_POST['new_user_link'] ) && is_array( $_POST['new_user_link'] ) && !empty( $_POST['new_user_link'] ) ) {
181
+ foreach ( $_POST['new_user_link'] as $role => $link ) {
182
+ $clean_title = wp_kses( $link['title'], null );
183
+ $clean_url = wp_kses( $link['url'], null );
184
+ if ( !empty( $clean_title ) && !empty( $clean_url ) )
185
+ $settings['user_links'][$role][] = array( 'title' => $clean_title, 'url' => $clean_url );
186
+ }
187
+ }
188
+ // Reset link keys
189
+ foreach ( $settings['user_links'] as $role => $links ) {
190
+ $settings['user_links'][$role] = array_values( $links );
191
+ }
192
+ return $settings;
193
+ }
194
+
195
+ /**
196
+ * Loads admin styles and scripts
197
+ *
198
+ * Callback for "load-settings_page_theme-my-login" hook in file "wp-admin/admin.php"
199
+ *
200
+ * @since 6.0
201
+ * @access public
202
+ */
203
+ function load_settings_page() {
204
+ wp_enqueue_style( 'tml-custom-user-links-admin', plugins_url( 'theme-my-login/modules/custom-user-links/admin/css/custom-user-links-admin.css' ) );
205
+ wp_enqueue_script( 'tml-custom-user-links-admin', plugins_url( 'theme-my-login/modules/custom-user-links/admin/js/custom-user-links-admin.js' ), array( 'wp-lists', 'jquery-ui-sortable' ) );
206
+ }
207
+
208
+ /**
209
+ * Outputs user links admin menu for specified role
210
+ *
211
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
212
+ *
213
+ * @see Theme_My_Login_Admin::add_submenu_page()
214
+ * @since 6.0
215
+ * @access public
216
+ *
217
+ * @param string $role Name of user role
218
+ */
219
+ function display_settings( $role ) {
220
+ $links =& $this->theme_my_login->options['user_links'][$role];
221
+ if ( empty($links) )
222
+ $links = array();
223
+ ?>
224
+ <div id="ajax-response-<?php echo $role; ?>" class="ajax-response"></div>
225
+
226
+ <table id="<?php echo $role; ?>-link-table"<?php if ( empty( $links ) ) echo ' style="display: none;"'; ?> class="sortable">
227
+ <thead>
228
+ <tr>
229
+ <th class="left"><?php _e( 'Title', $this->theme_my_login->textdomain ); ?></th>
230
+ <th><?php _e( 'URL', $this->theme_my_login->textdomain ); ?></th>
231
+ <th></th>
232
+ </tr>
233
+ </thead>
234
+ <tbody id="<?php echo $role; ?>-link-list" class="list:user-link">
235
+ <?php if ( empty( $links ) ) {
236
+ echo '<tr><td></td></tr>';
237
+ } else {
238
+ $count = 0;
239
+ foreach ( $links as $key => $link ) {
240
+ $link['id'] = $key;
241
+ echo $this->get_link_row( $link, $role, $count );
242
+ }
243
+ } ?>
244
+ </tbody>
245
+ </table>
246
+
247
+ <p><strong><?php _e( 'Add New link:' , $this->theme_my_login->textdomain ) ?></strong></p>
248
+
249
+ <table id="new-<?php echo $role; ?>-link">
250
+ <thead>
251
+ <tr>
252
+ <th class="left"><label for="new_user_link[<?php echo $role; ?>][title]"><?php _e( 'Title', $this->theme_my_login->textdomain ) ?></label></th>
253
+ <th><label for="new_user_link[<?php echo $role; ?>][url]"><?php _e( 'URL', $this->theme_my_login->textdomain ) ?></label></th>
254
+ <th></th>
255
+ </tr>
256
+ </thead>
257
+
258
+ <tbody>
259
+ <tr>
260
+ <td class="left"><input id="new_user_link[<?php echo $role; ?>][title]" name="new_user_link[<?php echo $role; ?>][title]" type="text" tabindex="8" size="20" /></td>
261
+ <td class="center"><input id="new_user_link[<?php echo $role; ?>][url]" name="new_user_link[<?php echo $role; ?>][url]" type="text" tabindex="8" size="20" /></td>
262
+ <td class="submit">
263
+ <input type="submit" id="add_new_user_link_<?php echo $role; ?>" name="add_new_user_link[<?php echo $role; ?>]" class="add:<?php echo $role; ?>-link-list:new-<?php echo $role; ?>-link" tabindex="9" value="<?php esc_attr_e( 'Add link', $this->theme_my_login->textdomain ) ?>" />
264
+ <?php wp_nonce_field( 'add-user-link', '_ajax_nonce', false ); ?>
265
+ </td>
266
+ </tr>
267
+ </tbody>
268
+ </table>
269
+ <?php
270
+ }
271
+
272
+ /**
273
+ * Outputs a link row to the table
274
+ *
275
+ * @since 6.0
276
+ * @access public
277
+ *
278
+ * @param array $link Link data
279
+ * @param string $role Name of user role
280
+ * @param int $count Reference to counter variable
281
+ * @return sring Link row
282
+ */
283
+ function get_link_row( $link, $role, &$count ) {
284
+ $r = '';
285
+ ++ $count;
286
+ if ( $count % 2 )
287
+ $style = 'alternate';
288
+ else
289
+ $style = '';
290
+
291
+ $link = (object) $link;
292
+
293
+ $delete_nonce = wp_create_nonce( 'delete-user-link_' . $link->id );
294
+ $update_nonce = wp_create_nonce( 'add-user-link' );
295
+
296
+ $r .= "\n\t<tr id='$role-link-$link->id' class='$style'>";
297
+ $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='user_links[$role][$link->id][title]'>" . __( 'Title', $this->theme_my_login->textdomain ) . "</label><input name='user_links[$role][$link->id][title]' id='user_links[$role][$link->id][title]' tabindex='6' type='text' size='20' value='$link->title' />";
298
+ $r .= wp_nonce_field( 'change-user-link', '_ajax_nonce', false, false );
299
+ $r .= "</td>";
300
+
301
+ $r .= "\n\t\t<td class='center'><label class='screen-reader-text' for='user_links[$role][$link->id][url]'>" . __( 'URL', $this->theme_my_login->textdomain ) . "</label><input name='user_links[$role][$link->id][url]' id='user_links[$role][$link->id][url]' tabindex='6' type='text' size='20' value='$link->url' /></td>";
302
+
303
+ $r .= "\n\t\t<td class='submit'><input name='delete_user_link[$role][$link->id]' type='submit' class='delete:$role-link-list:$role-link-$link->id::_ajax_nonce=$delete_nonce deletelink' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
304
+ $r .= "\n\t\t<input name='updatelink' type='submit' class='add:$role-link-list:$role-link-$link->id::_ajax_nonce=$update_nonce updatelink' tabindex='6' value='". esc_attr__( 'Update' ) ."' /></td>\n\t</tr>";
305
+ return $r;
306
+ }
307
+
308
+ /**
309
+ * Loads the module
310
+ *
311
+ * @since 6.0
312
+ * @access public
313
+ */
314
+ function load() {
315
+ add_action( 'tml_admin_menu', array( &$this, 'admin_menu' ) );
316
+ add_filter( 'tml_save_settings', array( &$this, 'save_settings' ) );
317
+
318
+ add_action( 'load-settings_page_theme-my-login', array( &$this, 'load_settings_page' ) );
319
+
320
+ add_action( 'wp_ajax_add-user-link', array( &$this, 'add_user_link_ajax' ) );
321
+ add_action( 'wp_ajax_delete-user-link', array( &$this, 'delete_user_link_ajax' ) );
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Holds the reference to Theme_My_Login_Custom_User_Links_Admin object
327
+ * @global object $theme_my_login_custom_user_links_admin
328
+ * @since 6.0
329
+ */
330
+ $theme_my_login_custom_user_links_admin = new Theme_My_Login_Custom_User_Links_Admin();
331
+
332
+ endif; // Class exists
333
+
334
+ ?>
modules/custom-user-links/admin/js/custom-user-links-admin.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function($) {
2
+ $('#tml-options-user-links tbody').wpList( {
3
+ addBefore: function( s ) {
4
+ var cls = $(s.target).attr('class').split(':'),
5
+ role = cls[1].split('-')[0];
6
+ s.what = role + '-link';
7
+ return s;
8
+ },
9
+ addAfter: function( xml, s ) {
10
+ var cls = $(s.target).attr('class').split(':'),
11
+ role = cls[1].split('-')[0];
12
+ $('table#' + role + '-link-table').show();
13
+ },
14
+ delBefore: function( s ) {
15
+ var cls = $(s.target).attr('class').split(':'),
16
+ role = cls[1].split('-')[0];
17
+ s.data.user_role = role;
18
+ return s;
19
+ },
20
+ delAfter: function( r, s ) {
21
+ $('#' + s.element).remove();
22
+ }
23
+ } );
24
+
25
+ var fixHelper = function(e, ui) {
26
+ ui.children().each(function() {
27
+ $(this).width($(this).width());
28
+ });
29
+ return ui;
30
+ };
31
+
32
+ $('#tml-options-user-links table.sortable tbody').sortable({
33
+ axis: 'y',
34
+ helper: fixHelper,
35
+ items: 'tr'
36
+ });
37
+ } );
modules/custom-user-links/custom-user-links.php CHANGED
@@ -4,71 +4,121 @@ Plugin Name: Custom User Links
4
  Description: Enabling this module will initialize custom user links. You will then have to configure the settings via the "User Links" tab.
5
  */
6
 
7
- add_action('tml_init', 'wdbj_tml_custom_user_links_init');
8
- function wdbj_tml_custom_user_links_init() {
9
- add_filter('tml_user_links', 'wdbj_tml_custom_user_links');
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- function wdbj_tml_custom_user_links($links) {
13
- if ( !is_user_logged_in() )
14
- return $links;
 
 
 
 
 
15
 
16
- $current_user = wp_get_current_user();
17
- $user_role = reset($current_user->roles);
18
-
19
- $links = wdbj_tml_get_option('user_links', $user_role);
20
- if ( !is_array($links) || empty($links) )
21
- $links = array();
22
 
23
- // Allow for user_id variable in link
24
- foreach ( $links as $key => $link ) {
25
- $links[$key]['url'] = str_replace('%user_id%', $current_user->ID, $link['url']);
26
  }
27
-
28
- return $links;
29
- }
30
 
31
- add_action('tml_admin_init', 'wdbj_tml_custom_user_links_admin_init');
32
- function wdbj_tml_custom_user_links_admin_init() {
33
- global $wp_roles;
34
-
35
- if ( empty($wp_roles) )
36
- $wp_roles = new WP_Roles();
37
-
38
- require_once (TML_MODULE_DIR . '/custom-user-links/admin/admin.php');
39
- add_action('tml_admin_menu', 'wdbj_tml_custom_user_links_admin_menu');
40
- add_filter('tml_save_settings', 'wdbj_tml_custom_user_links_save_settings');
41
- add_action('tml_settings_page', 'wdbj_tml_custom_user_links_admin_styles');
42
- foreach ( $wp_roles->get_names() as $role => $label ) {
43
- add_action('wp_ajax_add-' . $role . '-link', 'wdbj_tml_custom_user_links_add_user_link_ajax');
44
- add_action('wp_ajax_delete-' . $role . '-link', 'wdbj_tml_custom_user_links_delete_user_link_ajax');
 
 
 
 
45
  }
46
- }
47
 
48
- add_action('activate_custom-user-links/custom-user-links.php', 'wdbj_tml_custom_user_links_activate');
49
- function wdbj_tml_custom_user_links_activate() {
50
- $current = wdbj_tml_get_option('user_links');
51
- $default = wdbj_tml_custom_user_links_default_settings();
52
-
53
- if ( is_array($current) )
54
- wdbj_tml_update_option(array_merge($default, $current), 'user_links');
55
- else
56
- wdbj_tml_update_option($default, 'user_links');
57
-
58
- unset($current, $default);
59
- }
 
 
60
 
61
- function wdbj_tml_custom_user_links_default_settings() {
62
- global $wp_roles;
63
- foreach ( $wp_roles->get_names() as $role => $label ) {
64
- if ( 'pending' == $role )
65
- continue;
66
- $options[$role] = array(
67
- array('title' => __('Dashboard', 'theme-my-login'), 'url' => admin_url()),
68
- array('title' => __('Profile', 'theme-my-login'), 'url' => admin_url('profile.php'))
69
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
- return $options;
72
  }
73
 
74
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
4
  Description: Enabling this module will initialize custom user links. You will then have to configure the settings via the "User Links" tab.
5
  */
6
 
7
+ if ( !class_exists( 'Theme_My_Login_Custom_User_Links' ) ) :
8
+ /**
9
+ * Theme My Login Custom User Links module class
10
+ *
11
+ * Adds the ability to define custom links to display to a user when logged in based upon their "user role".
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Custom_User_Links extends Theme_My_Login_Module {
16
+ /**
17
+ * Gets the user links for the current user's role
18
+ *
19
+ * Callback for "tml_user_links" hook in method Theme_My_Login_Template::display()
20
+ *
21
+ * @see Theme_My_Login_Template::display()
22
+ * @since 6.0
23
+ * @access public
24
+ *
25
+ * @param array $links Default user links
26
+ * @return array New user links
27
+ */
28
+ function get_user_links( $links = array() ) {
29
 
30
+ if ( !is_user_logged_in() )
31
+ return $links;
32
+
33
+ $current_user = wp_get_current_user();
34
+
35
+ $links = $this->theme_my_login->options['user_links'][$current_user->roles[0]];
36
+ if ( !is_array( $links ) || empty( $links ) )
37
+ $links = array();
38
 
39
+ // Allow for user_id variable in link
40
+ foreach ( $links as $key => $link ) {
41
+ $links[$key]['url'] = str_replace( '%user_id%', $current_user->ID, $link['url'] );
42
+ }
 
 
43
 
44
+ return $links;
 
 
45
  }
 
 
 
46
 
47
+ /**
48
+ * Activates this module
49
+ *
50
+ * Callback for "tml_activate_custom-user-links/custom-user-links.php" hook in method Theme_My_Login_Admin::activate_module()
51
+ *
52
+ * @see Theme_My_Login_Admin::activate_module()
53
+ * @since 6.0
54
+ * @access public
55
+ *
56
+ * @param object $theme_my_login Reference to global $theme_my_login object
57
+ */
58
+ function activate( &$theme_my_login ) {
59
+ $options = $this->init_options();
60
+ if ( !isset( $theme_my_login->options['user_links'] ) ) {
61
+ $theme_my_login->options['user_links'] = $options['user_links'];
62
+ } else {
63
+ $theme_my_login->options['user_links'] = $theme_my_login->array_merge_recursive( $options['user_links'], $theme_my_login->options['user_links'] );
64
+ }
65
  }
 
66
 
67
+ /**
68
+ * Initializes options for this module
69
+ *
70
+ * Callback for "tml_init_options" hook in method Theme_My_Login_Base::init_options()
71
+ *
72
+ * @see Theme_My_Login_Base::init_options()
73
+ * @since 6.0
74
+ * @access public
75
+ *
76
+ * @param array $options Options passd in from filter
77
+ * @return array Original $options array with module options appended
78
+ */
79
+ function init_options( $options = array() ) {
80
+ global $wp_roles;
81
 
82
+ if ( empty( $wp_roles ) )
83
+ $wp_roles =& new WP_Roles();
84
+
85
+ $options = (array) $options;
86
+
87
+ $options['user_links'] = array();
88
+ foreach ( $wp_roles->get_names() as $role => $label ) {
89
+ if ( 'pending' == $role )
90
+ continue;
91
+ $options['user_links'][$role] = array(
92
+ array( 'title' => __( 'Dashboard', $this->theme_my_login->textdomain ), 'url' => admin_url() ),
93
+ array( 'title' => __( 'Profile', $this->theme_my_login->textdomain ), 'url' => admin_url( 'profile.php' ) )
94
+ );
95
+ }
96
+ return $options;
97
+ }
98
+
99
+ /**
100
+ * Loads the module
101
+ *
102
+ * @since 6.0
103
+ * @access public
104
+ */
105
+ function load() {
106
+ add_action( 'tml_activate_custom-user-links/custom-user-links.php', array( &$this, 'activate' ) );
107
+ add_filter( 'tml_init_options', array( &$this, 'init_options' ) );
108
+ add_filter( 'tml_user_links', array( &$this, 'get_user_links' ) );
109
  }
 
110
  }
111
 
112
+ /**
113
+ * Holds the reference to Theme_My_Login_Custom_User_Links object
114
+ * @global object $theme_my_login_custom_user_links
115
+ * @since 6.0
116
+ */
117
+ $theme_my_login_custom_user_links = new Theme_My_Login_Custom_User_Links();
118
+
119
+ if ( is_admin() )
120
+ include_once( TML_ABSPATH. '/modules/custom-user-links/admin/custom-user-links-admin.php' );
121
+
122
+ endif; // Class exists
123
+
124
+ ?>
modules/security/admin/js/security-admin.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ jQuery(document).ready( function($) {
2
+ $('#users .row-actions .unlock-user').parents('tr').children().css('background-color', '#ffebe8');
3
+ } );
modules/security/admin/security-admin.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists( 'Theme_My_Login_Security_Admin' ) ) :
4
+ /**
5
+ * Theme My Login Security module admin class
6
+ *
7
+ * @since 6.0
8
+ */
9
+ class Theme_My_Login_Security_Admin extends Theme_My_Login_Module {
10
+ /**
11
+ * Attaches actions/filters explicitly to "users.php"
12
+ *
13
+ * Callback for "load-users.php" hook
14
+ *
15
+ * @since 6.0
16
+ * @access public
17
+ */
18
+ function load_users_page() {
19
+ global $theme_my_login_security;
20
+
21
+ // Shorthand reference
22
+ $theme_my_login =& $this->theme_my_login;
23
+
24
+ wp_enqueue_script( 'tml-security-admin', plugins_url( TML_DIRNAME . '/modules/security/admin/js/security-admin.js' ), array( 'jquery' ) );
25
+
26
+ add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
27
+ add_filter( 'user_row_actions', array( &$this, 'user_row_actions' ), 10, 2 );
28
+
29
+ if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'lock', 'unlock' ) ) ) {
30
+
31
+ $redirect_to = isset( $_REQUEST['wp_http_referer'] ) ? remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), stripslashes( $_REQUEST['wp_http_referer'] ) ) : 'users.php';
32
+ $user = isset( $_GET['user'] ) ? $_GET['user'] : '';
33
+
34
+ if ( !$user || !current_user_can( 'edit_user', $user ) )
35
+ wp_die( __( 'You can&#8217;t edit that user.', $theme_my_login->textdomain ) );
36
+
37
+ if ( !$user = get_userdata( $user ) )
38
+ wp_die( __( 'You can&#8217;t edit that user.', $theme_my_login->textdomain ) );
39
+
40
+ if ( 'lock' == $_GET['action'] ) {
41
+ check_admin_referer( 'lock-user_' . $user->ID );
42
+
43
+ $theme_my_login_security->lock_user( $user );
44
+
45
+ $redirect_to = add_query_arg( 'update', 'lock', $redirect_to );
46
+ } elseif ( 'unlock' == $_GET['action'] ) {
47
+ check_admin_referer( 'unlock-user_' . $user->ID );
48
+
49
+ $theme_my_login_security->unlock_user( $user );
50
+
51
+ $redirect_to = add_query_arg( 'update', 'unlock', $redirect_to );
52
+ }
53
+
54
+ wp_redirect( $redirect_to );
55
+ exit;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Adds update messages to the admin screen
61
+ *
62
+ * Callback for "admin_notices" hook in file admin-header.php
63
+ *
64
+ * @since 6.0
65
+ * @access public
66
+ */
67
+ function admin_notices() {
68
+ if ( isset( $_GET['update'] ) ) {
69
+ if ( 'lock' == $_GET['update'] )
70
+ echo '<div id="message" class="updated fade"><p>' . __( 'User locked.', $this->theme_my_login->textdomain ) . '</p></div>';
71
+ elseif ( 'unlock' == $_GET['update'] )
72
+ echo '<div id="message" class="updated fade"><p>' . __( 'User unlocked.', $this->theme_my_login->textdomain ) . '</p></div>';
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Adds "Lock" and "Unlock" links for each pending user on users.php
78
+ *
79
+ * Callback for "user_row_actions" hook in {@internal unknown}
80
+ *
81
+ * @since 6.0
82
+ * @access public
83
+ *
84
+ * @param array $actions The user actions
85
+ * @param WP_User $user_object The current user object
86
+ * @return array The filtered user actions
87
+ */
88
+ function user_row_actions( $actions, $user_object ) {
89
+ $current_user = wp_get_current_user();
90
+
91
+ $security_meta = isset( $user_object->theme_my_login_security ) ? (array) $user_object->theme_my_login_security : array();
92
+
93
+ if ( $current_user->ID != $user_object->ID ) {
94
+ if ( isset( $security_meta['is_locked'] ) && $security_meta['is_locked'] )
95
+ $new_actions['unlock-user'] = '<a href="' . add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url( "users.php?action=unlock&amp;user=$user_object->ID", "unlock-user_$user_object->ID" ) ) . '">' . __( 'Unlock', $this->theme_my_login->textdomain ) . '</a>';
96
+ else
97
+ $new_actions['lock-user'] = '<a href="' . add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url( "users.php?action=lock&amp;user=$user_object->ID", "lock-user_$user_object->ID" ) ) . '">' . __( 'Lock', $this->theme_my_login->textdomain ) . '</a>';
98
+ $actions = array_merge( $new_actions, $actions );
99
+ }
100
+ return $actions;
101
+ }
102
+
103
+ /**
104
+ * Adds "Security" tab to Theme My Login menu
105
+ *
106
+ * Callback for "tml_admin_menu" hook in method Theme_My_Login_Admin::display_settings_page()
107
+ *
108
+ * @see Theme_My_Login_Admin::display_settings_page(), Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
109
+ * @uses Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
110
+ * @since 6.0
111
+ * @access public
112
+ *
113
+ * @param object $admin Reference to global $theme_my_login_admin object
114
+ */
115
+ function admin_menu( &$admin ) {
116
+ $admin->add_menu_page( __( 'Security', $this->theme_my_login->textdomain ), 'tml-options-security', array( &$this, 'display_settings' ) );
117
+ }
118
+
119
+ /**
120
+ * Outputs user moderation settings
121
+ *
122
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
123
+ *
124
+ * @see Theme_My_Login_Admin::add_submenu_page()
125
+ * @since 6.0
126
+ * @access public
127
+ */
128
+ function display_settings() {
129
+ // Shorthand reference
130
+ $theme_my_login =& $this->theme_my_login;
131
+ // Security options
132
+ $security = $theme_my_login->get_option( array( 'security', 'failed_login' ), array() );
133
+ ?>
134
+ <table class="form-table">
135
+ <tr valign="top">
136
+ <th scope="row"><?php _e( 'Login Attempts', $this->theme_my_login->textdomain ); ?></th>
137
+ <td>
138
+ <?php
139
+ // Units
140
+ $units = array(
141
+ 'minute' => __( 'minute(s)', $this->theme_my_login->textdomain ),
142
+ 'hour' => __( 'hour(s)', $this->theme_my_login->textdomain ),
143
+ 'day' => __( 'day(s)', $this->theme_my_login->textdomain )
144
+ );
145
+ // Threshold
146
+ $threshold = '<input type="text" name="theme_my_login[security][failed_login][threshold]" id="theme_my_login_security_failed_login_threshold" value="' . $security['threshold'] . '" size="1" />';
147
+ // Threshold duration
148
+ $threshold_duration = '<input type="text" name="theme_my_login[security][failed_login][threshold_duration]" id="theme_my_login_security_failed_login_threshold_duration" value="' . $security['threshold_duration'] . '" size="1" />';
149
+ // Threshold duration unit
150
+ $threshold_duration_unit = '<select name="theme_my_login[security][failed_login][threshold_duration_unit]" id="theme_my_login_security_failed_login_threshold_duration_unit">';
151
+ foreach ( $units as $unit => $label ) {
152
+ $selected = ( $security['threshold_duration_unit'] == $unit ) ? ' selected="selected"' : '';
153
+ $threshold_duration_unit .= '<option value="' . $unit . '"' . $selected . '>' . $label . '</option>';
154
+ }
155
+ $threshold_duration_unit .= '</select>';
156
+ // Lockout duration
157
+ $lockout_duration = '<input type="text" name="theme_my_login[security][failed_login][lockout_duration]" id="theme_my_login_security_failed_login_lockout_duration" value="' . $security['lockout_duration'] . '" size="1" />';
158
+ // Lockout duration unit
159
+ $lockout_duration_unit = '<select name="theme_my_login[security][failed_login][lockout_duration_unit]" id="theme_my_login_security_failed_login_lockout_duration_unit">';
160
+ foreach ( $units as $unit => $label ) {
161
+ $selected = ( $security['lockout_duration_unit'] == $unit ) ? ' selected="selected"' : '';
162
+ $lockout_duration_unit .= '<option value="' . $unit . '"' . $selected . '>' . $label . '</option>';
163
+ }
164
+ $lockout_duration_unit .= '</select>';
165
+ // Output them all
166
+ printf( __( 'After %1$s failed login attempts within %2$s %3$s, lockout the account for %4$s %5$s.', $this->theme_my_login->textdomain ), $threshold, $threshold_duration, $threshold_duration_unit, $lockout_duration, $lockout_duration_unit ); ?>
167
+ </td>
168
+ </tr>
169
+ </table>
170
+ <?php
171
+ }
172
+
173
+ /**
174
+ * Sanitizes settings
175
+ *
176
+ * Callback for "tml_save_settings" hook in method Theme_My_Login_Admin::save_settings()
177
+ *
178
+ * @see Theme_My_Login_Admin::save_settings()
179
+ * @since 6.0
180
+ * @access public
181
+ *
182
+ * @param string|array $settings Settings passed in from filter
183
+ * @return string|array Sanitized settings
184
+ */
185
+ function save_settings( $settings ) {
186
+ $settings['security']['failed_login']['threshold'] = absint( $settings['security']['failed_login']['threshold'] );
187
+ $settings['security']['failed_login']['threshold_duration'] = absint( $settings['security']['failed_login']['threshold_duration'] );
188
+ $settings['security']['failed_login']['lockout_duration'] = absint( $settings['security']['failed_login']['lockout_duration'] );
189
+ return $settings;
190
+ }
191
+
192
+ /**
193
+ * Loads the module
194
+ *
195
+ * @since 6.0
196
+ * @access public
197
+ */
198
+ function load() {
199
+ add_action( 'tml_admin_menu', array( &$this, 'admin_menu' ) );
200
+ add_filter( 'tml_save_settings', array( &$this, 'save_settings' ) );
201
+ add_action( 'load-users.php', array( &$this, 'load_users_page' ) );
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Holds the reference to Theme_My_Login_Security_Admin object
207
+ * @global object $theme_my_login_security_admin
208
+ * @since 6.0
209
+ */
210
+ $theme_my_login_security_admin = new Theme_My_Login_Security_Admin();
211
+
212
+ endif; // Class exists
213
+
214
+ ?>
modules/security/security.php ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Security
4
+ Description: Enabling this module will initialize security. You will then have to configure the settings via the "Security" tab.
5
+ */
6
+
7
+ if ( !class_exists( 'Theme_My_Login_Security' ) ) :
8
+ /**
9
+ * Theme My Login Custom User Links module class
10
+ *
11
+ * Adds options to help protect your site.
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Security extends Theme_My_Login_Module {
16
+ /**
17
+ * Blocks locked users from logging in
18
+ *
19
+ * Callback for "authenticate" hook in function wp_authenticate()
20
+ *
21
+ * @see wp_authenticate()
22
+ * @since 6.0
23
+ * @access public
24
+ *
25
+ * @param WP_User $user WP_User object
26
+ * @param string $username Username posted
27
+ * @param string $password Password posted
28
+ * @return WP_User|WP_Error WP_User if the user can login, WP_Error otherwise
29
+ */
30
+ function authenticate( $user, $username, $password ) {
31
+
32
+ if ( !$userdata = get_user_by( 'login', $username ) )
33
+ return;
34
+
35
+ // Current time
36
+ $time = time();
37
+
38
+ if ( $this->is_user_locked( $userdata->ID ) ) {
39
+ if ( $expiration = $this->get_user_lock_expiration( $userdata->ID ) ) {
40
+ if ( $time > $expiration )
41
+ $this->unlock_user( $userdata->ID );
42
+ else
43
+ return new WP_Error( 'locked_account', sprintf( __( '<strong>ERROR</strong>: This account has been locked because of too many failed login attempts. You may try again in %s.', $this->theme_my_login->textdomain ), human_time_diff( $time, $expiration ) ) );
44
+ } else {
45
+ return new WP_Error( 'locked_account', __( '<strong>ERROR</strong>: This account has been locked.', $this->theme_my_login->textdomain ) );
46
+ }
47
+ } elseif ( is_wp_error( $user ) && 'incorrect_password' == $user->get_error_code() ) {
48
+ // Get the options
49
+ $options = $this->theme_my_login->get_option( array( 'security', 'failed_login' ), array() );
50
+
51
+ // Get the attempts
52
+ $attempts = $this->get_failed_login_attempts( $userdata->ID );
53
+
54
+ // Get the first valid attempt
55
+ $first_attempt = reset( $attempts );
56
+
57
+ // Get the relative duration
58
+ $duration = $first_attempt['time'] + $this->get_seconds_from_unit( $options['threshold_duration'], $options['threshold_duration_unit'] );
59
+
60
+ // If current time is less than relative duration time, we're still within the defensive zone
61
+ if ( $time < $duration ) {
62
+ // Log this attempt
63
+ $this->add_failed_login_attempt( $userdata->ID, $time );
64
+ // If failed attempts reach treshold, lock the account
65
+ if ( $this->get_failed_login_attempt_count( $userdata->ID ) >= $options['threshold'] ) {
66
+ // Create new expiration
67
+ $expiration = $time + $this->get_seconds_from_unit( $options['lockout_duration'], $options['lockout_duration_unit'] );
68
+ $this->lock_user( $userdata->ID, $expiration );
69
+ return new WP_Error( 'locked_account', sprintf( __( '<strong>ERROR</strong>: This account has been locked because of too many failed login attempts. You may try again in %s.', $this->theme_my_login->textdomain ), human_time_diff( $time, $expiration ) ) );
70
+ }
71
+ } else {
72
+ // Clear the attempts
73
+ $this->reset_failed_login_attempts( $userdata->ID );
74
+ // Log this attempt
75
+ $this->add_failed_login_attempt( $userdata->ID, $time );
76
+ }
77
+ }
78
+ return $user;
79
+ }
80
+
81
+ /**
82
+ * Blocks locked users from resetting their password, if locked by admin
83
+ *
84
+ * Callback for "allow_password_reset" in method Theme_My_Login::retrieve_password()
85
+ *
86
+ * @see Theme_My_Login::retrieve_password()
87
+ * @since 6.0
88
+ * @access public
89
+ *
90
+ * @param bool $allow Default setting
91
+ * @param int $user_id User ID
92
+ * @return bool Whether to allow password reset or not
93
+ */
94
+ function allow_password_reset( $allow, $user_id ) {
95
+ if ( $this->is_user_locked( $user_id ) && !$this->get_user_lock_expiration( $user_id ) )
96
+ $allow = false;
97
+ return $allow;
98
+ }
99
+
100
+ /**
101
+ * Locks a user
102
+ *
103
+ * @since 6.0
104
+ * @access public
105
+ *
106
+ * @param int|WP_User $user User ID ir WP_User object
107
+ * @param int $expires When the lock expires, in seconds from current time
108
+ */
109
+ function lock_user( $user, $expires = 0 ) {
110
+ if ( is_object( $user ) )
111
+ $user = $user->ID;
112
+
113
+ $user = (int) $user;
114
+
115
+ do_action( 'tml_lock_user', $user );
116
+
117
+ $security = $this->get_security_meta( $user );
118
+
119
+ $security['is_locked'] = true;
120
+ if ( $expires )
121
+ $security['lock_expiration'] = absint( $expires );
122
+
123
+ return $this->update_user_meta( $user, 'theme_my_login_security', $security );
124
+ }
125
+
126
+ /**
127
+ * Unlocks a user
128
+ *
129
+ * @since 6.0
130
+ * @access public
131
+ *
132
+ * @param int|WP_User $user User ID or WP_User object
133
+ */
134
+ function unlock_user( $user ) {
135
+ if ( is_object( $user ) )
136
+ $user = $user->ID;
137
+
138
+ $user = (int) $user;
139
+
140
+ do_action( 'tml_unlock_user', $user );
141
+
142
+ $security = $this->get_security_meta( $user );
143
+
144
+ $security['is_locked'] = false;
145
+ if ( isset( $security['lock_expiration'] ) )
146
+ unset( $security['lock_expiration'] );
147
+ $security['failed_login_attempts'] = array();
148
+
149
+ return $this->update_user_meta( $user, 'theme_my_login_security', $security );
150
+ }
151
+
152
+ /**
153
+ * Determine if a user is locked or not
154
+ *
155
+ * @since 6.0
156
+ * @access public
157
+ *
158
+ * @param int|WP_User $user User ID or WP_User object
159
+ * @return bool True if user is locked, false if not
160
+ */
161
+ function is_user_locked( $user ) {
162
+ if ( is_object( $user ) )
163
+ $user = $user->ID;
164
+
165
+ $user = (int) $user;
166
+
167
+ $security = $this->get_security_meta( $user );
168
+
169
+ // If "is_locked" is not set, there is no lock
170
+ if ( !$security['is_locked'] )
171
+ return false;
172
+
173
+ // If "lock_expires" is not set, there is a lock but no expiry
174
+ if ( !$expires = $this->get_user_lock_expiration( $user ) )
175
+ return true;
176
+
177
+ // We have a lock with an expiry
178
+ $time = time();
179
+ if ( $time > $expires ) {
180
+ $this->unlock_user( $user );
181
+ return false;
182
+ }
183
+
184
+ return true;
185
+ }
186
+
187
+ /**
188
+ * Calls get_user_meta() or get_usermeta() depending on WP version
189
+ *
190
+ * @see get_user_meta(), get_usermeta()
191
+ * @since 6.0
192
+ * @access public
193
+ *
194
+ * @param int $user_id User ID
195
+ * @param string $key The meta key to retrieve
196
+ * @param bool $single Whether to return a single value
197
+ * @return mixed Array if $single is false, value of meta data field if $single is true
198
+ */
199
+ function get_user_meta( $user_id, $meta_key, $single = false ) {
200
+ if ( function_exists( 'get_user_meta' ) )
201
+ $value = get_user_meta( $user_id, $meta_key, $single );
202
+ else {
203
+ $value = get_usermeta( $user_id, $meta_key );
204
+ if ( empty( $value ) && !$single )
205
+ $value = array();
206
+ }
207
+ return $value;
208
+ }
209
+
210
+ /**
211
+ * Calls update_user_meta() or update_usermeta() depending on WP version
212
+ *
213
+ * @see update_user_meta(), update_usermeta()
214
+ * @since 6.0
215
+ * @access public
216
+ *
217
+ * @param int $user_id User ID
218
+ * @param string $key Metadata key
219
+ * @param mixed $value Metadata value
220
+ * @param mixed $prev_value Optional. Previous value to check before removing
221
+ * @return bool False on failure, true if success.
222
+ */
223
+ function update_user_meta( $user_id, $meta_key, $meta_value = '', $prev_value = '' ) {
224
+ if ( function_exists( 'update_user_meta' ) )
225
+ return update_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
226
+ else
227
+ return update_usermeta( $user_id, $meta_key, $meta_value );
228
+ }
229
+
230
+ /**
231
+ * Get a user's security meta
232
+ *
233
+ * @since 6.0
234
+ * @access public
235
+ *
236
+ * @param int $user_id User ID
237
+ * @return array User's security meta
238
+ */
239
+ function get_security_meta( $user_id ) {
240
+ $defaults = array(
241
+ 'is_locked' => false,
242
+ 'failed_login_attempts' => array()
243
+ );
244
+ $meta = $this->get_user_meta( $user_id, 'theme_my_login_security', true );
245
+ if ( !is_array( $meta ) )
246
+ $meta = array();
247
+
248
+ return array_merge( $defaults, $meta );
249
+ }
250
+
251
+ /**
252
+ * Get a user's failed login attempts
253
+ *
254
+ * @since 6.0
255
+ * @access public
256
+ *
257
+ * @param int $user_id User ID
258
+ * @return array User's failed login attempts
259
+ */
260
+ function get_failed_login_attempts( $user_id ) {
261
+ $security_meta = $this->get_security_meta( $user_id );
262
+ if ( !is_array( $security_meta['failed_login_attempts'] ) )
263
+ $security_meta['failed_login_attempts'] = array();
264
+ return $security_meta['failed_login_attempts'];
265
+ }
266
+
267
+ /**
268
+ * Reset a user's failed login attempts
269
+ *
270
+ * @since 6.0
271
+ * @access public
272
+ *
273
+ * @param int $user_id User ID
274
+ */
275
+ function reset_failed_login_attempts( $user_id ) {
276
+ $security_meta = $this->get_security_meta( $user_id );
277
+ $security_meta['failed_login_attempts'] = array();
278
+ return $this->update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
279
+ }
280
+
281
+ /**
282
+ * Get a user's failed login attempt count
283
+ *
284
+ * @since 6.0
285
+ * @access public
286
+ *
287
+ * @param int $user_id User ID
288
+ * @return int Number of user's failed login attempts
289
+ */
290
+ function get_failed_login_attempt_count( $user_id ) {
291
+ return count( $this->get_failed_login_attempts( $user_id ) );
292
+ }
293
+
294
+ /**
295
+ * Add a failed login attempt to a user
296
+ *
297
+ * @since 6.0
298
+ * @access public
299
+ *
300
+ * @param int $user_id User ID
301
+ * @param int $time Time of attempt, in seconds
302
+ * @param string $ip IP address of attempt
303
+ */
304
+ function add_failed_login_attempt( $user_id, $time = '', $ip = '' ) {
305
+ $security_meta = $this->get_security_meta( $user_id );
306
+ if ( !is_array( $security_meta['failed_login_attempts'] ) )
307
+ $security_meta['failed_login_attempts'] = array();
308
+
309
+ $time = absint( $time );
310
+
311
+ if ( empty( $time ) )
312
+ $time = time();
313
+
314
+ if ( empty( $ip ) )
315
+ $ip = $_SERVER['REMOTE_ADDR'];
316
+
317
+ $security_meta['failed_login_attempts'][] = array( 'time' => $time, 'ip' => $ip );
318
+
319
+ return $this->update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
320
+ }
321
+
322
+ /**
323
+ * Get user's lock expiration time
324
+ *
325
+ * @since 6.0
326
+ * @access public
327
+ *
328
+ * @param int $user_id User ID
329
+ * @return int User's lock expiration time
330
+ */
331
+ function get_user_lock_expiration( $user_id ) {
332
+ $expiration = false;
333
+ $security_meta = $this->get_security_meta( $user_id );
334
+ if ( isset( $security_meta['lock_expiration'] ) )
335
+ $expiration = absint( $security_meta['lock_expiration'] );
336
+ return apply_filters( 'tml_user_lock_expiration', $expiration, $user_id );
337
+ }
338
+
339
+ /**
340
+ * Get number of secongs from days, hours and minutes
341
+ *
342
+ * @since 6.0
343
+ * @access public
344
+ *
345
+ * @param int $value Number of $unit
346
+ * @param string $unit Can be either "day", "hour" or "minute"
347
+ * @return int Number of seconds
348
+ */
349
+ function get_seconds_from_unit( $value, $unit = 'minute' ) {
350
+ switch ( $unit ) {
351
+ case 'day' :
352
+ $value = $value * 24 * 60 * 60;
353
+ break;
354
+ case 'hour' :
355
+ $value = $value * 60 * 60;
356
+ break;
357
+ case 'minute' :
358
+ $value = $value * 60;
359
+ break;
360
+ }
361
+ return $value;
362
+ }
363
+
364
+ /**
365
+ * Activates this module
366
+ *
367
+ * Callback for "tml_activate_security/security.php" hook in method Theme_My_Login_Admin::activate_module()
368
+ *
369
+ * @see Theme_My_Login_Admin::activate_module()
370
+ * @since 6.0
371
+ * @access public
372
+ *
373
+ * @param object $theme_my_login Reference to global $theme_my_login object
374
+ */
375
+ function activate( &$theme_my_login ) {
376
+ $options = $this->init_options();
377
+ if ( !isset( $theme_my_login->options['security'] ) ) {
378
+ $theme_my_login->options['security'] = $options['security'];
379
+ } else {
380
+ $theme_my_login->options['security'] = $theme_my_login->array_merge_recursive( $options['security'], $theme_my_login->options['security'] );
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Initializes options for this module
386
+ *
387
+ * Callback for "tml_init_options" hook in method Theme_My_Login_Base::init_options()
388
+ *
389
+ * @see Theme_My_Login_Base::init_options()
390
+ * @since 6.0
391
+ * @access public
392
+ *
393
+ * @param array $options Options passed in from filter
394
+ * @return array Original $options array with module options appended
395
+ */
396
+ function init_options( $options = array() ) {
397
+ // Make sure it's an array
398
+ $options = (array) $options;
399
+ // Assign our options
400
+ $options['security'] = array(
401
+ 'failed_login' => array(
402
+ 'threshold' => 5,
403
+ 'threshold_duration' => 1,
404
+ 'threshold_duration_unit' => 'hour',
405
+ 'lockout_duration' => 24,
406
+ 'lockout_duration_unit' => 'hour'
407
+ )
408
+ );
409
+ return $options;
410
+ }
411
+
412
+ /**
413
+ * Loads the module
414
+ *
415
+ * @since 6.0
416
+ * @access public
417
+ */
418
+ function load() {
419
+ // Activate
420
+ add_action( 'tml_activate_security/security.php', array( &$this, 'activate' ) );
421
+ // Initialize
422
+ add_filter( 'tml_init_options', array( &$this, 'init_options' ) );
423
+
424
+ // Block locked users from logging in
425
+ add_action( 'authenticate', array( &$this, 'authenticate' ), 100, 3 );
426
+ // Block locked users from password reset
427
+ add_filter( 'allow_password_reset', array( &$this, 'allow_password_reset' ), 10, 2 );
428
+ }
429
+ }
430
+
431
+ /**
432
+ * Holds the reference to Theme_My_Login_Security object
433
+ * @global object $theme_my_login_security
434
+ * @since 6.0
435
+ */
436
+ $theme_my_login_security = new Theme_My_Login_Security();
437
+
438
+ if ( is_admin() )
439
+ include_once( TML_ABSPATH . '/modules/security/admin/security-admin.php' );
440
+
441
+ endif; // Class exists
442
+
443
+ ?>
modules/themed-profiles/includes/template-functions.php DELETED
@@ -1,196 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_themed_profiles_display() {
4
- global $current_user, $action, $redirect, $profile, $user_id, $wp_http_referer;
5
-
6
- $profileuser = get_user_to_edit($current_user->ID);
7
-
8
- $wp_error = wdbj_tml_get_var('errors');
9
- if ( empty($wp_error) )
10
- $wp_error = new WP_Error();
11
-
12
- if ( isset($_GET['updated']) && $_GET['updated'] )
13
- $wp_error->add('profile_updated', __('Profile updated.', 'theme-my-login'), 'message');
14
-
15
- ob_start();
16
- ?>
17
- <div class="login" id="profile">
18
- <?php
19
- if ( is_wp_error($wp_error) && $wp_error->get_error_code() ) {
20
- $errors = '';
21
- $messages = '';
22
- foreach ( $wp_error->get_error_codes() as $code ) {
23
- $severity = $wp_error->get_error_data($code);
24
- foreach ( $wp_error->get_error_messages($code) as $error ) {
25
- if ( 'message' == $severity )
26
- $messages .= ' ' . $error . "<br />\n";
27
- else
28
- $errors .= ' ' . $error . "<br />\n";
29
- }
30
- }
31
- if ( !empty($errors) )
32
- echo '<p class="error">' . apply_filters('login_errors', $errors) . "</p>\n";
33
- if ( !empty($messages) )
34
- echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
35
- }
36
- ?>
37
- <form id="your-profile" action="" method="post">
38
- <?php wp_nonce_field('update-user_' . $current_user->ID) ?>
39
- <?php if ( $wp_http_referer ) : ?>
40
- <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
41
- <?php endif; ?>
42
- <p>
43
- <input type="hidden" name="from" value="profile" />
44
- <input type="hidden" name="checkuser_id" value="<?php echo $current_user->ID; ?>" />
45
- </p>
46
-
47
- <?php if ( has_filter('personal_options') || has_filter('profile_personal_options') ) : ?>
48
- <h3><?php _e('Personal Options', 'theme-my-login'); ?></h3>
49
-
50
- <table class="form-table">
51
- <?php do_action('personal_options', $profileuser); ?>
52
- </table>
53
- <?php do_action('profile_personal_options', $profileuser); ?>
54
- <?php endif; ?>
55
-
56
- <h3><?php _e('Name', 'theme-my-login') ?></h3>
57
-
58
- <table class="form-table">
59
- <tr>
60
- <th><label for="user_login"><?php _e('Username', 'theme-my-login'); ?></label></th>
61
- <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Your username cannot be changed.', 'theme-my-login'); ?></span></td>
62
- </tr>
63
-
64
- <tr>
65
- <th><label for="first_name"><?php _e('First name', 'theme-my-login') ?></label></th>
66
- <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
67
- </tr>
68
-
69
- <tr>
70
- <th><label for="last_name"><?php _e('Last name', 'theme-my-login') ?></label></th>
71
- <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
72
- </tr>
73
-
74
- <tr>
75
- <th><label for="nickname"><?php _e('Nickname', 'theme-my-login'); ?> <span class="description"><?php _e('(required)', 'theme-my-login'); ?></span></label></th>
76
- <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
77
- </tr>
78
-
79
- <tr>
80
- <th><label for="display_name"><?php _e('Display name publicly as', 'theme-my-login') ?></label></th>
81
- <td>
82
- <select name="display_name" id="display_name">
83
- <?php
84
- $public_display = array();
85
- $public_display['display_nickname'] = $profileuser->nickname;
86
- $public_display['display_username'] = $profileuser->user_login;
87
- if ( !empty($profileuser->first_name) )
88
- $public_display['display_firstname'] = $profileuser->first_name;
89
- if ( !empty($profileuser->last_name) )
90
- $public_display['display_lastname'] = $profileuser->last_name;
91
- if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
92
- $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
93
- $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
94
- }
95
- if ( !in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
96
- $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
97
- $public_display = array_map( 'trim', $public_display );
98
- foreach ( $public_display as $id => $item ) {
99
- ?>
100
- <option id="<?php echo $id; ?>" value="<?php echo esc_attr($item); ?>"<?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
101
- <?php
102
- }
103
- ?>
104
- </select>
105
- </td>
106
- </tr>
107
- </table>
108
-
109
- <h3><?php _e('Contact Info', 'theme-my-login') ?></h3>
110
-
111
- <table class="form-table">
112
- <tr>
113
- <th><label for="email"><?php _e('E-mail', 'theme-my-login'); ?> <span class="description"><?php _e('(required)', 'theme-my-login'); ?></span></label></th>
114
- <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /></td>
115
- </tr>
116
-
117
- <tr>
118
- <th><label for="url"><?php _e('Website', 'theme-my-login') ?></label></th>
119
- <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
120
- </tr>
121
-
122
- <?php if ( function_exists('_wp_get_user_contactmethods') ) :
123
- foreach (_wp_get_user_contactmethods() as $name => $desc) {
124
- ?>
125
- <tr>
126
- <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
127
- <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
128
- </tr>
129
- <?php
130
- }
131
- endif;
132
- ?>
133
- </table>
134
-
135
- <h3><?php _e('About Yourself', 'theme-my-login'); ?></h3>
136
-
137
- <table class="form-table">
138
- <tr>
139
- <th><label for="description"><?php _e('Biographical Info', 'theme-my-login'); ?></label></th>
140
- <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html($profileuser->description); ?></textarea><br />
141
- <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.', 'theme-my-login'); ?></span></td>
142
- </tr>
143
-
144
- <?php
145
- $show_password_fields = apply_filters('show_password_fields', true, $profileuser);
146
- if ( $show_password_fields ) :
147
- ?>
148
- <tr id="password">
149
- <th><label for="pass1"><?php _e('New Password', 'theme-my-login'); ?></label></th>
150
- <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("If you would like to change the password type a new one. Otherwise leave this blank.", 'theme-my-login'); ?></span><br />
151
- <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again.", 'theme-my-login'); ?></span><br />
152
- <div id="pass-strength-result"><?php _e('Strength indicator', 'theme-my-login'); ?></div>
153
- <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).', 'theme-my-login'); ?></p>
154
- </td>
155
- </tr>
156
- <?php endif; ?>
157
- </table>
158
-
159
- <?php
160
- do_action('show_user_profile', $profileuser);
161
- ?>
162
-
163
- <?php if ( count($profileuser->caps) > count($profileuser->roles) && apply_filters('additional_capabilities_display', true, $profileuser) ) { ?>
164
- <br class="clear" />
165
- <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
166
- <tr>
167
- <th scope="row"><?php _e('Additional Capabilities', 'theme-my-login') ?></th>
168
- <td><?php
169
- $output = '';
170
- global $wp_roles;
171
- foreach ( $profileuser->caps as $cap => $value ) {
172
- if ( !$wp_roles->is_role($cap) ) {
173
- if ( $output != '' )
174
- $output .= ', ';
175
- $output .= $value ? $cap : "Denied: {$cap}";
176
- }
177
- }
178
- echo $output;
179
- ?></td>
180
- </tr>
181
- </table>
182
- <?php } ?>
183
-
184
- <p class="submit">
185
- <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($current_user->ID); ?>" />
186
- <input type="submit" class="button-primary" value="<?php esc_attr_e('Update Profile'); ?>" name="submit" />
187
- </p>
188
- </form>
189
- </div>
190
- <?php
191
- $contents = ob_get_contents();
192
- ob_end_clean();
193
- return $contents;
194
- }
195
-
196
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/themed-profiles/{themed-profiles.css → password-strength.css} RENAMED
@@ -1,7 +1,7 @@
1
  #pass-strength-result {
2
  border-style: solid;
3
  border-width: 1px;
4
- float: left;
5
  margin: 12px 5px 5px 1px;
6
  padding: 3px 5px;
7
  text-align: center;
1
  #pass-strength-result {
2
  border-style: solid;
3
  border-width: 1px;
4
+ float: left;
5
  margin: 12px 5px 5px 1px;
6
  padding: 3px 5px;
7
  text-align: center;
modules/themed-profiles/themed-profiles.php CHANGED
@@ -4,105 +4,220 @@ Plugin Name: Themed Profiles
4
  Description: Enabling this module will initialize and enable themed profiles. There are no other settings for this module.
5
  */
6
 
7
- add_action('tml_load', 'wdbj_tml_themed_profiles_load');
8
- function wdbj_tml_themed_profiles_load() {
9
- add_filter('site_url', 'wdbj_tml_themed_profiles_site_url', 10, 3);
10
- add_filter('admin_url', 'wdbj_tml_themed_profiles_site_url', 10, 2);
11
- }
12
-
13
- add_action('tml_init', 'wdbj_tml_themed_profiles_init');
14
- function wdbj_tml_themed_profiles_init() {
15
- if ( is_user_logged_in() && is_page(wdbj_tml_get_option('page_id')) && !( isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('update', 'profile', 'logout')) ) ) {
16
- $redirect_to = admin_url('profile.php');
17
- wp_redirect($redirect_to);
18
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
20
- }
21
 
22
- add_action('login_action_profile', 'wdbj_tml_themed_profiles_action');
23
- function wdbj_tml_themed_profiles_action() {
24
- global $current_user, $action, $redirect, $profile, $user_id, $wp_http_referer;
25
-
26
- require_once( TML_MODULE_DIR . '/themed-profiles/includes/template-functions.php' );
27
-
28
- require_once( ABSPATH . 'wp-admin/includes/misc.php' );
29
- require_once( ABSPATH . 'wp-admin/includes/template.php' );
30
- require_once( ABSPATH . 'wp-admin/includes/user.php' );
31
- require_once( ABSPATH . WPINC . '/registration.php' );
32
-
33
- // Needed to make admin scripts available
34
- define('WP_ADMIN', true);
35
- define('IS_PROFILE_PAGE', true);
36
-
37
- wp_enqueue_style('themed-profiles', plugins_url('theme-my-login/modules/themed-profiles/themed-profiles.css'));
38
-
39
- wp_enqueue_script('user-profile');
40
- wp_enqueue_script('password-strength-meter');
41
-
42
- wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
43
-
44
- $wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
45
-
46
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
47
- check_admin_referer('update-user_' . $current_user->ID);
48
-
49
- if ( !current_user_can('edit_user', $current_user->ID) )
50
- wp_die(__('You do not have permission to edit this user.', 'theme-my-login'));
51
-
52
- do_action('personal_options_update', $current_user->ID);
53
-
54
- $errors = edit_user($current_user->ID);
55
-
56
- if ( !is_wp_error( $errors ) ) {
57
- $redirect = add_query_arg(array('updated' => 'true', 'wp_http_referer' => urlencode($wp_http_referer)));
58
- wp_redirect($redirect);
59
- exit;
60
- } else wdbj_tml_set_error($errors);
61
  }
62
- }
63
 
64
- add_filter('the_content', 'wdbj_tml_themed_profiles_content');
65
- function wdbj_tml_themed_profiles_content($content) {
66
- $action = wdbj_tml_get_var('request_action');
67
- if ( is_page( wdbj_tml_get_option('page_id') ) && is_user_logged_in() && ( 'profile' == $action || 'update' == $action ) )
68
- return wdbj_tml_themed_profiles_display();
69
- return $content;
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
- add_action('init', 'wdbj_tml_themed_profiles_template_redirect');
73
- function wdbj_tml_themed_profiles_template_redirect() {
74
- global $pagenow;
75
- if ( 'profile.php' == $pagenow ) {
76
- $redirect_to = add_query_arg( 'action', 'profile', get_page_link(wdbj_tml_get_option('page_id')) );
77
- $redirect_to = add_query_arg( $_GET, $redirect_to );
78
- wp_redirect($redirect_to);
79
- exit;
 
 
 
80
  }
81
- }
82
 
83
- function wdbj_tml_themed_profiles_site_url($url, $path, $orig_scheme = '') {
84
- if ( is_user_logged_in() ) {
85
- if ( strpos($url, 'profile.php') !== false ) {
86
- $parsed_url = parse_url($url);
87
- $url = add_query_arg('action', 'profile', get_permalink(wdbj_tml_get_option('page_id')));
88
- if ( isset($parsed_url['query']) ) {
89
- wp_parse_str($parsed_url['query'], $r);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  foreach ( $r as $k => $v ) {
91
- if ( strpos($v, ' ') !== false )
92
- $r[$k] = rawurlencode($v);
93
  }
94
- $url = add_query_arg($r, $url);
95
  }
96
  }
 
97
  }
98
- return $url;
99
- }
100
 
101
- add_filter('tml_title', 'wdbj_tml_themed_profiles_title', 10, 2);
102
- function wdbj_tml_themed_profiles_title($title, $action) {
103
- if ( ( 'profile' == $action || 'update' == $action ) && is_user_logged_in() && '' == wdbj_tml_get_var('current_instance', 'instance_id') )
104
- $title = __('Your Profile', 'theme-my-login');
105
- return $title;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
 
 
 
 
 
 
 
 
 
 
108
  ?>
4
  Description: Enabling this module will initialize and enable themed profiles. There are no other settings for this module.
5
  */
6
 
7
+ if ( !class_exists( 'Theme_My_Login_Themed_Profiles' ) ) :
8
+ /**
9
+ * Theme My Login Themed Profiles module class
10
+ *
11
+ * Allows users to edit profile on the front-end.
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Themed_Profiles extends Theme_My_Login_Module {
16
+ /**
17
+ * Redirects "profile.php" to themed profile page
18
+ *
19
+ * Callback for "init" hook
20
+ *
21
+ * @since 6.0
22
+ * @access public
23
+ */
24
+ function init() {
25
+ global $pagenow;
26
+ if ( 'profile.php' == $pagenow && !isset( $_REQUEST['page'] ) ) {
27
+ $redirect_to = add_query_arg( 'action', 'profile', $this->theme_my_login->get_login_page_link() );
28
+ $redirect_to = add_query_arg( $_GET, $redirect_to );
29
+ wp_redirect( $redirect_to );
30
+ exit();
31
+ }
32
  }
 
33
 
34
+ /**
35
+ * Redirects login page to profile if user is logged in
36
+ *
37
+ * Callback for "template_redirect" hook
38
+ *
39
+ * @since 6.0
40
+ * @access public
41
+ */
42
+ function template_redirect() {
43
+ if ( $this->theme_my_login->is_login_page() && is_user_logged_in() && !( isset( $_REQUEST['action'] ) && in_array($_REQUEST['action'], array( 'profile', 'logout' ) ) ) ){
44
+ $redirect_to = add_query_arg( 'action', 'profile', $this->theme_my_login->get_login_page_link() );
45
+ wp_redirect( $redirect_to );
46
+ exit();
47
+ } elseif ( $this->theme_my_login->is_login_page() && ( isset( $_REQUEST['action'] ) && 'profile' == $_REQUEST['action'] ) && isset( $_REQUEST['instance'] ) ) {
48
+ $redirect_to = remove_query_arg( array( 'instance' ) );
49
+ wp_redirect( $redirect_to );
50
+ exit();
51
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
 
53
 
54
+ /**
55
+ * Handles profile action
56
+ *
57
+ * Callback for "tml_request_profile" in method Theme_My_Login::the_request()
58
+ *
59
+ * @see Theme_My_Login::the_request()
60
+ * @since 6.0
61
+ * @access public
62
+ */
63
+ function profile_action() {
64
+
65
+ require_once( ABSPATH . 'wp-admin/includes/user.php' );
66
+ require_once( ABSPATH . WPINC . '/registration.php' );
67
+
68
+ define( 'IS_PROFILE_PAGE', true );
69
+
70
+ wp_enqueue_style( 'password-strength', plugins_url( 'theme-my-login/modules/themed-profiles/password-strength.css' ) );
71
+
72
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
73
+
74
+ wp_enqueue_script( 'user-profile', admin_url( "js/user-profile$suffix.js" ), array( 'jquery' ), '', true );
75
+ wp_enqueue_script( 'password-strength-meter', admin_url( "js/password-strength-meter$suffix.js" ), array( 'jquery' ), '', true );
76
+ wp_localize_script( 'password-strength-meter', 'pwsL10n', array(
77
+ 'empty' => __( 'Strength indicator', $this->theme_my_login->textdomain ),
78
+ 'short' => __( 'Very weak', $this->theme_my_login->textdomain ),
79
+ 'bad' => __( 'Weak', $this->theme_my_login->textdomain ),
80
+ /* translators: password strength */
81
+ 'good' => _x( 'Medium', 'password strength', $this->theme_my_login->textdomain ),
82
+ 'strong' => __( 'Strong', $this->theme_my_login->textdomain ),
83
+ 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
84
+ ) );
85
+
86
+ $current_user = wp_get_current_user();
87
+
88
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
89
+ check_admin_referer( 'update-user_' . $current_user->ID );
90
+
91
+ if ( !current_user_can( 'edit_user', $current_user->ID ) )
92
+ wp_die( __( 'You do not have permission to edit this user.', $this->theme_my_login->textdomain ) );
93
+
94
+ do_action( 'personal_options_update', $current_user->ID );
95
+
96
+ $errors = edit_user( $current_user->ID );
97
 
98
+ if ( !is_wp_error( $errors ) ) {
99
+ $redirect = add_query_arg( array( 'updated' => 'true' ) );
100
+ wp_redirect( $redirect );
101
+ exit();
102
+ }
103
+
104
+ $this->theme_my_login->errors = $errors;
105
+ }
106
+
107
+ if ( isset( $_GET['updated'] ) && 'true' == $_GET['updated'] )
108
+ $this->theme_my_login->errors->add( 'profile_updated', __( 'Profile updated.', $this->theme_my_login->textdomain ), 'message' );
109
  }
 
110
 
111
+ /**
112
+ * Outputs profile form HTML
113
+ *
114
+ * Callback for "tml_template_profile" hook in method Theme_My_login_Template::display()
115
+ *
116
+ * @see Theme_My_Login_Template::display()
117
+ * @since 6.0
118
+ * @access public
119
+ *
120
+ * @param object $template Reference to $theme_my_login_template object
121
+ */
122
+ function get_profile_form( &$template ) {
123
+ $_template = array();
124
+ // Allow template override via shortcode or template tag args
125
+ if ( !empty( $template->options['profile_template'] ) )
126
+ $_template[] = $template->options['profile_template'];
127
+ // Default template
128
+ $_template[] = 'profile-form.php';
129
+ // Load template
130
+ $template->get_template( $_template );
131
+ }
132
+
133
+ /**
134
+ * Changes links from "profile.php" to themed profile page
135
+ *
136
+ * Callback for "site_url" hook
137
+ *
138
+ * @see site_url()
139
+ * @since 6.0
140
+ * @access public
141
+ *
142
+ * @param string $url The generated link
143
+ * @param string $path The specified path
144
+ * @param string $orig_scheme The original connection scheme
145
+ * @return string The filtered link
146
+ */
147
+ function site_url( $url, $path, $orig_scheme = '' ) {
148
+ if ( strpos( $url, 'profile.php' ) !== false ) {
149
+ $parsed_url = parse_url( $url );
150
+ $url = add_query_arg( 'action', 'profile', $this->theme_my_login->get_login_page_link( '', true ) );
151
+ if ( isset( $parsed_url['query'] ) ) {
152
+ wp_parse_str( $parsed_url['query'], $r );
153
  foreach ( $r as $k => $v ) {
154
+ if ( strpos( $v, ' ' ) !== false )
155
+ $r[$k] = rawurlencode( $v );
156
  }
157
+ $url = add_query_arg( $r, $url );
158
  }
159
  }
160
+ return $url;
161
  }
 
 
162
 
163
+ /**
164
+ * Changes the page title for themed profile page
165
+ *
166
+ * Callback for "tml_title" hook in method Theme_My_Login_Template::get_page_title()
167
+ *
168
+ * @see Theme_My_Login_Template::get_page_title()
169
+ * @since 6.0
170
+ * @access public
171
+ *
172
+ * @param string $title The current title
173
+ * @param string $action The requested action
174
+ * @return string The filtered title
175
+ */
176
+ function tml_title( $title, $action ) {
177
+ if ( 'profile' == $action && is_user_logged_in() && '' == $this->theme_my_login->request_instance )
178
+ $title = __( 'Your Profile', $this->theme_my_login->textdomain );
179
+ return $title;
180
+ }
181
+
182
+ /**
183
+ * Adds filters to site_url() and admin_url()
184
+ *
185
+ * Callback for "tml_modules_loaded" in file "theme-my-login.php"
186
+ *
187
+ * @since 6.0
188
+ * @access public
189
+ */
190
+ function modules_loaded() {
191
+ add_filter( 'site_url', array( &$this, 'site_url' ), 10, 3 );
192
+ add_filter( 'admin_url', array( &$this, 'site_url' ), 10, 2 );
193
+ }
194
+
195
+ /**
196
+ * Loads the module
197
+ *
198
+ * @since 6.0
199
+ * @access public
200
+ */
201
+ function load() {
202
+ // Load
203
+ add_action( 'tml_modules_loaded', array( &$this, 'modules_loaded' ) );
204
+ add_filter( 'tml_title', array( &$this, 'tml_title' ), 10, 2 );
205
+
206
+ add_action( 'init', array( &$this, 'init' ) );
207
+ add_action( 'template_redirect', array( &$this, 'template_redirect' ) );
208
+
209
+ add_action( 'tml_request_profile', array( &$this, 'profile_action' ) );
210
+ add_action( 'tml_display_profile', array( &$this, 'get_profile_form' ) );
211
+ }
212
  }
213
 
214
+ /**
215
+ * Holds the reference to Theme_My_Login_Themed_Profiles object
216
+ * @global object $theme_my_login_themed_profiles
217
+ * @since 6.0
218
+ */
219
+ $theme_my_login_themed_profiles = new Theme_My_Login_Themed_Profiles();
220
+
221
+ endif; // Class exists
222
+
223
  ?>
modules/user-moderation/admin/admin.php DELETED
@@ -1,94 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_user_mod_load_users_page() {
4
- if ( 'admin' == wdbj_tml_get_option('moderation', 'type') ) {
5
- add_action('delete_user', 'wdbj_tml_user_mod_deny_user');
6
- add_filter('user_row_actions', 'wdbj_tml_user_mod_user_row_actions', 10, 2);
7
- if ( isset($_GET['action']) && 'approve' == $_GET['action'] ) {
8
- check_admin_referer('approve-user');
9
-
10
- $user = isset($_GET['user']) ? $_GET['user'] : '';
11
- if ( !$user )
12
- wp_die(__('You can&#8217;t edit that user.', 'theme-my-login'));
13
-
14
- if ( !current_user_can('edit_user', $user) )
15
- wp_die(__('You can&#8217;t edit that user.', 'theme-my-login'));
16
-
17
- include_once( TML_MODULE_DIR. '/user-moderation/includes/functions.php' );
18
-
19
- $newpass = ( wdbj_tml_is_module_active('custom-passwords/custom-passwords.php') ) ? 0 : 1;
20
- if ( ! wdbj_tml_user_mod_approve_new_user($user, $newpass) )
21
- wp_die(__('You can&#8217;t edit that user.', 'theme-my-login'));
22
-
23
- add_action('admin_notices', create_function('', "echo '<div id=\"message\" class=\"updated fade\"><p>' . __('User approved.', 'theme-my-login') . '</p></div>';"));
24
- }
25
- }
26
- }
27
-
28
- function wdbj_tml_user_mod_user_row_actions($actions, $user_object) {
29
- $current_user = wp_get_current_user();
30
- $user_role = reset($user_object->roles);
31
- if ( $current_user->ID != $user_object->ID ) {
32
- if ( 'pending' == $user_role ) {
33
- $approve['approve-user'] = '<a href="' . add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url("users.php?action=approve&amp;user=$user_object->ID", 'approve-user') ) . '">Approve</a>';
34
- $actions = array_merge($approve, $actions);
35
- }
36
- }
37
- return $actions;
38
- }
39
-
40
- function wdbj_tml_user_mod_deny_user($user_id) {
41
- $user = new WP_User($user_id);
42
- $user_role = reset($user->roles);
43
- if ( 'pending' != $user_role )
44
- return;
45
-
46
- do_action('deny_user', $user->ID);
47
-
48
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
49
- // we want to reverse this for the plain text arena of emails.
50
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
51
-
52
- $message = sprintf(__('You have been denied access to %s', 'theme-my-login'), $blogname);
53
- $title = sprintf(__('[%s] Registration Denied', 'theme-my-login'), $blogname);
54
-
55
- $title = apply_filters('user_denial_title', $title);
56
- $message = apply_filters('user_denial_message', $message, $user_id);
57
-
58
- if ( $message && !wp_mail($user->user_email, $title, $message) )
59
- die('<p>' . __('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login') . '</p>');
60
- }
61
-
62
- function wdbj_tml_user_mod_admin_menu() {
63
- wdbj_tml_add_menu_page(__('Moderation', 'theme-my-login'), __FILE__, 'wdbj_tml_user_mod_admin_page');
64
- if ( wdbj_tml_is_module_active('custom-email/custom-email.php') ) {
65
- $parent = plugin_basename(TML_MODULE_DIR . '/custom-email/admin/options.php');
66
- wdbj_tml_add_submenu_page($parent, __('User Activation', 'theme-my-login'), TML_MODULE_DIR . '/user-moderation/admin/options-user-activation-email.php');
67
- wdbj_tml_add_submenu_page($parent, __('User Approval', 'theme-my-login'), TML_MODULE_DIR . '/user-moderation/admin/options-user-approval-email.php');
68
- wdbj_tml_add_submenu_page($parent, __('User Denial', 'theme-my-login'), TML_MODULE_DIR . '/user-moderation/admin/options-user-denial-email.php');
69
- }
70
- }
71
-
72
- function wdbj_tml_user_mod_admin_page() {
73
- $moderation = wdbj_tml_get_option('moderation', 'type');
74
- ?>
75
- <table class="form-table">
76
- <tr valign="top">
77
- <th scope="row"><?php _e('User Moderation', 'theme-my-login'); ?></th>
78
- <td>
79
- <input name="theme_my_login[moderation][type]" type="radio" id="theme_my_login_moderation_type_none" value="none" <?php if ( 'none' == $moderation ) { echo 'checked="checked"'; } ?> />
80
- <label for="theme_my_login_moderation_type_none"><?php _e('None', 'theme-my-login'); ?></label>
81
- <p class="description"><?php _e('Check this option to require no moderation.', 'theme-my-login'); ?></p>
82
- <input name="theme_my_login[moderation][type]" type="radio" id="theme_my_login_moderation_type_email" value="email" <?php if ( 'email' == $moderation ) { echo 'checked="checked"'; } ?> />
83
- <label for="theme_my_login_moderation_type_email"><?php _e('E-mail Confirmation', 'theme-my-login'); ?></label>
84
- <p class="description"><?php _e('Check this option to require new users to confirm their e-mail address before they may log in.', 'theme-my-login'); ?></p>
85
- <input name="theme_my_login[moderation][type]" type="radio" id="theme_my_login_moderation_type_admin" value="admin" <?php if ( 'admin' == $moderation ) { echo 'checked="checked"'; } ?> />
86
- <label for="theme_my_login_moderation_type_admin"><?php _e('Admin Approval', 'theme-my-login'); ?></label>
87
- <p class="description"><?php _e('Check this option to require new users to be approved by an administrator before they may log in.', 'theme-my-login'); ?></p>
88
- </td>
89
- </tr>
90
- </table>
91
- <?php
92
- }
93
-
94
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/admin/options-user-activation-email.php DELETED
@@ -1,16 +0,0 @@
1
- <table class="form-table">
2
- <tr>
3
- <td>
4
- <p class="description">
5
- <?php _e('This e-mail will be sent to a new user upon registration when "E-mail Confirmation" is checked for "User Moderation".', 'theme-my-login'); ?>
6
- <?php _e('Please be sure to include the variable %activateurl% or else the user will not be able to activate their account!', 'theme-my-login'); ?>
7
- <?php _e('If either field is left empty, the default will be used instead.', 'theme-my-login'); ?>
8
- </p>
9
- <p class="description"><?php _e('Available Variables', 'theme-my-login'); ?>: %blogname%, %siteurl%, %activateurl%, %user_login%, %user_email%, %user_pass%, %user_ip%</p>
10
- <label for="theme_my_login_user_activation_title"><?php _e('Subject', 'theme-my-login'); ?></label><br />
11
- <input name="theme_my_login[email][user_activation][title]" type="text" id="theme_my_login_user_activation_title" value="<?php if ( isset($theme_my_login->options['email']['user_activation']['title']) ) echo $theme_my_login->options['email']['user_activation']['title']; ?>" class="full-text" /><br />
12
- <label for="theme_my_login_user_activation_message"><?php _e('Message', 'theme-my-login'); ?></label><br />
13
- <textarea name="theme_my_login[email][user_activation][message]" id="theme_my_login_user_activation_message" class="large-text" rows="10"><?php if ( isset($theme_my_login->options['email']['user_activation']['message']) ) echo $theme_my_login->options['email']['user_activation']['message']; ?></textarea><br />
14
- </td>
15
- </tr>
16
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/admin/options-user-approval-email.php DELETED
@@ -1,16 +0,0 @@
1
- <table class="form-table">
2
- <tr>
3
- <td>
4
- <p class="description">
5
- <?php _e('This e-mail will be sent to a new user upon admin approval when "Admin Approval" is checked for "User Moderation".', 'theme-my-login'); ?>
6
- <?php _e('Please be sure to include the variable %user_pass% if using default passwords or else the user will not know their password!', 'theme-my-login'); ?>
7
- <?php _e('If either field is left empty, the default will be used instead.', 'theme-my-login'); ?>
8
- </p>
9
- <p class="description"><?php _e('Available Variables', 'theme-my-login'); ?>: %blogname%, %siteurl%, %activateurl%, %user_login%, %user_email%, %user_pass%</p>
10
- <label for="theme_my_login_user_approval_title"><?php _e('Subject', 'theme-my-login'); ?></label><br />
11
- <input name="theme_my_login[email][user_approval][title]" type="text" id="theme_my_login_user_approval_title" value="<?php if ( isset($theme_my_login->options['email']['user_approval']['title']) ) echo $theme_my_login->options['email']['user_approval']['title']; ?>" class="full-text" /><br />
12
- <label for="theme_my_login_user_approval_message"><?php _e('Message', 'theme-my-login'); ?></label><br />
13
- <textarea name="theme_my_login[email][user_approval][message]" id="theme_my_login_user_approval_message" class="large-text" rows="10"><?php if ( isset($theme_my_login->options['email']['user_approval']['message']) ) echo $theme_my_login->options['email']['user_approval']['message']; ?></textarea><br />
14
- </td>
15
- </tr>
16
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/admin/options-user-denial-email.php DELETED
@@ -1,15 +0,0 @@
1
- <table class="form-table">
2
- <tr>
3
- <td>
4
- <p class="description">
5
- <?php _e('This e-mail will be sent to a user who is deleted/denied when "Admin Approval" is checked for "User Moderation" and the user\'s role is "Pending".', 'theme-my-login'); ?>
6
- <?php _e('If either field is left empty, the default will be used instead.', 'theme-my-login'); ?>
7
- </p>
8
- <p class="description"><?php _e('Available Variables', 'theme-my-login'); ?>: %blogname%, %siteurl%, %user_login%, %user_email%</p>
9
- <label for="theme_my_login_user_denial_title"><?php _e('Subject', 'theme-my-login'); ?></label><br />
10
- <input name="theme_my_login[email][user_denial][title]" type="text" id="theme_my_login_user_denial_title" value="<?php if ( isset($theme_my_login->options['email']['user_denial']['title']) ) echo $theme_my_login->options['email']['user_denial']['title']; ?>" class="full-text" /><br />
11
- <label for="theme_my_login_user_denial_message"><?php _e('Message', 'theme-my-login'); ?></label><br />
12
- <textarea name="theme_my_login[email][user_denial][message]" id="theme_my_login_user_denial_message" class="large-text" rows="10"><?php if ( isset($theme_my_login->options['email']['user_denial']['message']) ) echo $theme_my_login->options['email']['user_denial']['message']; ?></textarea><br />
13
- </td>
14
- </tr>
15
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/admin/user-moderation-admin.php ADDED
@@ -0,0 +1,491 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists( 'Theme_My_Login_User_Moderation_Admin' ) ) :
4
+ /**
5
+ * Theme My Login User Moderation module admin class
6
+ *
7
+ * @since 6.0
8
+ */
9
+ class Theme_My_Login_User_Moderation_Admin extends Theme_My_Login_Module {
10
+ /**
11
+ * Attaches actions/filters explicitly to users.php
12
+ *
13
+ * Callback for "load-users.php" hook
14
+ *
15
+ * @since 6.0
16
+ * @access public
17
+ */
18
+ function load_users_page() {
19
+ // Shorthand reference
20
+ $theme_my_login =& $this->theme_my_login;
21
+ $user_moderation =& $GLOBALS['theme_my_login_user_moderation'];
22
+
23
+ add_filter( 'user_row_actions', array( &$this, 'user_row_actions' ), 10, 2 );
24
+ add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
25
+ add_action( 'delete_user', array( &$this, 'deny_user' ) );
26
+
27
+ // Is there an action?
28
+ if ( isset( $_GET['action'] ) ) {
29
+
30
+ // Is it a sanctioned action?
31
+ if ( in_array( $_GET['action'], array( 'approve', 'resendactivation' ) ) ) {
32
+
33
+ // Is there a user ID?
34
+ $user = isset( $_GET['user'] ) ? $_GET['user'] : '';
35
+
36
+ // No user ID?
37
+ if ( !$user || !current_user_can( 'edit_user', $user ) )
38
+ wp_die( __( 'You can&#8217;t edit that user.', $theme_my_login->textdomain ) );
39
+
40
+ // Where did we come from?
41
+ $redirect_to = isset( $_REQUEST['wp_http_referer'] ) ? remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), stripslashes( $_REQUEST['wp_http_referer'] ) ) : 'users.php';
42
+
43
+ // Are we approving?
44
+ if ( 'approve' == $_GET['action'] ) {
45
+ check_admin_referer( 'approve-user' );
46
+
47
+ $newpass = $theme_my_login->is_module_active( 'custom-passwords/custom-passwords.php' ) ? 0 : 1;
48
+
49
+ if ( !$this->approve_user( $user, $newpass ) )
50
+ wp_die( __( 'You can&#8217;t edit that user.', $theme_my_login->textdomain ) );
51
+
52
+ $redirect_to = add_query_arg( 'update', 'approve', $redirect_to );
53
+ }
54
+ // Are we resending an activation e-mail?
55
+ elseif ( 'resendactivation' == $_GET['action'] ) {
56
+ check_admin_referer( 'resend-activation' );
57
+
58
+ // Apply activation e-mail filters
59
+ $user_moderation->apply_user_activation_notification_filters();
60
+ if ( !$user_moderation->new_user_activation_notification( $user ) )
61
+ wp_die( __( 'The e-mail could not be sent.', $theme_my_login->textdomain ) . "<br />\n" . __( 'Possible reason: your host may have disabled the mail() function...', $theme_my_login->textdomain ) );
62
+
63
+ $redirect_to = add_query_arg( 'update', 'sendactivation', $redirect_to );
64
+ }
65
+ wp_redirect( $redirect_to );
66
+ exit;
67
+ }
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Adds update messages to the admin screen
73
+ *
74
+ * Callback for "admin_notices" hook in file admin-header.php
75
+ *
76
+ * @since 6.0
77
+ * @access public
78
+ */
79
+ function admin_notices() {
80
+ if ( isset( $_GET['update'] ) && in_array( $_GET['update'], array( 'approve', 'sendactivation' ) ) ) {
81
+ echo '<div id="message" class="updated fade"><p>';
82
+ if ( 'approve' == $_GET['update'] )
83
+ _e( 'User approved.', $this->theme_my_login->textdomain );
84
+ elseif ( 'sendactivation' == $_GET['update'] )
85
+ _e( 'Activation sent.', $this->theme_my_login->textdomain );
86
+ echo '</p></div>';
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Adds "Approve" link for each pending user on users.php
92
+ *
93
+ * Callback for "user_row_actions" hook in {@internal unknown}
94
+ *
95
+ * @since 6.0
96
+ * @access public
97
+ *
98
+ * @param array $actions The user actions
99
+ * @param WP_User $user_object The current user object
100
+ * @return array The filtered user actions
101
+ */
102
+ function user_row_actions( $actions, $user_object ) {
103
+ $current_user = wp_get_current_user();
104
+ if ( $current_user->ID != $user_object->ID ) {
105
+ if ( 'pending' == $user_object->roles[0] ) {
106
+ $_actions = array();
107
+ // If moderation type is e-mail activation, add "Resend Activation" link
108
+ if ( 'email' == $this->theme_my_login->options['moderation']['type'] ) {
109
+ $_actions['resend-activation'] = '<a href="' . add_query_arg( 'wp_http_referer',
110
+ urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),
111
+ wp_nonce_url( "users.php?action=resendactivation&amp;user=$user_object->ID", 'resend-activation' ) ) . '">' . __( 'Resend Activation', $this->theme_my_login->textdomain ) . '</a>';
112
+ } elseif ( 'admin' == $this->theme_my_login->options['moderation']['type'] ) {
113
+ // Add "Approve" link
114
+ $_actions['approve-user'] = '<a href="' . add_query_arg( 'wp_http_referer',
115
+ urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),
116
+ wp_nonce_url( "users.php?action=approve&amp;user=$user_object->ID", 'approve-user' ) ) . '">' . __( 'Approve', $this->theme_my_login->textdomain ) . '</a>';
117
+ }
118
+ $actions = array_merge( $_actions, $actions );
119
+ }
120
+ }
121
+ return $actions;
122
+ }
123
+
124
+ /**
125
+ * Handles activating a new user by admin approval
126
+ *
127
+ * @param string $user_id User's ID
128
+ * @param bool $newpass Whether or not to assign a new password
129
+ * @return bool Returns false if not a valid user
130
+ */
131
+ function approve_user( $user_id, $newpass = false ) {
132
+ global $wpdb;
133
+
134
+ $user_id = (int) $user_id;
135
+
136
+ // Get user by ID
137
+ $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $user_id ) );
138
+ if ( empty( $user ) )
139
+ return false;
140
+
141
+ do_action( 'approve_user', $user->ID );
142
+
143
+ // Clear the activation key if there is one
144
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'ID' => $user->ID ) );
145
+
146
+ $user_object = new WP_User( $user->ID );
147
+ $user_object->set_role( get_option( 'default_role' ) );
148
+ unset( $user_object );
149
+
150
+ $user_pass = __( 'Same as when you signed up.', $this->theme_my_login->textdomain );
151
+ if ( $newpass ) {
152
+ $user_pass = wp_generate_password();
153
+ wp_set_password( $user_pass, $user->ID );
154
+ }
155
+
156
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
157
+ $blogname = $GLOBALS['current_site']->site_name;
158
+ } else {
159
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
160
+ // we want to reverse this for the plain text arena of emails.
161
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
162
+ }
163
+
164
+ $message = sprintf( __( 'You have been approved access to %s', $this->theme_my_login->textdomain ), $blogname ) . "\r\n\r\n";
165
+ $message .= sprintf( __( 'Username: %s', $this->theme_my_login->textdomain ), $user->user_login ) . "\r\n";
166
+ $message .= sprintf( __( 'Password: %s', $this->theme_my_login->textdomain ), $user_pass ) . "\r\n\r\n";
167
+ $message .= site_url( 'wp-login.php', 'login' ) . "\r\n";
168
+
169
+ $title = sprintf( __( '[%s] Registration Approved', $this->theme_my_login->textdomain ), $blogname );
170
+
171
+ $title = apply_filters( 'user_approval_notification_title', $title, $user->ID );
172
+ $message = apply_filters( 'user_approval_notification_message', $message, $user_pass, $user->ID );
173
+
174
+ if ( $message && !wp_mail( $user->user_email, $title, $message ) )
175
+ die( '<p>' . __( 'The e-mail could not be sent.', $this->theme_my_login->textdomain ) . "<br />\n" . __( 'Possible reason: your host may have disabled the mail() function...', $this->theme_my_login->textdomain ) . '</p>' );
176
+
177
+ return true;
178
+ }
179
+
180
+ /**
181
+ * Called upon deletion of a user in the "Pending" role
182
+ *
183
+ * @param string $user_id User's ID
184
+ */
185
+ function deny_user( $user_id ) {
186
+
187
+ $user_id = (int) $user_id;
188
+
189
+ $user = new WP_User( $user_id );
190
+ if ( 'pending' != $user->roles[0] )
191
+ return;
192
+
193
+ do_action( 'deny_user', $user->ID );
194
+
195
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
196
+ $blogname = $GLOBALS['current_site']->site_name;
197
+ } else {
198
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
199
+ // we want to reverse this for the plain text arena of emails.
200
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
201
+ }
202
+
203
+ $message = sprintf( __( 'You have been denied access to %s', $this->theme_my_login->textdomain ), $blogname );
204
+ $title = sprintf( __( '[%s] Registration Denied', $this->theme_my_login->textdomain ), $blogname );
205
+
206
+ $title = apply_filters( 'user_denial_notification_title', $title, $user_id );
207
+ $message = apply_filters( 'user_denial_notification_message', $message, $user_id );
208
+
209
+ if ( $message && !wp_mail( $user->user_email, $title, $message ) )
210
+ die( '<p>' . __( 'The e-mail could not be sent.', $this->theme_my_login->textdomain ) . "<br />\n" . __( 'Possible reason: your host may have disabled the mail() function...', $this->theme_my_login->textdomain ) . '</p>' );
211
+ }
212
+
213
+ /**
214
+ * Adds "Moderation" tab to Theme My Login menu
215
+ *
216
+ * Callback for "tml_admin_menu" hook in method Theme_My_Login_Admin::display_settings_page()
217
+ *
218
+ * @see Theme_My_Login_Admin::display_settings_page(), Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
219
+ * @uses Theme_My_Login_Admin::add_menu_page, Theme_My_Login_Admin::add_submenu_page()
220
+ * @since 6.0
221
+ * @access public
222
+ *
223
+ * @param object $admin Reference to global $theme_my_login_admin object
224
+ */
225
+ function admin_menu( &$admin ) {
226
+ $admin->add_menu_page( __( 'Moderation', $this->theme_my_login->textdomain ), 'tml-options-moderation', array( &$this, 'display_settings' ) );
227
+ if ( $this->theme_my_login->is_module_active( 'custom-email/custom-email.php' ) ) {
228
+ $admin->add_submenu_page( 'tml-options-email', __( 'User Activation', $this->theme_my_login->textdomain ), 'tml-options-email-user-activation', array( &$this, 'display_user_activation_email_settings' ) );
229
+ $admin->add_submenu_page( 'tml-options-email', __( 'User Approval', $this->theme_my_login->textdomain ), 'tml-options-email-user-approval', array( &$this, 'display_user_approval_email_settings' ) );
230
+ $admin->add_submenu_page( 'tml-options-email', __( 'User Denial', $this->theme_my_login->textdomain ), 'tml-options-email-user-denial', array( &$this, 'display_user_denial_email_settings' ) );
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Outputs user moderation settings
236
+ *
237
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
238
+ *
239
+ * @see Theme_My_Login_Admin::add_submenu_page()
240
+ * @since 6.0
241
+ * @access public
242
+ */
243
+ function display_settings() {
244
+ // Shorthand reference
245
+ $theme_my_login =& $this->theme_my_login;
246
+ ?>
247
+ <table class="form-table">
248
+ <tr valign="top">
249
+ <th scope="row"><?php _e( 'User Moderation', $this->theme_my_login->textdomain ); ?></th>
250
+ <td>
251
+ <input name="theme_my_login[moderation][type]" type="radio" id="theme_my_login_moderation_type_none" value="none" <?php if ( 'none' == $theme_my_login->options['moderation']['type'] ) echo 'checked="checked"'; ?> />
252
+ <label for="theme_my_login_moderation_type_none"><?php _e( 'None', $theme_my_login->textdomain ); ?></label>
253
+ <p class="description"><?php _e( 'Check this option to require no moderation.', $theme_my_login->textdomain ); ?></p>
254
+ <input name="theme_my_login[moderation][type]" type="radio" id="theme_my_login_moderation_type_email" value="email" <?php if ( 'email' == $theme_my_login->options['moderation']['type'] ) echo 'checked="checked"'; ?> />
255
+ <label for="theme_my_login_moderation_type_email"><?php _e( 'E-mail Confirmation', $theme_my_login->textdomain ); ?></label>
256
+ <p class="description"><?php _e( 'Check this option to require new users to confirm their e-mail address before they may log in.', $this->theme_my_login->textdomain ); ?></p>
257
+ <input name="theme_my_login[moderation][type]" type="radio" id="theme_my_login_moderation_type_admin" value="admin" <?php if ( 'admin' == $theme_my_login->options['moderation']['type'] ) echo 'checked="checked"'; ?> />
258
+ <label for="theme_my_login_moderation_type_admin"><?php _e( 'Admin Approval', $theme_my_login->textdomain ); ?></label>
259
+ <p class="description"><?php _e( 'Check this option to require new users to be approved by an administrator before they may log in.', $this->theme_my_login->textdomain ); ?></p>
260
+ </td>
261
+ </tr>
262
+ </table>
263
+ <?php
264
+ }
265
+
266
+ /**
267
+ * Outputs user activation e-mail settings
268
+ *
269
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
270
+ *
271
+ * @see Theme_My_Login_Admin::add_submenu_page()
272
+ * @since 6.0
273
+ * @access public
274
+ */
275
+ function display_user_activation_email_settings() {
276
+ // Shorthand reference to $theme_my_login object
277
+ $theme_my_login =& $this->theme_my_login;
278
+ // User activation email options
279
+ $user_activation = $theme_my_login->get_option( array( 'email', 'user_activation' ), array() );
280
+ ?>
281
+ <table class="form-table">
282
+ <tr>
283
+ <td>
284
+ <p class="description">
285
+ <?php _e( 'This e-mail will be sent to a new user upon registration when "E-mail Confirmation" is checked for "User Moderation".', $theme_my_login->textdomain ); ?>
286
+ <?php _e( 'Please be sure to include the variable %activateurl% or else the user will not be able to activate their account!', $theme_my_login->textdomain ); ?>
287
+ <?php _e( 'If any field is left empty, the default will be used instead.', $theme_my_login->textdomain ); ?>
288
+ </p>
289
+
290
+ <p><label for="theme_my_login_user_activation_mail_from_name"><?php _e( 'From Name', $theme_my_login->textdomain ); ?></label><br />
291
+ <input name="theme_my_login[email][user_activation][mail_from_name]" type="text" id="theme_my_login_user_activation_mail_from_name" value="<?php if ( isset( $user_activation['mail_from_name'] ) ) echo $user_activation['mail_from_name']; ?>" class="extended-text" /></p>
292
+
293
+ <p><label for="theme_my_login_user_activation_mail_from"><?php _e( 'From E-mail', $theme_my_login->textdomain ); ?></label><br />
294
+ <input name="theme_my_login[email][user_activation][mail_from]" type="text" id="theme_my_login_user_activation_mail_from" value="<?php if ( isset( $user_activation['mail_from'] ) ) echo $user_activation['mail_from']; ?>" class="extended-text" /></p>
295
+
296
+ <p><label for="theme_my_login_user_activation_mail_content_type"><?php _e( 'E-mail Format', $theme_my_login->textdomain ); ?></label><br />
297
+ <select name="theme_my_login[email][user_activation][mail_content_type]" id="theme_my_login_user_activation_mail_content_type">
298
+ <option value="plain"<?php if ( isset( $user_activation['mail_content_type'] ) && 'plain' == $user_activation['mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
299
+ <option value="html"<?php if ( isset( $user_activation['mail_content_type'] ) && 'html' == $user_activation['mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
300
+ </select></p>
301
+
302
+ <p><label for="theme_my_login_user_activation_title"><?php _e( 'Subject', $theme_my_login->textdomain ); ?></label><br />
303
+ <input name="theme_my_login[email][user_activation][title]" type="text" id="theme_my_login_user_activation_title" value="<?php if ( isset( $user_activation['title'] ) ) echo $user_activation['title']; ?>" class="full-text" /></p>
304
+
305
+ <p><label for="theme_my_login_user_activation_message"><?php _e( 'Message', $theme_my_login->textdomain ); ?></label><br />
306
+ <textarea name="theme_my_login[email][user_activation][message]" id="theme_my_login_user_activation_message" class="large-text" rows="10"><?php if ( isset( $user_activation['message'] ) ) echo $user_activation['message']; ?></textarea></p>
307
+
308
+ <p class="description"><?php _e( 'Available Variables', $theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %activateurl%, %user_login%, %user_email%, %user_ip%</p>
309
+ </td>
310
+ </tr>
311
+ </table>
312
+ <?php
313
+ }
314
+
315
+ /**
316
+ * Outputs user approval e-mail settings
317
+ *
318
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
319
+ *
320
+ * @see Theme_My_Login_Admin::add_submenu_page()
321
+ * @since 6.0
322
+ * @access public
323
+ */
324
+ function display_user_approval_email_settings() {
325
+ // Shorthand reference to $theme_my_login object
326
+ $theme_my_login =& $this->theme_my_login;
327
+ // User approval email options
328
+ $user_approval = $theme_my_login->get_option( array( 'email', 'user_approval' ), array() );
329
+ ?>
330
+ <table class="form-table">
331
+ <tr>
332
+ <td>
333
+ <h3><?php _e( 'User Notification', $theme_my_login->textdomain ); ?></h3>
334
+
335
+ <p class="description">
336
+ <?php _e( 'This e-mail will be sent to a new user upon admin approval when "Admin Approval" is checked for "User Moderation".', $theme_my_login->textdomain ); ?>
337
+ <?php _e( 'Please be sure to include the variable %user_pass% if using default passwords or else the user will not know their password!', $theme_my_login->textdomain ); ?>
338
+ <?php _e( 'If any field is left empty, the default will be used instead.', $theme_my_login->textdomain ); ?>
339
+ </p>
340
+
341
+ <p><label for="theme_my_login_user_approval_mail_from_name"><?php _e( 'From Name', $theme_my_login->textdomain ); ?></label><br />
342
+ <input name="theme_my_login[email][user_approval][mail_from_name]" type="text" id="theme_my_login_user_approval_mail_from_name" value="<?php if ( isset( $user_approval['mail_from_name'] ) ) echo $user_approval['mail_from_name']; ?>" class="extended-text" /></p>
343
+
344
+ <p><label for="theme_my_login_user_approval_mail_from"><?php _e( 'From E-mail', $theme_my_login->textdomain ); ?></label><br />
345
+ <input name="theme_my_login[email][user_approval][mail_from]" type="text" id="theme_my_login_user_approval_mail_from" value="<?php if ( isset( $user_approval['mail_from'] ) ) echo $user_approval['mail_from']; ?>" class="extended-text" /></p>
346
+
347
+ <p><label for="theme_my_login_user_approval_mail_content_type"><?php _e( 'E-mail Format', $theme_my_login->textdomain ); ?></label><br />
348
+ <select name="theme_my_login[email][user_approval][mail_content_type]" id="theme_my_login_user_approval_mail_content_type">
349
+ <option value="plain"<?php if ( isset( $user_approval['mail_content_type'] ) && 'plain' == $user_approval['mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
350
+ <option value="html"<?php if ( isset( $user_approval['mail_content_type'] ) && 'html' == $user_approval['mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
351
+ </select></p>
352
+
353
+ <p><label for="theme_my_login_user_approval_title"><?php _e( 'Subject', $theme_my_login->textdomain ); ?></label><br />
354
+ <input name="theme_my_login[email][user_approval][title]" type="text" id="theme_my_login_user_approval_title" value="<?php if ( isset( $user_approval['title'] ) ) echo $user_approval['title']; ?>" class="full-text" /></p>
355
+
356
+ <p><label for="theme_my_login_user_approval_message"><?php _e( 'Message', $theme_my_login->textdomain ); ?></label><br />
357
+ <textarea name="theme_my_login[email][user_approval][message]" id="theme_my_login_user_approval_message" class="large-text" rows="10"><?php if ( isset( $user_approval['message'] ) ) echo $user_approval['message']; ?></textarea></p>
358
+
359
+ <p class="description"><?php _e( 'Available Variables', $theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %loginurl%, %user_login%, %user_email%, %user_pass%</p>
360
+ </td>
361
+ </tr>
362
+ <tr>
363
+ <td>
364
+ <h3><?php _e( 'Admin Notification', $theme_my_login->textdomain ); ?></h3>
365
+
366
+ <p class="description">
367
+ <?php _e( 'This e-mail will be sent to the e-mail address or addresses (multiple addresses may be separated by commas) specified below upon user registration when "Admin Approval" is checked for "User Moderation".', $theme_my_login->textdomain ); ?>
368
+ <?php _e( 'If any field is left empty, the default will be used instead.', $theme_my_login->textdomain ); ?>
369
+ </p>
370
+
371
+ <p><label for="theme_my_login_user_approval_admin_mail_to"><?php _e( 'To', $this->theme_my_login->textdomain ); ?></label><br />
372
+ <input name="theme_my_login[email][user_approval][admin_mail_to]" type="text" id="theme_my_login_user_approval_admin_mail_to" value="<?php if ( isset( $user_approval['admin_mail_to'] ) ) echo $user_approval['admin_mail_to']; ?>" class="extended-text" /></p>
373
+
374
+ <p><label for="theme_my_login_user_approval_admin_mail_from_name"><?php _e( 'From Name', $this->theme_my_login->textdomain ); ?></label><br />
375
+ <input name="theme_my_login[email][user_approval][admin_mail_from_name]" type="text" id="theme_my_login_user_approval_admin_mail_from_name" value="<?php if ( isset( $user_approval['admin_mail_from_name'] ) ) echo $user_approval['admin_mail_from_name']; ?>" class="extended-text" /></p>
376
+
377
+ <p><label for="theme_my_login_user_approval_admin_mail_from"><?php _e( 'From E-mail', $this->theme_my_login->textdomain ); ?></label><br />
378
+ <input name="theme_my_login[email][user_approval][admin_mail_from]" type="text" id="theme_my_login_user_approval_admin_mail_from" value="<?php if ( isset( $user_approval['admin_mail_from'] ) ) echo $user_approval['admin_mail_from']; ?>" class="extended-text" /></p>
379
+
380
+ <p><label for="theme_my_login_user_approval_admin_mail_content_type"><?php _e( 'E-mail Format', $this->theme_my_login->textdomain ); ?></label><br />
381
+ <select name="theme_my_login[email][user_approval][admin_mail_content_type]" id="theme_my_login_user_approval_admin_mail_content_type">
382
+ <option value="plain"<?php if ( isset( $user_approval['admin_mail_content_type'] ) && 'plain' == $user_approval['admin_mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
383
+ <option value="html"<?php if ( isset( $user_approval['admin_mail_content_type'] ) && 'html' == $user_approval['admin_mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
384
+ </select></p>
385
+
386
+ <p><label for="theme_my_login_user_approval_admin_title"><?php _e( 'Subject', $this->theme_my_login->textdomain ); ?></label><br />
387
+ <input name="theme_my_login[email][user_approval][admin_title]" type="text" id="theme_my_login_user_approval_admin_title" value="<?php if ( isset( $user_approval['admin_title'] ) ) echo $user_approval['admin_title']; ?>" class="full-text" /></p>
388
+
389
+ <p><label for="theme_my_login_user_approval_admin_message"><?php _e( 'Message', $this->theme_my_login->textdomain ); ?></label><br />
390
+ <textarea name="theme_my_login[email][user_approval][admin_message]" id="theme_my_login_user_approval_admin_message" class="large-text" rows="10"><?php if ( isset( $user_approval['admin_message'] ) ) echo $user_approval['admin_message']; ?></textarea></p>
391
+
392
+ <p class="description"><?php _e( 'Available Variables', $this->theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %pendingurl%, %user_login%, %user_email%, %user_ip%</p>
393
+
394
+ <p><label for="theme_my_login_user_approval_admin_disable"><input name="theme_my_login[email][user_approval][admin_disable]" type="checkbox" id="theme_my_login_user_approval_admin_disable" value="1"<?php checked( 1, isset( $user_approval['admin_disable'] ) && $user_approval['admin_disable'] ); ?> /> <?php _e( 'Disable Admin Notification', $this->theme_my_login->textdomain ); ?></label></p>
395
+ </td>
396
+ </tr>
397
+ </table>
398
+ <?php
399
+ }
400
+
401
+ /**
402
+ * Outputs user denial e-mail settings
403
+ *
404
+ * Callback for "$hookname" hook in method Theme_My_Login_Admin::add_submenu_page()
405
+ *
406
+ * @see Theme_My_Login_Admin::add_submenu_page()
407
+ * @since 6.0
408
+ * @access public
409
+ */
410
+ function display_user_denial_email_settings() {
411
+ // Shorthand reference to $theme_my_login object
412
+ $theme_my_login =& $this->theme_my_login;
413
+ // User denial email options
414
+ $user_denial = $theme_my_login->get_option( array( 'email', 'user_denial' ), array() );
415
+ ?>
416
+ <table class="form-table">
417
+ <tr>
418
+ <td>
419
+ <p class="description">
420
+ <?php _e( 'This e-mail will be sent to a user who is deleted/denied when "Admin Approval" is checked for "User Moderation" and the user\'s role is "Pending".', $theme_my_login->textdomain ); ?>
421
+ <?php _e( 'If any field is left empty, the default will be used instead.', $theme_my_login->textdomain ); ?>
422
+ </p>
423
+
424
+ <p><label for="theme_my_login_user_denial_mail_from_name"><?php _e( 'From Name', $theme_my_login->textdomain ); ?></label><br />
425
+ <input name="theme_my_login[email][user_denial][mail_from_name]" type="text" id="theme_my_login_user_denial_mail_from_name" value="<?php if ( isset( $user_denial['mail_from_name'] ) ) echo $user_denial['mail_from_name']; ?>" class="extended-text" /></p>
426
+
427
+ <p><label for="theme_my_login_user_denial_mail_from"><?php _e( 'From E-mail', $theme_my_login->textdomain ); ?></label><br />
428
+ <input name="theme_my_login[email][user_denial][mail_from]" type="text" id="theme_my_login_user_denial_mail_from" value="<?php if ( isset( $user_denial['mail_from'] ) ) echo $user_denial['mail_from']; ?>" class="extended-text" /></p>
429
+
430
+ <p><label for="theme_my_login_user_denial_mail_content_type"><?php _e( 'E-mail Format', $theme_my_login->textdomain ); ?></label><br />
431
+ <select name="theme_my_login[email][user_denial][mail_content_type]" id="theme_my_login_user_denial_mail_content_type">
432
+ <option value="plain"<?php if ( isset( $user_denial['mail_content_type'] ) && 'plain' == $user_denial['mail_content_type'] ) echo ' selected="selected"'; ?>>Plain Text</option>
433
+ <option value="html"<?php if ( isset( $user_denial['mail_content_type'] ) && 'html' == $user_denial['mail_content_type'] ) echo ' selected="selected"'; ?>>HTML</option>
434
+ </select></p>
435
+
436
+ <p><label for="theme_my_login_user_denial_title"><?php _e('Subject', $theme_my_login->textdomain); ?></label><br />
437
+ <input name="theme_my_login[email][user_denial][title]" type="text" id="theme_my_login_user_denial_title" value="<?php if ( isset( $user_denial['title'] ) ) echo $user_denial['title']; ?>" class="full-text" /></p>
438
+
439
+ <p><label for="theme_my_login_user_denial_message"><?php _e('Message', $theme_my_login->textdomain); ?></label><br />
440
+ <textarea name="theme_my_login[email][user_denial][message]" id="theme_my_login_user_denial_message" class="large-text" rows="10"><?php if ( isset( $user_denial['message'] ) ) echo $user_denial['message']; ?></textarea></p>
441
+
442
+ <p class="description"><?php _e( 'Available Variables', $theme_my_login->textdomain ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%</p>
443
+ </td>
444
+ </tr>
445
+ </table>
446
+ <?php
447
+ }
448
+
449
+ /**
450
+ * Sanitizes settings
451
+ *
452
+ * Callback for "tml_save_settings" hook in method Theme_My_Login_Admin::save_settings()
453
+ *
454
+ * @see Theme_My_Login_Admin::save_settings()
455
+ * @since 6.0
456
+ * @access public
457
+ *
458
+ * @param string|array $settings Settings passed in from filter
459
+ * @return string|array Sanitized settings
460
+ */
461
+ function save_settings( $settings ) {
462
+ // Checkboxes
463
+ if ( $this->theme_my_login->is_module_active( 'custom-email/custom-email.php' ) )
464
+ $settings['email']['user_approval']['admin_disable'] = empty( $settings['email']['user_approval']['admin_disable'] ) ? 0 : 1;
465
+ return $settings;
466
+ }
467
+
468
+ /**
469
+ * Loads the module
470
+ *
471
+ * @since 6.0
472
+ * @access public
473
+ */
474
+ function load() {
475
+ add_action( 'tml_admin_menu', array( &$this, 'admin_menu' ) );
476
+ add_filter( 'tml_save_settings', array( &$this, 'save_settings' ) );
477
+ add_action( 'load-users.php', array( &$this, 'load_users_page' ) );
478
+ }
479
+
480
+ }
481
+
482
+ /**
483
+ * Holds the reference to Theme_My_Login_User_Moderation_Admin object
484
+ * @global object $theme_my_login_user_moderation_admin
485
+ * @since 6.0
486
+ */
487
+ $theme_my_login_user_moderation_admin = new Theme_My_Login_User_Moderation_Admin();
488
+
489
+ endif; // Class exists
490
+
491
+ ?>
modules/user-moderation/includes/email-functions.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
-
3
- include_once( TML_MODULE_DIR . '/custom-email/includes/hook-functions.php' );
4
-
5
- function wdbj_tml_user_mod_custom_email_user_activation_filters() {
6
- wdbj_tml_custom_email_headers();
7
- add_filter('user_activation_title', 'wdbj_tml_user_mod_user_activation_title');
8
- add_filter('user_activation_message', 'wdbj_tml_user_mod_user_activation_message', 10, 3);
9
- }
10
-
11
- function wdbj_tml_user_mod_custom_email_user_approval_filters() {
12
- wdbj_tml_custom_email_headers();
13
- add_filter('user_approval_title', 'wdbj_tml_user_mod_user_approval_title');
14
- add_filter('user_approval_message', 'wdbj_tml_user_mod_user_approval_message', 10, 3);
15
- }
16
-
17
- function wdbj_tml_user_mod_custom_email_user_denial_filters() {
18
- wdbj_tml_custom_email_headers();
19
- add_filter('user_denial_title', 'wdbj_tml_user_mod_user_denial_title');
20
- add_filter('user_denial_message', 'wdbj_tml_user_mod_user_denial_message', 10, 2);
21
- }
22
-
23
- function wdbj_tml_user_mod_user_activation_title($title) {
24
- $_title = wdbj_tml_get_option('email', 'user_activation', 'title');
25
- return empty($_title) ? $title : wdbj_tml_custom_email_replace_vars($_title, $user_id);
26
- }
27
-
28
- function wdbj_tml_user_mod_user_activation_message($message, $user_id, $activation_url) {
29
- $_message = wdbj_tml_get_option('email', 'user_activation', 'message');
30
- $replacements = array(
31
- '%activateurl%' => $activation_url
32
- );
33
- return empty($_message) ? $message : wdbj_tml_custom_email_replace_vars($_message, $user_id, $replacements);
34
- }
35
-
36
- function wdbj_tml_user_mod_user_approval_title($title) {
37
- $_title = wdbj_tml_get_option('email', 'user_approval', 'title');
38
- return empty($_title) ? $title : wdbj_tml_custom_email_replace_vars($_title, $user_id);
39
- }
40
-
41
- function wdbj_tml_user_mod_user_approval_message($message, $new_pass, $user_id) {
42
- $_message = wdbj_tml_get_option('email', 'user_approval', 'message');
43
- $replacements = array(
44
- '%loginurl%' => site_url('wp-login.php', 'login'),
45
- '%user_pass%' => $new_pass
46
- );
47
- return empty($_message) ? $message : wdbj_tml_custom_email_replace_vars($_message, $user_id, $replacements);
48
- }
49
-
50
- function wdbj_tml_user_mod_user_denial_title($title) {
51
- $_title = wdbj_tml_get_option('email', 'user_denial', 'title');
52
- return empty($_title) ? $title : wdbj_tml_custom_email_replace_vars($_title, $user_id);
53
- }
54
-
55
- function wdbj_tml_user_mod_user_denial_message($message, $user_id) {
56
- $_message = wdbj_tml_get_option('email', 'user_denial', 'message');
57
- $replacements = array(
58
- '%loginurl%' => site_url('wp-login.php', 'login'),
59
- '%user_pass%' => $new_pass
60
- );
61
- return empty($_message) ? $message : wdbj_tml_custom_email_replace_vars($_message, $user_id, $replacements);
62
- }
63
-
64
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/includes/functions.php DELETED
@@ -1,159 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Handles activating a new user by user email confirmation.
5
- *
6
- * @param string $key Hash to validate sending confirmation email
7
- * @param string $login User's username for logging in
8
- * @param bool $newpass Whether or not to assign a new password
9
- * @return bool|WP_Error
10
- */
11
- function wdbj_tml_user_mod_activate_new_user($key, $login, $newpass = false) {
12
- global $wpdb;
13
-
14
- $key = preg_replace('/[^a-z0-9]/i', '', $key);
15
-
16
- if ( empty($key) || !is_string($key) )
17
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
18
-
19
- if ( empty($login) || !is_string($login) )
20
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
21
-
22
- $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
23
- if ( empty( $user ) )
24
- return new WP_Error('invalid_key', __('Invalid key', 'theme-my-login'));
25
-
26
- do_action('user_activation_post', $user->user_login, $user->user_email);
27
-
28
- // Allow plugins to short-circuit process and send errors
29
- $errors = new WP_Error();
30
- $errors = apply_filters( 'user_activation_errors', $errors, $user->user_login, $user->user_email );
31
-
32
- if ( $errors->get_error_code() )
33
- return $errors;
34
-
35
- $wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login) );
36
-
37
- $user_object = new WP_User($user->ID);
38
- $user_object->set_role(get_option('default_role'));
39
- unset($user_object);
40
-
41
- $pass = __('Same as when you signed up.', 'theme-my-login');
42
- if ( $newpass ) {
43
- $pass = wp_generate_password();
44
- wp_set_password($pass, $user->ID);
45
- }
46
-
47
- wp_new_user_notification($user->ID, $pass);
48
-
49
- return true;
50
- }
51
-
52
- /**
53
- * Handles activating a new user by admin approval.
54
- *
55
- * @param string $id User's ID
56
- * @param bool $newpass Whether or not to assign a new password
57
- * @return bool Returns false if not a valid user
58
- */
59
- function wdbj_tml_user_mod_approve_new_user($id, $newpass = false) {
60
- global $wpdb;
61
-
62
- $id = (int) $id;
63
-
64
- $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d", $id));
65
- if ( empty( $user ) )
66
- return false;
67
-
68
- do_action('approve_user', $user->ID);
69
-
70
- $wpdb->update($wpdb->users, array('user_activation_key' => ''), array('ID' => $id) );
71
-
72
- $user_object = new WP_User($user->ID);
73
- $user_object->set_role(get_option('default_role'));
74
- unset($user_object);
75
-
76
- $user_pass = __('Same as when you signed up.', 'theme-my-login');
77
- if ( $newpass ) {
78
- $user_pass = wp_generate_password();
79
- wp_set_password($user_pass, $user->ID);
80
- }
81
-
82
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
83
- // we want to reverse this for the plain text arena of emails.
84
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
85
-
86
- $message = sprintf(__('You have been approved access to %s', 'theme-my-login'), $blogname) . "\r\n\r\n";
87
- $message .= sprintf(__('Username: %s', 'theme-my-login'), $user->user_login) . "\r\n";
88
- $message .= sprintf(__('Password: %s', 'theme-my-login'), $user_pass) . "\r\n\r\n";
89
- $message .= site_url('wp-login.php', 'login') . "\r\n";
90
-
91
- $title = sprintf(__('[%s] Registration Approved', 'theme-my-login'), $blogname);
92
-
93
- $title = apply_filters('user_approval_title', $title);
94
- $message = apply_filters('user_approval_message', $message, $user_pass, $user->ID);
95
-
96
- if ( $message && !wp_mail($user->user_email, $title, $message) )
97
- die('<p>' . __('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login') . '</p>');
98
-
99
- return true;
100
- }
101
-
102
- function wdbj_tml_user_mod_new_user_activation_notification($user_id, $key = '') {
103
- global $wpdb;
104
-
105
- if ( apply_filters('new_user_activation_notification', true) ) {
106
-
107
- $user = new WP_User($user_id);
108
-
109
- $user_login = stripslashes($user->user_login);
110
- $user_email = stripslashes($user->user_email);
111
-
112
- if ( empty($key) ) {
113
- $key = $wpdb->get_var( $wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login) );
114
- if ( empty($key) ) {
115
- $key = wp_generate_password(20, false);
116
- $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
117
- }
118
- }
119
-
120
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
121
- // we want to reverse this for the plain text arena of emails.
122
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
123
-
124
- $activation_url = add_query_arg(array('action' => 'activate', 'key' => $key, 'login' => rawurlencode($user_login)), wp_login_url());
125
-
126
- $title = sprintf(__('[%s] Activate Your Account', 'theme-my-login'), $blogname);
127
- $message = sprintf(__('Thanks for registering at %s! To complete the activation of your account please click the following link: ', 'theme-my-login'), $blogname) . "\r\n\r\n";
128
- $message .= $activation_url . "\r\n";
129
-
130
- $title = apply_filters('user_activation_title', $title, $user_id);
131
- $message = apply_filters('user_activation_message', $message, $user_id, $activation_url);
132
-
133
- wp_mail($user_email, $title, $message);
134
- }
135
- }
136
-
137
- function wdbj_tml_user_mod_new_user_approval_admin_notification($user_id) {
138
- if ( apply_filters('new_user_approval_admin_notification', true) ) {
139
-
140
- $user = new WP_User($user_id);
141
-
142
- $user_login = stripslashes($user->user_login);
143
- $user_email = stripslashes($user->user_email);
144
-
145
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
146
- // we want to reverse this for the plain text arena of emails.
147
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
148
-
149
- $message = sprintf(__('New user requires approval on your blog %s:', 'theme-my-login'), $blogname) . "\r\n\r\n";
150
- $message .= sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n";
151
- $message .= sprintf(__('E-mail: %s', 'theme-my-login'), $user_email) . "\r\n\r\n";
152
- $message .= __('To approve or deny this user:', 'theme-my-login') . "\r\n";
153
- $message .= admin_url('users.php');
154
-
155
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Awaiting Approval', 'theme-my-login'), $blogname), $message);
156
- }
157
- }
158
-
159
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/includes/hook-functions.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
-
3
- function wdbj_tml_user_mod_user_moderation($user_id) {
4
- global $wpdb;
5
-
6
- require_once (TML_MODULE_DIR . '/user-moderation/includes/functions.php');
7
-
8
- // Disable original notification
9
- add_filter('new_user_admin_notification', create_function('', "return false;"), 100);
10
- add_filter('new_user_notification', create_function('', "return false;"), 100);
11
-
12
- $user = new WP_User($user_id);
13
- $user->set_role('pending');
14
- if ( 'email' == wdbj_tml_get_option('moderation', 'type') ) {
15
- $key = wp_generate_password(20, false);
16
- $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user->user_login));
17
- wdbj_tml_user_mod_new_user_activation_notification($user_id, $key);
18
- } elseif ( 'admin' == wdbj_tml_get_option('moderation', 'type') ) {
19
- wdbj_tml_user_mod_new_user_approval_admin_notification($user_id);
20
- }
21
- }
22
-
23
- function wdbj_tml_user_mod_authenticate($user, $username, $password) {
24
- global $wpdb;
25
-
26
- if ( is_a($user, 'WP_User') ) {
27
- $user_role = reset($user->roles);
28
- if ( 'pending' == $user_role ) {
29
- if ( 'email' == wdbj_tml_get_option('moderation', 'type') )
30
- return new WP_Error('pending', __('<strong>ERROR</strong>: You have not yet confirmed your e-mail address.', 'theme-my-login'));
31
- else
32
- return new WP_Error('pending', __('<strong>ERROR</strong>: Your registration has not yet been approved.', 'theme-my-login'));
33
- }
34
- }
35
- return $user;
36
- }
37
-
38
- function wdbj_tml_user_mod_user_activation() {
39
- require_once( TML_MODULE_DIR . '/user-moderation/includes/functions.php' );
40
-
41
- $newpass = ( wdbj_tml_is_module_active('custom-passwords/custom-passwords.php') ) ? 0 : 1;
42
- $errors = wdbj_tml_user_mod_activate_new_user($_GET['key'], $_GET['login'], $newpass);
43
-
44
- if ( !is_wp_error($errors) ) {
45
- $redirect_to = site_url('wp-login.php?activation=complete');
46
- if ( 'tml-page' != wdbj_tml_get_var('request_instance') )
47
- $redirect_to = wdbj_tml_get_current_url('activation=complete&instance=' . wdbj_tml_get_var('request_instance'));
48
- wp_redirect($redirect_to);
49
- exit();
50
- }
51
-
52
- $redirect_to = site_url('wp-login.php?activation=invalidkey');
53
- if ( 'tml-page' != wdbj_tml_get_var('request_instance') )
54
- $redirect_to = wdbj_tml_get_current_url('activation=invalidkey&instance=' . wdbj_tml_get_var('request_instance'));
55
- wp_redirect($redirect_to);
56
- exit();
57
- }
58
-
59
- function wdbj_tml_user_mod_allow_password_reset($allow, $user_id) {
60
- $user = new WP_User($user_id);
61
- $user_role = reset($user->roles);
62
- if ( 'pending' == $user_role )
63
- $allow = false;
64
- return $allow;
65
- }
66
-
67
- function wdbj_tml_user_mod_register_redirect($redirect_to) {
68
- $redirect_to = site_url('wp-login.php');
69
- if ( 'tml-page' != wdbj_tml_get_var('request_instance') )
70
- $redirect_to = wdbj_tml_get_current_url('instance=' . wdbj_tml_get_var('request_instance'));
71
-
72
- if ( 'email' == wdbj_tml_get_option('moderation', 'type') )
73
- $redirect_to = add_query_arg('pending', 'activation', $redirect_to);
74
- elseif ( 'admin' == wdbj_tml_get_option('moderation', 'type') )
75
- $redirect_to = add_query_arg('pending', 'approval', $redirect_to);
76
- return $redirect_to;
77
- }
78
-
79
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/user-moderation.php CHANGED
@@ -4,84 +4,796 @@ Plugin Name: User Moderation
4
  Description: Enabling this module will initialize user moderation. You will then have to configure the settings via the "Moderation" tab.
5
  */
6
 
7
- add_action('tml_init', 'wdbj_tml_user_mod_init');
8
- function wdbj_tml_user_mod_init() {
9
- include( TML_MODULE_DIR . '/user-moderation/includes/hook-functions.php' );
10
- $moderation = wdbj_tml_get_option('moderation', 'type');
11
- if ( in_array($moderation, array('admin', 'email')) ) {
12
- add_action('user_register', 'wdbj_tml_user_mod_user_moderation', 100);
13
- add_action('authenticate', 'wdbj_tml_user_mod_authenticate', 100, 3);
14
- add_filter('allow_password_reset', 'wdbj_tml_user_mod_allow_password_reset', 10, 2);
15
- add_filter('register_redirect', 'wdbj_tml_user_mod_register_redirect', 100);
16
- if ( 'email' == $moderation ) {
17
- add_action('login_action_activate', 'wdbj_tml_user_mod_user_activation');
18
- if ( wdbj_tml_is_module_active('custom-email/custom-email.php') ) {
19
- require_once( TML_MODULE_DIR . '/user-moderation/includes/email-functions.php' );
20
- add_action('register_post', 'wdbj_tml_user_mod_custom_email_user_activation_filters');
21
- add_action('user_activation_post', 'wdbj_tml_custom_email_new_user_filters', 10, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
  }
24
- }
25
- }
26
 
27
- add_action('template_redirect', 'wdbj_tml_user_mod_login_message', 100);
28
- function wdbj_tml_user_mod_login_message() {
29
- if ( isset($_GET['pending']) && 'activation' == $_GET['pending'] )
30
- wdbj_tml_set_error('pending_activation', __('Your registration was successful but you must now confirm your email address before you can log in. Please check your email and click on the link provided.', 'theme-my-login'), 'message');
31
- elseif ( isset($_GET['pending']) && 'approval' == $_GET['pending'] )
32
- wdbj_tml_set_error('pending_approval', __('Your registration was successful but you must now be approved by an administrator before you can log in. You will be notified by e-mail once your account has been reviewed.', 'theme-my-login'), 'message');
33
- elseif ( isset($_GET['activation']) && 'complete' == $_GET['activation'] ) {
34
- if ( wdbj_tml_is_module_active('custom-passwords/custom-passwords.php') )
35
- wdbj_tml_set_error('activation_complete', __('Your account has been activated. You may now log in.', 'theme-my-login'), 'message');
36
- else
37
- wdbj_tml_set_error('activation_complete', __('Your account has been activated. Please check your e-mail for your password.', 'theme-my-login'), 'message');
38
- }
39
-
40
- if ( wdbj_tml_get_var('request_instance') == wdbj_tml_get_var('current_instance', 'instance_id') && isset($_GET['activation']) && 'invalidkey' == $_GET['activation'] )
41
- wdbj_tml_set_error('invalid_key', __('<strong>ERROR</strong>: Sorry, that key does not appear to be valid.', 'theme-my-login'));
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- add_action('tml_admin_init', 'wdbj_tml_user_mod_admin_init');
45
- function wdbj_tml_user_mod_admin_init() {
46
- include( TML_MODULE_DIR . '/user-moderation/admin/admin.php' );
47
 
48
- add_action('tml_admin_menu', 'wdbj_tml_user_mod_admin_menu');
 
49
 
50
- add_action('load-users.php', 'wdbj_tml_user_mod_load_users_page');
 
 
 
51
 
52
- if ( wdbj_tml_is_module_active('custom-email/custom-email.php') ) {
53
- require_once( TML_MODULE_DIR . '/user-moderation/includes/email-functions.php' );
54
- add_action('approve_user', 'wdbj_tml_user_mod_custom_email_user_approval_filters');
55
- add_action('deny_user', 'wdbj_tml_user_mod_custom_email_user_denial_filters');
56
  }
57
- }
58
 
59
- add_action('activate_user-moderation/user-moderation.php', 'wdbj_tml_user_mod_activate');
60
- function wdbj_tml_user_mod_activate() {
61
- $current = wdbj_tml_get_option('moderation');
62
- $default = wdbj_tml_user_mod_default_settings();
 
 
 
 
 
 
 
 
 
63
 
64
- add_role( 'pending', 'Pending', array() );
65
 
66
- if ( is_array($current) )
67
- wdbj_tml_update_option(array_merge($default, $current), 'moderation');
68
- else
69
- wdbj_tml_update_option($default, 'moderation');
70
 
71
- unset($current, $default);
72
- }
73
 
74
- add_action('deactivate_user-moderation/user-moderation.php', 'wdbj_tml_user_mod_deactivate');
75
- add_action('uninstall_user-moderation/user-moderation.php', 'wdbj_tml_user_mod_deactivate');
76
- function wdbj_tml_user_mod_deactivate() {
77
- remove_role( 'pending' );
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
- function wdbj_tml_user_mod_default_settings() {
81
- $options = array(
82
- 'type' => 'none'
83
- );
84
- return $options;
85
  }
86
-
87
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
4
  Description: Enabling this module will initialize user moderation. You will then have to configure the settings via the "Moderation" tab.
5
  */
6
 
7
+ if ( !class_exists( 'Theme_My_Login_User_Moderation' ) ) :
8
+ /**
9
+ * Theme My Login Custom User Links module class
10
+ *
11
+ * Adds the ability to define custom links to display to a user when logged in based upon their "user role".
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_User_Moderation extends Theme_My_Login_Module {
16
+ /**
17
+ * Holds reference to $theme_my_login_custom_email object
18
+ *
19
+ * @since 6.0
20
+ * @access public
21
+ * @var object
22
+ */
23
+ var $theme_my_login_custom_email;
24
+
25
+ /**
26
+ * Applies user moderation upon registration
27
+ *
28
+ * @since 6.0
29
+ * @access public
30
+ */
31
+ function register_post() {
32
+ // Remove all other filters
33
+ remove_all_actions( 'tml_new_user_registered' );
34
+
35
+ // Moderate user upon registration
36
+ add_action( 'tml_new_user_registered', array( &$this, 'moderate_user' ), 100, 2 );
37
+ }
38
+
39
+ /**
40
+ * Applies moderation to a newly registered user
41
+ *
42
+ * Callback for "register_post" hook in method Theme_My_Login::register_new_user()
43
+ *
44
+ * @see Theme_My_Login::register_new_user()
45
+ * @since 6.0
46
+ * @access public
47
+ *
48
+ * @param int $user_id The user's ID
49
+ * @param string $user_pass The user's password
50
+ */
51
+ function moderate_user( $user_id, $user_pass ) {
52
+ global $wpdb;
53
+
54
+ // Set user role to "pending"
55
+ $user = new WP_User( $user_id );
56
+ $user->set_role( 'pending' );
57
+
58
+ // Shorthand reference
59
+ $theme_my_login =& $this->theme_my_login;
60
+
61
+ // Send appropriate e-mail depending on moderation type
62
+ if ( 'email' == $theme_my_login->options['moderation']['type'] ) { // User activation
63
+ // Generate an activation key
64
+ $key = wp_generate_password( 20, false );
65
+ // Set the activation key for the user
66
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => $key ), array( 'user_login' => $user->user_login ) );
67
+ // Apply activation e-mail filters
68
+ $this->apply_user_activation_notification_filters();
69
+ // Send activation e-mail
70
+ $this->new_user_activation_notification( $user_id, $key );
71
+ } elseif ( 'admin' == $theme_my_login->options['moderation']['type'] ) { // Admin approval
72
+ // Apply approval admin e-mail filters
73
+ $this->apply_user_approval_admin_notification_filters();
74
+ // Send approval e-mail
75
+ $this->new_user_approval_admin_notification( $user_id );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Handles "activate" action for login page
81
+ *
82
+ * Callback for "tml_request_activate" hook in method Theme_My_Login::the_request();
83
+ *
84
+ * @see Theme_My_Login::the_request();
85
+ * @since 6.0
86
+ * @access public
87
+ */
88
+ function user_activation() {
89
+ // Shorthand reference
90
+ $theme_my_login =& $this->theme_my_login;
91
+ // Determine if a new password needs to be set
92
+ $newpass = $theme_my_login->is_module_active('custom-passwords/custom-passwords.php') ? 0 : 1;
93
+ // Attempt to activate the user
94
+ $errors = $this->activate_new_user( $_GET['key'], $_GET['login'], $newpass );
95
+ // Make sure there are no errors
96
+ if ( !is_wp_error( $errors ) ) {
97
+ $redirect_to = $theme_my_login->get_current_url( 'activation=complete' );
98
+ if ( !empty( $theme_my_login->request_instance ) )
99
+ $redirect_to = add_query_arg( 'instance', $theme_my_login->request_instance, $redirect_to );
100
+ wp_redirect( $redirect_to );
101
+ exit();
102
+ }
103
+ // If we make it here, the user failed activation, so it must be an invalid key
104
+ $redirect_to = $theme_my_login->get_current_url( 'activation=invalidkey' );
105
+ if ( !empty( $theme_my_login->request_instance ) )
106
+ $redirect_to = add_query_arg( 'instance', $theme_my_login->request_instance, $redirect_to );
107
+ wp_redirect( $redirect_to );
108
+ exit();
109
+ }
110
+
111
+ /**
112
+ * Handles "send_activation" action for login page
113
+ *
114
+ * Callback for "tml_request_send_activation" hook in method Theme_My_Login::the_request();
115
+ *
116
+ * @see Theme_My_Login::the_request();
117
+ * @since 6.0
118
+ * @access public
119
+ */
120
+ function send_activation() {
121
+ global $wpdb;
122
+
123
+ // Shorthand reference
124
+ $theme_my_login =& $this->theme_my_login;
125
+
126
+ $login = isset( $_GET['login'] ) ? trim( $_GET['login'] ) : '';
127
+
128
+ if ( !$user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_login = %s", $login ) ) ) {
129
+ $redirect_to = $theme_my_login->get_current_url( 'sendactivation=failed' );
130
+ if ( !empty( $theme_my_login->request_instance ) )
131
+ $redirect_to = add_query_arg( 'instance', $theme_my_login->request_instance, $redirect_to );
132
+ wp_redirect( $redirect_to );
133
+ exit();
134
+ }
135
+
136
+ $user = new WP_User( $user_id );
137
+
138
+ if ( 'pending' == $user->roles[0] ) {
139
+ // Apply activation e-mail filters
140
+ $this->apply_user_activation_notification_filters();
141
+ // Send activation e-mail
142
+ $this->new_user_activation_notification( $user->ID );
143
+ // Now redirect them
144
+ $redirect_to = $theme_my_login->get_current_url( 'sendactivation=sent' );
145
+ wp_redirect( $redirect_to );
146
+ exit();
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Blocks "pending" users from loggin in
152
+ *
153
+ * Callback for "authenticate" hook in function wp_authenticate()
154
+ *
155
+ * @see wp_authenticate()
156
+ * @since 6.0
157
+ * @access public
158
+ *
159
+ * @param WP_User $user WP_User object
160
+ * @param string $username Username posted
161
+ * @param string $password Password posted
162
+ * @return WP_User|WP_Error WP_User if the user can login, WP_Error otherwise
163
+ */
164
+ function authenticate( $user, $username, $password ) {
165
+ global $wpdb;
166
+
167
+ if ( is_a( $user, 'WP_User' ) ) {
168
+ if ( 'pending' == $user->roles[0] ) {
169
+ if ( 'email' == $this->theme_my_login->options['moderation']['type'] ) {
170
+ return new WP_Error( 'pending', sprintf(
171
+ __( '<strong>ERROR</strong>: You have not yet confirmed your e-mail address. <a href="%s">Resend activation</a>?', $this->theme_my_login->textdomain ),
172
+ $this->theme_my_login->get_login_page_link( 'action=sendactivation&login=' . $username ) ) );
173
+ } else {
174
+ return new WP_Error( 'pending', __( '<strong>ERROR</strong>: Your registration has not yet been approved.', $this->theme_my_login->textdomain ) );
175
+ }
176
  }
177
  }
178
+ return $user;
179
+ }
180
 
181
+ /**
182
+ * Blocks "pending" users from resetting their password
183
+ *
184
+ * Callback for "allow_password_reset" in method Theme_My_Login::retrieve_password()
185
+ *
186
+ * @see Theme_My_Login::retrieve_password()
187
+ * @since 6.0
188
+ * @access public
189
+ *
190
+ * @param bool $allow Default setting
191
+ * @param int $user_id User ID
192
+ * @return bool Whether to allow password reset or not
193
+ */
194
+ function allow_password_reset( $allow, $user_id ) {
195
+ $user = new WP_User( $user_id );
196
+ if ( 'pending' == $user->roles[0] )
197
+ $allow = false;
198
+ return $allow;
199
+ }
200
+
201
+ /**
202
+ * Changes the registration redirection based upon moderaton type
203
+ *
204
+ * Callback for "register_redirect" hook in method Theme_My_Login::the_request()
205
+ *
206
+ * @see Theme_My_Login::the_request()
207
+ * @since 6.0
208
+ * @access public
209
+ *
210
+ * @param string $redirect_to Default redirect
211
+ * @return string URL to redirect to
212
+ */
213
+ function register_redirect( $redirect_to ) {
214
+ // Shorthand reference
215
+ $theme_my_login =& $this->theme_my_login;
216
 
217
+ // TML page link
218
+ $redirect_to = $theme_my_login->get_login_page_link();
 
219
 
220
+ if ( !empty( $theme_my_login->request_instance ) )
221
+ $redirect_to = $theme_my_login->get_current_url( 'instance=' . $theme_my_login->request_instance );
222
 
223
+ if ( 'email' == $theme_my_login->options['moderation']['type'] )
224
+ $redirect_to = add_query_arg( 'pending', 'activation', $redirect_to );
225
+ elseif ( 'admin' == $theme_my_login->options['moderation']['type'] )
226
+ $redirect_to = add_query_arg( 'pending', 'approval', $redirect_to );
227
 
228
+ return $redirect_to;
 
 
 
229
  }
 
230
 
231
+ /**
232
+ * Handles activating a new user by user email confirmation
233
+ *
234
+ * @since 6.0
235
+ * @access public
236
+ *
237
+ * @param string $key Hash to validate sending confirmation email
238
+ * @param string $login User's username for logging in
239
+ * @param bool $newpass Whether or not to assign a new password
240
+ * @return bool|WP_Error True if successful, WP_Error otherwise
241
+ */
242
+ function activate_new_user( $key, $login, $newpass = false ) {
243
+ global $wpdb;
244
 
245
+ $key = preg_replace('/[^a-z0-9]/i', '', $key);
246
 
247
+ if ( empty( $key ) || !is_string( $key ) )
248
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->theme_my_login->textdomain ) );
 
 
249
 
250
+ if ( empty( $login ) || !is_string( $login ) )
251
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->theme_my_login->textdomain ) );
252
 
253
+ // Validate activation key
254
+ $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login ) );
255
+ if ( empty( $user ) )
256
+ return new WP_Error( 'invalid_key', __( 'Invalid key', $this->theme_my_login->textdomain ) );
257
+
258
+ do_action( 'tml_user_activation_post', $user->user_login, $user->user_email );
259
+
260
+ // Allow plugins to short-circuit process and send errors
261
+ $errors = new WP_Error();
262
+ $errors = apply_filters( 'tml_user_activation_errors', $errors, $user->user_login, $user->user_email );
263
+
264
+ // Return errors if there are any
265
+ if ( $errors->get_error_code() )
266
+ return $errors;
267
+
268
+ // Clear the activation key
269
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'user_login' => $login ) );
270
+
271
+ $user_object = new WP_User( $user->ID );
272
+ $user_object->set_role( get_option( 'default_role' ) );
273
+ unset( $user_object );
274
+
275
+ $pass = __( 'Same as when you signed up.', $this->theme_my_login->textdomain );
276
+ if ( $newpass ) {
277
+ $pass = wp_generate_password();
278
+ wp_set_password( $pass, $user->ID );
279
+ }
280
+
281
+ do_action( 'tml_new_user_activated', $user->ID, $pass );
282
+
283
+ return true;
284
+ }
285
+
286
+ /**
287
+ * Calls the "tml_new_user_registered" hook
288
+ *
289
+ * @since 6.0
290
+ * @access public
291
+ *
292
+ * @param int $user_id The user's ID
293
+ * @param string $user_pass The user's password
294
+ */
295
+ function new_user_activated( $user_id, $user_pass ) {
296
+ do_action( 'tml_new_user_registered', $user_id, $user_pass );
297
+ }
298
+
299
+ /**
300
+ * Notifies a pending user to activate their account
301
+ *
302
+ * @since 6.0
303
+ * @access public
304
+ *
305
+ * @param int $user_id The user's ID
306
+ * @param string $key The unique activation key
307
+ */
308
+ function new_user_activation_notification( $user_id, $key = '' ) {
309
+ global $wpdb;
310
+
311
+ $user = new WP_User( $user_id );
312
+
313
+ $user_login = stripslashes( $user->user_login );
314
+ $user_email = stripslashes( $user->user_email );
315
+
316
+ if ( empty( $key ) ) {
317
+ $key = $wpdb->get_var( $wpdb->prepare( "SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login ) );
318
+ if ( empty( $key ) ) {
319
+ $key = wp_generate_password( 20, false );
320
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => $key ), array( 'user_login' => $user_login ) );
321
+ }
322
+ }
323
+
324
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
325
+ $blogname = $GLOBALS['current_site']->site_name;
326
+ } else {
327
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
328
+ // we want to reverse this for the plain text arena of emails.
329
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
330
+ }
331
+
332
+ $activation_url = add_query_arg( array( 'action' => 'activate', 'key' => $key, 'login' => rawurlencode( $user_login ) ), wp_login_url() );
333
+
334
+ $title = sprintf( __( '[%s] Activate Your Account', $this->theme_my_login->textdomain ), $blogname );
335
+ $message = sprintf( __( 'Thanks for registering at %s! To complete the activation of your account please click the following link: ', $this->theme_my_login->textdomain ), $blogname ) . "\r\n\r\n";
336
+ $message .= $activation_url . "\r\n";
337
+
338
+ $title = apply_filters( 'user_activation_notification_title', $title, $user_id );
339
+ $message = apply_filters( 'user_activation_notification_message', $message, $activation_url, $user_id );
340
+
341
+ return wp_mail( $user_email, $title, $message );
342
+ }
343
+
344
+ /**
345
+ * Notifies the administrator of a pending user needing approval
346
+ *
347
+ * @since 6.0
348
+ * @access public
349
+ *
350
+ * @param int $user_id The user's ID
351
+ */
352
+ function new_user_approval_admin_notification( $user_id ) {
353
+
354
+ $user = new WP_User( $user_id );
355
+
356
+ $user_login = stripslashes( $user->user_login );
357
+ $user_email = stripslashes( $user->user_email );
358
+
359
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
360
+ $blogname = $GLOBALS['current_site']->site_name;
361
+ } else {
362
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
363
+ // we want to reverse this for the plain text arena of emails.
364
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
365
+ }
366
+
367
+ $title = sprintf( __( '[%s] New User Awaiting Approval', $this->theme_my_login->textdomain ), $blogname );
368
+
369
+ $message = sprintf( __( 'New user requires approval on your blog %s:', $this->theme_my_login->textdomain ), $blogname ) . "\r\n\r\n";
370
+ $message .= sprintf( __( 'Username: %s', $this->theme_my_login->textdomain ), $user_login ) . "\r\n";
371
+ $message .= sprintf( __( 'E-mail: %s', $this->theme_my_login->textdomain ), $user_email ) . "\r\n\r\n";
372
+ $message .= __( 'To approve or deny this user:', $this->theme_my_login->textdomain ) . "\r\n";
373
+ $message .= admin_url( 'users.php?role=pending' );
374
+
375
+ $title = apply_filters( 'user_approval_admin_notification_title', $title, $user_id );
376
+ $message = apply_filters( 'user_approval_admin_notification_message', $message, $user_id );
377
+
378
+ $to = apply_filters( 'user_approval_admin_notifcation_mail_to', get_option( 'admin_email' ) );
379
+
380
+ @wp_mail( $to, $title, $message );
381
+ }
382
+
383
+ /**
384
+ * Handles display of various action/status messages
385
+ *
386
+ * @since 6.0
387
+ * @access public
388
+ *
389
+ * @param object $theme_my_login Reference to global $theme_my_login object
390
+ */
391
+ function action_messages( &$theme_my_login ) {
392
+ if ( isset( $_GET['pending'] ) && 'activation' == $_GET['pending'] ) {
393
+ $theme_my_login->errors->add( 'pending_activation', __( 'Your registration was successful but you must now confirm your email address before you can log in. Please check your email and click on the link provided.', $theme_my_login->textdomain ), 'message' );
394
+ } elseif ( isset( $_GET['pending'] ) && 'approval' == $_GET['pending'] ) {
395
+ $theme_my_login->errors->add( 'pending_approval', __( 'Your registration was successful but you must now be approved by an administrator before you can log in. You will be notified by e-mail once your account has been reviewed.', $theme_my_login->textdomain ), 'message' );
396
+ } elseif ( isset( $_GET['activation'] ) && 'complete' == $_GET['activation'] ) {
397
+ if ( $theme_my_login->is_module_active( 'custom-passwords/custom-passwords.php' ) )
398
+ $theme_my_login->errors->add( 'activation_complete', __( 'Your account has been activated. You may now log in.', $theme_my_login->textdomain ), 'message' );
399
+ else
400
+ $theme_my_login->errors->add( 'activation_complete', __( 'Your account has been activated. Please check your e-mail for your password.', $theme_my_login->textdomain ), 'message' );
401
+ } elseif ( isset( $_GET['activation'] ) && 'invalidkey' == $_GET['activation'] ) {
402
+ $theme_my_login->errors->add( 'invalid_key', __('<strong>ERROR</strong>: Sorry, that key does not appear to be valid.', $theme_my_login->textdomain ) );
403
+ } elseif ( isset( $_GET['sendactivation'] ) ) {
404
+ if ( 'failed' == $_GET['sendactivation'] )
405
+ $theme_my_login->errors->add( 'sendactivation_failed', __('<strong>ERROR</strong>: Sorry, the activation e-mail could not be sent.', $theme_my_login->textdomain ) );
406
+ elseif ( 'sent' == $_GET['sendactivation'] )
407
+ $theme_my_login->errors->add( 'sendactivation_sent', __('The activation e-mail has been sent to the e-mail address with which you registered. Please check your email and click on the link provided.', $theme_my_login->textdomain ), 'message' );
408
+ }
409
+ }
410
+
411
+ /**
412
+ * Applies all user activation mail filters
413
+ *
414
+ * @since 6.0
415
+ * @access public
416
+ */
417
+ function apply_user_activation_notification_filters() {
418
+ if ( $this->theme_my_login->is_module_active( 'custom-email/custom-email.php' ) && $options = $this->theme_my_login->get_option( array( 'email', 'user_activation' ) ) ) {
419
+ $this->theme_my_login_custom_email->set_mail_headers( $options['mail_from'], $options['mail_from_name'], $options['mail_content_type'] );
420
+ add_filter( 'user_activation_notification_title', array( &$this, 'user_activation_notification_title_filter' ), 10, 2 );
421
+ add_filter( 'user_activation_notification_message', array( &$this, 'user_activation_notification_message_filter' ), 10, 3 );
422
+ }
423
+ }
424
+
425
+ /**
426
+ * Applies all user approval mail filters
427
+ *
428
+ * Callback for "approve_user" hook in method Theme_My_Login_User_Moderation_Admin::approve_user()
429
+ *
430
+ * @see Theme_My_Login_User_Moderation_Admin::approve_user()
431
+ * @since 6.0
432
+ * @access public
433
+ */
434
+ function apply_user_approval_notification_filters() {
435
+ if ( $this->theme_my_login->is_module_active( 'custom-email/custom-email.php' ) && $options = $this->theme_my_login->get_option( array( 'email', 'user_approval' ) ) ) {
436
+ $this->theme_my_login_custom_email->set_mail_headers( $options['mail_from'], $options['mail_from_name'], $options['mail_content_type'] );
437
+ add_filter( 'user_approval_notification_title', array( &$this, 'user_approval_notification_title_filter' ), 10, 2 );
438
+ add_filter( 'user_approval_notification_message', array( &$this, 'user_approval_notification_message_filter' ), 10, 3 );
439
+ }
440
+ }
441
+
442
+ /**
443
+ * Applies all user approval admin mail filters
444
+ *
445
+ * @since 6.0
446
+ * @access public
447
+ */
448
+ function apply_user_approval_admin_notification_filters() {
449
+ if ( $this->theme_my_login->is_module_active( 'custom-email/custom-email.php' ) && $options = $this->theme_my_login->get_option( array( 'email', 'user_approval' ) ) ) {
450
+ $this->theme_my_login_custom_email->set_mail_headers( $options['admin_mail_from'], $options['admin_mail_from_name'], $options['admin_mail_content_type'] );
451
+ add_filter( 'user_approval_admin_notifcation_mail_to', array( &$this, 'user_approval_admin_notifcation_mail_to_filter' ) );
452
+ add_filter( 'user_approval_admin_notification_title', array( &$this, 'user_approval_admin_notification_title_filter' ), 10, 2 );
453
+ add_filter( 'user_approval_admin_notification_message', array( &$this, 'user_approval_admin_notification_message_filter' ), 10, 2 );
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Applies all user denial mail filters
459
+ *
460
+ * Callback for "deny_user" hook in method Theme_My_Login_User_Moderation_Admin::deny_user()
461
+ *
462
+ * @see Theme_My_Login_User_Moderation_Admin::deny_user()
463
+ * @since 6.0
464
+ * @access public
465
+ */
466
+ function apply_user_denial_notification_filters() {
467
+ if ( $this->theme_my_login->is_module_active( 'custom-email/custom-email.php' ) && $options = $this->theme_my_login->get_option( array( 'email', 'user_denial' ) ) ) {
468
+ $this->theme_my_login_custom_email->set_mail_headers( $options['mail_from'], $options['mail_from_name'], $options['mail_content_type'] );
469
+ add_filter( 'user_denial_notification_title', array( &$this, 'user_denial_notification_title_filter' ), 10, 2 );
470
+ add_filter( 'user_denial_notification_message', array( &$this, 'user_denial_notification_message_filter' ), 10, 2 );
471
+ }
472
+ }
473
+
474
+ /**
475
+ * Changes the user activation e-mail subject
476
+ *
477
+ * Callback for "user_activation_notification_title" hook in Theme_My_Login_User_Moderation::new_user_activation_notification()
478
+ *
479
+ * @see Theme_My_Login_User_Moderation::new_user_activation_notification()
480
+ * @since 6.0
481
+ * @access public
482
+ *
483
+ * @param string $title The default subject
484
+ * @param int $user_id The user's ID
485
+ * @return string The filtered subject
486
+ */
487
+ function user_activation_notification_title_filter( $title, $user_id ) {
488
+ $_title = $this->theme_my_login->get_option( array( 'email', 'user_activation', 'title' ) );
489
+ return empty( $_title ) ? $title : $this->theme_my_login_custom_email->replace_vars( $_title, $user_id );
490
+ }
491
+
492
+ /**
493
+ * Changes the user activation e-mail message
494
+ *
495
+ * Callback for "user_activation_notification_message" hook in Theme_My_Login_User_Moderation::new_user_activation_notification()
496
+ *
497
+ * @see Theme_My_Login_User_Moderation::new_user_activation_notification()
498
+ * @since 6.0
499
+ * @access public
500
+ *
501
+ * @param string $title The default message
502
+ * @param int $user_id The user's ID
503
+ * @param string $activation_url The activation URL
504
+ * @return string The filtered message
505
+ */
506
+ function user_activation_notification_message_filter( $message, $activation_url, $user_id ) {
507
+ $_message = $this->theme_my_login->get_option( array( 'email', 'user_activation', 'message' ) );
508
+ return empty( $_message ) ? $message : $this->theme_my_login_custom_email->replace_vars( $_message, $user_id, array( '%activateurl%' => $activation_url ) );
509
+ }
510
+
511
+ /**
512
+ * Changes the user approval e-mail subject
513
+ *
514
+ * Callback for "user_approval_notification_title" hook in Theme_My_Login_User_Moderation_Admin::approve_user()
515
+ *
516
+ * @see Theme_My_Login_User_Moderation_Admin::approve_user()
517
+ * @since 6.0
518
+ * @access public
519
+ *
520
+ * @param string $title The default subject
521
+ * @param int $user_id The user's ID
522
+ * @return string The filtered subject
523
+ */
524
+ function user_approval_notification_title_filter( $title, $user_id ) {
525
+ $_title = $this->theme_my_login->get_option( array( 'email', 'user_approval', 'title' ) );
526
+ return empty( $_title ) ? $title : $this->theme_my_login_custom_email->replace_vars( $_title, $user_id );
527
+ }
528
+
529
+ /**
530
+ * Changes the user approval e-mail message
531
+ *
532
+ * Callback for "user_approval_notification_message" hook in Theme_My_Login_User_Moderation_Admin::approve_user()
533
+ *
534
+ * @see Theme_My_Login_User_Moderation_Admin::approve_user()
535
+ * @since 6.0
536
+ * @access public
537
+ *
538
+ * @param string $title The default message
539
+ * @param string $new_pass The user's new password
540
+ * @param int $user_id The user's ID
541
+ * @return string The filtered message
542
+ */
543
+ function user_approval_notification_message_filter( $message, $new_pass, $user_id ) {
544
+ $_message = $this->theme_my_login->get_option( array( 'email', 'user_approval', 'message' ) );
545
+ return empty( $_message ) ? $message : $this->theme_my_login_custom_email->replace_vars( $_message, $user_id, array( '%loginurl%' => $this->theme_my_login->get_login_page_link(), '%user_pass%' => $new_pass ) );
546
+ }
547
+
548
+ /**
549
+ * Changes the user approval admin e-mail recipient
550
+ *
551
+ * Callback for "user_approval_admin_notification_mail_to" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
552
+ *
553
+ * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
554
+ * @since 6.0
555
+ * @access public
556
+ *
557
+ * @param string $to The default recipient
558
+ * @return string The filtered recipient
559
+ */
560
+ function user_approval_admin_notifcation_mail_to_filter( $to ) {
561
+ $_to = $this->theme_my_login->get_option( array( 'email', 'user_approval', 'admin_mail_to' ) );
562
+ return empty( $_to ) ? $to : $_to;
563
+ }
564
+
565
+ /**
566
+ * Changes the user approval admin e-mail subject
567
+ *
568
+ * Callback for "user_approval_admin_notification_title" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
569
+ *
570
+ * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
571
+ * @since 6.0
572
+ * @access public
573
+ *
574
+ * @param string $title The default subject
575
+ * @param int $user_id The user's ID
576
+ * @return string The filtered subject
577
+ */
578
+ function user_approval_admin_notification_title_filter( $title, $user_id ) {
579
+ $_title = $this->theme_my_login->get_option( array( 'email', 'user_approval', 'admin_title' ) );
580
+ return empty( $_title ) ? $title : $this->theme_my_login_custom_email->replace_vars( $_title, $user_id );
581
+ }
582
+
583
+ /**
584
+ * Changes the user approval admin e-mail message
585
+ *
586
+ * Callback for "user_approval_admin_notification_message" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
587
+ *
588
+ * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
589
+ * @since 6.0
590
+ * @access public
591
+ *
592
+ * @param string $message The default message
593
+ * @param int $user_id The user's ID
594
+ * @return string The filtered message
595
+ */
596
+ function user_approval_admin_notification_message_filter( $message, $user_id ) {
597
+ $_message = $this->theme_my_login->get_option( array( 'email', 'user_approval', 'admin_message' ) );
598
+ return empty( $_message ) ? $message : $this->theme_my_login_custom_email->replace_vars( $_message, $user_id, array( '%pendingurl%' => admin_url( 'users.php?role=pending' ) ) );
599
+ }
600
+
601
+ /**
602
+ * Changes the user denial e-mail subject
603
+ *
604
+ * Callback for "user_denial_notification_title" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
605
+ *
606
+ * @see Theme_My_Login_User_Moderation_Admin::deny_user()
607
+ * @since 6.0
608
+ * @access public
609
+ *
610
+ * @param string $title The default subject
611
+ * @param int $user_id The user's ID
612
+ * @return string The filtered subject
613
+ */
614
+ function user_denial_notification_title_filter( $title, $user_id ) {
615
+ $_title = $this->theme_my_login->get_option( array( 'email', 'user_denial', 'title' ) );
616
+ return empty( $_title ) ? $title : $this->theme_my_login_custom_email->replace_vars( $_title, $user_id );
617
+ }
618
+
619
+ /**
620
+ * Changes the user denial e-mail message
621
+ *
622
+ * Callback for "user_denial_notification_message" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
623
+ *
624
+ * @see Theme_My_Login_User_Moderation_Admin::deny_user()
625
+ * @since 6.0
626
+ * @access public
627
+ *
628
+ * @param string $message The default message
629
+ * @param int $user_id The user's ID
630
+ * @return string The filtered message
631
+ */
632
+ function user_denial_notification_message_filter( $message, $user_id ) {
633
+ $_message = $this->theme_my_login->get_option( array( 'email', 'user_denial', 'message' ) );
634
+ return empty( $_message ) ? $message : $this->theme_my_login_custom_email->replace_vars( $_message, $user_id );
635
+ }
636
+
637
+ /**
638
+ * Activates this module
639
+ *
640
+ * Callback for "tml_activate_user-moderation/user-moderation.php" hook in method Theme_My_Login_Admin::activate_module()
641
+ *
642
+ * @see Theme_My_Login_Admin::activate_module()
643
+ * @since 6.0
644
+ * @access public
645
+ *
646
+ * @param object $theme_my_login Reference to global $theme_my_login object
647
+ */
648
+ function activate( &$theme_my_login ) {
649
+ $options = $this->init_options();
650
+ $theme_my_login->options['moderation'] = isset( $theme_my_login->options['moderation'] ) ? $theme_my_login->array_merge_recursive( $options['moderation'], $theme_my_login->options['moderation'] ) : $options['moderation'];
651
+ $theme_my_login->options['email'] = isset( $theme_my_login->options['email'] ) ? $theme_my_login->array_merge_recursive( $options['email'], $theme_my_login->options['email'] ) : $options['email'];
652
+ }
653
+
654
+ /**
655
+ * Deactivates this module
656
+ *
657
+ * Callback for "tml_deactivate_user-moderation/user-moderation.php" hook in method Theme_My_Login_Admin::activate_module()
658
+ *
659
+ * @see Theme_My_Login_Admin::activate_module()
660
+ * @since 6.0
661
+ * @access public
662
+ *
663
+ * @param object $theme_my_login Reference to global $theme_my_login object
664
+ */
665
+ function deactivate( &$theme_my_login ) {
666
+ remove_role( 'pending' );
667
+ }
668
+
669
+ /**
670
+ * Initializes options for this module
671
+ *
672
+ * Callback for "tml_init_options" hook in method Theme_My_Login_Base::init_options()
673
+ *
674
+ * @see Theme_My_Login_Base::init_options()
675
+ * @since 6.0
676
+ * @access public
677
+ *
678
+ * @param array $options Options passd in from filter
679
+ * @return array Original $options array with module options appended
680
+ */
681
+ function init_options( $options = array() ) {
682
+ $options = (array) $options;
683
+
684
+ $options['moderation'] = array(
685
+ 'type' => 'none'
686
+ );
687
+ $options['email'] = array(
688
+ 'user_activation' => array(
689
+ 'mail_from' => '',
690
+ 'mail_from_name' => '',
691
+ 'mail_content_type' => '',
692
+ 'title' => '',
693
+ 'message' => ''
694
+ ),
695
+ 'user_approval' => array(
696
+ 'mail_from' => '',
697
+ 'mail_from_name' => '',
698
+ 'mail_content_type' => '',
699
+ 'title' => '',
700
+ 'message' => '',
701
+ 'admin_mail_to' => '',
702
+ 'admin_mail_from' => '',
703
+ 'admin_mail_from_name' => '',
704
+ 'admin_mail_content_type' => '',
705
+ 'admin_title' => '',
706
+ 'admin_message' => '',
707
+ 'admin_disable' => 0
708
+ ),
709
+ 'user_denial' => array(
710
+ 'mail_from' => '',
711
+ 'mail_from_name' => '',
712
+ 'mail_content_type' => '',
713
+ 'title' => '',
714
+ 'message' => ''
715
+ )
716
+ );
717
+ return $options;
718
+ }
719
+
720
+ /**
721
+ * Applies module actions and filters
722
+ *
723
+ * Callback for "tml_modules_loaded" in file "theme-my-login.php"
724
+ *
725
+ * @since 6.0
726
+ * @access public
727
+ *
728
+ * @param object $theme_my_login Reference to global $theme_my_login object
729
+ */
730
+ function modules_loaded() {
731
+ global $theme_my_login_custom_email;
732
+
733
+ // Shorthand reference
734
+ $theme_my_login =& $this->theme_my_login;
735
+
736
+ // Create a reference to global $theme_my_login_custom_email object
737
+ if ( is_a( $theme_my_login_custom_email, 'Theme_My_Login_Custom_Email' ) )
738
+ $this->theme_my_login_custom_email =& $theme_my_login_custom_email;
739
+
740
+ // Moderation is enabled
741
+ if ( in_array( $theme_my_login->options['moderation']['type'], array( 'admin', 'email' ) ) ) {
742
+ // Remove all other registration filters
743
+ add_action( 'register_post', array( &$this, 'register_post' ) );
744
+
745
+ // Redirect with proper message after registration
746
+ add_filter( 'register_redirect', array( &$this, 'register_redirect' ), 100 );
747
+
748
+ // Block pending users from logging in
749
+ add_action( 'authenticate', array( &$this, 'authenticate' ), 100, 3 );
750
+ // Block pending users from password reset
751
+ add_filter( 'allow_password_reset', array( &$this, 'allow_password_reset' ), 10, 2 );
752
+
753
+ // Call "tml_new_user_registered" hook on successful activation
754
+ add_action( 'tml_new_user_activated', array( &$this, 'new_user_activated' ), 10, 2 );
755
+
756
+ // Apply user approval e-mail filters
757
+ add_action( 'approve_user', array( &$this, 'apply_user_approval_notification_filters' ) );
758
+ // Apply user denial e-mail filters
759
+ add_action( 'deny_user', array( &$this, 'apply_user_denial_notification_filters' ) );
760
+
761
+ // Add activation action
762
+ if ( 'email' == $theme_my_login->options['moderation']['type'] ) {
763
+ add_action( 'tml_request_activate', array( &$this, 'user_activation' ) );
764
+ add_action( 'tml_request_sendactivation', array( &$this, 'send_activation' ) );
765
+ }
766
+ }
767
+ }
768
+
769
+ /**
770
+ * Loads the module
771
+ *
772
+ * @since 6.0
773
+ * @access public
774
+ */
775
+ function load() {
776
+ add_action( 'tml_activate_user-moderation/user-moderation.php', array( &$this, 'activate' ) );
777
+ add_action( 'tml_deactivate_user-moderation/user-moderation.php', array( &$this, 'deactivate' ) );
778
+ add_filter( 'tml_init_options', array( &$this, 'init_options' ) );
779
+ add_action( 'tml_modules_loaded', array( &$this, 'modules_loaded' ) );
780
+ add_action( 'tml_request', array( &$this, 'action_messages' ) );
781
+
782
+ add_role( 'pending', 'Pending', array() );
783
+ }
784
 
 
 
 
 
 
785
  }
786
+
787
+ /**
788
+ * Holds the reference to Theme_My_Login_User_Moderation object
789
+ * @global object $theme_my_login_user_moderation
790
+ * @since 6.0
791
+ */
792
+ $theme_my_login_user_moderation = new Theme_My_Login_User_Moderation();
793
+
794
+ if ( is_admin() )
795
+ include_once( TML_ABSPATH. '/modules/user-moderation/admin/user-moderation-admin.php' );
796
+
797
+ endif; // Class exists
798
+
799
+ ?>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: jfarthing84
3
  Donate link: http://www.jfarthing.com/donate
4
  Tags: widget, login, registration, theme, custom, log in, register, sidebar, gravatar, redirection, e-mail
5
  Requires at least: 2.8
6
- Tested up to: 3.0
7
- Stable tag: 5.1.6
8
 
9
  Themes the WordPress login pages according to your theme.
10
 
@@ -13,8 +13,6 @@ Themes the WordPress login pages according to your theme.
13
 
14
  This plugin themes the WordPress login, registration and forgot password pages according to your current theme. It replaces the wp-login.php file by using a page template from your theme. Also includes a widget for sidebar login.
15
 
16
- = NOTICE =
17
- Upgrading to version 5.0 will drop all previous options!
18
 
19
  = Features =
20
  * Your registration, log in, and password recovery pages will all match the rest of your website
@@ -33,16 +31,29 @@ Upgrading to version 5.0 will drop all previous options!
33
 
34
  1. Upload the plugin to your 'wp-content/plugins' directory
35
  1. Activate the plugin
36
- 1. Visit the [Theme My Login Official Usage Thread](http://www.jfarthing.com/forum/theme-my-login/theme-my-login-official-usage-thread/) for further instruction.
37
 
38
 
39
  == Frequently Asked Questions ==
40
 
41
- None yet. Please visit http://www.jfarthing.com/forum for any support!
42
 
43
 
44
  == Changelog ==
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  = 5.1.6 =
47
  * Fix issue with spaces in usernames
48
 
3
  Donate link: http://www.jfarthing.com/donate
4
  Tags: widget, login, registration, theme, custom, log in, register, sidebar, gravatar, redirection, e-mail
5
  Requires at least: 2.8
6
+ Tested up to: 3.0.1
7
+ Stable tag: 6.0
8
 
9
  Themes the WordPress login pages according to your theme.
10
 
13
 
14
  This plugin themes the WordPress login, registration and forgot password pages according to your current theme. It replaces the wp-login.php file by using a page template from your theme. Also includes a widget for sidebar login.
15
 
 
 
16
 
17
  = Features =
18
  * Your registration, log in, and password recovery pages will all match the rest of your website
31
 
32
  1. Upload the plugin to your 'wp-content/plugins' directory
33
  1. Activate the plugin
 
34
 
35
 
36
  == Frequently Asked Questions ==
37
 
38
+ Please visit http://www.jfarthing.com/support if you have any questions, concerns, suggestions or problems.
39
 
40
 
41
  == Changelog ==
42
 
43
+ = 6.0 =
44
+ * Complete code rewrite
45
+ * Users can now log in with e-mail address as well as username
46
+ * Remove option to disable template tag and widget in favor of always being enabled
47
+ * Remove option to rewrite login links in favor of always being rewritten
48
+ * Custom templates can now be defined per action (login, register, etc.)
49
+ * User moderation activation e-mails can be resent on demand
50
+ * Add various new hooks to help with custom integration with other plugins
51
+ * Make custom user links sortable
52
+ * Customize every aspect of every e-mail
53
+ * Add a cool new random tip widget in the TML admin
54
+ * Use WP 3.0 functions (such as 'network_site_url') if available
55
+ * phpDoc everywhere!
56
+
57
  = 5.1.6 =
58
  * Fix issue with spaces in usernames
59
 
templates/login-form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ If you would like to edit this file, copy it to your current theme's directory and edit it there.
4
+ Theme My Login will always look in your theme's directory first, before using this default template.
5
+ */
6
+ ?>
7
+ <div class="login" id="theme-my-login<?php $template->the_instance(); ?>">
8
+ <?php $template->the_action_template_message( 'login' ); ?>
9
+ <?php $template->the_errors(); ?>
10
+ <form name="loginform" id="loginform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'login' ); ?>" method="post">
11
+ <p>
12
+ <label for="log<?php $template->the_instance(); ?>"><?php _e( 'Username', 'theme-my-login' ) ?></label>
13
+ <input type="text" name="log" id="user_login<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'log' ); ?>" size="20" />
14
+ </p>
15
+ <p>
16
+ <label for="pwd<?php $template->the_instance(); ?>"><?php _e( 'Password', 'theme-my-login' ) ?></label>
17
+ <input type="password" name="pwd" id="user_pass<?php $template->the_instance(); ?>" class="input" value="" size="20" />
18
+ </p>
19
+ <?php
20
+ do_action( 'login_form' ); // Wordpress hook
21
+ do_action_ref_array( 'tml_login_form', array( &$template ) ); // TML hook
22
+ ?>
23
+ <p class="forgetmenot">
24
+ <input name="rememberme" type="checkbox" id="rememberme<?php $template->the_instance(); ?>" value="forever" />
25
+ <label for="rememberme<?php $template->the_instance(); ?>"><?php _e( 'Remember Me', 'theme-my-login' ); ?></label>
26
+ </p>
27
+ <p class="submit">
28
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php _e( 'Log In', 'theme-my-login' ); ?>" />
29
+ <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'login' ); ?>" />
30
+ <input type="hidden" name="testcookie" value="1" />
31
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
32
+ </p>
33
+ </form>
34
+ <?php $template->the_action_links( array( 'login' => false ) ); ?>
35
+ </div>
templates/lostpassword-form.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ If you would like to edit this file, copy it to your current theme's directory and edit it there.
4
+ Theme My Login will always look in your theme's directory first, before using this default template.
5
+ */
6
+ ?>
7
+ <div class="login" id="theme-my-login<?php $template->the_instance(); ?>">
8
+ <?php $template->the_action_template_message( 'lostpassword' ); ?>
9
+ <?php $template->the_errors(); ?>
10
+ <form name="lostpasswordform" id="lostpasswordform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'lostpassword' ); ?>" method="post">
11
+ <p>
12
+ <label for="user_login<?php $template->the_instance(); ?>"><?php _e( 'Username or E-mail:', 'theme-my-login' ) ?></label>
13
+ <input type="text" name="user_login" id="user_login<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'user_login' ); ?>" size="20" />
14
+ </p>
15
+ <?php
16
+ do_action( 'lostpassword_form' ); // Wordpress hook
17
+ do_action_ref_array( 'tml_lostpassword_form', array( &$template ) ); // TML hook
18
+ ?>
19
+ <p class="submit">
20
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php _e( 'Get New Password', 'theme-my-login' ); ?>" />
21
+ <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'lostpassword' ); ?>" />
22
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
23
+ </p>
24
+ </form>
25
+ <?php $template->the_action_links( array( 'lostpassword' => false ) ); ?>
26
+ </div>
templates/profile-form.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ If you would like to edit this file, copy it to your current theme's directory and edit it there.
4
+ Theme My Login will always look in your theme's directory first, before using this default template.
5
+ */
6
+
7
+ $GLOBALS['current_user'] = $current_user = wp_get_current_user();
8
+ $GLOBALS['profileuser'] = $profileuser = get_user_to_edit( $current_user->ID );
9
+ ?>
10
+
11
+ <div class="login profile" id="theme-my-login<?php $template->the_instance(); ?>">
12
+ <?php $template->the_action_template_message( 'profile' ); ?>
13
+ <?php $template->the_errors(); ?>
14
+ <form id="your-profile" action="" method="post">
15
+ <?php wp_nonce_field( 'update-user_' . $current_user->ID ) ?>
16
+ <p>
17
+ <input type="hidden" name="from" value="profile" />
18
+ <input type="hidden" name="checkuser_id" value="<?php echo $current_user->ID; ?>" />
19
+ </p>
20
+
21
+ <?php if ( has_filter( 'personal_options' ) || has_filter( 'profile_personal_options' ) ) : ?>
22
+ <h3><?php _e( 'Personal Options', $theme_my_login->textdomain ); ?></h3>
23
+
24
+ <table class="form-table">
25
+ <?php do_action( 'personal_options', $profileuser ); ?>
26
+ </table>
27
+ <?php do_action( 'profile_personal_options', $profileuser ); ?>
28
+ <?php endif; ?>
29
+
30
+ <h3><?php _e( 'Name', $theme_my_login->textdomain ) ?></h3>
31
+
32
+ <table class="form-table">
33
+ <tr>
34
+ <th><label for="user_login"><?php _e( 'Username', $theme_my_login->textdomain ); ?></label></th>
35
+ <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profileuser->user_login ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( 'Your username cannot be changed.', $theme_my_login->textdomain ); ?></span></td>
36
+ </tr>
37
+
38
+ <tr>
39
+ <th><label for="first_name"><?php _e( 'First name', $theme_my_login->textdomain ) ?></label></th>
40
+ <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ) ?>" class="regular-text" /></td>
41
+ </tr>
42
+
43
+ <tr>
44
+ <th><label for="last_name"><?php _e( 'Last name', $theme_my_login->textdomain ) ?></label></th>
45
+ <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ) ?>" class="regular-text" /></td>
46
+ </tr>
47
+
48
+ <tr>
49
+ <th><label for="nickname"><?php _e( 'Nickname', $theme_my_login->textdomain ); ?> <span class="description"><?php _e( '(required)', $theme_my_login->textdomain ); ?></span></label></th>
50
+ <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ) ?>" class="regular-text" /></td>
51
+ </tr>
52
+
53
+ <tr>
54
+ <th><label for="display_name"><?php _e( 'Display name publicly as', $theme_my_login->textdomain ) ?></label></th>
55
+ <td>
56
+ <select name="display_name" id="display_name">
57
+ <?php
58
+ $public_display = array();
59
+ $public_display['display_nickname'] = $profileuser->nickname;
60
+ $public_display['display_username'] = $profileuser->user_login;
61
+ if ( !empty( $profileuser->first_name ) )
62
+ $public_display['display_firstname'] = $profileuser->first_name;
63
+ if ( !empty( $profileuser->last_name ) )
64
+ $public_display['display_lastname'] = $profileuser->last_name;
65
+ if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) {
66
+ $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
67
+ $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
68
+ }
69
+ if ( !in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
70
+ $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
71
+ $public_display = array_map( 'trim', $public_display );
72
+ foreach ( $public_display as $id => $item ) {
73
+ $selected = ( $profileuser->display_name == $item ) ? ' selected="selected"' : '';
74
+ ?>
75
+ <option id="<?php echo $id; ?>" value="<?php echo esc_attr( $item ); ?>"<?php echo $selected; ?>><?php echo $item; ?></option>
76
+ <?php } ?>
77
+ </select>
78
+ </td>
79
+ </tr>
80
+ </table>
81
+
82
+ <h3><?php _e( 'Contact Info', $theme_my_login->textdomain ) ?></h3>
83
+
84
+ <table class="form-table">
85
+ <tr>
86
+ <th><label for="email"><?php _e( 'E-mail', $theme_my_login->textdomain ); ?> <span class="description"><?php _e( '(required)', $theme_my_login->textdomain ); ?></span></label></th>
87
+ <td><input type="text" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text" /></td>
88
+ </tr>
89
+
90
+ <tr>
91
+ <th><label for="url"><?php _e( 'Website', $theme_my_login->textdomain ) ?></label></th>
92
+ <td><input type="text" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td>
93
+ </tr>
94
+
95
+ <?php if ( function_exists( '_wp_get_user_contactmethods' ) ) :
96
+ foreach ( _wp_get_user_contactmethods() as $name => $desc ) {
97
+ ?>
98
+ <tr>
99
+ <th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_'.$name.'_label', $desc ); ?></label></th>
100
+ <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ) ?>" class="regular-text" /></td>
101
+ </tr>
102
+ <?php
103
+ }
104
+ endif;
105
+ ?>
106
+ </table>
107
+
108
+ <h3><?php _e( 'About Yourself', $theme_my_login->textdomain ); ?></h3>
109
+
110
+ <table class="form-table">
111
+ <tr>
112
+ <th><label for="description"><?php _e( 'Biographical Info', $theme_my_login->textdomain ); ?></label></th>
113
+ <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html( $profileuser->description ); ?></textarea><br />
114
+ <span class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.', $theme_my_login->textdomain ); ?></span></td>
115
+ </tr>
116
+
117
+ <?php
118
+ $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
119
+ if ( $show_password_fields ) :
120
+ ?>
121
+ <tr id="password">
122
+ <th><label for="pass1"><?php _e( 'New Password', $theme_my_login->textdomain ); ?></label></th>
123
+ <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e( 'If you would like to change the password type a new one. Otherwise leave this blank.', $theme_my_login->textdomain ); ?></span><br />
124
+ <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e( 'Type your new password again.', $theme_my_login->textdomain ); ?></span><br />
125
+ <div id="pass-strength-result"><?php _e( 'Strength indicator', $theme_my_login->textdomain ); ?></div>
126
+ <p class="description indicator-hint"><?php _e( 'Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).', $theme_my_login->textdomain ); ?></p>
127
+ </td>
128
+ </tr>
129
+ <?php endif; ?>
130
+ </table>
131
+
132
+ <?php
133
+ do_action( 'show_user_profile', $profileuser );
134
+ ?>
135
+
136
+ <?php if ( count( $profileuser->caps ) > count( $profileuser->roles ) && apply_filters( 'additional_capabilities_display', true, $profileuser ) ) { ?>
137
+ <br class="clear" />
138
+ <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
139
+ <tr>
140
+ <th scope="row"><?php _e( 'Additional Capabilities', $theme_my_login->textdomain ) ?></th>
141
+ <td><?php
142
+ $output = '';
143
+ global $wp_roles;
144
+ foreach ( $profileuser->caps as $cap => $value ) {
145
+ if ( !$wp_roles->is_role( $cap ) ) {
146
+ if ( $output != '' )
147
+ $output .= ', ';
148
+ $output .= $value ? $cap : "Denied: {$cap}";
149
+ }
150
+ }
151
+ echo $output;
152
+ ?></td>
153
+ </tr>
154
+ </table>
155
+ <?php } ?>
156
+
157
+ <p class="submit">
158
+ <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
159
+ <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Update Profile', $theme_my_login->textdomain ); ?>" name="submit" />
160
+ </p>
161
+ </form>
162
+ </div>
templates/register-form.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ If you would like to edit this file, copy it to your current theme's directory and edit it there.
4
+ Theme My Login will always look in your theme's directory first, before using this default template.
5
+ */
6
+ ?>
7
+ <div class="login" id="theme-my-login<?php $template->the_instance(); ?>">
8
+ <?php $template->the_action_template_message( 'register' ); ?>
9
+ <?php $template->the_errors(); ?>
10
+ <form name="registerform" id="registerform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'register' ); ?>" method="post">
11
+ <p>
12
+ <label for="user_login<?php $template->the_instance(); ?>"><?php _e( 'Username', 'theme-my-login' ) ?></label>
13
+ <input type="text" name="user_login" id="user_login<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'user_login' ); ?>" size="20" />
14
+ </p>
15
+ <p>
16
+ <label for="user_email<?php $template->the_instance(); ?>"><?php _e( 'E-mail', 'theme-my-login' ) ?></label>
17
+ <input type="text" name="user_email" id="user_email<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'user_email' ); ?>" size="20" />
18
+ </p>
19
+ <?php
20
+ do_action( 'register_form' ); // Wordpress hook
21
+ do_action_ref_array( 'tml_register_form', array( &$template ) ); //TML hook
22
+ ?>
23
+ <p id="reg_passmail<?php $template->the_instance(); ?>"><?php echo apply_filters( 'tml_register_passmail_template_message', __( 'A password will be e-mailed to you.', $theme_my_login->textdomain ) ); ?></p>
24
+ <p class="submit">
25
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php _e( 'Register', 'theme-my-login' ); ?>" />
26
+ <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'register' ); ?>" />
27
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
28
+ </p>
29
+ </form>
30
+ <?php $template->the_action_links( array( 'register' => false ) ); ?>
31
+ </div>
templates/resetpass-form.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ If you would like to edit this file, copy it to your current theme's directory and edit it there.
4
+ Theme My Login will always look in your theme's directory first, before using this default template.
5
+ */
6
+ ?>
7
+ <div class="login" id="theme-my-login<?php $template->the_instance(); ?>">
8
+ <?php $template->the_action_template_message( 'resetpass' ); ?>
9
+ <?php $template->the_errors(); ?>
10
+ <form name="resetpasswordform" id="resetpasswordform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'resetpass' ); ?>" method="post">
11
+ <p>
12
+ <label for="pass1<?php $template->the_instance(); ?>"><?php _e( 'New Password:', $theme_my_login->textdomain );?></label>
13
+ <input autocomplete="off" name="pass1" id="pass1<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" />
14
+ </p>
15
+ <p>
16
+ <label for="pass2<?php $template->the_instance(); ?>"><?php _e( 'Confirm Password:', $theme_my_login->textdomain );?></label>
17
+ <input autocomplete="off" name="pass2" id="pass2<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" />
18
+ </p>
19
+ <?php
20
+ do_action( 'resetpassword_form' ); // Wordpress hook
21
+ do_action_ref_array( 'tml_resetpassword_form', array( $template ) ); // TML hook
22
+ ?>
23
+ <p class="submit">
24
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php _e( 'Change Password', $theme_my_login->textdomain ); ?>" />
25
+ <input type="hidden" name="key" value="<?php $template->the_posted_value( 'key' ); ?>" />
26
+ <input type="hidden" name="login" value="<?php $template->the_posted_value( 'login' ); ?>" />
27
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
28
+ </p>
29
+ </form>
30
+ <?php $template->the_action_links( array( 'lost_password' => false ) ); ?>
31
+ </div>
templates/user-panel.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ If you would like to edit this file, copy it to your current theme's directory and edit it there.
4
+ Theme My Login will always look in your theme's directory first, before using this default template.
5
+ */
6
+ ?>
7
+ <div class="login" id="theme-my-login<?php $template->the_instance(); ?>">
8
+ <?php if ( $template->options['show_gravatar'] ) : ?>
9
+ <div class="tml-user-avatar"><?php $template->the_user_avatar(); ?></div>
10
+ <?php endif; ?>
11
+
12
+ <?php $this->the_user_links(); ?>
13
+
14
+ <?php do_action_ref_array( 'tml_user_panel', array( $template ) ); ?>
15
+ </div>
theme-my-login.php CHANGED
@@ -1,115 +1,104 @@
1
  <?php
2
  /*
3
  Plugin Name: Theme My Login
4
- Plugin URI: http://www.jfarthing.com/wordpress-plugins/theme-my-login
5
  Description: Themes the WordPress login, registration and forgot password pages according to your theme.
6
- Version: 5.1.6
7
  Author: Jeff Farthing
8
  Author URI: http://www.jfarthing.com
9
  Text Domain: theme-my-login
10
  */
11
 
12
- // Set the default module directory
13
- if ( !defined('TML_MODULE_DIR') )
14
- define('TML_MODULE_DIR', WP_PLUGIN_DIR . '/theme-my-login/modules');
 
 
 
 
15
 
16
- // Require global configuration class file
17
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/class.php' );
 
18
 
19
- // Declare $theme_my_login as global for use within functions
20
- global $theme_my_login;
 
 
 
 
 
21
 
22
- // Initialize global configuration class
23
- $theme_my_login = new Theme_My_Login();
 
 
 
 
 
24
 
25
- // Require general plugin functions file
26
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/functions.php' );
 
 
 
 
 
 
27
 
28
- // Load the plugin textdomain
29
- load_plugin_textdomain('theme-my-login', '', 'theme-my-login/language');
 
 
 
30
 
31
- // Load active modules
32
- wdbj_tml_load_active_modules();
 
 
 
 
33
 
34
- // Include admin-functions.php for install/uninstall process
35
- if ( is_admin() ) {
36
- require_once( WP_PLUGIN_DIR . '/theme-my-login/admin/includes/admin.php' );
37
- require_once( WP_PLUGIN_DIR . '/theme-my-login/admin/includes/module.php' );
38
-
39
- register_activation_hook(__FILE__, 'wdbj_tml_install');
40
- register_uninstall_hook(__FILE__, 'wdbj_tml_uninstall');
41
-
42
- add_action('admin_init', 'wdbj_tml_admin_init');
43
- add_action('admin_menu', 'wdbj_tml_admin_menu');
44
-
45
- // Display warning notices for function overrides
46
- if ( function_exists('wp_new_user_notification') )
47
- add_action('tml_settings_page', 'wdbj_tml_add_new_user_notification_override_notice');
48
- if ( function_exists('wp_password_change_notification') )
49
- add_action('tml_settings_page', 'wdbj_tml_add_password_change_notification_override_notice');
50
- }
51
 
52
- // Load pluggable functions after modules (in case a module needs to override a function)
53
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/pluggable-functions.php' );
 
 
54
 
55
- add_action('plugins_loaded', 'wdbj_tml_load');
56
- function wdbj_tml_load() {
57
- global $pagenow;
58
-
59
- // Bailout if we're at the default login
60
- if ( 'wp-login.php' == $pagenow )
61
- return;
62
-
63
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/hook-functions.php' );
64
-
65
- do_action('tml_load');
66
 
67
- add_action('template_redirect', 'wdbj_tml_template_redirect');
68
-
69
- add_filter('the_title', 'wdbj_tml_the_title', 10, 2);
70
- add_filter('single_post_title', 'wdbj_tml_single_post_title');
71
-
72
- if ( wdbj_tml_get_option('rewrite_links') )
73
- add_filter('site_url', 'wdbj_tml_site_url', 10, 3);
74
-
75
- add_filter('wp_list_pages_excludes', 'wdbj_tml_list_pages_excludes');
76
- add_filter('wp_list_pages', 'wdbj_tml_list_pages');
77
- add_filter('page_link', 'wdbj_tml_page_link', 10, 2);
78
-
79
- add_filter('wp_setup_nav_menu_item', 'wdbj_tml_setup_nav_menu_item');
80
-
81
- add_shortcode('theme-my-login-page', 'wdbj_tml_page_shortcode');
82
- add_shortcode('theme-my-login', 'wdbj_tml_shortcode');
83
-
84
- if ( wdbj_tml_get_option('enable_widget') ) {
85
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/widget.php' );
86
- add_action('widgets_init', 'wdbj_tml_register_widget');
87
- function wdbj_tml_register_widget() {
88
- return register_widget("Theme_My_Login_Widget");
89
- }
90
- }
91
  }
92
 
93
- function wdbj_tml_template_redirect() {
94
- if ( is_page(wdbj_tml_get_option('page_id')) || wdbj_tml_get_option('enable_template_tag') || is_active_widget(false, null, 'theme-my-login') ) {
95
-
96
- wdbj_tml_set_error();
97
-
98
- do_action('tml_init');
99
-
100
- if ( wdbj_tml_get_option('enable_css') )
101
- wdbj_tml_get_css();
102
-
103
- require_once( WP_PLUGIN_DIR . '/theme-my-login/includes/login-actions.php' );
104
- }
105
- }
106
 
107
- // Template tag
108
- function theme_my_login($args = '') {
109
- if ( ! wdbj_tml_get_option('enable_template_tag') )
110
- return false;
111
- $args = wp_parse_args($args);
112
- echo wdbj_tml_shortcode($args);
 
 
 
 
 
113
  }
 
114
 
115
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Theme My Login
4
+ Plugin URI: http://www.jfarthing.com/wordpress-plugins/theme-my-login/
5
  Description: Themes the WordPress login, registration and forgot password pages according to your theme.
6
+ Version: 6.0
7
  Author: Jeff Farthing
8
  Author URI: http://www.jfarthing.com
9
  Text Domain: theme-my-login
10
  */
11
 
12
+ /*
13
+ * = Future Ideas =
14
+ * ----------------------------------------------------------------------
15
+ * Allow separate permalinks for login, register and lostpassword
16
+ * Allow users to delete themselves
17
+ * Add option to forward all "wp-login.php" requests to TML login page
18
+ */
19
 
20
+ // Allow custom functions file
21
+ if ( file_exists( WP_PLUGIN_DIR . '/theme-my-login-custom.php' ) )
22
+ include_once( WP_PLUGIN_DIR . '/theme-my-login-custom.php' );
23
 
24
+ /**
25
+ * Holds the absolute location of Theme My Login
26
+ *
27
+ * @since 6.0
28
+ */
29
+ if ( !defined( 'TML_ABSPATH' ) )
30
+ define( 'TML_ABSPATH', dirname( __FILE__ ) );
31
 
32
+ /**
33
+ * Holds the name of the Theme My Login directory
34
+ *
35
+ * @since 6.0
36
+ */
37
+ if ( !defined( 'TML_DIRNAME' ) )
38
+ define( 'TML_DIRNAME', basename( TML_ABSPATH ) );
39
 
40
+ /**
41
+ * For developers, setting this to true will output useful debug information
42
+ * such as memory usage at specific hooks.
43
+ *
44
+ * @since 6.0
45
+ */
46
+ if ( !defined( 'TML_DEBUG' ) )
47
+ define( 'TML_DEBUG', false );
48
 
49
+ // Require a few needed files
50
+ require_once( TML_ABSPATH . '/includes/class-theme-my-login.php' );
51
+ require_once( TML_ABSPATH . '/includes/class-theme-my-login-template.php' );
52
+ require_once( TML_ABSPATH . '/includes/class-theme-my-login-module.php' );
53
+ require_once( TML_ABSPATH . '/includes/class-theme-my-login-widget.php' );
54
 
55
+ /**
56
+ * Theme My Login object
57
+ * @global object $theme_my_login_object
58
+ * @since 6.0
59
+ */
60
+ $GLOBALS['theme_my_login_object'] =& new Theme_My_Login();
61
 
62
+ /**
63
+ * Holds the reference to @see $theme_my_login_object
64
+ * Use this global for interfacing
65
+ * @global object $theme_my_login
66
+ * @since 1.0
67
+ */
68
+ $GLOBALS['theme_my_login'] =& $GLOBALS['theme_my_login_object'];
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Load active modules
71
+ foreach ( $GLOBALS['theme_my_login']->get_active_and_valid_modules() as $module )
72
+ include_once( $module );
73
+ unset( $module );
74
 
75
+ do_action( 'tml_modules_loaded' );
 
 
 
 
 
 
 
 
 
 
76
 
77
+ if ( is_admin() ) {
78
+ require_once( TML_ABSPATH . '/admin/class-theme-my-login-admin.php' );
79
+ /**
80
+ * Theme My Login Admin object
81
+ * @global object $theme_my_login_admin
82
+ * @since 6.0
83
+ */
84
+ $GLOBALS['theme_my_login_admin'] =& new Theme_My_Login_Admin();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
+ if ( defined( 'TML_DEBUG' ) && TML_DEBUG )
88
+ include_once( TML_ABSPATH . '/includes/class-theme-my-login-debug.php' );
 
 
 
 
 
 
 
 
 
 
 
89
 
90
+ if ( !function_exists( 'theme_my_login' ) ) :
91
+ /**
92
+ * Displays a TML instance
93
+ *
94
+ * @see Theme_My_Login::shortcode() for $args parameters
95
+ * @since 6.0
96
+ *
97
+ * @param string|array $args Template tag arguments
98
+ */
99
+ function theme_my_login( $args = '' ) {
100
+ echo $GLOBALS['theme_my_login']->shortcode( $args );
101
  }
102
+ endif;
103
 
104
  ?>